From 2fd6e728513f46e1f313667dfcf6b3d6e09cad39 Mon Sep 17 00:00:00 2001 From: Kester Maddock Date: Sun, 16 May 2004 13:05:15 +0000 Subject: Changed Python _getattr/_setattr methods to use const STR_String& instead of char* - makes using these methods much nicer. --- source/gameengine/Expressions/Value.h | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'source/gameengine/Expressions/Value.h') diff --git a/source/gameengine/Expressions/Value.h b/source/gameengine/Expressions/Value.h index 527dfa85d39..4656e2ca5ac 100644 --- a/source/gameengine/Expressions/Value.h +++ b/source/gameengine/Expressions/Value.h @@ -200,6 +200,20 @@ public: static char method_name##_doc[]; \ /* The line above should remain empty */ +/** + * Method table macro (with doc) + */ +#define KX_PYMETHODTABLE(class_name, method_name) \ + {#method_name , (PyCFunction) class_name::sPy##method_name, METH_VARARGS, class_name::method_name##_doc} + +/** + * Function implementation macro + */ +#define KX_PYMETHODDEF_DOC(class_name, method_name, doc_string) \ +char class_name::method_name##_doc[] = doc_string; \ +PyObject* class_name::Py##method_name(PyObject* self, PyObject* args, PyObject* kwds) + + #ifndef NO_EXP_PYTHON_EMBEDDING #include "PyObjectPlus.h" @@ -239,7 +253,7 @@ public: - PyObject* _getattr(char* attr); + virtual PyObject* _getattr(const STR_String& attr); void SpecialRelease() { @@ -266,7 +280,7 @@ public: virtual CValue* ConvertPythonToValue(PyObject* pyobj); - int _setattr(char* attr,PyObject* value); + virtual int _setattr(const STR_String& attr,PyObject* value); KX_PYMETHOD(CValue,GetName); -- cgit v1.2.3