Emit the static module definition struct (PyModuleDef).
(
self, emitter: Emitter, module_name: str, module_prefix: str
)
| 1174 | emitter.emit_line() |
| 1175 | |
| 1176 | def emit_module_def_struct( |
| 1177 | self, emitter: Emitter, module_name: str, module_prefix: str |
| 1178 | ) -> None: |
| 1179 | """Emit the static module definition struct (PyModuleDef).""" |
| 1180 | emitter.emit_lines( |
| 1181 | f"static struct PyModuleDef {module_prefix}module = {{", |
| 1182 | "PyModuleDef_HEAD_INIT,", |
| 1183 | f'"{module_name}",', |
| 1184 | "NULL, /* docstring */", |
| 1185 | "0, /* size of per-interpreter state of the module */", |
| 1186 | ) |
| 1187 | if self.multi_phase_init: |
| 1188 | # Methods are added later via PyModule_AddFunctions in CPyExec_*. |
| 1189 | emitter.emit_line("NULL, /* m_methods */") |
| 1190 | else: |
| 1191 | emitter.emit_line(f"{module_prefix}module_methods,") |
| 1192 | if self.multi_phase_init and not self.use_shared_lib: |
| 1193 | slots_name = f"{module_prefix}_slots" |
| 1194 | emitter.emit_line(f"{slots_name}, /* m_slots */") |
| 1195 | else: |
| 1196 | emitter.emit_line("NULL,") |
| 1197 | emitter.emit_line("};") |
| 1198 | emitter.emit_line() |
| 1199 | |
| 1200 | def emit_coroutine_wrappers(self, emitter: Emitter, module: ModuleIR, globals: str) -> None: |
| 1201 | """Emit insertion of coroutines into the module dict when the module is initialized. |
no test coverage detected