Port 2V0 UI Python bindings and app module link surface

This commit is contained in:
shen
2026-09-22 19:57:35 -07:00
parent a0ad587f78
commit b221a9eaf5
74 changed files with 18320 additions and 9 deletions
@@ -0,0 +1,26 @@
#pragma once
#include <Python.h>
// The 40250 Python API represents native handles as integers. Keep that API while allowing a
// 64-bit pointer to survive the round trip on macOS and mobile builds.
template <typename T>
PyObject* Py_BuildPointer(T* pointer)
{
return PyLong_FromVoidPtr(static_cast<void*>(pointer));
}
template <typename T>
bool PyTuple_GetPointer(PyObject* args, int position, T** out)
{
if (position < 0 || position >= PyTuple_Size(args))
return false;
PyObject* value = PyTuple_GetItem(args, position);
if (!value)
return false;
void* pointer = PyLong_AsVoidPtr(value);
if (PyErr_Occurred())
return false;
*out = static_cast<T*>(pointer);
return true;
}