remove python2.x support

This commit is contained in:
Campbell Barton
2009-08-10 00:07:34 +00:00
parent f71ef08744
commit 7440fee85c
106 changed files with 665 additions and 1671 deletions

View File

@@ -83,13 +83,7 @@ static PyObject *Buffer_getattr( PyObject * self, char *name );
static PyObject *Buffer_repr( PyObject * self );
PyTypeObject buffer_Type = {
#if (PY_VERSION_HEX >= 0x02060000)
PyVarObject_HEAD_INIT(NULL, 0)
#else
/* python 2.5 and below */
PyObject_HEAD_INIT( NULL ) /* required py macro */
0, /* ob_size */
#endif
"buffer", /*tp_name */
sizeof( Buffer ), /*tp_basicsize */
0, /*tp_itemsize */
@@ -1090,7 +1084,6 @@ static struct PyMethodDef BGL_methods[] = {
{NULL, NULL, 0, NULL}
};
#if (PY_VERSION_HEX >= 0x03000000)
static struct PyModuleDef BGL_module_def = {
PyModuleDef_HEAD_INIT,
"BGL", /* m_name */
@@ -1102,17 +1095,13 @@ static struct PyModuleDef BGL_module_def = {
0, /* m_clear */
0, /* m_free */
};
#endif
PyObject *BGL_Init(const char *from)
PyObject *BGL_Init(void)
{
PyObject *mod, *dict, *item;
#if (PY_VERSION_HEX >= 0x03000000)
mod = PyModule_Create(&BGL_module_def);
PyDict_SetItemString(PySys_GetObject("modules"), BGL_module_def.m_name, mod);
#else
mod= Py_InitModule(from, BGL_methods);
#endif
dict= PyModule_GetDict(mod);
if( PyType_Ready( &buffer_Type) < 0)

View File

@@ -42,9 +42,8 @@
#include <Python.h>
#include <GL/glew.h>
#include "../intern/bpy_compat.h"
PyObject *BGL_Init( const char *from );
PyObject *BGL_Init(void);
/*@ Buffer Object */
/*@ For Python access to OpenGL functions requiring a pointer. */

View File

@@ -78,7 +78,6 @@ struct PyMethodDef M_Geometry_methods[] = {
{NULL, NULL, 0, NULL}
};
#if (PY_VERSION_HEX >= 0x03000000)
static struct PyModuleDef M_Geometry_module_def = {
PyModuleDef_HEAD_INIT,
"Geometry", /* m_name */
@@ -90,19 +89,14 @@ static struct PyModuleDef M_Geometry_module_def = {
0, /* m_clear */
0, /* m_free */
};
#endif
/*----------------------------MODULE INIT-------------------------*/
PyObject *Geometry_Init(const char *from)
PyObject *Geometry_Init(void)
{
PyObject *submodule;
#if (PY_VERSION_HEX >= 0x03000000)
submodule = PyModule_Create(&M_Geometry_module_def);
PyDict_SetItemString(PySys_GetObject("modules"), M_Geometry_module_def.m_name, submodule);
#else
submodule = Py_InitModule3(from, M_Geometry_methods, M_Geometry_doc);
#endif
return (submodule);
}

View File

@@ -34,6 +34,6 @@
#include <Python.h>
#include "Mathutils.h"
PyObject *Geometry_Init( const char *from );
PyObject *Geometry_Init(void);
#endif /* EXPP_Geometry_H */

View File

@@ -94,7 +94,6 @@ struct PyMethodDef M_Mathutils_methods[] = {
/*----------------------------MODULE INIT-------------------------*/
/* from can be Blender.Mathutils or GameLogic.Mathutils for the BGE */
#if (PY_VERSION_HEX >= 0x03000000)
static struct PyModuleDef M_Mathutils_module_def = {
PyModuleDef_HEAD_INIT,
"Mathutils", /* m_name */
@@ -106,21 +105,13 @@ static struct PyModuleDef M_Mathutils_module_def = {
0, /* m_clear */
0, /* m_free */
};
#endif
PyObject *Mathutils_Init(const char *from)
PyObject *Mathutils_Init(void)
{
PyObject *submodule;
//seed the generator for the rand function
BLI_srand((unsigned int) (PIL_check_seconds_timer() * 0x7FFFFFFF));
#if (PY_VERSION_HEX < 0x03000000)
vector_Type.tp_flags |= Py_TPFLAGS_CHECKTYPES;
matrix_Type.tp_flags |= Py_TPFLAGS_CHECKTYPES;
euler_Type.tp_flags |= Py_TPFLAGS_CHECKTYPES;
quaternion_Type.tp_flags |= Py_TPFLAGS_CHECKTYPES;
#endif
if( PyType_Ready( &vector_Type ) < 0 )
return NULL;
@@ -131,12 +122,8 @@ PyObject *Mathutils_Init(const char *from)
if( PyType_Ready( &quaternion_Type ) < 0 )
return NULL;
#if (PY_VERSION_HEX >= 0x03000000)
submodule = PyModule_Create(&M_Mathutils_module_def);
PyDict_SetItemString(PySys_GetObject("modules"), M_Mathutils_module_def.m_name, submodule);
#else
submodule = Py_InitModule3(from, M_Mathutils_methods, M_Mathutils_doc);
#endif
/* each type has its own new() function */
PyModule_AddObject( submodule, "Vector", (PyObject *)&vector_Type );

View File

@@ -32,7 +32,6 @@
#define EXPP_Mathutils_H
#include <Python.h>
#include "../intern/bpy_compat.h"
#include "vector.h"
#include "matrix.h"
#include "quat.h"
@@ -55,10 +54,7 @@ PyObject *BaseMathObject_getOwner( BaseMathObject * self, void * );
PyObject *BaseMathObject_getWrapped( BaseMathObject *self, void * );
void BaseMathObject_dealloc(BaseMathObject * self);
PyObject *Mathutils_Init( const char * from );
PyObject *Mathutils_Init(void);
PyObject *quat_rotation(PyObject *arg1, PyObject *arg2);

View File

@@ -179,20 +179,12 @@ static PyObject *blender_import( PyObject * self, PyObject * args, PyObject * k
PyObject *newmodule;
//PyObject_Print(args, stderr, 0);
#if (PY_VERSION_HEX >= 0x02060000)
int dummy_val; /* what does this do?*/
static char *kwlist[] = {"name", "globals", "locals", "fromlist", "level", 0};
if( !PyArg_ParseTupleAndKeywords( args, kw, "s|OOOi:bpy_import_meth", kwlist,
&name, &globals, &locals, &fromlist, &dummy_val) )
return NULL;
#else
static char *kwlist[] = {"name", "globals", "locals", "fromlist", 0};
if( !PyArg_ParseTupleAndKeywords( args, kw, "s|OOO:bpy_import_meth", kwlist,
&name, &globals, &locals, &fromlist ) )
return NULL;
#endif
/* import existing builtin modules or modules that have been imported alredy */
newmodule = PyImport_ImportModuleEx( name, globals, locals, fromlist );

View File

@@ -32,7 +32,6 @@
#define EXPP_bpy_import_h
#include <Python.h>
#include "../intern/bpy_compat.h"
#include "compile.h" /* for the PyCodeObject */
#include "eval.h" /* for PyEval_EvalCode */

View File

@@ -547,13 +547,7 @@ static PyGetSetDef Euler_getseters[] = {
//------------------PY_OBECT DEFINITION--------------------------
PyTypeObject euler_Type = {
#if (PY_VERSION_HEX >= 0x02060000)
PyVarObject_HEAD_INIT(NULL, 0)
#else
/* python 2.5 and below */
PyObject_HEAD_INIT( NULL ) /* required py macro */
0, /* ob_size */
#endif
"euler", //tp_name
sizeof(EulerObject), //tp_basicsize
0, //tp_itemsize

View File

@@ -32,7 +32,6 @@
#define EXPP_euler_h
#include <Python.h>
#include "../intern/bpy_compat.h"
extern PyTypeObject euler_Type;
#define EulerObject_Check(_v) PyObject_TypeCheck((_v), &euler_Type)

View File

@@ -998,8 +998,6 @@ static PySequenceMethods Matrix_SeqMethods = {
};
#if (PY_VERSION_HEX >= 0x03000000)
static PyObject *Matrix_subscript(MatrixObject* self, PyObject* item)
{
if (PyIndex_Check(item)) {
@@ -1071,11 +1069,8 @@ static PyMappingMethods Matrix_AsMapping = {
(binaryfunc)Matrix_subscript,
(objobjargproc)Matrix_ass_subscript
};
#endif /* (PY_VERSION_HEX >= 0x03000000) */
#if (PY_VERSION_HEX >= 0x03000000)
static PyNumberMethods Matrix_NumMethods = {
(binaryfunc) Matrix_add, /*nb_add*/
(binaryfunc) Matrix_sub, /*nb_subtract*/
@@ -1112,33 +1107,6 @@ static PyNumberMethods Matrix_NumMethods = {
0, /* nb_inplace_true_divide */
0, /* nb_index */
};
#else
static PyNumberMethods Matrix_NumMethods = {
(binaryfunc) Matrix_add, /* __add__ */
(binaryfunc) Matrix_sub, /* __sub__ */
(binaryfunc) Matrix_mul, /* __mul__ */
(binaryfunc) 0, /* __div__ */
(binaryfunc) 0, /* __mod__ */
(binaryfunc) 0, /* __divmod__ */
(ternaryfunc) 0, /* __pow__ */
(unaryfunc) 0, /* __neg__ */
(unaryfunc) 0, /* __pos__ */
(unaryfunc) 0, /* __abs__ */
(inquiry) 0, /* __nonzero__ */
(unaryfunc) Matrix_inv, /* __invert__ */
(binaryfunc) 0, /* __lshift__ */
(binaryfunc) 0, /* __rshift__ */
(binaryfunc) 0, /* __and__ */
(binaryfunc) 0, /* __xor__ */
(binaryfunc) 0, /* __or__ */
/*(coercion)*/ 0, /* __coerce__ */
(unaryfunc) 0, /* __int__ */
(unaryfunc) 0, /* __long__ */
(unaryfunc) 0, /* __float__ */
(unaryfunc) 0, /* __oct__ */
(unaryfunc) 0, /* __hex__ */
};
#endif
static PyObject *Matrix_getRowSize( MatrixObject * self, void *type )
{
@@ -1164,13 +1132,7 @@ static PyGetSetDef Matrix_getseters[] = {
/*------------------PY_OBECT DEFINITION--------------------------*/
PyTypeObject matrix_Type = {
#if (PY_VERSION_HEX >= 0x02060000)
PyVarObject_HEAD_INIT(NULL, 0)
#else
/* python 2.5 and below */
PyObject_HEAD_INIT( NULL ) /* required py macro */
0, /* ob_size */
#endif
"matrix", /*tp_name*/
sizeof(MatrixObject), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -1182,11 +1144,7 @@ PyTypeObject matrix_Type = {
(reprfunc) Matrix_repr, /*tp_repr*/
&Matrix_NumMethods, /*tp_as_number*/
&Matrix_SeqMethods, /*tp_as_sequence*/
#if (PY_VERSION_HEX >= 0x03000000)
&Matrix_AsMapping, /*tp_as_mapping*/
#else
0,
#endif
0, /*tp_hash*/
0, /*tp_call*/
0, /*tp_str*/

View File

@@ -620,7 +620,6 @@ static PySequenceMethods Quaternion_SeqMethods = {
(ssizessizeobjargproc) Quaternion_ass_slice, /* sq_ass_slice */
};
#if (PY_VERSION_HEX >= 0x03000000)
static PyNumberMethods Quaternion_NumMethods = {
(binaryfunc) Quaternion_add, /*nb_add*/
(binaryfunc) Quaternion_sub, /*nb_subtract*/
@@ -657,33 +656,6 @@ static PyNumberMethods Quaternion_NumMethods = {
0, /* nb_inplace_true_divide */
0, /* nb_index */
};
#else
static PyNumberMethods Quaternion_NumMethods = {
(binaryfunc) Quaternion_add, /* __add__ */
(binaryfunc) Quaternion_sub, /* __sub__ */
(binaryfunc) Quaternion_mul, /* __mul__ */
(binaryfunc) 0, /* __div__ */
(binaryfunc) 0, /* __mod__ */
(binaryfunc) 0, /* __divmod__ */
(ternaryfunc) 0, /* __pow__ */
(unaryfunc) 0, /* __neg__ */
(unaryfunc) 0, /* __pos__ */
(unaryfunc) 0, /* __abs__ */
(inquiry) 0, /* __nonzero__ */
(unaryfunc) 0, /* __invert__ */
(binaryfunc) 0, /* __lshift__ */
(binaryfunc) 0, /* __rshift__ */
(binaryfunc) 0, /* __and__ */
(binaryfunc) 0, /* __xor__ */
(binaryfunc) 0, /* __or__ */
/*(coercion)*/ 0, /* __coerce__ */
(unaryfunc) 0, /* __int__ */
(unaryfunc) 0, /* __long__ */
(unaryfunc) 0, /* __float__ */
(unaryfunc) 0, /* __oct__ */
(unaryfunc) 0, /* __hex__ */
};
#endif
static PyObject *Quaternion_getAxis( QuaternionObject * self, void *type )
{
@@ -778,13 +750,7 @@ static PyGetSetDef Quaternion_getseters[] = {
//------------------PY_OBECT DEFINITION--------------------------
PyTypeObject quaternion_Type = {
#if (PY_VERSION_HEX >= 0x02060000)
PyVarObject_HEAD_INIT(NULL, 0)
#else
/* python 2.5 and below */
PyObject_HEAD_INIT( NULL ) /* required py macro */
0, /* ob_size */
#endif
"quaternion", //tp_name
sizeof(QuaternionObject), //tp_basicsize
0, //tp_itemsize

View File

@@ -32,7 +32,6 @@
#define EXPP_quat_h
#include <Python.h>
#include "../intern/bpy_compat.h"
extern PyTypeObject quaternion_Type;
#define QuaternionObject_Check(_v) PyObject_TypeCheck((_v), &quaternion_Type)

View File

@@ -1058,21 +1058,11 @@ static PySequenceMethods Vector_SeqMethods = {
(binaryfunc) 0, /* sq_concat */
(ssizeargfunc) 0, /* sq_repeat */
(ssizeargfunc) Vector_item, /* sq_item */
#if (PY_VERSION_HEX < 0x03000000)
(ssizessizeargfunc) Vector_slice, /* sq_slice */ /* PY2 ONLY */
#else
NULL,
#endif
NULL, /* py3 deprecated slice func */
(ssizeobjargproc) Vector_ass_item, /* sq_ass_item */
#if (PY_VERSION_HEX < 0x03000000)
(ssizessizeobjargproc) Vector_ass_slice, /* sq_ass_slice */ /* PY2 ONLY */
#else
NULL,
#endif
NULL, /* py3 deprecated slice assign func */
};
#if (PY_VERSION_HEX >= 0x03000000)
static PyObject *Vector_subscript(VectorObject* self, PyObject* item)
{
if (PyIndex_Check(item)) {
@@ -1144,9 +1134,8 @@ static PyMappingMethods Vector_AsMapping = {
(binaryfunc)Vector_subscript,
(objobjargproc)Vector_ass_subscript
};
#endif /* (PY_VERSION_HEX >= 0x03000000) */
#if (PY_VERSION_HEX >= 0x03000000)
static PyNumberMethods Vector_NumMethods = {
(binaryfunc) Vector_add, /*nb_add*/
(binaryfunc) Vector_sub, /*nb_subtract*/
@@ -1183,53 +1172,6 @@ static PyNumberMethods Vector_NumMethods = {
Vector_idiv, /* nb_inplace_true_divide */
0, /* nb_index */
};
#else
static PyNumberMethods Vector_NumMethods = {
(binaryfunc) Vector_add, /* __add__ */
(binaryfunc) Vector_sub, /* __sub__ */
(binaryfunc) Vector_mul, /* __mul__ */
(binaryfunc) Vector_div, /* __div__ */
(binaryfunc) NULL, /* __mod__ */
(binaryfunc) NULL, /* __divmod__ */
(ternaryfunc) NULL, /* __pow__ */
(unaryfunc) Vector_neg, /* __neg__ */
(unaryfunc) NULL, /* __pos__ */
(unaryfunc) NULL, /* __abs__ */
(inquiry) NULL, /* __nonzero__ */
(unaryfunc) NULL, /* __invert__ */
(binaryfunc) NULL, /* __lshift__ */
(binaryfunc) NULL, /* __rshift__ */
(binaryfunc) NULL, /* __and__ */
(binaryfunc) NULL, /* __xor__ */
(binaryfunc) NULL, /* __or__ */
/*(coercion)*/ NULL, /* __coerce__ */
(unaryfunc) NULL, /* __int__ */
(unaryfunc) NULL, /* __long__ */
(unaryfunc) NULL, /* __float__ */
(unaryfunc) NULL, /* __oct__ */
(unaryfunc) NULL, /* __hex__ */
/* Added in release 2.0 */
(binaryfunc) Vector_iadd, /*__iadd__*/
(binaryfunc) Vector_isub, /*__isub__*/
(binaryfunc) Vector_imul, /*__imul__*/
(binaryfunc) Vector_idiv, /*__idiv__*/
(binaryfunc) NULL, /*__imod__*/
(ternaryfunc) NULL, /*__ipow__*/
(binaryfunc) NULL, /*__ilshift__*/
(binaryfunc) NULL, /*__irshift__*/
(binaryfunc) NULL, /*__iand__*/
(binaryfunc) NULL, /*__ixor__*/
(binaryfunc) NULL, /*__ior__*/
/* Added in release 2.2 */
/* The following require the Py_TPFLAGS_HAVE_CLASS flag */
(binaryfunc) NULL, /*__floordiv__ __rfloordiv__*/
(binaryfunc) NULL, /*__truediv__ __rfloordiv__*/
(binaryfunc) NULL, /*__ifloordiv__*/
(binaryfunc) NULL, /*__itruediv__*/
};
#endif
/*------------------PY_OBECT DEFINITION--------------------------*/
@@ -1872,13 +1814,7 @@ if len(unique) != len(items):
*/
PyTypeObject vector_Type = {
#if (PY_VERSION_HEX >= 0x02060000)
PyVarObject_HEAD_INIT(NULL, 0)
#else
/* python 2.5 and below */
PyObject_HEAD_INIT( NULL ) /* required py macro */
0, /* ob_size */
#endif
/* For printing, in format "<module>.<name>" */
"vector", /* char *tp_name; */
sizeof( VectorObject ), /* int tp_basicsize; */
@@ -1897,11 +1833,7 @@ PyTypeObject vector_Type = {
&Vector_NumMethods, /* PyNumberMethods *tp_as_number; */
&Vector_SeqMethods, /* PySequenceMethods *tp_as_sequence; */
#if (PY_VERSION_HEX >= 0x03000000)
&Vector_AsMapping, /* PyMappingMethods *tp_as_mapping; */
#else
NULL,
#endif
/* More standard operations (here for binary compatibility) */

View File

@@ -31,7 +31,6 @@
#define EXPP_vector_h
#include <Python.h>
#include "../intern/bpy_compat.h"
extern PyTypeObject vector_Type;
#define VectorObject_Check(_v) PyObject_TypeCheck((_v), &vector_Type)

View File

@@ -1,126 +0,0 @@
/**
* $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* Contributor(s): Campbell Barton
*
* ***** END GPL LICENSE BLOCK *****
*/
/* This file is only to contain definitions to functions that enable
* the python api to compile with different python versions.
* no utility functions please
*/
#ifndef BPY_COMPAT_H__
#define BPY_COMPAT_H__
/* if you are NOT using python 3.0 - define these */
#if PY_VERSION_HEX < 0x03000000
#define _PyUnicode_AsString PyString_AsString
#undef PyUnicode_Check
#define PyUnicode_Check PyString_Check
#define PyLong_FromSsize_t PyInt_FromLong
#define PyLong_AsSsize_t PyInt_AsLong
#undef PyLong_Check
#define PyLong_Check PyInt_Check
#ifdef PyUnicode_FromString
#undef PyUnicode_FromString
#endif
#define PyUnicode_FromString PyString_FromString
#ifdef PyUnicode_FromFormat
#undef PyUnicode_FromFormat
#endif
#define PyUnicode_FromFormat PyString_FromFormat
#endif
#ifndef Py_REFCNT
#define Py_REFCNT(ob) (((PyObject*)(ob))->ob_refcnt)
#endif
#ifndef Py_TYPE
#define Py_TYPE(ob) (((PyObject*)(ob))->ob_type)
#endif
#ifndef Py_TYPE
#define Py_SIZE(ob) (((PyVarObject*)(ob))->ob_size)
#endif
/* older then python 2.6 - define these */
// #if (PY_VERSION_HEX < 0x02060000)
// #endif
/* older then python 2.5 - define these */
#if (PY_VERSION_HEX < 0x02050000)
#define Py_ssize_t ssize_t
typedef Py_ssize_t (*lenfunc)(PyObject *);
#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
#define PyInt_FromSsize_t PyInt_FromLong
#define PyNumber_AsSsize_t(ob, exc) PyInt_AsLong(ob)
#define PyIndex_Check(ob) PyInt_Check(ob)
#endif
#if PY_VERSION_HEX < 0x03000000
#ifndef ssizeargfunc
#define ssizeargfunc intargfunc
#endif
#ifndef ssizessizeargfunc
#define ssizessizeargfunc intintargfunc
#endif
#ifndef ssizeobjargproc
#define ssizeobjargproc intobjargproc
#endif
#ifndef ssizessizeobjargproc
#define ssizessizeobjargproc intintobjargproc
#endif
#endif
/* defined in bpy_util.c */
#if PY_VERSION_HEX < 0x03000000
PyObject *Py_CmpToRich(int op, int cmp);
#endif
#ifndef Py_CmpToRich
PyObject *Py_CmpToRich(int op, int cmp); /* bpy_util.c */
#endif
#endif /* BPY_COMPAT_H__ */

View File

@@ -14,8 +14,6 @@
#include "compile.h" /* for the PyCodeObject */
#include "eval.h" /* for PyEval_EvalCode */
#include "bpy_compat.h"
#include "bpy_rna.h"
#include "bpy_operator.h"
#include "bpy_ui.h"
@@ -149,18 +147,11 @@ static void bpy_init_modules( void )
/* stand alone utility modules not related to blender directly */
Geometry_Init("Geometry");
Mathutils_Init("Mathutils");
BGL_Init("BGL");
Geometry_Init();
Mathutils_Init();
BGL_Init();
}
#if (PY_VERSION_HEX < 0x02050000)
PyObject *PyImport_ImportModuleLevel(char *name, void *a, void *b, void *c, int d)
{
return PyImport_ImportModule(name);
}
#endif
void BPY_update_modules( void )
{
PyObject *mod= PyImport_ImportModuleLevel("bpy", NULL, NULL, NULL, 0);
@@ -244,9 +235,7 @@ void BPY_start_python( int argc, char **argv )
Py_Initialize( );
#if (PY_VERSION_HEX < 0x03000000)
PySys_SetArgv( argc, argv);
#else
// PySys_SetArgv( argc, argv); // broken in py3, not a huge deal
/* sigh, why do python guys not have a char** version anymore? :( */
{
int i;
@@ -258,7 +247,6 @@ void BPY_start_python( int argc, char **argv )
PySys_SetObject("argv", py_argv);
Py_DECREF(py_argv);
}
#endif
/* Initialize thread support (also acquires lock) */
PyEval_InitThreads();

View File

@@ -30,7 +30,6 @@
#include "bpy_operator.h"
#include "bpy_operator_wrap.h"
#include "bpy_rna.h" /* for setting arg props only - pyrna_py_to_prop() */
#include "bpy_compat.h"
#include "bpy_util.h"
#include "WM_api.h"

View File

@@ -37,7 +37,6 @@
#include "RNA_define.h"
#include "bpy_rna.h"
#include "bpy_compat.h"
#include "bpy_util.h"
#include "../generic/bpy_internal_import.h" // our own imports

View File

@@ -23,7 +23,6 @@
*/
#include "bpy_rna.h"
#include "bpy_compat.h"
#include "bpy_util.h"
//#include "blendef.h"
#include "BLI_dynstr.h"
@@ -904,10 +903,6 @@ static PyObject *prop_subscript_collection_str(BPy_PropertyRNA * self, char *key
}
/* static PyObject *prop_subscript_array_str(BPy_PropertyRNA * self, char *keyname) */
#if PY_VERSION_HEX >= 0x03000000
static PyObject *prop_subscript_collection_slice(BPy_PropertyRNA * self, int start, int stop)
{
PointerRNA newptr;
@@ -942,7 +937,6 @@ static PyObject *prop_subscript_array_slice(BPy_PropertyRNA * self, int start, i
return list;
}
#endif
static PyObject *prop_subscript_collection(BPy_PropertyRNA * self, PyObject *key)
{
@@ -956,7 +950,6 @@ static PyObject *prop_subscript_collection(BPy_PropertyRNA * self, PyObject *key
return prop_subscript_collection_int(self, i);
}
#if PY_VERSION_HEX >= 0x03000000
else if (PySlice_Check(key)) {
int len= RNA_property_collection_length(&self->ptr, self->prop);
Py_ssize_t start, stop, step, slicelength;
@@ -975,7 +968,6 @@ static PyObject *prop_subscript_collection(BPy_PropertyRNA * self, PyObject *key
return NULL;
}
}
#endif
else {
PyErr_Format(PyExc_TypeError, "invalid rna key, key must be a string or an int instead of %.200s instance.", Py_TYPE(key)->tp_name);
return NULL;
@@ -993,7 +985,6 @@ static PyObject *prop_subscript_array(BPy_PropertyRNA * self, PyObject *key)
return NULL;
return prop_subscript_array_int(self, PyLong_AsSsize_t(key));
}
#if PY_VERSION_HEX >= 0x03000000
else if (PySlice_Check(key)) {
int len= RNA_property_array_length(self->prop);
Py_ssize_t start, stop, step, slicelength;
@@ -1012,7 +1003,6 @@ static PyObject *prop_subscript_array(BPy_PropertyRNA * self, PyObject *key)
return NULL;
}
}
#endif
else {
PyErr_SetString(PyExc_AttributeError, "invalid key, key must be an int");
return NULL;
@@ -1032,7 +1022,6 @@ static PyObject *pyrna_prop_subscript( BPy_PropertyRNA * self, PyObject *key )
}
#if PY_VERSION_HEX >= 0x03000000
static int prop_subscript_ass_array_slice(BPy_PropertyRNA * self, int begin, int end, PyObject *value)
{
int count;
@@ -1049,7 +1038,6 @@ static int prop_subscript_ass_array_slice(BPy_PropertyRNA * self, int begin, int
return 0;
}
#endif
static int prop_subscript_ass_array_int(BPy_PropertyRNA * self, int keynum, PyObject *value)
{
@@ -1087,7 +1075,6 @@ static int pyrna_prop_ass_subscript( BPy_PropertyRNA * self, PyObject *key, PyOb
return prop_subscript_ass_array_int(self, i, value);
}
#if PY_VERSION_HEX >= 0x03000000
else if (PySlice_Check(key)) {
int len= RNA_property_array_length(self->prop);
Py_ssize_t start, stop, step, slicelength;
@@ -1106,7 +1093,6 @@ static int pyrna_prop_ass_subscript( BPy_PropertyRNA * self, PyObject *key, PyOb
return -1;
}
}
#endif
else {
PyErr_SetString(PyExc_AttributeError, "invalid key, key must be an int");
return -1;
@@ -1458,7 +1444,7 @@ static PyObject *pyrna_prop_get(BPy_PropertyRNA *self, PyObject *args)
}
#if (PY_VERSION_HEX >= 0x03000000) /* foreach needs py3 */
static void foreach_attr_type( BPy_PropertyRNA *self, char *attr,
/* values to assign */
RawPropertyType *raw_type, int *attr_tot, int *attr_signed )
@@ -1693,7 +1679,6 @@ static PyObject *pyrna_prop_foreach_set(BPy_PropertyRNA *self, PyObject *args)
{
return foreach_getset(self, args, 1);
}
#endif /* #if (PY_VERSION_HEX >= 0x03000000) */
/* A bit of a kludge, make a list out of a collection or array,
* then return the lists iter function, not especially fast but convenient for now */
@@ -1744,11 +1729,10 @@ static struct PyMethodDef pyrna_prop_methods[] = {
{"get", (PyCFunction)pyrna_prop_get, METH_VARARGS, NULL},
#if (PY_VERSION_HEX >= 0x03000000)
/* array accessor function */
{"foreach_get", (PyCFunction)pyrna_prop_foreach_get, METH_VARARGS, NULL},
{"foreach_set", (PyCFunction)pyrna_prop_foreach_set, METH_VARARGS, NULL},
#endif
{NULL, NULL, 0, NULL}
};
@@ -2112,13 +2096,7 @@ static PyObject * pyrna_func_call(PyObject * self, PyObject *args, PyObject *kw)
/*-----------------------BPy_StructRNA method def------------------------------*/
PyTypeObject pyrna_struct_Type = {
#if (PY_VERSION_HEX >= 0x02060000)
PyVarObject_HEAD_INIT(NULL, 0)
#else
/* python 2.5 and below */
PyObject_HEAD_INIT( NULL ) /* required py macro */
0, /* ob_size */
#endif
"StructRNA", /* tp_name */
sizeof( BPy_StructRNA ), /* tp_basicsize */
0, /* tp_itemsize */
@@ -2197,14 +2175,7 @@ PyTypeObject pyrna_struct_Type = {
/*-----------------------BPy_PropertyRNA method def------------------------------*/
PyTypeObject pyrna_prop_Type = {
#if (PY_VERSION_HEX >= 0x02060000)
PyVarObject_HEAD_INIT(NULL, 0)
#else
/* python 2.5 and below */
PyObject_HEAD_INIT( NULL ) /* required py macro */
0, /* ob_size */
#endif
"PropertyRNA", /* tp_name */
sizeof( BPy_PropertyRNA ), /* tp_basicsize */
0, /* tp_itemsize */
@@ -2555,7 +2526,6 @@ static struct PyMethodDef props_methods[] = {
{NULL, NULL, 0, NULL}
};
#if PY_VERSION_HEX >= 0x03000000
static struct PyModuleDef props_module = {
PyModuleDef_HEAD_INIT,
"bpy.props",
@@ -2564,16 +2534,11 @@ static struct PyModuleDef props_module = {
props_methods,
NULL, NULL, NULL, NULL
};
#endif
PyObject *BPY_rna_props( void )
{
PyObject *submodule;
#if PY_VERSION_HEX >= 0x03000000
submodule= PyModule_Create(&props_module);
#else /* Py2.x */
submodule= Py_InitModule3( "bpy.props", props_methods, "" );
#endif
/* INCREF since its its assumed that all these functions return the
* module with a new ref like PyDict_New, since they are passed to

View File

@@ -26,7 +26,6 @@
#include "bpy_util.h"
#include "bpy_rna.h" /* for rna buttons */
#include "bpy_operator.h" /* for setting button operator properties */
#include "bpy_compat.h"
#include "WM_types.h" /* for WM_OP_INVOKE_DEFAULT & friends */
@@ -47,7 +46,6 @@ static struct PyMethodDef ui_methods[] = {
{NULL, NULL, 0, NULL}
};
#if PY_VERSION_HEX >= 0x03000000
static struct PyModuleDef ui_module = {
PyModuleDef_HEAD_INIT,
"bpy.ui",
@@ -56,16 +54,11 @@ static struct PyModuleDef ui_module = {
ui_methods,
NULL, NULL, NULL, NULL
};
#endif
PyObject *BPY_ui_module( void )
{
PyObject *submodule, *mod;
#if PY_VERSION_HEX >= 0x03000000
submodule= PyModule_Create(&ui_module);
#else /* Py2.x */
submodule= Py_InitModule3( "bpy.ui", ui_methods, "" );
#endif
/* INCREF since its its assumed that all these functions return the
* module with a new ref like PyDict_New, since they are passed to

View File

@@ -373,11 +373,7 @@ PyObject *BPY_exception_buffer(void)
* string_io = StringIO.StringIO()
*/
#if PY_VERSION_HEX < 0x03000000
if(! (string_io_mod= PyImport_ImportModule("StringIO")) ) {
#else
if(! (string_io_mod= PyImport_ImportModule("io")) ) {
#endif
goto error_cleanup;
} else if (! (string_io = PyObject_CallMethod(string_io_mod, "StringIO", NULL))) {
goto error_cleanup;

View File

@@ -27,7 +27,10 @@
#ifndef BPY_UTIL_H
#define BPY_UTIL_H
#include "bpy_compat.h"
#if PY_VERSION_HEX < 0x03010000
#error Python versions below 3.1 are not supported anymore, you'll need to update your python.
#endif
#include "RNA_types.h" /* for EnumPropertyItem only */
struct EnumPropertyItem;