diff options
Diffstat (limited to 'source/blender/python')
25 files changed, 120 insertions, 42 deletions
diff --git a/source/blender/python/generic/bgl.c b/source/blender/python/generic/bgl.c index 441c4b6438a..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 */ diff --git a/source/blender/python/generic/bgl.h b/source/blender/python/generic/bgl.h index 6df534a3940..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 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 acfe6ee80bf..88e2da16eb5 100644 --- a/source/blender/python/generic/bpy_internal_import.c +++ b/source/blender/python/generic/bpy_internal_import.c @@ -17,14 +17,19 @@ * * This is a new part of Blender. * - * Contributor(s): Willian P. Germano, - * Campbell Barton + * 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). */ 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 ea2266c99b4..ffa9e5cc27c 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 cfd2e5556a1..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); diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index 3411bceda69..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> @@ -6470,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_geometry.c b/source/blender/python/mathutils/mathutils_geometry.c index e8721a3a91d..3518c8008c6 100644 --- a/source/blender/python/mathutils/mathutils_geometry.c +++ b/source/blender/python/mathutils/mathutils_geometry.c @@ -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]; |