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

Function generate_readonly_getter

mypyc/codegen/emitclass.py:1234–1257  ·  view source on GitHub ↗
(
    cl: ClassIR, attr: str, rtype: RType, func_ir: FuncIR, emitter: Emitter
)

Source from the content-addressed store, hash-verified

1232
1233
1234def generate_readonly_getter(
1235 cl: ClassIR, attr: str, rtype: RType, func_ir: FuncIR, emitter: Emitter
1236) -> None:
1237 emitter.emit_line("static PyObject *")
1238 emitter.emit_line(
1239 "{}({} *self, void *closure)".format(
1240 getter_name(cl, attr, emitter.names), cl.struct_name(emitter.names)
1241 )
1242 )
1243 emitter.emit_line("{")
1244 if rtype.is_unboxed:
1245 emitter.emit_line(
1246 "{}retval = {}{}((PyObject *) self);".format(
1247 emitter.ctype_spaced(rtype), NATIVE_PREFIX, func_ir.cname(emitter.names)
1248 )
1249 )
1250 emitter.emit_error_check("retval", rtype, "return NULL;")
1251 emitter.emit_box("retval", "retbox", rtype, declare_dest=True)
1252 emitter.emit_line("return retbox;")
1253 else:
1254 emitter.emit_line(
1255 f"return {NATIVE_PREFIX}{func_ir.cname(emitter.names)}((PyObject *) self);"
1256 )
1257 emitter.emit_line("}")
1258
1259
1260def generate_property_setter(

Callers 1

generate_getsetersFunction · 0.85

Calls 8

getter_nameFunction · 0.85
ctype_spacedMethod · 0.80
emit_error_checkMethod · 0.80
emit_boxMethod · 0.80
emit_lineMethod · 0.45
formatMethod · 0.45
struct_nameMethod · 0.45
cnameMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…