Files
AVA2/shared/common/PortPythonPointer.h
shenleiandClaude Opus 5.5 9077aa389a AVA2 client Windows parity passes (gr2 BitKnit2/64-bit, GamePhase handlers, python modules)
- gr2: BitKnit2 decompression, 64-bit LE files, compressed curves
- net: remaining GamePhase handlers, generated GC packet table
- python: event/chat/chr/minimap/guild/quest/messenger/shop-search and
  other native modules ported against the AVA2 Windows client
- render: D3D8 fixed-function lighting in Gr2ModelRenderer, terrain
  without baked shade; cape/NPC equipment attachment
- tests + audits updated; docs/PORT-PLAN.md and WINDOWS-PARITY.md

Batch 4 (render pipeline: background.*, app.RenderGame/UpdateGame,
camera bindings, main.cpp fake-content removal) is still in progress.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-08 10:43:01 +09:00

36 lines
1.1 KiB
C++

#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;
// A ScriptLib call may leave an error set while returning None (Py_BuildException with a
// message, e.g. a missing image). AVA2 ScriptLib PyTuple_GetInteger ignores that stale error, so
// only judge this conversion and leave the earlier error as it was.
PyObject *type, *error, *traceback;
PyErr_Fetch(&type, &error, &traceback);
void* pointer = PyLong_AsVoidPtr(value);
const bool failed = PyErr_Occurred() != nullptr;
if (failed)
PyErr_Clear();
PyErr_Restore(type, error, traceback);
if (failed)
return false;
*out = static_cast<T*>(pointer);
return true;
}