* lean_py_of_lean_obj: wrap any lean_object* as a Python LeanObjHandle, * then return it as a Lean Py (external class wrapping PyObject*). * * @[extern "lean_py_of_lean_obj"] * opaque Py.ofLeanObj (obj : @& α) : IO Py */
| 1174 | |
| 1175 | /* ---- Lean-facing FFI ------------------------------------------------- */ |
| 1176 | |
| 1177 | /* |
| 1178 | * lean_py_of_lean_obj: wrap any lean_object* as a Python LeanObjHandle, |
| 1179 | * then return it as a Lean Py (external class wrapping PyObject*). |
| 1180 | * |
| 1181 | * @[extern "lean_py_of_lean_obj"] |
| 1182 | * opaque Py.ofLeanObj (obj : @& α) : IO Py |
| 1183 | */ |
| 1184 | LEAN_EXPORT lean_obj_res lean_py_of_lean_obj(b_lean_obj_arg obj, lean_obj_arg world) { |
| 1185 | (void)world; |
| 1186 | ENSURE_INIT(); WITH_GIL(); |
| 1187 | |
| 1188 | PyObject *type = get_lean_obj_handle_type(); |
| 1189 | if (!type) return raise_io_error("LeanPy: failed to create LeanObjHandle type"); |
| 1190 | |
| 1191 | PyObject *inst = p_PyType_GenericAlloc(type, 0); |
| 1192 | if (!inst) return raise_py_error(); |
| 1193 | |
| 1194 | LeanObjHandle *h = (LeanObjHandle *)inst; |
nothing calls this directly
no test coverage detected