[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [42172] trunk/blender/source/blender/ python/intern: minor bpy api edits
Campbell Barton
ideasman42 at gmail.com
Sat Nov 26 16:18:31 CET 2011
Revision: 42172
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=42172
Author: campbellbarton
Date: 2011-11-26 15:18:30 +0000 (Sat, 26 Nov 2011)
Log Message:
-----------
minor bpy api edits
- strict check for rna properties
- formatting edits (120 line width)
- use PyDoc_STRVAR macros for getset docstrings
Modified Paths:
--------------
trunk/blender/source/blender/python/intern/bpy.c
trunk/blender/source/blender/python/intern/bpy_app.c
trunk/blender/source/blender/python/intern/bpy_interface.c
trunk/blender/source/blender/python/intern/bpy_library.c
trunk/blender/source/blender/python/intern/bpy_operator.c
trunk/blender/source/blender/python/intern/bpy_props.c
trunk/blender/source/blender/python/intern/bpy_rna.c
trunk/blender/source/blender/python/intern/bpy_rna_anim.c
trunk/blender/source/blender/python/intern/bpy_rna_array.c
trunk/blender/source/blender/python/intern/bpy_traceback.c
Modified: trunk/blender/source/blender/python/intern/bpy.c
===================================================================
--- trunk/blender/source/blender/python/intern/bpy.c 2011-11-26 15:08:01 UTC (rev 42171)
+++ trunk/blender/source/blender/python/intern/bpy.c 2011-11-26 15:18:30 UTC (rev 42172)
@@ -203,10 +203,14 @@
return PyUnicode_DecodeFSDefault(path);
}
-static PyMethodDef meth_bpy_script_paths= {"script_paths", (PyCFunction)bpy_script_paths, METH_NOARGS, bpy_script_paths_doc};
-static PyMethodDef meth_bpy_blend_paths= {"blend_paths", (PyCFunction)bpy_blend_paths, METH_VARARGS|METH_KEYWORDS, bpy_blend_paths_doc};
-static PyMethodDef meth_bpy_user_resource= {"user_resource", (PyCFunction)bpy_user_resource, METH_VARARGS|METH_KEYWORDS, NULL};
-static PyMethodDef meth_bpy_resource_path= {"resource_path", (PyCFunction)bpy_resource_path, METH_VARARGS|METH_KEYWORDS, bpy_resource_path_doc};
+static PyMethodDef meth_bpy_script_paths=
+ {"script_paths", (PyCFunction)bpy_script_paths, METH_NOARGS, bpy_script_paths_doc};
+static PyMethodDef meth_bpy_blend_paths=
+ {"blend_paths", (PyCFunction)bpy_blend_paths, METH_VARARGS|METH_KEYWORDS, bpy_blend_paths_doc};
+static PyMethodDef meth_bpy_user_resource=
+ {"user_resource", (PyCFunction)bpy_user_resource, METH_VARARGS|METH_KEYWORDS, NULL};
+static PyMethodDef meth_bpy_resource_path=
+ {"resource_path", (PyCFunction)bpy_resource_path, METH_VARARGS|METH_KEYWORDS, bpy_resource_path_doc};
static PyObject *bpy_import_test(const char *modname)
@@ -257,16 +261,21 @@
/* run first, initializes rna types */
BPY_rna_init();
- PyModule_AddObject(mod, "types", BPY_rna_types()); /* needs to be first so bpy_types can run */
- PyModule_AddObject(mod, "StructMetaPropGroup", (PyObject *)&pyrna_struct_meta_idprop_Type); /* metaclass for idprop types, bpy_types.py needs access */
+ /* needs to be first so bpy_types can run */
+ PyModule_AddObject(mod, "types", BPY_rna_types());
- bpy_lib_init(mod); /* adds '_bpy._library_load', must be called before 'bpy_types' which uses it */
+ /* metaclass for idprop types, bpy_types.py needs access */
+ PyModule_AddObject(mod, "StructMetaPropGroup", (PyObject *)&pyrna_struct_meta_idprop_Type);
+ /* needs to be first so bpy_types can run */
+ bpy_lib_init(mod);
+
bpy_import_test("bpy_types");
PyModule_AddObject(mod, "data", BPY_rna_module()); /* imports bpy_types by running this */
bpy_import_test("bpy_types");
- PyModule_AddObject(mod, "props", BPY_rna_props());
- PyModule_AddObject(mod, "ops", BPY_operator_module()); /* ops is now a python module that does the conversion from SOME_OT_foo -> some.foo */
+ PyModule_AddObject(mod, "props", BPY_rna_props());
+ /* ops is now a python module that does the conversion from SOME_OT_foo -> some.foo */
+ PyModule_AddObject(mod, "ops", BPY_operator_module());
PyModule_AddObject(mod, "app", BPY_app_struct());
/* bpy context */
Modified: trunk/blender/source/blender/python/intern/bpy_app.c
===================================================================
--- trunk/blender/source/blender/python/intern/bpy_app.c 2011-11-26 15:08:01 UTC (rev 42171)
+++ trunk/blender/source/blender/python/intern/bpy_app.c 2011-11-26 15:18:30 UTC (rev 42172)
@@ -159,6 +159,10 @@
/* a few getsets because it makes sense for them to be in bpy.app even though
* they are not static */
+
+PyDoc_STRVAR(bpy_app_debug_doc,
+"Boolean, set when blender is running in debug mode (started with --debug)"
+);
static PyObject *bpy_app_debug_get(PyObject *UNUSED(self), void *UNUSED(closure))
{
return PyBool_FromLong(G.f & G_DEBUG);
@@ -179,6 +183,9 @@
return 0;
}
+PyDoc_STRVAR(bpy_app_debug_value_doc,
+"Int, number which can be set to non-zero values for testing purposes"
+);
static PyObject *bpy_app_debug_value_get(PyObject *UNUSED(self), void *UNUSED(closure))
{
return PyLong_FromSsize_t(G.rt);
@@ -198,11 +205,17 @@
return 0;
}
+PyDoc_STRVAR(bpy_app_tempdir_doc,
+"String, the temp directory used by blender (read-only)"
+);
static PyObject *bpy_app_tempdir_get(PyObject *UNUSED(self), void *UNUSED(closure))
{
return PyC_UnicodeFromByte(BLI_temporary_dir());
}
+PyDoc_STRVAR(bpy_app_driver_dict_doc,
+"Dictionary for drivers namespace, editable in-place, reset on file load (read-only)"
+);
static PyObject *bpy_app_driver_dict_get(PyObject *UNUSED(self), void *UNUSED(closure))
{
if (bpy_pydriver_Dict == NULL)
@@ -217,10 +230,10 @@
static PyGetSetDef bpy_app_getsets[]= {
- {(char *)"debug", bpy_app_debug_get, bpy_app_debug_set, (char *)"Boolean, set when blender is running in debug mode (started with -d)", NULL},
- {(char *)"debug_value", bpy_app_debug_value_get, bpy_app_debug_value_set, (char *)"Int, number which can be set to non-zero values for testing purposes.", NULL},
- {(char *)"tempdir", bpy_app_tempdir_get, NULL, (char *)"String, the temp directory used by blender (read-only)", NULL},
- {(char *)"driver_namespace", bpy_app_driver_dict_get, NULL, (char *)"Dictionary for drivers namespace, editable in-place, reset on file load (read-only)", NULL},
+ {(char *)"debug", bpy_app_debug_get, bpy_app_debug_set, (char *)bpy_app_debug_doc, NULL},
+ {(char *)"debug_value", bpy_app_debug_value_get, bpy_app_debug_value_set, (char *)bpy_app_debug_value_doc, NULL},
+ {(char *)"tempdir", bpy_app_tempdir_get, NULL, (char *)bpy_app_tempdir_doc, NULL},
+ {(char *)"driver_namespace", bpy_app_driver_dict_get, NULL, (char *)bpy_app_driver_dict_doc, NULL},
{NULL, NULL, NULL, NULL, NULL}
};
@@ -253,4 +266,3 @@
return ret;
}
-
Modified: trunk/blender/source/blender/python/intern/bpy_interface.c
===================================================================
--- trunk/blender/source/blender/python/intern/bpy_interface.c 2011-11-26 15:08:01 UTC (rev 42171)
+++ trunk/blender/source/blender/python/intern/bpy_interface.c 2011-11-26 15:18:30 UTC (rev 42172)
@@ -134,9 +134,12 @@
fprintf(stderr, "ERROR: Python context internal state bug. this should not happen!\n");
}
else if (py_call_level==0) {
- // XXX - Calling classes currently wont store the context :\, cant set NULL because of this. but this is very flakey still.
- //BPy_SetContext(NULL);
- //bpy_import_main_set(NULL);
+ /* XXX - Calling classes currently wont store the context :\,
+ * cant set NULL because of this. but this is very flakey still. */
+#if 0
+ BPy_SetContext(NULL);
+ bpy_import_main_set(NULL);
+#endif
#ifdef TIME_PY_RUN
bpy_timer_run_tot += PIL_check_seconds_timer() - bpy_timer_run;
@@ -329,7 +332,8 @@
} PyModuleObject;
#endif
-static int python_script_exec(bContext *C, const char *fn, struct Text *text, struct ReportList *reports, const short do_jump)
+static int python_script_exec(bContext *C, const char *fn, struct Text *text,
+ struct ReportList *reports, const short do_jump)
{
PyObject *main_mod= NULL;
PyObject *py_dict= NULL, *py_result= NULL;
@@ -717,7 +721,10 @@
{
const int argc= 1;
const char *argv[2];
- PyObject *filename_obj= PyModule_GetFilenameObject(bpy_proxy); /* updating the module dict below will loose the reference to __file__ */
+
+ /* updating the module dict below will loose the reference to __file__ */
+ PyObject *filename_obj= PyModule_GetFilenameObject(bpy_proxy);
+
const char *filename_rel= _PyUnicode_AsString(filename_obj); /* can be relative */
char filename_abs[1024];
Modified: trunk/blender/source/blender/python/intern/bpy_library.c
===================================================================
--- trunk/blender/source/blender/python/intern/bpy_library.c 2011-11-26 15:08:01 UTC (rev 42171)
+++ trunk/blender/source/blender/python/intern/bpy_library.c 2011-11-26 15:18:30 UTC (rev 42172)
@@ -426,7 +426,10 @@
int bpy_lib_init(PyObject *mod_par)
{
- static PyMethodDef load_meth= {"load", (PyCFunction)bpy_lib_load, METH_STATIC|METH_VARARGS|METH_KEYWORDS, bpy_lib_load_doc};
+ static PyMethodDef load_meth= {"load", (PyCFunction)bpy_lib_load,
+ METH_STATIC|METH_VARARGS|METH_KEYWORDS,
+ bpy_lib_load_doc};
+
PyModule_AddObject(mod_par, "_library_load", PyCFunction_New(&load_meth, NULL));
/* some compilers dont like accessing this directly, delay assignment */
Modified: trunk/blender/source/blender/python/intern/bpy_operator.c
===================================================================
--- trunk/blender/source/blender/python/intern/bpy_operator.c 2011-11-26 15:08:01 UTC (rev 42171)
+++ trunk/blender/source/blender/python/intern/bpy_operator.c 2011-11-26 15:18:30 UTC (rev 42172)
@@ -31,11 +31,6 @@
* which fakes exposing operators as modules/functions using its own classes.
*/
-
-/* Note, this module is not to be used directly by the user.
- * Internally its exposed as '_bpy.ops', which provides functions for 'bpy.ops', a python package.
- * */
-
#include <Python.h>
#include "RNA_types.h"
@@ -78,7 +73,8 @@
int context= WM_OP_EXEC_DEFAULT;
- // XXX Todo, work out a better solution for passing on context, could make a tuple from self and pack the name and Context into it...
+ /* XXX Todo, work out a better solution for passing on context,
+ * could make a tuple from self and pack the name and Context into it... */
bContext *C= (bContext *)BPy_GetContext();
if (C==NULL) {
@@ -152,7 +148,8 @@
/* note that context is an int, python does the conversion in this case */
int context= WM_OP_EXEC_DEFAULT;
- // XXX Todo, work out a better solution for passing on context, could make a tuple from self and pack the name and Context into it...
+ /* XXX Todo, work out a better solution for passing on context,
+ * could make a tuple from self and pack the name and Context into it... */
bContext *C= (bContext *)BPy_GetContext();
if (C==NULL) {
Modified: trunk/blender/source/blender/python/intern/bpy_props.c
===================================================================
--- trunk/blender/source/blender/python/intern/bpy_props.c 2011-11-26 15:08:01 UTC (rev 42171)
+++ trunk/blender/source/blender/python/intern/bpy_props.c 2011-11-26 15:18:30 UTC (rev 42172)
@@ -301,7 +301,7 @@
if (srna==NULL) { \
if (PyErr_Occurred()) \
return NULL; \
- return bpy_prop_deferred_return((void *)pymeth_##_func, kw); \
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list