Python BGE API
- Initialize python types with PyType_Ready, which adds methods to the type dictionary. - use Pythons get/setattro (uses a python string for the attribute rather then char*). Using basic C strings seems nice but internally python converts them to python strings and discards them for most functions that accept char arrays. - Method lookups use the PyTypes dictionary (should be faster then Py_FindMethod) - Renamed __getattr -> py_base_getattro, _getattr -> py_getattro, __repr -> py_base_repr, py_delattro, py_getattro_self etc. From here is possible to put all the parent classes methods into each python types dictionary to avoid nested lookups (api has 4 levels of lookups in some places), tested this but its not ready yet. Simple tests for getting a method within a loop show this to be between 0.5 and 3.2x faster then using Py_FindMethod()
This commit is contained in:
@@ -965,18 +965,21 @@ KX_PYMETHODDEF_DOC(BL_ActionActuator, setChannel,
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
PyTypeObject BL_ActionActuator::Type = {
|
||||
PyObject_HEAD_INIT(&PyType_Type)
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0,
|
||||
"BL_ActionActuator",
|
||||
sizeof(BL_ActionActuator),
|
||||
0,
|
||||
PyDestructor,
|
||||
0,
|
||||
__getattr,
|
||||
__setattr,
|
||||
0,
|
||||
__repr,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,
|
||||
0,
|
||||
py_base_repr,
|
||||
0,0,0,0,0,0,
|
||||
py_base_getattro,
|
||||
py_base_setattro,
|
||||
0,0,0,0,0,0,0,0,0,
|
||||
Methods
|
||||
};
|
||||
|
||||
@@ -1032,17 +1035,20 @@ PyAttributeDef BL_ActionActuator::Attributes[] = {
|
||||
{ NULL } //Sentinel
|
||||
};
|
||||
|
||||
PyObject* BL_ActionActuator::_getattr(const char *attr) {
|
||||
if (!strcmp(attr, "action"))
|
||||
PyObject* BL_ActionActuator::py_getattro(PyObject *attr) {
|
||||
char *attr_str= PyString_AsString(attr);
|
||||
if (!strcmp(attr_str, "action"))
|
||||
return PyString_FromString(m_action->id.name+2);
|
||||
PyObject* object = _getattr_self(Attributes, this, attr);
|
||||
|
||||
PyObject* object = py_getattro_self(Attributes, this, attr);
|
||||
if (object != NULL)
|
||||
return object;
|
||||
_getattr_up(SCA_IActuator);
|
||||
py_getattro_up(SCA_IActuator);
|
||||
}
|
||||
|
||||
int BL_ActionActuator::_setattr(const char *attr, PyObject* value) {
|
||||
if (!strcmp(attr, "action"))
|
||||
int BL_ActionActuator::py_setattro(PyObject *attr, PyObject* value) {
|
||||
char *attr_str= PyString_AsString(attr);
|
||||
if (!strcmp(attr_str, "action"))
|
||||
{
|
||||
if (!PyString_Check(value))
|
||||
{
|
||||
@@ -1072,8 +1078,8 @@ int BL_ActionActuator::_setattr(const char *attr, PyObject* value) {
|
||||
m_action = action;
|
||||
return 0;
|
||||
}
|
||||
int ret = _setattr_self(Attributes, this, attr, value);
|
||||
int ret = py_setattro_self(Attributes, this, attr, value);
|
||||
if (ret >= 0)
|
||||
return ret;
|
||||
return SCA_IActuator::_setattr(attr, value);
|
||||
return SCA_IActuator::py_setattro(attr, value);
|
||||
}
|
@@ -110,8 +110,8 @@ public:
|
||||
|
||||
KX_PYMETHOD_DOC(BL_ActionActuator,setChannel);
|
||||
|
||||
virtual PyObject* _getattr(const char *attr);
|
||||
virtual int _setattr(const char *attr, PyObject* value);
|
||||
virtual PyObject* py_getattro(PyObject* attr);
|
||||
virtual int py_setattro(PyObject* attr, PyObject* value);
|
||||
|
||||
/* attribute check */
|
||||
static int CheckFrame(void *self, const PyAttributeDef*)
|
||||
|
@@ -420,18 +420,21 @@ bool BL_ShapeActionActuator::Update(double curtime, bool frame)
|
||||
/* Integration hooks ------------------------------------------------------- */
|
||||
|
||||
PyTypeObject BL_ShapeActionActuator::Type = {
|
||||
PyObject_HEAD_INIT(&PyType_Type)
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0,
|
||||
"BL_ShapeActionActuator",
|
||||
sizeof(BL_ShapeActionActuator),
|
||||
0,
|
||||
PyDestructor,
|
||||
0,
|
||||
__getattr,
|
||||
__setattr,
|
||||
0, //&MyPyCompare,
|
||||
__repr,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
py_base_repr,
|
||||
0,0,0,0,0,0,
|
||||
py_base_getattro,
|
||||
py_base_setattro,
|
||||
0,0,0,0,0,0,0,0,0,
|
||||
Methods
|
||||
};
|
||||
|
||||
@@ -481,17 +484,19 @@ PyAttributeDef BL_ShapeActionActuator::Attributes[] = {
|
||||
};
|
||||
|
||||
|
||||
PyObject* BL_ShapeActionActuator::_getattr(const char *attr) {
|
||||
if (!strcmp(attr, "action"))
|
||||
PyObject* BL_ShapeActionActuator::py_getattro(PyObject* attr) {
|
||||
char *attr_str= PyString_AsString(attr);
|
||||
if (!strcmp(attr_str, "action"))
|
||||
return PyString_FromString(m_action->id.name+2);
|
||||
PyObject* object = _getattr_self(Attributes, this, attr);
|
||||
PyObject* object = py_getattro_self(Attributes, this, attr);
|
||||
if (object != NULL)
|
||||
return object;
|
||||
_getattr_up(SCA_IActuator);
|
||||
py_getattro_up(SCA_IActuator);
|
||||
}
|
||||
|
||||
int BL_ShapeActionActuator::_setattr(const char *attr, PyObject* value) {
|
||||
if (!strcmp(attr, "action"))
|
||||
int BL_ShapeActionActuator::py_setattro(PyObject *attr, PyObject* value) {
|
||||
char *attr_str= PyString_AsString(attr);
|
||||
if (!strcmp(attr_str, "action"))
|
||||
{
|
||||
if (!PyString_Check(value))
|
||||
{
|
||||
@@ -521,10 +526,10 @@ int BL_ShapeActionActuator::_setattr(const char *attr, PyObject* value) {
|
||||
m_action = action;
|
||||
return 0;
|
||||
}
|
||||
int ret = _setattr_self(Attributes, this, attr, value);
|
||||
int ret = py_setattro_self(Attributes, this, attr, value);
|
||||
if (ret >= 0)
|
||||
return ret;
|
||||
return SCA_IActuator::_setattr(attr, value);
|
||||
return SCA_IActuator::py_setattro(attr, value);
|
||||
}
|
||||
|
||||
/* setStart */
|
||||
|
@@ -103,8 +103,8 @@ public:
|
||||
KX_PYMETHOD_DOC_NOARGS(BL_ShapeActionActuator,GetType);
|
||||
KX_PYMETHOD_DOC(BL_ShapeActionActuator,SetType);
|
||||
|
||||
virtual PyObject* _getattr(const char *attr);
|
||||
virtual int _setattr(const char *attr, PyObject* value);
|
||||
virtual PyObject* py_getattro(PyObject* attr);
|
||||
virtual int py_setattro(PyObject* attr, PyObject* value);
|
||||
|
||||
static int CheckBlendTime(void *self, const PyAttributeDef*)
|
||||
{
|
||||
|
@@ -193,7 +193,7 @@ static PyMappingMethods instance_as_mapping = {
|
||||
|
||||
|
||||
PyTypeObject CListValue::Type = {
|
||||
PyObject_HEAD_INIT(&PyType_Type)
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0, /*ob_size*/
|
||||
"CListValue", /*tp_name*/
|
||||
sizeof(CListValue), /*tp_basicsize*/
|
||||
@@ -201,16 +201,19 @@ PyTypeObject CListValue::Type = {
|
||||
/* methods */
|
||||
PyDestructor, /*tp_dealloc*/
|
||||
0, /*tp_print*/
|
||||
__getattr, /*tp_getattr*/
|
||||
__setattr, /*tp_setattr*/
|
||||
0, /*tp_getattr*/
|
||||
0, /*tp_setattr*/
|
||||
0, /*tp_compare*/
|
||||
__repr, /*tp_repr*/
|
||||
py_base_repr, /*tp_repr*/
|
||||
0, /*tp_as_number*/
|
||||
&listvalue_as_sequence, /*tp_as_sequence*/
|
||||
&instance_as_mapping, /*tp_as_mapping*/
|
||||
0, /*tp_hash*/
|
||||
0, /*tp_call */
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,
|
||||
py_base_getattro,
|
||||
py_base_setattro,
|
||||
0,0,0,0,0,0,0,0,0,
|
||||
Methods
|
||||
};
|
||||
|
||||
@@ -238,8 +241,8 @@ PyAttributeDef CListValue::Attributes[] = {
|
||||
{ NULL } //Sentinel
|
||||
};
|
||||
|
||||
PyObject* CListValue::_getattr(const char *attr) {
|
||||
_getattr_up(CValue);
|
||||
PyObject* CListValue::py_getattro(PyObject* attr) {
|
||||
py_getattro_up(CValue);
|
||||
}
|
||||
|
||||
|
||||
|
@@ -59,7 +59,7 @@ public:
|
||||
|
||||
bool CheckEqual(CValue* first,CValue* second);
|
||||
|
||||
virtual PyObject* _getattr(const char *attr);
|
||||
virtual PyObject* py_getattro(PyObject* attr);
|
||||
|
||||
KX_PYMETHOD_O(CListValue,append);
|
||||
KX_PYMETHOD_NOARGS(CListValue,reverse);
|
||||
|
@@ -55,19 +55,22 @@
|
||||
------------------------------*/
|
||||
|
||||
PyTypeObject PyObjectPlus::Type = {
|
||||
PyObject_HEAD_INIT(&PyType_Type)
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0, /*ob_size*/
|
||||
"PyObjectPlus", /*tp_name*/
|
||||
sizeof(PyObjectPlus), /*tp_basicsize*/
|
||||
0, /*tp_itemsize*/
|
||||
/* methods */
|
||||
PyDestructor, /*tp_dealloc*/
|
||||
0, /*tp_print*/
|
||||
__getattr, /*tp_getattr*/
|
||||
__setattr, /*tp_setattr*/
|
||||
0, /*tp_compare*/
|
||||
__repr,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
PyDestructor,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
py_base_repr,
|
||||
0,0,0,0,0,0,
|
||||
py_base_getattro,
|
||||
py_base_setattro,
|
||||
0,0,0,0,0,0,0,0,0,
|
||||
Methods
|
||||
};
|
||||
|
||||
@@ -103,37 +106,41 @@ PyParentObject PyObjectPlus::Parents[] = {&PyObjectPlus::Type, NULL};
|
||||
/*------------------------------
|
||||
* PyObjectPlus attributes -- attributes
|
||||
------------------------------*/
|
||||
PyObject *PyObjectPlus::_getattr(const char *attr)
|
||||
PyObject *PyObjectPlus::py_getattro(PyObject* attr)
|
||||
{
|
||||
if (!strcmp(attr, "__doc__") && GetType()->tp_doc)
|
||||
return PyString_FromString(GetType()->tp_doc);
|
||||
|
||||
PyObject *descr = PyDict_GetItem(Type.tp_dict, attr); \
|
||||
if (descr == NULL) {
|
||||
PyErr_SetString(PyExc_AttributeError, "attribute not found");
|
||||
return NULL;
|
||||
} else {
|
||||
return PyCFunction_New(((PyMethodDescrObject *)descr)->d_method, (PyObject *)this); \
|
||||
}
|
||||
//if (streq(attr, "type"))
|
||||
// return Py_BuildValue("s", (*(GetParents()))->tp_name);
|
||||
|
||||
return Py_FindMethod(Methods, this, attr);
|
||||
}
|
||||
|
||||
int PyObjectPlus::_delattr(const char *attr)
|
||||
int PyObjectPlus::py_delattro(PyObject* attr)
|
||||
{
|
||||
PyErr_SetString(PyExc_AttributeError, "attribute cant be deleted");
|
||||
return 1;
|
||||
}
|
||||
|
||||
int PyObjectPlus::_setattr(const char *attr, PyObject *value)
|
||||
int PyObjectPlus::py_setattro(PyObject *attr, PyObject* value)
|
||||
{
|
||||
//return PyObject::_setattr(attr,value);
|
||||
//return PyObject::py_setattro(attr,value);
|
||||
//cerr << "Unknown attribute" << endl;
|
||||
PyErr_SetString(PyExc_AttributeError, "attribute cant be set");
|
||||
return 1;
|
||||
}
|
||||
|
||||
PyObject *PyObjectPlus::_getattr_self(const PyAttributeDef attrlist[], void *self, const char *attr)
|
||||
PyObject *PyObjectPlus::py_getattro_self(const PyAttributeDef attrlist[], void *self, PyObject *attr)
|
||||
{
|
||||
char *attr_str= PyString_AsString(attr);
|
||||
|
||||
const PyAttributeDef *attrdef;
|
||||
for (attrdef=attrlist; attrdef->m_name != NULL; attrdef++)
|
||||
{
|
||||
if (!strcmp(attr, attrdef->m_name))
|
||||
if (!strcmp(attr_str, attrdef->m_name))
|
||||
{
|
||||
if (attrdef->m_type == KX_PYATTRIBUTE_TYPE_DUMMY)
|
||||
{
|
||||
@@ -242,16 +249,17 @@ PyObject *PyObjectPlus::_getattr_self(const PyAttributeDef attrlist[], void *sel
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int PyObjectPlus::_setattr_self(const PyAttributeDef attrlist[], void *self, const char *attr, PyObject *value)
|
||||
int PyObjectPlus::py_setattro_self(const PyAttributeDef attrlist[], void *self, PyObject *attr, PyObject *value)
|
||||
{
|
||||
const PyAttributeDef *attrdef;
|
||||
void *undoBuffer = NULL;
|
||||
void *sourceBuffer = NULL;
|
||||
size_t bufferSize = 0;
|
||||
char *attr_str= PyString_AsString(attr);
|
||||
|
||||
for (attrdef=attrlist; attrdef->m_name != NULL; attrdef++)
|
||||
{
|
||||
if (!strcmp(attr, attrdef->m_name))
|
||||
if (!strcmp(attr_str, attrdef->m_name))
|
||||
{
|
||||
if (attrdef->m_access == KX_PYATTRIBUTE_RO ||
|
||||
attrdef->m_type == KX_PYATTRIBUTE_TYPE_DUMMY)
|
||||
@@ -684,7 +692,7 @@ int PyObjectPlus::_setattr_self(const PyAttributeDef attrlist[], void *self, con
|
||||
/*------------------------------
|
||||
* PyObjectPlus repr -- representations
|
||||
------------------------------*/
|
||||
PyObject *PyObjectPlus::_repr(void)
|
||||
PyObject *PyObjectPlus::py_repr(void)
|
||||
{
|
||||
PyErr_SetString(PyExc_SystemError, "Representation not overridden by object.");
|
||||
return NULL;
|
||||
@@ -726,7 +734,7 @@ PyObject *PyObjectPlus::Py_isA(PyObject *value) // Python wrapper for isA
|
||||
Py_RETURN_FALSE;
|
||||
}
|
||||
|
||||
/* Utility function called by the macro _getattr_up()
|
||||
/* Utility function called by the macro py_getattro_up()
|
||||
* for getting ob.__dict__() values from our PyObject
|
||||
* this is used by python for doing dir() on an object, so its good
|
||||
* if we return a list of attributes and methods.
|
||||
|
@@ -72,6 +72,8 @@ typedef int Py_ssize_t;
|
||||
#define PY_METHODCHAR const char *
|
||||
#endif
|
||||
|
||||
#include "descrobject.h"
|
||||
|
||||
static inline void Py_Fatal(const char *M) {
|
||||
fprintf(stderr, "%s\n", M);
|
||||
exit(-1);
|
||||
@@ -90,21 +92,27 @@ static inline void Py_Fatal(const char *M) {
|
||||
|
||||
|
||||
|
||||
// This defines the _getattr_up macro
|
||||
// This defines the py_getattro_up macro
|
||||
// which allows attribute and method calls
|
||||
// to be properly passed up the hierarchy.
|
||||
#define _getattr_up(Parent) \
|
||||
PyObject *rvalue = Py_FindMethod(Methods, this, attr); \
|
||||
|
||||
#define py_getattro_up(Parent) \
|
||||
PyObject *rvalue; \
|
||||
PyObject *descr = PyDict_GetItem(Type.tp_dict, attr); \
|
||||
\
|
||||
if (rvalue == NULL) { \
|
||||
if (descr == NULL) { \
|
||||
PyErr_Clear(); \
|
||||
rvalue = Parent::_getattr(attr); \
|
||||
rvalue = Parent::py_getattro(attr); \
|
||||
} else { \
|
||||
rvalue= PyCFunction_New(((PyMethodDescrObject *)descr)->d_method, (PyObject *)this); \
|
||||
} \
|
||||
if (strcmp(attr, "__dict__")==0) {\
|
||||
\
|
||||
if (strcmp(PyString_AsString(attr), "__dict__")==0) {\
|
||||
rvalue = _getattr_dict(rvalue, Methods, Attributes); \
|
||||
} \
|
||||
return rvalue; \
|
||||
|
||||
|
||||
/**
|
||||
* These macros are helpfull when embedding Python routines. The second
|
||||
* macro is one that also requires a documentation string
|
||||
@@ -361,29 +369,29 @@ public:
|
||||
// Py_DECREF(this);
|
||||
// }; // decref method
|
||||
|
||||
virtual PyObject *_getattr(const char *attr); // _getattr method
|
||||
static PyObject *__getattr(PyObject * PyObj, char *attr) // This should be the entry in Type.
|
||||
virtual PyObject *py_getattro(PyObject *attr); // py_getattro method
|
||||
static PyObject *py_base_getattro(PyObject * PyObj, PyObject *attr) // This should be the entry in Type.
|
||||
{
|
||||
return ((PyObjectPlus*) PyObj)->_getattr(attr);
|
||||
return ((PyObjectPlus*) PyObj)->py_getattro(attr);
|
||||
}
|
||||
static PyObject *_getattr_self(const PyAttributeDef attrlist[], void *self, const char *attr);
|
||||
static int _setattr_self(const PyAttributeDef attrlist[], void *self, const char *attr, PyObject *value);
|
||||
static PyObject *py_getattro_self(const PyAttributeDef attrlist[], void *self, PyObject *attr);
|
||||
static int py_setattro_self(const PyAttributeDef attrlist[], void *self, PyObject *attr, PyObject *value);
|
||||
|
||||
virtual int _delattr(const char *attr);
|
||||
virtual int _setattr(const char *attr, PyObject *value); // _setattr method
|
||||
static int __setattr(PyObject *PyObj, // This should be the entry in Type.
|
||||
char *attr,
|
||||
virtual int py_delattro(PyObject *attr);
|
||||
virtual int py_setattro(PyObject *attr, PyObject *value); // py_setattro method
|
||||
static int py_base_setattro(PyObject *PyObj, // This should be the entry in Type.
|
||||
PyObject *attr,
|
||||
PyObject *value)
|
||||
{
|
||||
if (!value)
|
||||
return ((PyObjectPlus*) PyObj)->_delattr(attr);
|
||||
return ((PyObjectPlus*) PyObj)->_setattr(attr, value);
|
||||
if (value==NULL)
|
||||
return ((PyObjectPlus*) PyObj)->py_delattro(attr);
|
||||
return ((PyObjectPlus*) PyObj)->py_setattro(attr, value);
|
||||
}
|
||||
|
||||
virtual PyObject *_repr(void); // _repr method
|
||||
static PyObject *__repr(PyObject *PyObj) // This should be the entry in Type.
|
||||
virtual PyObject *py_repr(void); // py_repr method
|
||||
static PyObject *py_base_repr(PyObject *PyObj) // This should be the entry in Type.
|
||||
{
|
||||
return ((PyObjectPlus*) PyObj)->_repr();
|
||||
return ((PyObjectPlus*) PyObj)->py_repr();
|
||||
}
|
||||
|
||||
// isA methods
|
||||
|
@@ -139,19 +139,22 @@ static PyNumberMethods cvalue_as_number = {
|
||||
|
||||
|
||||
PyTypeObject CValue::Type = {
|
||||
PyObject_HEAD_INIT(&PyType_Type)
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0,
|
||||
"CValue",
|
||||
sizeof(CValue),
|
||||
0,
|
||||
PyDestructor,
|
||||
0,
|
||||
__getattr,
|
||||
__setattr,
|
||||
0,
|
||||
0,
|
||||
&MyPyCompare,
|
||||
__repr,
|
||||
py_base_repr,
|
||||
&cvalue_as_number,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,
|
||||
py_base_getattro,
|
||||
py_base_setattro,
|
||||
0,0,0,0,0,0,0,0,0,
|
||||
Methods
|
||||
};
|
||||
|
||||
@@ -695,9 +698,10 @@ PyAttributeDef CValue::Attributes[] = {
|
||||
};
|
||||
|
||||
|
||||
PyObject* CValue::_getattr(const char *attr)
|
||||
PyObject* CValue::py_getattro(PyObject *attr)
|
||||
{
|
||||
CValue* resultattr = GetProperty(attr);
|
||||
char *attr_str= PyString_AsString(attr);
|
||||
CValue* resultattr = GetProperty(attr_str);
|
||||
if (resultattr)
|
||||
{
|
||||
PyObject* pyconvert = resultattr->ConvertValueToPython();
|
||||
@@ -707,7 +711,7 @@ PyObject* CValue::_getattr(const char *attr)
|
||||
else
|
||||
return resultattr; // also check if it's already in pythoninterpreter!
|
||||
}
|
||||
_getattr_up(PyObjectPlus);
|
||||
py_getattro_up(PyObjectPlus);
|
||||
}
|
||||
|
||||
CValue* CValue::ConvertPythonToValue(PyObject* pyobj)
|
||||
@@ -769,26 +773,28 @@ CValue* CValue::ConvertPythonToValue(PyObject* pyobj)
|
||||
|
||||
}
|
||||
|
||||
int CValue::_delattr(const char *attr)
|
||||
int CValue::py_delattro(PyObject *attr)
|
||||
{
|
||||
if (RemoveProperty(STR_String(attr)))
|
||||
char *attr_str= PyString_AsString(attr);
|
||||
if (RemoveProperty(STR_String(attr_str)))
|
||||
return 0;
|
||||
|
||||
PyErr_Format(PyExc_AttributeError, "attribute \"%s\" dosnt exist", attr);
|
||||
PyErr_Format(PyExc_AttributeError, "attribute \"%s\" dosnt exist", attr_str);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int CValue::_setattr(const char *attr, PyObject* pyobj)
|
||||
int CValue::py_setattro(PyObject *attr, PyObject* pyobj)
|
||||
{
|
||||
CValue* vallie = ConvertPythonToValue(pyobj);
|
||||
if (vallie)
|
||||
{
|
||||
CValue* oldprop = GetProperty(attr);
|
||||
char *attr_str= PyString_AsString(attr);
|
||||
CValue* oldprop = GetProperty(attr_str);
|
||||
|
||||
if (oldprop)
|
||||
oldprop->SetValue(vallie);
|
||||
else
|
||||
SetProperty(attr, vallie);
|
||||
SetProperty(attr_str, vallie);
|
||||
|
||||
vallie->Release();
|
||||
} else
|
||||
@@ -796,7 +802,7 @@ int CValue::_setattr(const char *attr, PyObject* pyobj)
|
||||
return 1; /* ConvertPythonToValue sets the error message */
|
||||
}
|
||||
|
||||
//PyObjectPlus::_setattr(attr,value);
|
||||
//PyObjectPlus::py_setattro(attr,value);
|
||||
return 0;
|
||||
};
|
||||
|
||||
|
@@ -217,14 +217,14 @@ public:
|
||||
|
||||
CValue(PyTypeObject *T = &Type);
|
||||
//static PyObject* PyMake(PyObject*,PyObject*);
|
||||
virtual PyObject *_repr(void)
|
||||
virtual PyObject *py_repr(void)
|
||||
{
|
||||
return Py_BuildValue("s",(const char*)GetText());
|
||||
}
|
||||
|
||||
|
||||
|
||||
virtual PyObject* _getattr(const char *attr);
|
||||
virtual PyObject* py_getattro(PyObject *attr);
|
||||
|
||||
void SpecialRelease()
|
||||
{
|
||||
@@ -251,8 +251,8 @@ public:
|
||||
virtual CValue* ConvertPythonToValue(PyObject* pyobj);
|
||||
|
||||
|
||||
virtual int _delattr(const char *attr);
|
||||
virtual int _setattr(const char *attr, PyObject* value);
|
||||
virtual int py_delattro(PyObject *attr);
|
||||
virtual int py_setattro(PyObject *attr, PyObject* value);
|
||||
|
||||
virtual PyObject* ConvertKeysToPython( void );
|
||||
|
||||
|
@@ -80,18 +80,21 @@ bool SCA_2DFilterActuator::Update()
|
||||
|
||||
|
||||
PyTypeObject SCA_2DFilterActuator::Type = {
|
||||
PyObject_HEAD_INIT(&PyType_Type)
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0,
|
||||
"SCA_2DFilterActuator",
|
||||
sizeof(SCA_2DFilterActuator),
|
||||
0,
|
||||
PyDestructor,
|
||||
0,
|
||||
__getattr,
|
||||
__setattr,
|
||||
0,
|
||||
__repr,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,
|
||||
0,
|
||||
py_base_repr,
|
||||
0,0,0,0,0,0,
|
||||
py_base_getattro,
|
||||
py_base_setattro,
|
||||
0,0,0,0,0,0,0,0,0,
|
||||
Methods
|
||||
};
|
||||
|
||||
@@ -114,6 +117,6 @@ PyAttributeDef SCA_2DFilterActuator::Attributes[] = {
|
||||
{ NULL } //Sentinel
|
||||
};
|
||||
|
||||
PyObject* SCA_2DFilterActuator::_getattr(const char *attr) {
|
||||
_getattr_up(SCA_IActuator);
|
||||
PyObject* SCA_2DFilterActuator::py_getattro(PyObject *attr) {
|
||||
py_getattro_up(SCA_IActuator);
|
||||
}
|
||||
|
@@ -38,7 +38,7 @@ public:
|
||||
virtual bool Update();
|
||||
|
||||
virtual CValue* GetReplica();
|
||||
virtual PyObject* _getattr(const char *attr);
|
||||
virtual PyObject* py_getattro(PyObject *attr);
|
||||
|
||||
};
|
||||
#endif
|
||||
|
@@ -107,18 +107,21 @@ CValue* SCA_ANDController::GetReplica()
|
||||
|
||||
/* Integration hooks ------------------------------------------------------- */
|
||||
PyTypeObject SCA_ANDController::Type = {
|
||||
PyObject_HEAD_INIT(&PyType_Type)
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0,
|
||||
"SCA_ANDController",
|
||||
sizeof(SCA_ANDController),
|
||||
0,
|
||||
PyDestructor,
|
||||
0,
|
||||
__getattr,
|
||||
__setattr,
|
||||
0,
|
||||
__repr,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,
|
||||
0,
|
||||
py_base_repr,
|
||||
0,0,0,0,0,0,
|
||||
py_base_getattro,
|
||||
py_base_setattro,
|
||||
0,0,0,0,0,0,0,0,0,
|
||||
Methods
|
||||
};
|
||||
|
||||
@@ -138,8 +141,8 @@ PyAttributeDef SCA_ANDController::Attributes[] = {
|
||||
{ NULL } //Sentinel
|
||||
};
|
||||
|
||||
PyObject* SCA_ANDController::_getattr(const char *attr) {
|
||||
_getattr_up(SCA_IController);
|
||||
PyObject* SCA_ANDController::py_getattro(PyObject *attr) {
|
||||
py_getattro_up(SCA_IController);
|
||||
}
|
||||
|
||||
/* eof */
|
||||
|
@@ -48,7 +48,7 @@ public:
|
||||
/* Python interface ---------------------------------------------------- */
|
||||
/* --------------------------------------------------------------------- */
|
||||
|
||||
virtual PyObject* _getattr(const char *attr);
|
||||
virtual PyObject* py_getattro(PyObject *attr);
|
||||
|
||||
};
|
||||
|
||||
|
@@ -122,18 +122,21 @@ void SCA_ActuatorSensor::Update()
|
||||
|
||||
/* Integration hooks ------------------------------------------------------- */
|
||||
PyTypeObject SCA_ActuatorSensor::Type = {
|
||||
PyObject_HEAD_INIT(&PyType_Type)
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0,
|
||||
"SCA_ActuatorSensor",
|
||||
sizeof(SCA_ActuatorSensor),
|
||||
0,
|
||||
PyDestructor,
|
||||
0,
|
||||
__getattr,
|
||||
__setattr,
|
||||
0,
|
||||
__repr,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,
|
||||
0,
|
||||
py_base_repr,
|
||||
0,0,0,0,0,0,
|
||||
py_base_getattro,
|
||||
py_base_setattro,
|
||||
0,0,0,0,0,0,0,0,0,
|
||||
Methods
|
||||
};
|
||||
|
||||
@@ -158,11 +161,11 @@ PyAttributeDef SCA_ActuatorSensor::Attributes[] = {
|
||||
{ NULL } //Sentinel
|
||||
};
|
||||
|
||||
PyObject* SCA_ActuatorSensor::_getattr(const char *attr) {
|
||||
PyObject* object = _getattr_self(Attributes, this, attr);
|
||||
PyObject* SCA_ActuatorSensor::py_getattro(PyObject *attr) {
|
||||
PyObject* object = py_getattro_self(Attributes, this, attr);
|
||||
if (object != NULL)
|
||||
return object;
|
||||
_getattr_up(SCA_ISensor); /* implicit return! */
|
||||
py_getattro_up(SCA_ISensor); /* implicit return! */
|
||||
}
|
||||
|
||||
int SCA_ActuatorSensor::CheckActuator(void *self, const PyAttributeDef*)
|
||||
@@ -177,11 +180,11 @@ int SCA_ActuatorSensor::CheckActuator(void *self, const PyAttributeDef*)
|
||||
return 1;
|
||||
}
|
||||
|
||||
int SCA_ActuatorSensor::_setattr(const char *attr, PyObject *value) {
|
||||
int ret = _setattr_self(Attributes, this, attr, value);
|
||||
int SCA_ActuatorSensor::py_setattro(PyObject *attr, PyObject *value) {
|
||||
int ret = py_setattro_self(Attributes, this, attr, value);
|
||||
if (ret >= 0)
|
||||
return ret;
|
||||
return SCA_ISensor::_setattr(attr, value);
|
||||
return SCA_ISensor::py_setattro(attr, value);
|
||||
}
|
||||
|
||||
/* 3. getActuator */
|
||||
|
@@ -61,8 +61,8 @@ public:
|
||||
/* Python interface ---------------------------------------------------- */
|
||||
/* --------------------------------------------------------------------- */
|
||||
|
||||
virtual PyObject* _getattr(const char *attr);
|
||||
virtual int _setattr(const char *attr, PyObject *value);
|
||||
virtual PyObject* py_getattro(PyObject *attr);
|
||||
virtual int py_setattro(PyObject *attr, PyObject *value);
|
||||
|
||||
/* 3. setProperty */
|
||||
KX_PYMETHOD_DOC(SCA_ActuatorSensor,SetActuator);
|
||||
|
@@ -105,18 +105,21 @@ bool SCA_AlwaysSensor::Evaluate(CValue* event)
|
||||
|
||||
/* Integration hooks ------------------------------------------------------- */
|
||||
PyTypeObject SCA_AlwaysSensor::Type = {
|
||||
PyObject_HEAD_INIT(&PyType_Type)
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0,
|
||||
"SCA_AlwaysSensor",
|
||||
sizeof(SCA_AlwaysSensor),
|
||||
0,
|
||||
PyDestructor,
|
||||
0,
|
||||
__getattr,
|
||||
__setattr,
|
||||
0, //&MyPyCompare,
|
||||
__repr,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
py_base_repr,
|
||||
0,0,0,0,0,0,
|
||||
py_base_getattro,
|
||||
py_base_setattro,
|
||||
0,0,0,0,0,0,0,0,0,
|
||||
Methods
|
||||
};
|
||||
|
||||
@@ -136,8 +139,8 @@ PyAttributeDef SCA_AlwaysSensor::Attributes[] = {
|
||||
{ NULL } //Sentinel
|
||||
};
|
||||
|
||||
PyObject* SCA_AlwaysSensor::_getattr(const char *attr) {
|
||||
_getattr_up(SCA_ISensor);
|
||||
PyObject* SCA_AlwaysSensor::py_getattro(PyObject *attr) {
|
||||
py_getattro_up(SCA_ISensor);
|
||||
}
|
||||
|
||||
/* eof */
|
||||
|
@@ -52,7 +52,7 @@ public:
|
||||
/* Python interface ---------------------------------------------------- */
|
||||
/* --------------------------------------------------------------------- */
|
||||
|
||||
virtual PyObject* _getattr(const char *attr);
|
||||
virtual PyObject* py_getattro(PyObject *attr);
|
||||
|
||||
|
||||
};
|
||||
|
@@ -131,18 +131,21 @@ bool SCA_DelaySensor::Evaluate(CValue* event)
|
||||
|
||||
/* Integration hooks ------------------------------------------------------- */
|
||||
PyTypeObject SCA_DelaySensor::Type = {
|
||||
PyObject_HEAD_INIT(&PyType_Type)
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0,
|
||||
"SCA_DelaySensor",
|
||||
sizeof(SCA_DelaySensor),
|
||||
0,
|
||||
PyDestructor,
|
||||
0,
|
||||
__getattr,
|
||||
__setattr,
|
||||
0, //&MyPyCompare,
|
||||
__repr,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
py_base_repr,
|
||||
0,0,0,0,0,0,
|
||||
py_base_getattro,
|
||||
py_base_setattro,
|
||||
0,0,0,0,0,0,0,0,0,
|
||||
Methods
|
||||
};
|
||||
|
||||
@@ -175,18 +178,18 @@ PyAttributeDef SCA_DelaySensor::Attributes[] = {
|
||||
{ NULL } //Sentinel
|
||||
};
|
||||
|
||||
PyObject* SCA_DelaySensor::_getattr(const char *attr) {
|
||||
PyObject* object = _getattr_self(Attributes, this, attr);
|
||||
PyObject* SCA_DelaySensor::py_getattro(PyObject *attr) {
|
||||
PyObject* object = py_getattro_self(Attributes, this, attr);
|
||||
if (object != NULL)
|
||||
return object;
|
||||
_getattr_up(SCA_ISensor);
|
||||
py_getattro_up(SCA_ISensor);
|
||||
}
|
||||
|
||||
int SCA_DelaySensor::_setattr(const char *attr, PyObject *value) {
|
||||
int ret = _setattr_self(Attributes, this, attr, value);
|
||||
int SCA_DelaySensor::py_setattro(PyObject *attr, PyObject *value) {
|
||||
int ret = py_setattro_self(Attributes, this, attr, value);
|
||||
if (ret >= 0)
|
||||
return ret;
|
||||
return SCA_ISensor::_setattr(attr, value);
|
||||
return SCA_ISensor::py_setattro(attr, value);
|
||||
}
|
||||
|
||||
|
||||
|
@@ -60,8 +60,8 @@ public:
|
||||
/* Python interface ---------------------------------------------------- */
|
||||
/* --------------------------------------------------------------------- */
|
||||
|
||||
virtual PyObject* _getattr(const char *attr);
|
||||
virtual int _setattr(const char *attr, PyObject *value);
|
||||
virtual PyObject* py_getattro(PyObject *attr);
|
||||
virtual int py_setattro(PyObject *attr, PyObject *value);
|
||||
|
||||
/* setProperty */
|
||||
KX_PYMETHOD_DOC(SCA_DelaySensor,SetDelay);
|
||||
|
@@ -59,7 +59,7 @@ public:
|
||||
/* Python interface ---------------------------------------------------- */
|
||||
/* --------------------------------------------------------------------- */
|
||||
|
||||
// virtual PyObject* _getattr(const char *attr);
|
||||
// virtual PyObject* py_getattro(PyObject *attr);
|
||||
|
||||
};
|
||||
|
||||
|
@@ -217,18 +217,21 @@ CValue* SCA_ILogicBrick::GetEvent()
|
||||
/* python stuff */
|
||||
|
||||
PyTypeObject SCA_ILogicBrick::Type = {
|
||||
PyObject_HEAD_INIT(&PyType_Type)
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0,
|
||||
"SCA_ILogicBrick",
|
||||
sizeof(SCA_ILogicBrick),
|
||||
0,
|
||||
PyDestructor,
|
||||
0,
|
||||
__getattr,
|
||||
__setattr,
|
||||
0, //&MyPyCompare,
|
||||
__repr,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
py_base_repr,
|
||||
0,0,0,0,0,0,
|
||||
py_base_getattro,
|
||||
py_base_setattro,
|
||||
0,0,0,0,0,0,0,0,0,
|
||||
Methods
|
||||
};
|
||||
|
||||
@@ -275,20 +278,20 @@ int SCA_ILogicBrick::CheckProperty(void *self, const PyAttributeDef *attrdef)
|
||||
}
|
||||
|
||||
PyObject*
|
||||
SCA_ILogicBrick::_getattr(const char *attr)
|
||||
SCA_ILogicBrick::py_getattro(PyObject *attr)
|
||||
{
|
||||
PyObject* object = _getattr_self(Attributes, this, attr);
|
||||
PyObject* object = py_getattro_self(Attributes, this, attr);
|
||||
if (object != NULL)
|
||||
return object;
|
||||
_getattr_up(CValue);
|
||||
py_getattro_up(CValue);
|
||||
}
|
||||
|
||||
int SCA_ILogicBrick::_setattr(const char *attr, PyObject *value)
|
||||
int SCA_ILogicBrick::py_setattro(PyObject *attr, PyObject *value)
|
||||
{
|
||||
int ret = _setattr_self(Attributes, this, attr, value);
|
||||
int ret = py_setattro_self(Attributes, this, attr, value);
|
||||
if (ret >= 0)
|
||||
return ret;
|
||||
return CValue::_setattr(attr, value);
|
||||
return CValue::py_setattro(attr, value);
|
||||
}
|
||||
|
||||
|
||||
|
@@ -79,8 +79,8 @@ public:
|
||||
|
||||
virtual bool LessComparedTo(SCA_ILogicBrick* other);
|
||||
|
||||
virtual PyObject* _getattr(const char *attr);
|
||||
virtual int _setattr(const char *attr, PyObject *value);
|
||||
virtual PyObject* py_getattro(PyObject *attr);
|
||||
virtual int py_setattro(PyObject *attr, PyObject *value);
|
||||
|
||||
static class SCA_LogicManager* m_sCurrentLogicManager;
|
||||
|
||||
|
@@ -375,18 +375,21 @@ void SCA_IObject::SetState(unsigned int state)
|
||||
|
||||
/* Integration hooks ------------------------------------------------------- */
|
||||
PyTypeObject SCA_IObject::Type = {
|
||||
PyObject_HEAD_INIT(&PyType_Type)
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0,
|
||||
"SCA_IObject",
|
||||
sizeof(SCA_IObject),
|
||||
0,
|
||||
PyDestructor,
|
||||
0,
|
||||
__getattr,
|
||||
__setattr,
|
||||
0, //&MyPyCompare,
|
||||
__repr,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
py_base_repr,
|
||||
0,0,0,0,0,0,
|
||||
py_base_getattro,
|
||||
py_base_setattro,
|
||||
0,0,0,0,0,0,0,0,0,
|
||||
Methods
|
||||
};
|
||||
|
||||
@@ -411,7 +414,7 @@ PyAttributeDef SCA_IObject::Attributes[] = {
|
||||
};
|
||||
|
||||
|
||||
PyObject* SCA_IObject::_getattr(const char *attr) {
|
||||
_getattr_up(CValue);
|
||||
PyObject* SCA_IObject::py_getattro(PyObject *attr) {
|
||||
py_getattro_up(CValue);
|
||||
}
|
||||
|
||||
|
@@ -145,7 +145,7 @@ public:
|
||||
// const class MT_Point3& ConvertPythonPylist(PyObject* pylist);
|
||||
|
||||
// here come the python forwarded methods
|
||||
virtual PyObject* _getattr(const char *attr);
|
||||
virtual PyObject* py_getattro(PyObject *attr);
|
||||
|
||||
virtual int GetGameObjectType() {return -1;}
|
||||
|
||||
|
@@ -393,18 +393,21 @@ KX_PYMETHODDEF_DOC_NOARGS(SCA_ISensor, reset,
|
||||
/* ----------------------------------------------- */
|
||||
|
||||
PyTypeObject SCA_ISensor::Type = {
|
||||
PyObject_HEAD_INIT(&PyType_Type)
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0,
|
||||
"SCA_ISensor",
|
||||
sizeof(SCA_ISensor),
|
||||
0,
|
||||
PyDestructor,
|
||||
0,
|
||||
__getattr,
|
||||
__setattr,
|
||||
0,
|
||||
__repr,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,
|
||||
0,
|
||||
py_base_repr,
|
||||
0,0,0,0,0,0,
|
||||
py_base_getattro,
|
||||
py_base_setattro,
|
||||
0,0,0,0,0,0,0,0,0,
|
||||
Methods
|
||||
};
|
||||
|
||||
@@ -451,38 +454,40 @@ PyAttributeDef SCA_ISensor::Attributes[] = {
|
||||
KX_PYATTRIBUTE_INT_RW("frequency",0,100000,true,SCA_ISensor,m_pulse_frequency),
|
||||
KX_PYATTRIBUTE_BOOL_RW("invert",SCA_ISensor,m_invert),
|
||||
KX_PYATTRIBUTE_BOOL_RW("level",SCA_ISensor,m_level),
|
||||
// make these properties read-only in _setaddr, must still implement them in _getattr
|
||||
// make these properties read-only in _setaddr, must still implement them in py_getattro
|
||||
KX_PYATTRIBUTE_DUMMY("triggered"),
|
||||
KX_PYATTRIBUTE_DUMMY("positive"),
|
||||
{ NULL } //Sentinel
|
||||
};
|
||||
|
||||
PyObject*
|
||||
SCA_ISensor::_getattr(const char *attr)
|
||||
SCA_ISensor::py_getattro(PyObject *attr)
|
||||
{
|
||||
PyObject* object = _getattr_self(Attributes, this, attr);
|
||||
PyObject* object = py_getattro_self(Attributes, this, attr);
|
||||
if (object != NULL)
|
||||
return object;
|
||||
if (!strcmp(attr, "triggered"))
|
||||
|
||||
char *attr_str= PyString_AsString(attr);
|
||||
if (!strcmp(attr_str, "triggered"))
|
||||
{
|
||||
int retval = 0;
|
||||
if (SCA_PythonController::m_sCurrentController)
|
||||
retval = SCA_PythonController::m_sCurrentController->IsTriggered(this);
|
||||
return PyInt_FromLong(retval);
|
||||
}
|
||||
if (!strcmp(attr, "positive"))
|
||||
if (!strcmp(attr_str, "positive"))
|
||||
{
|
||||
int retval = IsPositiveTrigger();
|
||||
return PyInt_FromLong(retval);
|
||||
}
|
||||
_getattr_up(SCA_ILogicBrick);
|
||||
py_getattro_up(SCA_ILogicBrick);
|
||||
}
|
||||
|
||||
int SCA_ISensor::_setattr(const char *attr, PyObject *value)
|
||||
int SCA_ISensor::py_setattro(PyObject *attr, PyObject *value)
|
||||
{
|
||||
int ret = _setattr_self(Attributes, this, attr, value);
|
||||
int ret = py_setattro_self(Attributes, this, attr, value);
|
||||
if (ret >= 0)
|
||||
return ret;
|
||||
return SCA_ILogicBrick::_setattr(attr, value);
|
||||
return SCA_ILogicBrick::py_setattro(attr, value);
|
||||
}
|
||||
/* eof */
|
||||
|
@@ -136,8 +136,8 @@ public:
|
||||
|
||||
/* Python functions: */
|
||||
|
||||
virtual PyObject* _getattr(const char *attr);
|
||||
virtual int _setattr(const char *attr, PyObject *value);
|
||||
virtual PyObject* py_getattro(PyObject *attr);
|
||||
virtual int py_setattro(PyObject *attr, PyObject *value);
|
||||
|
||||
//Deprecated functions ----->
|
||||
KX_PYMETHOD_DOC_NOARGS(SCA_ISensor,IsPositive);
|
||||
|
@@ -275,18 +275,21 @@ bool SCA_JoystickSensor::isValid(SCA_JoystickSensor::KX_JOYSENSORMODE m)
|
||||
|
||||
/* Integration hooks ------------------------------------------------------- */
|
||||
PyTypeObject SCA_JoystickSensor::Type = {
|
||||
PyObject_HEAD_INIT(&PyType_Type)
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0,
|
||||
"SCA_JoystickSensor",
|
||||
sizeof(SCA_JoystickSensor),
|
||||
0,
|
||||
PyDestructor,
|
||||
0,
|
||||
__getattr,
|
||||
__setattr,
|
||||
0, //&MyPyCompare,
|
||||
__repr,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
py_base_repr,
|
||||
0,0,0,0,0,0,
|
||||
py_base_getattro,
|
||||
py_base_setattro,
|
||||
0,0,0,0,0,0,0,0,0,
|
||||
Methods
|
||||
};
|
||||
|
||||
@@ -330,8 +333,8 @@ PyAttributeDef SCA_JoystickSensor::Attributes[] = {
|
||||
KX_PYATTRIBUTE_INT_RW("button",0,100,false,SCA_JoystickSensor,m_button),
|
||||
KX_PYATTRIBUTE_INT_LIST_RW_CHECK("axis",0,3,true,SCA_JoystickSensor,m_axis,2,CheckAxis),
|
||||
KX_PYATTRIBUTE_INT_LIST_RW_CHECK("hat",0,12,true,SCA_JoystickSensor,m_hat,2,CheckHat),
|
||||
// dummy attributes will just be read-only in _setattr
|
||||
// you still need to defined them in _getattr
|
||||
// dummy attributes will just be read-only in py_setattro
|
||||
// you still need to defined them in py_getattro
|
||||
KX_PYATTRIBUTE_DUMMY("axisPosition"),
|
||||
KX_PYATTRIBUTE_DUMMY("numAxis"),
|
||||
KX_PYATTRIBUTE_DUMMY("numButtons"),
|
||||
@@ -340,38 +343,40 @@ PyAttributeDef SCA_JoystickSensor::Attributes[] = {
|
||||
{ NULL } //Sentinel
|
||||
};
|
||||
|
||||
PyObject* SCA_JoystickSensor::_getattr(const char *attr) {
|
||||
PyObject* SCA_JoystickSensor::py_getattro(PyObject *attr) {
|
||||
SCA_Joystick *joy = m_pJoystickMgr->GetJoystickDevice(m_joyindex);
|
||||
if (!strcmp(attr, "axisPosition")) {
|
||||
char *attr_str= PyString_AsString(attr);
|
||||
|
||||
if (!strcmp(attr_str, "axisPosition")) {
|
||||
if(joy)
|
||||
return Py_BuildValue("[iiii]", joy->GetAxis10(), joy->GetAxis11(), joy->GetAxis20(), joy->GetAxis21());
|
||||
else
|
||||
return Py_BuildValue("[iiii]", 0, 0, 0, 0);
|
||||
}
|
||||
if (!strcmp(attr, "numAxis")) {
|
||||
if (!strcmp(attr_str, "numAxis")) {
|
||||
return PyInt_FromLong( joy ? joy->GetNumberOfAxes() : 0 );
|
||||
}
|
||||
if (!strcmp(attr, "numButtons")) {
|
||||
if (!strcmp(attr_str, "numButtons")) {
|
||||
return PyInt_FromLong( joy ? joy->GetNumberOfButtons() : 0 );
|
||||
}
|
||||
if (!strcmp(attr, "numHats")) {
|
||||
if (!strcmp(attr_str, "numHats")) {
|
||||
return PyInt_FromLong( joy ? joy->GetNumberOfHats() : 0 );
|
||||
}
|
||||
if (!strcmp(attr, "connected")) {
|
||||
if (!strcmp(attr_str, "connected")) {
|
||||
return PyBool_FromLong( joy ? joy->Connected() : 0 );
|
||||
}
|
||||
PyObject* object = _getattr_self(Attributes, this, attr);
|
||||
PyObject* object = py_getattro_self(Attributes, this, attr);
|
||||
if (object != NULL)
|
||||
return object;
|
||||
_getattr_up(SCA_ISensor);
|
||||
py_getattro_up(SCA_ISensor);
|
||||
}
|
||||
|
||||
int SCA_JoystickSensor::_setattr(const char *attr, PyObject *value)
|
||||
int SCA_JoystickSensor::py_setattro(PyObject *attr, PyObject *value)
|
||||
{
|
||||
int ret = _setattr_self(Attributes, this, attr, value);
|
||||
int ret = py_setattro_self(Attributes, this, attr, value);
|
||||
if (ret >= 0)
|
||||
return ret;
|
||||
return SCA_ISensor::_setattr(attr, value);
|
||||
return SCA_ISensor::py_setattro(attr, value);
|
||||
}
|
||||
|
||||
|
||||
|
@@ -121,8 +121,8 @@ public:
|
||||
/* Python interface ---------------------------------------------------- */
|
||||
/* --------------------------------------------------------------------- */
|
||||
|
||||
virtual PyObject* _getattr(const char *attr);
|
||||
virtual int _setattr(const char *attr, PyObject *value);
|
||||
virtual PyObject* py_getattro(PyObject *attr);
|
||||
virtual int py_setattro(PyObject *attr, PyObject *value);
|
||||
|
||||
/* Joystick Index */
|
||||
KX_PYMETHOD_DOC_NOARGS(SCA_JoystickSensor,GetIndex);
|
||||
|
@@ -778,18 +778,21 @@ KX_PYMETHODDEF_DOC_O(SCA_KeyboardSensor, getKeyStatus,
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
PyTypeObject SCA_KeyboardSensor::Type = {
|
||||
PyObject_HEAD_INIT(&PyType_Type)
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0,
|
||||
"SCA_KeyboardSensor",
|
||||
sizeof(SCA_KeyboardSensor),
|
||||
0,
|
||||
PyDestructor,
|
||||
0,
|
||||
__getattr,
|
||||
__setattr,
|
||||
0, //&MyPyCompare,
|
||||
__repr,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
py_base_repr,
|
||||
0,0,0,0,0,0,
|
||||
py_base_getattro,
|
||||
py_base_setattro,
|
||||
0,0,0,0,0,0,0,0,0,
|
||||
Methods
|
||||
};
|
||||
|
||||
@@ -828,18 +831,18 @@ PyAttributeDef SCA_KeyboardSensor::Attributes[] = {
|
||||
};
|
||||
|
||||
PyObject*
|
||||
SCA_KeyboardSensor::_getattr(const char *attr)
|
||||
SCA_KeyboardSensor::py_getattro(PyObject *attr)
|
||||
{
|
||||
PyObject* object = _getattr_self(Attributes, this, attr);
|
||||
PyObject* object = py_getattro_self(Attributes, this, attr);
|
||||
if (object != NULL)
|
||||
return object;
|
||||
_getattr_up(SCA_ISensor);
|
||||
py_getattro_up(SCA_ISensor);
|
||||
}
|
||||
|
||||
int SCA_KeyboardSensor::_setattr(const char *attr, PyObject *value)
|
||||
int SCA_KeyboardSensor::py_setattro(PyObject *attr, PyObject *value)
|
||||
{
|
||||
int ret = _setattr_self(Attributes, this, attr, value);
|
||||
int ret = py_setattro_self(Attributes, this, attr, value);
|
||||
if (ret >= 0)
|
||||
return ret;
|
||||
return SCA_ISensor::_setattr(attr, value);
|
||||
return SCA_ISensor::py_setattro(attr, value);
|
||||
}
|
||||
|
@@ -126,8 +126,8 @@ public:
|
||||
/* Python interface ---------------------------------------------------- */
|
||||
/* --------------------------------------------------------------------- */
|
||||
|
||||
virtual PyObject* _getattr(const char *attr);
|
||||
virtual int _setattr(const char *attr, PyObject *value);
|
||||
virtual PyObject* py_getattro(PyObject *attr);
|
||||
virtual int py_setattro(PyObject *attr, PyObject *value);
|
||||
|
||||
//Deprecated functions ----->
|
||||
/** 1. GetKey : check which key this sensor looks at */
|
||||
|
@@ -102,7 +102,7 @@ int SCA_MouseSensor::UpdateHotkey(void *self, const PyAttributeDef*)
|
||||
default:
|
||||
; /* ignore, no hotkey */
|
||||
}
|
||||
// return value is used in _setattr(),
|
||||
// return value is used in py_setattro(),
|
||||
// 0=attribute checked ok (see Attributes array definition)
|
||||
return 0;
|
||||
}
|
||||
@@ -300,18 +300,21 @@ KX_PYMETHODDEF_DOC_O(SCA_MouseSensor, getButtonStatus,
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
PyTypeObject SCA_MouseSensor::Type = {
|
||||
PyObject_HEAD_INIT(&PyType_Type)
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0,
|
||||
"SCA_MouseSensor",
|
||||
sizeof(SCA_MouseSensor),
|
||||
0,
|
||||
PyDestructor,
|
||||
0,
|
||||
__getattr,
|
||||
__setattr,
|
||||
0,
|
||||
__repr,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,
|
||||
0,
|
||||
py_base_repr,
|
||||
0,0,0,0,0,0,
|
||||
py_base_getattro,
|
||||
py_base_setattro,
|
||||
0,0,0,0,0,0,0,0,0,
|
||||
Methods
|
||||
};
|
||||
|
||||
@@ -338,20 +341,20 @@ PyAttributeDef SCA_MouseSensor::Attributes[] = {
|
||||
{ NULL } //Sentinel
|
||||
};
|
||||
|
||||
PyObject* SCA_MouseSensor::_getattr(const char *attr)
|
||||
PyObject* SCA_MouseSensor::py_getattro(PyObject *attr)
|
||||
{
|
||||
PyObject* object = _getattr_self(Attributes, this, attr);
|
||||
PyObject* object = py_getattro_self(Attributes, this, attr);
|
||||
if (object != NULL)
|
||||
return object;
|
||||
_getattr_up(SCA_ISensor);
|
||||
py_getattro_up(SCA_ISensor);
|
||||
}
|
||||
|
||||
int SCA_MouseSensor::_setattr(const char *attr, PyObject *value)
|
||||
int SCA_MouseSensor::py_setattro(PyObject *attr, PyObject *value)
|
||||
{
|
||||
int ret = _setattr_self(Attributes, this, attr, value);
|
||||
int ret = py_setattro_self(Attributes, this, attr, value);
|
||||
if (ret >= 0)
|
||||
return ret;
|
||||
return SCA_ISensor::_setattr(attr, value);
|
||||
return SCA_ISensor::py_setattro(attr, value);
|
||||
}
|
||||
|
||||
/* eof */
|
||||
|
@@ -109,8 +109,8 @@ class SCA_MouseSensor : public SCA_ISensor
|
||||
/* Python interface ---------------------------------------------------- */
|
||||
/* --------------------------------------------------------------------- */
|
||||
|
||||
virtual PyObject* _getattr(const char *attr);
|
||||
virtual int _setattr(const char *attr, PyObject *value);
|
||||
virtual PyObject* py_getattro(PyObject *attr);
|
||||
virtual int py_setattro(PyObject *attr, PyObject *value);
|
||||
|
||||
//Deprecated functions ----->
|
||||
/* read x-coordinate */
|
||||
|
@@ -107,18 +107,21 @@ CValue* SCA_NANDController::GetReplica()
|
||||
|
||||
/* Integration hooks ------------------------------------------------------- */
|
||||
PyTypeObject SCA_NANDController::Type = {
|
||||
PyObject_HEAD_INIT(&PyType_Type)
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0,
|
||||
"SCA_NANDController",
|
||||
sizeof(SCA_NANDController),
|
||||
0,
|
||||
PyDestructor,
|
||||
0,
|
||||
__getattr,
|
||||
__setattr,
|
||||
0,
|
||||
__repr,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,
|
||||
0,
|
||||
py_base_repr,
|
||||
0,0,0,0,0,0,
|
||||
py_base_getattro,
|
||||
py_base_setattro,
|
||||
0,0,0,0,0,0,0,0,0,
|
||||
Methods
|
||||
};
|
||||
|
||||
@@ -138,8 +141,8 @@ PyAttributeDef SCA_NANDController::Attributes[] = {
|
||||
{ NULL } //Sentinel
|
||||
};
|
||||
|
||||
PyObject* SCA_NANDController::_getattr(const char *attr) {
|
||||
_getattr_up(SCA_IController);
|
||||
PyObject* SCA_NANDController::py_getattro(PyObject *attr) {
|
||||
py_getattro_up(SCA_IController);
|
||||
}
|
||||
|
||||
/* eof */
|
||||
|
@@ -48,7 +48,7 @@ public:
|
||||
/* Python interface ---------------------------------------------------- */
|
||||
/* --------------------------------------------------------------------- */
|
||||
|
||||
virtual PyObject* _getattr(const char *attr);
|
||||
virtual PyObject* py_getattro(PyObject *attr);
|
||||
|
||||
};
|
||||
|
||||
|
@@ -107,18 +107,21 @@ CValue* SCA_NORController::GetReplica()
|
||||
|
||||
/* Integration hooks ------------------------------------------------------- */
|
||||
PyTypeObject SCA_NORController::Type = {
|
||||
PyObject_HEAD_INIT(&PyType_Type)
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0,
|
||||
"SCA_NORController",
|
||||
sizeof(SCA_NORController),
|
||||
0,
|
||||
PyDestructor,
|
||||
0,
|
||||
__getattr,
|
||||
__setattr,
|
||||
0,
|
||||
__repr,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,
|
||||
0,
|
||||
py_base_repr,
|
||||
0,0,0,0,0,0,
|
||||
py_base_getattro,
|
||||
py_base_setattro,
|
||||
0,0,0,0,0,0,0,0,0,
|
||||
Methods
|
||||
};
|
||||
|
||||
@@ -138,8 +141,8 @@ PyAttributeDef SCA_NORController::Attributes[] = {
|
||||
{ NULL } //Sentinel
|
||||
};
|
||||
|
||||
PyObject* SCA_NORController::_getattr(const char *attr) {
|
||||
_getattr_up(SCA_IController);
|
||||
PyObject* SCA_NORController::py_getattro(PyObject *attr) {
|
||||
py_getattro_up(SCA_IController);
|
||||
}
|
||||
|
||||
/* eof */
|
||||
|
@@ -48,7 +48,7 @@ public:
|
||||
/* Python interface ---------------------------------------------------- */
|
||||
/* --------------------------------------------------------------------- */
|
||||
|
||||
virtual PyObject* _getattr(const char *attr);
|
||||
virtual PyObject* py_getattro(PyObject *attr);
|
||||
|
||||
};
|
||||
|
||||
|
@@ -99,18 +99,21 @@ void SCA_ORController::Trigger(SCA_LogicManager* logicmgr)
|
||||
|
||||
/* Integration hooks ------------------------------------------------------- */
|
||||
PyTypeObject SCA_ORController::Type = {
|
||||
PyObject_HEAD_INIT(&PyType_Type)
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0,
|
||||
"SCA_ORController",
|
||||
sizeof(SCA_ORController),
|
||||
0,
|
||||
PyDestructor,
|
||||
0,
|
||||
__getattr,
|
||||
__setattr,
|
||||
0, //&MyPyCompare,
|
||||
__repr,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
py_base_repr,
|
||||
0,0,0,0,0,0,
|
||||
py_base_getattro,
|
||||
py_base_setattro,
|
||||
0,0,0,0,0,0,0,0,0,
|
||||
Methods
|
||||
};
|
||||
|
||||
@@ -131,8 +134,8 @@ PyAttributeDef SCA_ORController::Attributes[] = {
|
||||
};
|
||||
|
||||
|
||||
PyObject* SCA_ORController::_getattr(const char *attr) {
|
||||
_getattr_up(SCA_IController);
|
||||
PyObject* SCA_ORController::py_getattro(PyObject *attr) {
|
||||
py_getattro_up(SCA_IController);
|
||||
}
|
||||
|
||||
/* eof */
|
||||
|
@@ -49,7 +49,7 @@ public:
|
||||
/* Python interface ---------------------------------------------------- */
|
||||
/* --------------------------------------------------------------------- */
|
||||
|
||||
virtual PyObject* _getattr(const char *attr);
|
||||
virtual PyObject* py_getattro(PyObject *attr);
|
||||
};
|
||||
|
||||
#endif //__KX_ORCONTROLLER
|
||||
|
@@ -218,18 +218,21 @@ void SCA_PropertyActuator::Relink(GEN_Map<GEN_HashedPtr, void*> *obj_map)
|
||||
|
||||
/* Integration hooks ------------------------------------------------------- */
|
||||
PyTypeObject SCA_PropertyActuator::Type = {
|
||||
PyObject_HEAD_INIT(&PyType_Type)
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0,
|
||||
"SCA_PropertyActuator",
|
||||
sizeof(SCA_PropertyActuator),
|
||||
0,
|
||||
PyDestructor,
|
||||
0,
|
||||
__getattr,
|
||||
__setattr,
|
||||
0,
|
||||
__repr,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,
|
||||
0,
|
||||
py_base_repr,
|
||||
0,0,0,0,0,0,
|
||||
py_base_getattro,
|
||||
py_base_setattro,
|
||||
0,0,0,0,0,0,0,0,0,
|
||||
Methods
|
||||
};
|
||||
|
||||
@@ -257,18 +260,18 @@ PyAttributeDef SCA_PropertyActuator::Attributes[] = {
|
||||
{ NULL } //Sentinel
|
||||
};
|
||||
|
||||
PyObject* SCA_PropertyActuator::_getattr(const char *attr) {
|
||||
PyObject* object = _getattr_self(Attributes, this, attr);
|
||||
PyObject* SCA_PropertyActuator::py_getattro(PyObject *attr) {
|
||||
PyObject* object = py_getattro_self(Attributes, this, attr);
|
||||
if (object != NULL)
|
||||
return object;
|
||||
_getattr_up(SCA_IActuator);
|
||||
py_getattro_up(SCA_IActuator);
|
||||
}
|
||||
|
||||
int SCA_PropertyActuator::_setattr(const char *attr, PyObject *value) {
|
||||
int ret = _setattr_self(Attributes, this, attr, value);
|
||||
int SCA_PropertyActuator::py_setattro(PyObject *attr, PyObject *value) {
|
||||
int ret = py_setattro_self(Attributes, this, attr, value);
|
||||
if (ret >= 0)
|
||||
return ret;
|
||||
return SCA_IActuator::_setattr(attr, value);
|
||||
return SCA_IActuator::py_setattro(attr, value);
|
||||
}
|
||||
|
||||
/* 1. setProperty */
|
||||
|
@@ -85,8 +85,8 @@ public:
|
||||
/* Python interface ---------------------------------------------------- */
|
||||
/* --------------------------------------------------------------------- */
|
||||
|
||||
virtual PyObject* _getattr(const char *attr);
|
||||
virtual int _setattr(const char *attr, PyObject *value);
|
||||
virtual PyObject* py_getattro(PyObject *attr);
|
||||
virtual int py_setattro(PyObject *attr, PyObject *value);
|
||||
|
||||
// python wrapped methods
|
||||
KX_PYMETHOD_DOC(SCA_PropertyActuator,SetProperty);
|
||||
|
@@ -306,18 +306,21 @@ int SCA_PropertySensor::validValueForProperty(void *self, const PyAttributeDef*)
|
||||
|
||||
/* Integration hooks ------------------------------------------------------- */
|
||||
PyTypeObject SCA_PropertySensor::Type = {
|
||||
PyObject_HEAD_INIT(&PyType_Type)
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0,
|
||||
"SCA_PropertySensor",
|
||||
sizeof(SCA_PropertySensor),
|
||||
0,
|
||||
PyDestructor,
|
||||
0,
|
||||
__getattr,
|
||||
__setattr,
|
||||
0,
|
||||
__repr,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,
|
||||
0,
|
||||
py_base_repr,
|
||||
0,0,0,0,0,0,
|
||||
py_base_getattro,
|
||||
py_base_setattro,
|
||||
0,0,0,0,0,0,0,0,0,
|
||||
Methods
|
||||
};
|
||||
|
||||
@@ -349,18 +352,18 @@ PyAttributeDef SCA_PropertySensor::Attributes[] = {
|
||||
};
|
||||
|
||||
|
||||
PyObject* SCA_PropertySensor::_getattr(const char *attr) {
|
||||
PyObject* object = _getattr_self(Attributes, this, attr);
|
||||
PyObject* SCA_PropertySensor::py_getattro(PyObject *attr) {
|
||||
PyObject* object = py_getattro_self(Attributes, this, attr);
|
||||
if (object != NULL)
|
||||
return object;
|
||||
_getattr_up(SCA_ISensor); /* implicit return! */
|
||||
py_getattro_up(SCA_ISensor); /* implicit return! */
|
||||
}
|
||||
|
||||
int SCA_PropertySensor::_setattr(const char *attr, PyObject *value) {
|
||||
int ret = _setattr_self(Attributes, this, attr, value);
|
||||
int SCA_PropertySensor::py_setattro(PyObject *attr, PyObject *value) {
|
||||
int ret = py_setattro_self(Attributes, this, attr, value);
|
||||
if (ret >= 0)
|
||||
return ret;
|
||||
return SCA_ISensor::_setattr(attr, value);
|
||||
return SCA_ISensor::py_setattro(attr, value);
|
||||
}
|
||||
|
||||
/* 1. getType */
|
||||
|
@@ -89,8 +89,8 @@ public:
|
||||
/* Python interface ---------------------------------------------------- */
|
||||
/* --------------------------------------------------------------------- */
|
||||
|
||||
virtual PyObject* _getattr(const char *attr);
|
||||
virtual int _setattr(const char *attr, PyObject *value);
|
||||
virtual PyObject* py_getattro(PyObject *attr);
|
||||
virtual int py_setattro(PyObject *attr, PyObject *value);
|
||||
|
||||
/* 1. getType */
|
||||
KX_PYMETHOD_DOC(SCA_PropertySensor,GetType);
|
||||
|
@@ -224,18 +224,21 @@ const char* SCA_PythonController::sPyAddActiveActuator__doc__= "addActiveActuato
|
||||
const char SCA_PythonController::GetActuators_doc[] = "getActuator";
|
||||
|
||||
PyTypeObject SCA_PythonController::Type = {
|
||||
PyObject_HEAD_INIT(&PyType_Type)
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0,
|
||||
"SCA_PythonController",
|
||||
sizeof(SCA_PythonController),
|
||||
0,
|
||||
PyDestructor,
|
||||
0,
|
||||
__getattr,
|
||||
__setattr,
|
||||
0, //&MyPyCompare,
|
||||
__repr,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
py_base_repr,
|
||||
0,0,0,0,0,0,
|
||||
py_base_getattro,
|
||||
py_base_setattro,
|
||||
0,0,0,0,0,0,0,0,0,
|
||||
Methods
|
||||
};
|
||||
|
||||
@@ -369,24 +372,26 @@ void SCA_PythonController::Trigger(SCA_LogicManager* logicmgr)
|
||||
|
||||
|
||||
|
||||
PyObject* SCA_PythonController::_getattr(const char *attr)
|
||||
PyObject* SCA_PythonController::py_getattro(PyObject *attr)
|
||||
{
|
||||
if (!strcmp(attr,"state")) {
|
||||
char *attr_str= PyString_AsString(attr);
|
||||
if (!strcmp(attr_str,"state")) {
|
||||
return PyInt_FromLong(m_statemask);
|
||||
}
|
||||
if (!strcmp(attr,"script")) {
|
||||
if (!strcmp(attr_str,"script")) {
|
||||
return PyString_FromString(m_scriptText);
|
||||
}
|
||||
_getattr_up(SCA_IController);
|
||||
py_getattro_up(SCA_IController);
|
||||
}
|
||||
|
||||
int SCA_PythonController::_setattr(const char *attr, PyObject *value)
|
||||
int SCA_PythonController::py_setattro(PyObject *attr, PyObject *value)
|
||||
{
|
||||
if (!strcmp(attr,"state")) {
|
||||
char *attr_str= PyString_AsString(attr);
|
||||
if (!strcmp(attr_str,"state")) {
|
||||
PyErr_SetString(PyExc_AttributeError, "state is read only");
|
||||
return 1;
|
||||
}
|
||||
if (!strcmp(attr,"script")) {
|
||||
if (!strcmp(attr_str,"script")) {
|
||||
char *scriptArg = PyString_AsString(value);
|
||||
|
||||
if (scriptArg==NULL) {
|
||||
@@ -400,7 +405,7 @@ int SCA_PythonController::_setattr(const char *attr, PyObject *value)
|
||||
|
||||
return 1;
|
||||
}
|
||||
return SCA_IController::_setattr(attr, value);
|
||||
return SCA_IController::py_setattro(attr, value);
|
||||
}
|
||||
|
||||
PyObject* SCA_PythonController::PyActivate(PyObject* self, PyObject *value)
|
||||
|
@@ -78,8 +78,8 @@ class SCA_PythonController : public SCA_IController
|
||||
static PyObject* sPyAddActiveActuator(PyObject* self,
|
||||
PyObject* args);
|
||||
static SCA_IActuator* LinkedActuatorFromPy(PyObject *value);
|
||||
virtual PyObject* _getattr(const char *attr);
|
||||
virtual int _setattr(const char *attr, PyObject *value);
|
||||
virtual PyObject* py_getattro(PyObject *attr);
|
||||
virtual int py_setattro(PyObject *attr, PyObject *value);
|
||||
|
||||
|
||||
KX_PYMETHOD_O(SCA_PythonController,Activate);
|
||||
|
@@ -312,18 +312,21 @@ void SCA_RandomActuator::enforceConstraints() {
|
||||
|
||||
/* Integration hooks ------------------------------------------------------- */
|
||||
PyTypeObject SCA_RandomActuator::Type = {
|
||||
PyObject_HEAD_INIT(&PyType_Type)
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0,
|
||||
"SCA_RandomActuator",
|
||||
sizeof(SCA_RandomActuator),
|
||||
0,
|
||||
PyDestructor,
|
||||
0,
|
||||
__getattr,
|
||||
__setattr,
|
||||
0,
|
||||
__repr,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,
|
||||
0,
|
||||
py_base_repr,
|
||||
0,0,0,0,0,0,
|
||||
py_base_getattro,
|
||||
py_base_setattro,
|
||||
0,0,0,0,0,0,0,0,0,
|
||||
Methods
|
||||
};
|
||||
|
||||
@@ -366,22 +369,25 @@ PyAttributeDef SCA_RandomActuator::Attributes[] = {
|
||||
{ NULL } //Sentinel
|
||||
};
|
||||
|
||||
PyObject* SCA_RandomActuator::_getattr(const char *attr) {
|
||||
PyObject* object = _getattr_self(Attributes, this, attr);
|
||||
PyObject* SCA_RandomActuator::py_getattro(PyObject *attr) {
|
||||
PyObject* object = py_getattro_self(Attributes, this, attr);
|
||||
if (object != NULL)
|
||||
return object;
|
||||
if (!strcmp(attr, "seed")) {
|
||||
char *attr_str= PyString_AsString(attr);
|
||||
if (!strcmp(attr_str, "seed")) {
|
||||
return PyInt_FromLong(m_base->GetSeed());
|
||||
}
|
||||
_getattr_up(SCA_IActuator);
|
||||
py_getattro_up(SCA_IActuator);
|
||||
}
|
||||
|
||||
int SCA_RandomActuator::_setattr(const char *attr, PyObject *value)
|
||||
int SCA_RandomActuator::py_setattro(PyObject *attr, PyObject *value)
|
||||
{
|
||||
int ret = _setattr_self(Attributes, this, attr, value);
|
||||
int ret = py_setattro_self(Attributes, this, attr, value);
|
||||
if (ret >= 0)
|
||||
return ret;
|
||||
if (!strcmp(attr, "seed")) {
|
||||
|
||||
char *attr_str= PyString_AsString(attr);
|
||||
if (!strcmp(attr_str, "seed")) {
|
||||
if (PyInt_Check(value)) {
|
||||
int ival = PyInt_AsLong(value);
|
||||
m_base->SetSeed(ival);
|
||||
@@ -391,7 +397,7 @@ int SCA_RandomActuator::_setattr(const char *attr, PyObject *value)
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return SCA_IActuator::_setattr(attr, value);
|
||||
return SCA_IActuator::py_setattro(attr, value);
|
||||
}
|
||||
|
||||
/* 1. setSeed */
|
||||
|
@@ -96,8 +96,8 @@ class SCA_RandomActuator : public SCA_IActuator
|
||||
/* Python interface ---------------------------------------------------- */
|
||||
/* --------------------------------------------------------------------- */
|
||||
|
||||
virtual PyObject* _getattr(const char *attr);
|
||||
virtual int _setattr(const char *attr, PyObject *value);
|
||||
virtual PyObject* py_getattro(PyObject *attr);
|
||||
virtual int py_setattro(PyObject *attr, PyObject *value);
|
||||
|
||||
/* 1. setSeed */
|
||||
KX_PYMETHOD_DOC(SCA_RandomActuator,SetSeed);
|
||||
|
@@ -127,18 +127,21 @@ bool SCA_RandomSensor::Evaluate(CValue* event)
|
||||
|
||||
/* Integration hooks ------------------------------------------------------- */
|
||||
PyTypeObject SCA_RandomSensor::Type = {
|
||||
PyObject_HEAD_INIT(&PyType_Type)
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0,
|
||||
"SCA_RandomSensor",
|
||||
sizeof(SCA_RandomSensor),
|
||||
0,
|
||||
PyDestructor,
|
||||
0,
|
||||
__getattr,
|
||||
__setattr,
|
||||
0,
|
||||
__repr,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,
|
||||
0,
|
||||
py_base_repr,
|
||||
0,0,0,0,0,0,
|
||||
py_base_getattro,
|
||||
py_base_setattro,
|
||||
0,0,0,0,0,0,0,0,0,
|
||||
Methods
|
||||
};
|
||||
|
||||
@@ -162,22 +165,25 @@ PyAttributeDef SCA_RandomSensor::Attributes[] = {
|
||||
{NULL} //Sentinel
|
||||
};
|
||||
|
||||
PyObject* SCA_RandomSensor::_getattr(const char *attr) {
|
||||
PyObject* object = _getattr_self(Attributes, this, attr);
|
||||
PyObject* SCA_RandomSensor::py_getattro(PyObject *attr) {
|
||||
PyObject* object = py_getattro_self(Attributes, this, attr);
|
||||
if (object != NULL)
|
||||
return object;
|
||||
if (!strcmp(attr,"seed")) {
|
||||
|
||||
char *attr_str= PyString_AsString(attr);
|
||||
if (!strcmp(attr_str,"seed")) {
|
||||
return PyInt_FromLong(m_basegenerator->GetSeed());
|
||||
}
|
||||
_getattr_up(SCA_ISensor);
|
||||
py_getattro_up(SCA_ISensor);
|
||||
}
|
||||
|
||||
int SCA_RandomSensor::_setattr(const char *attr, PyObject *value)
|
||||
int SCA_RandomSensor::py_setattro(PyObject *attr, PyObject *value)
|
||||
{
|
||||
int ret = _setattr_self(Attributes, this, attr, value);
|
||||
int ret = py_setattro_self(Attributes, this, attr, value);
|
||||
if (ret >= 0)
|
||||
return ret;
|
||||
if (!strcmp(attr,"seed")) {
|
||||
char *attr_str= PyString_AsString(attr);
|
||||
if (!strcmp(attr_str,"seed")) {
|
||||
if (PyInt_Check(value)) {
|
||||
int ival = PyInt_AsLong(value);
|
||||
m_basegenerator->SetSeed(ival);
|
||||
@@ -187,7 +193,7 @@ int SCA_RandomSensor::_setattr(const char *attr, PyObject *value)
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return SCA_ISensor::_setattr(attr, value);
|
||||
return SCA_ISensor::py_setattro(attr, value);
|
||||
}
|
||||
|
||||
/* 1. setSeed */
|
||||
|
@@ -60,8 +60,8 @@ public:
|
||||
/* Python interface ---------------------------------------------------- */
|
||||
/* --------------------------------------------------------------------- */
|
||||
|
||||
virtual PyObject* _getattr(const char *attr);
|
||||
virtual int _setattr(const char *attr, PyObject *value);
|
||||
virtual PyObject* py_getattro(PyObject *attr);
|
||||
virtual int py_setattro(PyObject *attr, PyObject *value);
|
||||
|
||||
/* 1. setSeed */
|
||||
KX_PYMETHOD_DOC(SCA_RandomSensor,SetSeed);
|
||||
|
@@ -111,18 +111,21 @@ CValue* SCA_XNORController::GetReplica()
|
||||
|
||||
/* Integration hooks ------------------------------------------------------- */
|
||||
PyTypeObject SCA_XNORController::Type = {
|
||||
PyObject_HEAD_INIT(&PyType_Type)
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0,
|
||||
"SCA_XNORController",
|
||||
sizeof(SCA_XNORController),
|
||||
0,
|
||||
PyDestructor,
|
||||
0,
|
||||
__getattr,
|
||||
__setattr,
|
||||
0,
|
||||
__repr,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,
|
||||
0,
|
||||
py_base_repr,
|
||||
0,0,0,0,0,0,
|
||||
py_base_getattro,
|
||||
py_base_setattro,
|
||||
0,0,0,0,0,0,0,0,0,
|
||||
Methods
|
||||
};
|
||||
|
||||
@@ -142,8 +145,8 @@ PyAttributeDef SCA_XNORController::Attributes[] = {
|
||||
{ NULL } //Sentinel
|
||||
};
|
||||
|
||||
PyObject* SCA_XNORController::_getattr(const char *attr) {
|
||||
_getattr_up(SCA_IController);
|
||||
PyObject* SCA_XNORController::py_getattro(PyObject *attr) {
|
||||
py_getattro_up(SCA_IController);
|
||||
}
|
||||
|
||||
/* eof */
|
||||
|
@@ -48,7 +48,7 @@ public:
|
||||
/* Python interface ---------------------------------------------------- */
|
||||
/* --------------------------------------------------------------------- */
|
||||
|
||||
virtual PyObject* _getattr(const char *attr);
|
||||
virtual PyObject* py_getattro(PyObject *attr);
|
||||
|
||||
};
|
||||
|
||||
|
@@ -111,18 +111,21 @@ CValue* SCA_XORController::GetReplica()
|
||||
|
||||
/* Integration hooks ------------------------------------------------------- */
|
||||
PyTypeObject SCA_XORController::Type = {
|
||||
PyObject_HEAD_INIT(&PyType_Type)
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0,
|
||||
"SCA_XORController",
|
||||
sizeof(SCA_XORController),
|
||||
0,
|
||||
PyDestructor,
|
||||
0,
|
||||
__getattr,
|
||||
__setattr,
|
||||
0,
|
||||
__repr,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,
|
||||
0,
|
||||
py_base_repr,
|
||||
0,0,0,0,0,0,
|
||||
py_base_getattro,
|
||||
py_base_setattro,
|
||||
0,0,0,0,0,0,0,0,0,
|
||||
Methods
|
||||
};
|
||||
|
||||
@@ -142,8 +145,8 @@ PyAttributeDef SCA_XORController::Attributes[] = {
|
||||
{ NULL } //Sentinel
|
||||
};
|
||||
|
||||
PyObject* SCA_XORController::_getattr(const char *attr) {
|
||||
_getattr_up(SCA_IController);
|
||||
PyObject* SCA_XORController::py_getattro(PyObject *attr) {
|
||||
py_getattro_up(SCA_IController);
|
||||
}
|
||||
|
||||
/* eof */
|
||||
|
@@ -48,7 +48,7 @@ public:
|
||||
/* Python interface ---------------------------------------------------- */
|
||||
/* --------------------------------------------------------------------- */
|
||||
|
||||
virtual PyObject* _getattr(const char *attr);
|
||||
virtual PyObject* py_getattro(PyObject *attr);
|
||||
|
||||
};
|
||||
|
||||
|
@@ -729,9 +729,9 @@ void BL_Shader::SetUniform(int uniform, const int* val, int len)
|
||||
}
|
||||
|
||||
|
||||
PyObject* BL_Shader::_getattr(const char *attr)
|
||||
PyObject* BL_Shader::py_getattro(PyObject *attr)
|
||||
{
|
||||
_getattr_up(PyObjectPlus);
|
||||
py_getattro_up(PyObjectPlus);
|
||||
}
|
||||
|
||||
|
||||
@@ -772,25 +772,28 @@ PyAttributeDef BL_Shader::Attributes[] = {
|
||||
};
|
||||
|
||||
PyTypeObject BL_Shader::Type = {
|
||||
PyObject_HEAD_INIT(&PyType_Type)
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0,
|
||||
"BL_Shader",
|
||||
sizeof(BL_Shader),
|
||||
0,
|
||||
PyDestructor,
|
||||
0,
|
||||
__getattr,
|
||||
__setattr,
|
||||
0,
|
||||
__repr,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,
|
||||
0,
|
||||
py_base_repr,
|
||||
0,0,0,0,0,0,
|
||||
py_base_getattro,
|
||||
py_base_setattro,
|
||||
0,0,0,0,0,0,0,0,0,
|
||||
Methods
|
||||
};
|
||||
|
||||
|
||||
PyParentObject BL_Shader::Parents[] = {
|
||||
&PyObjectPlus::Type,
|
||||
&BL_Shader::Type,
|
||||
&PyObjectPlus::Type,
|
||||
NULL
|
||||
};
|
||||
|
||||
|
@@ -202,7 +202,7 @@ public:
|
||||
void SetUniform(int uniform, const int val);
|
||||
|
||||
// Python interface
|
||||
virtual PyObject* _getattr(const char *attr);
|
||||
virtual PyObject* py_getattro(PyObject *attr);
|
||||
|
||||
// -----------------------------------
|
||||
KX_PYMETHOD_DOC( BL_Shader, setSource );
|
||||
|
@@ -105,18 +105,21 @@ CValue* KX_NetworkMessageActuator::GetReplica()
|
||||
|
||||
/* Integration hooks -------------------------------------------------- */
|
||||
PyTypeObject KX_NetworkMessageActuator::Type = {
|
||||
PyObject_HEAD_INIT(&PyType_Type)
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0,
|
||||
"KX_NetworkMessageActuator",
|
||||
sizeof(KX_NetworkMessageActuator),
|
||||
0,
|
||||
PyDestructor,
|
||||
0,
|
||||
__getattr,
|
||||
__setattr,
|
||||
0,
|
||||
__repr,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,
|
||||
0,
|
||||
py_base_repr,
|
||||
0,0,0,0,0,0,
|
||||
py_base_getattro,
|
||||
py_base_setattro,
|
||||
0,0,0,0,0,0,0,0,0,
|
||||
Methods
|
||||
};
|
||||
|
||||
@@ -150,18 +153,18 @@ PyAttributeDef KX_NetworkMessageActuator::Attributes[] = {
|
||||
{ NULL } //Sentinel
|
||||
};
|
||||
|
||||
PyObject* KX_NetworkMessageActuator::_getattr(const char *attr) {
|
||||
PyObject* object = _getattr_self(Attributes, this, attr);
|
||||
PyObject* KX_NetworkMessageActuator::py_getattro(PyObject *attr) {
|
||||
PyObject* object = py_getattro_self(Attributes, this, attr);
|
||||
if (object != NULL)
|
||||
return object;
|
||||
_getattr_up(SCA_IActuator);
|
||||
py_getattro_up(SCA_IActuator);
|
||||
}
|
||||
|
||||
int KX_NetworkMessageActuator::_setattr(const char *attr, PyObject *value) {
|
||||
int ret = _setattr_self(Attributes, this, attr, value);
|
||||
int KX_NetworkMessageActuator::py_setattro(PyObject *attr, PyObject *value) {
|
||||
int ret = py_setattro_self(Attributes, this, attr, value);
|
||||
if (ret >= 0)
|
||||
return ret;
|
||||
return SCA_IActuator::_setattr(attr, value);
|
||||
return SCA_IActuator::py_setattro(attr, value);
|
||||
}
|
||||
|
||||
// Deprecated ----->
|
||||
|
@@ -61,8 +61,8 @@ public:
|
||||
/* Python interface ------------------------------------------- */
|
||||
/* ------------------------------------------------------------ */
|
||||
|
||||
virtual PyObject* _getattr(const char *attr);
|
||||
virtual int _setattr(const char *attr, PyObject *value);
|
||||
virtual PyObject* py_getattro(PyObject *attr);
|
||||
virtual int py_setattro(PyObject *attr, PyObject *value);
|
||||
|
||||
// Deprecated ----->
|
||||
KX_PYMETHOD(KX_NetworkMessageActuator, SetToPropName);
|
||||
|
@@ -168,18 +168,21 @@ bool KX_NetworkMessageSensor::IsPositiveTrigger()
|
||||
|
||||
/* Integration hooks --------------------------------------------------- */
|
||||
PyTypeObject KX_NetworkMessageSensor::Type = {
|
||||
PyObject_HEAD_INIT(&PyType_Type)
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0,
|
||||
"KX_NetworkMessageSensor",
|
||||
sizeof(KX_NetworkMessageSensor),
|
||||
0,
|
||||
PyDestructor,
|
||||
0,
|
||||
__getattr,
|
||||
__setattr,
|
||||
0,
|
||||
__repr,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,
|
||||
0,
|
||||
py_base_repr,
|
||||
0,0,0,0,0,0,
|
||||
py_base_getattro,
|
||||
py_base_setattro,
|
||||
0,0,0,0,0,0,0,0,0,
|
||||
Methods
|
||||
};
|
||||
|
||||
@@ -220,18 +223,18 @@ PyAttributeDef KX_NetworkMessageSensor::Attributes[] = {
|
||||
{ NULL } //Sentinel
|
||||
};
|
||||
|
||||
PyObject* KX_NetworkMessageSensor::_getattr(const char *attr) {
|
||||
PyObject* object = _getattr_self(Attributes, this, attr);
|
||||
PyObject* KX_NetworkMessageSensor::py_getattro(PyObject *attr) {
|
||||
PyObject* object = py_getattro_self(Attributes, this, attr);
|
||||
if (object != NULL)
|
||||
return object;
|
||||
_getattr_up(SCA_ISensor);
|
||||
py_getattro_up(SCA_ISensor);
|
||||
}
|
||||
|
||||
int KX_NetworkMessageSensor::_setattr(const char *attr, PyObject *value) {
|
||||
int ret = _setattr_self(Attributes, this, attr, value);
|
||||
int KX_NetworkMessageSensor::py_setattro(PyObject *attr, PyObject *value) {
|
||||
int ret = py_setattro_self(Attributes, this, attr, value);
|
||||
if (ret >= 0)
|
||||
return ret;
|
||||
return SCA_ISensor::_setattr(attr, value);
|
||||
return SCA_ISensor::py_setattro(attr, value);
|
||||
}
|
||||
|
||||
PyObject* KX_NetworkMessageSensor::pyattr_get_bodies(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
|
||||
|
@@ -72,8 +72,8 @@ public:
|
||||
/* Python interface -------------------------------------------- */
|
||||
/* ------------------------------------------------------------- */
|
||||
|
||||
virtual PyObject* _getattr(const char *attr);
|
||||
virtual int _setattr(const char *attr, PyObject *value);
|
||||
virtual PyObject* py_getattro(PyObject *attr);
|
||||
virtual int py_setattro(PyObject *attr, PyObject *value);
|
||||
|
||||
// Deprecated ----->
|
||||
KX_PYMETHOD_DOC_O(KX_NetworkMessageSensor, SetSubjectFilterText);
|
||||
|
@@ -753,37 +753,40 @@ PyAttributeDef KX_BlenderMaterial::Attributes[] = {
|
||||
};
|
||||
|
||||
PyTypeObject KX_BlenderMaterial::Type = {
|
||||
PyObject_HEAD_INIT(&PyType_Type)
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0,
|
||||
"KX_BlenderMaterial",
|
||||
sizeof(KX_BlenderMaterial),
|
||||
0,
|
||||
PyDestructor,
|
||||
0,
|
||||
__getattr,
|
||||
__setattr,
|
||||
0,
|
||||
__repr,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,
|
||||
0,
|
||||
py_base_repr,
|
||||
0,0,0,0,0,0,
|
||||
py_base_getattro,
|
||||
py_base_setattro,
|
||||
0,0,0,0,0,0,0,0,0,
|
||||
Methods
|
||||
};
|
||||
|
||||
|
||||
PyParentObject KX_BlenderMaterial::Parents[] = {
|
||||
&PyObjectPlus::Type,
|
||||
&KX_BlenderMaterial::Type,
|
||||
&PyObjectPlus::Type,
|
||||
NULL
|
||||
};
|
||||
|
||||
|
||||
PyObject* KX_BlenderMaterial::_getattr(const char *attr)
|
||||
PyObject* KX_BlenderMaterial::py_getattro(PyObject *attr)
|
||||
{
|
||||
_getattr_up(PyObjectPlus);
|
||||
py_getattro_up(PyObjectPlus);
|
||||
}
|
||||
|
||||
int KX_BlenderMaterial::_setattr(const char *attr, PyObject *pyvalue)
|
||||
int KX_BlenderMaterial::py_setattro(PyObject *attr, PyObject *pyvalue)
|
||||
{
|
||||
return PyObjectPlus::_setattr(attr, pyvalue);
|
||||
return PyObjectPlus::py_setattro(attr, pyvalue);
|
||||
}
|
||||
|
||||
|
||||
|
@@ -82,8 +82,8 @@ public:
|
||||
);
|
||||
|
||||
// --------------------------------
|
||||
virtual PyObject* _getattr(const char *attr);
|
||||
virtual int _setattr(const char *attr, PyObject *pyvalue);
|
||||
virtual PyObject* py_getattro(PyObject *attr);
|
||||
virtual int py_setattro(PyObject *attr, PyObject *pyvalue);
|
||||
|
||||
KX_PYMETHOD_DOC( KX_BlenderMaterial, getShader );
|
||||
KX_PYMETHOD_DOC( KX_BlenderMaterial, getMaterialIndex );
|
||||
|
@@ -158,18 +158,21 @@ bool KX_CDActuator::Update()
|
||||
|
||||
/* Integration hooks ------------------------------------------------------- */
|
||||
PyTypeObject KX_CDActuator::Type = {
|
||||
PyObject_HEAD_INIT(&PyType_Type)
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0,
|
||||
"KX_SoundActuator",
|
||||
sizeof(KX_CDActuator),
|
||||
0,
|
||||
PyDestructor,
|
||||
0,
|
||||
__getattr,
|
||||
__setattr,
|
||||
0,
|
||||
__repr,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,
|
||||
0,
|
||||
py_base_repr,
|
||||
0,0,0,0,0,0,
|
||||
py_base_getattro,
|
||||
py_base_setattro,
|
||||
0,0,0,0,0,0,0,0,0,
|
||||
Methods
|
||||
};
|
||||
|
||||
@@ -212,20 +215,20 @@ int KX_CDActuator::pyattr_setGain(void *self, const struct KX_PYATTRIBUTE_DEF *a
|
||||
return 0;
|
||||
}
|
||||
|
||||
PyObject* KX_CDActuator::_getattr(const char *attr)
|
||||
PyObject* KX_CDActuator::py_getattro(PyObject *attr)
|
||||
{
|
||||
PyObject* object = _getattr_self(Attributes, this, attr);
|
||||
PyObject* object = py_getattro_self(Attributes, this, attr);
|
||||
if (object != NULL)
|
||||
return object;
|
||||
_getattr_up(SCA_IActuator);
|
||||
py_getattro_up(SCA_IActuator);
|
||||
}
|
||||
|
||||
int KX_CDActuator::_setattr(const char *attr, PyObject *value)
|
||||
int KX_CDActuator::py_setattro(PyObject *attr, PyObject *value)
|
||||
{
|
||||
int ret = _setattr_self(Attributes, this, attr, value);
|
||||
int ret = py_setattro_self(Attributes, this, attr, value);
|
||||
if (ret >= 0)
|
||||
return ret;
|
||||
return SCA_IActuator::_setattr(attr, value);
|
||||
return SCA_IActuator::py_setattro(attr, value);
|
||||
}
|
||||
|
||||
|
||||
|
@@ -81,8 +81,8 @@ public:
|
||||
/* Python interface --------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------- */
|
||||
|
||||
virtual PyObject* _getattr(const char *attr);
|
||||
virtual int _setattr(const char *attr, PyObject *value);
|
||||
virtual PyObject* py_getattro(PyObject *attr);
|
||||
virtual int py_setattro(PyObject *attr, PyObject *value);
|
||||
|
||||
// Deprecated ----->
|
||||
KX_PYMETHOD(KX_CDActuator,SetGain);
|
||||
|
@@ -488,18 +488,21 @@ PyAttributeDef KX_Camera::Attributes[] = {
|
||||
};
|
||||
|
||||
PyTypeObject KX_Camera::Type = {
|
||||
PyObject_HEAD_INIT(&PyType_Type)
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0,
|
||||
"KX_Camera",
|
||||
sizeof(KX_Camera),
|
||||
0,
|
||||
PyDestructor,
|
||||
0,
|
||||
__getattr,
|
||||
__setattr,
|
||||
0,
|
||||
__repr,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,
|
||||
0,
|
||||
py_base_repr,
|
||||
0,0,0,0,0,0,
|
||||
py_base_getattro,
|
||||
py_base_setattro,
|
||||
0,0,0,0,0,0,0,0,0,
|
||||
Methods
|
||||
};
|
||||
|
||||
@@ -511,48 +514,51 @@ PyParentObject KX_Camera::Parents[] = {
|
||||
NULL
|
||||
};
|
||||
|
||||
PyObject* KX_Camera::_getattr(const char *attr)
|
||||
PyObject* KX_Camera::py_getattro(PyObject *attr)
|
||||
{
|
||||
if (!strcmp(attr, "INSIDE"))
|
||||
char *attr_str= PyString_AsString(attr);
|
||||
if (!strcmp(attr_str, "INSIDE"))
|
||||
return PyInt_FromLong(INSIDE); /* new ref */
|
||||
if (!strcmp(attr, "OUTSIDE"))
|
||||
if (!strcmp(attr_str, "OUTSIDE"))
|
||||
return PyInt_FromLong(OUTSIDE); /* new ref */
|
||||
if (!strcmp(attr, "INTERSECT"))
|
||||
if (!strcmp(attr_str, "INTERSECT"))
|
||||
return PyInt_FromLong(INTERSECT); /* new ref */
|
||||
|
||||
if (!strcmp(attr, "lens"))
|
||||
if (!strcmp(attr_str, "lens"))
|
||||
return PyFloat_FromDouble(GetLens()); /* new ref */
|
||||
if (!strcmp(attr, "near"))
|
||||
if (!strcmp(attr_str, "near"))
|
||||
return PyFloat_FromDouble(GetCameraNear()); /* new ref */
|
||||
if (!strcmp(attr, "far"))
|
||||
if (!strcmp(attr_str, "far"))
|
||||
return PyFloat_FromDouble(GetCameraFar()); /* new ref */
|
||||
if (!strcmp(attr, "frustum_culling"))
|
||||
if (!strcmp(attr_str, "frustum_culling"))
|
||||
return PyInt_FromLong(m_frustum_culling); /* new ref */
|
||||
if (!strcmp(attr, "perspective"))
|
||||
if (!strcmp(attr_str, "perspective"))
|
||||
return PyInt_FromLong(m_camdata.m_perspective); /* new ref */
|
||||
if (!strcmp(attr, "projection_matrix"))
|
||||
if (!strcmp(attr_str, "projection_matrix"))
|
||||
return PyObjectFrom(GetProjectionMatrix()); /* new ref */
|
||||
if (!strcmp(attr, "modelview_matrix"))
|
||||
if (!strcmp(attr_str, "modelview_matrix"))
|
||||
return PyObjectFrom(GetModelviewMatrix()); /* new ref */
|
||||
if (!strcmp(attr, "camera_to_world"))
|
||||
if (!strcmp(attr_str, "camera_to_world"))
|
||||
return PyObjectFrom(GetCameraToWorld()); /* new ref */
|
||||
if (!strcmp(attr, "world_to_camera"))
|
||||
if (!strcmp(attr_str, "world_to_camera"))
|
||||
return PyObjectFrom(GetWorldToCamera()); /* new ref */
|
||||
|
||||
_getattr_up(KX_GameObject);
|
||||
py_getattro_up(KX_GameObject);
|
||||
}
|
||||
|
||||
int KX_Camera::_setattr(const char *attr, PyObject *pyvalue)
|
||||
int KX_Camera::py_setattro(PyObject *attr, PyObject *pyvalue)
|
||||
{
|
||||
char *attr_str= PyString_AsString(attr);
|
||||
|
||||
if (PyInt_Check(pyvalue))
|
||||
{
|
||||
if (!strcmp(attr, "frustum_culling"))
|
||||
if (!strcmp(attr_str, "frustum_culling"))
|
||||
{
|
||||
m_frustum_culling = PyInt_AsLong(pyvalue);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!strcmp(attr, "perspective"))
|
||||
if (!strcmp(attr_str, "perspective"))
|
||||
{
|
||||
m_camdata.m_perspective = PyInt_AsLong(pyvalue);
|
||||
return 0;
|
||||
@@ -561,19 +567,19 @@ int KX_Camera::_setattr(const char *attr, PyObject *pyvalue)
|
||||
|
||||
if (PyFloat_Check(pyvalue))
|
||||
{
|
||||
if (!strcmp(attr, "lens"))
|
||||
if (!strcmp(attr_str, "lens"))
|
||||
{
|
||||
m_camdata.m_lens = PyFloat_AsDouble(pyvalue);
|
||||
m_set_projection_matrix = false;
|
||||
return 0;
|
||||
}
|
||||
if (!strcmp(attr, "near"))
|
||||
if (!strcmp(attr_str, "near"))
|
||||
{
|
||||
m_camdata.m_clipstart = PyFloat_AsDouble(pyvalue);
|
||||
m_set_projection_matrix = false;
|
||||
return 0;
|
||||
}
|
||||
if (!strcmp(attr, "far"))
|
||||
if (!strcmp(attr_str, "far"))
|
||||
{
|
||||
m_camdata.m_clipend = PyFloat_AsDouble(pyvalue);
|
||||
m_set_projection_matrix = false;
|
||||
@@ -583,7 +589,7 @@ int KX_Camera::_setattr(const char *attr, PyObject *pyvalue)
|
||||
|
||||
if (PyObject_IsMT_Matrix(pyvalue, 4))
|
||||
{
|
||||
if (!strcmp(attr, "projection_matrix"))
|
||||
if (!strcmp(attr_str, "projection_matrix"))
|
||||
{
|
||||
MT_Matrix4x4 mat;
|
||||
if (PyMatTo(pyvalue, mat))
|
||||
@@ -594,7 +600,7 @@ int KX_Camera::_setattr(const char *attr, PyObject *pyvalue)
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return KX_GameObject::_setattr(attr, pyvalue);
|
||||
return KX_GameObject::py_setattro(attr, pyvalue);
|
||||
}
|
||||
|
||||
KX_PYMETHODDEF_DOC_VARARGS(KX_Camera, sphereInsideFrustum,
|
||||
|
@@ -265,8 +265,8 @@ public:
|
||||
KX_PYMETHOD_DOC_VARARGS(KX_Camera, setViewport);
|
||||
KX_PYMETHOD_DOC_NOARGS(KX_Camera, setOnTop);
|
||||
|
||||
virtual PyObject* _getattr(const char *attr); /* lens, near, far, projection_matrix */
|
||||
virtual int _setattr(const char *attr, PyObject *pyvalue);
|
||||
virtual PyObject* py_getattro(PyObject *attr); /* lens, near, far, projection_matrix */
|
||||
virtual int py_setattro(PyObject *attr, PyObject *pyvalue);
|
||||
|
||||
};
|
||||
|
||||
|
@@ -371,18 +371,21 @@ bool KX_CameraActuator::string2axischoice(const char *axisString)
|
||||
|
||||
/* Integration hooks ------------------------------------------------------- */
|
||||
PyTypeObject KX_CameraActuator::Type = {
|
||||
PyObject_HEAD_INIT(&PyType_Type)
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0,
|
||||
"KX_CameraActuator",
|
||||
sizeof(KX_CameraActuator),
|
||||
0,
|
||||
PyDestructor,
|
||||
0,
|
||||
__getattr,
|
||||
__setattr,
|
||||
0,
|
||||
__repr,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,
|
||||
0,
|
||||
py_base_repr,
|
||||
0,0,0,0,0,0,
|
||||
py_base_getattro,
|
||||
py_base_setattro,
|
||||
0,0,0,0,0,0,0,0,0,
|
||||
Methods
|
||||
};
|
||||
|
||||
@@ -414,27 +417,28 @@ PyAttributeDef KX_CameraActuator::Attributes[] = {
|
||||
KX_PYATTRIBUTE_FLOAT_RW("max",-MAXFLOAT,MAXFLOAT,KX_CameraActuator,m_maxHeight),
|
||||
KX_PYATTRIBUTE_FLOAT_RW("height",-MAXFLOAT,MAXFLOAT,KX_CameraActuator,m_height),
|
||||
KX_PYATTRIBUTE_BOOL_RW("xy",KX_CameraActuator,m_x),
|
||||
KX_PYATTRIBUTE_DUMMY("object"),
|
||||
{NULL}
|
||||
};
|
||||
|
||||
PyObject* KX_CameraActuator::_getattr(const char *attr) {
|
||||
PyObject* KX_CameraActuator::py_getattro(PyObject *attr) {
|
||||
PyObject* object;
|
||||
|
||||
if (!strcmp(attr, "object")) {
|
||||
char *attr_str= PyString_AsString(attr);
|
||||
if (!strcmp(attr_str, "object")) {
|
||||
if (!m_ob) Py_RETURN_NONE;
|
||||
else return m_ob->AddRef();
|
||||
}
|
||||
|
||||
object = _getattr_self(Attributes, this, attr);
|
||||
object = py_getattro_self(Attributes, this, attr);
|
||||
if (object != NULL)
|
||||
return object;
|
||||
_getattr_up(SCA_IActuator);
|
||||
py_getattro_up(SCA_IActuator);
|
||||
}
|
||||
|
||||
int KX_CameraActuator::_setattr(const char *attr, PyObject* value) {
|
||||
int KX_CameraActuator::py_setattro(PyObject *attr, PyObject* value) {
|
||||
int ret;
|
||||
|
||||
if (!strcmp(attr, "object")) {
|
||||
char *attr_str= PyString_AsString(attr);
|
||||
if (!strcmp(attr_str, "object")) {
|
||||
KX_GameObject *gameobj;
|
||||
|
||||
if (!ConvertPythonToGameObject(value, &gameobj, true))
|
||||
@@ -451,10 +455,10 @@ int KX_CameraActuator::_setattr(const char *attr, PyObject* value) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
ret = _setattr_self(Attributes, this, attr, value);
|
||||
ret = py_setattro_self(Attributes, this, attr, value);
|
||||
if (ret >= 0)
|
||||
return ret;
|
||||
return SCA_IActuator::_setattr(attr, value);
|
||||
return SCA_IActuator::py_setattro(attr, value);
|
||||
}
|
||||
|
||||
/* get obj ---------------------------------------------------------- */
|
||||
|
@@ -120,8 +120,8 @@ private :
|
||||
/* Python interface ---------------------------------------------------- */
|
||||
/* --------------------------------------------------------------------- */
|
||||
|
||||
virtual PyObject* _getattr(const char *attr);
|
||||
virtual int _setattr(const char *attr, PyObject* value);
|
||||
virtual PyObject* py_getattro(PyObject *attr);
|
||||
virtual int py_setattro(PyObject *attr, PyObject* value);
|
||||
|
||||
/* set object to look at */
|
||||
KX_PYMETHOD_DOC_O(KX_CameraActuator,SetObject);
|
||||
|
@@ -560,18 +560,21 @@ bool KX_ConstraintActuator::IsValidMode(KX_ConstraintActuator::KX_CONSTRAINTTYPE
|
||||
|
||||
/* Integration hooks ------------------------------------------------------- */
|
||||
PyTypeObject KX_ConstraintActuator::Type = {
|
||||
PyObject_HEAD_INIT(&PyType_Type)
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0,
|
||||
"KX_ConstraintActuator",
|
||||
sizeof(KX_ConstraintActuator),
|
||||
0,
|
||||
PyDestructor,
|
||||
0,
|
||||
__getattr,
|
||||
__setattr,
|
||||
0,
|
||||
__repr,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,
|
||||
0,
|
||||
py_base_repr,
|
||||
0,0,0,0,0,0,
|
||||
py_base_getattro,
|
||||
py_base_setattro,
|
||||
0,0,0,0,0,0,0,0,0,
|
||||
Methods
|
||||
};
|
||||
|
||||
@@ -613,8 +616,8 @@ PyAttributeDef KX_ConstraintActuator::Attributes[] = {
|
||||
{ NULL } //Sentinel
|
||||
};
|
||||
|
||||
PyObject* KX_ConstraintActuator::_getattr(const char *attr) {
|
||||
_getattr_up(SCA_IActuator);
|
||||
PyObject* KX_ConstraintActuator::py_getattro(PyObject *attr) {
|
||||
py_getattro_up(SCA_IActuator);
|
||||
}
|
||||
|
||||
/* 2. setDamp */
|
||||
|
@@ -142,7 +142,7 @@ protected:
|
||||
/* Python interface ---------------------------------------------------- */
|
||||
/* --------------------------------------------------------------------- */
|
||||
|
||||
virtual PyObject* _getattr(const char *attr);
|
||||
virtual PyObject* py_getattro(PyObject *attr);
|
||||
|
||||
KX_PYMETHOD_DOC(KX_ConstraintActuator,SetDamp);
|
||||
KX_PYMETHOD_DOC_NOARGS(KX_ConstraintActuator,GetDamp);
|
||||
|
@@ -69,18 +69,21 @@ PyObject* KX_ConstraintWrapper::PyGetConstraintId(PyObject* self,
|
||||
|
||||
//python specific stuff
|
||||
PyTypeObject KX_ConstraintWrapper::Type = {
|
||||
PyObject_HEAD_INIT(&PyType_Type)
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0,
|
||||
"KX_ConstraintWrapper",
|
||||
sizeof(KX_ConstraintWrapper),
|
||||
0,
|
||||
PyDestructor,
|
||||
0,
|
||||
__getattr,
|
||||
__setattr,
|
||||
0,
|
||||
__repr,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,
|
||||
0,
|
||||
py_base_repr,
|
||||
0,0,0,0,0,0,
|
||||
py_base_getattro,
|
||||
py_base_setattro,
|
||||
0,0,0,0,0,0,0,0,0,
|
||||
Methods
|
||||
};
|
||||
|
||||
@@ -89,13 +92,13 @@ PyParentObject KX_ConstraintWrapper::Parents[] = {
|
||||
NULL
|
||||
};
|
||||
|
||||
PyObject* KX_ConstraintWrapper::_getattr(const char *attr)
|
||||
PyObject* KX_ConstraintWrapper::py_getattro(PyObject *attr)
|
||||
{
|
||||
//here you can search for existing data members (like mass,friction etc.)
|
||||
_getattr_up(PyObjectPlus);
|
||||
py_getattro_up(PyObjectPlus);
|
||||
}
|
||||
|
||||
int KX_ConstraintWrapper::_setattr(const char *attr,PyObject* pyobj)
|
||||
int KX_ConstraintWrapper::py_setattro(PyObject *attr,PyObject* pyobj)
|
||||
{
|
||||
int result = 1;
|
||||
|
||||
@@ -117,7 +120,7 @@ int KX_ConstraintWrapper::_setattr(const char *attr,PyObject* pyobj)
|
||||
result = 0;
|
||||
}
|
||||
if (result)
|
||||
result = PyObjectPlus::_setattr(attr,pyobj);
|
||||
result = PyObjectPlus::py_setattro(attr,pyobj);
|
||||
return result;
|
||||
};
|
||||
|
||||
|
@@ -35,8 +35,8 @@
|
||||
class KX_ConstraintWrapper : public PyObjectPlus
|
||||
{
|
||||
Py_Header;
|
||||
virtual PyObject* _getattr(const char *attr);
|
||||
virtual int _setattr(const char *attr, PyObject *value);
|
||||
virtual PyObject* py_getattro(PyObject *attr);
|
||||
virtual int py_setattro(PyObject *attr, PyObject *value);
|
||||
public:
|
||||
KX_ConstraintWrapper(PHY_ConstraintType ctype,int constraintId,class PHY_IPhysicsEnvironment* physenv,PyTypeObject *T = &Type);
|
||||
virtual ~KX_ConstraintWrapper ();
|
||||
|
@@ -208,18 +208,21 @@ bool KX_GameActuator::Update()
|
||||
|
||||
/* Integration hooks ------------------------------------------------------- */
|
||||
PyTypeObject KX_GameActuator::Type = {
|
||||
PyObject_HEAD_INIT(&PyType_Type)
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0,
|
||||
"KX_GameActuator",
|
||||
sizeof(KX_GameActuator),
|
||||
0,
|
||||
PyDestructor,
|
||||
0,
|
||||
__getattr,
|
||||
__setattr,
|
||||
0,
|
||||
__repr,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,
|
||||
0,
|
||||
py_base_repr,
|
||||
0,0,0,0,0,0,
|
||||
py_base_getattro,
|
||||
py_base_setattro,
|
||||
0,0,0,0,0,0,0,0,0,
|
||||
Methods
|
||||
};
|
||||
|
||||
@@ -251,20 +254,20 @@ PyAttributeDef KX_GameActuator::Attributes[] = {
|
||||
};
|
||||
|
||||
PyObject*
|
||||
KX_GameActuator::_getattr(const char *attr)
|
||||
KX_GameActuator::py_getattro(PyObject *attr)
|
||||
{
|
||||
PyObject* object = _getattr_self(Attributes, this, attr);
|
||||
PyObject* object = py_getattro_self(Attributes, this, attr);
|
||||
if (object != NULL)
|
||||
return object;
|
||||
_getattr_up(SCA_IActuator);
|
||||
py_getattro_up(SCA_IActuator);
|
||||
}
|
||||
|
||||
int KX_GameActuator::_setattr(const char *attr, PyObject *value)
|
||||
int KX_GameActuator::py_setattro(PyObject *attr, PyObject *value)
|
||||
{
|
||||
int ret = _setattr_self(Attributes, this, attr, value);
|
||||
int ret = py_setattro_self(Attributes, this, attr, value);
|
||||
if (ret >= 0)
|
||||
return ret;
|
||||
return SCA_IActuator::_setattr(attr, value);
|
||||
return SCA_IActuator::py_setattro(attr, value);
|
||||
}
|
||||
|
||||
|
||||
|
@@ -77,8 +77,8 @@ protected:
|
||||
/* Python interface ---------------------------------------------------- */
|
||||
/* --------------------------------------------------------------------- */
|
||||
|
||||
virtual PyObject* _getattr(const char *attr);
|
||||
virtual int _setattr(const char *attr, PyObject *value);
|
||||
virtual PyObject* py_getattro(PyObject *attr);
|
||||
virtual int py_setattro(PyObject *attr, PyObject *value);
|
||||
|
||||
// Deprecated functions ----->
|
||||
KX_PYMETHOD_DOC(KX_GameActuator,GetFile);
|
||||
|
@@ -1180,21 +1180,21 @@ PyMappingMethods KX_GameObject::Mapping = {
|
||||
|
||||
|
||||
PyTypeObject KX_GameObject::Type = {
|
||||
PyObject_HEAD_INIT(&PyType_Type)
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0,
|
||||
"KX_GameObject",
|
||||
sizeof(KX_GameObject),
|
||||
0,
|
||||
PyDestructor,
|
||||
0,
|
||||
__getattr,
|
||||
__setattr,
|
||||
0,
|
||||
__repr,
|
||||
0,
|
||||
0,
|
||||
&Mapping,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,
|
||||
py_base_repr,
|
||||
0,0,0,0,0,0,
|
||||
py_base_getattro,
|
||||
py_base_setattro,
|
||||
0,0,0,0,0,0,0,0,0,
|
||||
Methods
|
||||
};
|
||||
|
||||
@@ -1420,7 +1420,9 @@ int KX_GameObject::pyattr_set_state(void *self_v, const KX_PYATTRIBUTE_DEF *attr
|
||||
PyObject* KX_GameObject::pyattr_get_dir_dict(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
|
||||
{
|
||||
KX_GameObject* self= static_cast<KX_GameObject*>(self_v);
|
||||
PyObject *dict= _getattr_dict(self->SCA_IObject::_getattr("__dict__"), KX_GameObject::Methods, KX_GameObject::Attributes);
|
||||
PyObject *dict_str = PyString_FromString("__dict__");
|
||||
PyObject *dict= _getattr_dict(self->SCA_IObject::py_getattro(dict_str), KX_GameObject::Methods, KX_GameObject::Attributes);
|
||||
Py_DECREF(dict_str);
|
||||
|
||||
if(dict==NULL)
|
||||
return NULL;
|
||||
@@ -1441,22 +1443,22 @@ PyObject* KX_GameObject::pyattr_get_dir_dict(void *self_v, const KX_PYATTRIBUTE_
|
||||
return dict;
|
||||
}
|
||||
|
||||
PyObject* KX_GameObject::_getattr(const char *attr)
|
||||
PyObject* KX_GameObject::py_getattro(PyObject *attr)
|
||||
{
|
||||
PyObject* object = _getattr_self(Attributes, this, attr);
|
||||
PyObject* object = py_getattro_self(Attributes, this, attr);
|
||||
if (object != NULL)
|
||||
return object;
|
||||
|
||||
_getattr_up(SCA_IObject);
|
||||
py_getattro_up(SCA_IObject);
|
||||
}
|
||||
|
||||
int KX_GameObject::_setattr(const char *attr, PyObject *value) // _setattr method
|
||||
int KX_GameObject::py_setattro(PyObject *attr, PyObject *value) // py_setattro method
|
||||
{
|
||||
int ret = _setattr_self(Attributes, this, attr, value);
|
||||
int ret = py_setattro_self(Attributes, this, attr, value);
|
||||
if (ret >= 0)
|
||||
return ret;
|
||||
|
||||
return SCA_IObject::_setattr(attr, value);
|
||||
return SCA_IObject::py_setattro(attr, value);
|
||||
}
|
||||
|
||||
PyObject* KX_GameObject::PyApplyForce(PyObject* self, PyObject* args)
|
||||
|
@@ -756,9 +756,9 @@ public:
|
||||
* @section Python interface functions.
|
||||
*/
|
||||
|
||||
virtual PyObject* _getattr(const char *attr);
|
||||
virtual int _setattr(const char *attr, PyObject *value); // _setattr method
|
||||
virtual PyObject* _repr(void) { return PyString_FromString(GetName().ReadPtr()); }
|
||||
virtual PyObject* py_getattro(PyObject *attr);
|
||||
virtual int py_setattro(PyObject *attr, PyObject *value); // py_setattro method
|
||||
virtual PyObject* py_repr(void) { return PyString_FromString(GetName().ReadPtr()); }
|
||||
|
||||
KX_PYMETHOD_NOARGS(KX_GameObject,GetPosition);
|
||||
KX_PYMETHOD_O(KX_GameObject,SetPosition);
|
||||
|
@@ -413,18 +413,21 @@ int KX_IpoActuator::string2mode(char* modename) {
|
||||
|
||||
/* Integration hooks ------------------------------------------------------- */
|
||||
PyTypeObject KX_IpoActuator::Type = {
|
||||
PyObject_HEAD_INIT(&PyType_Type)
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0,
|
||||
"KX_IpoActuator",
|
||||
sizeof(KX_IpoActuator),
|
||||
0,
|
||||
PyDestructor,
|
||||
0,
|
||||
__getattr,
|
||||
__setattr,
|
||||
0,
|
||||
__repr,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,
|
||||
0,
|
||||
py_base_repr,
|
||||
0,0,0,0,0,0,
|
||||
py_base_getattro,
|
||||
py_base_setattro,
|
||||
0,0,0,0,0,0,0,0,0,
|
||||
Methods
|
||||
};
|
||||
|
||||
@@ -470,25 +473,21 @@ PyAttributeDef KX_IpoActuator::Attributes[] = {
|
||||
{ NULL } //Sentinel
|
||||
};
|
||||
|
||||
PyObject* KX_IpoActuator::_getattr(const char *attr) {
|
||||
PyObject* object = _getattr_self(Attributes, this, attr);
|
||||
PyObject* KX_IpoActuator::py_getattro(PyObject *attr) {
|
||||
PyObject* object = py_getattro_self(Attributes, this, attr);
|
||||
if (object != NULL)
|
||||
return object;
|
||||
|
||||
if (!strcmp(attr, "__dict__")) { /* python 3.0 uses .__dir__()*/
|
||||
return _getattr_dict(SCA_IActuator::_getattr(attr), Methods, Attributes);
|
||||
}
|
||||
|
||||
_getattr_up(SCA_IActuator);
|
||||
py_getattro_up(SCA_IActuator);
|
||||
}
|
||||
|
||||
int KX_IpoActuator::_setattr(const char *attr, PyObject *value) // _setattr method
|
||||
int KX_IpoActuator::py_setattro(PyObject *attr, PyObject *value) // py_setattro method
|
||||
{
|
||||
int ret = _setattr_self(Attributes, this, attr, value);
|
||||
int ret = py_setattro_self(Attributes, this, attr, value);
|
||||
if (ret >= 0)
|
||||
return ret;
|
||||
|
||||
return SCA_IActuator::_setattr(attr, value);
|
||||
return SCA_IActuator::py_setattro(attr, value);
|
||||
}
|
||||
|
||||
/* set --------------------------------------------------------------------- */
|
||||
|
@@ -141,8 +141,8 @@ public:
|
||||
/* Python interface ---------------------------------------------------- */
|
||||
/* --------------------------------------------------------------------- */
|
||||
|
||||
virtual PyObject* _getattr(const char *attr);
|
||||
virtual int _setattr(const char *attr, PyObject *value);
|
||||
virtual PyObject* py_getattro(PyObject *attr);
|
||||
virtual int py_setattro(PyObject *attr, PyObject *value);
|
||||
|
||||
//KX_PYMETHOD_DOC
|
||||
KX_PYMETHOD_DOC(KX_IpoActuator,Set);
|
||||
|
@@ -173,59 +173,62 @@ void KX_LightObject::UnbindShadowBuffer(RAS_IRasterizer *ras)
|
||||
GPU_lamp_shadow_buffer_unbind(lamp);
|
||||
}
|
||||
|
||||
PyObject* KX_LightObject::_getattr(const char *attr)
|
||||
PyObject* KX_LightObject::py_getattro(PyObject *attr)
|
||||
{
|
||||
if (!strcmp(attr, "layer"))
|
||||
char *attr_str= PyString_AsString(attr);
|
||||
|
||||
if (!strcmp(attr_str, "layer"))
|
||||
return PyInt_FromLong(m_lightobj.m_layer);
|
||||
|
||||
if (!strcmp(attr, "energy"))
|
||||
if (!strcmp(attr_str, "energy"))
|
||||
return PyFloat_FromDouble(m_lightobj.m_energy);
|
||||
|
||||
if (!strcmp(attr, "distance"))
|
||||
if (!strcmp(attr_str, "distance"))
|
||||
return PyFloat_FromDouble(m_lightobj.m_distance);
|
||||
|
||||
if (!strcmp(attr, "colour") || !strcmp(attr, "color"))
|
||||
if (!strcmp(attr_str, "colour") || !strcmp(attr_str, "color"))
|
||||
return Py_BuildValue("[fff]", m_lightobj.m_red, m_lightobj.m_green, m_lightobj.m_blue);
|
||||
|
||||
if (!strcmp(attr, "lin_attenuation"))
|
||||
if (!strcmp(attr_str, "lin_attenuation"))
|
||||
return PyFloat_FromDouble(m_lightobj.m_att1);
|
||||
|
||||
if (!strcmp(attr, "quad_attenuation"))
|
||||
if (!strcmp(attr_str, "quad_attenuation"))
|
||||
return PyFloat_FromDouble(m_lightobj.m_att2);
|
||||
|
||||
if (!strcmp(attr, "spotsize"))
|
||||
if (!strcmp(attr_str, "spotsize"))
|
||||
return PyFloat_FromDouble(m_lightobj.m_spotsize);
|
||||
|
||||
if (!strcmp(attr, "spotblend"))
|
||||
if (!strcmp(attr_str, "spotblend"))
|
||||
return PyFloat_FromDouble(m_lightobj.m_spotblend);
|
||||
|
||||
if (!strcmp(attr, "SPOT"))
|
||||
if (!strcmp(attr_str, "SPOT"))
|
||||
return PyInt_FromLong(RAS_LightObject::LIGHT_SPOT);
|
||||
|
||||
if (!strcmp(attr, "SUN"))
|
||||
if (!strcmp(attr_str, "SUN"))
|
||||
return PyInt_FromLong(RAS_LightObject::LIGHT_SUN);
|
||||
|
||||
if (!strcmp(attr, "NORMAL"))
|
||||
if (!strcmp(attr_str, "NORMAL"))
|
||||
return PyInt_FromLong(RAS_LightObject::LIGHT_NORMAL);
|
||||
|
||||
if (!strcmp(attr, "type"))
|
||||
if (!strcmp(attr_str, "type"))
|
||||
return PyInt_FromLong(m_lightobj.m_type);
|
||||
|
||||
_getattr_up(KX_GameObject);
|
||||
py_getattro_up(KX_GameObject);
|
||||
}
|
||||
|
||||
int KX_LightObject::_setattr(const char *attr, PyObject *pyvalue)
|
||||
int KX_LightObject::py_setattro(PyObject *attr, PyObject *pyvalue)
|
||||
{
|
||||
char *attr_str= PyString_AsString(attr);
|
||||
if (PyInt_Check(pyvalue))
|
||||
{
|
||||
int value = PyInt_AsLong(pyvalue);
|
||||
if (!strcmp(attr, "layer"))
|
||||
if (!strcmp(attr_str, "layer"))
|
||||
{
|
||||
m_lightobj.m_layer = value;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!strcmp(attr, "type"))
|
||||
if (!strcmp(attr_str, "type"))
|
||||
{
|
||||
if (value >= RAS_LightObject::LIGHT_SPOT && value <= RAS_LightObject::LIGHT_NORMAL)
|
||||
m_lightobj.m_type = (RAS_LightObject::LightType) value;
|
||||
@@ -236,37 +239,37 @@ int KX_LightObject::_setattr(const char *attr, PyObject *pyvalue)
|
||||
if (PyFloat_Check(pyvalue))
|
||||
{
|
||||
float value = PyFloat_AsDouble(pyvalue);
|
||||
if (!strcmp(attr, "energy"))
|
||||
if (!strcmp(attr_str, "energy"))
|
||||
{
|
||||
m_lightobj.m_energy = value;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!strcmp(attr, "distance"))
|
||||
if (!strcmp(attr_str, "distance"))
|
||||
{
|
||||
m_lightobj.m_distance = value;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!strcmp(attr, "lin_attenuation"))
|
||||
if (!strcmp(attr_str, "lin_attenuation"))
|
||||
{
|
||||
m_lightobj.m_att1 = value;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!strcmp(attr, "quad_attenuation"))
|
||||
if (!strcmp(attr_str, "quad_attenuation"))
|
||||
{
|
||||
m_lightobj.m_att2 = value;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!strcmp(attr, "spotsize"))
|
||||
if (!strcmp(attr_str, "spotsize"))
|
||||
{
|
||||
m_lightobj.m_spotsize = value;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!strcmp(attr, "spotblend"))
|
||||
if (!strcmp(attr_str, "spotblend"))
|
||||
{
|
||||
m_lightobj.m_spotblend = value;
|
||||
return 0;
|
||||
@@ -275,7 +278,7 @@ int KX_LightObject::_setattr(const char *attr, PyObject *pyvalue)
|
||||
|
||||
if (PySequence_Check(pyvalue))
|
||||
{
|
||||
if (!strcmp(attr, "colour") || !strcmp(attr, "color"))
|
||||
if (!strcmp(attr_str, "colour") || !strcmp(attr_str, "color"))
|
||||
{
|
||||
MT_Vector3 color;
|
||||
if (PyVecTo(pyvalue, color))
|
||||
@@ -289,13 +292,13 @@ int KX_LightObject::_setattr(const char *attr, PyObject *pyvalue)
|
||||
}
|
||||
}
|
||||
|
||||
if (!strcmp(attr, "SPOT") || !strcmp(attr, "SUN") || !strcmp(attr, "NORMAL"))
|
||||
if (!strcmp(attr_str, "SPOT") || !strcmp(attr_str, "SUN") || !strcmp(attr_str, "NORMAL"))
|
||||
{
|
||||
PyErr_Format(PyExc_RuntimeError, "Attribute %s is read only.", attr);
|
||||
PyErr_Format(PyExc_RuntimeError, "Attribute %s is read only.", attr_str);
|
||||
return 1;
|
||||
}
|
||||
|
||||
return KX_GameObject::_setattr(attr, pyvalue);
|
||||
return KX_GameObject::py_setattro(attr, pyvalue);
|
||||
}
|
||||
|
||||
PyMethodDef KX_LightObject::Methods[] = {
|
||||
@@ -308,18 +311,21 @@ PyAttributeDef KX_LightObject::Attributes[] = {
|
||||
|
||||
|
||||
PyTypeObject KX_LightObject::Type = {
|
||||
PyObject_HEAD_INIT(&PyType_Type)
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0,
|
||||
"KX_LightObject",
|
||||
sizeof(KX_LightObject),
|
||||
0,
|
||||
PyDestructor,
|
||||
0,
|
||||
__getattr,
|
||||
__setattr,
|
||||
0,
|
||||
__repr,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,
|
||||
0,
|
||||
py_base_repr,
|
||||
0,0,0,0,0,0,
|
||||
py_base_getattro,
|
||||
py_base_setattro,
|
||||
0,0,0,0,0,0,0,0,0,
|
||||
Methods
|
||||
};
|
||||
|
||||
|
@@ -62,8 +62,8 @@ public:
|
||||
void UnbindShadowBuffer(class RAS_IRasterizer *ras);
|
||||
void Update();
|
||||
|
||||
virtual PyObject* _getattr(const char *attr); /* lens, near, far, projection_matrix */
|
||||
virtual int _setattr(const char *attr, PyObject *pyvalue);
|
||||
virtual PyObject* py_getattro(PyObject *attr); /* lens, near, far, projection_matrix */
|
||||
virtual int py_setattro(PyObject *attr, PyObject *pyvalue);
|
||||
|
||||
virtual bool IsLight(void) { return true; }
|
||||
};
|
||||
|
@@ -46,18 +46,21 @@
|
||||
#include "PyObjectPlus.h"
|
||||
|
||||
PyTypeObject KX_MeshProxy::Type = {
|
||||
PyObject_HEAD_INIT(&PyType_Type)
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0,
|
||||
"KX_MeshProxy",
|
||||
sizeof(KX_MeshProxy),
|
||||
0,
|
||||
PyDestructor,
|
||||
0,
|
||||
__getattr,
|
||||
__setattr,
|
||||
0,
|
||||
__repr,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,
|
||||
0,
|
||||
py_base_repr,
|
||||
0,0,0,0,0,0,
|
||||
py_base_getattro,
|
||||
py_base_setattro,
|
||||
0,0,0,0,0,0,0,0,0,
|
||||
Methods
|
||||
};
|
||||
|
||||
@@ -94,9 +97,11 @@ void KX_MeshProxy::SetMeshModified(bool v)
|
||||
|
||||
|
||||
PyObject*
|
||||
KX_MeshProxy::_getattr(const char *attr)
|
||||
KX_MeshProxy::py_getattro(PyObject *attr)
|
||||
{
|
||||
if (!strcmp(attr, "materials"))
|
||||
char *attr_str= PyString_AsString(attr);
|
||||
|
||||
if (!strcmp(attr_str, "materials"))
|
||||
{
|
||||
PyObject *materials = PyList_New(0);
|
||||
list<RAS_MeshMaterial>::iterator mit = m_meshobj->GetFirstMaterial();
|
||||
@@ -115,7 +120,7 @@ KX_MeshProxy::_getattr(const char *attr)
|
||||
}
|
||||
return materials;
|
||||
}
|
||||
_getattr_up(SCA_IObject);
|
||||
py_getattro_up(SCA_IObject);
|
||||
}
|
||||
|
||||
|
||||
|
@@ -54,7 +54,7 @@ public:
|
||||
virtual CValue* GetReplica();
|
||||
|
||||
// stuff for python integration
|
||||
virtual PyObject* _getattr(const char *attr);
|
||||
virtual PyObject* py_getattro(PyObject *attr);
|
||||
KX_PYMETHOD(KX_MeshProxy,GetNumMaterials);
|
||||
KX_PYMETHOD(KX_MeshProxy,GetMaterialName);
|
||||
KX_PYMETHOD(KX_MeshProxy,GetTextureName);
|
||||
|
@@ -293,18 +293,21 @@ bool KX_MouseFocusSensor::ParentObjectHasFocus(void)
|
||||
|
||||
/* Integration hooks ------------------------------------------------------- */
|
||||
PyTypeObject KX_MouseFocusSensor::Type = {
|
||||
PyObject_HEAD_INIT(&PyType_Type)
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0,
|
||||
"KX_MouseFocusSensor",
|
||||
sizeof(KX_MouseFocusSensor),
|
||||
0,
|
||||
PyDestructor,
|
||||
0,
|
||||
__getattr,
|
||||
__setattr,
|
||||
0,
|
||||
__repr,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,
|
||||
0,
|
||||
py_base_repr,
|
||||
0,0,0,0,0,0,
|
||||
py_base_getattro,
|
||||
py_base_setattro,
|
||||
0,0,0,0,0,0,0,0,0,
|
||||
Methods
|
||||
};
|
||||
|
||||
@@ -333,8 +336,8 @@ PyAttributeDef KX_MouseFocusSensor::Attributes[] = {
|
||||
{ NULL } //Sentinel
|
||||
};
|
||||
|
||||
PyObject* KX_MouseFocusSensor::_getattr(const char *attr) {
|
||||
_getattr_up(SCA_MouseSensor);
|
||||
PyObject* KX_MouseFocusSensor::py_getattro(PyObject *attr) {
|
||||
py_getattro_up(SCA_MouseSensor);
|
||||
}
|
||||
|
||||
|
||||
|
@@ -87,7 +87,7 @@ class KX_MouseFocusSensor : public SCA_MouseSensor
|
||||
/* --------------------------------------------------------------------- */
|
||||
/* Python interface ---------------------------------------------------- */
|
||||
/* --------------------------------------------------------------------- */
|
||||
virtual PyObject* _getattr(const char *attr);
|
||||
virtual PyObject* py_getattro(PyObject *attr);
|
||||
|
||||
KX_PYMETHOD_DOC_NOARGS(KX_MouseFocusSensor,GetRayTarget);
|
||||
KX_PYMETHOD_DOC_NOARGS(KX_MouseFocusSensor,GetRaySource);
|
||||
|
@@ -287,18 +287,21 @@ bool KX_NearSensor::NewHandleCollision(void* obj1,void* obj2,const PHY_CollData
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
PyTypeObject KX_NearSensor::Type = {
|
||||
PyObject_HEAD_INIT(&PyType_Type)
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0,
|
||||
"KX_NearSensor",
|
||||
sizeof(KX_NearSensor),
|
||||
0,
|
||||
PyDestructor,
|
||||
0,
|
||||
__getattr,
|
||||
__setattr,
|
||||
0,
|
||||
__repr,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,
|
||||
0,
|
||||
py_base_repr,
|
||||
0,0,0,0,0,0,
|
||||
py_base_getattro,
|
||||
py_base_setattro,
|
||||
0,0,0,0,0,0,0,0,0,
|
||||
Methods
|
||||
};
|
||||
|
||||
@@ -327,20 +330,20 @@ PyAttributeDef KX_NearSensor::Attributes[] = {
|
||||
};
|
||||
|
||||
|
||||
PyObject* KX_NearSensor::_getattr(const char *attr)
|
||||
PyObject* KX_NearSensor::py_getattro(PyObject *attr)
|
||||
{
|
||||
PyObject* object = _getattr_self(Attributes, this, attr);
|
||||
PyObject* object = py_getattro_self(Attributes, this, attr);
|
||||
if (object != NULL)
|
||||
return object;
|
||||
|
||||
_getattr_up(KX_TouchSensor);
|
||||
py_getattro_up(KX_TouchSensor);
|
||||
}
|
||||
|
||||
int KX_NearSensor::_setattr(const char *attr, PyObject* value)
|
||||
int KX_NearSensor::py_setattro(PyObject*attr, PyObject* value)
|
||||
{
|
||||
int ret = _setattr_self(Attributes, this, attr, value);
|
||||
int ret = py_setattro_self(Attributes, this, attr, value);
|
||||
if (ret >= 0)
|
||||
return ret;
|
||||
|
||||
return KX_TouchSensor::_setattr(attr, value);
|
||||
return KX_TouchSensor::py_setattro(attr, value);
|
||||
}
|
||||
|
@@ -82,8 +82,8 @@ public:
|
||||
/* --------------------------------------------------------------------- */
|
||||
/* Python interface ---------------------------------------------------- */
|
||||
/* --------------------------------------------------------------------- */
|
||||
virtual PyObject* _getattr(const char *attr);
|
||||
virtual int _setattr(const char *attr, PyObject* value);
|
||||
virtual PyObject* py_getattro(PyObject *attr);
|
||||
virtual int py_setattro(PyObject *attr, PyObject* value);
|
||||
|
||||
//No methods
|
||||
|
||||
|
@@ -277,18 +277,21 @@ bool KX_ObjectActuator::isValid(KX_ObjectActuator::KX_OBJECT_ACT_VEC_TYPE type)
|
||||
|
||||
/* Integration hooks ------------------------------------------------------- */
|
||||
PyTypeObject KX_ObjectActuator::Type = {
|
||||
PyObject_HEAD_INIT(&PyType_Type)
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0,
|
||||
"KX_ObjectActuator",
|
||||
sizeof(KX_ObjectActuator),
|
||||
0,
|
||||
PyDestructor,
|
||||
0,
|
||||
__getattr,
|
||||
__setattr,
|
||||
0,
|
||||
__repr,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,
|
||||
0,
|
||||
py_base_repr,
|
||||
0,0,0,0,0,0,
|
||||
py_base_getattro,
|
||||
py_base_setattro,
|
||||
0,0,0,0,0,0,0,0,0,
|
||||
Methods
|
||||
};
|
||||
|
||||
@@ -333,8 +336,8 @@ PyAttributeDef KX_ObjectActuator::Attributes[] = {
|
||||
{ NULL } //Sentinel
|
||||
};
|
||||
|
||||
PyObject* KX_ObjectActuator::_getattr(const char *attr) {
|
||||
_getattr_up(SCA_IActuator);
|
||||
PyObject* KX_ObjectActuator::py_getattro(PyObject *attr) {
|
||||
py_getattro_up(SCA_IActuator);
|
||||
};
|
||||
|
||||
/* 1. set ------------------------------------------------------------------ */
|
||||
|
@@ -153,7 +153,7 @@ public:
|
||||
/* Python interface ---------------------------------------------------- */
|
||||
/* --------------------------------------------------------------------- */
|
||||
|
||||
virtual PyObject* _getattr(const char *attr);
|
||||
virtual PyObject* py_getattro(PyObject *attr);
|
||||
|
||||
KX_PYMETHOD_NOARGS(KX_ObjectActuator,GetForce);
|
||||
KX_PYMETHOD(KX_ObjectActuator,SetForce);
|
||||
|
@@ -139,18 +139,21 @@ bool KX_ParentActuator::Update()
|
||||
|
||||
/* Integration hooks ------------------------------------------------------- */
|
||||
PyTypeObject KX_ParentActuator::Type = {
|
||||
PyObject_HEAD_INIT(&PyType_Type)
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0,
|
||||
"KX_ParentActuator",
|
||||
sizeof(KX_ParentActuator),
|
||||
0,
|
||||
PyDestructor,
|
||||
0,
|
||||
__getattr,
|
||||
__setattr,
|
||||
0,
|
||||
__repr,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,
|
||||
0,
|
||||
py_base_repr,
|
||||
0,0,0,0,0,0,
|
||||
py_base_getattro,
|
||||
py_base_setattro,
|
||||
0,0,0,0,0,0,0,0,0,
|
||||
Methods
|
||||
};
|
||||
|
||||
@@ -204,20 +207,20 @@ int KX_ParentActuator::pyattr_set_object(void *self, const struct KX_PYATTRIBUTE
|
||||
}
|
||||
|
||||
|
||||
PyObject* KX_ParentActuator::_getattr(const char *attr) {
|
||||
PyObject* KX_ParentActuator::py_getattro(PyObject *attr) {
|
||||
|
||||
PyObject* object = _getattr_self(Attributes, this, attr);
|
||||
PyObject* object = py_getattro_self(Attributes, this, attr);
|
||||
if (object != NULL)
|
||||
return object;
|
||||
_getattr_up(SCA_IActuator);
|
||||
py_getattro_up(SCA_IActuator);
|
||||
}
|
||||
|
||||
int KX_ParentActuator::_setattr(const char *attr, PyObject* value) {
|
||||
int KX_ParentActuator::py_setattro(PyObject *attr, PyObject* value) {
|
||||
|
||||
int ret = _setattr_self(Attributes, this, attr, value);
|
||||
int ret = py_setattro_self(Attributes, this, attr, value);
|
||||
if (ret >= 0)
|
||||
return ret;
|
||||
return SCA_IActuator::_setattr(attr, value);
|
||||
return SCA_IActuator::py_setattro(attr, value);
|
||||
}
|
||||
|
||||
/* Deprecated -----> */
|
||||
|
@@ -76,8 +76,8 @@ class KX_ParentActuator : public SCA_IActuator
|
||||
/* Python interface ---------------------------------------------------- */
|
||||
/* --------------------------------------------------------------------- */
|
||||
|
||||
virtual PyObject* _getattr(const char *attr);
|
||||
virtual int _setattr(const char *attr, PyObject* value);
|
||||
virtual PyObject* py_getattro(PyObject *attr);
|
||||
virtual int py_setattro(PyObject *attr, PyObject* value);
|
||||
|
||||
/* These are used to get and set m_ob */
|
||||
static PyObject* pyattr_get_object(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef);
|
||||
|
@@ -115,22 +115,27 @@ PyObject* KX_PhysicsObjectWrapper::PySetActive(PyObject* self,
|
||||
}
|
||||
|
||||
|
||||
|
||||
PyAttributeDef KX_PhysicsObjectWrapper::Attributes[] = {
|
||||
{ NULL } //Sentinel
|
||||
};
|
||||
|
||||
//python specific stuff
|
||||
PyTypeObject KX_PhysicsObjectWrapper::Type = {
|
||||
PyObject_HEAD_INIT(&PyType_Type)
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0,
|
||||
"KX_PhysicsObjectWrapper",
|
||||
sizeof(KX_PhysicsObjectWrapper),
|
||||
0,
|
||||
PyDestructor,
|
||||
0,
|
||||
__getattr,
|
||||
__setattr,
|
||||
0,
|
||||
__repr,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,
|
||||
0,
|
||||
py_base_repr,
|
||||
0,0,0,0,0,0,
|
||||
py_base_getattro,
|
||||
py_base_setattro,
|
||||
0,0,0,0,0,0,0,0,0,
|
||||
Methods
|
||||
};
|
||||
|
||||
@@ -139,13 +144,13 @@ PyParentObject KX_PhysicsObjectWrapper::Parents[] = {
|
||||
NULL
|
||||
};
|
||||
|
||||
PyObject* KX_PhysicsObjectWrapper::_getattr(const char *attr)
|
||||
PyObject* KX_PhysicsObjectWrapper::py_getattro(PyObject *attr)
|
||||
{
|
||||
_getattr_up(PyObjectPlus);
|
||||
py_getattro_up(PyObjectPlus);
|
||||
}
|
||||
|
||||
|
||||
int KX_PhysicsObjectWrapper::_setattr(const char *attr,PyObject *pyobj)
|
||||
int KX_PhysicsObjectWrapper::py_setattro(PyObject *attr,PyObject *pyobj)
|
||||
{
|
||||
int result = 1;
|
||||
|
||||
@@ -158,7 +163,7 @@ int KX_PhysicsObjectWrapper::_setattr(const char *attr,PyObject *pyobj)
|
||||
result = 0;
|
||||
}
|
||||
if (result)
|
||||
result = PyObjectPlus::_setattr(attr,pyobj);
|
||||
result = PyObjectPlus::py_setattro(attr,pyobj);
|
||||
|
||||
return result;
|
||||
};
|
||||
|
@@ -36,8 +36,8 @@ class KX_PhysicsObjectWrapper : public PyObjectPlus
|
||||
{
|
||||
Py_Header;
|
||||
|
||||
virtual PyObject* _getattr(const char *attr);
|
||||
virtual int _setattr(const char *attr, PyObject *value);
|
||||
virtual PyObject* py_getattro(PyObject *attr);
|
||||
virtual int py_setattro(PyObject *attr, PyObject *value);
|
||||
public:
|
||||
KX_PhysicsObjectWrapper(class PHY_IPhysicsController* ctrl,class PHY_IPhysicsEnvironment* physenv,PyTypeObject *T = &Type);
|
||||
virtual ~KX_PhysicsObjectWrapper();
|
||||
|
@@ -39,18 +39,21 @@
|
||||
#include "KX_PyMath.h"
|
||||
|
||||
PyTypeObject KX_PolyProxy::Type = {
|
||||
PyObject_HEAD_INIT(&PyType_Type)
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0,
|
||||
"KX_PolyProxy",
|
||||
sizeof(KX_PolyProxy),
|
||||
0,
|
||||
PyDestructor,
|
||||
0,
|
||||
__getattr,
|
||||
__setattr,
|
||||
0,
|
||||
__repr,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,
|
||||
0,
|
||||
py_base_repr,
|
||||
0,0,0,0,0,0,
|
||||
py_base_getattro,
|
||||
py_base_setattro,
|
||||
0,0,0,0,0,0,0,0,0,
|
||||
Methods
|
||||
};
|
||||
|
||||
@@ -78,17 +81,18 @@ PyAttributeDef KX_PolyProxy::Attributes[] = {
|
||||
{ NULL } //Sentinel
|
||||
};
|
||||
|
||||
PyObject* KX_PolyProxy::_getattr(const char *attr)
|
||||
PyObject* KX_PolyProxy::py_getattro(PyObject *attr)
|
||||
{
|
||||
if (!strcmp(attr, "matname"))
|
||||
char *attr_str= PyString_AsString(attr);
|
||||
if (!strcmp(attr_str, "matname"))
|
||||
{
|
||||
return PyString_FromString(m_polygon->GetMaterial()->GetPolyMaterial()->GetMaterialName());
|
||||
}
|
||||
if (!strcmp(attr, "texture"))
|
||||
if (!strcmp(attr_str, "texture"))
|
||||
{
|
||||
return PyString_FromString(m_polygon->GetMaterial()->GetPolyMaterial()->GetTextureName());
|
||||
}
|
||||
if (!strcmp(attr, "material"))
|
||||
if (!strcmp(attr_str, "material"))
|
||||
{
|
||||
RAS_IPolyMaterial *polymat = m_polygon->GetMaterial()->GetPolyMaterial();
|
||||
if(polymat->GetFlag() & RAS_BLENDERMAT)
|
||||
@@ -104,7 +108,7 @@ PyObject* KX_PolyProxy::_getattr(const char *attr)
|
||||
return mat;
|
||||
}
|
||||
}
|
||||
if (!strcmp(attr, "matid"))
|
||||
if (!strcmp(attr_str, "matid"))
|
||||
{
|
||||
// we'll have to scan through the material bucket of the mes and compare with
|
||||
// the one of the polygon
|
||||
@@ -119,31 +123,31 @@ PyObject* KX_PolyProxy::_getattr(const char *attr)
|
||||
}
|
||||
return PyInt_FromLong(matid);
|
||||
}
|
||||
if (!strcmp(attr, "v1"))
|
||||
if (!strcmp(attr_str, "v1"))
|
||||
{
|
||||
return PyInt_FromLong(m_polygon->GetVertexOffset(0));
|
||||
}
|
||||
if (!strcmp(attr, "v2"))
|
||||
if (!strcmp(attr_str, "v2"))
|
||||
{
|
||||
return PyInt_FromLong(m_polygon->GetVertexOffset(1));
|
||||
}
|
||||
if (!strcmp(attr, "v3"))
|
||||
if (!strcmp(attr_str, "v3"))
|
||||
{
|
||||
return PyInt_FromLong(m_polygon->GetVertexOffset(2));
|
||||
}
|
||||
if (!strcmp(attr, "v4"))
|
||||
if (!strcmp(attr_str, "v4"))
|
||||
{
|
||||
return PyInt_FromLong(((m_polygon->VertexCount()>3)?m_polygon->GetVertexOffset(3):0));
|
||||
}
|
||||
if (!strcmp(attr, "visible"))
|
||||
if (!strcmp(attr_str, "visible"))
|
||||
{
|
||||
return PyInt_FromLong(m_polygon->IsVisible());
|
||||
}
|
||||
if (!strcmp(attr, "collide"))
|
||||
if (!strcmp(attr_str, "collide"))
|
||||
{
|
||||
return PyInt_FromLong(m_polygon->IsCollider());
|
||||
}
|
||||
_getattr_up(SCA_IObject);
|
||||
py_getattro_up(SCA_IObject);
|
||||
}
|
||||
|
||||
KX_PolyProxy::KX_PolyProxy(const RAS_MeshObject*mesh, RAS_Polygon* polygon)
|
||||
|
@@ -53,7 +53,7 @@ public:
|
||||
|
||||
|
||||
// stuff for python integration
|
||||
virtual PyObject* _getattr(const char *attr);
|
||||
virtual PyObject* py_getattro(PyObject *attr);
|
||||
|
||||
KX_PYMETHOD_DOC_NOARGS(KX_PolyProxy,getMaterialIndex)
|
||||
KX_PYMETHOD_DOC_NOARGS(KX_PolyProxy,getNumVertex)
|
||||
|
@@ -185,38 +185,42 @@ PyAttributeDef KX_PolygonMaterial::Attributes[] = {
|
||||
};
|
||||
|
||||
PyTypeObject KX_PolygonMaterial::Type = {
|
||||
PyObject_HEAD_INIT(&PyType_Type)
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0,
|
||||
"KX_PolygonMaterial",
|
||||
sizeof(KX_PolygonMaterial),
|
||||
0,
|
||||
PyDestructor,
|
||||
0,
|
||||
__getattr,
|
||||
__setattr,
|
||||
0,
|
||||
__repr,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,
|
||||
0,
|
||||
py_base_repr,
|
||||
0,0,0,0,0,0,
|
||||
py_base_getattro,
|
||||
py_base_setattro,
|
||||
0,0,0,0,0,0,0,0,0,
|
||||
Methods
|
||||
};
|
||||
|
||||
PyParentObject KX_PolygonMaterial::Parents[] = {
|
||||
&PyObjectPlus::Type,
|
||||
&KX_PolygonMaterial::Type,
|
||||
&PyObjectPlus::Type,
|
||||
NULL
|
||||
};
|
||||
|
||||
PyObject* KX_PolygonMaterial::_getattr(const char *attr)
|
||||
PyObject* KX_PolygonMaterial::py_getattro(PyObject *attr)
|
||||
{
|
||||
if (!strcmp(attr, "texture"))
|
||||
char *attr_str= PyString_AsString(attr);
|
||||
if (!strcmp(attr_str, "texture"))
|
||||
return PyString_FromString(m_texturename.ReadPtr());
|
||||
if (!strcmp(attr, "material"))
|
||||
if (!strcmp(attr_str, "material"))
|
||||
return PyString_FromString(m_materialname.ReadPtr());
|
||||
|
||||
if (!strcmp(attr, "tface"))
|
||||
if (!strcmp(attr_str, "tface"))
|
||||
return PyCObject_FromVoidPtr(m_tface, NULL);
|
||||
|
||||
if (!strcmp(attr, "gl_texture"))
|
||||
if (!strcmp(attr_str, "gl_texture"))
|
||||
{
|
||||
Image *ima = m_tface->tpage;
|
||||
int bind = 0;
|
||||
@@ -226,49 +230,50 @@ PyObject* KX_PolygonMaterial::_getattr(const char *attr)
|
||||
return PyInt_FromLong(bind);
|
||||
}
|
||||
|
||||
if (!strcmp(attr, "tile"))
|
||||
if (!strcmp(attr_str, "tile"))
|
||||
return PyInt_FromLong(m_tile);
|
||||
if (!strcmp(attr, "tilexrep"))
|
||||
if (!strcmp(attr_str, "tilexrep"))
|
||||
return PyInt_FromLong(m_tilexrep);
|
||||
if (!strcmp(attr, "tileyrep"))
|
||||
if (!strcmp(attr_str, "tileyrep"))
|
||||
return PyInt_FromLong(m_tileyrep);
|
||||
|
||||
if (!strcmp(attr, "drawingmode"))
|
||||
if (!strcmp(attr_str, "drawingmode"))
|
||||
return PyInt_FromLong(m_drawingmode);
|
||||
if (!strcmp(attr, "transparent"))
|
||||
if (!strcmp(attr_str, "transparent"))
|
||||
return PyInt_FromLong(m_alpha);
|
||||
if (!strcmp(attr, "zsort"))
|
||||
if (!strcmp(attr_str, "zsort"))
|
||||
return PyInt_FromLong(m_zsort);
|
||||
if (!strcmp(attr, "lightlayer"))
|
||||
if (!strcmp(attr_str, "lightlayer"))
|
||||
return PyInt_FromLong(m_lightlayer);
|
||||
if (!strcmp(attr, "triangle"))
|
||||
if (!strcmp(attr_str, "triangle"))
|
||||
// deprecated, triangle/quads shouldn't have been a material property
|
||||
return 0;
|
||||
|
||||
if (!strcmp(attr, "diffuse"))
|
||||
if (!strcmp(attr_str, "diffuse"))
|
||||
return PyObjectFrom(m_diffuse);
|
||||
if (!strcmp(attr, "shininess"))
|
||||
if (!strcmp(attr_str, "shininess"))
|
||||
return PyFloat_FromDouble(m_shininess);
|
||||
if (!strcmp(attr, "specular"))
|
||||
if (!strcmp(attr_str, "specular"))
|
||||
return PyObjectFrom(m_specular);
|
||||
if (!strcmp(attr, "specularity"))
|
||||
if (!strcmp(attr_str, "specularity"))
|
||||
return PyFloat_FromDouble(m_specularity);
|
||||
|
||||
_getattr_up(PyObjectPlus);
|
||||
py_getattro_up(PyObjectPlus);
|
||||
}
|
||||
|
||||
int KX_PolygonMaterial::_setattr(const char *attr, PyObject *pyvalue)
|
||||
int KX_PolygonMaterial::py_setattro(PyObject *attr, PyObject *pyvalue)
|
||||
{
|
||||
char *attr_str= PyString_AsString(attr);
|
||||
if (PyFloat_Check(pyvalue))
|
||||
{
|
||||
float value = PyFloat_AsDouble(pyvalue);
|
||||
if (!strcmp(attr, "shininess"))
|
||||
if (!strcmp(attr_str, "shininess"))
|
||||
{
|
||||
m_shininess = value;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!strcmp(attr, "specularity"))
|
||||
if (!strcmp(attr_str, "specularity"))
|
||||
{
|
||||
m_specularity = value;
|
||||
return 0;
|
||||
@@ -278,50 +283,50 @@ int KX_PolygonMaterial::_setattr(const char *attr, PyObject *pyvalue)
|
||||
if (PyInt_Check(pyvalue))
|
||||
{
|
||||
int value = PyInt_AsLong(pyvalue);
|
||||
if (!strcmp(attr, "tile"))
|
||||
if (!strcmp(attr_str, "tile"))
|
||||
{
|
||||
m_tile = value;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!strcmp(attr, "tilexrep"))
|
||||
if (!strcmp(attr_str, "tilexrep"))
|
||||
{
|
||||
m_tilexrep = value;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!strcmp(attr, "tileyrep"))
|
||||
if (!strcmp(attr_str, "tileyrep"))
|
||||
{
|
||||
m_tileyrep = value;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!strcmp(attr, "drawingmode"))
|
||||
if (!strcmp(attr_str, "drawingmode"))
|
||||
{
|
||||
m_drawingmode = value;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!strcmp(attr, "transparent"))
|
||||
if (!strcmp(attr_str, "transparent"))
|
||||
{
|
||||
m_alpha = value;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!strcmp(attr, "zsort"))
|
||||
if (!strcmp(attr_str, "zsort"))
|
||||
{
|
||||
m_zsort = value;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!strcmp(attr, "lightlayer"))
|
||||
if (!strcmp(attr_str, "lightlayer"))
|
||||
{
|
||||
m_lightlayer = value;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// This probably won't work...
|
||||
if (!strcmp(attr, "triangle"))
|
||||
if (!strcmp(attr_str, "triangle"))
|
||||
{
|
||||
// deprecated, triangle/quads shouldn't have been a material property
|
||||
return 0;
|
||||
@@ -335,13 +340,13 @@ int KX_PolygonMaterial::_setattr(const char *attr, PyObject *pyvalue)
|
||||
MT_Vector3 value;
|
||||
if (PyVecTo(pyvalue, value))
|
||||
{
|
||||
if (!strcmp(attr, "diffuse"))
|
||||
if (!strcmp(attr_str, "diffuse"))
|
||||
{
|
||||
m_diffuse = value;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!strcmp(attr, "specular"))
|
||||
if (!strcmp(attr_str, "specular"))
|
||||
{
|
||||
m_specular = value;
|
||||
return 0;
|
||||
@@ -350,7 +355,7 @@ int KX_PolygonMaterial::_setattr(const char *attr, PyObject *pyvalue)
|
||||
}
|
||||
}
|
||||
|
||||
return PyObjectPlus::_setattr(attr, pyvalue);
|
||||
return PyObjectPlus::py_setattro(attr, pyvalue);
|
||||
}
|
||||
|
||||
KX_PYMETHODDEF_DOC(KX_PolygonMaterial, setCustomMaterial, "setCustomMaterial(material)")
|
||||
|
@@ -115,8 +115,8 @@ public:
|
||||
KX_PYMETHOD_DOC(KX_PolygonMaterial, setCustomMaterial);
|
||||
KX_PYMETHOD_DOC(KX_PolygonMaterial, loadProgram);
|
||||
|
||||
virtual PyObject* _getattr(const char *attr);
|
||||
virtual int _setattr(const char *attr, PyObject *pyvalue);
|
||||
virtual PyObject* py_getattro(PyObject *attr);
|
||||
virtual int py_setattro(PyObject *attr, PyObject *pyvalue);
|
||||
};
|
||||
|
||||
#endif // __KX_POLYGONMATERIAL_H__
|
||||
|
@@ -73,6 +73,8 @@
|
||||
|
||||
#include "PyObjectPlus.h"
|
||||
|
||||
#include "KX_PythonInitTypes.h"
|
||||
|
||||
extern "C" {
|
||||
#include "Mathutils.h" // Blender.Mathutils module copied here so the blenderlayer can use.
|
||||
}
|
||||
@@ -1257,6 +1259,7 @@ PyObject* initGamePlayerPythonScripting(const STR_String& progname, TPythonSecur
|
||||
//importBlenderModules()
|
||||
|
||||
setSandbox(level);
|
||||
initPyTypes();
|
||||
|
||||
PyObject* moduleobj = PyImport_AddModule("__main__");
|
||||
return PyModule_GetDict(moduleobj);
|
||||
@@ -1278,6 +1281,7 @@ PyObject* initGamePythonScripting(const STR_String& progname, TPythonSecurityLev
|
||||
Py_FrozenFlag=1;
|
||||
|
||||
setSandbox(level);
|
||||
initPyTypes();
|
||||
|
||||
PyObject* moduleobj = PyImport_AddModule("__main__");
|
||||
return PyModule_GetDict(moduleobj);
|
||||
|
204
source/gameengine/Ketsji/KX_PythonInitTypes.cpp
Normal file
204
source/gameengine/Ketsji/KX_PythonInitTypes.cpp
Normal file
@@ -0,0 +1,204 @@
|
||||
/**
|
||||
* $Id: PyObjectPlus.h 19511 2009-04-03 02:16:56Z campbellbarton $
|
||||
*
|
||||
* ***** BEGIN GPL LICENSE BLOCK *****
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
|
||||
* All rights reserved.
|
||||
*
|
||||
* The Original Code is: all of this file.
|
||||
*
|
||||
* Contributor(s): Campbell Barton
|
||||
*
|
||||
* ***** END GPL LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#ifndef _adr_py_init_types_h_ // only process once,
|
||||
#define _adr_py_init_types_h_ // even if multiply included
|
||||
|
||||
/* Only for Class::Parents */
|
||||
#include "BL_BlenderShader.h"
|
||||
#include "BL_ShapeActionActuator.h"
|
||||
#include "KX_BlenderMaterial.h"
|
||||
#include "KX_CDActuator.h"
|
||||
#include "KX_CameraActuator.h"
|
||||
#include "KX_ConstraintActuator.h"
|
||||
#include "KX_ConstraintWrapper.h"
|
||||
#include "KX_GameActuator.h"
|
||||
#include "KX_Light.h"
|
||||
#include "KX_MeshProxy.h"
|
||||
#include "KX_MouseFocusSensor.h"
|
||||
#include "KX_NetworkMessageActuator.h"
|
||||
#include "KX_NetworkMessageSensor.h"
|
||||
#include "KX_ObjectActuator.h"
|
||||
#include "KX_ParentActuator.h"
|
||||
#include "KX_PhysicsObjectWrapper.h"
|
||||
#include "KX_PolyProxy.h"
|
||||
#include "KX_PolygonMaterial.h"
|
||||
#include "KX_SCA_AddObjectActuator.h"
|
||||
#include "KX_SCA_EndObjectActuator.h"
|
||||
#include "KX_SCA_ReplaceMeshActuator.h"
|
||||
#include "KX_SceneActuator.h"
|
||||
#include "KX_StateActuator.h"
|
||||
#include "KX_TrackToActuator.h"
|
||||
#include "KX_VehicleWrapper.h"
|
||||
#include "KX_VertexProxy.h"
|
||||
#include "SCA_2DFilterActuator.h"
|
||||
#include "SCA_ANDController.h"
|
||||
#include "SCA_ActuatorSensor.h"
|
||||
#include "SCA_AlwaysSensor.h"
|
||||
#include "SCA_DelaySensor.h"
|
||||
#include "SCA_JoystickSensor.h"
|
||||
#include "SCA_KeyboardSensor.h"
|
||||
#include "SCA_MouseSensor.h"
|
||||
#include "SCA_NANDController.h"
|
||||
#include "SCA_NORController.h"
|
||||
#include "SCA_ORController.h"
|
||||
#include "SCA_RandomSensor.h"
|
||||
#include "SCA_XNORController.h"
|
||||
#include "SCA_XORController.h"
|
||||
#include "KX_IpoActuator.h"
|
||||
#include "KX_NearSensor.h"
|
||||
#include "KX_RadarSensor.h"
|
||||
#include "KX_RaySensor.h"
|
||||
#include "KX_SCA_DynamicActuator.h"
|
||||
#include "KX_SoundActuator.h"
|
||||
#include "KX_TouchSensor.h"
|
||||
#include "SCA_PropertySensor.h"
|
||||
#include "SCA_PythonController.h"
|
||||
#include "SCA_RandomActuator.h"
|
||||
|
||||
|
||||
void initPyObjectPlusType(PyTypeObject **parents)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i=0; parents[i]; i++) {
|
||||
if(PyType_Ready(parents[i]) < 0) {
|
||||
/* This is very very unlikely */
|
||||
printf("Error, pytype could not initialize, Blender may crash \"%s\"\n", parents[i]->tp_name);
|
||||
return;
|
||||
}
|
||||
|
||||
#if 0
|
||||
PyObject_Print((PyObject *)parents[i], stderr, 0);
|
||||
fprintf(stderr, "\n");
|
||||
PyObject_Print(parents[i]->tp_dict, stderr, 0);
|
||||
fprintf(stderr, "\n\n");
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
PyObject *dict= NULL;
|
||||
|
||||
while(i) {
|
||||
i--;
|
||||
|
||||
if (dict) {
|
||||
PyDict_Update(parents[i]->tp_dict, dict);
|
||||
}
|
||||
dict= parents[i]->tp_dict;
|
||||
|
||||
#if 1
|
||||
PyObject_Print((PyObject *)parents[i], stderr, 0);
|
||||
fprintf(stderr, "\n");
|
||||
PyObject_Print(parents[i]->tp_dict, stderr, 0);
|
||||
fprintf(stderr, "\n\n");
|
||||
#endif
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void initPyTypes(void)
|
||||
{
|
||||
|
||||
/*
|
||||
initPyObjectPlusType(BL_ActionActuator::Parents);
|
||||
.....
|
||||
*/
|
||||
|
||||
/* For now just do PyType_Ready */
|
||||
|
||||
PyType_Ready(&BL_ActionActuator::Type);
|
||||
PyType_Ready(&BL_Shader::Type);
|
||||
PyType_Ready(&BL_ShapeActionActuator::Type);
|
||||
PyType_Ready(&CListValue::Type);
|
||||
PyType_Ready(&CValue::Type);
|
||||
PyType_Ready(&KX_BlenderMaterial::Type);
|
||||
PyType_Ready(&KX_CDActuator::Type);
|
||||
PyType_Ready(&KX_Camera::Type);
|
||||
PyType_Ready(&KX_CameraActuator::Type);
|
||||
PyType_Ready(&KX_ConstraintActuator::Type);
|
||||
PyType_Ready(&KX_ConstraintWrapper::Type);
|
||||
PyType_Ready(&KX_GameActuator::Type);
|
||||
PyType_Ready(&KX_GameObject::Type);
|
||||
PyType_Ready(&KX_IpoActuator::Type);
|
||||
PyType_Ready(&KX_LightObject::Type);
|
||||
PyType_Ready(&KX_MeshProxy::Type);
|
||||
PyType_Ready(&KX_MouseFocusSensor::Type);
|
||||
PyType_Ready(&KX_NearSensor::Type);
|
||||
PyType_Ready(&KX_NetworkMessageActuator::Type);
|
||||
PyType_Ready(&KX_NetworkMessageSensor::Type);
|
||||
PyType_Ready(&KX_ObjectActuator::Type);
|
||||
PyType_Ready(&KX_ParentActuator::Type);
|
||||
PyType_Ready(&KX_PhysicsObjectWrapper::Type);
|
||||
PyType_Ready(&KX_PolyProxy::Type);
|
||||
PyType_Ready(&KX_PolygonMaterial::Type);
|
||||
PyType_Ready(&KX_RadarSensor::Type);
|
||||
PyType_Ready(&KX_RaySensor::Type);
|
||||
PyType_Ready(&KX_SCA_AddObjectActuator::Type);
|
||||
PyType_Ready(&KX_SCA_DynamicActuator::Type);
|
||||
PyType_Ready(&KX_SCA_EndObjectActuator::Type);
|
||||
PyType_Ready(&KX_SCA_ReplaceMeshActuator::Type);
|
||||
PyType_Ready(&KX_Scene::Type);
|
||||
PyType_Ready(&KX_SceneActuator::Type);
|
||||
PyType_Ready(&KX_SoundActuator::Type);
|
||||
PyType_Ready(&KX_StateActuator::Type);
|
||||
PyType_Ready(&KX_TouchSensor::Type);
|
||||
PyType_Ready(&KX_TrackToActuator::Type);
|
||||
PyType_Ready(&KX_VehicleWrapper::Type);
|
||||
PyType_Ready(&KX_VertexProxy::Type);
|
||||
PyType_Ready(&PyObjectPlus::Type);
|
||||
PyType_Ready(&SCA_2DFilterActuator::Type);
|
||||
PyType_Ready(&SCA_ANDController::Type);
|
||||
PyType_Ready(&SCA_ActuatorSensor::Type);
|
||||
PyType_Ready(&SCA_AlwaysSensor::Type);
|
||||
PyType_Ready(&SCA_DelaySensor::Type);
|
||||
PyType_Ready(&SCA_ILogicBrick::Type);
|
||||
PyType_Ready(&SCA_IObject::Type);
|
||||
PyType_Ready(&SCA_ISensor::Type);
|
||||
PyType_Ready(&SCA_JoystickSensor::Type);
|
||||
PyType_Ready(&SCA_KeyboardSensor::Type);
|
||||
PyType_Ready(&SCA_MouseSensor::Type);
|
||||
PyType_Ready(&SCA_NANDController::Type);
|
||||
PyType_Ready(&SCA_NORController::Type);
|
||||
PyType_Ready(&SCA_ORController::Type);
|
||||
PyType_Ready(&SCA_PropertyActuator::Type);
|
||||
PyType_Ready(&SCA_PropertySensor::Type);
|
||||
PyType_Ready(&SCA_PythonController::Type);
|
||||
PyType_Ready(&SCA_RandomActuator::Type);
|
||||
PyType_Ready(&SCA_RandomSensor::Type);
|
||||
PyType_Ready(&SCA_XNORController::Type);
|
||||
PyType_Ready(&SCA_XORController::Type);
|
||||
}
|
||||
|
||||
#endif
|
35
source/gameengine/Ketsji/KX_PythonInitTypes.h
Normal file
35
source/gameengine/Ketsji/KX_PythonInitTypes.h
Normal file
@@ -0,0 +1,35 @@
|
||||
/**
|
||||
* $Id: PyObjectPlus.h 19511 2009-04-03 02:16:56Z campbellbarton $
|
||||
*
|
||||
* ***** BEGIN GPL LICENSE BLOCK *****
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
|
||||
* All rights reserved.
|
||||
*
|
||||
* The Original Code is: all of this file.
|
||||
*
|
||||
* Contributor(s): Campbell Barton
|
||||
*
|
||||
* ***** END GPL LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
#ifndef _adr_py_init_types_h_ // only process once,
|
||||
#define _adr_py_init_types_h_ // even if multiply included
|
||||
|
||||
void initPyTypes(void);
|
||||
|
||||
#endif
|
@@ -250,18 +250,21 @@ PyObject* KX_RadarSensor::PyGetConeHeight(PyObject* self) {
|
||||
/* Python Integration Hooks */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
PyTypeObject KX_RadarSensor::Type = {
|
||||
PyObject_HEAD_INIT(&PyType_Type)
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0,
|
||||
"KX_RadarSensor",
|
||||
sizeof(KX_RadarSensor),
|
||||
0,
|
||||
PyDestructor,
|
||||
0,
|
||||
__getattr,
|
||||
__setattr,
|
||||
0,
|
||||
__repr,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,
|
||||
0,
|
||||
py_base_repr,
|
||||
0,0,0,0,0,0,
|
||||
py_base_getattro,
|
||||
py_base_setattro,
|
||||
0,0,0,0,0,0,0,0,0,
|
||||
Methods
|
||||
};
|
||||
|
||||
@@ -295,20 +298,20 @@ PyAttributeDef KX_RadarSensor::Attributes[] = {
|
||||
{NULL} //Sentinel
|
||||
};
|
||||
|
||||
PyObject* KX_RadarSensor::_getattr(const char *attr)
|
||||
PyObject* KX_RadarSensor::py_getattro(PyObject *attr)
|
||||
{
|
||||
PyObject* object = _getattr_self(Attributes, this, attr);
|
||||
PyObject* object = py_getattro_self(Attributes, this, attr);
|
||||
if (object != NULL)
|
||||
return object;
|
||||
|
||||
_getattr_up(KX_NearSensor);
|
||||
py_getattro_up(KX_NearSensor);
|
||||
}
|
||||
|
||||
int KX_RadarSensor::_setattr(const char *attr, PyObject* value)
|
||||
int KX_RadarSensor::py_setattro(PyObject *attr, PyObject* value)
|
||||
{
|
||||
int ret = _setattr_self(Attributes, this, attr, value);
|
||||
int ret = py_setattro_self(Attributes, this, attr, value);
|
||||
if (ret >= 0)
|
||||
return ret;
|
||||
|
||||
return KX_NearSensor::_setattr(attr, value);
|
||||
return KX_NearSensor::py_setattro(attr, value);
|
||||
}
|
||||
|
@@ -89,8 +89,8 @@ public:
|
||||
KX_RADAR_AXIS_NEG_Z
|
||||
};
|
||||
|
||||
virtual PyObject* _getattr(const char *attr);
|
||||
virtual int _setattr(const char *attr, PyObject* value);
|
||||
virtual PyObject* py_getattro(PyObject *attr);
|
||||
virtual int py_setattro(PyObject *attr, PyObject* value);
|
||||
|
||||
//Deprecated ----->
|
||||
KX_PYMETHOD_DOC_NOARGS(KX_RadarSensor,GetConeOrigin);
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user