forked from bartvdbraak/blender
8d2cb5bea4
This changes how the BGE classes and Python work together, which hasnt changed since blender went opensource. The main difference is PyObjectPlus - the base class for most game engine classes, no longer inherit from PyObject, and cannot be cast to a PyObject. This has the advantage that the BGE does not have to keep 2 reference counts valid for C++ and Python. Previously C++ classes would never be freed while python held a reference, however this reference could be problematic eg: a GameObject that isnt in a scene anymore should not be used by python, doing so could even crash blender in some cases. Instead PyObjectPlus has a member "PyObject *m_proxy" which is lazily initialized when python needs it. m_proxy reference counts are managed by python, though it should never be freed while the C++ class exists since it holds a reference to avoid making and freeing it all the time. When the C++ class is free'd it sets the m_proxy reference to NULL, If python accesses this variable it will raise a RuntimeError, (check the isValid attribute to see if its valid without raising an error). - This replaces the m_zombie bool and IsZombie() tests added recently. In python return values that used to be.. return value->AddRef(); Are now return value->GetProxy(); or... return value->NewProxy(true); // true means python owns this C++ value which will be deleted when the PyObject is freed |
||
---|---|---|
.. | ||
BoolValue.cpp | ||
BoolValue.h | ||
CMakeLists.txt | ||
ConstExpr.cpp | ||
ConstExpr.h | ||
EmptyValue.cpp | ||
EmptyValue.h | ||
ErrorValue.cpp | ||
ErrorValue.h | ||
EXP_C-Api.cpp | ||
EXP_C-Api.h | ||
Expression.cpp | ||
Expression.h | ||
FloatValue.cpp | ||
FloatValue.h | ||
IdentifierExpr.cpp | ||
IdentifierExpr.h | ||
IfExpr.cpp | ||
IfExpr.h | ||
InputParser.cpp | ||
InputParser.h | ||
IntValue.cpp | ||
IntValue.h | ||
KX_HashedPtr.cpp | ||
KX_HashedPtr.h | ||
KX_Python_dynamic.h | ||
KX_Python_static.h | ||
KX_Python.h | ||
ListValue.cpp | ||
ListValue.h | ||
Makefile | ||
Operator1Expr.cpp | ||
Operator1Expr.h | ||
Operator2Expr.cpp | ||
Operator2Expr.h | ||
PyObjectPlus.cpp | ||
PyObjectPlus.h | ||
SConscript | ||
StringValue.cpp | ||
StringValue.h | ||
Value.cpp | ||
Value.h | ||
VectorValue.cpp | ||
VectorValue.h | ||
VoidValue.h |