4747 'Clear out in file once out file is written' )
4848flags .DEFINE_string ('import_module' , None ,
4949 'Change DllImport module to this value' )
50+ flags .DEFINE_boolean ('static_k_removal' , False ,
51+ 'Whether to remove public static attributes k initial' )
5052
5153
5254def get_dll_import_transformation ():
@@ -63,6 +65,20 @@ def get_dll_import_transformation():
6365 ]
6466
6567
68+ def get_static_k_removal_transformation ():
69+ """Gets the transforms to remove k initial for public static attribute
70+
71+ Returns:
72+ list of static k removal transformations.
73+ """
74+ if not FLAGS .static_k_removal :
75+ return []
76+
77+ return [
78+ swig_post_process .StaticFunctionKInitRemoval ()
79+ ]
80+
81+
6682class NamespaceCMethodsCMake (swig_post_process .SWIGPostProcessingInterface ):
6783 """Add a module namespace prefix to all generated C methods."""
6884
@@ -146,7 +162,8 @@ def get_transformations(namespace):
146162 swig_post_process .RenameAsyncMethods (),
147163 swig_post_process .RenameArgsFromSnakeToCamelCase (),
148164 swig_post_process .AddPInvokeAttribute (),
149- ] + get_dll_import_transformation (),
165+ ] + get_dll_import_transformation ()
166+ + get_static_k_removal_transformation (),
150167 }
151168
152169
@@ -166,7 +183,7 @@ def main(argv): # pylint: disable=unused-argument
166183 logging .warning ('Empty input file "%s"' , FLAGS .in_file )
167184 return 0
168185
169- new_contents = swig_post_process .apply_post_process (contents , '' , processes )
186+ new_contents = swig_post_process .apply_post_process (contents , FLAGS . in_file , processes )
170187
171188 with open (FLAGS .out_file , 'w' ) as out_file :
172189 out_file .write (new_contents )
0 commit comments