diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2011-11-07 19:23:08 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2011-11-07 19:23:08 +0400 |
commit | 5ef9039b7e2ea16bd4b651aab21d5aa690485569 (patch) | |
tree | e67247fa43d89748900b697eb9bdf0341fe53afc /source/blender/python | |
parent | fb56dbc2afc7c8b6ffc24406ed82cbcbff090da3 (diff) | |
parent | 5ebee683bd736ef80df939552bbe0d8e104b56df (diff) |
Cycles: svn merge -r41531:41613 ^/trunk/blender
Diffstat (limited to 'source/blender/python')
38 files changed, 251 insertions, 231 deletions
diff --git a/source/blender/python/generic/bgl.c b/source/blender/python/generic/bgl.c index 24d963243f6..03d66e918d5 100644 --- a/source/blender/python/generic/bgl.c +++ b/source/blender/python/generic/bgl.c @@ -1,5 +1,4 @@ -/* - * +/* * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or @@ -21,20 +20,21 @@ * * This is a new part of Blender. * - * Contributor(s): Willian P. Germano + * Contributor(s): Willian P. Germano, Campbell Barton * * ***** END GPL LICENSE BLOCK ***** */ /** \file blender/python/generic/bgl.c * \ingroup pygen + * + * This file is the 'bgl' module which wraps OpenGL functions and constants, + * allowing script writers to make OpenGL calls in their Python scripts. + * + * \note + * This module is very similar to 'PyOpenGL' which could replace 'bgl' one day. */ - -/* This file is the 'bgl' module. - * The BGL submodule "wraps" OpenGL functions and constants, - * allowing script writers to make OpenGL calls in their Python scripts. */ - #include <Python.h> #include "bgl.h" /*This must come first */ @@ -205,29 +205,36 @@ PyTypeObject BGL_bufferType = { NULL /*tp_del*/ }; - -/* #ifndef __APPLE__ */ - -#define BGL_Wrap(nargs, funcname, ret, arg_list) \ -static PyObject *Method_##funcname (PyObject *UNUSED(self), PyObject *args) {\ - arg_def##nargs arg_list; \ - ret_def_##ret; \ - if (!PyArg_ParseTuple(args, arg_str##nargs arg_list, arg_ref##nargs arg_list)) return NULL;\ - ret_set_##ret gl##funcname (arg_var##nargs arg_list);\ - ret_ret_##ret; \ +#define BGL_Wrap(nargs, funcname, ret, arg_list) \ +static PyObject *Method_##funcname (PyObject *UNUSED(self), PyObject *args) \ +{ \ + arg_def##nargs arg_list; \ + ret_def_##ret; \ + if (!PyArg_ParseTuple(args, \ + arg_str##nargs arg_list, \ + arg_ref##nargs arg_list)) \ + { \ + return NULL; \ + } \ + ret_set_##ret gl##funcname (arg_var##nargs arg_list); \ + ret_ret_##ret; \ } -#define BGLU_Wrap(nargs, funcname, ret, arg_list) \ -static PyObject *Method_##funcname (PyObject *UNUSED(self), PyObject *args) {\ - arg_def##nargs arg_list; \ - ret_def_##ret; \ - if (!PyArg_ParseTuple(args, arg_str##nargs arg_list, arg_ref##nargs arg_list)) return NULL;\ - ret_set_##ret glu##funcname (arg_var##nargs arg_list);\ - ret_ret_##ret; \ +#define BGLU_Wrap(nargs, funcname, ret, arg_list) \ +static PyObject *Method_##funcname (PyObject *UNUSED(self), PyObject *args) \ +{ \ + arg_def##nargs arg_list; \ + ret_def_##ret; \ + if (!PyArg_ParseTuple(args, \ + arg_str##nargs arg_list, \ + arg_ref##nargs arg_list)) \ + { \ + return NULL; \ + } \ + ret_set_##ret glu##funcname (arg_var##nargs arg_list); \ + ret_ret_##ret; \ } -/* #endif */ - /********/ int BGL_typeSize(int type) { @@ -267,7 +274,7 @@ Buffer *BGL_MakeBuffer(int type, int ndimensions, int *dimensions, void *initbuf memcpy(buffer->dimensions, dimensions, ndimensions*sizeof(int)); buffer->type= type; buffer->buf.asvoid= buf; - + if (initbuffer) { memcpy(buffer->buf.asvoid, initbuffer, length*size); } diff --git a/source/blender/python/generic/bgl.h b/source/blender/python/generic/bgl.h index 5cf9eac8289..2e02900d69f 100644 --- a/source/blender/python/generic/bgl.h +++ b/source/blender/python/generic/bgl.h @@ -1,5 +1,4 @@ -/* - * +/* * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or @@ -331,12 +330,13 @@ extern PyTypeObject BGL_bufferType; #define ret_def_GLstring const unsigned char *ret_str; #define ret_set_GLstring ret_str= -#define ret_ret_GLstring \ - if (ret_str) {\ - return PyUnicode_FromString((const char *)ret_str);\ - } else {\ - PyErr_SetString(PyExc_AttributeError, "could not get opengl string");\ - return NULL;\ - } +#define ret_ret_GLstring \ + if (ret_str) { \ + return PyUnicode_FromString((const char *)ret_str); \ + } \ + else { \ + PyErr_SetString(PyExc_AttributeError, "could not get opengl string"); \ + return NULL; \ + } \ #endif /* BGL_H */ diff --git a/source/blender/python/generic/blf_py_api.c b/source/blender/python/generic/blf_py_api.c index a9cd16c70f0..a4373e46e23 100644 --- a/source/blender/python/generic/blf_py_api.c +++ b/source/blender/python/generic/blf_py_api.c @@ -22,9 +22,10 @@ /** \file blender/python/generic/blf_py_api.c * \ingroup pygen + * + * This file defines the 'bgl' module, used for drawing text in OpenGL. */ - #include <Python.h> #include "blf_py_api.h" diff --git a/source/blender/python/generic/bpy_internal_import.c b/source/blender/python/generic/bpy_internal_import.c index 293ade35584..88e2da16eb5 100644 --- a/source/blender/python/generic/bpy_internal_import.c +++ b/source/blender/python/generic/bpy_internal_import.c @@ -15,18 +15,21 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * * This is a new part of Blender. * - * Contributor(s): Willian P. Germano + * Contributor(s): Willian P. Germano, Campbell Barton * * ***** END GPL LICENSE BLOCK ***** */ /** \file blender/python/generic/bpy_internal_import.c * \ingroup pygen + * + * This file defines replacements for pythons '__import__' and 'imp.reload' + * functions which can import from blender textblocks. + * + * \note + * This should eventually be replaced by import hooks (pep 302). */ @@ -308,77 +311,3 @@ static PyObject *blender_reload(PyObject *UNUSED(self), PyObject *module) PyMethodDef bpy_import_meth= {"bpy_import_meth", (PyCFunction)blender_import, METH_VARARGS | METH_KEYWORDS, "blenders import"}; PyMethodDef bpy_reload_meth= {"bpy_reload_meth", (PyCFunction)blender_reload, METH_O, "blenders reload"}; - - -/* Clear user modules. - * This is to clear any modules that could be defined from running scripts in blender. - * - * Its also needed for the BGE Python api so imported scripts are not used between levels - * - * This clears every modules that has a __file__ attribute (is not a builtin) - * - * Note that clearing external python modules is important for the BGE otherwise - * it wont reload scripts between loading different blend files or while making the game. - * - use 'clear_all' arg in this case. - * - * Since pythons built-ins include a full path even for win32. - * even if we remove a python module a re-import will bring it back again. - */ - -#if 0 // not used anymore but may still come in handy later - -#if defined(WIN32) || defined(WIN64) -#define SEPSTR "\\" -#else -#define SEPSTR "/" -#endif - - -void bpy_text_clear_modules(int clear_all) -{ - PyObject *modules= PyImport_GetModuleDict(); - - char *fname; - char *file_extension; - - /* looping over the dict */ - PyObject *key, *value; - Py_ssize_t pos= 0; - - /* new list */ - PyObject *list; - - if (modules==NULL) - return; /* should never happen but just incase */ - - list= PyList_New(0); - - /* go over sys.modules and remove anything with a - * sys.modukes[x].__file__ thats ends with a .py and has no path - */ - while (PyDict_Next(modules, &pos, &key, &value)) { - fname= PyModule_GetFilename(value); - if (fname) { - if (clear_all || ((strstr(fname, SEPSTR))==0)) { /* no path ? */ - file_extension= strstr(fname, ".py"); - if (file_extension && (*(file_extension + 3) == '\0' || *(file_extension + 4) == '\0')) { /* .py or pyc extension? */ - /* now we can be fairly sure its a python import from the blendfile */ - PyList_Append(list, key); /* free'd with the list */ - } - } - } - else { - PyErr_Clear(); - } - } - - /* remove all our modules */ - for (pos=0; pos < PyList_GET_SIZE(list); pos++) { - /* PyObject_Print(key, stderr, 0); */ - key= PyList_GET_ITEM(list, pos); - PyDict_DelItem(modules, key); - } - - Py_DECREF(list); /* removes all references from append */ -} -#endif diff --git a/source/blender/python/generic/noise_py_api.c b/source/blender/python/generic/noise_py_api.c index 6afb1a00e2f..c12cc1ccdd2 100644 --- a/source/blender/python/generic/noise_py_api.c +++ b/source/blender/python/generic/noise_py_api.c @@ -1,8 +1,4 @@ /* - * - * Blender.Noise BPython module implementation. - * This submodule has functions to generate noise of various types. - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or @@ -24,13 +20,16 @@ * * This is a new part of Blender. * - * Contributor(s): eeshlo + * Contributor(s): eeshlo, Campbell Barton * * ***** END GPL LICENSE BLOCK ***** */ /** \file blender/python/generic/noise_py_api.c * \ingroup pygen + * + * This file defines the 'noise' module, a general purpose module to access + * blenders noise functions. */ diff --git a/source/blender/python/generic/py_capi_utils.c b/source/blender/python/generic/py_capi_utils.c index eb4ecf79941..7fbd8baa558 100644 --- a/source/blender/python/generic/py_capi_utils.c +++ b/source/blender/python/generic/py_capi_utils.c @@ -20,6 +20,13 @@ /** \file blender/python/generic/py_capi_utils.c * \ingroup pygen + * + * Extend upon CPython's API, filling in some gaps, these functions use PyC_ + * prefix to distinguish them apart from CPython. + * + * \note + * This module should only depend on CPython, however it currently uses + * BLI_string_utf8() for unicode conversion. */ diff --git a/source/blender/python/intern/bpy.c b/source/blender/python/intern/bpy.c index dfb7a1e8f75..2df907f3a12 100644 --- a/source/blender/python/intern/bpy.c +++ b/source/blender/python/intern/bpy.c @@ -22,11 +22,11 @@ /** \file blender/python/intern/bpy.c * \ingroup pythonintern + * + * This file defines the '_bpy' module which is used by python's 'bpy' package + * to access C defined builtin functions. + * A script writer should never directly access this module. */ - - -/* This file defines the '_bpy' module which is used by python's 'bpy' package. - * a script writer should never directly access this module */ #define WITH_PYTHON /* for AUD_PyInit.h, possibly others */ diff --git a/source/blender/python/intern/bpy_app.c b/source/blender/python/intern/bpy_app.c index cc3b88722b6..b5ae225fda7 100644 --- a/source/blender/python/intern/bpy_app.c +++ b/source/blender/python/intern/bpy_app.c @@ -22,6 +22,10 @@ /** \file blender/python/intern/bpy_app.c * \ingroup pythonintern + * + * This file defines a 'PyStructSequence' accessed via 'bpy.app', mostly + * exposing static applications variables such as version and buildinfo + * however some writable variables have been added such as 'debug' and 'tempdir' */ diff --git a/source/blender/python/intern/bpy_app_handlers.c b/source/blender/python/intern/bpy_app_handlers.c index f130a4bcc5c..edab92b295b 100644 --- a/source/blender/python/intern/bpy_app_handlers.c +++ b/source/blender/python/intern/bpy_app_handlers.c @@ -22,6 +22,10 @@ /** \file blender/python/intern/bpy_app_handlers.c * \ingroup pythonintern + * + * This file defines a 'PyStructSequence' accessed via 'bpy.app.handlers', + * which exposes various lists that the script author can add callback + * functions into (called via blenders generic BLI_cb api) */ #include <Python.h> diff --git a/source/blender/python/intern/bpy_driver.c b/source/blender/python/intern/bpy_driver.c index 0fe1d2d26ba..12fb5ed43b4 100644 --- a/source/blender/python/intern/bpy_driver.c +++ b/source/blender/python/intern/bpy_driver.c @@ -22,6 +22,10 @@ /** \file blender/python/intern/bpy_driver.c * \ingroup pythonintern + * + * This file defines the 'BPY_driver_exec' to execute python driver expressions, + * called by the animation system, there are also some utility functions + * to deal with the namespace used for driver execution. */ /* ****************************************** */ diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c index 73dcbdaca55..de2433c8766 100644 --- a/source/blender/python/intern/bpy_interface.c +++ b/source/blender/python/intern/bpy_interface.c @@ -23,6 +23,10 @@ /** \file blender/python/intern/bpy_interface.c * \ingroup pythonintern + * + * This file deals with embedding the python interpreter within blender, + * starting and stopping python and exposing blender/python modules so they can + * be accesses from scripts. */ diff --git a/source/blender/python/intern/bpy_interface_atexit.c b/source/blender/python/intern/bpy_interface_atexit.c index aa5b934891c..a0cf3c38503 100644 --- a/source/blender/python/intern/bpy_interface_atexit.c +++ b/source/blender/python/intern/bpy_interface_atexit.c @@ -22,6 +22,10 @@ /** \file blender/python/intern/bpy_interface_atexit.c * \ingroup pythonintern + * + * This file inserts an exit callback into pythons 'atexit' module. + * Without this sys.exit() can crash because blender is not properly closing + * resources. */ diff --git a/source/blender/python/intern/bpy_intern_string.c b/source/blender/python/intern/bpy_intern_string.c index 32d329e11b3..4f206c4c365 100644 --- a/source/blender/python/intern/bpy_intern_string.c +++ b/source/blender/python/intern/bpy_intern_string.c @@ -22,6 +22,10 @@ /** \file blender/python/intern/bpy_intern_string.c * \ingroup pythonintern + * + * Store python versions of strings frequently used for python lookups + * to avoid converting, creating the hash and freeing every time as + * PyDict_GetItemString and PyObject_GetAttrString do. */ #include <Python.h> diff --git a/source/blender/python/intern/bpy_library.c b/source/blender/python/intern/bpy_library.c index 382a513f40a..b91948cc0b8 100644 --- a/source/blender/python/intern/bpy_library.c +++ b/source/blender/python/intern/bpy_library.c @@ -22,6 +22,13 @@ /** \file blender/python/intern/bpy_library.c * \ingroup pythonintern + * + * This file exposed blend file library appending/linking to python, typically + * this would be done via RNA api but in this case a hand written python api + * allows us to use pythons context manager (__enter__ and __exit__). + * + * Everything here is exposed via bpy.data.libraries.load(...) which returns + * a context manager. */ /* nifty feature. swap out strings for RNA data */ @@ -71,8 +78,8 @@ static PyObject *bpy_lib_dir(BPy_Library *self); static PyMethodDef bpy_lib_methods[]= { {"__enter__", (PyCFunction)bpy_lib_enter, METH_NOARGS}, - {"__exit__", (PyCFunction)bpy_lib_exit, METH_VARARGS}, - {"__dir__", (PyCFunction)bpy_lib_dir, METH_NOARGS}, + {"__exit__", (PyCFunction)bpy_lib_exit, METH_VARARGS}, + {"__dir__", (PyCFunction)bpy_lib_dir, METH_NOARGS}, {NULL} /* sentinel */ }; @@ -283,7 +290,7 @@ static void bpy_lib_exit_warn_idname(BPy_Library *self, const char *name_plural, PyObject *exc, *val, *tb; PyErr_Fetch(&exc, &val, &tb); if (PyErr_WarnFormat(PyExc_UserWarning, 1, - "load: '%s' does not contain %s[\"%s\"]", + "load: '%s' does not contain %s[\"%s\"]", self->abspath, name_plural, idname)) { /* Spurious errors can appear at shutdown */ if (PyErr_ExceptionMatches(PyExc_Warning)) { @@ -298,7 +305,7 @@ static void bpy_lib_exit_warn_type(BPy_Library *self, PyObject *item) PyObject *exc, *val, *tb; PyErr_Fetch(&exc, &val, &tb); if (PyErr_WarnFormat(PyExc_UserWarning, 1, - "load: '%s' expected a string type, not a %.200s", + "load: '%s' expected a string type, not a %.200s", self->abspath, Py_TYPE(item)->tp_name)) { /* Spurious errors can appear at shutdown */ if (PyErr_ExceptionMatches(PyExc_Warning)) { diff --git a/source/blender/python/intern/bpy_operator.c b/source/blender/python/intern/bpy_operator.c index 70a5d79e9ac..3fd4e8a128b 100644 --- a/source/blender/python/intern/bpy_operator.c +++ b/source/blender/python/intern/bpy_operator.c @@ -1,6 +1,4 @@ - /* - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or @@ -24,6 +22,13 @@ /** \file blender/python/intern/bpy_operator.c * \ingroup pythonintern + * + * This file defines '_bpy.ops', an internal python module which gives python + * the ability to inspect and call both C and Python defined operators. + * + * \note + * This module is exposed to the user via 'release/scripts/modules/bpy/ops.py' + * which fakes exposing operators as modules/functions using its own classes. */ diff --git a/source/blender/python/intern/bpy_operator_wrap.c b/source/blender/python/intern/bpy_operator_wrap.c index cb460f2fa08..aa458925202 100644 --- a/source/blender/python/intern/bpy_operator_wrap.c +++ b/source/blender/python/intern/bpy_operator_wrap.c @@ -22,6 +22,11 @@ /** \file blender/python/intern/bpy_operator_wrap.c * \ingroup pythonintern + * + * This file is so python can define operators that C can call into. + * The generic callback functions for python operators are defines in + * 'rna_wm.c', some calling into functions here to do python specific + * functionality. */ diff --git a/source/blender/python/intern/bpy_props.c b/source/blender/python/intern/bpy_props.c index b10223207bf..4dbaf5db4a4 100644 --- a/source/blender/python/intern/bpy_props.c +++ b/source/blender/python/intern/bpy_props.c @@ -22,6 +22,10 @@ /** \file blender/python/intern/bpy_props.c * \ingroup pythonintern + * + * This file defines 'bpy.props' module used so scripts can define their own + * rna properties for use with python operators or adding new properties to + * existing blender types. */ @@ -254,7 +258,7 @@ static int bpy_prop_callback_assign(struct PropertyRNA *prop, PyObject *update_c { /* assume this is already checked for type and arg length */ if (update_cb) { - PyObject **py_data= MEM_callocN(sizeof(PyObject *) * BPY_DATA_CB_SLOT_SIZE, "bpy_prop_callback_assign"); + PyObject **py_data= MEM_callocN(sizeof(PyObject *) * BPY_DATA_CB_SLOT_SIZE, __func__); RNA_def_property_update_runtime(prop, (void *)bpy_prop_update_cb); py_data[BPY_DATA_CB_SLOT_UPDATE]= update_cb; RNA_def_py_data(prop, py_data); @@ -279,52 +283,60 @@ static int py_long_as_int(PyObject *py_long, int *r_int) /* this define runs at the start of each function and deals with * returning a deferred property (to be registered later) */ -#define BPY_PROPDEF_HEAD(_func) \ - if (PyTuple_GET_SIZE(args) == 1) { \ - PyObject *ret; \ - self= PyTuple_GET_ITEM(args, 0); \ - args= PyTuple_New(0); \ - ret= BPy_##_func(self, args, kw); \ - Py_DECREF(args); \ - return ret; \ - } \ - else if (PyTuple_GET_SIZE(args) > 1) { \ - PyErr_SetString(PyExc_ValueError, "all args must be keywords"); \ - return NULL; \ - } \ - srna= srna_from_self(self, #_func"(...):"); \ - if (srna==NULL) { \ - if (PyErr_Occurred()) \ - return NULL; \ - return bpy_prop_deferred_return((void *)pymeth_##_func, kw); \ - } \ +#define BPY_PROPDEF_HEAD(_func) \ + if (PyTuple_GET_SIZE(args) == 1) { \ + PyObject *ret; \ + self= PyTuple_GET_ITEM(args, 0); \ + args= PyTuple_New(0); \ + ret= BPy_##_func(self, args, kw); \ + Py_DECREF(args); \ + return ret; \ + } \ + else if (PyTuple_GET_SIZE(args) > 1) { \ + PyErr_SetString(PyExc_ValueError, "all args must be keywords"); \ + return NULL; \ + } \ + srna= srna_from_self(self, #_func"(...):"); \ + if (srna==NULL) { \ + if (PyErr_Occurred()) \ + return NULL; \ + return bpy_prop_deferred_return((void *)pymeth_##_func, kw); \ + } \ /* terse macros for error checks shared between all funcs cant use function * calls because of static strins passed to pyrna_set_to_enum_bitfield */ -#define BPY_PROPDEF_CHECK(_func, _property_flag_items) \ - if (id_len >= MAX_IDPROP_NAME) { \ - PyErr_Format(PyExc_TypeError, \ - #_func"(): '%.200s' too long, max length is %d", \ - id, MAX_IDPROP_NAME-1); \ - return NULL; \ - } \ - if (RNA_def_property_free_identifier(srna, id) == -1) { \ - PyErr_Format(PyExc_TypeError, \ - #_func"(): '%s' is defined as a non-dynamic type", \ - id); \ - return NULL; \ - } \ - if (pyopts && pyrna_set_to_enum_bitfield(_property_flag_items, pyopts, &opts, #_func"(options={...}):")) \ - return NULL; \ - -#define BPY_PROPDEF_SUBTYPE_CHECK(_func, _property_flag_items, _subtype) \ - BPY_PROPDEF_CHECK(_func, _property_flag_items) \ - if (pysubtype && RNA_enum_value_from_id(_subtype, pysubtype, &subtype)==0) { \ - PyErr_Format(PyExc_TypeError, \ - #_func"(subtype='%s'): invalid subtype", \ - pysubtype); \ - return NULL; \ - } \ +#define BPY_PROPDEF_CHECK(_func, _property_flag_items) \ + if (id_len >= MAX_IDPROP_NAME) { \ + PyErr_Format(PyExc_TypeError, \ + #_func"(): '%.200s' too long, max length is %d", \ + id, MAX_IDPROP_NAME-1); \ + return NULL; \ + } \ + if (RNA_def_property_free_identifier(srna, id) == -1) { \ + PyErr_Format(PyExc_TypeError, \ + #_func"(): '%s' is defined as a non-dynamic type", \ + id); \ + return NULL; \ + } \ + if (pyopts && pyrna_set_to_enum_bitfield(_property_flag_items, \ + pyopts, \ + &opts, \ + #_func"(options={...}):")) \ + { \ + return NULL; \ + } \ + +#define BPY_PROPDEF_SUBTYPE_CHECK(_func, _property_flag_items, _subtype) \ + BPY_PROPDEF_CHECK(_func, _property_flag_items) \ + if (pysubtype && RNA_enum_value_from_id(_subtype, \ + pysubtype, \ + &subtype)==0) \ + { \ + PyErr_Format(PyExc_TypeError, \ + #_func"(subtype='%s'): invalid subtype", \ + pysubtype); \ + return NULL; \ + } \ #define BPY_PROPDEF_NAME_DOC \ diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index 1ecbeb4d16a..44e26a56db6 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -22,9 +22,14 @@ /** \file blender/python/intern/bpy_rna.c * \ingroup pythonintern + * + * This file is the main interface between python and blenders data api (RNA), + * exposing RNA to python so blender data can be accessed in a python like way. + * + * The two main types are 'BPy_StructRNA' and 'BPy_PropertyRNA' - the base + * classes for most of the data python accesses in blender. */ - #include <Python.h> #include <stddef.h> @@ -82,10 +87,10 @@ static PyObject* pyrna_struct_Subtype(PointerRNA *ptr); static PyObject *pyrna_prop_collection_values(BPy_PropertyRNA *self); -#define BPY_DOC_ID_PROP_TYPE_NOTE \ -" .. note::\n" \ -"\n" \ -" Only :class:`bpy.types.ID`, :class:`bpy.types.Bone` and \n" \ +#define BPY_DOC_ID_PROP_TYPE_NOTE \ +" .. note::\n" \ +"\n" \ +" Only :class:`bpy.types.ID`, :class:`bpy.types.Bone` and \n" \ " :class:`bpy.types.PoseBone` classes support custom properties.\n" @@ -6404,17 +6409,19 @@ static int bpy_class_validate(PointerRNA *dummyptr, void *py_data, int *have_fun if (item==NULL) { /* Sneaky workaround to use the class name as the bl_idname */ -#define BPY_REPLACEMENT_STRING(rna_attr, py_attr) \ - if (strcmp(identifier, rna_attr) == 0) { \ - item= PyObject_GetAttrString(py_class, py_attr); \ - if (item && item != Py_None) { \ - if (pyrna_py_to_prop(dummyptr, prop, NULL, item, "validating class:") != 0) { \ - Py_DECREF(item); \ - return -1; \ - } \ - } \ - Py_XDECREF(item); \ - } \ +#define BPY_REPLACEMENT_STRING(rna_attr, py_attr) \ + if (strcmp(identifier, rna_attr) == 0) { \ + item= PyObject_GetAttrString(py_class, py_attr); \ + if (item && item != Py_None) { \ + if (pyrna_py_to_prop(dummyptr, prop, NULL, \ + item, "validating class:") != 0) \ + { \ + Py_DECREF(item); \ + return -1; \ + } \ + } \ + Py_XDECREF(item); \ + } \ BPY_REPLACEMENT_STRING("bl_idname", "__name__"); @@ -6468,7 +6475,9 @@ static int bpy_class_call(bContext *C, PointerRNA *ptr, FunctionRNA *func, Param const int is_operator= RNA_struct_is_a(ptr->type, &RNA_Operator); const char *func_id= RNA_function_identifier(func); /* testing, for correctness, not operator and not draw function */ - const short is_readonly= strstr("draw", func_id) || /*strstr("render", func_id) ||*/ !is_operator; + const short is_readonly= ((strncmp("draw", func_id, 4) ==0) || /* draw or draw_header */ + /*strstr("render", func_id) ||*/ + !is_operator); #endif py_class= RNA_struct_py_type_get(ptr->type); diff --git a/source/blender/python/intern/bpy_rna_anim.c b/source/blender/python/intern/bpy_rna_anim.c index 4ebb407f4d6..edc6e672238 100644 --- a/source/blender/python/intern/bpy_rna_anim.c +++ b/source/blender/python/intern/bpy_rna_anim.c @@ -22,6 +22,8 @@ /** \file blender/python/intern/bpy_rna_anim.c * \ingroup pythonintern + * + * This file defines the animation related methods used in bpy_rna.c */ #include <Python.h> diff --git a/source/blender/python/intern/bpy_rna_array.c b/source/blender/python/intern/bpy_rna_array.c index eda2511a187..73e9e0a44d9 100644 --- a/source/blender/python/intern/bpy_rna_array.c +++ b/source/blender/python/intern/bpy_rna_array.c @@ -15,13 +15,15 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * Contributor(s): Arystanbek Dyussenov + * Contributor(s): Arystanbek Dyussenov, Campbell Barton * * ***** END GPL LICENSE BLOCK ***** */ /** \file blender/python/intern/bpy_rna_array.c * \ingroup pythonintern + * + * This file deals with array access for 'BPy_PropertyArrayRNA' from bpy_rna.c */ #include <Python.h> diff --git a/source/blender/python/intern/bpy_rna_callback.c b/source/blender/python/intern/bpy_rna_callback.c index af6fc88097b..85f950947a7 100644 --- a/source/blender/python/intern/bpy_rna_callback.c +++ b/source/blender/python/intern/bpy_rna_callback.c @@ -22,6 +22,9 @@ /** \file blender/python/intern/bpy_rna_callback.c * \ingroup pythonintern + * + * This file currently exposes callbacks for interface regions but may be + * extended later. */ diff --git a/source/blender/python/intern/bpy_traceback.c b/source/blender/python/intern/bpy_traceback.c index aa21627a279..5045f6708b5 100644 --- a/source/blender/python/intern/bpy_traceback.c +++ b/source/blender/python/intern/bpy_traceback.c @@ -20,6 +20,9 @@ /** \file blender/python/intern/bpy_traceback.c * \ingroup pythonintern + * + * This file contains utility functions for getting data from a python stack + * trace. */ diff --git a/source/blender/python/intern/bpy_util.c b/source/blender/python/intern/bpy_util.c index bec3a07d32a..fb42f7d59e0 100644 --- a/source/blender/python/intern/bpy_util.c +++ b/source/blender/python/intern/bpy_util.c @@ -22,9 +22,11 @@ /** \file blender/python/intern/bpy_util.c * \ingroup pythonintern + * + * This file contains blender/python utility functions for the api's internal + * use (unrelated to 'bpy.utils') */ - #include <Python.h> #include "bpy_util.h" diff --git a/source/blender/python/intern/gpu.c b/source/blender/python/intern/gpu.c index 1162491ee26..57ce7b59067 100644 --- a/source/blender/python/intern/gpu.c +++ b/source/blender/python/intern/gpu.c @@ -27,6 +27,9 @@ /** \file blender/python/intern/gpu.c * \ingroup pythonintern + * + * This file defines the 'gpu' module, used to get GLSL shader code and data + * from blender materials. */ /* python redefines */ diff --git a/source/blender/python/mathutils/mathutils.c b/source/blender/python/mathutils/mathutils.c index 770a743b733..41c1568dbde 100644 --- a/source/blender/python/mathutils/mathutils.c +++ b/source/blender/python/mathutils/mathutils.c @@ -25,8 +25,8 @@ * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/python/generic/mathutils.c - * \ingroup pygen +/** \file blender/python/mathutils/mathutils.c + * \ingroup pymathutils */ #include <Python.h> diff --git a/source/blender/python/mathutils/mathutils.h b/source/blender/python/mathutils/mathutils.h index bcea62c8f1c..70b0ef93ebd 100644 --- a/source/blender/python/mathutils/mathutils.h +++ b/source/blender/python/mathutils/mathutils.h @@ -26,8 +26,8 @@ * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/python/generic/mathutils.h - * \ingroup pygen +/** \file blender/python/mathutils/mathutils.h + * \ingroup pymathutils */ //Include this file for access to vector, quat, matrix, euler, etc... diff --git a/source/blender/python/mathutils/mathutils_Color.c b/source/blender/python/mathutils/mathutils_Color.c index a0035e5f34d..c374d0eb73d 100644 --- a/source/blender/python/mathutils/mathutils_Color.c +++ b/source/blender/python/mathutils/mathutils_Color.c @@ -21,8 +21,8 @@ * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/python/generic/mathutils_Color.c - * \ingroup pygen +/** \file blender/python/mathutils/mathutils_Color.c + * \ingroup pymathutils */ diff --git a/source/blender/python/mathutils/mathutils_Color.h b/source/blender/python/mathutils/mathutils_Color.h index 231fab511c8..6c84b5f596d 100644 --- a/source/blender/python/mathutils/mathutils_Color.h +++ b/source/blender/python/mathutils/mathutils_Color.h @@ -27,8 +27,8 @@ * */ -/** \file blender/python/generic/mathutils_Color.h - * \ingroup pygen +/** \file blender/python/mathutils/mathutils_Color.h + * \ingroup pymathutils */ diff --git a/source/blender/python/mathutils/mathutils_Euler.c b/source/blender/python/mathutils/mathutils_Euler.c index 4d44ec8b1e9..ce9ac5fbbb5 100644 --- a/source/blender/python/mathutils/mathutils_Euler.c +++ b/source/blender/python/mathutils/mathutils_Euler.c @@ -25,8 +25,8 @@ * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/python/generic/mathutils_Euler.c - * \ingroup pygen +/** \file blender/python/mathutils/mathutils_Euler.c + * \ingroup pymathutils */ diff --git a/source/blender/python/mathutils/mathutils_Euler.h b/source/blender/python/mathutils/mathutils_Euler.h index 0c51a2a1dd8..46f5910f31f 100644 --- a/source/blender/python/mathutils/mathutils_Euler.h +++ b/source/blender/python/mathutils/mathutils_Euler.h @@ -27,8 +27,8 @@ * */ -/** \file blender/python/generic/mathutils_Euler.h - * \ingroup pygen +/** \file blender/python/mathutils/mathutils_Euler.h + * \ingroup pymathutils */ diff --git a/source/blender/python/mathutils/mathutils_Matrix.c b/source/blender/python/mathutils/mathutils_Matrix.c index 2a5d45bdff0..980dbd17a96 100644 --- a/source/blender/python/mathutils/mathutils_Matrix.c +++ b/source/blender/python/mathutils/mathutils_Matrix.c @@ -24,8 +24,8 @@ * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/python/generic/mathutils_Matrix.c - * \ingroup pygen +/** \file blender/python/mathutils/mathutils_Matrix.c + * \ingroup pymathutils */ diff --git a/source/blender/python/mathutils/mathutils_Matrix.h b/source/blender/python/mathutils/mathutils_Matrix.h index 01fae91b1a4..275f4270787 100644 --- a/source/blender/python/mathutils/mathutils_Matrix.h +++ b/source/blender/python/mathutils/mathutils_Matrix.h @@ -26,8 +26,8 @@ * */ -/** \file blender/python/generic/mathutils_Matrix.h - * \ingroup pygen +/** \file blender/python/mathutils/mathutils_Matrix.h + * \ingroup pymathutils */ diff --git a/source/blender/python/mathutils/mathutils_Quaternion.c b/source/blender/python/mathutils/mathutils_Quaternion.c index f892c25f67e..3f0a5d55ec2 100644 --- a/source/blender/python/mathutils/mathutils_Quaternion.c +++ b/source/blender/python/mathutils/mathutils_Quaternion.c @@ -24,8 +24,8 @@ * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/python/generic/mathutils_Quaternion.c - * \ingroup pygen +/** \file blender/python/mathutils/mathutils_Quaternion.c + * \ingroup pymathutils */ diff --git a/source/blender/python/mathutils/mathutils_Quaternion.h b/source/blender/python/mathutils/mathutils_Quaternion.h index c8029d61679..13060ed9ff9 100644 --- a/source/blender/python/mathutils/mathutils_Quaternion.h +++ b/source/blender/python/mathutils/mathutils_Quaternion.h @@ -27,8 +27,8 @@ * */ -/** \file blender/python/generic/mathutils_Quaternion.h - * \ingroup pygen +/** \file blender/python/mathutils/mathutils_Quaternion.h + * \ingroup pymathutils */ diff --git a/source/blender/python/mathutils/mathutils_Vector.c b/source/blender/python/mathutils/mathutils_Vector.c index a932d8d6b01..ba7cf604c42 100644 --- a/source/blender/python/mathutils/mathutils_Vector.c +++ b/source/blender/python/mathutils/mathutils_Vector.c @@ -24,8 +24,8 @@ * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/python/generic/mathutils_Vector.c - * \ingroup pygen +/** \file blender/python/mathutils/mathutils_Vector.c + * \ingroup pymathutils */ diff --git a/source/blender/python/mathutils/mathutils_Vector.h b/source/blender/python/mathutils/mathutils_Vector.h index bd4cd5f5be7..610805fcee0 100644 --- a/source/blender/python/mathutils/mathutils_Vector.h +++ b/source/blender/python/mathutils/mathutils_Vector.h @@ -27,8 +27,8 @@ * */ -/** \file blender/python/generic/mathutils_Vector.h - * \ingroup pygen +/** \file blender/python/mathutils/mathutils_Vector.h + * \ingroup pymathutils */ diff --git a/source/blender/python/mathutils/mathutils_geometry.c b/source/blender/python/mathutils/mathutils_geometry.c index 6e8624721b7..3518c8008c6 100644 --- a/source/blender/python/mathutils/mathutils_geometry.c +++ b/source/blender/python/mathutils/mathutils_geometry.c @@ -26,8 +26,8 @@ * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/python/generic/mathutils_geometry.c - * \ingroup pygen +/** \file blender/python/mathutils/mathutils_geometry.c + * \ingroup pymathutils */ @@ -97,14 +97,14 @@ static PyObject *M_Geometry_intersect_ray_tri(PyObject *UNUSED(self), PyObject* if (BaseMath_ReadCallback(vec1) == -1 || BaseMath_ReadCallback(vec2) == -1 || BaseMath_ReadCallback(vec3) == -1 || BaseMath_ReadCallback(ray) == -1 || BaseMath_ReadCallback(ray_off) == -1) return NULL; - VECCOPY(v1, vec1->vec); - VECCOPY(v2, vec2->vec); - VECCOPY(v3, vec3->vec); + copy_v3_v3(v1, vec1->vec); + copy_v3_v3(v2, vec2->vec); + copy_v3_v3(v3, vec3->vec); - VECCOPY(dir, ray->vec); + copy_v3_v3(dir, ray->vec); normalize_v3(dir); - VECCOPY(orig, ray_off->vec); + copy_v3_v3(orig, ray_off->vec); /* find vectors for two edges sharing v1 */ sub_v3_v3v3(e1, v2, v1); @@ -189,10 +189,10 @@ static PyObject *M_Geometry_intersect_line_line(PyObject *UNUSED(self), PyObject int result; if (vec1->size == 3) { - VECCOPY(v1, vec1->vec); - VECCOPY(v2, vec2->vec); - VECCOPY(v3, vec3->vec); - VECCOPY(v4, vec4->vec); + copy_v3_v3(v1, vec1->vec); + copy_v3_v3(v2, vec2->vec); + copy_v3_v3(v3, vec3->vec); + copy_v3_v3(v4, vec4->vec); } else { v1[0]= vec1->vec[0]; diff --git a/source/blender/python/mathutils/mathutils_geometry.h b/source/blender/python/mathutils/mathutils_geometry.h index 58a2bf9142f..1b339bdaf00 100644 --- a/source/blender/python/mathutils/mathutils_geometry.h +++ b/source/blender/python/mathutils/mathutils_geometry.h @@ -26,8 +26,8 @@ * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/python/generic/mathutils_geometry.h - * \ingroup pygen +/** \file blender/python/mathutils/mathutils_geometry.h + * \ingroup pymathutils */ /*Include this file for access to vector, quat, matrix, euler, etc...*/ |