From cdec2b3d15ab0448e4df70496285ed95681e5972 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 19 Feb 2009 13:42:07 +0000 Subject: BGE Python API Use 'const char *' rather then the C++ 'STR_String' type for the attribute identifier of python attributes. Each attribute and method access from python was allocating and freeing the string. A simple test with getting an attribute a loop shows this speeds up attribute lookups a bit over 2x. --- source/gameengine/Ketsji/KX_StateActuator.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'source/gameengine/Ketsji/KX_StateActuator.cpp') diff --git a/source/gameengine/Ketsji/KX_StateActuator.cpp b/source/gameengine/Ketsji/KX_StateActuator.cpp index e360c4bac1f..7237d6ced1e 100644 --- a/source/gameengine/Ketsji/KX_StateActuator.cpp +++ b/source/gameengine/Ketsji/KX_StateActuator.cpp @@ -146,10 +146,7 @@ KX_StateActuator::Methods[] = { {NULL,NULL} //Sentinel }; -PyObject* -KX_StateActuator::_getattr( - const STR_String& attr - ) +PyObject* KX_StateActuator::_getattr(const char *attr) { _getattr_up(SCA_IActuator); }; -- cgit v1.2.3 From 9d5c2af1d1e11d40fec6c0da96cb37de1684f13c Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 21 Feb 2009 12:43:24 +0000 Subject: * removed typedefs that were not used (from anonymous enums and structs) * Missed some cases of using a 'char *' as an attribute * replace BGE's Py_Return macro with Pythons Py_RETURN_NONE * other minor warnings removed --- source/gameengine/Ketsji/KX_StateActuator.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source/gameengine/Ketsji/KX_StateActuator.cpp') diff --git a/source/gameengine/Ketsji/KX_StateActuator.cpp b/source/gameengine/Ketsji/KX_StateActuator.cpp index 7237d6ced1e..cd5c5d29ab1 100644 --- a/source/gameengine/Ketsji/KX_StateActuator.cpp +++ b/source/gameengine/Ketsji/KX_StateActuator.cpp @@ -173,7 +173,7 @@ KX_StateActuator::PySetOperation(PyObject* self, m_operation = oper; - Py_Return; + Py_RETURN_NONE; } /* set mask ---------------------------------------------------------- */ @@ -198,7 +198,7 @@ KX_StateActuator::PySetMask(PyObject* self, m_mask = mask; - Py_Return; + Py_RETURN_NONE; } -- cgit v1.2.3 From c785532becca59aa2d1b3ae67784b7ac2b733ec2 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 26 Feb 2009 09:04:06 +0000 Subject: Py BGE API Python dir(ob) for game types now includes attributes names, * Use "__dict__" rather then "__methods__" attribute to be Python 3.0 compatible * Added _getattr_dict() for getting the method and attribute names from a PyObject, rather then building it in the macro. * Added place holder *::Attribute array, needed for the _getattr_up macro. --- source/gameengine/Ketsji/KX_StateActuator.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source/gameengine/Ketsji/KX_StateActuator.cpp') diff --git a/source/gameengine/Ketsji/KX_StateActuator.cpp b/source/gameengine/Ketsji/KX_StateActuator.cpp index cd5c5d29ab1..0de4da79bd8 100644 --- a/source/gameengine/Ketsji/KX_StateActuator.cpp +++ b/source/gameengine/Ketsji/KX_StateActuator.cpp @@ -146,6 +146,10 @@ KX_StateActuator::Methods[] = { {NULL,NULL} //Sentinel }; +PyAttributeDef KX_StateActuator::Attributes[] = { + { NULL } //Sentinel +}; + PyObject* KX_StateActuator::_getattr(const char *attr) { _getattr_up(SCA_IActuator); -- cgit v1.2.3