MCPcopy Create free account
hub / github.com/BasisResearch/lean.py / _make_struct

Function _make_struct

lean_py/_runtime.py:180–193  ·  view source on GitHub ↗

Create a ctypes Structure subclass dynamically.

(sdef: StructDef, known: dict[str, type])

Source from the content-addressed store, hash-verified

178
179
180def _make_struct(sdef: StructDef, known: dict[str, type]) -> type:
181 """Create a ctypes Structure subclass dynamically."""
182 fields = []
183 for f in sdef.fields:
184 ct = _resolve_type(f.c_type, known)
185 if ct is None:
186 ct = c_void_p
187 if f.bitfield is not None:
188 fields.append((f.name, ct, f.bitfield))
189 else:
190 fields.append((f.name, ct)) # type: ignore[arg-type]
191
192 cls = type(sdef.name, (Structure,), {"_fields_": fields})
193 return cls
194
195
196# ============================================================================

Callers 1

_build_structsFunction · 0.85

Calls 1

_resolve_typeFunction · 0.85

Tested by

no test coverage detected