converted my gen_utils.h fix to PyObjectPlus.h

Also added a fix for PyMarshal_WriteObjectToString

Now I just need to figure out linking of the gameengine on my imac.

Kent
This commit is contained in:
2008-09-06 14:13:31 +00:00
parent 810f799660
commit 115cf18bed
25 changed files with 50 additions and 24 deletions

View File

@@ -45,6 +45,7 @@
Py_RETURN_NONE Py_RETURN_NONE
Python 2.4 macro. Python 2.4 macro.
defined here until we switch to 2.4 defined here until we switch to 2.4
also in PyObjectPlus.h for gameengine
*/ */
#ifndef Py_RETURN_NONE #ifndef Py_RETURN_NONE
#define Py_RETURN_NONE return Py_BuildValue("O", Py_None) #define Py_RETURN_NONE return Py_BuildValue("O", Py_None)

View File

@@ -50,7 +50,7 @@
#include "MT_Matrix4x4.h" #include "MT_Matrix4x4.h"
#include "BKE_utildefines.h" #include "BKE_utildefines.h"
#include "FloatValue.h" #include "FloatValue.h"
#include "gen_utils.h" /* Python stuff */ #include "PyObjectPlus.h"
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
#include <config.h> #include <config.h>

View File

@@ -49,8 +49,7 @@
#include "BLI_arithb.h" #include "BLI_arithb.h"
#include "MT_Matrix4x4.h" #include "MT_Matrix4x4.h"
#include "BKE_utildefines.h" #include "BKE_utildefines.h"
#include "PyObjectPlus.h"
#include "gen_utils.h" /* python stuff */
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
#include <config.h> #include <config.h>

View File

@@ -39,7 +39,6 @@ CPPFLAGS += -I$(OPENGL_HEADERS)
CPPFLAGS += -I$(NAN_STRING)/include CPPFLAGS += -I$(NAN_STRING)/include
CPPFLAGS += -I$(NAN_SOUNDSYSTEM)/include CPPFLAGS += -I$(NAN_SOUNDSYSTEM)/include
CPPFLAGS += -I$(NAN_PYTHON)/include/python$(NAN_PYTHON_VERSION) CPPFLAGS += -I$(NAN_PYTHON)/include/python$(NAN_PYTHON_VERSION)
CPPFLAGS += -I../../blender/python/api2_2x
CPPFLAGS += -I$(NAN_FUZZICS)/include -I$(NAN_SUMO) -I$(NAN_MOTO)/include CPPFLAGS += -I$(NAN_FUZZICS)/include -I$(NAN_SUMO) -I$(NAN_MOTO)/include
CPPFLAGS += -I$(NAN_SOLID)/include CPPFLAGS += -I$(NAN_SOLID)/include
CPPFLAGS += -I$(NAN_BULLET2)/include CPPFLAGS += -I$(NAN_BULLET2)/include

View File

@@ -36,7 +36,6 @@ include nan_compile.mk
CCFLAGS += $(LEVEL_1_CPP_WARNINGS) CCFLAGS += $(LEVEL_1_CPP_WARNINGS)
CPPFLAGS += -I$(NAN_PYTHON)/include/python$(NAN_PYTHON_VERSION) CPPFLAGS += -I$(NAN_PYTHON)/include/python$(NAN_PYTHON_VERSION)
CPPFLAGS += -I../../blender/python/api2_2x
CPPFLAGS += -I../../blender/makesdna CPPFLAGS += -I../../blender/makesdna
CPPFLAGS += -I$(NAN_STRING)/include CPPFLAGS += -I$(NAN_STRING)/include

View File

@@ -50,7 +50,6 @@
#include "stdlib.h" #include "stdlib.h"
#include "PyObjectPlus.h" #include "PyObjectPlus.h"
#include "STR_String.h" #include "STR_String.h"
#include "gen_utils.h"
/*------------------------------ /*------------------------------
* PyObjectPlus Type -- Every class, even the abstract one should have a Type * PyObjectPlus Type -- Every class, even the abstract one should have a Type
------------------------------*/ ------------------------------*/

View File

@@ -43,6 +43,33 @@
* Python defines * Python defines
------------------------------*/ ------------------------------*/
/*
Py_RETURN_NONE
Python 2.4 macro.
defined here until we switch to 2.4
also in api2_2x/gen_utils.h
*/
#ifndef Py_RETURN_NONE
#define Py_RETURN_NONE return Py_BuildValue("O", Py_None)
#endif
#ifndef Py_RETURN_FALSE
#define Py_RETURN_FALSE return PyBool_FromLong(0)
#endif
#ifndef Py_RETURN_TRUE
#define Py_RETURN_TRUE return PyBool_FromLong(1)
#endif
/* for pre Py 2.5 */
#if PY_VERSION_HEX < 0x02050000
typedef int Py_ssize_t;
#define PY_SSIZE_T_MAX INT_MAX
#define PY_SSIZE_T_MIN INT_MIN
#else
/* Py 2.5 and later */
#define intargfunc ssizeargfunc
#define intintargfunc ssizessizeargfunc
#endif
// some basic python macros // some basic python macros
#define Py_Return { Py_INCREF(Py_None); return Py_None;} #define Py_Return { Py_INCREF(Py_None); return Py_None;}

View File

@@ -44,7 +44,6 @@ CPPFLAGS += -I$(NAN_STRING)/include
CPPFLAGS += -I$(NAN_MOTO)/include CPPFLAGS += -I$(NAN_MOTO)/include
CPPFLAGS += -I../../blender/makesdna CPPFLAGS += -I../../blender/makesdna
CPPFLAGS += -I$(NAN_PYTHON)/include/python$(NAN_PYTHON_VERSION) CPPFLAGS += -I$(NAN_PYTHON)/include/python$(NAN_PYTHON_VERSION)
CPPFLAGS += -I../../blender/python/api2_2x
CPPFLAGS += $(NAN_SDLCFLAGS) CPPFLAGS += $(NAN_SDLCFLAGS)
CPPFLAGS += -I../../kernel/gen_system CPPFLAGS += -I../../kernel/gen_system

View File

@@ -27,7 +27,7 @@
*/ */
#include "SCA_ILogicBrick.h" #include "SCA_ILogicBrick.h"
#include "gen_utils.h" /* python stuff */ #include "PyObjectPlus.h"
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
#include <config.h> #include <config.h>

View File

@@ -30,9 +30,10 @@
#include "SCA_EventManager.h" #include "SCA_EventManager.h"
#include "SCA_LogicManager.h" #include "SCA_LogicManager.h"
#include "PyObjectPlus.h"
#include <iostream> #include <iostream>
#include "gen_utils.h" /* python stuff */
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
#include <config.h> #include <config.h>

View File

@@ -33,11 +33,11 @@
#include "SCA_LogicManager.h" #include "SCA_LogicManager.h"
#include "SCA_ISensor.h" #include "SCA_ISensor.h"
#include "SCA_IActuator.h" #include "SCA_IActuator.h"
#include "PyObjectPlus.h"
#include "compile.h" #include "compile.h"
#include "eval.h" #include "eval.h"
#include <algorithm> #include <algorithm>
#include "gen_utils.h" /* python stuff */
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
#include <config.h> #include <config.h>

View File

@@ -717,7 +717,11 @@ void GPG_Application::stopEngine()
if (gameLogic) { if (gameLogic) {
PyObject* pyGlobalDict = PyDict_GetItemString(PyModule_GetDict(gameLogic), "globalDict"); // Same as importing the module PyObject* pyGlobalDict = PyDict_GetItemString(PyModule_GetDict(gameLogic), "globalDict"); // Same as importing the module
if (pyGlobalDict) { if (pyGlobalDict) {
#ifdef Py_MARSHAL_VERSION
PyObject* pyGlobalDictMarshal = PyMarshal_WriteObjectToString( pyGlobalDict, 2); // Py_MARSHAL_VERSION == 2 as of Py2.5 PyObject* pyGlobalDictMarshal = PyMarshal_WriteObjectToString( pyGlobalDict, 2); // Py_MARSHAL_VERSION == 2 as of Py2.5
#else
PyObject* pyGlobalDictMarshal = PyMarshal_WriteObjectToString( pyGlobalDict );
#endif
if (pyGlobalDictMarshal) { if (pyGlobalDictMarshal) {
m_pyGlobalDictString_Length = PyString_Size(pyGlobalDictMarshal); m_pyGlobalDictString_Length = PyString_Size(pyGlobalDictMarshal);
PyObject_Print(pyGlobalDictMarshal, stderr, 0); PyObject_Print(pyGlobalDictMarshal, stderr, 0);

View File

@@ -15,8 +15,6 @@
#include "RAS_MeshObject.h" #include "RAS_MeshObject.h"
#include "RAS_IRasterizer.h" #include "RAS_IRasterizer.h"
#include "gen_utils.h" /* python stuff */
#define spit(x) std::cout << x << std::endl; #define spit(x) std::cout << x << std::endl;
#define SORT_UNIFORMS 1 #define SORT_UNIFORMS 1

View File

@@ -35,7 +35,7 @@
#include <math.h> #include <math.h>
#include "KX_GameObject.h" #include "KX_GameObject.h"
#include "gen_utils.h" /* Python stuff */ #include "PyObjectPlus.h"
STR_String KX_CameraActuator::X_AXIS_STRING = "x"; STR_String KX_CameraActuator::X_AXIS_STRING = "x";
STR_String KX_CameraActuator::Y_AXIS_STRING = "y"; STR_String KX_CameraActuator::Y_AXIS_STRING = "y";

View File

@@ -27,7 +27,7 @@
* ***** END GPL LICENSE BLOCK ***** * ***** END GPL LICENSE BLOCK *****
*/ */
#include <Python.h> #include <Python.h>
#include "gen_utils.h" #include "PyObjectPlus.h"
#include "KX_ConstraintWrapper.h" #include "KX_ConstraintWrapper.h"
#include "PHY_IPhysicsEnvironment.h" #include "PHY_IPhysicsEnvironment.h"

View File

@@ -65,7 +65,7 @@ typedef unsigned long uint_ptr;
#include "SCA_IActuator.h" #include "SCA_IActuator.h"
#include "SCA_ISensor.h" #include "SCA_ISensor.h"
#include "gen_utils.h" /* python stuff */ #include "PyObjectPlus.h" /* python stuff */
// This file defines relationships between parents and children // This file defines relationships between parents and children
// in the game engine. // in the game engine.

View File

@@ -43,7 +43,7 @@
#include "KX_PyMath.h" #include "KX_PyMath.h"
#include "KX_ConvertPhysicsObject.h" #include "KX_ConvertPhysicsObject.h"
#include "gen_utils.h" /* Python stuff */ #include "PyObjectPlus.h"
PyTypeObject KX_MeshProxy::Type = { PyTypeObject KX_MeshProxy::Type = {
PyObject_HEAD_INIT(&PyType_Type) PyObject_HEAD_INIT(&PyType_Type)

View File

@@ -36,7 +36,7 @@
#include "KX_GameObject.h" #include "KX_GameObject.h"
#include "KX_PythonInit.h" #include "KX_PythonInit.h"
#include "gen_utils.h" /* Python stuff */ #include "PyObjectPlus.h"
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
#include <config.h> #include <config.h>

View File

@@ -27,7 +27,7 @@
* ***** END GPL LICENSE BLOCK ***** * ***** END GPL LICENSE BLOCK *****
*/ */
#include <Python.h> #include <Python.h>
#include "gen_utils.h" #include "PyObjectPlus.h"
#include "KX_PhysicsObjectWrapper.h" #include "KX_PhysicsObjectWrapper.h"
#include "PHY_IPhysicsEnvironment.h" #include "PHY_IPhysicsEnvironment.h"

View File

@@ -34,7 +34,7 @@
#include "PHY_IPhysicsController.h" #include "PHY_IPhysicsController.h"
#include "PHY_IVehicle.h" #include "PHY_IVehicle.h"
#include "gen_utils.h" /* Python stuff */ #include "PyObjectPlus.h"
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
#include <config.h> #include <config.h>

View File

@@ -68,7 +68,7 @@
#include "KX_PyMath.h" #include "KX_PyMath.h"
#include "gen_utils.h" /* Python stuff */ #include "PyObjectPlus.h"
extern "C" { extern "C" {
#include "Mathutils.h" // Blender.Mathutils module copied here so the blenderlayer can use. #include "Mathutils.h" // Blender.Mathutils module copied here so the blenderlayer can use.

View File

@@ -39,7 +39,7 @@
#include "KX_GameObject.h" #include "KX_GameObject.h"
#include "KX_IPhysicsController.h" #include "KX_IPhysicsController.h"
#include "gen_utils.h" /* Python stuff */ #include "PyObjectPlus.h"
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
#include <config.h> #include <config.h>

View File

@@ -37,7 +37,7 @@
#include "KX_SCA_ReplaceMeshActuator.h" #include "KX_SCA_ReplaceMeshActuator.h"
#include "gen_utils.h" /* Python stuff */ #include "PyObjectPlus.h"
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
#include <config.h> #include <config.h>

View File

@@ -42,7 +42,7 @@
#include <iostream> #include <iostream>
#include "KX_GameObject.h" #include "KX_GameObject.h"
#include "gen_utils.h" /* Python stuff */ #include "PyObjectPlus.h"
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
#include <config.h> #include <config.h>

View File

@@ -1,7 +1,7 @@
#include <Python.h> #include <Python.h>
#include "gen_utils.h" #include "PyObjectPlus.h"
#include "KX_VehicleWrapper.h" #include "KX_VehicleWrapper.h"
#include "PHY_IPhysicsEnvironment.h" #include "PHY_IPhysicsEnvironment.h"