(self, emitter: Emitter)
| 1083 | ) |
| 1084 | |
| 1085 | def generate_globals_init(self, emitter: Emitter) -> None: |
| 1086 | emitter.emit_lines( |
| 1087 | "", |
| 1088 | "int CPyGlobalsInit(void)", |
| 1089 | "{", |
| 1090 | "static int is_initialized = 0;", |
| 1091 | "if (is_initialized) return 0;", |
| 1092 | "", |
| 1093 | ) |
| 1094 | |
| 1095 | emitter.emit_line("CPy_Init();") |
| 1096 | for symbol, fixup in self.simple_inits: |
| 1097 | emitter.emit_line(f"{symbol} = {fixup};") |
| 1098 | |
| 1099 | values = "CPyLit_Str, CPyLit_Bytes, CPyLit_Int, CPyLit_Float, CPyLit_Complex, CPyLit_Tuple, CPyLit_FrozenSet" |
| 1100 | emitter.emit_lines( |
| 1101 | f"if (CPyStatics_Initialize(CPyStatics, {values}) < 0) {{", "return -1;", "}" |
| 1102 | ) |
| 1103 | |
| 1104 | emitter.emit_lines("is_initialized = 1;", "return 0;", "}") |
| 1105 | |
| 1106 | def generate_module_def(self, emitter: Emitter, module_name: str, module: ModuleIR) -> None: |
| 1107 | """Emit the PyModuleDef struct for a module and the module init function.""" |
no test coverage detected