[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [45662] trunk/blender/source/blender/ python: add 'idprop' module so we can document idprop.types.*, currently doc generator has no access to ID Property types.
Campbell Barton
ideasman42 at gmail.com
Sun Apr 15 16:54:15 CEST 2012
Revision: 45662
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=45662
Author: campbellbarton
Date: 2012-04-15 14:54:15 +0000 (Sun, 15 Apr 2012)
Log Message:
-----------
add 'idprop' module so we can document idprop.types.*, currently doc generator has no access to ID Property types.
Modified Paths:
--------------
trunk/blender/source/blender/python/bmesh/bmesh_py_api.c
trunk/blender/source/blender/python/generic/idprop_py_api.c
trunk/blender/source/blender/python/generic/idprop_py_api.h
trunk/blender/source/blender/python/intern/bpy_interface.c
trunk/blender/source/blender/python/mathutils/mathutils.c
trunk/blender/source/blender/python/mathutils/mathutils_Color.c
trunk/blender/source/blender/python/mathutils/mathutils_Euler.c
trunk/blender/source/blender/python/mathutils/mathutils_Matrix.c
trunk/blender/source/blender/python/mathutils/mathutils_Quaternion.c
trunk/blender/source/blender/python/mathutils/mathutils_Vector.c
Modified: trunk/blender/source/blender/python/bmesh/bmesh_py_api.c
===================================================================
--- trunk/blender/source/blender/python/bmesh/bmesh_py_api.c 2012-04-15 14:54:01 UTC (rev 45661)
+++ trunk/blender/source/blender/python/bmesh/bmesh_py_api.c 2012-04-15 14:54:15 UTC (rev 45662)
@@ -129,7 +129,7 @@
{
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 @@
/* 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;
Modified: trunk/blender/source/blender/python/generic/idprop_py_api.c
===================================================================
--- trunk/blender/source/blender/python/generic/idprop_py_api.c 2012-04-15 14:54:01 UTC (rev 45661)
+++ trunk/blender/source/blender/python/generic/idprop_py_api.c 2012-04-15 14:54:15 UTC (rev 45662)
@@ -886,7 +886,7 @@
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 @@
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 @@
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 @@
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;
+}
Modified: trunk/blender/source/blender/python/generic/idprop_py_api.h
===================================================================
--- trunk/blender/source/blender/python/generic/idprop_py_api.h 2012-04-15 14:54:01 UTC (rev 45661)
+++ trunk/blender/source/blender/python/generic/idprop_py_api.h 2012-04-15 14:54:15 UTC (rev 45662)
@@ -64,6 +64,8 @@
void IDProp_Init_Types(void);
+PyObject *BPyInit_idprop(void);
+
#define IDPROP_ITER_KEYS 0
#define IDPROP_ITER_ITEMS 1
Modified: trunk/blender/source/blender/python/intern/bpy_interface.c
===================================================================
--- trunk/blender/source/blender/python/intern/bpy_interface.c 2012-04-15 14:54:01 UTC (rev 45661)
+++ trunk/blender/source/blender/python/intern/bpy_interface.c 2012-04-15 14:54:15 UTC (rev 45662)
@@ -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 @@
{(char *)"_cycles", CCL_initPython},
#endif
{(char *)"gpu", GPU_initPython},
+ {(char *)"idprop", BPyInit_idprop},
{NULL, NULL}
};
Modified: trunk/blender/source/blender/python/mathutils/mathutils.c
===================================================================
--- trunk/blender/source/blender/python/mathutils/mathutils.c 2012-04-15 14:54:01 UTC (rev 45661)
+++ trunk/blender/source/blender/python/mathutils/mathutils.c 2012-04-15 14:54:15 UTC (rev 45662)
@@ -433,8 +433,8 @@
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 @@
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;
}
Modified: trunk/blender/source/blender/python/mathutils/mathutils_Color.c
===================================================================
--- trunk/blender/source/blender/python/mathutils/mathutils_Color.c 2012-04-15 14:54:01 UTC (rev 45661)
+++ trunk/blender/source/blender/python/mathutils/mathutils_Color.c 2012-04-15 14:54:15 UTC (rev 45662)
@@ -807,7 +807,7 @@
);
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
Modified: trunk/blender/source/blender/python/mathutils/mathutils_Euler.c
===================================================================
--- trunk/blender/source/blender/python/mathutils/mathutils_Euler.c 2012-04-15 14:54:01 UTC (rev 45661)
+++ trunk/blender/source/blender/python/mathutils/mathutils_Euler.c 2012-04-15 14:54:15 UTC (rev 45662)
@@ -650,7 +650,7 @@
);
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
Modified: trunk/blender/source/blender/python/mathutils/mathutils_Matrix.c
===================================================================
--- trunk/blender/source/blender/python/mathutils/mathutils_Matrix.c 2012-04-15 14:54:01 UTC (rev 45661)
+++ trunk/blender/source/blender/python/mathutils/mathutils_Matrix.c 2012-04-15 14:54:15 UTC (rev 45662)
@@ -2316,7 +2316,7 @@
);
PyTypeObject matrix_Type = {
PyVarObject_HEAD_INIT(NULL, 0)
- "mathutils.Matrix", /*tp_name*/
+ "Matrix", /*tp_name*/
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list