115115# TODO: we need to add/fix/figure out the pympistandard's way for properly
116116# defining callback functions
117117def cb_declaration (proc_expression ):
118- func_str = str (proc_expression ). replace ( r"\ldots" , "..." )
118+ func_str = str (proc_expression )
119119 func_str_list = func_str .split ()
120120 func_name , arg_1 = func_str_list [2 ].split ("(" )
121+ if MANGLE_NAMES :
122+ func_name = f"{ func_name } { ABI_INTERNAL } "
121123 decl_string = f"{ ' ' .join (func_str_list [:2 ])} ({ func_name } )({ arg_1 } { ' ' .join (func_str_list [3 :])} ;\n "
122124 return decl_string
123125
124126def output_constant (const , use_enum : bool , mangle_name : bool ):
127+ spacing = 45
125128 name = const ["name" ]
126129 abi_value = const ["abi_value" ]
127130 c_type = const ["handle_types" ]["c" ]["type" ]
128131 if c_type is None :
129132 return None
130133 if mangle_name :
131134 name = f"{ name } { ABI_INTERNAL } "
132- c_type = f"{ c_type } { ABI_INTERNAL } "
135+ spacing = 55
136+ #c_type = f"{c_type}{ABI_INTERNAL}"
133137 def_name = f"#define { name } "
134138 if use_enum :
135139 def_name = f" { name } "
@@ -138,7 +142,7 @@ def output_constant(const, use_enum: bool, mangle_name: bool):
138142 value = f"{ abi_value } "
139143 else :
140144 value = f"(({ c_type } ) { abi_value } )"
141- return def_name + " " * (45 - len (def_name )) + value + "\n "
145+ return def_name + " " * (spacing - len (def_name ) + 1 ) + value + "\n "
142146
143147# ========================= Manipulate Template Header =========================
144148lines = []
@@ -208,17 +212,16 @@ def output_constant(const, use_enum: bool, mangle_name: bool):
208212""" )
209213output .append ("#endif /* _ABI_INTERNAL_ */" )
210214
211- # Iterate through all lines and replace datatypes with their internal ABI
212- # counterparts
213- if MANGLE_NAMES :
214- for i , line in enumerate (output ):
215- mangled_line = line
215+ for i , line in enumerate (output ):
216+ line = line .replace (r"\ldots" , "..." )
217+ if MANGLE_NAMES :
218+ # Replace datatypes with their internal ABI counterparts
216219 for datatype in INTERNAL_DATATYPES :
217220 # Need to include the extra space here or else we'll edit functions
218221 # like "MPI_Group_difference"
219- datatype_pattern = r"([\( ]?)(" + datatype + r")([; \*]{1})"
220- mangled_line = re .sub (datatype_pattern , f"\\ g<1>\\ g<2>{ ABI_INTERNAL } \\ g<3>" , mangled_line )
221- output [i ] = mangled_line
222+ datatype_pattern = r"([\( ]?)(" + datatype + r")([; \*\) ]{1})"
223+ line = re .sub (datatype_pattern , f"\\ g<1>\\ g<2>{ ABI_INTERNAL } \\ g<3>" , line )
224+ output [i ] = line
222225
223226with open (OUTPUT , 'tw' ) as header_out :
224227 header_out .writelines (output )
0 commit comments