Revision: 15490
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=15490
Author:   campbellbarton
Date:     2008-07-08 19:57:31 +0200 (Tue, 08 Jul 2008)

Log Message:
-----------
bugfix - GameEngine PyObject methods did not all return when using dir(), 
because inherited methods were ignored, This made it incredibly annoying, not 
only having to search a C++ file to see what functions were available. but 
looking up methods inherited from other C++ classes.
There is still no __members__ attribute so dir() wont work at all for 
attributes.

Modified Paths:
--------------
    trunk/blender/source/gameengine/Expressions/PyObjectPlus.h

Modified: trunk/blender/source/gameengine/Expressions/PyObjectPlus.h
===================================================================
--- trunk/blender/source/gameengine/Expressions/PyObjectPlus.h  2008-07-08 
17:38:33 UTC (rev 15489)
+++ trunk/blender/source/gameengine/Expressions/PyObjectPlus.h  2008-07-08 
17:57:31 UTC (rev 15490)
@@ -76,19 +76,37 @@
   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
  * macro is one that also requires a documentation string


_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to