Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2012-03-27 00:41:54 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-03-27 00:41:54 +0400
commitabf551b1a51fe7991be0eb9a8ced6a9c4db927e5 (patch)
treec1e279a212e8b3de1672fdacfd640c6d78569f77 /source/blender/python/intern
parent57f7aca8ee7d64c66ce8de950d1856c962841589 (diff)
style cleanup: py api
Diffstat (limited to 'source/blender/python/intern')
-rw-r--r--source/blender/python/intern/bpy.c10
-rw-r--r--source/blender/python/intern/bpy_app.c3
-rw-r--r--source/blender/python/intern/bpy_app_ffmpeg.c12
-rw-r--r--source/blender/python/intern/bpy_app_handlers.c88
-rw-r--r--source/blender/python/intern/bpy_interface.c24
-rw-r--r--source/blender/python/intern/bpy_library.c87
-rw-r--r--source/blender/python/intern/bpy_operator.c26
-rw-r--r--source/blender/python/intern/bpy_operator_wrap.c3
-rw-r--r--source/blender/python/intern/bpy_props.c56
-rw-r--r--source/blender/python/intern/bpy_rna.c1621
-rw-r--r--source/blender/python/intern/bpy_rna_anim.c18
-rw-r--r--source/blender/python/intern/bpy_rna_array.c4
-rw-r--r--source/blender/python/intern/bpy_traceback.c10
-rw-r--r--source/blender/python/intern/bpy_util.c8
-rw-r--r--source/blender/python/intern/gpu.c79
15 files changed, 1027 insertions, 1022 deletions
diff --git a/source/blender/python/intern/bpy.c b/source/blender/python/intern/bpy.c
index 71cfa50743d..1e2e2bf6b2b 100644
--- a/source/blender/python/intern/bpy.c
+++ b/source/blender/python/intern/bpy.c
@@ -52,7 +52,7 @@
#include "MEM_guardedalloc.h"
- /* external util modules */
+/* external util modules */
#include "../generic/idprop_py_api.h"
#include "../generic/bgl.h"
#include "../generic/blf_py_api.h"
@@ -211,11 +211,11 @@ static PyObject *bpy_resource_path(PyObject *UNUSED(self), PyObject *args, PyObj
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};
+ {"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};
+ {"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};
+ {"resource_path", (PyCFunction)bpy_resource_path, METH_VARARGS | METH_KEYWORDS, bpy_resource_path_doc};
static PyObject *bpy_import_test(const char *modname)
@@ -279,7 +279,7 @@ void BPy_init_modules(void)
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());
- /* ops is now a python module that does the conversion from SOME_OT_foo -> some.foo */
+ /* 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());
diff --git a/source/blender/python/intern/bpy_app.c b/source/blender/python/intern/bpy_app.c
index 7cd672ba0c5..aab1f508e32 100644
--- a/source/blender/python/intern/bpy_app.c
+++ b/source/blender/python/intern/bpy_app.c
@@ -223,10 +223,11 @@ PyDoc_STRVAR(bpy_app_driver_dict_doc,
);
static PyObject *bpy_app_driver_dict_get(PyObject *UNUSED(self), void *UNUSED(closure))
{
- if (bpy_pydriver_Dict == NULL)
+ if (bpy_pydriver_Dict == NULL) {
if (bpy_pydriver_create_dict() != 0) {
PyErr_SetString(PyExc_RuntimeError, "bpy.app.driver_namespace failed to create dictionary");
return NULL;
+ }
}
Py_INCREF(bpy_pydriver_Dict);
diff --git a/source/blender/python/intern/bpy_app_ffmpeg.c b/source/blender/python/intern/bpy_app_ffmpeg.c
index 778334c9600..44bba4c098f 100644
--- a/source/blender/python/intern/bpy_app_ffmpeg.c
+++ b/source/blender/python/intern/bpy_app_ffmpeg.c
@@ -88,16 +88,18 @@ static PyObject *make_ffmpeg_info(void)
PyStructSequence_SET_ITEM(ffmpeg_info, pos++, obj)
#ifdef WITH_FFMPEG
- #define FFMPEG_LIB_VERSION(lib) \
+# define FFMPEG_LIB_VERSION(lib) { \
curversion = lib ## _version(); \
SetObjItem(Py_BuildValue("(iii)", \
- curversion >> 16, (curversion >> 8) % 256, curversion % 256)); \
+ curversion >> 16, (curversion >> 8) % 256, curversion % 256)); \
SetObjItem(PyUnicode_FromFormat("%2d, %2d, %2d", \
- curversion >> 16, (curversion >> 8) % 256, curversion % 256));
+ curversion >> 16, (curversion >> 8) % 256, curversion % 256)); \
+} (void)0
#else
- #define FFMPEG_LIB_VERSION(lib) \
+# define FFMPEG_LIB_VERSION(lib) { \
SetStrItem("Unknown"); \
- SetStrItem("Unknown");
+ SetStrItem("Unknown"); \
+} (void)0
#endif
#ifdef WITH_FFMPEG
diff --git a/source/blender/python/intern/bpy_app_handlers.c b/source/blender/python/intern/bpy_app_handlers.c
index 2974e3cf3cb..5128cf0b924 100644
--- a/source/blender/python/intern/bpy_app_handlers.c
+++ b/source/blender/python/intern/bpy_app_handlers.c
@@ -71,7 +71,7 @@ static PyStructSequence_Desc app_cb_info_desc = {
};
#if 0
-# if (BLI_CB_EVT_TOT != ((sizeof(app_cb_info_fields)/sizeof(PyStructSequence_Field))))
+# if (BLI_CB_EVT_TOT != ((sizeof(app_cb_info_fields) / sizeof(PyStructSequence_Field))))
# error "Callbacks are out of sync"
# endif
#endif
@@ -118,51 +118,51 @@ static PyObject *bpy_app_handlers_persistent_new(PyTypeObject *UNUSED(type), PyO
static PyTypeObject BPyPersistent_Type = {
#if defined(_MSC_VER) || defined(FREE_WINDOWS)
- PyVarObject_HEAD_INIT(NULL, 0)
+ PyVarObject_HEAD_INIT(NULL, 0)
#else
- PyVarObject_HEAD_INIT(&PyType_Type, 0)
+ PyVarObject_HEAD_INIT(&PyType_Type, 0)
#endif
- "persistent", /* tp_name */
- 0, /* tp_basicsize */
- 0, /* tp_itemsize */
- /* methods */
- 0, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC |
- Py_TPFLAGS_BASETYPE, /* tp_flags */
- 0, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- 0, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- 0, /* tp_init */
- 0, /* tp_alloc */
- bpy_app_handlers_persistent_new, /* tp_new */
- 0, /* tp_free */
+ "persistent", /* tp_name */
+ 0, /* tp_basicsize */
+ 0, /* tp_itemsize */
+ /* methods */
+ 0, /* tp_dealloc */
+ 0, /* tp_print */
+ 0, /* tp_getattr */
+ 0, /* tp_setattr */
+ 0, /* tp_reserved */
+ 0, /* tp_repr */
+ 0, /* tp_as_number */
+ 0, /* tp_as_sequence */
+ 0, /* tp_as_mapping */
+ 0, /* tp_hash */
+ 0, /* tp_call */
+ 0, /* tp_str */
+ 0, /* tp_getattro */
+ 0, /* tp_setattro */
+ 0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC |
+ Py_TPFLAGS_BASETYPE, /* tp_flags */
+ 0, /* tp_doc */
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ 0, /* tp_methods */
+ 0, /* tp_members */
+ 0, /* tp_getset */
+ 0, /* tp_base */
+ 0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ 0, /* tp_init */
+ 0, /* tp_alloc */
+ bpy_app_handlers_persistent_new, /* tp_new */
+ 0, /* tp_free */
};
static PyObject *py_cb_array[BLI_CB_EVT_TOT] = {NULL};
@@ -237,7 +237,7 @@ void BPY_app_handlers_reset(const short do_all)
int pos = 0;
if (do_all) {
- for (pos = 0; pos < BLI_CB_EVT_TOT; pos++) {
+ for (pos = 0; pos < BLI_CB_EVT_TOT; pos++) {
/* clear list */
PyList_SetSlice(py_cb_array[pos], 0, PY_SSIZE_T_MAX, NULL);
}
diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c
index f3d21c74080..61b3f7b1575 100644
--- a/source/blender/python/intern/bpy_interface.c
+++ b/source/blender/python/intern/bpy_interface.c
@@ -86,10 +86,10 @@ BPy_StructRNA *bpy_context_module = NULL; /* for fast access */
#ifdef TIME_PY_RUN
#include "PIL_time.h"
-static int bpy_timer_count = 0;
-static double bpy_timer; /* time since python starts */
-static double bpy_timer_run; /* time for each python script run */
-static double bpy_timer_run_tot; /* accumulate python runs */
+static int bpy_timer_count = 0;
+static double bpy_timer; /* time since python starts */
+static double bpy_timer_run; /* time for each python script run */
+static double bpy_timer_run_tot; /* accumulate python runs */
#endif
/* use for updating while a python script runs - in case of file load */
@@ -184,7 +184,7 @@ extern PyObject *AUD_initPython(void);
/* defined in cycles module */
static PyObject *CCL_initPython(void)
{
- return (PyObject*)CCL_python_module_init();
+ return (PyObject *)CCL_python_module_init();
}
#endif
@@ -195,8 +195,8 @@ static struct _inittab bpy_internal_modules[] = {
{(char *)"bgl", BPyInit_bgl},
{(char *)"blf", BPyInit_blf},
{(char *)"bmesh", BPyInit_bmesh},
- // {(char *)"bmesh.types", BPyInit_bmesh_types},
- // {(char *)"bmesh.utils", BPyInit_bmesh_utils},
+ // {(char *)"bmesh.types", BPyInit_bmesh_types},
+ // {(char *)"bmesh.utils", BPyInit_bmesh_utils},
#ifdef WITH_AUDASPACE
{(char *)"aud", AUD_initPython},
#endif
@@ -308,10 +308,10 @@ void BPY_python_end(void)
printf("tot exec: %d, ", bpy_timer_count);
printf("tot run: %.4fsec, ", bpy_timer_run_tot);
if (bpy_timer_count > 0)
- printf("average run: %.6fsec, ", (bpy_timer_run_tot/bpy_timer_count));
+ printf("average run: %.6fsec, ", (bpy_timer_run_tot / bpy_timer_count));
if (bpy_timer > 0.0)
- printf("tot usage %.4f%%", (bpy_timer_run_tot/bpy_timer) * 100.0);
+ printf("tot usage %.4f%%", (bpy_timer_run_tot / bpy_timer) * 100.0);
printf("\n");
@@ -367,7 +367,7 @@ static int python_script_exec(bContext *C, const char *fn, struct Text *text,
char fn_dummy[FILE_MAXDIR];
bpy_text_filename_get(fn_dummy, sizeof(fn_dummy), text);
- if (text->compiled == NULL) { /* if it wasn't already compiled, do it now */
+ if (text->compiled == NULL) { /* if it wasn't already compiled, do it now */
char *buf = txt_to_buf(text);
text->compiled = Py_CompileString(buf, fn_dummy, Py_file_input);
@@ -692,8 +692,8 @@ int BPY_context_member_get(bContext *C, const char *member, bContextDataResult *
}
if (done == 0) {
- if (item) printf("PyContext '%s' not a valid type\n", member);
- else printf("PyContext '%s' not found\n", member);
+ if (item) printf("PyContext '%s' not a valid type\n", member);
+ else printf("PyContext '%s' not found\n", member);
}
else {
if (G.f & G_DEBUG) {
diff --git a/source/blender/python/intern/bpy_library.c b/source/blender/python/intern/bpy_library.c
index 9148ccde9a0..a5350b984c1 100644
--- a/source/blender/python/intern/bpy_library.c
+++ b/source/blender/python/intern/bpy_library.c
@@ -92,75 +92,75 @@ static void bpy_lib_dealloc(BPy_Library *self)
static PyTypeObject bpy_lib_Type = {
PyVarObject_HEAD_INIT(NULL, 0)
- "bpy_lib", /* tp_name */
- sizeof(BPy_Library), /* tp_basicsize */
- 0, /* tp_itemsize */
+ "bpy_lib", /* tp_name */
+ sizeof(BPy_Library), /* tp_basicsize */
+ 0, /* tp_itemsize */
/* methods */
- (destructor)bpy_lib_dealloc,/* tp_dealloc */
+ (destructor)bpy_lib_dealloc, /* tp_dealloc */
NULL, /* printfunc tp_print; */
- NULL, /* getattrfunc tp_getattr; */
+ NULL, /* getattrfunc tp_getattr; */
NULL, /* setattrfunc tp_setattr; */
- NULL, /* tp_compare */ /* DEPRECATED in python 3.0! */
- NULL, /* tp_repr */
+ NULL, /* tp_compare */ /* DEPRECATED in python 3.0! */
+ NULL, /* tp_repr */
/* Method suites for standard classes */
- NULL, /* PyNumberMethods *tp_as_number; */
- NULL, /* PySequenceMethods *tp_as_sequence; */
- NULL, /* PyMappingMethods *tp_as_mapping; */
+ NULL, /* PyNumberMethods *tp_as_number; */
+ NULL, /* PySequenceMethods *tp_as_sequence; */
+ NULL, /* PyMappingMethods *tp_as_mapping; */
/* More standard operations (here for binary compatibility) */
- NULL, /* hashfunc tp_hash; */
+ NULL, /* hashfunc tp_hash; */
NULL, /* ternaryfunc tp_call; */
NULL, /* reprfunc tp_str; */
/* will only use these if this is a subtype of a py class */
- NULL /*PyObject_GenericGetAttr is assigned later */, /* getattrofunc tp_getattro; */
- NULL, /* setattrofunc tp_setattro; */
+ NULL /*PyObject_GenericGetAttr is assigned later */, /* getattrofunc tp_getattro; */
+ NULL, /* setattrofunc tp_setattro; */
/* Functions to access object as input/output buffer */
NULL, /* PyBufferProcs *tp_as_buffer; */
- /*** Flags to define presence of optional/expanded features ***/
+ /*** Flags to define presence of optional/expanded features ***/
Py_TPFLAGS_DEFAULT, /* long tp_flags; */
- NULL, /* char *tp_doc; Documentation string */
- /*** Assigned meaning in release 2.0 ***/
+ NULL, /* char *tp_doc; Documentation string */
+ /*** Assigned meaning in release 2.0 ***/
/* call function for all accessible objects */
NULL, /* traverseproc tp_traverse; */
/* delete references to contained objects */
NULL, /* inquiry tp_clear; */
- /*** Assigned meaning in release 2.1 ***/
- /*** rich comparisons ***/
+ /*** Assigned meaning in release 2.1 ***/
+ /*** rich comparisons ***/
NULL, /* subclassed */ /* richcmpfunc tp_richcompare; */
- /*** weak reference enabler ***/
+ /*** weak reference enabler ***/
0,
- /*** Added in release 2.2 ***/
+ /*** Added in release 2.2 ***/
/* Iterators */
- NULL, /* getiterfunc tp_iter; */
+ NULL, /* getiterfunc tp_iter; */
NULL, /* iternextfunc tp_iternext; */
- /*** Attribute descriptor and subclassing stuff ***/
- bpy_lib_methods, /* struct PyMethodDef *tp_methods; */
+ /*** Attribute descriptor and subclassing stuff ***/
+ bpy_lib_methods, /* struct PyMethodDef *tp_methods; */
NULL, /* struct PyMemberDef *tp_members; */
- NULL, /* struct PyGetSetDef *tp_getset; */
+ NULL, /* struct PyGetSetDef *tp_getset; */
NULL, /* struct _typeobject *tp_base; */
NULL, /* PyObject *tp_dict; */
NULL, /* descrgetfunc tp_descr_get; */
NULL, /* descrsetfunc tp_descr_set; */
- offsetof(BPy_Library, dict),/* long tp_dictoffset; */
+ offsetof(BPy_Library, dict), /* long tp_dictoffset; */
NULL, /* initproc tp_init; */
NULL, /* allocfunc tp_alloc; */
- NULL, /* newfunc tp_new; */
+ NULL, /* newfunc tp_new; */
/* Low-level free-memory routine */
NULL, /* freefunc tp_free; */
/* For PyObject_IS_GC */
NULL, /* inquiry tp_is_gc; */
- NULL, /* PyObject *tp_bases; */
+ NULL, /* PyObject *tp_bases; */
/* method resolution order */
NULL, /* PyObject *tp_mro; */
NULL, /* PyObject *tp_cache; */
@@ -170,18 +170,18 @@ static PyTypeObject bpy_lib_Type = {
};
PyDoc_STRVAR(bpy_lib_load_doc,
-".. method:: load(filepath, link=False, relative=False)\n"
-"\n"
-" Returns a context manager which exposes 2 library objects on entering.\n"
-" Each object has attributes matching bpy.data which are lists of strings to be linked.\n"
-"\n"
-" :arg filepath: The path to a blend file.\n"
-" :type filepath: string\n"
-" :arg link: When False reference to the original file is lost.\n"
-" :type link: bool\n"
-" :arg relative: When True the path is stored relative to the open blend file.\n"
-" :type relative: bool\n"
-);
+ ".. method:: load(filepath, link=False, relative=False)\n"
+ "\n"
+ " Returns a context manager which exposes 2 library objects on entering.\n"
+ " Each object has attributes matching bpy.data which are lists of strings to be linked.\n"
+ "\n"
+ " :arg filepath: The path to a blend file.\n"
+ " :type filepath: string\n"
+ " :arg link: When False reference to the original file is lost.\n"
+ " :type link: bool\n"
+ " :arg relative: When True the path is stored relative to the open blend file.\n"
+ " :type relative: bool\n"
+ );
static PyObject *bpy_lib_load(PyObject *UNUSED(self), PyObject *args, PyObject *kwds)
{
static const char *kwlist[] = {"filepath", "link", "relative", NULL};
@@ -222,7 +222,7 @@ static PyObject *_bpy_names(BPy_Library *self, int blocktype)
PyList_SET_ITEM(list, counter, PyUnicode_FromString((char *)l->link));
counter++;
}
- BLI_linklist_free(names, free); /* free linklist *and* each node's data */
+ BLI_linklist_free(names, free); /* free linklist *and* each node's data */
}
else {
list = PyList_New(0);
@@ -401,7 +401,8 @@ static PyObject *bpy_lib_exit(BPy_Library *self, PyObject *UNUSED(args))
BLO_blendhandle_close(self->blo_handle);
self->blo_handle = NULL;
- { /* copied from wm_operator.c */
+ /* copied from wm_operator.c */
+ {
/* mark all library linked objects to be updated */
recalc_all_library_objects(G.main);
@@ -426,8 +427,8 @@ static PyObject *bpy_lib_dir(BPy_Library *self)
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};
+ METH_STATIC | METH_VARARGS | METH_KEYWORDS,
+ bpy_lib_load_doc};
PyModule_AddObject(mod_par, "_library_load", PyCFunction_New(&load_meth, NULL));
diff --git a/source/blender/python/intern/bpy_operator.c b/source/blender/python/intern/bpy_operator.c
index 14058c96633..8f5a9fec86b 100644
--- a/source/blender/python/intern/bpy_operator.c
+++ b/source/blender/python/intern/bpy_operator.c
@@ -65,11 +65,11 @@
static PyObject *pyop_poll(PyObject *UNUSED(self), PyObject *args)
{
wmOperatorType *ot;
- char *opname;
- PyObject *context_dict = NULL; /* optional args */
- PyObject *context_dict_back;
- char *context_str = NULL;
- PyObject *ret;
+ char *opname;
+ PyObject *context_dict = NULL; /* optional args */
+ PyObject *context_dict_back;
+ char *context_str = NULL;
+ PyObject *ret;
int context = WM_OP_EXEC_DEFAULT;
@@ -139,11 +139,11 @@ static PyObject *pyop_call(PyObject *UNUSED(self), PyObject *args)
PointerRNA ptr;
int operator_ret = OPERATOR_CANCELLED;
- char *opname;
- char *context_str = NULL;
- PyObject *kw = NULL; /* optional args */
- PyObject *context_dict = NULL; /* optional args */
- PyObject *context_dict_back;
+ char *opname;
+ char *context_str = NULL;
+ PyObject *kw = NULL; /* optional args */
+ PyObject *context_dict = NULL; /* optional args */
+ PyObject *context_dict_back;
/* note that context is an int, python does the conversion in this case */
int context = WM_OP_EXEC_DEFAULT;
@@ -306,8 +306,8 @@ static PyObject *pyop_as_string(PyObject *UNUSED(self), PyObject *args)
wmOperatorType *ot;
PointerRNA ptr;
- char *opname;
- PyObject *kw = NULL; /* optional args */
+ char *opname;
+ PyObject *kw = NULL; /* optional args */
int all_args = 1;
int error_val = 0;
@@ -462,7 +462,7 @@ static struct PyModuleDef bpy_ops_module = {
PyModuleDef_HEAD_INIT,
"_bpy.ops",
NULL,
- -1,/* multiple "initialization" just copies the module dict. */
+ -1, /* multiple "initialization" just copies the module dict. */
bpy_ops_methods,
NULL, NULL, NULL, NULL
};
diff --git a/source/blender/python/intern/bpy_operator_wrap.c b/source/blender/python/intern/bpy_operator_wrap.c
index 39780e7e257..1caec294aa0 100644
--- a/source/blender/python/intern/bpy_operator_wrap.c
+++ b/source/blender/python/intern/bpy_operator_wrap.c
@@ -69,7 +69,8 @@ void operator_wrapper(wmOperatorType *ot, void *userdata)
operator_properties_init(ot);
- { /* XXX - not nice, set the first enum as searchable, should have a way for python to set */
+ /* XXX - not nice, set the first enum as searchable, should have a way for python to set */
+ {
PointerRNA ptr;
PropertyRNA *prop;
diff --git a/source/blender/python/intern/bpy_props.c b/source/blender/python/intern/bpy_props.c
index ae818eb2491..4d0c05f6582 100644
--- a/source/blender/python/intern/bpy_props.c
+++ b/source/blender/python/intern/bpy_props.c
@@ -399,7 +399,7 @@ static PyObject *BPy_BoolProperty(PyObject *self, PyObject *args, PyObject *kw)
if (srna) {
static const char *kwlist[] = {"attr", "name", "description", "default",
- "options", "subtype", "update", NULL};
+ "options", "subtype", "update", NULL};
const char *id = NULL, *name = NULL, *description = "";
int id_len;
int def = 0;
@@ -475,7 +475,7 @@ static PyObject *BPy_BoolVectorProperty(PyObject *self, PyObject *args, PyObject
if (srna) {
static const char *kwlist[] = {"attr", "name", "description", "default",
- "options", "subtype", "size", "update", NULL};
+ "options", "subtype", "size", "update", NULL};
const char *id = NULL, *name = NULL, *description = "";
int id_len;
int def[PYRNA_STACK_ARRAY] = {0};
@@ -561,7 +561,7 @@ static PyObject *BPy_IntProperty(PyObject *self, PyObject *args, PyObject *kw)
if (srna) {
static const char *kwlist[] = {"attr", "name", "description", "default",
- "min", "max", "soft_min", "soft_max",
+ "min", "max", "soft_min", "soft_max",
"step", "options", "subtype", "update", NULL};
const char *id = NULL, *name = NULL, *description = "";
int id_len;
@@ -642,8 +642,8 @@ static PyObject *BPy_IntVectorProperty(PyObject *self, PyObject *args, PyObject
if (srna) {
static const char *kwlist[] = {"attr", "name", "description", "default",
- "min", "max", "soft_min", "soft_max",
- "step", "options", "subtype", "size", "update", NULL};
+ "min", "max", "soft_min", "soft_max",
+ "step", "options", "subtype", "size", "update", NULL};
const char *id = NULL, *name = NULL, *description = "";
int id_len;
int min = INT_MIN, max = INT_MAX, soft_min = INT_MIN, soft_max = INT_MAX, step = 1;
@@ -736,8 +736,8 @@ static PyObject *BPy_FloatProperty(PyObject *self, PyObject *args, PyObject *kw)
if (srna) {
static const char *kwlist[] = {"attr", "name", "description", "default",
- "min", "max", "soft_min", "soft_max",
- "step", "precision", "options", "subtype", "unit", "update", NULL};
+ "min", "max", "soft_min", "soft_max",
+ "step", "precision", "options", "subtype", "unit", "update", NULL};
const char *id = NULL, *name = NULL, *description = "";
int id_len;
float min = -FLT_MAX, max = FLT_MAX, soft_min = -FLT_MAX, soft_max = FLT_MAX, step = 3, def = 0.0f;
@@ -829,8 +829,8 @@ static PyObject *BPy_FloatVectorProperty(PyObject *self, PyObject *args, PyObjec
if (srna) {
static const char *kwlist[] = {"attr", "name", "description", "default",
- "min", "max", "soft_min", "soft_max",
- "step", "precision", "options", "subtype", "unit", "size", "update", NULL};
+ "min", "max", "soft_min", "soft_max",
+ "step", "precision", "options", "subtype", "unit", "size", "update", NULL};
const char *id = NULL, *name = NULL, *description = "";
int id_len;
float min = -FLT_MAX, max = FLT_MAX, soft_min = -FLT_MAX, soft_max = FLT_MAX, step = 3;
@@ -924,7 +924,7 @@ static PyObject *BPy_StringProperty(PyObject *self, PyObject *args, PyObject *kw
if (srna) {
static const char *kwlist[] = {"attr", "name", "description", "default",
- "maxlen", "options", "subtype", "update", NULL};
+ "maxlen", "options", "subtype", "update", NULL};
const char *id = NULL, *name = NULL, *description = "", *def = "";
int id_len;
int maxlen = 0;
@@ -952,7 +952,7 @@ static PyObject *BPy_StringProperty(PyObject *self, PyObject *args, PyObject *kw
}
prop = RNA_def_property(srna, id, PROP_STRING, subtype);
- if (maxlen != 0) RNA_def_property_string_maxlength(prop, maxlen + 1); /* +1 since it includes null terminator */
+ if (maxlen != 0) RNA_def_property_string_maxlength(prop, maxlen + 1); /* +1 since it includes null terminator */
if (def) RNA_def_property_string_default(prop, def);
RNA_def_property_ui_text(prop, name ? name : id, description);
@@ -1110,7 +1110,7 @@ static EnumPropertyItem *enum_items_from_py(PyObject *seq_fast, PyObject *def, i
* annoying because it works most of the time without this. */
{
EnumPropertyItem *items_dup = MEM_mallocN((sizeof(EnumPropertyItem) * (seq_len + 1)) + (sizeof(char) * totbuf),
- "enum_items_from_py2");
+ "enum_items_from_py2");
EnumPropertyItem *items_ptr = items_dup;
char *buf = ((char *)items_dup) + (sizeof(EnumPropertyItem) * (seq_len + 1));
memcpy(items_dup, items, sizeof(EnumPropertyItem) * (seq_len + 1));
@@ -1162,7 +1162,7 @@ static EnumPropertyItem *bpy_props_enum_itemf(struct bContext *C, PointerRNA *pt
int defvalue_dummy = 0;
if (!(items_fast = PySequence_Fast(items, "EnumProperty(...): "
- "return value from the callback was not a sequence")))
+ "return value from the callback was not a sequence")))
{
err = -1;
}
@@ -1230,7 +1230,7 @@ static PyObject *BPy_EnumProperty(PyObject *self, PyObject *args, PyObject *kw)
if (srna) {
static const char *kwlist[] = {"attr", "items", "name", "description", "default",
- "options", "update", NULL};
+ "options", "update", NULL};
const char *id = NULL, *name = NULL, *description = "";
PyObject *def = NULL;
int id_len;
@@ -1281,7 +1281,7 @@ static PyObject *BPy_EnumProperty(PyObject *self, PyObject *args, PyObject *kw)
}
else {
if (!(items_fast = PySequence_Fast(items, "EnumProperty(...): "
- "expected a sequence of tuples for the enum items or a function")))
+ "expected a sequence of tuples for the enum items or a function")))
{
return NULL;
}
@@ -1531,18 +1531,18 @@ static PyObject *BPy_RemoveProperty(PyObject *self, PyObject *args, PyObject *kw
}
static struct PyMethodDef props_methods[] = {
- {"BoolProperty", (PyCFunction)BPy_BoolProperty, METH_VARARGS|METH_KEYWORDS, BPy_BoolProperty_doc},
- {"BoolVectorProperty", (PyCFunction)BPy_BoolVectorProperty, METH_VARARGS|METH_KEYWORDS, BPy_BoolVectorProperty_doc},
- {"IntProperty", (PyCFunction)BPy_IntProperty, METH_VARARGS|METH_KEYWORDS, BPy_IntProperty_doc},
- {"IntVectorProperty", (PyCFunction)BPy_IntVectorProperty, METH_VARARGS|METH_KEYWORDS, BPy_IntVectorProperty_doc},
- {"FloatProperty", (PyCFunction)BPy_FloatProperty, METH_VARARGS|METH_KEYWORDS, BPy_FloatProperty_doc},
- {"FloatVectorProperty", (PyCFunction)BPy_FloatVectorProperty, METH_VARARGS|METH_KEYWORDS, BPy_FloatVectorProperty_doc},
- {"StringProperty", (PyCFunction)BPy_StringProperty, METH_VARARGS|METH_KEYWORDS, BPy_StringProperty_doc},
- {"EnumProperty", (PyCFunction)BPy_EnumProperty, METH_VARARGS|METH_KEYWORDS, BPy_EnumProperty_doc},
- {"PointerProperty", (PyCFunction)BPy_PointerProperty, METH_VARARGS|METH_KEYWORDS, BPy_PointerProperty_doc},
- {"CollectionProperty", (PyCFunction)BPy_CollectionProperty, METH_VARARGS|METH_KEYWORDS, BPy_CollectionProperty_doc},
-
- {"RemoveProperty", (PyCFunction)BPy_RemoveProperty, METH_VARARGS|METH_KEYWORDS, BPy_RemoveProperty_doc},
+ {"BoolProperty", (PyCFunction)BPy_BoolProperty, METH_VARARGS | METH_KEYWORDS, BPy_BoolProperty_doc},
+ {"BoolVectorProperty", (PyCFunction)BPy_BoolVectorProperty, METH_VARARGS | METH_KEYWORDS, BPy_BoolVectorProperty_doc},
+ {"IntProperty", (PyCFunction)BPy_IntProperty, METH_VARARGS | METH_KEYWORDS, BPy_IntProperty_doc},
+ {"IntVectorProperty", (PyCFunction)BPy_IntVectorProperty, METH_VARARGS | METH_KEYWORDS, BPy_IntVectorProperty_doc},
+ {"FloatProperty", (PyCFunction)BPy_FloatProperty, METH_VARARGS | METH_KEYWORDS, BPy_FloatProperty_doc},
+ {"FloatVectorProperty", (PyCFunction)BPy_FloatVectorProperty, METH_VARARGS | METH_KEYWORDS, BPy_FloatVectorProperty_doc},
+ {"StringProperty", (PyCFunction)BPy_StringProperty, METH_VARARGS | METH_KEYWORDS, BPy_StringProperty_doc},
+ {"EnumProperty", (PyCFunction)BPy_EnumProperty, METH_VARARGS | METH_KEYWORDS, BPy_EnumProperty_doc},
+ {"PointerProperty", (PyCFunction)BPy_PointerProperty, METH_VARARGS | METH_KEYWORDS, BPy_PointerProperty_doc},
+ {"CollectionProperty", (PyCFunction)BPy_CollectionProperty, METH_VARARGS | METH_KEYWORDS, BPy_CollectionProperty_doc},
+
+ {"RemoveProperty", (PyCFunction)BPy_RemoveProperty, METH_VARARGS | METH_KEYWORDS, BPy_RemoveProperty_doc},
{NULL, NULL, 0, NULL}
};
@@ -1551,7 +1551,7 @@ static struct PyModuleDef props_module = {
"bpy.props",
"This module defines properties to extend blenders internal data, the result of these functions"
" is used to assign properties to classes registered with blender and can't be used directly.",
- -1,/* multiple "initialization" just copies the module dict. */
+ -1, /* multiple "initialization" just copies the module dict. */
props_methods,
NULL, NULL, NULL, NULL
};
diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c
index d66b7f98796..1f284ae01cb 100644
--- a/source/blender/python/intern/bpy_rna.c
+++ b/source/blender/python/intern/bpy_rna.c
@@ -508,11 +508,11 @@ static int mathutils_rna_vector_set_index(BaseMathObject *bmo, int UNUSED(subtyp
}
static Mathutils_Callback mathutils_rna_array_cb = {
- (BaseMathCheckFunc) mathutils_rna_generic_check,
- (BaseMathGetFunc) mathutils_rna_vector_get,
- (BaseMathSetFunc) mathutils_rna_vector_set,
- (BaseMathGetIndexFunc) mathutils_rna_vector_get_index,
- (BaseMathSetIndexFunc) mathutils_rna_vector_set_index
+ (BaseMathCheckFunc) mathutils_rna_generic_check,
+ (BaseMathGetFunc) mathutils_rna_vector_get,
+ (BaseMathSetFunc) mathutils_rna_vector_set,
+ (BaseMathGetIndexFunc) mathutils_rna_vector_get_index,
+ (BaseMathSetIndexFunc) mathutils_rna_vector_set_index
};
@@ -622,91 +622,91 @@ PyObject *pyrna_math_object_from_array(PointerRNA *ptr, PropertyRNA *prop)
if (totdim == 1 || (totdim == 2 && subtype == PROP_MATRIX)) {
if (!is_thick)
- ret = pyrna_prop_CreatePyObject(ptr, prop); /* owned by the mathutils PyObject */
+ ret = pyrna_prop_CreatePyObject(ptr, prop); /* owned by the mathutils PyObject */
switch (subtype) {
- case PROP_ALL_VECTOR_SUBTYPES:
- if (len >= 2 && len <= 4) {
- if (is_thick) {
- ret = Vector_CreatePyObject(NULL, len, Py_NEW, NULL);
- RNA_property_float_get_array(ptr, prop, ((VectorObject *)ret)->vec);
- }
- else {
- PyObject *vec_cb = Vector_CreatePyObject_cb(ret, len, mathutils_rna_array_cb_index, MATHUTILS_CB_SUBTYPE_VEC);
- Py_DECREF(ret); /* the vector owns now */
- ret = vec_cb; /* return the vector instead */
- }
- }
- break;
- case PROP_MATRIX:
- if (len == 16) {
- if (is_thick) {
- ret = Matrix_CreatePyObject(NULL, 4, 4, Py_NEW, NULL);
- RNA_property_float_get_array(ptr, prop, ((MatrixObject *)ret)->matrix);
- }
- else {
- PyObject *mat_cb = Matrix_CreatePyObject_cb(ret, 4,4, mathutils_rna_matrix_cb_index, FALSE);
- Py_DECREF(ret); /* the matrix owns now */
- ret = mat_cb; /* return the matrix instead */
- }
- }
- else if (len == 9) {
- if (is_thick) {
- ret = Matrix_CreatePyObject(NULL, 3, 3, Py_NEW, NULL);
- RNA_property_float_get_array(ptr, prop, ((MatrixObject *)ret)->matrix);
- }
- else {
- PyObject *mat_cb = Matrix_CreatePyObject_cb(ret, 3,3, mathutils_rna_matrix_cb_index, FALSE);
- Py_DECREF(ret); /* the matrix owns now */
- ret = mat_cb; /* return the matrix instead */
- }
- }
- break;
- case PROP_EULER:
- case PROP_QUATERNION:
- if (len == 3) { /* euler */
- if (is_thick) {
- /* attempt to get order, only needed for thick types since wrapped with update via callbacks */
- PropertyRNA *prop_eul_order = NULL;
- short order = pyrna_rotation_euler_order_get(ptr, &prop_eul_order, EULER_ORDER_XYZ);
-
- ret = Euler_CreatePyObject(NULL, order, Py_NEW, NULL); // TODO, get order from RNA
- RNA_property_float_get_array(ptr, prop, ((EulerObject *)ret)->eul);
+ case PROP_ALL_VECTOR_SUBTYPES:
+ if (len >= 2 && len <= 4) {
+ if (is_thick) {
+ ret = Vector_CreatePyObject(NULL, len, Py_NEW, NULL);
+ RNA_property_float_get_array(ptr, prop, ((VectorObject *)ret)->vec);
+ }
+ else {
+ PyObject *vec_cb = Vector_CreatePyObject_cb(ret, len, mathutils_rna_array_cb_index, MATHUTILS_CB_SUBTYPE_VEC);
+ Py_DECREF(ret); /* the vector owns now */
+ ret = vec_cb; /* return the vector instead */
+ }
}
- else {
- /* order will be updated from callback on use */
- PyObject *eul_cb = Euler_CreatePyObject_cb(ret, EULER_ORDER_XYZ, mathutils_rna_array_cb_index, MATHUTILS_CB_SUBTYPE_EUL); // TODO, get order from RNA
- Py_DECREF(ret); /* the euler owns now */
- ret = eul_cb; /* return the euler instead */
+ break;
+ case PROP_MATRIX:
+ if (len == 16) {
+ if (is_thick) {
+ ret = Matrix_CreatePyObject(NULL, 4, 4, Py_NEW, NULL);
+ RNA_property_float_get_array(ptr, prop, ((MatrixObject *)ret)->matrix);
+ }
+ else {
+ PyObject *mat_cb = Matrix_CreatePyObject_cb(ret, 4, 4, mathutils_rna_matrix_cb_index, FALSE);
+ Py_DECREF(ret); /* the matrix owns now */
+ ret = mat_cb; /* return the matrix instead */
+ }
}
- }
- else if (len == 4) {
- if (is_thick) {
- ret = Quaternion_CreatePyObject(NULL, Py_NEW, NULL);
- RNA_property_float_get_array(ptr, prop, ((QuaternionObject *)ret)->quat);
+ else if (len == 9) {
+ if (is_thick) {
+ ret = Matrix_CreatePyObject(NULL, 3, 3, Py_NEW, NULL);
+ RNA_property_float_get_array(ptr, prop, ((MatrixObject *)ret)->matrix);
+ }
+ else {
+ PyObject *mat_cb = Matrix_CreatePyObject_cb(ret, 3, 3, mathutils_rna_matrix_cb_index, FALSE);
+ Py_DECREF(ret); /* the matrix owns now */
+ ret = mat_cb; /* return the matrix instead */
+ }
}
- else {
- PyObject *quat_cb = Quaternion_CreatePyObject_cb(ret, mathutils_rna_array_cb_index, MATHUTILS_CB_SUBTYPE_QUAT);
- Py_DECREF(ret); /* the quat owns now */
- ret = quat_cb; /* return the quat instead */
+ break;
+ case PROP_EULER:
+ case PROP_QUATERNION:
+ if (len == 3) { /* euler */
+ if (is_thick) {
+ /* attempt to get order, only needed for thick types since wrapped with update via callbacks */
+ PropertyRNA *prop_eul_order = NULL;
+ short order = pyrna_rotation_euler_order_get(ptr, &prop_eul_order, EULER_ORDER_XYZ);
+
+ ret = Euler_CreatePyObject(NULL, order, Py_NEW, NULL); // TODO, get order from RNA
+ RNA_property_float_get_array(ptr, prop, ((EulerObject *)ret)->eul);
+ }
+ else {
+ /* order will be updated from callback on use */
+ PyObject *eul_cb = Euler_CreatePyObject_cb(ret, EULER_ORDER_XYZ, mathutils_rna_array_cb_index, MATHUTILS_CB_SUBTYPE_EUL); // TODO, get order from RNA
+ Py_DECREF(ret); /* the euler owns now */
+ ret = eul_cb; /* return the euler instead */
+ }
}
- }
- break;
- case PROP_COLOR:
- case PROP_COLOR_GAMMA:
- if (len == 3) { /* color */
- if (is_thick) {
- ret = Color_CreatePyObject(NULL, Py_NEW, NULL); // TODO, get order from RNA
- RNA_property_float_get_array(ptr, prop, ((ColorObject *)ret)->col);
+ else if (len == 4) {
+ if (is_thick) {
+ ret = Quaternion_CreatePyObject(NULL, Py_NEW, NULL);
+ RNA_property_float_get_array(ptr, prop, ((QuaternionObject *)ret)->quat);
+ }
+ else {
+ PyObject *quat_cb = Quaternion_CreatePyObject_cb(ret, mathutils_rna_array_cb_index, MATHUTILS_CB_SUBTYPE_QUAT);
+ Py_DECREF(ret); /* the quat owns now */
+ ret = quat_cb; /* return the quat instead */
+ }
}
- else {
- PyObject *col_cb = Color_CreatePyObject_cb(ret, mathutils_rna_array_cb_index, MATHUTILS_CB_SUBTYPE_COLOR);
- Py_DECREF(ret); /* the color owns now */
- ret = col_cb; /* return the color instead */
+ break;
+ case PROP_COLOR:
+ case PROP_COLOR_GAMMA:
+ if (len == 3) { /* color */
+ if (is_thick) {
+ ret = Color_CreatePyObject(NULL, Py_NEW, NULL); // TODO, get order from RNA
+ RNA_property_float_get_array(ptr, prop, ((ColorObject *)ret)->col);
+ }
+ else {
+ PyObject *col_cb = Color_CreatePyObject_cb(ret, mathutils_rna_array_cb_index, MATHUTILS_CB_SUBTYPE_COLOR);
+ Py_DECREF(ret); /* the color owns now */
+ ret = col_cb; /* return the color instead */
+ }
}
- }
- default:
- break;
+ default:
+ break;
}
}
@@ -840,8 +840,8 @@ static PyObject *pyrna_struct_str(BPy_StructRNA *self)
name = RNA_struct_name_get_alloc(&self->ptr, NULL, 0, NULL);
if (name) {
ret = PyUnicode_FromFormat("<bpy_struct, %.200s(\"%.200s\")>",
- RNA_struct_identifier(self->ptr.type),
- name);
+ RNA_struct_identifier(self->ptr.type),
+ name);
MEM_freeN((void *)name);
return ret;
}
@@ -858,30 +858,30 @@ static PyObject *pyrna_struct_repr(BPy_StructRNA *self)
PyObject *ret;
if (id == NULL || !PYRNA_STRUCT_IS_VALID(self))
- return pyrna_struct_str(self); /* fallback */
+ return pyrna_struct_str(self); /* fallback */
tmp_str = PyUnicode_FromString(id->name + 2);
if (RNA_struct_is_ID(self->ptr.type)) {
ret = PyUnicode_FromFormat("bpy.data.%s[%R]",
- BKE_idcode_to_name_plural(GS(id->name)),
- tmp_str);
+ BKE_idcode_to_name_plural(GS(id->name)),
+ tmp_str);
}
else {
const char *path;
path = RNA_path_from_ID_to_struct(&self->ptr);
if (path) {
ret = PyUnicode_FromFormat("bpy.data.%s[%R].%s",
- BKE_idcode_to_name_plural(GS(id->name)),
- tmp_str,
- path);
+ BKE_idcode_to_name_plural(GS(id->name)),
+ tmp_str,
+ path);
MEM_freeN((void *)path);
}
else { /* cant find, print something sane */
ret = PyUnicode_FromFormat("bpy.data.%s[%R]...%s",
- BKE_idcode_to_name_plural(GS(id->name)),
- tmp_str,
- RNA_struct_identifier(self->ptr.type));
+ BKE_idcode_to_name_plural(GS(id->name)),
+ tmp_str,
+ RNA_struct_identifier(self->ptr.type));
}
}
@@ -932,10 +932,10 @@ static PyObject *pyrna_prop_str(BPy_PropertyRNA *self)
if (name) {
ret = PyUnicode_FromFormat("<bpy_%.200s, %.200s.%.200s(\"%.200s\")>",
- type_fmt,
- RNA_struct_identifier(self->ptr.type),
- RNA_property_identifier(self->prop),
- name);
+ type_fmt,
+ RNA_struct_identifier(self->ptr.type),
+ RNA_property_identifier(self->prop),
+ name);
MEM_freeN((void *)name);
return ret;
}
@@ -965,23 +965,23 @@ static PyObject *pyrna_prop_repr(BPy_PropertyRNA *self)
PYRNA_PROP_CHECK_OBJ(self);
if (id == NULL)
- return pyrna_prop_str(self); /* fallback */
+ return pyrna_prop_str(self); /* fallback */
tmp_str = PyUnicode_FromString(id->name + 2);
path = RNA_path_from_ID_to_property(&self->ptr, self->prop);
if (path) {
ret = PyUnicode_FromFormat("bpy.data.%s[%R].%s",
- BKE_idcode_to_name_plural(GS(id->name)),
- tmp_str,
- path);
+ BKE_idcode_to_name_plural(GS(id->name)),
+ tmp_str,
+ path);
MEM_freeN((void *)path);
}
else { /* cant find, print something sane */
ret = PyUnicode_FromFormat("bpy.data.%s[%R]...%s",
- BKE_idcode_to_name_plural(GS(id->name)),
- tmp_str,
- RNA_property_identifier(self->prop));
+ BKE_idcode_to_name_plural(GS(id->name)),
+ tmp_str,
+ RNA_property_identifier(self->prop));
}
Py_DECREF(tmp_str);
@@ -1286,17 +1286,17 @@ static PyObject *pyrna_enum_to_py(PointerRNA *ptr, PropertyRNA *prop, int val)
/* prefer not fail silently in case of api errors, maybe disable it later */
printf("RNA Warning: Current value \"%d\" "
- "matches no enum in '%s', '%s', '%s'\n",
- val, RNA_struct_identifier(ptr->type),
- ptr_name, RNA_property_identifier(prop));
+ "matches no enum in '%s', '%s', '%s'\n",
+ val, RNA_struct_identifier(ptr->type),
+ ptr_name, RNA_property_identifier(prop));
-#if 0 // gives python decoding errors while generating docs :(
+#if 0 // gives python decoding errors while generating docs :(
char error_str[256];
BLI_snprintf(error_str, sizeof(error_str),
- "RNA Warning: Current value \"%d\" "
- "matches no enum in '%s', '%s', '%s'",
- val, RNA_struct_identifier(ptr->type),
- ptr_name, RNA_property_identifier(prop));
+ "RNA Warning: Current value \"%d\" "
+ "matches no enum in '%s', '%s', '%s'",
+ val, RNA_struct_identifier(ptr->type),
+ ptr_name, RNA_property_identifier(prop));
PyErr_Warn(PyExc_RuntimeWarning, error_str);
#endif
@@ -1331,73 +1331,73 @@ PyObject *pyrna_prop_to_py(PointerRNA *ptr, PropertyRNA *prop)
/* see if we can coorce into a python type - PropertyType */
switch (type) {
- case PROP_BOOLEAN:
- ret = PyBool_FromLong(RNA_property_boolean_get(ptr, prop));
- break;
- case PROP_INT:
- ret = PyLong_FromSsize_t((Py_ssize_t)RNA_property_int_get(ptr, prop));
- break;
- case PROP_FLOAT:
- ret = PyFloat_FromDouble(RNA_property_float_get(ptr, prop));
- break;
- case PROP_STRING:
- {
- const int subtype = RNA_property_subtype(prop);
- const char *buf;
- int buf_len;
- char buf_fixed[32];
+ case PROP_BOOLEAN:
+ ret = PyBool_FromLong(RNA_property_boolean_get(ptr, prop));
+ break;
+ case PROP_INT:
+ ret = PyLong_FromSsize_t((Py_ssize_t)RNA_property_int_get(ptr, prop));
+ break;
+ case PROP_FLOAT:
+ ret = PyFloat_FromDouble(RNA_property_float_get(ptr, prop));
+ break;
+ case PROP_STRING:
+ {
+ const int subtype = RNA_property_subtype(prop);
+ const char *buf;
+ int buf_len;
+ char buf_fixed[32];
- buf = RNA_property_string_get_alloc(ptr, prop, buf_fixed, sizeof(buf_fixed), &buf_len);
+ buf = RNA_property_string_get_alloc(ptr, prop, buf_fixed, sizeof(buf_fixed), &buf_len);
#ifdef USE_STRING_COERCE
- /* only file paths get special treatment, they may contain non utf-8 chars */
- if (subtype == PROP_BYTESTRING) {
- ret = PyBytes_FromStringAndSize(buf, buf_len);
- }
- else if (ELEM3(subtype, PROP_FILEPATH, PROP_DIRPATH, PROP_FILENAME)) {
- ret = PyC_UnicodeFromByteAndSize(buf, buf_len);
- }
- else {
- ret = PyUnicode_FromStringAndSize(buf, buf_len);
- }
+ /* only file paths get special treatment, they may contain non utf-8 chars */
+ if (subtype == PROP_BYTESTRING) {
+ ret = PyBytes_FromStringAndSize(buf, buf_len);
+ }
+ else if (ELEM3(subtype, PROP_FILEPATH, PROP_DIRPATH, PROP_FILENAME)) {
+ ret = PyC_UnicodeFromByteAndSize(buf, buf_len);
+ }
+ else {
+ ret = PyUnicode_FromStringAndSize(buf, buf_len);
+ }
#else // USE_STRING_COERCE
- if (subtype == PROP_BYTESTRING) {
- ret = PyBytes_FromStringAndSize(buf, buf_len);
- }
- else {
- ret = PyUnicode_FromStringAndSize(buf, buf_len);
- }
+ if (subtype == PROP_BYTESTRING) {
+ ret = PyBytes_FromStringAndSize(buf, buf_len);
+ }
+ else {
+ ret = PyUnicode_FromStringAndSize(buf, buf_len);
+ }
#endif // USE_STRING_COERCE
- if (buf_fixed != buf) {
- MEM_freeN((void *)buf);
+ if (buf_fixed != buf) {
+ MEM_freeN((void *)buf);
+ }
+ break;
}
- break;
- }
- case PROP_ENUM:
- {
- ret = pyrna_enum_to_py(ptr, prop, RNA_property_enum_get(ptr, prop));
- break;
- }
- case PROP_POINTER:
- {
- PointerRNA newptr;
- newptr = RNA_property_pointer_get(ptr, prop);
- if (newptr.data) {
- ret = pyrna_struct_CreatePyObject(&newptr);
+ case PROP_ENUM:
+ {
+ ret = pyrna_enum_to_py(ptr, prop, RNA_property_enum_get(ptr, prop));
+ break;
}
- else {
- ret = Py_None;
- Py_INCREF(ret);
+ case PROP_POINTER:
+ {
+ PointerRNA newptr;
+ newptr = RNA_property_pointer_get(ptr, prop);
+ if (newptr.data) {
+ ret = pyrna_struct_CreatePyObject(&newptr);
+ }
+ else {
+ ret = Py_None;
+ Py_INCREF(ret);
+ }
+ break;
}
- break;
- }
- case PROP_COLLECTION:
- ret = pyrna_prop_CreatePyObject(ptr, prop);
- break;
- default:
- PyErr_Format(PyExc_TypeError,
- "bpy_struct internal error: unknown type '%d' (pyrna_prop_to_py)", type);
- ret = NULL;
- break;
+ case PROP_COLLECTION:
+ ret = pyrna_prop_CreatePyObject(ptr, prop);
+ break;
+ default:
+ PyErr_Format(PyExc_TypeError,
+ "bpy_struct internal error: unknown type '%d' (pyrna_prop_to_py)", type);
+ ret = NULL;
+ break;
}
return ret;
@@ -1412,7 +1412,7 @@ int pyrna_pydict_to_props(PointerRNA *ptr, PyObject *kw, int all_args, const cha
const char *arg_name = NULL;
PyObject *item;
- totkw = kw ? PyDict_Size(kw):0;
+ totkw = kw ? PyDict_Size(kw) : 0;
RNA_STRUCT_BEGIN(ptr, prop) {
arg_name = RNA_property_identifier(prop);
@@ -1470,7 +1470,7 @@ int pyrna_pydict_to_props(PointerRNA *ptr, PyObject *kw, int all_args, const cha
static PyObject *pyrna_func_to_py(PointerRNA *ptr, FunctionRNA *func)
{
- BPy_FunctionRNA* pyfunc = (BPy_FunctionRNA *) PyObject_NEW(BPy_FunctionRNA, &pyrna_func_Type);
+ BPy_FunctionRNA *pyfunc = (BPy_FunctionRNA *) PyObject_NEW(BPy_FunctionRNA, &pyrna_func_Type);
pyfunc->ptr = *ptr;
pyfunc->func = func;
return (PyObject *)pyfunc;
@@ -1494,298 +1494,310 @@ static int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, void *data, PyOb
/* see if we can coorce into a python type - PropertyType */
switch (type) {
- case PROP_BOOLEAN:
- {
- int param;
- /* prefer not to have an exception here
- * however so many poll functions return None or a valid Object.
- * its a hassle to convert these into a bool before returning, */
- if (RNA_property_flag(prop) & PROP_OUTPUT)
- param = PyObject_IsTrue(value);
- else
- param = PyLong_AsLong(value);
+ case PROP_BOOLEAN:
+ {
+ int param;
+ /* prefer not to have an exception here
+ * however so many poll functions return None or a valid Object.
+ * its a hassle to convert these into a bool before returning, */
+ if (RNA_property_flag(prop) & PROP_OUTPUT)
+ param = PyObject_IsTrue(value);
+ else
+ param = PyLong_AsLong(value);
- if (param < 0) {
- PyErr_Format(PyExc_TypeError,
- "%.200s %.200s.%.200s expected True/False or 0/1, not %.200s",
- error_prefix, RNA_struct_identifier(ptr->type),
- RNA_property_identifier(prop), Py_TYPE(value)->tp_name);
- return -1;
- }
- else {
- if (data) *((int *)data)= param;
- else RNA_property_boolean_set(ptr, prop, param);
- }
- break;
- }
- case PROP_INT:
- {
- int overflow;
- long param = PyLong_AsLongAndOverflow(value, &overflow);
- if (overflow || (param > INT_MAX) || (param < INT_MIN)) {
- PyErr_Format(PyExc_ValueError,
- "%.200s %.200s.%.200s value not in 'int' range "
- "(" STRINGIFY(INT_MIN) ", " STRINGIFY(INT_MAX) ")",
- error_prefix, RNA_struct_identifier(ptr->type),
- RNA_property_identifier(prop));
- return -1;
- }
- else if (param == -1 && PyErr_Occurred()) {
- PyErr_Format(PyExc_TypeError,
- "%.200s %.200s.%.200s expected an int type, not %.200s",
- error_prefix, RNA_struct_identifier(ptr->type),
- RNA_property_identifier(prop), Py_TYPE(value)->tp_name);
- return -1;
- }
- else {
- int param_i = (int)param;
- RNA_property_int_clamp(ptr, prop, &param_i);
- if (data) *((int *)data)= param_i;
- else RNA_property_int_set(ptr, prop, param_i);
+ if (param < 0) {
+ PyErr_Format(PyExc_TypeError,
+ "%.200s %.200s.%.200s expected True/False or 0/1, not %.200s",
+ error_prefix, RNA_struct_identifier(ptr->type),
+ RNA_property_identifier(prop), Py_TYPE(value)->tp_name);
+ return -1;
+ }
+ else {
+ if (data) *((int *)data) = param;
+ else RNA_property_boolean_set(ptr, prop, param);
+ }
+ break;
}
- break;
- }
- case PROP_FLOAT:
- {
- float param = PyFloat_AsDouble(value);
- if (PyErr_Occurred()) {
- PyErr_Format(PyExc_TypeError,
- "%.200s %.200s.%.200s expected a float type, not %.200s",
- error_prefix, RNA_struct_identifier(ptr->type),
- RNA_property_identifier(prop), Py_TYPE(value)->tp_name);
- return -1;
+ case PROP_INT:
+ {
+ int overflow;
+ long param = PyLong_AsLongAndOverflow(value, &overflow);
+ if (overflow || (param > INT_MAX) || (param < INT_MIN)) {
+ PyErr_Format(PyExc_ValueError,
+ "%.200s %.200s.%.200s value not in 'int' range "
+ "(" STRINGIFY(INT_MIN) ", " STRINGIFY(INT_MAX) ")",
+ error_prefix, RNA_struct_identifier(ptr->type),
+ RNA_property_identifier(prop));
+ return -1;
+ }
+ else if (param == -1 && PyErr_Occurred()) {
+ PyErr_Format(PyExc_TypeError,
+ "%.200s %.200s.%.200s expected an int type, not %.200s",
+ error_prefix, RNA_struct_identifier(ptr->type),
+ RNA_property_identifier(prop), Py_TYPE(value)->tp_name);
+ return -1;
+ }
+ else {
+ int param_i = (int)param;
+ RNA_property_int_clamp(ptr, prop, &param_i);
+ if (data) *((int *)data) = param_i;
+ else RNA_property_int_set(ptr, prop, param_i);
+ }
+ break;
}
- else {
- RNA_property_float_clamp(ptr, prop, (float *)&param);
- if (data) *((float *)data)= param;
- else RNA_property_float_set(ptr, prop, param);
+ case PROP_FLOAT:
+ {
+ float param = PyFloat_AsDouble(value);
+ if (PyErr_Occurred()) {
+ PyErr_Format(PyExc_TypeError,
+ "%.200s %.200s.%.200s expected a float type, not %.200s",
+ error_prefix, RNA_struct_identifier(ptr->type),
+ RNA_property_identifier(prop), Py_TYPE(value)->tp_name);
+ return -1;
+ }
+ else {
+ RNA_property_float_clamp(ptr, prop, (float *)&param);
+ if (data) *((float *)data) = param;
+ else RNA_property_float_set(ptr, prop, param);
+ }
+ break;
}
- break;
- }
- case PROP_STRING:
- {
- const int subtype = RNA_property_subtype(prop);
- const char *param;
+ case PROP_STRING:
+ {
+ const int subtype = RNA_property_subtype(prop);
+ const char *param;
- if (subtype == PROP_BYTESTRING) {
+ if (subtype == PROP_BYTESTRING) {
- /* Byte String */
+ /* Byte String */
- param = PyBytes_AsString(value);
+ param = PyBytes_AsString(value);
- if (param == NULL) {
- if (PyBytes_Check(value)) {
- /* there was an error assigning a string type,
- * rather than setting a new error, prefix the existing one
- */
- PyC_Err_Format_Prefix(PyExc_TypeError,
- "%.200s %.200s.%.200s error assigning bytes",
- error_prefix, RNA_struct_identifier(ptr->type),
- RNA_property_identifier(prop));
+ if (param == NULL) {
+ if (PyBytes_Check(value)) {
+ /* there was an error assigning a string type,
+ * rather than setting a new error, prefix the existing one
+ */
+ PyC_Err_Format_Prefix(PyExc_TypeError,
+ "%.200s %.200s.%.200s error assigning bytes",
+ error_prefix, RNA_struct_identifier(ptr->type),
+ RNA_property_identifier(prop));
+ }
+ else {
+ PyErr_Format(PyExc_TypeError,
+ "%.200s %.200s.%.200s expected a bytes type, not %.200s",
+ error_prefix, RNA_struct_identifier(ptr->type),
+ RNA_property_identifier(prop), Py_TYPE(value)->tp_name);
+ }
+
+ return -1;
}
else {
- PyErr_Format(PyExc_TypeError,
- "%.200s %.200s.%.200s expected a bytes type, not %.200s",
- error_prefix, RNA_struct_identifier(ptr->type),
- RNA_property_identifier(prop), Py_TYPE(value)->tp_name);
+ /* same as unicode */
+ if (data) *((char **)data) = (char *)param; /*XXX, this is suspect but needed for function calls, need to see if theres a better way */
+ else RNA_property_string_set(ptr, prop, param);
}
-
- return -1;
}
else {
- /* same as unicode */
- if (data) *((char **)data)= (char *)param; /*XXX, this is suspect but needed for function calls, need to see if theres a better way */
- else RNA_property_string_set(ptr, prop, param);
- }
- }
- else {
- /* Unicode String */
+ /* Unicode String */
#ifdef USE_STRING_COERCE
- PyObject *value_coerce = NULL;
- if (ELEM3(subtype, PROP_FILEPATH, PROP_DIRPATH, PROP_FILENAME)) {
- /* TODO, get size */
- param = PyC_UnicodeAsByte(value, &value_coerce);
- }
- else {
- param = _PyUnicode_AsString(value);
-#ifdef WITH_INTERNATIONAL
- if (subtype == PROP_TRANSLATE) {
- param = IFACE_(param);
+ PyObject *value_coerce = NULL;
+ if (ELEM3(subtype, PROP_FILEPATH, PROP_DIRPATH, PROP_FILENAME)) {
+ /* TODO, get size */
+ param = PyC_UnicodeAsByte(value, &value_coerce);
}
+ else {
+ param = _PyUnicode_AsString(value);
+#ifdef WITH_INTERNATIONAL
+ if (subtype == PROP_TRANSLATE) {
+ param = IFACE_(param);
+ }
#endif // WITH_INTERNATIONAL
- }
+ }
#else // USE_STRING_COERCE
- param = _PyUnicode_AsString(value);
+ param = _PyUnicode_AsString(value);
#endif // USE_STRING_COERCE
- if (param == NULL) {
- if (PyUnicode_Check(value)) {
- /* there was an error assigning a string type,
- * rather than setting a new error, prefix the existing one
- */
- PyC_Err_Format_Prefix(PyExc_TypeError,
- "%.200s %.200s.%.200s error assigning string",
- error_prefix, RNA_struct_identifier(ptr->type),
- RNA_property_identifier(prop));
+ if (param == NULL) {
+ if (PyUnicode_Check(value)) {
+ /* there was an error assigning a string type,
+ * rather than setting a new error, prefix the existing one
+ */
+ PyC_Err_Format_Prefix(PyExc_TypeError,
+ "%.200s %.200s.%.200s error assigning string",
+ error_prefix, RNA_struct_identifier(ptr->type),
+ RNA_property_identifier(prop));
+ }
+ else {
+ PyErr_Format(PyExc_TypeError,
+ "%.200s %.200s.%.200s expected a string type, not %.200s",
+ error_prefix, RNA_struct_identifier(ptr->type),
+ RNA_property_identifier(prop), Py_TYPE(value)->tp_name);
+ }
+
+ return -1;
}
else {
- PyErr_Format(PyExc_TypeError,
- "%.200s %.200s.%.200s expected a string type, not %.200s",
- error_prefix, RNA_struct_identifier(ptr->type),
- RNA_property_identifier(prop), Py_TYPE(value)->tp_name);
+ /* same as bytes */
+ if (data) *((char **)data) = (char *)param; /*XXX, this is suspect but needed for function calls, need to see if theres a better way */
+ else RNA_property_string_set(ptr, prop, param);
}
-
- return -1;
- }
- else {
- /* same as bytes */
- if (data) *((char **)data)= (char *)param; /*XXX, this is suspect but needed for function calls, need to see if theres a better way */
- else RNA_property_string_set(ptr, prop, param);
- }
#ifdef USE_STRING_COERCE
- Py_XDECREF(value_coerce);
+ Py_XDECREF(value_coerce);
#endif // USE_STRING_COERCE
+ }
+ break;
}
- break;
- }
- case PROP_ENUM:
- {
- int val = 0;
+ case PROP_ENUM:
+ {
+ int val = 0;
- /* type checkins is done by each function */
- if (RNA_property_flag(prop) & PROP_ENUM_FLAG) {
- /* set of enum items, concatenate all values with OR */
- if (pyrna_prop_to_enum_bitfield(ptr, prop, value, &val, error_prefix) < 0) {
- return -1;
+ /* type checkins is done by each function */
+ if (RNA_property_flag(prop) & PROP_ENUM_FLAG) {
+ /* set of enum items, concatenate all values with OR */
+ if (pyrna_prop_to_enum_bitfield(ptr, prop, value, &val, error_prefix) < 0) {
+ return -1;
+ }
}
- }
- else {
- /* simple enum string */
- if (pyrna_string_to_enum(value, ptr, prop, &val, error_prefix) < 0) {
- return -1;
+ else {
+ /* simple enum string */
+ if (pyrna_string_to_enum(value, ptr, prop, &val, error_prefix) < 0) {
+ return -1;
+ }
}
- }
-
- if (data) *((int *)data)= val;
- else RNA_property_enum_set(ptr, prop, val);
-
- break;
- }
- case PROP_POINTER:
- {
- PyObject *value_new = NULL;
- StructRNA *ptr_type = RNA_property_pointer_type(ptr, prop);
- int flag = RNA_property_flag(prop);
+ if (data) *((int *)data) = val;
+ else RNA_property_enum_set(ptr, prop, val);
- /* this is really nasty!, so we can fake the operator having direct properties eg:
- * layout.prop(self, "filepath")
- * ... which infact should be
- * layout.prop(self.properties, "filepath")
- *
- * we need to do this trick.
- * if the prop is not an operator type and the pyobject is an operator,
- * use its properties in place of its self.
- *
- * this is so bad that its almost a good reason to do away with fake 'self.properties -> self' class mixing
- * if this causes problems in the future it should be removed.
- */
- if ((ptr_type == &RNA_AnyType) &&
- (BPy_StructRNA_Check(value)) &&
- (RNA_struct_is_a(((BPy_StructRNA *)value)->ptr.type, &RNA_Operator)))
- {
- value = PyObject_GetAttrString(value, "properties");
- value_new = value;
+ break;
}
+ case PROP_POINTER:
+ {
+ PyObject *value_new = NULL;
+
+ StructRNA *ptr_type = RNA_property_pointer_type(ptr, prop);
+ int flag = RNA_property_flag(prop);
+
+ /* this is really nasty!, so we can fake the operator having direct properties eg:
+ * layout.prop(self, "filepath")
+ * ... which infact should be
+ * layout.prop(self.properties, "filepath")
+ *
+ * we need to do this trick.
+ * if the prop is not an operator type and the pyobject is an operator,
+ * use its properties in place of its self.
+ *
+ * this is so bad that its almost a good reason to do away with fake 'self.properties -> self' class mixing
+ * if this causes problems in the future it should be removed.
+ */
+ if ((ptr_type == &RNA_AnyType) &&
+ (BPy_StructRNA_Check(value)) &&
+ (RNA_struct_is_a(((BPy_StructRNA *)value)->ptr.type, &RNA_Operator)))
+ {
+ value = PyObject_GetAttrString(value, "properties");
+ value_new = value;
+ }
- /* if property is an OperatorProperties pointer and value is a map,
- * forward back to pyrna_pydict_to_props */
- if (RNA_struct_is_a(ptr_type, &RNA_OperatorProperties) && PyDict_Check(value)) {
- PointerRNA opptr = RNA_property_pointer_get(ptr, prop);
- return pyrna_pydict_to_props(&opptr, value, 0, error_prefix);
- }
+ /* if property is an OperatorProperties pointer and value is a map,
+ * forward back to pyrna_pydict_to_props */
+ if (RNA_struct_is_a(ptr_type, &RNA_OperatorProperties) && PyDict_Check(value)) {
+ PointerRNA opptr = RNA_property_pointer_get(ptr, prop);
+ return pyrna_pydict_to_props(&opptr, value, 0, error_prefix);
+ }
- /* another exception, allow to pass a collection as an RNA property */
- if (Py_TYPE(value) == &pyrna_prop_collection_Type) { /* ok to ignore idprop collections */
- PointerRNA c_ptr;
- BPy_PropertyRNA *value_prop = (BPy_PropertyRNA *)value;
- if (RNA_property_collection_type_get(&value_prop->ptr, value_prop->prop, &c_ptr)) {
- value = pyrna_struct_CreatePyObject(&c_ptr);
- value_new = value;
+ /* another exception, allow to pass a collection as an RNA property */
+ if (Py_TYPE(value) == &pyrna_prop_collection_Type) { /* ok to ignore idprop collections */
+ PointerRNA c_ptr;
+ BPy_PropertyRNA *value_prop = (BPy_PropertyRNA *)value;
+ if (RNA_property_collection_type_get(&value_prop->ptr, value_prop->prop, &c_ptr)) {
+ value = pyrna_struct_CreatePyObject(&c_ptr);
+ value_new = value;
+ }
+ else {
+ PyErr_Format(PyExc_TypeError,
+ "%.200s %.200s.%.200s collection has no type, "
+ "cant be used as a %.200s type",
+ error_prefix, RNA_struct_identifier(ptr->type),
+ RNA_property_identifier(prop), RNA_struct_identifier(ptr_type));
+ return -1;
+ }
}
- else {
+
+ if (!BPy_StructRNA_Check(value) && value != Py_None) {
+ PyErr_Format(PyExc_TypeError,
+ "%.200s %.200s.%.200s expected a %.200s type, not %.200s",
+ error_prefix, RNA_struct_identifier(ptr->type),
+ RNA_property_identifier(prop), RNA_struct_identifier(ptr_type),
+ Py_TYPE(value)->tp_name);
+ Py_XDECREF(value_new); return -1;
+ }
+ else if ((flag & PROP_NEVER_NULL) && value == Py_None) {
PyErr_Format(PyExc_TypeError,
- "%.200s %.200s.%.200s collection has no type, "
- "cant be used as a %.200s type",
+ "%.200s %.200s.%.200s does not support a 'None' assignment %.200s type",
error_prefix, RNA_struct_identifier(ptr->type),
RNA_property_identifier(prop), RNA_struct_identifier(ptr_type));
- return -1;
+ Py_XDECREF(value_new); return -1;
}
- }
-
- if (!BPy_StructRNA_Check(value) && value != Py_None) {
- PyErr_Format(PyExc_TypeError,
- "%.200s %.200s.%.200s expected a %.200s type, not %.200s",
- error_prefix, RNA_struct_identifier(ptr->type),
- RNA_property_identifier(prop), RNA_struct_identifier(ptr_type),
- Py_TYPE(value)->tp_name);
- Py_XDECREF(value_new); return -1;
- }
- else if ((flag & PROP_NEVER_NULL) && value == Py_None) {
- PyErr_Format(PyExc_TypeError,
- "%.200s %.200s.%.200s does not support a 'None' assignment %.200s type",
- error_prefix, RNA_struct_identifier(ptr->type),
- RNA_property_identifier(prop), RNA_struct_identifier(ptr_type));
- Py_XDECREF(value_new); return -1;
- }
- else if ((value != Py_None) &&
- ((flag & PROP_ID_SELF_CHECK) && ptr->id.data == ((BPy_StructRNA *)value)->ptr.id.data))
- {
- PyErr_Format(PyExc_TypeError,
- "%.200s %.200s.%.200s ID type does not support assignment to its self",
- error_prefix, RNA_struct_identifier(ptr->type),
- RNA_property_identifier(prop));
- Py_XDECREF(value_new); return -1;
- }
- else {
- BPy_StructRNA *param = (BPy_StructRNA *)value;
- int raise_error = FALSE;
- if (data) {
-
- if (flag & PROP_RNAPTR) {
- if (value == Py_None)
- memset(data, 0, sizeof(PointerRNA));
- else
- *((PointerRNA *)data)= param->ptr;
- }
- else if (value == Py_None) {
- *((void **)data)= NULL;
- }
- else if (RNA_struct_is_a(param->ptr.type, ptr_type)) {
- *((void **)data)= param->ptr.data;
- }
- else {
- raise_error = TRUE;
- }
+ else if ((value != Py_None) &&
+ ((flag & PROP_ID_SELF_CHECK) && ptr->id.data == ((BPy_StructRNA *)value)->ptr.id.data))
+ {
+ PyErr_Format(PyExc_TypeError,
+ "%.200s %.200s.%.200s ID type does not support assignment to its self",
+ error_prefix, RNA_struct_identifier(ptr->type),
+ RNA_property_identifier(prop));
+ Py_XDECREF(value_new); return -1;
}
else {
- /* data == NULL, assign to RNA */
- if (value == Py_None) {
- PointerRNA valueptr = {{NULL}};
- RNA_property_pointer_set(ptr, prop, valueptr);
- }
- else if (RNA_struct_is_a(param->ptr.type, ptr_type)) {
- RNA_property_pointer_set(ptr, prop, param->ptr);
+ BPy_StructRNA *param = (BPy_StructRNA *)value;
+ int raise_error = FALSE;
+ if (data) {
+
+ if (flag & PROP_RNAPTR) {
+ if (value == Py_None)
+ memset(data, 0, sizeof(PointerRNA));
+ else
+ *((PointerRNA *)data) = param->ptr;
+ }
+ else if (value == Py_None) {
+ *((void **)data) = NULL;
+ }
+ else if (RNA_struct_is_a(param->ptr.type, ptr_type)) {
+ *((void **)data) = param->ptr.data;
+ }
+ else {
+ raise_error = TRUE;
+ }
}
else {
+ /* data == NULL, assign to RNA */
+ if (value == Py_None) {
+ PointerRNA valueptr = {{NULL}};
+ RNA_property_pointer_set(ptr, prop, valueptr);
+ }
+ else if (RNA_struct_is_a(param->ptr.type, ptr_type)) {
+ RNA_property_pointer_set(ptr, prop, param->ptr);
+ }
+ else {
+ PointerRNA tmp;
+ RNA_pointer_create(NULL, ptr_type, NULL, &tmp);
+ PyErr_Format(PyExc_TypeError,
+ "%.200s %.200s.%.200s expected a %.200s type. not %.200s",
+ error_prefix, RNA_struct_identifier(ptr->type),
+ RNA_property_identifier(prop), RNA_struct_identifier(tmp.type),
+ RNA_struct_identifier(param->ptr.type));
+ Py_XDECREF(value_new); return -1;
+ }
+ }
+
+ if (raise_error) {
PointerRNA tmp;
RNA_pointer_create(NULL, ptr_type, NULL, &tmp);
PyErr_Format(PyExc_TypeError,
- "%.200s %.200s.%.200s expected a %.200s type. not %.200s",
+ "%.200s %.200s.%.200s expected a %.200s type, not %.200s",
error_prefix, RNA_struct_identifier(ptr->type),
RNA_property_identifier(prop), RNA_struct_identifier(tmp.type),
RNA_struct_identifier(param->ptr.type));
@@ -1793,98 +1805,86 @@ static int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, void *data, PyOb
}
}
- if (raise_error) {
- PointerRNA tmp;
- RNA_pointer_create(NULL, ptr_type, NULL, &tmp);
- PyErr_Format(PyExc_TypeError,
- "%.200s %.200s.%.200s expected a %.200s type, not %.200s",
- error_prefix, RNA_struct_identifier(ptr->type),
- RNA_property_identifier(prop), RNA_struct_identifier(tmp.type),
- RNA_struct_identifier(param->ptr.type));
- Py_XDECREF(value_new); return -1;
- }
- }
+ Py_XDECREF(value_new);
- Py_XDECREF(value_new);
-
- break;
- }
- case PROP_COLLECTION:
- {
- Py_ssize_t seq_len, i;
- PyObject *item;
- PointerRNA itemptr;
- ListBase *lb;
- CollectionPointerLink *link;
-
- lb = (data) ? (ListBase *)data : NULL;
-
- /* convert a sequence of dict's into a collection */
- if (!PySequence_Check(value)) {
- PyErr_Format(PyExc_TypeError,
- "%.200s %.200s.%.200s expected a sequence for an RNA collection, not %.200s",
- error_prefix, RNA_struct_identifier(ptr->type),
- RNA_property_identifier(prop), Py_TYPE(value)->tp_name);
- return -1;
+ break;
}
+ case PROP_COLLECTION:
+ {
+ Py_ssize_t seq_len, i;
+ PyObject *item;
+ PointerRNA itemptr;
+ ListBase *lb;
+ CollectionPointerLink *link;
- seq_len = PySequence_Size(value);
- for (i = 0; i < seq_len; i++) {
- item = PySequence_GetItem(value, i);
+ lb = (data) ? (ListBase *)data : NULL;
- if (item == NULL) {
+ /* convert a sequence of dict's into a collection */
+ if (!PySequence_Check(value)) {
PyErr_Format(PyExc_TypeError,
- "%.200s %.200s.%.200s failed to get sequence index '%d' for an RNA collection",
+ "%.200s %.200s.%.200s expected a sequence for an RNA collection, not %.200s",
error_prefix, RNA_struct_identifier(ptr->type),
- RNA_property_identifier(prop), i);
- Py_XDECREF(item);
+ RNA_property_identifier(prop), Py_TYPE(value)->tp_name);
return -1;
}
- if (PyDict_Check(item) == 0) {
- PyErr_Format(PyExc_TypeError,
- "%.200s %.200s.%.200s expected a each sequence "
- "member to be a dict for an RNA collection, not %.200s",
- error_prefix, RNA_struct_identifier(ptr->type),
- RNA_property_identifier(prop), Py_TYPE(item)->tp_name);
- Py_XDECREF(item);
- return -1;
- }
+ seq_len = PySequence_Size(value);
+ for (i = 0; i < seq_len; i++) {
+ item = PySequence_GetItem(value, i);
- if (lb) {
- link = MEM_callocN(sizeof(CollectionPointerLink), "PyCollectionPointerLink");
- link->ptr = itemptr;
- BLI_addtail(lb, link);
- }
- else
- RNA_property_collection_add(ptr, prop, &itemptr);
+ if (item == NULL) {
+ PyErr_Format(PyExc_TypeError,
+ "%.200s %.200s.%.200s failed to get sequence index '%d' for an RNA collection",
+ error_prefix, RNA_struct_identifier(ptr->type),
+ RNA_property_identifier(prop), i);
+ Py_XDECREF(item);
+ return -1;
+ }
+
+ if (PyDict_Check(item) == 0) {
+ PyErr_Format(PyExc_TypeError,
+ "%.200s %.200s.%.200s expected a each sequence "
+ "member to be a dict for an RNA collection, not %.200s",
+ error_prefix, RNA_struct_identifier(ptr->type),
+ RNA_property_identifier(prop), Py_TYPE(item)->tp_name);
+ Py_XDECREF(item);
+ return -1;
+ }
- if (pyrna_pydict_to_props(&itemptr, item, 1, "Converting a python list to an RNA collection") == -1) {
- PyObject *msg = PyC_ExceptionBuffer();
- const char *msg_char = _PyUnicode_AsString(msg);
+ if (lb) {
+ link = MEM_callocN(sizeof(CollectionPointerLink), "PyCollectionPointerLink");
+ link->ptr = itemptr;
+ BLI_addtail(lb, link);
+ }
+ else
+ RNA_property_collection_add(ptr, prop, &itemptr);
- PyErr_Format(PyExc_TypeError,
- "%.200s %.200s.%.200s error converting a member of a collection "
- "from a dicts into an RNA collection, failed with: %s",
- error_prefix, RNA_struct_identifier(ptr->type),
- RNA_property_identifier(prop), msg_char);
+ if (pyrna_pydict_to_props(&itemptr, item, 1, "Converting a python list to an RNA collection") == -1) {
+ PyObject *msg = PyC_ExceptionBuffer();
+ const char *msg_char = _PyUnicode_AsString(msg);
+ PyErr_Format(PyExc_TypeError,
+ "%.200s %.200s.%.200s error converting a member of a collection "
+ "from a dicts into an RNA collection, failed with: %s",
+ error_prefix, RNA_struct_identifier(ptr->type),
+ RNA_property_identifier(prop), msg_char);
+
+ Py_DECREF(item);
+ Py_DECREF(msg);
+ return -1;
+ }
Py_DECREF(item);
- Py_DECREF(msg);
- return -1;
}
- Py_DECREF(item);
- }
- break;
- }
- default:
- PyErr_Format(PyExc_AttributeError,
- "%.200s %.200s.%.200s unknown property type (pyrna_py_to_prop)",
- error_prefix, RNA_struct_identifier(ptr->type),
- RNA_property_identifier(prop));
- return -1;
- break;
+ break;
+ }
+ default:
+ PyErr_Format(PyExc_AttributeError,
+ "%.200s %.200s.%.200s unknown property type (pyrna_py_to_prop)",
+ error_prefix, RNA_struct_identifier(ptr->type),
+ RNA_property_identifier(prop));
+ return -1;
+ break;
}
}
@@ -1920,7 +1920,7 @@ static int pyrna_py_to_prop_array_index(BPy_PropertyArrayRNA *self, int index, P
else {
/* see if we can coerce into a python type - PropertyType */
switch (RNA_property_type(prop)) {
- case PROP_BOOLEAN:
+ case PROP_BOOLEAN:
{
int param = PyLong_AsLong(value);
@@ -1933,7 +1933,7 @@ static int pyrna_py_to_prop_array_index(BPy_PropertyArrayRNA *self, int index, P
}
break;
}
- case PROP_INT:
+ case PROP_INT:
{
int param = PyLong_AsLong(value);
if (param == -1 && PyErr_Occurred()) {
@@ -1946,7 +1946,7 @@ static int pyrna_py_to_prop_array_index(BPy_PropertyArrayRNA *self, int index, P
}
break;
}
- case PROP_FLOAT:
+ case PROP_FLOAT:
{
float param = PyFloat_AsDouble(value);
if (PyErr_Occurred()) {
@@ -1959,10 +1959,10 @@ static int pyrna_py_to_prop_array_index(BPy_PropertyArrayRNA *self, int index, P
}
break;
}
- default:
- PyErr_SetString(PyExc_AttributeError, "not an array type");
- ret = -1;
- break;
+ default:
+ PyErr_SetString(PyExc_AttributeError, "not an array type");
+ ret = -1;
+ break;
}
}
@@ -2172,9 +2172,9 @@ int pyrna_prop_collection_subscript_str_lib_pair_ptr(BPy_PropertyRNA *self, PyOb
if (lib == NULL) {
if (err_not_found) {
PyErr_Format(PyExc_KeyError,
- "%s: lib name '%.240s' "
- "does not reference a valid library",
- err_prefix, keylib_str);
+ "%s: lib name '%.240s' "
+ "does not reference a valid library",
+ err_prefix, keylib_str);
return -1;
}
else {
@@ -2300,7 +2300,7 @@ static PyObject *pyrna_prop_array_subscript_slice(BPy_PropertyArrayRNA *self, Po
}
else {
switch (RNA_property_type(prop)) {
- case PROP_FLOAT:
+ case PROP_FLOAT:
{
float values_stack[PYRNA_STACK_ARRAY];
float *values;
@@ -2309,30 +2309,30 @@ static PyObject *pyrna_prop_array_subscript_slice(BPy_PropertyArrayRNA *self, Po
RNA_property_float_get_array(ptr, prop, values);
for (count = start; count < stop; count++)
- PyTuple_SET_ITEM(tuple, count-start, PyFloat_FromDouble(values[count]));
+ PyTuple_SET_ITEM(tuple, count - start, PyFloat_FromDouble(values[count]));
if (values != values_stack) {
PyMem_FREE(values);
}
break;
}
- case PROP_BOOLEAN:
+ case PROP_BOOLEAN:
{
int values_stack[PYRNA_STACK_ARRAY];
int *values;
- if (length > PYRNA_STACK_ARRAY) { values = PyMem_MALLOC(sizeof(int) * length); }
+ if (length > PYRNA_STACK_ARRAY) { values = PyMem_MALLOC(sizeof(int) * length); }
else { values = values_stack; }
RNA_property_boolean_get_array(ptr, prop, values);
for (count = start; count < stop; count++)
- PyTuple_SET_ITEM(tuple, count-start, PyBool_FromLong(values[count]));
+ PyTuple_SET_ITEM(tuple, count - start, PyBool_FromLong(values[count]));
if (values != values_stack) {
PyMem_FREE(values);
}
break;
}
- case PROP_INT:
+ case PROP_INT:
{
int values_stack[PYRNA_STACK_ARRAY];
int *values;
@@ -2341,19 +2341,19 @@ static PyObject *pyrna_prop_array_subscript_slice(BPy_PropertyArrayRNA *self, Po
RNA_property_int_get_array(ptr, prop, values);
for (count = start; count < stop; count++)
- PyTuple_SET_ITEM(tuple, count-start, PyLong_FromSsize_t(values[count]));
+ PyTuple_SET_ITEM(tuple, count - start, PyLong_FromSsize_t(values[count]));
if (values != values_stack) {
PyMem_FREE(values);
}
break;
}
- default:
- BLI_assert(!"Invalid array type");
+ default:
+ BLI_assert(!"Invalid array type");
- PyErr_SetString(PyExc_TypeError, "not an array type");
- Py_DECREF(tuple);
- tuple = NULL;
+ PyErr_SetString(PyExc_TypeError, "not an array type");
+ Py_DECREF(tuple);
+ tuple = NULL;
}
}
return tuple;
@@ -2392,7 +2392,7 @@ static PyObject *pyrna_prop_collection_subscript(BPy_PropertyRNA *self, PyObject
/* avoid PySlice_GetIndicesEx because it needs to know the length ahead of time. */
if (key_slice->start != Py_None && !_PyEval_SliceIndex(key_slice->start, &start)) return NULL;
- if (key_slice->stop != Py_None && !_PyEval_SliceIndex(key_slice->stop, &stop)) return NULL;
+ if (key_slice->stop != Py_None && !_PyEval_SliceIndex(key_slice->stop, &stop)) return NULL;
if (start < 0 || stop < 0) {
/* only get the length for negative values */
@@ -2517,8 +2517,8 @@ static int pyrna_prop_collection_ass_subscript(BPy_PropertyRNA *self, PyObject *
Py_ssize_t start = 0, stop = PY_SSIZE_T_MAX;
/* avoid PySlice_GetIndicesEx because it needs to know the length ahead of time. */
- if (key_slice->start != Py_None && !_PyEval_SliceIndex(key_slice->start, &start)) return NULL;
- if (key_slice->stop != Py_None && !_PyEval_SliceIndex(key_slice->stop, &stop)) return NULL;
+ if (key_slice->start != Py_None && !_PyEval_SliceIndex(key_slice->start, &start)) return NULL;
+ if (key_slice->stop != Py_None && !_PyEval_SliceIndex(key_slice->stop, &stop)) return NULL;
if (start < 0 || stop < 0) {
/* only get the length for negative values */
@@ -2618,7 +2618,7 @@ static int prop_subscript_ass_array_slice(PointerRNA *ptr, PropertyRNA *prop,
return -1;
}
- if (PySequence_Fast_GET_SIZE(value) != stop-start) {
+ if (PySequence_Fast_GET_SIZE(value) != stop - start) {
Py_DECREF(value);
PyErr_SetString(PyExc_TypeError,
"bpy_prop_array[slice] = value: re-sizing bpy_struct arrays isn't supported");
@@ -2674,14 +2674,14 @@ static int prop_subscript_ass_array_slice(PointerRNA *ptr, PropertyRNA *prop,
int min, max;
RNA_property_int_range(ptr, prop, &min, &max);
- if (length > PYRNA_STACK_ARRAY) { values = values_alloc = PyMem_MALLOC(sizeof(int) * length); }
+ if (length > PYRNA_STACK_ARRAY) { values = values_alloc = PyMem_MALLOC(sizeof(int) * length); }
else { values = values_stack; }
if (start != 0 || stop != length) /* partial assignment? - need to get the array */
RNA_property_int_get_array(ptr, prop, values);
for (count = start; count < stop; count++) {
- ival = PyLong_AsLong(PySequence_Fast_GET_ITEM(value, count-start));
+ ival = PyLong_AsLong(PySequence_Fast_GET_ITEM(value, count - start));
CLAMP(ival, min, max);
values[count] = ival;
}
@@ -2780,15 +2780,15 @@ static int pyrna_prop_array_ass_subscript(BPy_PropertyArrayRNA *self, PyObject *
/* for slice only */
static PyMappingMethods pyrna_prop_array_as_mapping = {
- (lenfunc) pyrna_prop_array_length, /* mp_length */
- (binaryfunc) pyrna_prop_array_subscript, /* mp_subscript */
- (objobjargproc) pyrna_prop_array_ass_subscript, /* mp_ass_subscript */
+ (lenfunc) pyrna_prop_array_length, /* mp_length */
+ (binaryfunc) pyrna_prop_array_subscript, /* mp_subscript */
+ (objobjargproc) pyrna_prop_array_ass_subscript, /* mp_ass_subscript */
};
static PyMappingMethods pyrna_prop_collection_as_mapping = {
- (lenfunc) pyrna_prop_collection_length, /* mp_length */
- (binaryfunc) pyrna_prop_collection_subscript, /* mp_subscript */
- (objobjargproc) pyrna_prop_collection_ass_subscript, /* mp_ass_subscript */
+ (lenfunc) pyrna_prop_collection_length, /* mp_length */
+ (binaryfunc) pyrna_prop_collection_subscript, /* mp_subscript */
+ (objobjargproc) pyrna_prop_collection_ass_subscript, /* mp_ass_subscript */
};
/* only for fast bool's, large structs, assign nb_bool on init */
@@ -2871,44 +2871,44 @@ static int pyrna_struct_contains(BPy_StructRNA *self, PyObject *value)
if (!group)
return 0;
- return IDP_GetPropertyFromGroup(group, name) ? 1:0;
+ return IDP_GetPropertyFromGroup(group, name) ? 1 : 0;
}
static PySequenceMethods pyrna_prop_array_as_sequence = {
- (lenfunc)pyrna_prop_array_length, /* Cant set the len otherwise it can evaluate as false */
- NULL, /* sq_concat */
- NULL, /* sq_repeat */
+ (lenfunc)pyrna_prop_array_length, /* Cant set the len otherwise it can evaluate as false */
+ NULL, /* sq_concat */
+ NULL, /* sq_repeat */
(ssizeargfunc)pyrna_prop_array_subscript_int, /* sq_item */ /* Only set this so PySequence_Check() returns True */
- NULL, /* sq_slice */
- (ssizeobjargproc)prop_subscript_ass_array_int, /* sq_ass_item */
- NULL, /* *was* sq_ass_slice */
- (objobjproc)pyrna_prop_array_contains, /* sq_contains */
+ NULL, /* sq_slice */
+ (ssizeobjargproc)prop_subscript_ass_array_int, /* sq_ass_item */
+ NULL, /* *was* sq_ass_slice */
+ (objobjproc)pyrna_prop_array_contains, /* sq_contains */
(binaryfunc) NULL, /* sq_inplace_concat */
(ssizeargfunc) NULL, /* sq_inplace_repeat */
};
static PySequenceMethods pyrna_prop_collection_as_sequence = {
- (lenfunc)pyrna_prop_collection_length, /* Cant set the len otherwise it can evaluate as false */
- NULL, /* sq_concat */
- NULL, /* sq_repeat */
+ (lenfunc)pyrna_prop_collection_length, /* Cant set the len otherwise it can evaluate as false */
+ NULL, /* sq_concat */
+ NULL, /* sq_repeat */
(ssizeargfunc)pyrna_prop_collection_subscript_int, /* sq_item */ /* Only set this so PySequence_Check() returns True */
- NULL, /* *was* sq_slice */
+ NULL, /* *was* sq_slice */
(ssizeobjargproc)/* pyrna_prop_collection_ass_subscript_int */ NULL /* let mapping take this one */, /* sq_ass_item */
- NULL, /* *was* sq_ass_slice */
- (objobjproc)pyrna_prop_collection_contains, /* sq_contains */
+ NULL, /* *was* sq_ass_slice */
+ (objobjproc)pyrna_prop_collection_contains, /* sq_contains */
(binaryfunc) NULL, /* sq_inplace_concat */
(ssizeargfunc) NULL, /* sq_inplace_repeat */
};
static PySequenceMethods pyrna_struct_as_sequence = {
- NULL, /* Cant set the len otherwise it can evaluate as false */
- NULL, /* sq_concat */
- NULL, /* sq_repeat */
- NULL, /* sq_item */ /* Only set this so PySequence_Check() returns True */
- NULL, /* *was* sq_slice */
- NULL, /* sq_ass_item */
- NULL, /* *was* sq_ass_slice */
- (objobjproc)pyrna_struct_contains, /* sq_contains */
+ NULL, /* Cant set the len otherwise it can evaluate as false */
+ NULL, /* sq_concat */
+ NULL, /* sq_repeat */
+ NULL, /* sq_item */ /* Only set this so PySequence_Check() returns True */
+ NULL, /* *was* sq_slice */
+ NULL, /* sq_ass_item */
+ NULL, /* *was* sq_ass_slice */
+ (objobjproc)pyrna_struct_contains, /* sq_contains */
(binaryfunc) NULL, /* sq_inplace_concat */
(ssizeargfunc) NULL, /* sq_inplace_repeat */
};
@@ -2971,9 +2971,9 @@ static int pyrna_struct_ass_subscript(BPy_StructRNA *self, PyObject *key, PyObje
}
static PyMappingMethods pyrna_struct_as_mapping = {
- (lenfunc) NULL, /* mp_length */
- (binaryfunc) pyrna_struct_subscript, /* mp_subscript */
- (objobjargproc) pyrna_struct_ass_subscript, /* mp_ass_subscript */
+ (lenfunc) NULL, /* mp_length */
+ (binaryfunc) pyrna_struct_subscript, /* mp_subscript */
+ (objobjargproc) pyrna_struct_ass_subscript, /* mp_ass_subscript */
};
PyDoc_STRVAR(pyrna_struct_keys_doc,
@@ -3463,16 +3463,16 @@ static PyObject *pyrna_struct_getattro(BPy_StructRNA *self, PyObject *pyname)
if (done == 1) { /* found */
switch (newtype) {
- case CTX_DATA_TYPE_POINTER:
- if (newptr.data == NULL) {
- ret = Py_None;
- Py_INCREF(ret);
- }
- else {
- ret = pyrna_struct_CreatePyObject(&newptr);
- }
- break;
- case CTX_DATA_TYPE_COLLECTION:
+ case CTX_DATA_TYPE_POINTER:
+ if (newptr.data == NULL) {
+ ret = Py_None;
+ Py_INCREF(ret);
+ }
+ else {
+ ret = pyrna_struct_CreatePyObject(&newptr);
+ }
+ break;
+ case CTX_DATA_TYPE_COLLECTION:
{
CollectionPointerLink *link;
PyObject *linkptr;
@@ -3486,14 +3486,14 @@ static PyObject *pyrna_struct_getattro(BPy_StructRNA *self, PyObject *pyname)
}
}
break;
- default:
- /* should never happen */
- BLI_assert(!"Invalid context type");
-
- PyErr_Format(PyExc_AttributeError,
- "bpy_struct: Context type invalid %d, can't get \"%.200s\" from context",
- newtype, name);
- ret = NULL;
+ default:
+ /* should never happen */
+ BLI_assert(!"Invalid context type");
+
+ PyErr_Format(PyExc_AttributeError,
+ "bpy_struct: Context type invalid %d, can't get \"%.200s\" from context",
+ newtype, name);
+ ret = NULL;
}
}
else if (done == -1) { /* found but not set */
@@ -3542,10 +3542,10 @@ static int pyrna_struct_pydict_contains(PyObject *self, PyObject *pyname)
//--------------- setattr-------------------------------------------
static int pyrna_is_deferred_prop(const PyObject *value)
{
- return PyTuple_CheckExact(value) &&
- PyTuple_GET_SIZE(value) == 2 &&
- PyCFunction_Check(PyTuple_GET_ITEM(value, 0)) &&
- PyDict_CheckExact(PyTuple_GET_ITEM(value, 1));
+ return PyTuple_CheckExact(value) &&
+ PyTuple_GET_SIZE(value) == 2 &&
+ PyCFunction_Check(PyTuple_GET_ITEM(value, 0)) &&
+ PyDict_CheckExact(PyTuple_GET_ITEM(value, 1));
}
#if 0
@@ -4132,7 +4132,7 @@ static PyObject *pyrna_prop_collection_get(BPy_PropertyRNA *self, PyObject *args
}
else if (PyTuple_Check(key_ob)) {
PyObject *ret = pyrna_prop_collection_subscript_str_lib_pair(self, key_ob,
- "bpy_prop_collection.get((id, lib))", FALSE);
+ "bpy_prop_collection.get((id, lib))", FALSE);
if (ret) {
return ret;
}
@@ -4205,20 +4205,19 @@ static void foreach_attr_type(BPy_PropertyRNA *self, const char *attr,
prop = RNA_struct_find_property(&itemptr, attr);
*raw_type = RNA_property_raw_type(prop);
*attr_tot = RNA_property_array_length(&itemptr, prop);
- *attr_signed = (RNA_property_subtype(prop) == PROP_UNSIGNED) ? FALSE:TRUE;
+ *attr_signed = (RNA_property_subtype(prop) == PROP_UNSIGNED) ? FALSE : TRUE;
break;
}
RNA_PROP_END;
}
/* pyrna_prop_collection_foreach_get/set both use this */
-static int foreach_parse_args(
- BPy_PropertyRNA *self, PyObject *args,
+static int foreach_parse_args(BPy_PropertyRNA *self, PyObject *args,
- /* values to assign */
- const char **attr, PyObject **seq, int *tot, int *size,
- RawPropertyType *raw_type, int *attr_tot, int *attr_signed
- )
+ /* values to assign */
+ const char **attr, PyObject **seq, int *tot, int *size,
+ RawPropertyType *raw_type, int *attr_tot, int *attr_signed
+ )
{
#if 0
int array_tot;
@@ -4239,7 +4238,7 @@ static int foreach_parse_args(
foreach_attr_type(self, *attr, raw_type, attr_tot, attr_signed);
*size = RNA_raw_type_sizeof(*raw_type);
-#if 0 // works fine but not strictly needed, we could allow RNA_property_collection_raw_* to do the checks
+#if 0 // works fine but not strictly needed, we could allow RNA_property_collection_raw_* to do the checks
if ((*attr_tot) < 1)
*attr_tot = 1;
@@ -4272,22 +4271,22 @@ static int foreach_parse_args(
static int foreach_compat_buffer(RawPropertyType raw_type, int attr_signed, const char *format)
{
- char f = format ? *format:'B'; /* B is assumed when not set */
+ char f = format ? *format : 'B'; /* B is assumed when not set */
switch (raw_type) {
case PROP_RAW_CHAR:
- if (attr_signed) return (f == 'b') ? 1:0;
- else return (f == 'B') ? 1:0;
+ if (attr_signed) return (f == 'b') ? 1 : 0;
+ else return (f == 'B') ? 1 : 0;
case PROP_RAW_SHORT:
- if (attr_signed) return (f == 'h') ? 1:0;
- else return (f == 'H') ? 1:0;
+ if (attr_signed) return (f == 'h') ? 1 : 0;
+ else return (f == 'H') ? 1 : 0;
case PROP_RAW_INT:
- if (attr_signed) return (f == 'i') ? 1:0;
- else return (f == 'I') ? 1:0;
+ if (attr_signed) return (f == 'i') ? 1 : 0;
+ else return (f == 'I') ? 1 : 0;
case PROP_RAW_FLOAT:
- return (f == 'f') ? 1:0;
+ return (f == 'f') ? 1 : 0;
case PROP_RAW_DOUBLE:
- return (f == 'd') ? 1:0;
+ return (f == 'd') ? 1 : 0;
case PROP_RAW_UNSET:
return 0;
}
@@ -4389,7 +4388,7 @@ static PyObject *foreach_getset(BPy_PropertyRNA *self, PyObject *args, int set)
ok = RNA_property_collection_raw_get(NULL, &self->ptr, self->prop, attr, array, raw_type, tot);
- if (!ok) i = tot; /* skip the loop */
+ if (!ok) i = tot; /* skip the loop */
for ( ; i < tot; i++) {
@@ -4537,8 +4536,8 @@ static struct PyMethodDef pyrna_struct_methods[] = {
{"as_pointer", (PyCFunction)pyrna_struct_as_pointer, METH_NOARGS, pyrna_struct_as_pointer_doc},
/* bpy_rna_anim.c */
- {"keyframe_insert", (PyCFunction)pyrna_struct_keyframe_insert, METH_VARARGS|METH_KEYWORDS, pyrna_struct_keyframe_insert_doc},
- {"keyframe_delete", (PyCFunction)pyrna_struct_keyframe_delete, METH_VARARGS|METH_KEYWORDS, pyrna_struct_keyframe_delete_doc},
+ {"keyframe_insert", (PyCFunction)pyrna_struct_keyframe_insert, METH_VARARGS | METH_KEYWORDS, pyrna_struct_keyframe_insert_doc},
+ {"keyframe_delete", (PyCFunction)pyrna_struct_keyframe_delete, METH_VARARGS | METH_KEYWORDS, pyrna_struct_keyframe_delete_doc},
{"driver_add", (PyCFunction)pyrna_struct_driver_add, METH_VARARGS, pyrna_struct_driver_add_doc},
{"driver_remove", (PyCFunction)pyrna_struct_driver_remove, METH_VARARGS, pyrna_struct_driver_remove_doc},
@@ -4679,154 +4678,154 @@ static PyObject *pyrna_param_to_py(PointerRNA *ptr, PropertyRNA *prop, void *dat
/* kazanbas: TODO make multidim sequences here */
switch (type) {
- case PROP_BOOLEAN:
- ret = PyTuple_New(len);
- for (a = 0; a < len; a++)
- PyTuple_SET_ITEM(ret, a, PyBool_FromLong(((int *)data)[a]));
- break;
- case PROP_INT:
- ret = PyTuple_New(len);
- for (a = 0; a < len; a++)
- PyTuple_SET_ITEM(ret, a, PyLong_FromSsize_t((Py_ssize_t)((int *)data)[a]));
- break;
- case PROP_FLOAT:
- switch (RNA_property_subtype(prop)) {
+ case PROP_BOOLEAN:
+ ret = PyTuple_New(len);
+ for (a = 0; a < len; a++)
+ PyTuple_SET_ITEM(ret, a, PyBool_FromLong(((int *)data)[a]));
+ break;
+ case PROP_INT:
+ ret = PyTuple_New(len);
+ for (a = 0; a < len; a++)
+ PyTuple_SET_ITEM(ret, a, PyLong_FromSsize_t((Py_ssize_t)((int *)data)[a]));
+ break;
+ case PROP_FLOAT:
+ switch (RNA_property_subtype(prop)) {
#ifdef USE_MATHUTILS
- case PROP_ALL_VECTOR_SUBTYPES:
- ret = Vector_CreatePyObject(data, len, Py_NEW, NULL);
- break;
- case PROP_MATRIX:
- if (len == 16) {
- ret = Matrix_CreatePyObject(data, 4, 4, Py_NEW, NULL);
- break;
- }
- else if (len == 9) {
- ret = Matrix_CreatePyObject(data, 3, 3, Py_NEW, NULL);
+ case PROP_ALL_VECTOR_SUBTYPES:
+ ret = Vector_CreatePyObject(data, len, Py_NEW, NULL);
break;
- }
- /* pass through */
+ case PROP_MATRIX:
+ if (len == 16) {
+ ret = Matrix_CreatePyObject(data, 4, 4, Py_NEW, NULL);
+ break;
+ }
+ else if (len == 9) {
+ ret = Matrix_CreatePyObject(data, 3, 3, Py_NEW, NULL);
+ break;
+ }
+ /* pass through */
#endif
- default:
- ret = PyTuple_New(len);
- for (a = 0; a < len; a++)
- PyTuple_SET_ITEM(ret, a, PyFloat_FromDouble(((float *)data)[a]));
+ default:
+ ret = PyTuple_New(len);
+ for (a = 0; a < len; a++)
+ PyTuple_SET_ITEM(ret, a, PyFloat_FromDouble(((float *)data)[a]));
- }
- break;
- default:
- PyErr_Format(PyExc_TypeError,
- "RNA Error: unknown array type \"%d\" (pyrna_param_to_py)",
- type);
- ret = NULL;
- break;
+ }
+ break;
+ default:
+ PyErr_Format(PyExc_TypeError,
+ "RNA Error: unknown array type \"%d\" (pyrna_param_to_py)",
+ type);
+ ret = NULL;
+ break;
}
}
else {
/* see if we can coorce into a python type - PropertyType */
switch (type) {
- case PROP_BOOLEAN:
- ret = PyBool_FromLong(*(int *)data);
- break;
- case PROP_INT:
- ret = PyLong_FromSsize_t((Py_ssize_t)*(int *)data);
- break;
- case PROP_FLOAT:
- ret = PyFloat_FromDouble(*(float *)data);
- break;
- case PROP_STRING:
- {
- char *data_ch;
- PyObject *value_coerce = NULL;
- const int subtype = RNA_property_subtype(prop);
+ case PROP_BOOLEAN:
+ ret = PyBool_FromLong(*(int *)data);
+ break;
+ case PROP_INT:
+ ret = PyLong_FromSsize_t((Py_ssize_t)*(int *)data);
+ break;
+ case PROP_FLOAT:
+ ret = PyFloat_FromDouble(*(float *)data);
+ break;
+ case PROP_STRING:
+ {
+ char *data_ch;
+ PyObject *value_coerce = NULL;
+ const int subtype = RNA_property_subtype(prop);
- if (flag & PROP_THICK_WRAP)
- data_ch = (char *)data;
- else
- data_ch = *(char **)data;
+ if (flag & PROP_THICK_WRAP)
+ data_ch = (char *)data;
+ else
+ data_ch = *(char **)data;
#ifdef USE_STRING_COERCE
- if (subtype == PROP_BYTESTRING) {
- ret = PyBytes_FromString(data_ch);
- }
- else if (ELEM3(subtype, PROP_FILEPATH, PROP_DIRPATH, PROP_FILENAME)) {
- ret = PyC_UnicodeFromByte(data_ch);
- }
- else {
- ret = PyUnicode_FromString(data_ch);
- }
+ if (subtype == PROP_BYTESTRING) {
+ ret = PyBytes_FromString(data_ch);
+ }
+ else if (ELEM3(subtype, PROP_FILEPATH, PROP_DIRPATH, PROP_FILENAME)) {
+ ret = PyC_UnicodeFromByte(data_ch);
+ }
+ else {
+ ret = PyUnicode_FromString(data_ch);
+ }
#else
- if (subtype == PROP_BYTESTRING) {
- ret = PyBytes_FromString(buf);
- }
- else {
- ret = PyUnicode_FromString(data_ch);
- }
+ if (subtype == PROP_BYTESTRING) {
+ ret = PyBytes_FromString(buf);
+ }
+ else {
+ ret = PyUnicode_FromString(data_ch);
+ }
#endif
#ifdef USE_STRING_COERCE
- Py_XDECREF(value_coerce);
+ Py_XDECREF(value_coerce);
#endif
- break;
- }
- case PROP_ENUM:
- {
- ret = pyrna_enum_to_py(ptr, prop, *(int *)data);
- break;
- }
- case PROP_POINTER:
- {
- PointerRNA newptr;
- StructRNA *ptype = RNA_property_pointer_type(ptr, prop);
-
- if (flag & PROP_RNAPTR) {
- /* in this case we get the full ptr */
- newptr = *(PointerRNA *)data;
+ break;
}
- else {
- if (RNA_struct_is_ID(ptype)) {
- RNA_id_pointer_create(*(void **)data, &newptr);
+ case PROP_ENUM:
+ {
+ ret = pyrna_enum_to_py(ptr, prop, *(int *)data);
+ break;
+ }
+ case PROP_POINTER:
+ {
+ PointerRNA newptr;
+ StructRNA *ptype = RNA_property_pointer_type(ptr, prop);
+
+ if (flag & PROP_RNAPTR) {
+ /* in this case we get the full ptr */
+ newptr = *(PointerRNA *)data;
}
else {
- /* note: this is taken from the function's ID pointer
- * and will break if a function returns a pointer from
- * another ID block, watch this! - it should at least be
- * easy to debug since they are all ID's */
- RNA_pointer_create(ptr->id.data, ptype, *(void **)data, &newptr);
+ if (RNA_struct_is_ID(ptype)) {
+ RNA_id_pointer_create(*(void **)data, &newptr);
+ }
+ else {
+ /* note: this is taken from the function's ID pointer
+ * and will break if a function returns a pointer from
+ * another ID block, watch this! - it should at least be
+ * easy to debug since they are all ID's */
+ RNA_pointer_create(ptr->id.data, ptype, *(void **)data, &newptr);
+ }
}
- }
- if (newptr.data) {
- ret = pyrna_struct_CreatePyObject(&newptr);
- }
- else {
- ret = Py_None;
- Py_INCREF(ret);
+ if (newptr.data) {
+ ret = pyrna_struct_CreatePyObject(&newptr);
+ }
+ else {
+ ret = Py_None;
+ Py_INCREF(ret);
+ }
+ break;
}
- break;
- }
- case PROP_COLLECTION:
- {
- ListBase *lb = (ListBase *)data;
- CollectionPointerLink *link;
- PyObject *linkptr;
+ case PROP_COLLECTION:
+ {
+ ListBase *lb = (ListBase *)data;
+ CollectionPointerLink *link;
+ PyObject *linkptr;
- ret = PyList_New(0);
+ ret = PyList_New(0);
- for (link = lb->first; link; link = link->next) {
- linkptr = pyrna_struct_CreatePyObject(&link->ptr);
- PyList_Append(ret, linkptr);
- Py_DECREF(linkptr);
- }
+ for (link = lb->first; link; link = link->next) {
+ linkptr = pyrna_struct_CreatePyObject(&link->ptr);
+ PyList_Append(ret, linkptr);
+ Py_DECREF(linkptr);
+ }
- break;
- }
- default:
- PyErr_Format(PyExc_TypeError,
- "RNA Error: unknown type \"%d\" (pyrna_param_to_py)",
- type);
- ret = NULL;
- break;
+ break;
+ }
+ default:
+ PyErr_Format(PyExc_TypeError,
+ "RNA Error: unknown type \"%d\" (pyrna_param_to_py)",
+ type);
+ ret = NULL;
+ break;
}
}
@@ -4954,7 +4953,7 @@ static PyObject *pyrna_func_call(BPy_FunctionRNA *self, PyObject *args, PyObject
item = small_dict_get_item_string(kw, RNA_property_identifier(parm)); /* borrow ref */
#endif
if (item)
- kw_tot++; /* make sure invalid keywords are not given */
+ kw_tot++; /* make sure invalid keywords are not given */
kw_arg = TRUE;
}
@@ -5206,30 +5205,30 @@ PyTypeObject pyrna_struct_meta_idprop_Type = {
/* Functions to access object as input/output buffer */
NULL, /* PyBufferProcs *tp_as_buffer; */
- /*** Flags to define presence of optional/expanded features ***/
+ /*** Flags to define presence of optional/expanded features ***/
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* long tp_flags; */
NULL, /* char *tp_doc; Documentation string */
- /*** Assigned meaning in release 2.0 ***/
+ /*** Assigned meaning in release 2.0 ***/
/* call function for all accessible objects */
NULL, /* traverseproc tp_traverse; */
/* delete references to contained objects */
NULL, /* inquiry tp_clear; */
- /*** Assigned meaning in release 2.1 ***/
- /*** rich comparisons ***/
+ /*** Assigned meaning in release 2.1 ***/
+ /*** rich comparisons ***/
NULL, /* richcmpfunc tp_richcompare; */
- /*** weak reference enabler ***/
+ /*** weak reference enabler ***/
0, /* long tp_weaklistoffset; */
- /*** Added in release 2.2 ***/
+ /*** Added in release 2.2 ***/
/* Iterators */
NULL, /* getiterfunc tp_iter; */
NULL, /* iternextfunc tp_iternext; */
- /*** Attribute descriptor and subclassing stuff ***/
+ /*** Attribute descriptor and subclassing stuff ***/
NULL, /* struct PyMethodDef *tp_methods; */
NULL, /* struct PyMemberDef *tp_members; */
NULL, /* struct PyGetSetDef *tp_getset; */
@@ -5266,7 +5265,7 @@ PyTypeObject pyrna_struct_Type = {
sizeof(BPy_StructRNA), /* tp_basicsize */
0, /* tp_itemsize */
/* methods */
- (destructor) pyrna_struct_dealloc,/* tp_dealloc */
+ (destructor) pyrna_struct_dealloc, /* tp_dealloc */
NULL, /* printfunc tp_print; */
NULL, /* getattrfunc tp_getattr; */
NULL, /* setattrfunc tp_setattr; */
@@ -5290,11 +5289,11 @@ PyTypeObject pyrna_struct_Type = {
/* Functions to access object as input/output buffer */
NULL, /* PyBufferProcs *tp_as_buffer; */
- /*** Flags to define presence of optional/expanded features ***/
+ /*** Flags to define presence of optional/expanded features ***/
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, /* long tp_flags; */
NULL, /* char *tp_doc; Documentation string */
- /*** Assigned meaning in release 2.0 ***/
+ /*** Assigned meaning in release 2.0 ***/
/* call function for all accessible objects */
#ifdef USE_PYRNA_STRUCT_REFERENCE
(traverseproc) pyrna_struct_traverse, /* traverseproc tp_traverse; */
@@ -5308,22 +5307,22 @@ PyTypeObject pyrna_struct_Type = {
NULL, /* inquiry tp_clear; */
#endif /* !USE_PYRNA_STRUCT_REFERENCE */
- /*** Assigned meaning in release 2.1 ***/
- /*** rich comparisons ***/
+ /*** Assigned meaning in release 2.1 ***/
+ /*** rich comparisons ***/
(richcmpfunc)pyrna_struct_richcmp, /* richcmpfunc tp_richcompare; */
- /*** weak reference enabler ***/
+ /*** weak reference enabler ***/
#ifdef USE_WEAKREFS
offsetof(BPy_StructRNA, in_weakreflist), /* long tp_weaklistoffset; */
#else
0,
#endif
- /*** Added in release 2.2 ***/
+ /*** Added in release 2.2 ***/
/* Iterators */
NULL, /* getiterfunc tp_iter; */
NULL, /* iternextfunc tp_iternext; */
- /*** Attribute descriptor and subclassing stuff ***/
+ /*** Attribute descriptor and subclassing stuff ***/
pyrna_struct_methods, /* struct PyMethodDef *tp_methods; */
NULL, /* struct PyMemberDef *tp_members; */
pyrna_struct_getseters, /* struct PyGetSetDef *tp_getset; */
@@ -5381,37 +5380,37 @@ PyTypeObject pyrna_prop_Type = {
/* Functions to access object as input/output buffer */
NULL, /* PyBufferProcs *tp_as_buffer; */
- /*** Flags to define presence of optional/expanded features ***/
+ /*** Flags to define presence of optional/expanded features ***/
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* long tp_flags; */
NULL, /* char *tp_doc; Documentation string */
- /*** Assigned meaning in release 2.0 ***/
+ /*** Assigned meaning in release 2.0 ***/
/* call function for all accessible objects */
NULL, /* traverseproc tp_traverse; */
/* delete references to contained objects */
NULL, /* inquiry tp_clear; */
- /*** Assigned meaning in release 2.1 ***/
- /*** rich comparisons ***/
- (richcmpfunc)pyrna_prop_richcmp, /* richcmpfunc tp_richcompare; */
+ /*** Assigned meaning in release 2.1 ***/
+ /*** rich comparisons ***/
+ (richcmpfunc)pyrna_prop_richcmp, /* richcmpfunc tp_richcompare; */
- /*** weak reference enabler ***/
+ /*** weak reference enabler ***/
#ifdef USE_WEAKREFS
- offsetof(BPy_PropertyRNA, in_weakreflist), /* long tp_weaklistoffset; */
+ offsetof(BPy_PropertyRNA, in_weakreflist), /* long tp_weaklistoffset; */
#else
0,
#endif
- /*** Added in release 2.2 ***/
+ /*** Added in release 2.2 ***/
/* Iterators */
NULL, /* getiterfunc tp_iter; */
NULL, /* iternextfunc tp_iternext; */
- /*** Attribute descriptor and subclassing stuff ***/
+ /*** Attribute descriptor and subclassing stuff ***/
pyrna_prop_methods, /* struct PyMethodDef *tp_methods; */
NULL, /* struct PyMemberDef *tp_members; */
- pyrna_prop_getseters, /* struct PyGetSetDef *tp_getset; */
+ pyrna_prop_getseters, /* struct PyGetSetDef *tp_getset; */
NULL, /* struct _typeobject *tp_base; */
NULL, /* PyObject *tp_dict; */
NULL, /* descrgetfunc tp_descr_get; */
@@ -5436,7 +5435,7 @@ PyTypeObject pyrna_prop_Type = {
PyTypeObject pyrna_prop_array_Type = {
PyVarObject_HEAD_INIT(NULL, 0)
"bpy_prop_array", /* tp_name */
- sizeof(BPy_PropertyArrayRNA), /* tp_basicsize */
+ sizeof(BPy_PropertyArrayRNA), /* tp_basicsize */
0, /* tp_itemsize */
/* methods */
(destructor)pyrna_prop_array_dealloc, /* tp_dealloc */
@@ -5444,7 +5443,7 @@ PyTypeObject pyrna_prop_array_Type = {
NULL, /* getattrfunc tp_getattr; */
NULL, /* setattrfunc tp_setattr; */
NULL, /* tp_compare */ /* DEPRECATED in python 3.0! */
- NULL,/* subclassed */ /* tp_repr */
+ NULL, /* subclassed */ /* tp_repr */
/* Method suites for standard classes */
@@ -5465,33 +5464,33 @@ PyTypeObject pyrna_prop_array_Type = {
/* Functions to access object as input/output buffer */
NULL, /* PyBufferProcs *tp_as_buffer; */
- /*** Flags to define presence of optional/expanded features ***/
+ /*** Flags to define presence of optional/expanded features ***/
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* long tp_flags; */
NULL, /* char *tp_doc; Documentation string */
- /*** Assigned meaning in release 2.0 ***/
+ /*** Assigned meaning in release 2.0 ***/
/* call function for all accessible objects */
NULL, /* traverseproc tp_traverse; */
/* delete references to contained objects */
NULL, /* inquiry tp_clear; */
- /*** Assigned meaning in release 2.1 ***/
- /*** rich comparisons ***/
+ /*** Assigned meaning in release 2.1 ***/
+ /*** rich comparisons ***/
NULL, /* subclassed */ /* richcmpfunc tp_richcompare; */
- /*** weak reference enabler ***/
+ /*** weak reference enabler ***/
#ifdef USE_WEAKREFS
- offsetof(BPy_PropertyArrayRNA, in_weakreflist), /* long tp_weaklistoffset; */
+ offsetof(BPy_PropertyArrayRNA, in_weakreflist), /* long tp_weaklistoffset; */
#else
0,
#endif
- /*** Added in release 2.2 ***/
+ /*** Added in release 2.2 ***/
/* Iterators */
- (getiterfunc)pyrna_prop_array_iter, /* getiterfunc tp_iter; */
+ (getiterfunc)pyrna_prop_array_iter, /* getiterfunc tp_iter; */
NULL, /* iternextfunc tp_iternext; */
- /*** Attribute descriptor and subclassing stuff ***/
+ /*** Attribute descriptor and subclassing stuff ***/
pyrna_prop_array_methods, /* struct PyMethodDef *tp_methods; */
NULL, /* struct PyMemberDef *tp_members; */
NULL /*pyrna_prop_getseters*/, /* struct PyGetSetDef *tp_getset; */
@@ -5548,34 +5547,34 @@ PyTypeObject pyrna_prop_collection_Type = {
/* Functions to access object as input/output buffer */
NULL, /* PyBufferProcs *tp_as_buffer; */
- /*** Flags to define presence of optional/expanded features ***/
+ /*** Flags to define presence of optional/expanded features ***/
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* long tp_flags; */
NULL, /* char *tp_doc; Documentation string */
- /*** Assigned meaning in release 2.0 ***/
+ /*** Assigned meaning in release 2.0 ***/
/* call function for all accessible objects */
NULL, /* traverseproc tp_traverse; */
/* delete references to contained objects */
NULL, /* inquiry tp_clear; */
- /*** Assigned meaning in release 2.1 ***/
- /*** rich comparisons ***/
+ /*** Assigned meaning in release 2.1 ***/
+ /*** rich comparisons ***/
NULL, /* subclassed */ /* richcmpfunc tp_richcompare; */
- /*** weak reference enabler ***/
+ /*** weak reference enabler ***/
#ifdef USE_WEAKREFS
offsetof(BPy_PropertyRNA, in_weakreflist), /* long tp_weaklistoffset; */
#else
0,
#endif
- /*** Added in release 2.2 ***/
+ /*** Added in release 2.2 ***/
/* Iterators */
(getiterfunc)pyrna_prop_collection_iter, /* getiterfunc tp_iter; */
NULL, /* iternextfunc tp_iternext; */
- /*** Attribute descriptor and subclassing stuff ***/
+ /*** Attribute descriptor and subclassing stuff ***/
pyrna_prop_collection_methods, /* struct PyMethodDef *tp_methods; */
NULL, /* struct PyMemberDef *tp_members; */
NULL /*pyrna_prop_getseters*/, /* struct PyGetSetDef *tp_getset; */
@@ -5633,38 +5632,38 @@ static PyTypeObject pyrna_prop_collection_idprop_Type = {
/* Functions to access object as input/output buffer */
NULL, /* PyBufferProcs *tp_as_buffer; */
- /*** Flags to define presence of optional/expanded features ***/
+ /*** Flags to define presence of optional/expanded features ***/
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* long tp_flags; */
NULL, /* char *tp_doc; Documentation string */
- /*** Assigned meaning in release 2.0 ***/
+ /*** Assigned meaning in release 2.0 ***/
/* call function for all accessible objects */
NULL, /* traverseproc tp_traverse; */
/* delete references to contained objects */
NULL, /* inquiry tp_clear; */
- /*** Assigned meaning in release 2.1 ***/
- /*** rich comparisons ***/
+ /*** Assigned meaning in release 2.1 ***/
+ /*** rich comparisons ***/
NULL, /* subclassed */ /* richcmpfunc tp_richcompare; */
- /*** weak reference enabler ***/
+ /*** weak reference enabler ***/
#ifdef USE_WEAKREFS
offsetof(BPy_PropertyRNA, in_weakreflist), /* long tp_weaklistoffset; */
#else
0,
#endif
- /*** Added in release 2.2 ***/
+ /*** Added in release 2.2 ***/
/* Iterators */
NULL, /* getiterfunc tp_iter; */
NULL, /* iternextfunc tp_iternext; */
- /*** Attribute descriptor and subclassing stuff ***/
+ /*** Attribute descriptor and subclassing stuff ***/
pyrna_prop_collection_idprop_methods, /* struct PyMethodDef *tp_methods; */
NULL, /* struct PyMemberDef *tp_members; */
NULL /*pyrna_prop_getseters*/, /* struct PyGetSetDef *tp_getset; */
- &pyrna_prop_collection_Type,/* struct _typeobject *tp_base; */
+ &pyrna_prop_collection_Type, /* struct _typeobject *tp_base; */
NULL, /* PyObject *tp_dict; */
NULL, /* descrgetfunc tp_descr_get; */
NULL, /* descrsetfunc tp_descr_set; */
@@ -5718,34 +5717,34 @@ PyTypeObject pyrna_func_Type = {
/* Functions to access object as input/output buffer */
NULL, /* PyBufferProcs *tp_as_buffer; */
- /*** Flags to define presence of optional/expanded features ***/
+ /*** Flags to define presence of optional/expanded features ***/
Py_TPFLAGS_DEFAULT, /* long tp_flags; */
NULL, /* char *tp_doc; Documentation string */
- /*** Assigned meaning in release 2.0 ***/
+ /*** Assigned meaning in release 2.0 ***/
/* call function for all accessible objects */
NULL, /* traverseproc tp_traverse; */
/* delete references to contained objects */
NULL, /* inquiry tp_clear; */
- /*** Assigned meaning in release 2.1 ***/
- /*** rich comparisons ***/
+ /*** Assigned meaning in release 2.1 ***/
+ /*** rich comparisons ***/
NULL, /* richcmpfunc tp_richcompare; */
- /*** weak reference enabler ***/
+ /*** weak reference enabler ***/
#ifdef USE_WEAKREFS
- offsetof(BPy_PropertyRNA, in_weakreflist), /* long tp_weaklistoffset; */
+ offsetof(BPy_PropertyRNA, in_weakreflist), /* long tp_weaklistoffset; */
#else
0,
#endif
- /*** Added in release 2.2 ***/
+ /*** Added in release 2.2 ***/
/* Iterators */
NULL, /* getiterfunc tp_iter; */
NULL, /* iternextfunc tp_iternext; */
- /*** Attribute descriptor and subclassing stuff ***/
+ /*** Attribute descriptor and subclassing stuff ***/
NULL, /* struct PyMethodDef *tp_methods; */
NULL, /* struct PyMemberDef *tp_members; */
pyrna_func_getseters, /* struct PyGetSetDef *tp_getset; */
@@ -5793,7 +5792,7 @@ PyTypeObject pyrna_prop_collection_iter_Type = {
NULL, /* getattrfunc tp_getattr; */
NULL, /* setattrfunc tp_setattr; */
NULL, /* tp_compare */ /* DEPRECATED in python 3.0! */
- NULL,/* subclassed */ /* tp_repr */
+ NULL, /* subclassed */ /* tp_repr */
/* Method suites for standard classes */
@@ -5818,28 +5817,28 @@ PyTypeObject pyrna_prop_collection_iter_Type = {
/* Functions to access object as input/output buffer */
NULL, /* PyBufferProcs *tp_as_buffer; */
- /*** Flags to define presence of optional/expanded features ***/
+ /*** Flags to define presence of optional/expanded features ***/
Py_TPFLAGS_DEFAULT, /* long tp_flags; */
NULL, /* char *tp_doc; Documentation string */
- /*** Assigned meaning in release 2.0 ***/
+ /*** Assigned meaning in release 2.0 ***/
/* call function for all accessible objects */
NULL, /* traverseproc tp_traverse; */
/* delete references to contained objects */
NULL, /* inquiry tp_clear; */
- /*** Assigned meaning in release 2.1 ***/
- /*** rich comparisons ***/
+ /*** Assigned meaning in release 2.1 ***/
+ /*** rich comparisons ***/
NULL, /* subclassed */ /* richcmpfunc tp_richcompare; */
- /*** weak reference enabler ***/
+ /*** weak reference enabler ***/
#ifdef USE_WEAKREFS
offsetof(BPy_PropertyCollectionIterRNA, in_weakreflist), /* long tp_weaklistoffset; */
#else
0,
#endif
- /*** Added in release 2.2 ***/
+ /*** Added in release 2.2 ***/
/* Iterators */
#if defined(_MSC_VER) || defined(FREE_WINDOWS)
NULL, /* defer assignment */
@@ -5848,7 +5847,7 @@ PyTypeObject pyrna_prop_collection_iter_Type = {
#endif
(iternextfunc) pyrna_prop_collection_iter_next, /* iternextfunc tp_iternext; */
- /*** Attribute descriptor and subclassing stuff ***/
+ /*** Attribute descriptor and subclassing stuff ***/
NULL, /* struct PyMethodDef *tp_methods; */
NULL, /* struct PyMemberDef *tp_members; */
NULL, /* struct PyGetSetDef *tp_getset; */
@@ -5977,7 +5976,7 @@ static PyObject *pyrna_srna_PyBase(StructRNA *srna) //, PyObject *bpy_types_dict
base = RNA_struct_base(srna);
if (base && base != srna) {
- /*/printf("debug subtype %s %p\n", RNA_struct_identifier(srna), srna); */
+ /* printf("debug subtype %s %p\n", RNA_struct_identifier(srna), srna); */
py_base = pyrna_srna_Subtype(base); //, bpy_types_dict);
Py_DECREF(py_base); /* srna owns, this is only to pass as an arg */
}
@@ -6047,18 +6046,18 @@ static PyObject *pyrna_srna_Subtype(StructRNA *srna)
{
PyObject *newclass = NULL;
- /* stupid/simple case */
+ /* stupid/simple case */
if (srna == NULL) {
newclass = NULL; /* Nothing to do */
- } /* the class may have already been declared & allocated */
+ } /* the class may have already been declared & allocated */
else if ((newclass = RNA_struct_py_type_get(srna))) {
Py_INCREF(newclass);
- } /* check if bpy_types.py module has the class defined in it */
+ } /* check if bpy_types.py module has the class defined in it */
else if ((newclass = pyrna_srna_ExternalType(srna))) {
pyrna_subtype_set_rna(newclass, srna);
Py_INCREF(newclass);
- } /* create a new class instance with the C api
- * mainly for the purposing of matching the C/rna type hierarchy */
+ } /* create a new class instance with the C api
+ * mainly for the purposing of matching the C/rna type hierarchy */
else {
/* subclass equivalents
* - class myClass(myBase):
@@ -6087,7 +6086,7 @@ static PyObject *pyrna_srna_Subtype(StructRNA *srna)
/* always use O not N when calling, N causes refcount errors */
newclass = PyObject_CallFunction(metaclass, (char *)"s(O) {sss()}",
- idname, py_base, "__module__","bpy.types", "__slots__");
+ idname, py_base, "__module__", "bpy.types", "__slots__");
/* newclass will now have 2 ref's, ???, probably 1 is internal since decrefing here segfaults */
@@ -6782,24 +6781,24 @@ static int bpy_class_validate(PointerRNA *dummyptr, void *py_data, int *have_fun
/* 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); \
+ 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__");
BPY_REPLACEMENT_STRING("bl_description", "__doc__");
-#undef BPY_REPLACEMENT_STRING
+#undef BPY_REPLACEMENT_STRING
if (item == NULL && (((flag & PROP_REGISTER_OPTIONAL) != PROP_REGISTER_OPTIONAL))) {
PyErr_Format(PyExc_AttributeError,
@@ -6848,8 +6847,8 @@ static int bpy_class_call(bContext *C, PointerRNA *ptr, FunctionRNA *func, Param
const char *func_id = RNA_function_identifier(func);
/* testing, for correctness, not operator and not draw function */
const short is_readonly = ((strncmp("draw", func_id, 4) == 0) || /* draw or draw_header */
- /*strstr("render", func_id) ||*/
- !is_operator);
+ /*strstr("render", func_id) ||*/
+ !is_operator);
#endif
py_class = RNA_struct_py_type_get(ptr->type);
@@ -7001,7 +7000,7 @@ static int bpy_class_call(bContext *C, PointerRNA *ptr, FunctionRNA *func, Param
}
#ifdef USE_PEDANTIC_WRITE
- rna_disallow_writes = is_readonly ? TRUE:FALSE;
+ rna_disallow_writes = is_readonly ? TRUE : FALSE;
#endif
/* *** Main Caller *** */
@@ -7088,8 +7087,8 @@ static int bpy_class_call(bContext *C, PointerRNA *ptr, FunctionRNA *func, Param
/* only useful for single argument returns, we'll need another list loop for multiple */
if (flag & PROP_OUTPUT) {
err = pyrna_py_to_prop(&funcptr, parm, iter.data,
- PyTuple_GET_ITEM(ret, i++),
- "calling class function:");
+ PyTuple_GET_ITEM(ret, i++),
+ "calling class function:");
if (err) {
break;
}
@@ -7203,7 +7202,7 @@ void pyrna_free_types(void)
void *py_ptr = RNA_struct_py_type_get(srna);
if (py_ptr) {
-#if 0 // XXX - should be able to do this but makes python crash on exit
+#if 0 // XXX - should be able to do this but makes python crash on exit
bpy_class_free(py_ptr);
#endif
RNA_struct_py_type_set(srna, NULL);
@@ -7383,7 +7382,7 @@ PyDoc_STRVAR(pyrna_unregister_class_doc,
" before unregistering.\n"
);
PyMethodDef meth_bpy_unregister_class = {
- "unregister_class", pyrna_unregister_class, METH_O, pyrna_unregister_class_doc
+ "unregister_class", pyrna_unregister_class, METH_O, pyrna_unregister_class_doc
};
static PyObject *pyrna_unregister_class(PyObject *UNUSED(self), PyObject *py_class)
{
@@ -7482,7 +7481,7 @@ static PyObject *pyrna_unregister_class(PyObject *UNUSED(self), PyObject *py_cla
PyDict_DelItem(((PyTypeObject *)py_class)->tp_dict, bpy_intern_str_bl_rna);
if (PyErr_Occurred())
- PyErr_Clear(); //return NULL;
+ PyErr_Clear(); //return NULL;
Py_RETURN_NONE;
}
diff --git a/source/blender/python/intern/bpy_rna_anim.c b/source/blender/python/intern/bpy_rna_anim.c
index 4b4d0ff3535..b7a45897668 100644
--- a/source/blender/python/intern/bpy_rna_anim.c
+++ b/source/blender/python/intern/bpy_rna_anim.c
@@ -149,8 +149,8 @@ static int pyrna_struct_anim_args_parse(
/* internal use for insert and delete */
static int pyrna_struct_keyframe_parse(
- PointerRNA *ptr, PyObject *args, PyObject *kw, const char *parse_str, const char *error_prefix,
- const char **path_full, int *index, float *cfra, const char **group_name) /* return values */
+ PointerRNA *ptr, PyObject *args, PyObject *kw, const char *parse_str, const char *error_prefix,
+ const char **path_full, int *index, float *cfra, const char **group_name) /* return values */
{
static const char *kwlist[] = {"data_path", "index", "frame", "group", NULL};
const char *path;
@@ -195,8 +195,8 @@ PyObject *pyrna_struct_keyframe_insert(BPy_StructRNA *self, PyObject *args, PyOb
PYRNA_STRUCT_CHECK_OBJ(self);
if (pyrna_struct_keyframe_parse(&self->ptr, args, kw,
- "s|ifs:bpy_struct.keyframe_insert()", "bpy_struct.keyframe_insert()",
- &path_full, &index, &cfra, &group_name) == -1)
+ "s|ifs:bpy_struct.keyframe_insert()", "bpy_struct.keyframe_insert()",
+ &path_full, &index, &cfra, &group_name) == -1)
{
return NULL;
}
@@ -243,9 +243,9 @@ PyObject *pyrna_struct_keyframe_delete(BPy_StructRNA *self, PyObject *args, PyOb
PYRNA_STRUCT_CHECK_OBJ(self);
if (pyrna_struct_keyframe_parse(&self->ptr, args, kw,
- "s|ifs:bpy_struct.keyframe_delete()",
- "bpy_struct.keyframe_insert()",
- &path_full, &index, &cfra, &group_name) == -1)
+ "s|ifs:bpy_struct.keyframe_delete()",
+ "bpy_struct.keyframe_insert()",
+ &path_full, &index, &cfra, &group_name) == -1)
{
return NULL;
}
@@ -327,7 +327,7 @@ PyObject *pyrna_struct_driver_add(BPy_StructRNA *self, PyObject *args)
ret = pyrna_struct_CreatePyObject(&tptr);
}
- WM_event_add_notifier(BPy_GetContext(), NC_ANIMATION|ND_FCURVES_ORDER, NULL);
+ WM_event_add_notifier(BPy_GetContext(), NC_ANIMATION | ND_FCURVES_ORDER, NULL);
}
else {
/* XXX, should be handled by reports, */
@@ -380,7 +380,7 @@ PyObject *pyrna_struct_driver_remove(BPy_StructRNA *self, PyObject *args)
if (BPy_reports_to_error(&reports, PyExc_RuntimeError, TRUE) == -1)
return NULL;
- WM_event_add_notifier(BPy_GetContext(), NC_ANIMATION|ND_FCURVES_ORDER, NULL);
+ WM_event_add_notifier(BPy_GetContext(), NC_ANIMATION | ND_FCURVES_ORDER, NULL);
return PyBool_FromLong(result);
}
diff --git a/source/blender/python/intern/bpy_rna_array.c b/source/blender/python/intern/bpy_rna_array.c
index 6e6eb015387..8d8219df188 100644
--- a/source/blender/python/intern/bpy_rna_array.c
+++ b/source/blender/python/intern/bpy_rna_array.c
@@ -45,7 +45,7 @@
#define MAX_ARRAY_DIMENSION 10
typedef void (*ItemConvertFunc)(PyObject *, char *);
-typedef int (*ItemTypeCheckFunc)(PyObject *);
+typedef int (*ItemTypeCheckFunc)(PyObject *);
typedef void (*RNA_SetArrayFunc)(PointerRNA *, PropertyRNA *, const char *);
typedef void (*RNA_SetIndexFunc)(PointerRNA *, PropertyRNA *, int index, void *);
@@ -65,7 +65,7 @@ typedef void (*RNA_SetIndexFunc)(PointerRNA *, PropertyRNA *, int index, void *)
/* arr[3] = x, self->arraydim is 0, lvalue_dim is 1 */
/* Ensures that a python sequence has expected number of items/sub-items and items are of desired type. */
static int validate_array_type(PyObject *seq, int dim, int totdim, int dimsize[],
- ItemTypeCheckFunc check_item_type, const char *item_type_str, const char *error_prefix)
+ ItemTypeCheckFunc check_item_type, const char *item_type_str, const char *error_prefix)
{
Py_ssize_t i;
diff --git a/source/blender/python/intern/bpy_traceback.c b/source/blender/python/intern/bpy_traceback.c
index aaba90604f5..0e3162e09a4 100644
--- a/source/blender/python/intern/bpy_traceback.c
+++ b/source/blender/python/intern/bpy_traceback.c
@@ -42,7 +42,7 @@ static const char *traceback_filepath(PyTracebackObject *tb, PyObject **coerce)
/* copied from pythonrun.c, 3.2.0 */
static int
parse_syntax_error(PyObject *err, PyObject **message, const char **filename,
- int *lineno, int *offset, const char **text)
+ int *lineno, int *offset, const char **text)
{
long hold;
PyObject *v;
@@ -50,7 +50,7 @@ parse_syntax_error(PyObject *err, PyObject **message, const char **filename,
/* old style errors */
if (PyTuple_Check(err))
return PyArg_ParseTuple(err, "O(ziiz)", message, filename,
- lineno, offset, text);
+ lineno, offset, text);
/* new style errors. `err' is an instance */
@@ -96,7 +96,7 @@ parse_syntax_error(PyObject *err, PyObject **message, const char **filename,
if (v == Py_None)
*text = NULL;
else if (!PyUnicode_Check(v) ||
- !(*text = _PyUnicode_AsString(v)))
+ !(*text = _PyUnicode_AsString(v)))
goto finally;
Py_DECREF(v);
return 1;
@@ -122,7 +122,7 @@ void python_script_error_jump(const char *filepath, int *lineno, int *offset)
/* no traceback available when SyntaxError.
* python has no api's to this. reference parse_syntax_error() from pythonrun.c */
PyErr_NormalizeException(&exception, &value, (PyObject **)&tb);
- PyErr_Restore(exception, value, (PyObject *)tb); /* takes away reference! */
+ PyErr_Restore(exception, value, (PyObject *)tb); /* takes away reference! */
if (value) { /* should always be true */
PyObject *message;
@@ -146,7 +146,7 @@ void python_script_error_jump(const char *filepath, int *lineno, int *offset)
}
else {
PyErr_NormalizeException(&exception, &value, (PyObject **)&tb);
- PyErr_Restore(exception, value, (PyObject *)tb); /* takes away reference! */
+ PyErr_Restore(exception, value, (PyObject *)tb); /* takes away reference! */
PyErr_Print();
for (tb = (PyTracebackObject *)PySys_GetObject("last_traceback");
diff --git a/source/blender/python/intern/bpy_util.c b/source/blender/python/intern/bpy_util.c
index ec7eff1756a..01495c793a8 100644
--- a/source/blender/python/intern/bpy_util.c
+++ b/source/blender/python/intern/bpy_util.c
@@ -37,9 +37,9 @@
#include "../generic/py_capi_utils.h"
-static bContext* __py_context = NULL;
-bContext* BPy_GetContext(void) { return __py_context; }
-void BPy_SetContext(bContext *C) { __py_context = C; }
+static bContext* __py_context = NULL;
+bContext *BPy_GetContext(void) { return __py_context; }
+void BPy_SetContext(bContext *C) { __py_context = C; }
char *BPy_enum_as_string(EnumPropertyItem *item)
{
@@ -49,7 +49,7 @@ char *BPy_enum_as_string(EnumPropertyItem *item)
for (e = item; item->identifier; item++) {
if (item->identifier[0])
- BLI_dynstr_appendf(dynstr, (e == item)?"'%s'":", '%s'", item->identifier);
+ BLI_dynstr_appendf(dynstr, (e == item) ? "'%s'" : ", '%s'", item->identifier);
}
cstring = BLI_dynstr_get_cstring(dynstr);
diff --git a/source/blender/python/intern/gpu.c b/source/blender/python/intern/gpu.c
index cc7506f863e..e5f45ca7736 100644
--- a/source/blender/python/intern/gpu.c
+++ b/source/blender/python/intern/gpu.c
@@ -60,18 +60,18 @@
#include "gpu.h"
-#define PY_MODULE_ADD_CONSTANT(module, name) PyModule_AddIntConstant(module, #name, name)
+#define PY_MODULE_ADD_CONSTANT(module, name) PyModule_AddIntConstant(module, # name, name)
PyDoc_STRVAR(M_gpu_doc,
- "This module provides access to the GLSL shader.");
-
+"This module provides access to the GLSL shader."
+);
static struct PyModuleDef gpumodule = {
PyModuleDef_HEAD_INIT,
"gpu", /* name of module */
M_gpu_doc, /* module documentation */
-1, /* size of per-interpreter state of the module,
* or -1 if the module keeps state in global variables. */
- NULL, NULL, NULL, NULL, NULL
+ NULL, NULL, NULL, NULL, NULL
};
PyMODINIT_FUNC
@@ -116,35 +116,35 @@ PyInit_gpu(void)
return m;
}
-#define PY_DICT_ADD_STRING(d,s,f) \
- val = PyUnicode_FromString(s->f); \
- PyDict_SetItemString(d, #f, val); \
+#define PY_DICT_ADD_STRING(d, s, f) \
+ val = PyUnicode_FromString(s->f); \
+ PyDict_SetItemString(d, # f, val); \
Py_DECREF(val)
-#define PY_DICT_ADD_LONG(d,s,f) \
- val = PyLong_FromLong(s->f); \
- PyDict_SetItemString(d, #f, val); \
+#define PY_DICT_ADD_LONG(d, s, f) \
+ val = PyLong_FromLong(s->f); \
+ PyDict_SetItemString(d, # f, val); \
Py_DECREF(val)
-#define PY_DICT_ADD_ID(d,s,f) \
- RNA_id_pointer_create((struct ID*)s->f, &tptr); \
- val = pyrna_struct_CreatePyObject(&tptr); \
- PyDict_SetItemString(d, #f, val); \
+#define PY_DICT_ADD_ID(d, s, f) \
+ RNA_id_pointer_create((struct ID *)s->f, &tptr); \
+ val = pyrna_struct_CreatePyObject(&tptr); \
+ PyDict_SetItemString(d, # f, val); \
Py_DECREF(val)
-#define PY_OBJ_ADD_ID(d,s,f) \
- val = PyUnicode_FromString(&s->f->id.name[2]); \
- PyObject_SetAttrString(d, #f, val); \
+#define PY_OBJ_ADD_ID(d, s, f) \
+ val = PyUnicode_FromString(&s->f->id.name[2]); \
+ PyObject_SetAttrString(d, # f, val); \
Py_DECREF(val)
-#define PY_OBJ_ADD_LONG(d,s,f) \
- val = PyLong_FromLong(s->f); \
- PyObject_SetAttrString(d, #f, val); \
+#define PY_OBJ_ADD_LONG(d, s, f) \
+ val = PyLong_FromLong(s->f); \
+ PyObject_SetAttrString(d, # f, val); \
Py_DECREF(val)
-#define PY_OBJ_ADD_STRING(d,s,f) \
- val = PyUnicode_FromString(s->f); \
- PyObject_SetAttrString(d, #f, val); \
+#define PY_OBJ_ADD_STRING(d, s, f) \
+ val = PyUnicode_FromString(s->f); \
+ PyObject_SetAttrString(d, # f, val); \
Py_DECREF(val)
PyDoc_STRVAR(GPU_export_shader_doc,
@@ -196,33 +196,34 @@ static PyObject *GPU_export_shader(PyObject *UNUSED(self), PyObject *args, PyObj
// build a dictionary
result = PyDict_New();
if (shader->fragment) {
- PY_DICT_ADD_STRING(result,shader,fragment);
+ PY_DICT_ADD_STRING(result, shader, fragment);
}
if (shader->vertex) {
- PY_DICT_ADD_STRING(result,shader,vertex);
+ PY_DICT_ADD_STRING(result, shader, vertex);
}
seq = PyList_New(BLI_countlist(&shader->uniforms));
for (i = 0, uniform = shader->uniforms.first; uniform; uniform = uniform->next, i++) {
dict = PyDict_New();
- PY_DICT_ADD_STRING(dict,uniform,varname);
- PY_DICT_ADD_LONG(dict,uniform,datatype);
- PY_DICT_ADD_LONG(dict,uniform,type);
+ PY_DICT_ADD_STRING(dict, uniform, varname);
+ PY_DICT_ADD_LONG(dict, uniform, datatype);
+ PY_DICT_ADD_LONG(dict, uniform, type);
if (uniform->lamp) {
- PY_DICT_ADD_ID(dict,uniform,lamp);
+ PY_DICT_ADD_ID(dict, uniform, lamp);
}
if (uniform->image) {
- PY_DICT_ADD_ID(dict,uniform,image);
+ PY_DICT_ADD_ID(dict, uniform, image);
}
if (uniform->type == GPU_DYNAMIC_SAMPLER_2DBUFFER ||
- uniform->type == GPU_DYNAMIC_SAMPLER_2DIMAGE ||
- uniform->type == GPU_DYNAMIC_SAMPLER_2DSHADOW) {
- PY_DICT_ADD_LONG(dict,uniform,texnumber);
+ uniform->type == GPU_DYNAMIC_SAMPLER_2DIMAGE ||
+ uniform->type == GPU_DYNAMIC_SAMPLER_2DSHADOW)
+ {
+ PY_DICT_ADD_LONG(dict, uniform, texnumber);
}
if (uniform->texpixels) {
val = PyByteArray_FromStringAndSize((const char *)uniform->texpixels, uniform->texsize * 4);
PyDict_SetItemString(dict, "texpixels", val);
Py_DECREF(val);
- PY_DICT_ADD_LONG(dict,uniform,texsize);
+ PY_DICT_ADD_LONG(dict, uniform, texsize);
}
PyList_SET_ITEM(seq, i, dict);
}
@@ -232,13 +233,13 @@ static PyObject *GPU_export_shader(PyObject *UNUSED(self), PyObject *args, PyObj
seq = PyList_New(BLI_countlist(&shader->attributes));
for (i = 0, attribute = shader->attributes.first; attribute; attribute = attribute->next, i++) {
dict = PyDict_New();
- PY_DICT_ADD_STRING(dict,attribute,varname);
- PY_DICT_ADD_LONG(dict,attribute,datatype);
- PY_DICT_ADD_LONG(dict,attribute,type);
- PY_DICT_ADD_LONG(dict,attribute,number);
+ PY_DICT_ADD_STRING(dict, attribute, varname);
+ PY_DICT_ADD_LONG(dict, attribute, datatype);
+ PY_DICT_ADD_LONG(dict, attribute, type);
+ PY_DICT_ADD_LONG(dict, attribute, number);
if (attribute->name) {
if (attribute->name[0] != 0) {
- PY_DICT_ADD_STRING(dict,attribute,name);
+ PY_DICT_ADD_STRING(dict, attribute, name);
}
else {
val = PyLong_FromLong(0);