Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndre Susano Pinto <andresusanopinto@gmail.com>2008-07-13 17:21:01 +0400
committerAndre Susano Pinto <andresusanopinto@gmail.com>2008-07-13 17:21:01 +0400
commit70730c722679653d6accbb0ce36840ed84baf739 (patch)
treee857975f39f0c7365da1993407d954f49f3aaf80 /source/gameengine/Expressions/PyObjectPlus.h
parent7d6e004153e356101bb37be4fb6867791eb7b251 (diff)
svn merge -r 15392:15551 https://svn.blender.org/svnroot/bf-blender/trunk/blender
Diffstat (limited to 'source/gameengine/Expressions/PyObjectPlus.h')
-rw-r--r--source/gameengine/Expressions/PyObjectPlus.h57
1 files changed, 51 insertions, 6 deletions
diff --git a/source/gameengine/Expressions/PyObjectPlus.h b/source/gameengine/Expressions/PyObjectPlus.h
index de89ed9b5c8..2bcb604dd23 100644
--- a/source/gameengine/Expressions/PyObjectPlus.h
+++ b/source/gameengine/Expressions/PyObjectPlus.h
@@ -76,18 +76,36 @@ static inline void Py_Fatal(char *M) {
virtual PyTypeObject *GetType(void) {return &Type;}; \
virtual PyParentObject *GetParents(void) {return Parents;}
+
// This defines the _getattr_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, const_cast<char*>(attr.ReadPtr())); \
- if (rvalue == NULL) \
- { \
+ PyObject *rvalue = NULL; \
+ if (attr=="__methods__") { \
+ PyObject *_attr_string = NULL; \
+ PyMethodDef *meth = Methods; \
+ rvalue = Parent::_getattr(attr); \
+ if (rvalue==NULL) { \
+ PyErr_Clear(); \
+ rvalue = PyList_New(0); \
+ } \
+ if (meth) { \
+ for (; meth->ml_name != NULL; meth++) { \
+ _attr_string = PyString_FromString(meth->ml_name); \
+ PyList_Append(rvalue, _attr_string); \
+ Py_DECREF(_attr_string); \
+ } \
+ } \
+ } else { \
+ rvalue = Py_FindMethod(Methods, this, const_cast<char*>(attr.ReadPtr())); \
+ if (rvalue == NULL) { \
PyErr_Clear(); \
- return Parent::_getattr(attr); \
+ rvalue = Parent::_getattr(attr); \
} \
- else \
- return rvalue
+ } \
+ return rvalue; \
+
/**
* These macros are helpfull when embedding Python routines. The second
@@ -99,6 +117,18 @@ static inline void Py_Fatal(char *M) {
return ((class_name*) self)->Py##method_name(self, args, kwds); \
}; \
+#define KX_PYMETHOD_NOARGS(class_name, method_name) \
+ PyObject* Py##method_name(PyObject* self); \
+ static PyObject* sPy##method_name( PyObject* self) { \
+ return ((class_name*) self)->Py##method_name(self); \
+ }; \
+
+#define KX_PYMETHOD_O(class_name, method_name) \
+ PyObject* Py##method_name(PyObject* self, PyObject* value); \
+ static PyObject* sPy##method_name( PyObject* self, PyObject* value) { \
+ return ((class_name*) self)->Py##method_name(self, value); \
+ }; \
+
#define KX_PYMETHOD_DOC(class_name, method_name) \
PyObject* Py##method_name(PyObject* self, PyObject* args, PyObject* kwds); \
static PyObject* sPy##method_name( PyObject* self, PyObject* args, PyObject* kwds) { \
@@ -106,6 +136,21 @@ static inline void Py_Fatal(char *M) {
}; \
static char method_name##_doc[]; \
+#define KX_PYMETHOD_DOC_O(class_name, method_name) \
+ PyObject* Py##method_name(PyObject* self, PyObject* value); \
+ static PyObject* sPy##method_name( PyObject* self, PyObject* value) { \
+ return ((class_name*) self)->Py##method_name(self, value); \
+ }; \
+ static char method_name##_doc[]; \
+
+#define KX_PYMETHOD_DOC_NOARGS(class_name, method_name) \
+ PyObject* Py##method_name(PyObject* self); \
+ static PyObject* sPy##method_name( PyObject* self) { \
+ return ((class_name*) self)->Py##method_name(self); \
+ }; \
+ static char method_name##_doc[]; \
+
+
/* The line above should remain empty */
/**
* Method table macro (with doc)