Revision: 41572
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=41572
Author:   campbellbarton
Date:     2011-11-06 01:39:36 +0000 (Sun, 06 Nov 2011)
Log Message:
-----------
PyUnicode_From_STR_String utility function which passes STR_String to 
PyUnicode_FromStringAndSize (saves a call to strlen).

Also made CValue::ConvertKeysToPython use faster list creation and improved 
some of the macro formatting.

Modified Paths:
--------------
    trunk/blender/source/gameengine/Converter/BL_ActionActuator.h
    trunk/blender/source/gameengine/Converter/BL_ArmatureActuator.h
    trunk/blender/source/gameengine/Converter/BL_ArmatureConstraint.h
    trunk/blender/source/gameengine/Converter/BL_ArmatureObject.h
    trunk/blender/source/gameengine/Converter/BL_ShapeActionActuator.h
    trunk/blender/source/gameengine/Expressions/Expression.h
    trunk/blender/source/gameengine/Expressions/ListValue.h
    trunk/blender/source/gameengine/Expressions/PyObjectPlus.cpp
    trunk/blender/source/gameengine/Expressions/PyObjectPlus.h
    trunk/blender/source/gameengine/Expressions/Value.cpp
    trunk/blender/source/gameengine/Expressions/Value.h
    trunk/blender/source/gameengine/GameLogic/SCA_2DFilterActuator.h
    trunk/blender/source/gameengine/GameLogic/SCA_ANDController.h
    trunk/blender/source/gameengine/GameLogic/SCA_ActuatorSensor.h
    trunk/blender/source/gameengine/GameLogic/SCA_AlwaysSensor.h
    trunk/blender/source/gameengine/GameLogic/SCA_DelaySensor.h
    trunk/blender/source/gameengine/GameLogic/SCA_ExpressionController.h
    trunk/blender/source/gameengine/GameLogic/SCA_IController.h
    trunk/blender/source/gameengine/GameLogic/SCA_ILogicBrick.h
    trunk/blender/source/gameengine/GameLogic/SCA_IObject.h
    trunk/blender/source/gameengine/GameLogic/SCA_ISensor.h
    trunk/blender/source/gameengine/GameLogic/SCA_JoystickSensor.h
    trunk/blender/source/gameengine/GameLogic/SCA_KeyboardSensor.h
    trunk/blender/source/gameengine/GameLogic/SCA_MouseSensor.h
    trunk/blender/source/gameengine/GameLogic/SCA_NANDController.h
    trunk/blender/source/gameengine/GameLogic/SCA_NORController.h
    trunk/blender/source/gameengine/GameLogic/SCA_ORController.h
    trunk/blender/source/gameengine/GameLogic/SCA_PropertyActuator.h
    trunk/blender/source/gameengine/GameLogic/SCA_PropertySensor.h
    trunk/blender/source/gameengine/GameLogic/SCA_PythonController.cpp
    trunk/blender/source/gameengine/GameLogic/SCA_PythonController.h
    trunk/blender/source/gameengine/GameLogic/SCA_PythonKeyboard.h
    trunk/blender/source/gameengine/GameLogic/SCA_PythonMouse.h
    trunk/blender/source/gameengine/GameLogic/SCA_RandomActuator.h
    trunk/blender/source/gameengine/GameLogic/SCA_RandomSensor.h
    trunk/blender/source/gameengine/GameLogic/SCA_XNORController.h
    trunk/blender/source/gameengine/GameLogic/SCA_XORController.h
    trunk/blender/source/gameengine/Ketsji/BL_Shader.h
    trunk/blender/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.h
    trunk/blender/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.h
    trunk/blender/source/gameengine/Ketsji/KX_ArmatureSensor.h
    trunk/blender/source/gameengine/Ketsji/KX_BlenderMaterial.h
    trunk/blender/source/gameengine/Ketsji/KX_Camera.h
    trunk/blender/source/gameengine/Ketsji/KX_CameraActuator.h
    trunk/blender/source/gameengine/Ketsji/KX_ConstraintActuator.h
    trunk/blender/source/gameengine/Ketsji/KX_ConstraintWrapper.h
    trunk/blender/source/gameengine/Ketsji/KX_FontObject.h
    trunk/blender/source/gameengine/Ketsji/KX_GameActuator.h
    trunk/blender/source/gameengine/Ketsji/KX_GameObject.cpp
    trunk/blender/source/gameengine/Ketsji/KX_GameObject.h
    trunk/blender/source/gameengine/Ketsji/KX_IpoActuator.h
    trunk/blender/source/gameengine/Ketsji/KX_Light.h
    trunk/blender/source/gameengine/Ketsji/KX_MeshProxy.cpp
    trunk/blender/source/gameengine/Ketsji/KX_MeshProxy.h
    trunk/blender/source/gameengine/Ketsji/KX_MouseFocusSensor.h
    trunk/blender/source/gameengine/Ketsji/KX_NavMeshObject.h
    trunk/blender/source/gameengine/Ketsji/KX_NearSensor.h
    trunk/blender/source/gameengine/Ketsji/KX_ObjectActuator.h
    trunk/blender/source/gameengine/Ketsji/KX_ParentActuator.h
    trunk/blender/source/gameengine/Ketsji/KX_PhysicsObjectWrapper.h
    trunk/blender/source/gameengine/Ketsji/KX_PolyProxy.cpp
    trunk/blender/source/gameengine/Ketsji/KX_PolyProxy.h
    trunk/blender/source/gameengine/Ketsji/KX_PolygonMaterial.cpp
    trunk/blender/source/gameengine/Ketsji/KX_PolygonMaterial.h
    trunk/blender/source/gameengine/Ketsji/KX_RadarSensor.h
    trunk/blender/source/gameengine/Ketsji/KX_RaySensor.h
    trunk/blender/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.h
    trunk/blender/source/gameengine/Ketsji/KX_SCA_DynamicActuator.h
    trunk/blender/source/gameengine/Ketsji/KX_SCA_EndObjectActuator.h
    trunk/blender/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.h
    trunk/blender/source/gameengine/Ketsji/KX_Scene.cpp
    trunk/blender/source/gameengine/Ketsji/KX_Scene.h
    trunk/blender/source/gameengine/Ketsji/KX_SceneActuator.h
    trunk/blender/source/gameengine/Ketsji/KX_SoundActuator.h
    trunk/blender/source/gameengine/Ketsji/KX_StateActuator.h
    trunk/blender/source/gameengine/Ketsji/KX_SteeringActuator.h
    trunk/blender/source/gameengine/Ketsji/KX_TouchSensor.h
    trunk/blender/source/gameengine/Ketsji/KX_TrackToActuator.h
    trunk/blender/source/gameengine/Ketsji/KX_VehicleWrapper.h
    trunk/blender/source/gameengine/Ketsji/KX_VertexProxy.h
    trunk/blender/source/gameengine/Ketsji/KX_VisibilityActuator.h

Modified: trunk/blender/source/gameengine/Converter/BL_ActionActuator.h
===================================================================
--- trunk/blender/source/gameengine/Converter/BL_ActionActuator.h       
2011-11-06 00:40:26 UTC (rev 41571)
+++ trunk/blender/source/gameengine/Converter/BL_ActionActuator.h       
2011-11-06 01:39:36 UTC (rev 41572)
@@ -40,7 +40,7 @@
 class BL_ActionActuator : public SCA_IActuator  
 {
 public:
-       Py_Header;
+       Py_Header
        BL_ActionActuator(SCA_IObject* gameobj,
                                                const STR_String& propname,
                                                const STR_String& framepropname,
@@ -70,8 +70,8 @@
 
 #ifdef WITH_PYTHON
 
-       KX_PYMETHOD_O(BL_ActionActuator,GetChannel);
-       KX_PYMETHOD_DOC(BL_ActionActuator,setChannel);
+       KX_PYMETHOD_O(BL_ActionActuator,GetChannel)
+       KX_PYMETHOD_DOC(BL_ActionActuator,setChannel)
 
        static PyObject*        pyattr_get_action(void *self_v, const 
KX_PYATTRIBUTE_DEF *attrdef);
        static int                      pyattr_set_action(void *self_v, const 
KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);

Modified: trunk/blender/source/gameengine/Converter/BL_ArmatureActuator.h
===================================================================
--- trunk/blender/source/gameengine/Converter/BL_ArmatureActuator.h     
2011-11-06 00:40:26 UTC (rev 41571)
+++ trunk/blender/source/gameengine/Converter/BL_ArmatureActuator.h     
2011-11-06 01:39:36 UTC (rev 41572)
@@ -46,7 +46,7 @@
 
 class  BL_ArmatureActuator : public SCA_IActuator
 {
-       Py_Header;
+       Py_Header
 public:
        BL_ArmatureActuator(SCA_IObject* gameobj,
                                                int type,

Modified: trunk/blender/source/gameengine/Converter/BL_ArmatureConstraint.h
===================================================================
--- trunk/blender/source/gameengine/Converter/BL_ArmatureConstraint.h   
2011-11-06 00:40:26 UTC (rev 41571)
+++ trunk/blender/source/gameengine/Converter/BL_ArmatureConstraint.h   
2011-11-06 01:39:36 UTC (rev 41572)
@@ -52,7 +52,7 @@
  */
 class BL_ArmatureConstraint    : public PyObjectPlus
 {
-       Py_Header;
+       Py_Header
 
 private:
        struct bConstraint* m_constraint;

Modified: trunk/blender/source/gameengine/Converter/BL_ArmatureObject.h
===================================================================
--- trunk/blender/source/gameengine/Converter/BL_ArmatureObject.h       
2011-11-06 00:40:26 UTC (rev 41571)
+++ trunk/blender/source/gameengine/Converter/BL_ArmatureObject.h       
2011-11-06 01:39:36 UTC (rev 41572)
@@ -51,7 +51,7 @@
 
 class BL_ArmatureObject : public KX_GameObject  
 {
-       Py_Header;
+       Py_Header
 public:
 
        double GetLastFrame ();

Modified: trunk/blender/source/gameengine/Converter/BL_ShapeActionActuator.h
===================================================================
--- trunk/blender/source/gameengine/Converter/BL_ShapeActionActuator.h  
2011-11-06 00:40:26 UTC (rev 41571)
+++ trunk/blender/source/gameengine/Converter/BL_ShapeActionActuator.h  
2011-11-06 01:39:36 UTC (rev 41572)
@@ -42,7 +42,7 @@
 class BL_ShapeActionActuator : public SCA_IActuator  
 {
 public:
-       Py_Header;
+       Py_Header
        BL_ShapeActionActuator(SCA_IObject* gameobj,
                                                const STR_String& propname,
                                                const STR_String& framepropname,

Modified: trunk/blender/source/gameengine/Expressions/Expression.h
===================================================================
--- trunk/blender/source/gameengine/Expressions/Expression.h    2011-11-06 
00:40:26 UTC (rev 41571)
+++ trunk/blender/source/gameengine/Expressions/Expression.h    2011-11-06 
01:39:36 UTC (rev 41572)
@@ -24,19 +24,25 @@
 //extern int gRefCountExpr; // only for debugging purposes (detect mem.leaks)
 
 
-#define PLUGIN_DECLARE_SERIAL_EXPRESSION(class_name,base_class_name)           
                                                        \
-public:                                                                        
                                                                                
                        \
-       virtual base_class_name *       Copy()                                  
        { return new class_name; }              \
-       virtual bool EdSerialize(CompressorArchive& arch,class CFactoryManager* 
facmgr,bool bIsStoring);    \
-       virtual bool EdIdSerialize(CompressorArchive& arch,class 
CFactoryManager* facmgr,bool bIsStoring)  \
-{                              \
-       if (bIsStoring)                 \
-       {                                                       \
-               unsigned char exprID = GetExpressionID(); \
-               arch << exprID;                                 \
-       }                                               \
-       return true; \
-}                              \
+#define PLUGIN_DECLARE_SERIAL_EXPRESSION(class_name, base_class_name)          
\
+public:                                                                        
\
+       virtual base_class_name * Copy() {                                      
   \
+               return new class_name;                                          
       \
+       }                                                                       
   \
+       virtual bool EdSerialize(CompressorArchive& arch,                       
   \
+                                class CFactoryManager* facmgr,                 
   \
+                                bool bIsStoring);                              
   \
+       virtual bool EdIdSerialize(CompressorArchive& arch,                     
   \
+                                  class CFactoryManager* facmgr,               
   \
+                                  bool bIsStoring)                             
   \
+       {                                                                       
   \
+               if (bIsStoring)                                                 
       \
+               {                                                               
       \
+                       unsigned char exprID = GetExpressionID();               
           \
+                       arch << exprID;                                         
           \
+               }                                                               
       \
+               return true;                                                    
       \
+       }                                                                       
   \
 
 
 

Modified: trunk/blender/source/gameengine/Expressions/ListValue.h
===================================================================
--- trunk/blender/source/gameengine/Expressions/ListValue.h     2011-11-06 
00:40:26 UTC (rev 41571)
+++ trunk/blender/source/gameengine/Expressions/ListValue.h     2011-11-06 
01:39:36 UTC (rev 41572)
@@ -23,7 +23,7 @@
 
 class CListValue : public CPropValue  
 {
-       Py_Header;
+       Py_Header
        //PLUGIN_DECLARE_SERIAL (CListValue,CValue)
 
 public:
@@ -58,7 +58,7 @@
        void Resize(int num);
        void SetValue(int i,CValue* val);
        CValue* GetValue(int i){        assertd(i < m_pValueArray.size());      
return m_pValueArray[i];}
-       int GetCount() { return m_pValueArray.size();};
+       int GetCount() { return m_pValueArray.size(); }
        virtual const STR_String & GetText();
 
        bool CheckEqual(CValue* first,CValue* second);

Modified: trunk/blender/source/gameengine/Expressions/PyObjectPlus.cpp
===================================================================
--- trunk/blender/source/gameengine/Expressions/PyObjectPlus.cpp        
2011-11-06 00:40:26 UTC (rev 41571)
+++ trunk/blender/source/gameengine/Expressions/PyObjectPlus.cpp        
2011-11-06 01:39:36 UTC (rev 41572)
@@ -470,7 +470,7 @@
                case KX_PYATTRIBUTE_TYPE_STRING:
                        {
                                STR_String *val = 
reinterpret_cast<STR_String*>(ptr);
-                               return PyUnicode_FromString(*val);
+                               return PyUnicode_From_STR_String(*val);
                        }
                case KX_PYATTRIBUTE_TYPE_CHAR:
                        {
@@ -1171,6 +1171,11 @@
        return self->m_proxy;
 }
 
+PyObject *PyUnicode_From_STR_String(const STR_String& str)
+{
+       return PyUnicode_FromStringAndSize(str.ReadPtr(), str.Length());
+}
+
 
///////////////////////////////////////////////////////////////////////////////////////////////
 
///////////////////////////////////////////////////////////////////////////////////////////////
 /* deprecation warning management */

Modified: trunk/blender/source/gameengine/Expressions/PyObjectPlus.h
===================================================================
--- trunk/blender/source/gameengine/Expressions/PyObjectPlus.h  2011-11-06 
00:40:26 UTC (rev 41571)
+++ trunk/blender/source/gameengine/Expressions/PyObjectPlus.h  2011-11-06 
01:39:36 UTC (rev 41572)
@@ -29,11 +29,12 @@
  *  \ingroup expressions
  */
 
+#ifndef _PY_OBJECT_PLUS_H
+#define _PY_OBJECT_PLUS_H
+
 /* for now keep weakrefs optional */
 #define USE_WEAKREFS
 
-#ifndef _adr_py_lib_h_                         // only process once,
-#define _adr_py_lib_h_                         // even if multiply included
 
 #ifndef __cplusplus                            // c++ only
 #error Must be compiled with C++
@@ -45,10 +46,6 @@
 #include "SG_QList.h"
 #include <stddef.h>
 
-/*------------------------------
- * Python defines
-------------------------------*/
-
 #ifdef WITH_PYTHON
 #ifdef USE_MATHUTILS
 extern "C" {
@@ -110,7 +107,7 @@
 #define BGE_PROXY_PYOWNS(_self) (((PyObjectPlus_Proxy *)_self)->py_owns)
 #define BGE_PROXY_PYREF(_self) (((PyObjectPlus_Proxy *)_self)->py_ref)
 #ifdef USE_WEAKREFS
-       #define BGE_PROXY_WKREF(_self) (((PyObjectPlus_Proxy 
*)_self)->in_weakreflist)
+#  define BGE_PROXY_WKREF(_self) (((PyObjectPlus_Proxy 
*)_self)->in_weakreflist)
 #endif
 
 /* Note, sometimes we dont care what BGE type this is as long as its a proxy */
@@ -124,45 +121,61 @@
 // PyC++ class
 // AttributesPtr correspond to attributes of proxy generic pointer 
 // each PyC++ class must be registered in KX_PythonInitTypes.cpp
-#define __Py_Header \
- public: \
-  static PyTypeObject   Type; \
-  static PyMethodDef    Methods[]; \
-  static PyAttributeDef Attributes[]; \
-  virtual PyTypeObject *GetType(void) {return &Type;}; \
-  virtual PyObject *GetProxy() {return GetProxyPlus_Ext(this, &Type, NULL);}; \
-  virtual PyObject *NewProxy(bool py_owns) {return NewProxyPlus_Ext(this, 
&Type, NULL, py_owns);}; \
+#define __Py_Header                                                           \
+public:                                                                       \
+       static PyTypeObject   Type;                                             
  \
+       static PyMethodDef    Methods[];                                        
  \
+       static PyAttributeDef Attributes[];                                     
  \
+       virtual PyTypeObject *GetType(void) {                                   
  \
+               return &Type;                                                   
      \
+       }                                                                       
  \
+       virtual PyObject *GetProxy() {                                          
  \
+               return GetProxyPlus_Ext(this, &Type, NULL);                     
      \
+       }                                                                       
  \
+       virtual PyObject *NewProxy(bool py_owns) {                              
  \
+               return NewProxyPlus_Ext(this, &Type, NULL, py_owns);            
      \
+       }                                                                       
  \
 
 // leave above line empty (macro)!
 // use this macro for class that use generic pointer in proxy

@@ Diff output truncated at 10240 characters. @@
_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to