Decode a ``LeanObj`` (raw ``lean_object*``) as a registered inductive. This is the entry point for Path B (tactic): Lean wraps an ``Expr`` via ``Py.ofLeanObj``, Python receives a ``LeanObj``, and this method walks the runtime representation using the type's registry metadata
(self, type_name: str, lean_obj: LeanObj)
| 619 | # -- public -------------------------------------------------------------- |
| 620 | |
| 621 | def decode_lean_obj(self, type_name: str, lean_obj: LeanObj) -> LeanInductiveValue: |
| 622 | """Decode a ``LeanObj`` (raw ``lean_object*``) as a registered inductive. |
| 623 | |
| 624 | This is the entry point for Path B (tactic): Lean wraps an ``Expr`` |
| 625 | via ``Py.ofLeanObj``, Python receives a ``LeanObj``, and this method |
| 626 | walks the runtime representation using the type's registry metadata. |
| 627 | """ |
| 628 | ti = self.registry.find_type(type_name) |
| 629 | if ti is None: |
| 630 | raise ValueError(f"Type {type_name!r} not found in registry") |
| 631 | # Borrow: _decode_inductive reads fields via lean_ctor_get (borrowed |
| 632 | # pointers) and lean_inc's each child, so we don't consume the handle. |
| 633 | self.ffi.lean_inc(lean_obj.ptr) |
| 634 | return self._decode_inductive(ti, lean_obj.ptr) |
| 635 | |
| 636 | def wrapper_for(self, t: TypeRepr) -> TypeWrapper: |
| 637 | key = self._key(t) |
no test coverage detected