MCPcopy Index your code
hub / github.com/python/mypy / generate_module_def

Method generate_module_def

mypyc/codegen/emitmodule.py:1106–1124  ·  view source on GitHub ↗

Emit the PyModuleDef struct for a module and the module init function.

(self, emitter: Emitter, module_name: str, module: ModuleIR)

Source from the content-addressed store, hash-verified

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."""
1108 module_prefix = emitter.names.private_name(module_name)
1109 self.emit_module_methods(emitter, module_name, module_prefix, module)
1110 self.emit_module_exec_func(emitter, module_name, module_prefix, module)
1111
1112 # If using multi-phase init and a shared lib, parts of module definition
1113 # will happen in the shim modules, so we skip some steps here.
1114 if not (self.multi_phase_init and self.use_shared_lib):
1115 if self.multi_phase_init:
1116 self.emit_module_def_slots(emitter, module_prefix, module_name)
1117 self.emit_module_def_struct(emitter, module_name, module_prefix)
1118 self.emit_module_init_func(emitter, module_name, module_prefix)
1119 elif self.use_shared_lib:
1120 # Multi-phase init with shared lib: shims handle PyInit_*, but we
1121 # still need CPyInitOnly_* for same-group native imports, and the
1122 # PyModuleDef struct it depends on.
1123 self.emit_module_def_struct(emitter, module_name, module_prefix)
1124 self.emit_init_only_func(emitter, module_name, module_prefix)
1125
1126 def emit_module_def_slots(
1127 self, emitter: Emitter, module_prefix: str, module_name: str

Callers 1

Calls 7

emit_module_methodsMethod · 0.95
emit_module_exec_funcMethod · 0.95
emit_module_def_slotsMethod · 0.95
emit_module_init_funcMethod · 0.95
emit_init_only_funcMethod · 0.95
private_nameMethod · 0.80

Tested by

no test coverage detected