Skip to content

Commit 5f29a48

Browse files
Joe-DownsJoseph Downs
authored andcommitted
WIP: generate callback function prototypes
1 parent c5d5f30 commit 5f29a48

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

ompi/mpi/bindings/ompi_bindings/c_header.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,23 @@ def output_constant(const, use_enum):
6464
output.append(line)
6565

6666
# ============================= Function Prototypes ============================
67+
# TODO: we need to add/fix/figure out the pympistandard's way for properly
68+
# defining callback functions
69+
def cb_declaration(proc_expression):
70+
func_str = str(proc_expression).replace(r"\ldots", "...")
71+
func_str_list = func_str.split()
72+
func_name, arg_1 = func_str_list[2].split("(")
73+
return f"{' '.join(func_str_list[:2])} ({func_name})({arg_1} {' '.join(func_str_list[3:])};\n"
74+
6775
std.use_api_version()
6876

77+
output.append("\n")
78+
output.append("/* Callback functions */\n")
79+
for proc in std.CALLBACKS.values():
80+
output.append(cb_declaration(proc.express.iso_c))
81+
if proc.has_embiggenment():
82+
output.append(cb_declaration(proc.express.embiggen.iso_c))
83+
6984
output.append("\n")
7085
output.append("/* MPI API */\n")
7186
for proc in std.all_iso_c_procedures():

0 commit comments

Comments
 (0)