Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2010-10-30 02:59:39 +0400
committerCampbell Barton <ideasman42@gmail.com>2010-10-30 02:59:39 +0400
commitced06081b8ef2c9cefd0ed61461c54d5393ca23d (patch)
treecf3b5fd656c58bce003bc9958d3f49621f47dc2a /source/blender/python
parent719c941c58f8b4acaced83c7521a6746fdd0841f (diff)
use PyImport_ExtendInittab for py module initialization rather then adding to sys.modules directly, no functional change.
Diffstat (limited to 'source/blender/python')
-rw-r--r--source/blender/python/generic/bgl.c11
-rw-r--r--source/blender/python/generic/bgl.h2
-rw-r--r--source/blender/python/generic/blf_api.c5
-rw-r--r--source/blender/python/generic/blf_api.h3
-rw-r--r--source/blender/python/generic/mathutils.c11
-rw-r--r--source/blender/python/generic/mathutils.h3
-rw-r--r--source/blender/python/generic/mathutils_geometry.c10
-rw-r--r--source/blender/python/generic/mathutils_geometry.h2
-rw-r--r--source/blender/python/generic/noise.c5
-rw-r--r--source/blender/python/intern/bpy.c7
-rw-r--r--source/blender/python/intern/bpy_interface.c19
-rw-r--r--source/blender/python/intern/bpy_operator.c8
12 files changed, 40 insertions, 46 deletions
diff --git a/source/blender/python/generic/bgl.c b/source/blender/python/generic/bgl.c
index 86b7bc522fe..321152ab581 100644
--- a/source/blender/python/generic/bgl.c
+++ b/source/blender/python/generic/bgl.c
@@ -1115,12 +1115,11 @@ static struct PyModuleDef BGL_module_def = {
};
-PyObject *BGL_Init(void)
+PyObject *BPyInit_bgl(void)
{
- PyObject *mod, *dict, *item;
- mod = PyModule_Create(&BGL_module_def);
- PyDict_SetItemString(PyImport_GetModuleDict(), BGL_module_def.m_name, mod);
- dict= PyModule_GetDict(mod);
+ PyObject *submodule, *dict, *item;
+ submodule= PyModule_Create(&BGL_module_def);
+ dict= PyModule_GetDict(submodule);
if( PyType_Ready( &BGL_bufferType) < 0)
return NULL; /* should never happen */
@@ -1612,6 +1611,6 @@ PyObject *BGL_Init(void)
EXPP_ADDCONST(GL_TEXTURE_BINDING_1D);
EXPP_ADDCONST(GL_TEXTURE_BINDING_2D);
- return mod;
+ return submodule;
}
diff --git a/source/blender/python/generic/bgl.h b/source/blender/python/generic/bgl.h
index 80b0b90f643..5e40cda3114 100644
--- a/source/blender/python/generic/bgl.h
+++ b/source/blender/python/generic/bgl.h
@@ -38,7 +38,7 @@
#include <Python.h>
-PyObject *BGL_Init(void);
+PyObject *BPyInit_bgl(void);
/*@ Create a buffer object */
/*@ dimensions is an array of ndimensions integers representing the size of each dimension */
diff --git a/source/blender/python/generic/blf_api.c b/source/blender/python/generic/blf_api.c
index 66d8cdd923a..80e140b7eac 100644
--- a/source/blender/python/generic/blf_api.c
+++ b/source/blender/python/generic/blf_api.c
@@ -390,17 +390,16 @@ static struct PyModuleDef BLF_module_def = {
0, /* m_free */
};
-PyObject *BLF_Init(void)
+PyObject *BPyInit_blf(void)
{
PyObject *submodule;
submodule = PyModule_Create(&BLF_module_def);
- PyDict_SetItemString(PyImport_GetModuleDict(), BLF_module_def.m_name, submodule);
PyModule_AddIntConstant(submodule, "ROTATION", BLF_ROTATION);
PyModule_AddIntConstant(submodule, "CLIPPING", BLF_CLIPPING);
PyModule_AddIntConstant(submodule, "SHADOW", BLF_SHADOW);
PyModule_AddIntConstant(submodule, "KERNING_DEFAULT", BLF_KERNING_DEFAULT);
- return (submodule);
+ return submodule;
}
diff --git a/source/blender/python/generic/blf_api.h b/source/blender/python/generic/blf_api.h
index fae20ace996..db17f62337b 100644
--- a/source/blender/python/generic/blf_api.h
+++ b/source/blender/python/generic/blf_api.h
@@ -22,5 +22,4 @@
* ***** END GPL LICENSE BLOCK *****
*/
-
-PyObject *BLF_Init(void);
+PyObject *BPyInit_blf(void);
diff --git a/source/blender/python/generic/mathutils.c b/source/blender/python/generic/mathutils.c
index f6b291622e3..4f54ee9e90e 100644
--- a/source/blender/python/generic/mathutils.c
+++ b/source/blender/python/generic/mathutils.c
@@ -245,12 +245,10 @@ static struct PyModuleDef M_Mathutils_module_def = {
0, /* m_free */
};
-PyObject *Mathutils_Init(void)
+PyMODINIT_FUNC BPyInit_mathutils(void)
{
PyObject *submodule;
-
-
-
+
if( PyType_Ready( &vector_Type ) < 0 )
return NULL;
if( PyType_Ready( &matrix_Type ) < 0 )
@@ -263,7 +261,6 @@ PyObject *Mathutils_Init(void)
return NULL;
submodule = PyModule_Create(&M_Mathutils_module_def);
- PyDict_SetItemString(PyImport_GetModuleDict(), M_Mathutils_module_def.m_name, submodule);
/* each type has its own new() function */
PyModule_AddObject( submodule, "Vector", (PyObject *)&vector_Type );
@@ -273,9 +270,9 @@ PyObject *Mathutils_Init(void)
PyModule_AddObject( submodule, "Color", (PyObject *)&color_Type );
/* submodule */
- PyModule_AddObject( submodule, "geometry", Geometry_Init());
+ PyModule_AddObject( submodule, "geometry", BPyInit_mathutils_geometry());
mathutils_matrix_vector_cb_index= Mathutils_RegisterCallback(&mathutils_matrix_vector_cb);
- return (submodule);
+ return submodule;
}
diff --git a/source/blender/python/generic/mathutils.h b/source/blender/python/generic/mathutils.h
index d5dc48bd589..22f1536bb10 100644
--- a/source/blender/python/generic/mathutils.h
+++ b/source/blender/python/generic/mathutils.h
@@ -61,8 +61,7 @@ PyObject *BaseMathObject_getOwner( BaseMathObject * self, void * );
PyObject *BaseMathObject_getWrapped( BaseMathObject *self, void * );
void BaseMathObject_dealloc(BaseMathObject * self);
-PyObject *Mathutils_Init(void);
-PyObject *Noise_Init(void); /* lazy, saves having own header */
+PyMODINIT_FUNC BPyInit_mathutils(void);
int EXPP_FloatsAreEqual(float A, float B, int floatSteps);
int EXPP_VectorsAreEqual(float *vecA, float *vecB, int size, int floatSteps);
diff --git a/source/blender/python/generic/mathutils_geometry.c b/source/blender/python/generic/mathutils_geometry.c
index 1644a502fa8..e57eb4ce83d 100644
--- a/source/blender/python/generic/mathutils_geometry.c
+++ b/source/blender/python/generic/mathutils_geometry.c
@@ -830,12 +830,8 @@ static struct PyModuleDef M_Geometry_module_def = {
};
/*----------------------------MODULE INIT-------------------------*/
-PyObject *Geometry_Init(void)
+PyMODINIT_FUNC BPyInit_mathutils_geometry(void)
{
- PyObject *submodule;
-
- submodule = PyModule_Create(&M_Geometry_module_def);
- PyDict_SetItemString(PyImport_GetModuleDict(), M_Geometry_module_def.m_name, submodule);
-
- return (submodule);
+ PyObject *submodule= PyModule_Create(&M_Geometry_module_def);
+ return submodule;
}
diff --git a/source/blender/python/generic/mathutils_geometry.h b/source/blender/python/generic/mathutils_geometry.h
index 401efcc7888..3d3f7c606a4 100644
--- a/source/blender/python/generic/mathutils_geometry.h
+++ b/source/blender/python/generic/mathutils_geometry.h
@@ -34,6 +34,6 @@
#include <Python.h>
#include "mathutils.h"
-PyObject *Geometry_Init(void);
+PyMODINIT_FUNC BPyInit_mathutils_geometry(void);
#endif /* EXPP_Geometry_H */
diff --git a/source/blender/python/generic/noise.c b/source/blender/python/generic/noise.c
index a9bbc016a54..b12ca47bdda 100644
--- a/source/blender/python/generic/noise.c
+++ b/source/blender/python/generic/noise.c
@@ -122,8 +122,6 @@ static int left = 1;
static int initf = 0;
static unsigned long *next;
-PyObject *Noise_Init(void);
-
/* initializes state[N] with a seed */
static void init_genrand(unsigned long s)
{
@@ -657,10 +655,9 @@ static struct PyModuleDef noise_module_def = {
0, /* m_free */
};
-PyObject *Noise_Init(void)
+PyObject *BPyInit_noise(void)
{
PyObject *submodule = PyModule_Create(&noise_module_def);
- PyDict_SetItemString(PyImport_GetModuleDict(), noise_module_def.m_name, submodule);
/* use current time as seed for random number generator by default */
setRndSeed(0);
diff --git a/source/blender/python/intern/bpy.c b/source/blender/python/intern/bpy.c
index 5a74e8412d1..3461f1eb65d 100644
--- a/source/blender/python/intern/bpy.c
+++ b/source/blender/python/intern/bpy.c
@@ -195,12 +195,7 @@ void BPy_init_modules( void )
printf("bpy: couldnt find 'scripts/modules', blender probably wont start.\n");
}
/* stand alone utility modules not related to blender directly */
- Mathutils_Init();
- Noise_Init();
- BGL_Init();
- BLF_Init();
- IDProp_Init_Types();
- AUD_initPython();
+ IDProp_Init_Types(); /* not actually a submodule, just types */
mod = PyModule_New("_bpy");
diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c
index 47b4c114944..ab8a355be47 100644
--- a/source/blender/python/intern/bpy_interface.c
+++ b/source/blender/python/intern/bpy_interface.c
@@ -196,6 +196,22 @@ void BPY_set_context(bContext *C)
BPy_SetContext(C);
}
+/* init-tab */
+extern PyObject *BPyInit_noise(void);
+extern PyObject *BPyInit_mathutils(void);
+extern PyObject *BPyInit_bgl(void);
+extern PyObject *BPyInit_blf(void);
+extern PyObject *AUD_initPython(void);
+
+static struct _inittab bpy_internal_modules[]= {
+ {"noise", BPyInit_noise},
+ {"mathutils", BPyInit_mathutils},
+ {"bgl", BPyInit_bgl},
+ {"blf", BPyInit_blf},
+ {"aud", AUD_initPython},
+ {NULL, NULL}
+};
+
/* call BPY_set_context first */
void BPY_start_python( int argc, char **argv )
{
@@ -206,6 +222,9 @@ void BPY_start_python( int argc, char **argv )
utf8towchar(bprogname_wchar, bprogname);
Py_SetProgramName(bprogname_wchar);
+ /* builtin modules */
+ PyImport_ExtendInittab(bpy_internal_modules);
+
BPY_start_python_path(); /* allow to use our own included python */
Py_Initialize( );
diff --git a/source/blender/python/intern/bpy_operator.c b/source/blender/python/intern/bpy_operator.c
index 3ffa78dab70..1cf99218bf6 100644
--- a/source/blender/python/intern/bpy_operator.c
+++ b/source/blender/python/intern/bpy_operator.c
@@ -313,14 +313,8 @@ static struct PyModuleDef bpy_ops_module = {
PyObject *BPY_operator_module(void)
{
PyObject *submodule;
-
- submodule= PyModule_Create(&bpy_ops_module);
- PyDict_SetItemString(PyImport_GetModuleDict(), bpy_ops_module.m_name, submodule);
- /* INCREF since its its assumed that all these functions return the
- * module with a new ref like PyDict_New, since they are passed to
- * PyModule_AddObject which steals a ref */
- Py_INCREF(submodule);
+ submodule= PyModule_Create(&bpy_ops_module);
return submodule;
}