diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-04-15 18:54:15 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-04-15 18:54:15 +0400 |
commit | 6520aa97a93e2438ddb739b2b990061ed18ab1d7 (patch) | |
tree | 661662ab9cf2b71cb245ae5f0c8f70c3dc71a687 /source/blender/python | |
parent | 24286ba5bd75b29ce454b85585272b7741c7d6c3 (diff) |
add 'idprop' module so we can document idprop.types.*, currently doc generator has no access to ID Property types.
Diffstat (limited to 'source/blender/python')
-rw-r--r-- | source/blender/python/bmesh/bmesh_py_api.c | 6 | ||||
-rw-r--r-- | source/blender/python/generic/idprop_py_api.c | 79 | ||||
-rw-r--r-- | source/blender/python/generic/idprop_py_api.h | 2 | ||||
-rw-r--r-- | source/blender/python/intern/bpy_interface.c | 3 | ||||
-rw-r--r-- | source/blender/python/mathutils/mathutils.c | 28 | ||||
-rw-r--r-- | source/blender/python/mathutils/mathutils_Color.c | 2 | ||||
-rw-r--r-- | source/blender/python/mathutils/mathutils_Euler.c | 2 | ||||
-rw-r--r-- | source/blender/python/mathutils/mathutils_Matrix.c | 2 | ||||
-rw-r--r-- | source/blender/python/mathutils/mathutils_Quaternion.c | 2 | ||||
-rw-r--r-- | source/blender/python/mathutils/mathutils_Vector.c | 2 |
10 files changed, 103 insertions, 25 deletions
diff --git a/source/blender/python/bmesh/bmesh_py_api.c b/source/blender/python/bmesh/bmesh_py_api.c index 77276df49f2..4d8d4e3bc23 100644 --- a/source/blender/python/bmesh/bmesh_py_api.c +++ b/source/blender/python/bmesh/bmesh_py_api.c @@ -129,7 +129,7 @@ PyObject *BPyInit_bmesh(void) { PyObject *mod; PyObject *submodule; - PyObject *sys_modules = PySys_GetObject("modules"); /* not pretty */ + PyObject *sys_modules = PyThreadState_GET()->interp->modules; BPy_BM_init_types(); BPy_BM_init_types_select(); @@ -140,11 +140,11 @@ PyObject *BPyInit_bmesh(void) /* bmesh.types */ PyModule_AddObject(mod, "types", (submodule = BPyInit_bmesh_types())); - PyDict_SetItemString(sys_modules, "bmesh.types", submodule); + PyDict_SetItemString(sys_modules, PyModule_GetName(submodule), submodule); Py_INCREF(submodule); PyModule_AddObject(mod, "utils", (submodule = BPyInit_bmesh_utils())); - PyDict_SetItemString(sys_modules, "bmesh.utils", submodule); + PyDict_SetItemString(sys_modules, PyModule_GetName(submodule), submodule); Py_INCREF(submodule); return mod; diff --git a/source/blender/python/generic/idprop_py_api.c b/source/blender/python/generic/idprop_py_api.c index cd2b1fb148e..9fd120b11aa 100644 --- a/source/blender/python/generic/idprop_py_api.c +++ b/source/blender/python/generic/idprop_py_api.c @@ -886,7 +886,7 @@ static PyMappingMethods BPy_IDGroup_Mapping = { PyTypeObject BPy_IDGroup_Type = { PyVarObject_HEAD_INIT(NULL, 0) /* For printing, in format "<module>.<name>" */ - "Blender IDProperty", /* char *tp_name; */ + "IDPropertyGroup", /* char *tp_name; */ sizeof(BPy_IDProperty), /* int tp_basicsize; */ 0, /* tp_itemsize; For allocation */ @@ -1236,7 +1236,7 @@ static PyMappingMethods BPy_IDArray_AsMapping = { PyTypeObject BPy_IDArray_Type = { PyVarObject_HEAD_INIT(NULL, 0) /* For printing, in format "<module>.<name>" */ - "Blender IDArray", /* char *tp_name; */ + "IDPropertyArray", /* char *tp_name; */ sizeof(BPy_IDArray), /* int tp_basicsize; */ 0, /* tp_itemsize; For allocation */ @@ -1350,7 +1350,7 @@ static PyObject *BPy_Group_Iter_Next(BPy_IDGroup_Iter *self) PyTypeObject BPy_IDGroup_Iter_Type = { PyVarObject_HEAD_INIT(NULL, 0) /* For printing, in format "<module>.<name>" */ - "Blender IDGroup_Iter", /* char *tp_name; */ + "IDPropertyGroupIter", /* char *tp_name; */ sizeof(BPy_IDGroup_Iter), /* int tp_basicsize; */ 0, /* tp_itemsize; For allocation */ @@ -1410,3 +1410,76 @@ void IDProp_Init_Types(void) PyType_Ready(&BPy_IDGroup_Iter_Type); PyType_Ready(&BPy_IDArray_Type); } + +/*----------------------------MODULE INIT-------------------------*/ + +/* --- */ + +static struct PyModuleDef IDProp_types_module_def = { + PyModuleDef_HEAD_INIT, + "idprop.types", /* m_name */ + NULL, /* m_doc */ + 0, /* m_size */ + NULL, /* m_methods */ + NULL, /* m_reload */ + NULL, /* m_traverse */ + NULL, /* m_clear */ + NULL, /* m_free */ +}; + +static PyObject *BPyInit_idprop_types(void) +{ + PyObject *submodule; + + submodule = PyModule_Create(&IDProp_types_module_def); + +#define MODULE_TYPE_ADD(s, t) \ + PyModule_AddObject(s, t.tp_name, (PyObject *)&t); Py_INCREF((PyObject *)&t) + + /* bmesh_py_types.c */ + MODULE_TYPE_ADD(submodule, BPy_IDGroup_Type); + MODULE_TYPE_ADD(submodule, BPy_IDGroup_Iter_Type); + MODULE_TYPE_ADD(submodule, BPy_IDArray_Type); + +#undef MODULE_TYPE_ADD + + return submodule; +} + +/* --- */ + +static PyMethodDef IDProp_methods[] = { + {NULL, NULL, 0, NULL} +}; + + +PyDoc_STRVAR(IDProp_module_doc, +"This module provides access id property types (currently mainly for docs)." +); +static struct PyModuleDef IDProp_module_def = { + PyModuleDef_HEAD_INIT, + "idprop", /* m_name */ + IDProp_module_doc, /* m_doc */ + 0, /* m_size */ + IDProp_methods, /* m_methods */ + NULL, /* m_reload */ + NULL, /* m_traverse */ + NULL, /* m_clear */ + NULL, /* m_free */ +}; + +PyObject *BPyInit_idprop(void) +{ + PyObject *mod; + PyObject *submodule; + PyObject *sys_modules = PyThreadState_GET()->interp->modules; + + mod = PyModule_Create(&IDProp_module_def); + + /* bmesh.types */ + PyModule_AddObject(mod, "types", (submodule = BPyInit_idprop_types())); + PyDict_SetItemString(sys_modules, PyModule_GetName(submodule), submodule); + Py_INCREF(submodule); + + return mod; +} diff --git a/source/blender/python/generic/idprop_py_api.h b/source/blender/python/generic/idprop_py_api.h index 35b130d005e..99e291f69c0 100644 --- a/source/blender/python/generic/idprop_py_api.h +++ b/source/blender/python/generic/idprop_py_api.h @@ -64,6 +64,8 @@ const char *BPy_IDProperty_Map_ValidateAndCreate(PyObject *key, struct IDPropert void IDProp_Init_Types(void); +PyObject *BPyInit_idprop(void); + #define IDPROP_ITER_KEYS 0 #define IDPROP_ITER_ITEMS 1 diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c index f68ef6838e8..f370c06194a 100644 --- a/source/blender/python/intern/bpy_interface.c +++ b/source/blender/python/intern/bpy_interface.c @@ -74,9 +74,11 @@ /* inittab initialization functions */ #include "../generic/bgl.h" #include "../generic/blf_py_api.h" +#include "../generic/idprop_py_api.h" #include "../bmesh/bmesh_py_api.h" #include "../mathutils/mathutils.h" + /* for internal use, when starting and ending python scripts */ /* in case a python script triggers another python call, stop bpy_context_clear from invalidating */ @@ -211,6 +213,7 @@ static struct _inittab bpy_internal_modules[] = { {(char *)"_cycles", CCL_initPython}, #endif {(char *)"gpu", GPU_initPython}, + {(char *)"idprop", BPyInit_idprop}, {NULL, NULL} }; diff --git a/source/blender/python/mathutils/mathutils.c b/source/blender/python/mathutils/mathutils.c index 5ae58973602..f78050a7639 100644 --- a/source/blender/python/mathutils/mathutils.c +++ b/source/blender/python/mathutils/mathutils.c @@ -433,8 +433,8 @@ static struct PyModuleDef M_Mathutils_module_def = { PyMODINIT_FUNC PyInit_mathutils(void) { + PyObject *mod; PyObject *submodule; - PyObject *item; PyObject *sys_modules = PyThreadState_GET()->interp->modules; if (PyType_Ready(&vector_Type) < 0) @@ -450,31 +450,31 @@ PyMODINIT_FUNC PyInit_mathutils(void) if (PyType_Ready(&color_Type) < 0) return NULL; - submodule = PyModule_Create(&M_Mathutils_module_def); + mod = PyModule_Create(&M_Mathutils_module_def); /* each type has its own new() function */ - PyModule_AddObject(submodule, "Vector", (PyObject *)&vector_Type); - PyModule_AddObject(submodule, "Matrix", (PyObject *)&matrix_Type); - PyModule_AddObject(submodule, "Euler", (PyObject *)&euler_Type); - PyModule_AddObject(submodule, "Quaternion", (PyObject *)&quaternion_Type); - PyModule_AddObject(submodule, "Color", (PyObject *)&color_Type); + PyModule_AddObject(mod, vector_Type.tp_name, (PyObject *)&vector_Type); + PyModule_AddObject(mod, matrix_Type.tp_name, (PyObject *)&matrix_Type); + PyModule_AddObject(mod, euler_Type.tp_name, (PyObject *)&euler_Type); + PyModule_AddObject(mod, quaternion_Type.tp_name, (PyObject *)&quaternion_Type); + PyModule_AddObject(mod, color_Type.tp_name, (PyObject *)&color_Type); /* submodule */ - PyModule_AddObject(submodule, "geometry", (item = PyInit_mathutils_geometry())); + PyModule_AddObject(mod, "geometry", (submodule = PyInit_mathutils_geometry())); /* XXX, python doesnt do imports with this usefully yet * 'from mathutils.geometry import PolyFill' * ...fails without this. */ - PyDict_SetItemString(sys_modules, "mathutils.geometry", item); - Py_INCREF(item); + PyDict_SetItemString(sys_modules, PyModule_GetName(submodule), submodule); + Py_INCREF(submodule); /* Noise submodule */ - PyModule_AddObject(submodule, "noise", (item = PyInit_mathutils_noise())); - PyDict_SetItemString(sys_modules, "mathutils.noise", item); - Py_INCREF(item); + PyModule_AddObject(mod, "noise", (submodule = PyInit_mathutils_noise())); + PyDict_SetItemString(sys_modules, PyModule_GetName(submodule), submodule); + Py_INCREF(submodule); mathutils_matrix_row_cb_index = Mathutils_RegisterCallback(&mathutils_matrix_row_cb); mathutils_matrix_col_cb_index = Mathutils_RegisterCallback(&mathutils_matrix_col_cb); mathutils_matrix_translation_cb_index = Mathutils_RegisterCallback(&mathutils_matrix_translation_cb); - return submodule; + return mod; } diff --git a/source/blender/python/mathutils/mathutils_Color.c b/source/blender/python/mathutils/mathutils_Color.c index 9b06214b8ec..fc8b2886f37 100644 --- a/source/blender/python/mathutils/mathutils_Color.c +++ b/source/blender/python/mathutils/mathutils_Color.c @@ -807,7 +807,7 @@ PyDoc_STRVAR(color_doc, ); PyTypeObject color_Type = { PyVarObject_HEAD_INIT(NULL, 0) - "mathutils.Color", //tp_name + "Color", //tp_name sizeof(ColorObject), //tp_basicsize 0, //tp_itemsize (destructor)BaseMathObject_dealloc, //tp_dealloc diff --git a/source/blender/python/mathutils/mathutils_Euler.c b/source/blender/python/mathutils/mathutils_Euler.c index 4e3b5f8d52e..a663bd71130 100644 --- a/source/blender/python/mathutils/mathutils_Euler.c +++ b/source/blender/python/mathutils/mathutils_Euler.c @@ -650,7 +650,7 @@ PyDoc_STRVAR(euler_doc, ); PyTypeObject euler_Type = { PyVarObject_HEAD_INIT(NULL, 0) - "mathutils.Euler", //tp_name + "Euler", //tp_name sizeof(EulerObject), //tp_basicsize 0, //tp_itemsize (destructor)BaseMathObject_dealloc, //tp_dealloc diff --git a/source/blender/python/mathutils/mathutils_Matrix.c b/source/blender/python/mathutils/mathutils_Matrix.c index bd37b645cbb..a48e7ed854d 100644 --- a/source/blender/python/mathutils/mathutils_Matrix.c +++ b/source/blender/python/mathutils/mathutils_Matrix.c @@ -2316,7 +2316,7 @@ PyDoc_STRVAR(matrix_doc, ); PyTypeObject matrix_Type = { PyVarObject_HEAD_INIT(NULL, 0) - "mathutils.Matrix", /*tp_name*/ + "Matrix", /*tp_name*/ sizeof(MatrixObject), /*tp_basicsize*/ 0, /*tp_itemsize*/ (destructor)BaseMathObject_dealloc, /*tp_dealloc*/ diff --git a/source/blender/python/mathutils/mathutils_Quaternion.c b/source/blender/python/mathutils/mathutils_Quaternion.c index 2a1cef5a241..d1da4660f3b 100644 --- a/source/blender/python/mathutils/mathutils_Quaternion.c +++ b/source/blender/python/mathutils/mathutils_Quaternion.c @@ -1192,7 +1192,7 @@ PyDoc_STRVAR(quaternion_doc, ); PyTypeObject quaternion_Type = { PyVarObject_HEAD_INIT(NULL, 0) - "mathutils.Quaternion", //tp_name + "Quaternion", //tp_name sizeof(QuaternionObject), //tp_basicsize 0, //tp_itemsize (destructor)BaseMathObject_dealloc, //tp_dealloc diff --git a/source/blender/python/mathutils/mathutils_Vector.c b/source/blender/python/mathutils/mathutils_Vector.c index 17fa9cdd802..07bda4c2b91 100644 --- a/source/blender/python/mathutils/mathutils_Vector.c +++ b/source/blender/python/mathutils/mathutils_Vector.c @@ -2791,7 +2791,7 @@ PyDoc_STRVAR(vector_doc, PyTypeObject vector_Type = { PyVarObject_HEAD_INIT(NULL, 0) /* For printing, in format "<module>.<name>" */ - "mathutils.Vector", /* char *tp_name; */ + "Vector", /* char *tp_name; */ sizeof(VectorObject), /* int tp_basicsize; */ 0, /* tp_itemsize; For allocation */ |