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

Method tuple_c_declaration

mypyc/codegen/emit.py:413–432  ·  view source on GitHub ↗
(self, rtuple: RTuple)

Source from the content-addressed store, hash-verified

411 return f"{self.get_group_prefix(fn)}{PREFIX}{fn.cname(self.names)}"
412
413 def tuple_c_declaration(self, rtuple: RTuple) -> list[str]:
414 result = [
415 f"#ifndef MYPYC_DECLARED_{rtuple.struct_name}",
416 f"#define MYPYC_DECLARED_{rtuple.struct_name}",
417 f"typedef struct {rtuple.struct_name} {{",
418 ]
419 if len(rtuple.types) == 0: # empty tuple
420 # Empty tuples contain a flag so that they can still indicate
421 # error values.
422 result.append("int empty_struct_error_flag;")
423 else:
424 i = 0
425 for typ in rtuple.types:
426 result.append(f"{self.ctype_spaced(typ)}f{i};")
427 i += 1
428 result.append(f"}} {rtuple.struct_name};")
429 result.append("#endif")
430 result.append("")
431
432 return result
433
434 def bitmap_field(self, index: int) -> str:
435 """Return C field name used for attribute bitmap."""

Callers 1

declare_tuple_structMethod · 0.95

Calls 3

ctype_spacedMethod · 0.95
lenFunction · 0.85
appendMethod · 0.80

Tested by

no test coverage detected