Merged changes in the trunk up to revision 45133.

Conflicts resolved:
source/blender/blenloader/intern/readfile.c
source/blender/blenloader/intern/writefile.c
source/blender/bmesh/intern/bmesh_construct.c
source/blender/bmesh/intern/bmesh_mesh_conv.c
source/blender/bmesh/intern/bmesh_mesh_conv.h
source/blender/editors/interface/interface_templates.c
source/blender/editors/interface/resources.c
source/blender/editors/mesh/bmesh_select.c
source/blender/editors/mesh/bmesh_tools.c
source/blender/editors/space_view3d/drawobject.c
source/blender/render/intern/source/shadeoutput.c
This commit is contained in:
Tamito Kajiyama
2012-03-25 08:20:19 +00:00
1200 changed files with 77004 additions and 63870 deletions

View File

@@ -73,12 +73,17 @@ PyDoc_STRVAR(bpy_script_paths_doc,
static PyObject *bpy_script_paths(PyObject *UNUSED(self))
{
PyObject *ret = PyTuple_New(2);
PyObject *item;
char *path;
path = BLI_get_folder(BLENDER_SYSTEM_SCRIPTS, NULL);
PyTuple_SET_ITEM(ret, 0, PyUnicode_FromString(path?path:""));
item = PyUnicode_DecodeFSDefault(path ? path : "");
BLI_assert(item != NULL);
PyTuple_SET_ITEM(ret, 0, item);
path = BLI_get_folder(BLENDER_USER_SCRIPTS, NULL);
PyTuple_SET_ITEM(ret, 1, PyUnicode_FromString(path?path:""));
item = PyUnicode_DecodeFSDefault(path ? path : "");
BLI_assert(item != NULL);
PyTuple_SET_ITEM(ret, 1, item);
return ret;
}
@@ -202,7 +207,7 @@ static PyObject *bpy_resource_path(PyObject *UNUSED(self), PyObject *args, PyObj
path = BLI_get_folder_version(folder_id, (major * 100) + minor, FALSE);
return PyUnicode_DecodeFSDefault(path);
return PyUnicode_DecodeFSDefault(path ? path : "");
}
static PyMethodDef meth_bpy_script_paths =

View File

@@ -47,6 +47,8 @@ static PyStructSequence_Field app_cb_info_fields[] = {
{(char *)"render_pre", (char *)"Callback list - on render (before)"},
{(char *)"render_post", (char *)"Callback list - on render (after)"},
{(char *)"render_stats", (char *)"Callback list - on printing render statistics"},
{(char *)"render_complete", (char *)"Callback list - on completion of render job"},
{(char *)"render_cancel", (char *)"Callback list - on cancelling a render job"},
{(char *)"load_pre", (char *)"Callback list - on loading a new blend file (before)"},
{(char *)"load_post", (char *)"Callback list - on loading a new blend file (after)"},
{(char *)"save_pre", (char *)"Callback list - on saving a blend file (before)"},
@@ -254,10 +256,10 @@ void BPY_app_handlers_reset(const short do_all)
for (i = PyList_GET_SIZE(ls) - 1; i >= 0; i--) {
if ( (PyFunction_Check((item = PyList_GET_ITEM(ls, i)))) &&
(dict_ptr = _PyObject_GetDictPtr(item)) &&
(*dict_ptr) &&
(PyDict_GetItem(*dict_ptr, perm_id_str) != NULL))
if ((PyFunction_Check((item = PyList_GET_ITEM(ls, i)))) &&
(dict_ptr = _PyObject_GetDictPtr(item)) &&
(*dict_ptr) &&
(PyDict_GetItem(*dict_ptr, perm_id_str) != NULL))
{
/* keep */
}
@@ -277,13 +279,12 @@ void BPY_app_handlers_reset(const short do_all)
void bpy_app_generic_callback(struct Main *UNUSED(main), struct ID *id, void *arg)
{
PyObject *cb_list = py_cb_array[GET_INT_FROM_POINTER(arg)];
Py_ssize_t cb_list_len;
if ((cb_list_len = PyList_GET_SIZE(cb_list)) > 0) {
if (PyList_GET_SIZE(cb_list) > 0) {
PyGILState_STATE gilstate = PyGILState_Ensure();
PyObject* args = PyTuple_New(1); // save python creating each call
PyObject* func;
PyObject* ret;
PyObject *args = PyTuple_New(1); // save python creating each call
PyObject *func;
PyObject *ret;
Py_ssize_t pos;
/* setup arguments */
@@ -297,8 +298,9 @@ void bpy_app_generic_callback(struct Main *UNUSED(main), struct ID *id, void *ar
Py_INCREF(Py_None);
}
// Iterate the list and run the callbacks
for (pos = 0; pos < cb_list_len; pos++) {
/* Iterate the list and run the callbacks
* note: don't store the list size since the scripts may remove themselves */
for (pos = 0; pos < PyList_GET_SIZE(cb_list); pos++) {
func = PyList_GET_ITEM(cb_list, pos);
ret = PyObject_Call(func, args, NULL);
if (ret == NULL) {

View File

@@ -70,7 +70,7 @@ int bpy_pydriver_create_dict(void)
mod = PyImport_ImportModule("math");
if (mod) {
PyDict_Merge(d, PyModule_GetDict(mod), 0); /* 0 - dont overwrite existing values */
PyDict_Merge(d, PyModule_GetDict(mod), 0); /* 0 - don't overwrite existing values */
Py_DECREF(mod);
}
@@ -159,14 +159,14 @@ static void pydriver_error(ChannelDriver *driver)
/* This evals py driver expressions, 'expr' is a Python expression that
* should evaluate to a float number, which is returned.
*
* (old)note: PyGILState_Ensure() isnt always called because python can call
* (old)note: PyGILState_Ensure() isn't always called because python can call
* the bake operator which intern starts a thread which calls scene update
* which does a driver update. to avoid a deadlock check PYC_INTERPRETER_ACTIVE
* if PyGILState_Ensure() is needed - see [#27683]
*
* (new)note: checking if python is running is not threadsafe [#28114]
* now release the GIL on python operator execution instead, using
* PyEval_SaveThread() / PyEval_RestoreThread() so we dont lock up blender.
* PyEval_SaveThread() / PyEval_RestoreThread() so we don't lock up blender.
*/
float BPY_driver_exec(ChannelDriver *driver, const float evaltime)
{

View File

@@ -52,6 +52,7 @@
#include "DNA_text_types.h"
#include "BLI_path_util.h"
#include "BLI_fileops.h"
#include "BLI_math_base.h"
#include "BLI_string.h"
#include "BLI_string_utf8.h"
@@ -96,7 +97,7 @@ void bpy_context_update(bContext *C)
{
BPy_SetContext(C);
bpy_import_main_set(CTX_data_main(C));
BPY_modules_update(C); /* can give really bad results if this isnt here */
BPY_modules_update(C); /* can give really bad results if this isn't here */
}
void bpy_context_set(bContext *C, PyGILState_STATE *gilstate)
@@ -238,7 +239,7 @@ void BPY_python_start(int argc, const char **argv)
Py_Initialize();
// PySys_SetArgv(argc, argv); // broken in py3, not a huge deal
/* sigh, why do python guys not have a char** version anymore? :( */
/* sigh, why do python guys not have a (char **) version anymore? */
{
int i;
PyObject *py_argv = PyList_New(argc);
@@ -388,7 +389,7 @@ static int python_script_exec(bContext *C, const char *fn, struct Text *text,
}
else {
FILE *fp = fopen(fn, "r");
FILE *fp = BLI_fopen(fn, "r");
if (fp) {
py_dict = PyC_DefaultNameSpace(fn);
@@ -497,7 +498,7 @@ int BPY_button_exec(bContext *C, const char *expr, double *value, const short ve
mod = PyImport_ImportModule("math");
if (mod) {
PyDict_Merge(py_dict, PyModule_GetDict(mod), 0); /* 0 - dont overwrite existing values */
PyDict_Merge(py_dict, PyModule_GetDict(mod), 0); /* 0 - don't overwrite existing values */
Py_DECREF(mod);
}
else { /* highly unlikely but possibly */
@@ -705,7 +706,7 @@ int BPY_context_member_get(bContext *C, const char *member, bContextDataResult *
#ifdef WITH_PYTHON_MODULE
#include "BLI_fileops.h"
/* TODO, reloading the module isnt functional at the moment. */
/* TODO, reloading the module isn't functional at the moment. */
static void bpy_module_free(void *mod);
extern int main_python_enter(int argc, const char **argv);
@@ -782,7 +783,7 @@ PyInit_bpy(void)
* we may end up having to rename this module so there is no naming conflict here eg:
* 'from blender import bpy'
*
* 3) we dont know the filename at this point, workaround by assigning a dummy value
* 3) we don't know the filename at this point, workaround by assigning a dummy value
* which calls back when its freed so the real loading can take place.
*/

View File

@@ -62,7 +62,7 @@ static void atexit_func_call(const char *func_name, PyObject *atexit_func_arg)
PyObject *ret;
PyTuple_SET_ITEM(args, 0, atexit_func_arg);
Py_INCREF(atexit_func_arg); /* only incref so we dont dec'ref along with 'args' */
Py_INCREF(atexit_func_arg); /* only incref so we don't dec'ref along with 'args' */
ret = PyObject_CallObject(atexit_func, args);

View File

@@ -62,7 +62,7 @@
#endif
typedef struct {
PyObject_HEAD /* required python macro */
PyObject_HEAD /* required python macro */
/* collection iterator specific parts */
char relpath[FILE_MAX];
char abspath[FILE_MAX]; /* absolute path */
@@ -186,7 +186,7 @@ static PyObject *bpy_lib_load(PyObject *UNUSED(self), PyObject *args, PyObject *
{
static const char *kwlist[] = {"filepath", "link", "relative", NULL};
BPy_Library *ret;
const char* filename = NULL;
const char *filename = NULL;
int is_rel = 0, is_link = 0;
if (!PyArg_ParseTupleAndKeywords(args, kwds, "s|ii:load", (char **)kwlist, &filename, &is_link, &is_rel))
@@ -199,8 +199,8 @@ static PyObject *bpy_lib_load(PyObject *UNUSED(self), PyObject *args, PyObject *
BLI_path_abs(ret->abspath, G.main->name);
ret->blo_handle = NULL;
ret->flag= (is_link ? FILE_LINK : 0) |
(is_rel ? FILE_RELPATH : 0);
ret->flag = ((is_link ? FILE_LINK : 0) |
(is_rel ? FILE_RELPATH : 0));
ret->dict = PyDict_New();
@@ -431,7 +431,7 @@ int bpy_lib_init(PyObject *mod_par)
PyModule_AddObject(mod_par, "_library_load", PyCFunction_New(&load_meth, NULL));
/* some compilers dont like accessing this directly, delay assignment */
/* some compilers don't like accessing this directly, delay assignment */
bpy_lib_Type.tp_getattro = PyObject_GenericGetAttr;
if (PyType_Ready(&bpy_lib_Type) < 0)

View File

@@ -225,7 +225,7 @@ static PyObject *pyop_call(PyObject *UNUSED(self), PyObject *args)
ReportList *reports;
reports = MEM_mallocN(sizeof(ReportList), "wmOperatorReportList");
BKE_reports_init(reports, RPT_STORE | RPT_OP_HOLD); /* own so these dont move into global reports */
BKE_reports_init(reports, RPT_STORE | RPT_OP_HOLD); /* own so these don't move into global reports */
#ifdef BPY_RELEASE_GIL
/* release GIL, since a thread could be started from an operator

View File

@@ -155,10 +155,10 @@ static void printf_func_error(PyObject *py_func)
/* use py style error */
fprintf(stderr, "File \"%s\", line %d, in %s\n",
_PyUnicode_AsString(f_code->co_filename),
f_code->co_firstlineno,
_PyUnicode_AsString(((PyFunctionObject *)py_func)->func_name)
);
_PyUnicode_AsString(f_code->co_filename),
f_code->co_firstlineno,
_PyUnicode_AsString(((PyFunctionObject *)py_func)->func_name)
);
}
/* operators and classes use this so it can store the args given but defer
@@ -372,7 +372,7 @@ static int bpy_struct_id_used(StructRNA *srna, char *identifier)
/* Function that sets RNA, NOTE - self is NULL when called from python,
* but being abused from C so we can pass the srna along.
* This isnt incorrect since its a python object - but be careful */
* This isn't incorrect since its a python object - but be careful */
PyDoc_STRVAR(BPy_BoolProperty_doc,
".. function:: BoolProperty(name=\"\", "
"description=\"\", "
@@ -1033,14 +1033,14 @@ static EnumPropertyItem *enum_items_from_py(PyObject *seq_fast, PyObject *def, i
item = PySequence_Fast_GET_ITEM(seq_fast, i);
if ( (PyTuple_CheckExact(item)) &&
(item_size = PyTuple_GET_SIZE(item)) &&
(item_size == 3 || item_size == 4) &&
(tmp.identifier = _PyUnicode_AsStringAndSize(PyTuple_GET_ITEM(item, 0), &id_str_size)) &&
(tmp.name = _PyUnicode_AsStringAndSize(PyTuple_GET_ITEM(item, 1), &name_str_size)) &&
(tmp.description = _PyUnicode_AsStringAndSize(PyTuple_GET_ITEM(item, 2), &desc_str_size)) &&
/* TODO, number isnt ensured to be unique from the script author */
(item_size < 4 || py_long_as_int(PyTuple_GET_ITEM(item, 3), &tmp.value) != -1))
if ((PyTuple_CheckExact(item)) &&
(item_size = PyTuple_GET_SIZE(item)) &&
(item_size == 3 || item_size == 4) &&
(tmp.identifier = _PyUnicode_AsStringAndSize(PyTuple_GET_ITEM(item, 0), &id_str_size)) &&
(tmp.name = _PyUnicode_AsStringAndSize(PyTuple_GET_ITEM(item, 1), &name_str_size)) &&
(tmp.description = _PyUnicode_AsStringAndSize(PyTuple_GET_ITEM(item, 2), &desc_str_size)) &&
/* TODO, number isn't ensured to be unique from the script author */
(item_size < 4 || py_long_as_int(PyTuple_GET_ITEM(item, 3), &tmp.value) != -1))
{
if (is_enum_flag) {
if (item_size < 4) {
@@ -1260,7 +1260,7 @@ static PyObject *BPy_EnumProperty(PyObject *self, PyObject *args, PyObject *kw)
}
/* items can be a list or a callable */
if (PyFunction_Check(items)) { /* dont use PyCallable_Check because we need the function code for errors */
if (PyFunction_Check(items)) { /* don't use PyCallable_Check because we need the function code for errors */
PyCodeObject *f_code = (PyCodeObject *)PyFunction_GET_CODE(items);
if (f_code->co_argcount != 2) {
PyErr_Format(PyExc_ValueError,

View File

@@ -85,7 +85,7 @@
#define USE_MATHUTILS
#define USE_STRING_COERCE
static PyObject* pyrna_struct_Subtype(PointerRNA *ptr);
static PyObject *pyrna_struct_Subtype(PointerRNA *ptr);
static PyObject *pyrna_prop_collection_values(BPy_PropertyRNA *self);
#define BPY_DOC_ID_PROP_TYPE_NOTE \
@@ -372,7 +372,7 @@ static PyObject *pyrna_prop_array_subscript_slice(BPy_PropertyArrayRNA *self, Po
static short pyrna_rotation_euler_order_get(PointerRNA *ptr, PropertyRNA **prop_eul_order, short order_fallback);
/* bpyrna vector/euler/quat callbacks */
static int mathutils_rna_array_cb_index = -1; /* index for our callbacks */
static unsigned char mathutils_rna_array_cb_index = -1; /* index for our callbacks */
/* subtype not used much yet */
#define MATHUTILS_CB_SUBTYPE_EUL 0
@@ -517,7 +517,7 @@ static Mathutils_Callback mathutils_rna_array_cb = {
/* bpyrna matrix callbacks */
static int mathutils_rna_matrix_cb_index = -1; /* index for our callbacks */
static unsigned char mathutils_rna_matrix_cb_index = -1; /* index for our callbacks */
static int mathutils_rna_matrix_get(BaseMathObject *bmo, int UNUSED(subtype))
{
@@ -756,15 +756,15 @@ int pyrna_enum_value_from_id(EnumPropertyItem *item, const char *identifier, int
static int pyrna_struct_compare(BPy_StructRNA *a, BPy_StructRNA *b)
{
return ( (a->ptr.data == b->ptr.data) &&
(a->ptr.type == b->ptr.type)) ? 0 : -1;
return (((a->ptr.data == b->ptr.data) &&
(a->ptr.type == b->ptr.type)) ? 0 : -1);
}
static int pyrna_prop_compare(BPy_PropertyRNA *a, BPy_PropertyRNA *b)
{
return ( (a->prop == b->prop) &&
return (((a->prop == b->prop) &&
(a->ptr.data == b->ptr.data) &&
(a->ptr.type == b->ptr.type) ) ? 0 : -1;
(a->ptr.type == b->ptr.type)) ? 0 : -1);
}
static PyObject *pyrna_struct_richcmp(PyObject *a, PyObject *b, int op)
@@ -776,21 +776,21 @@ static PyObject *pyrna_struct_richcmp(PyObject *a, PyObject *b, int op)
ok = pyrna_struct_compare((BPy_StructRNA *)a, (BPy_StructRNA *)b);
switch (op) {
case Py_NE:
ok = !ok; /* pass through */
case Py_EQ:
res = ok ? Py_False : Py_True;
break;
case Py_NE:
ok = !ok; /* pass through */
case Py_EQ:
res = ok ? Py_False : Py_True;
break;
case Py_LT:
case Py_LE:
case Py_GT:
case Py_GE:
res = Py_NotImplemented;
break;
default:
PyErr_BadArgument();
return NULL;
case Py_LT:
case Py_LE:
case Py_GT:
case Py_GE:
res = Py_NotImplemented;
break;
default:
PyErr_BadArgument();
return NULL;
}
return Py_INCREF(res), res;
@@ -805,21 +805,21 @@ static PyObject *pyrna_prop_richcmp(PyObject *a, PyObject *b, int op)
ok = pyrna_prop_compare((BPy_PropertyRNA *)a, (BPy_PropertyRNA *)b);
switch (op) {
case Py_NE:
ok = !ok; /* pass through */
case Py_EQ:
res = ok ? Py_False : Py_True;
break;
case Py_NE:
ok = !ok; /* pass through */
case Py_EQ:
res = ok ? Py_False : Py_True;
break;
case Py_LT:
case Py_LE:
case Py_GT:
case Py_GE:
res = Py_NotImplemented;
break;
default:
PyErr_BadArgument();
return NULL;
case Py_LT:
case Py_LE:
case Py_GT:
case Py_GE:
res = Py_NotImplemented;
break;
default:
PyErr_BadArgument();
return NULL;
}
return Py_INCREF(res), res;
@@ -912,7 +912,7 @@ static PyObject *pyrna_prop_str(BPy_PropertyRNA *self)
int len = -1;
char *c = type_fmt;
while ((*c++= tolower(*type_id++))) {}
while ((*c++ = tolower(*type_id++))) {}
if (type == PROP_COLLECTION) {
len = pyrna_prop_collection_length(self);
@@ -1694,9 +1694,9 @@ static int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, void *data, PyOb
* 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))
) {
(BPy_StructRNA_Check(value)) &&
(RNA_struct_is_a(((BPy_StructRNA *)value)->ptr.type, &RNA_Operator)))
{
value = PyObject_GetAttrString(value, "properties");
value_new = value;
}
@@ -2640,7 +2640,7 @@ static int prop_subscript_ass_array_slice(PointerRNA *ptr, PropertyRNA *prop,
RNA_property_float_get_array(ptr, prop, values);
for (count = start; count < stop; count++) {
fval = PyFloat_AsDouble(PySequence_Fast_GET_ITEM(value, count-start));
fval = PyFloat_AsDouble(PySequence_Fast_GET_ITEM(value, count - start));
CLAMP(fval, min, max);
values[count] = fval;
}
@@ -2660,7 +2660,7 @@ static int prop_subscript_ass_array_slice(PointerRNA *ptr, PropertyRNA *prop,
RNA_property_boolean_get_array(ptr, prop, values);
for (count = start; count < stop; count++)
values[count] = PyLong_AsLong(PySequence_Fast_GET_ITEM(value, count-start));
values[count] = PyLong_AsLong(PySequence_Fast_GET_ITEM(value, count - start));
if (PyErr_Occurred()) ret = -1;
else RNA_property_boolean_set_array(ptr, prop, values);
@@ -3282,25 +3282,42 @@ static PyObject *pyrna_struct_type_recast(BPy_StructRNA *self)
return pyrna_struct_CreatePyObject(&r_ptr);
}
static void pyrna_dir_members_py__add_keys(PyObject *list, PyObject *dict)
{
PyObject *list_tmp;
list_tmp = PyDict_Keys(dict);
PyList_SetSlice(list, INT_MAX, INT_MAX, list_tmp);
Py_DECREF(list_tmp);
}
static void pyrna_dir_members_py(PyObject *list, PyObject *self)
{
PyObject *dict;
PyObject **dict_ptr;
PyObject *list_tmp;
dict_ptr = _PyObject_GetDictPtr((PyObject *)self);
if (dict_ptr && (dict = *dict_ptr)) {
list_tmp = PyDict_Keys(dict);
PyList_SetSlice(list, INT_MAX, INT_MAX, list_tmp);
Py_DECREF(list_tmp);
pyrna_dir_members_py__add_keys(list, dict);
}
dict = ((PyTypeObject *)Py_TYPE(self))->tp_dict;
if (dict) {
list_tmp = PyDict_Keys(dict);
PyList_SetSlice(list, INT_MAX, INT_MAX, list_tmp);
Py_DECREF(list_tmp);
pyrna_dir_members_py__add_keys(list, dict);
}
/* since this is least common case, handle it last */
if (BPy_PropertyRNA_Check(self)) {
BPy_PropertyRNA *self_prop = (BPy_PropertyRNA *)self;
PointerRNA r_ptr;
if (RNA_property_collection_type_get(&self_prop->ptr, self_prop->prop, &r_ptr)) {
PyObject *cls = pyrna_struct_Subtype(&r_ptr); /* borrows */
dict = ((PyTypeObject *)cls)->tp_dict;
pyrna_dir_members_py__add_keys(list, dict);
Py_DECREF(cls);
}
}
}
@@ -3770,8 +3787,10 @@ static PyObject *pyrna_prop_collection_getattro(BPy_PropertyRNA *self, PyObject
PyErr_Fetch(&error_type, &error_value, &error_traceback);
PyErr_Clear();
cls = pyrna_struct_Subtype(&r_ptr); /* borrows */
cls = pyrna_struct_Subtype(&r_ptr);
ret = PyObject_GenericGetAttr(cls, pyname);
Py_DECREF(cls);
/* restore the original error */
if (ret == NULL) {
PyErr_Restore(error_type, error_value, error_traceback);
@@ -3919,6 +3938,12 @@ static PyGetSetDef pyrna_struct_getseters[] = {
{NULL, NULL, NULL, NULL, NULL} /* Sentinel */
};
static PyObject *pyrna_func_doc_get(BPy_FunctionRNA *self, void *closure);
static PyGetSetDef pyrna_func_getseters[] = {
{(char *)"__doc__", (getter)pyrna_func_doc_get, (setter)NULL, NULL, NULL},
{NULL, NULL, NULL, NULL, NULL} /* Sentinel */
};
PyDoc_STRVAR(pyrna_prop_collection_keys_doc,
".. method:: keys()\n"
@@ -3927,7 +3952,7 @@ PyDoc_STRVAR(pyrna_prop_collection_keys_doc,
" (matching pythons dict.keys() functionality).\n"
"\n"
" :return: the identifiers for each member of this collection.\n"
" :rtype: list of stings\n"
" :rtype: list of strings\n"
);
static PyObject *pyrna_prop_collection_keys(BPy_PropertyRNA *self)
{
@@ -4034,7 +4059,7 @@ static PyObject *pyrna_struct_get(BPy_StructRNA *self, PyObject *args)
IDProperty *group, *idprop;
const char *key;
PyObject* def = Py_None;
PyObject *def = Py_None;
PYRNA_STRUCT_CHECK_OBJ(self);
@@ -4092,7 +4117,7 @@ static PyObject *pyrna_prop_collection_get(BPy_PropertyRNA *self, PyObject *args
PointerRNA newptr;
PyObject *key_ob;
PyObject* def = Py_None;
PyObject *def = Py_None;
PYRNA_PROP_CHECK_OBJ(self);
@@ -4166,16 +4191,16 @@ static PyObject *pyrna_prop_collection_find(BPy_PropertyRNA *self, PyObject *key
return PyLong_FromSsize_t(index);
}
static void foreach_attr_type( BPy_PropertyRNA *self, const char *attr,
/* values to assign */
RawPropertyType *raw_type, int *attr_tot, int *attr_signed)
static void foreach_attr_type(BPy_PropertyRNA *self, const char *attr,
/* values to assign */
RawPropertyType *raw_type, int *attr_tot, int *attr_signed)
{
PropertyRNA *prop;
*raw_type = PROP_RAW_UNSET;
*attr_tot = 0;
*attr_signed = FALSE;
/* note: this is fail with zero length lists, so dont let this get caled in that case */
/* note: this is fail with zero length lists, so don't let this get caled in that case */
RNA_PROP_BEGIN(&self->ptr, itemptr, self->prop) {
prop = RNA_struct_find_property(&itemptr, attr);
*raw_type = RNA_property_raw_type(prop);
@@ -4190,8 +4215,8 @@ static void foreach_attr_type( BPy_PropertyRNA *self, const char *attr,
static int foreach_parse_args(
BPy_PropertyRNA *self, PyObject *args,
/*values to assign */
const char **attr, PyObject **seq, int *tot, int *size,
/* values to assign */
const char **attr, PyObject **seq, int *tot, int *size,
RawPropertyType *raw_type, int *attr_tot, int *attr_signed
)
{
@@ -4236,7 +4261,7 @@ static int foreach_parse_args(
#endif
}
/* check 'attr_tot' otherwise we dont know if any values were set
/* check 'attr_tot' otherwise we don't know if any values were set
* this isn't ideal because it means running on an empty list may fail silently when its not compatible. */
if (*size == 0 && *attr_tot != 0) {
PyErr_SetString(PyExc_AttributeError, "attribute does not support foreach method");
@@ -4250,21 +4275,21 @@ static int foreach_compat_buffer(RawPropertyType raw_type, int attr_signed, cons
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;
case PROP_RAW_SHORT:
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;
case PROP_RAW_FLOAT:
return (f == 'f') ? 1:0;
case PROP_RAW_DOUBLE:
return (f == 'd') ? 1:0;
case PROP_RAW_UNSET:
return 0;
case PROP_RAW_CHAR:
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;
case PROP_RAW_INT:
if (attr_signed) return (f == 'i') ? 1:0;
else return (f == 'I') ? 1:0;
case PROP_RAW_FLOAT:
return (f == 'f') ? 1:0;
case PROP_RAW_DOUBLE:
return (f == 'd') ? 1:0;
case PROP_RAW_UNSET:
return 0;
}
return 0;
@@ -4314,25 +4339,25 @@ static PyObject *foreach_getset(BPy_PropertyRNA *self, PyObject *args, int set)
for ( ; i < tot; i++) {
item = PySequence_GetItem(seq, i);
switch (raw_type) {
case PROP_RAW_CHAR:
((char *)array)[i] = (char)PyLong_AsLong(item);
break;
case PROP_RAW_SHORT:
((short *)array)[i] = (short)PyLong_AsLong(item);
break;
case PROP_RAW_INT:
((int *)array)[i] = (int)PyLong_AsLong(item);
break;
case PROP_RAW_FLOAT:
((float *)array)[i] = (float)PyFloat_AsDouble(item);
break;
case PROP_RAW_DOUBLE:
((double *)array)[i] = (double)PyFloat_AsDouble(item);
break;
case PROP_RAW_UNSET:
/* should never happen */
BLI_assert(!"Invalid array type - set");
break;
case PROP_RAW_CHAR:
((char *)array)[i] = (char)PyLong_AsLong(item);
break;
case PROP_RAW_SHORT:
((short *)array)[i] = (short)PyLong_AsLong(item);
break;
case PROP_RAW_INT:
((int *)array)[i] = (int)PyLong_AsLong(item);
break;
case PROP_RAW_FLOAT:
((float *)array)[i] = (float)PyFloat_AsDouble(item);
break;
case PROP_RAW_DOUBLE:
((double *)array)[i] = (double)PyFloat_AsDouble(item);
break;
case PROP_RAW_UNSET:
/* should never happen */
BLI_assert(!"Invalid array type - set");
break;
}
Py_DECREF(item);
@@ -4369,27 +4394,27 @@ static PyObject *foreach_getset(BPy_PropertyRNA *self, PyObject *args, int set)
for ( ; i < tot; i++) {
switch (raw_type) {
case PROP_RAW_CHAR:
item = PyLong_FromSsize_t((Py_ssize_t) ((char *)array)[i]);
break;
case PROP_RAW_SHORT:
item = PyLong_FromSsize_t((Py_ssize_t) ((short *)array)[i]);
break;
case PROP_RAW_INT:
item = PyLong_FromSsize_t((Py_ssize_t) ((int *)array)[i]);
break;
case PROP_RAW_FLOAT:
item = PyFloat_FromDouble((double) ((float *)array)[i]);
break;
case PROP_RAW_DOUBLE:
item = PyFloat_FromDouble((double) ((double *)array)[i]);
break;
default: /* PROP_RAW_UNSET */
/* should never happen */
BLI_assert(!"Invalid array type - get");
item = Py_None;
Py_INCREF(item);
break;
case PROP_RAW_CHAR:
item = PyLong_FromSsize_t((Py_ssize_t) ((char *)array)[i]);
break;
case PROP_RAW_SHORT:
item = PyLong_FromSsize_t((Py_ssize_t) ((short *)array)[i]);
break;
case PROP_RAW_INT:
item = PyLong_FromSsize_t((Py_ssize_t) ((int *)array)[i]);
break;
case PROP_RAW_FLOAT:
item = PyFloat_FromDouble((double) ((float *)array)[i]);
break;
case PROP_RAW_DOUBLE:
item = PyFloat_FromDouble((double) ((double *)array)[i]);
break;
default: /* PROP_RAW_UNSET */
/* should never happen */
BLI_assert(!"Invalid array type - get");
item = Py_None;
Py_INCREF(item);
break;
}
PySequence_SetItem(seq, i, item);
@@ -4524,7 +4549,7 @@ static struct PyMethodDef pyrna_struct_methods[] = {
{"type_recast", (PyCFunction)pyrna_struct_type_recast, METH_NOARGS, pyrna_struct_type_recast_doc},
{"__dir__", (PyCFunction)pyrna_struct_dir, METH_NOARGS, NULL},
/* experemental */
/* experimental */
{"callback_add", (PyCFunction)pyrna_callback_add, METH_VARARGS, NULL},
{"callback_remove", (PyCFunction)pyrna_callback_remove, METH_VARARGS, NULL},
{NULL, NULL, 0, NULL}
@@ -4993,7 +5018,7 @@ static PyObject *pyrna_func_call(BPy_FunctionRNA *self, PyObject *args, PyObject
/* Check if we gave args that don't exist in the function
* printing the error is slow but it should only happen when developing.
* the if below is quick, checking if it passed less keyword args then we gave.
* (Dont overwrite the error if we have one, otherwise can skip important messages and confuse with args)
* (Don't overwrite the error if we have one, otherwise can skip important messages and confuse with args)
*/
if (err == 0 && kw && (pykw_len > kw_tot)) {
PyObject *key, *value;
@@ -5131,6 +5156,22 @@ static PyObject *pyrna_func_call(BPy_FunctionRNA *self, PyObject *args, PyObject
Py_RETURN_NONE;
}
static PyObject *pyrna_func_doc_get(BPy_FunctionRNA *self, void *UNUSED(closure))
{
PyObject *ret;
char *args;
args = RNA_function_as_string_keywords(NULL, self->func, NULL, TRUE, TRUE);
ret = PyUnicode_FromFormat("%.200s.%.200s(%.200s)\n%s",
RNA_struct_identifier(self->ptr.type),
RNA_function_identifier(self->func),
args, RNA_function_ui_description(self->func));
MEM_freeN(args);
return ret;
}
/* subclasses of pyrna_struct_Type which support idprop definitions use this as a metaclass */
/* note: tp_base member is set to &PyType_Type on init */
@@ -5707,7 +5748,7 @@ PyTypeObject pyrna_func_Type = {
/*** Attribute descriptor and subclassing stuff ***/
NULL, /* struct PyMethodDef *tp_methods; */
NULL, /* struct PyMemberDef *tp_members; */
NULL, /* struct PyGetSetDef *tp_getset; */
pyrna_func_getseters, /* struct PyGetSetDef *tp_getset; */
NULL, /* struct _typeobject *tp_base; */
NULL, /* PyObject *tp_dict; */
NULL, /* descrgetfunc tp_descr_get; */
@@ -5922,10 +5963,10 @@ static void pyrna_subtype_set_rna(PyObject *newclass, StructRNA *srna)
/* done with rna instance */
}
static PyObject* pyrna_srna_Subtype(StructRNA *srna);
static PyObject *pyrna_srna_Subtype(StructRNA *srna);
/* return a borrowed reference */
static PyObject* pyrna_srna_PyBase(StructRNA *srna) //, PyObject *bpy_types_dict)
static PyObject *pyrna_srna_PyBase(StructRNA *srna) //, PyObject *bpy_types_dict)
{
/* Assume RNA_struct_py_type_get(srna) was already checked */
StructRNA *base;
@@ -5952,7 +5993,7 @@ static PyObject* pyrna_srna_PyBase(StructRNA *srna) //, PyObject *bpy_types_dict
* return a borrowed reference */
static PyObject *bpy_types_dict = NULL;
static PyObject* pyrna_srna_ExternalType(StructRNA *srna)
static PyObject *pyrna_srna_ExternalType(StructRNA *srna)
{
const char *idname = RNA_struct_identifier(srna);
PyObject *newclass;
@@ -6002,7 +6043,7 @@ static PyObject* pyrna_srna_ExternalType(StructRNA *srna)
return newclass;
}
static PyObject* pyrna_srna_Subtype(StructRNA *srna)
static PyObject *pyrna_srna_Subtype(StructRNA *srna)
{
PyObject *newclass = NULL;
@@ -6035,8 +6076,8 @@ static PyObject* pyrna_srna_Subtype(StructRNA *srna)
// if (!descr) descr = "(no docs)";
// "__doc__", descr
if ( RNA_struct_idprops_check(srna) &&
!PyObject_IsSubclass(py_base, (PyObject *)&pyrna_struct_meta_idprop_Type))
if (RNA_struct_idprops_check(srna) &&
!PyObject_IsSubclass(py_base, (PyObject *)&pyrna_struct_meta_idprop_Type))
{
metaclass = (PyObject *)&pyrna_struct_meta_idprop_Type;
}
@@ -6045,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()}",
newclass = PyObject_CallFunction(metaclass, (char *)"s(O) {sss()}",
idname, py_base, "__module__","bpy.types", "__slots__");
/* newclass will now have 2 ref's, ???, probably 1 is internal since decrefing here segfaults */
@@ -6082,7 +6123,7 @@ static StructRNA *srna_from_ptr(PointerRNA *ptr)
}
/* always returns a new ref, be sure to decref when done */
static PyObject* pyrna_struct_Subtype(PointerRNA *ptr)
static PyObject *pyrna_struct_Subtype(PointerRNA *ptr)
{
return pyrna_srna_Subtype(srna_from_ptr(ptr));
}
@@ -6588,10 +6629,10 @@ static int pyrna_deferred_register_class_recursive(StructRNA *srna, PyTypeObject
*
* So only scan base classes which are not subclasses if blender types.
* This best fits having 'mix-in' classes for operators and render engines.
* */
*/
if (py_superclass != &PyBaseObject_Type &&
!PyObject_IsSubclass((PyObject *)py_superclass, (PyObject *)&pyrna_struct_Type)
) {
!PyObject_IsSubclass((PyObject *)py_superclass, (PyObject *)&pyrna_struct_Type))
{
ret = pyrna_deferred_register_class_recursive(srna, py_superclass);
if (ret != 0) {
@@ -6606,7 +6647,7 @@ static int pyrna_deferred_register_class_recursive(StructRNA *srna, PyTypeObject
int pyrna_deferred_register_class(StructRNA *srna, PyObject *py_class)
{
/* Panels and Menus dont need this
/* Panels and Menus don't need this
* save some time and skip the checks here */
if (!RNA_struct_idprops_register_check(srna))
return 0;
@@ -6704,7 +6745,7 @@ static int bpy_class_validate(PointerRNA *dummyptr, void *py_data, int *have_fun
func_arg_count = rna_function_arg_count(func);
if (func_arg_count >= 0) { /* -1 if we dont care*/
if (func_arg_count >= 0) { /* -1 if we don't care*/
arg_count = ((PyCodeObject *)PyFunction_GET_CODE(item))->co_argcount;
/* note, the number of args we check for and the number of args we give to
@@ -7016,8 +7057,7 @@ static int bpy_class_call(bContext *C, PointerRNA *ptr, FunctionRNA *func, Param
if (err == -1) {
PyC_Err_Format_Prefix(PyExc_RuntimeError,
"class %.200s, function %.200s: incompatible return value ",
RNA_struct_identifier(ptr->type), RNA_function_identifier(func)
);
RNA_struct_identifier(ptr->type), RNA_function_identifier(func));
}
}
else if (ret_len > 1) {
@@ -7065,10 +7105,10 @@ static int bpy_class_call(bContext *C, PointerRNA *ptr, FunctionRNA *func, Param
if (err != 0) {
ReportList *reports;
/* alert the user, else they wont know unless they see the console. */
if ( (!is_static) &&
(ptr->data) &&
(RNA_struct_is_a(ptr->type, &RNA_Operator)) &&
(is_valid_wm == (CTX_wm_manager(C) != NULL)))
if ((!is_static) &&
(ptr->data) &&
(RNA_struct_is_a(ptr->type, &RNA_Operator)) &&
(is_valid_wm == (CTX_wm_manager(C) != NULL)))
{
wmOperator *op = ptr->data;
reports = op->reports;
@@ -7106,7 +7146,7 @@ static void bpy_class_free(void *pyob_ptr)
PyErr_Clear();
#if 0 /* needs further investigation, too annoying so quiet for now */
if (G.f&G_DEBUG) {
if (G.f & G_DEBUG) {
if (self->ob_refcnt > 1) {
PyC_ObSpit("zombie class - ref should be 1", self);
}

View File

@@ -550,21 +550,21 @@ int pyrna_py_to_array(PointerRNA *ptr, PropertyRNA *prop, char *param_data,
{
int ret;
switch (RNA_property_type(prop)) {
case PROP_FLOAT:
ret = py_to_array(py, ptr, prop, param_data, py_float_check, "float", sizeof(float),
py_to_float, (RNA_SetArrayFunc)RNA_property_float_set_array, error_prefix);
break;
case PROP_INT:
ret = py_to_array(py, ptr, prop, param_data, py_int_check, "int", sizeof(int),
py_to_int, (RNA_SetArrayFunc)RNA_property_int_set_array, error_prefix);
break;
case PROP_BOOLEAN:
ret = py_to_array(py, ptr, prop, param_data, py_bool_check, "boolean", sizeof(int),
py_to_bool, (RNA_SetArrayFunc)RNA_property_boolean_set_array, error_prefix);
break;
default:
PyErr_SetString(PyExc_TypeError, "not an array type");
ret = -1;
case PROP_FLOAT:
ret = py_to_array(py, ptr, prop, param_data, py_float_check, "float", sizeof(float),
py_to_float, (RNA_SetArrayFunc)RNA_property_float_set_array, error_prefix);
break;
case PROP_INT:
ret = py_to_array(py, ptr, prop, param_data, py_int_check, "int", sizeof(int),
py_to_int, (RNA_SetArrayFunc)RNA_property_int_set_array, error_prefix);
break;
case PROP_BOOLEAN:
ret = py_to_array(py, ptr, prop, param_data, py_bool_check, "boolean", sizeof(int),
py_to_bool, (RNA_SetArrayFunc)RNA_property_boolean_set_array, error_prefix);
break;
default:
PyErr_SetString(PyExc_TypeError, "not an array type");
ret = -1;
}
return ret;
@@ -575,21 +575,21 @@ int pyrna_py_to_array_index(PointerRNA *ptr, PropertyRNA *prop, int arraydim, in
{
int ret;
switch (RNA_property_type(prop)) {
case PROP_FLOAT:
ret = py_to_array_index(py, ptr, prop, arraydim, arrayoffset, index,
py_float_check, "float", py_to_float, float_set_index, error_prefix);
break;
case PROP_INT:
ret = py_to_array_index(py, ptr, prop, arraydim, arrayoffset, index,
py_int_check, "int", py_to_int, int_set_index, error_prefix);
break;
case PROP_BOOLEAN:
ret = py_to_array_index(py, ptr, prop, arraydim, arrayoffset, index,
py_bool_check, "boolean", py_to_bool, bool_set_index, error_prefix);
break;
default:
PyErr_SetString(PyExc_TypeError, "not an array type");
ret = -1;
case PROP_FLOAT:
ret = py_to_array_index(py, ptr, prop, arraydim, arrayoffset, index,
py_float_check, "float", py_to_float, float_set_index, error_prefix);
break;
case PROP_INT:
ret = py_to_array_index(py, ptr, prop, arraydim, arrayoffset, index,
py_int_check, "int", py_to_int, int_set_index, error_prefix);
break;
case PROP_BOOLEAN:
ret = py_to_array_index(py, ptr, prop, arraydim, arrayoffset, index,
py_bool_check, "boolean", py_to_bool, bool_set_index, error_prefix);
break;
default:
PyErr_SetString(PyExc_TypeError, "not an array type");
ret = -1;
}
return ret;
@@ -600,18 +600,18 @@ PyObject *pyrna_array_index(PointerRNA *ptr, PropertyRNA *prop, int index)
PyObject *item;
switch (RNA_property_type(prop)) {
case PROP_FLOAT:
item = PyFloat_FromDouble(RNA_property_float_get_index(ptr, prop, index));
break;
case PROP_BOOLEAN:
item = PyBool_FromLong(RNA_property_boolean_get_index(ptr, prop, index));
break;
case PROP_INT:
item = PyLong_FromSsize_t(RNA_property_int_get_index(ptr, prop, index));
break;
default:
PyErr_SetString(PyExc_TypeError, "not an array type");
item = NULL;
case PROP_FLOAT:
item = PyFloat_FromDouble(RNA_property_float_get_index(ptr, prop, index));
break;
case PROP_BOOLEAN:
item = PyBool_FromLong(RNA_property_boolean_get_index(ptr, prop, index));
break;
case PROP_INT:
item = PyLong_FromSsize_t(RNA_property_int_get_index(ptr, prop, index));
break;
default:
PyErr_SetString(PyExc_TypeError, "not an array type");
item = NULL;
}
return item;

View File

@@ -137,7 +137,7 @@ PyObject *pyrna_callback_remove(BPy_StructRNA *self, PyObject *args)
ED_region_draw_cb_exit(((ARegion *)self->ptr.data)->type, handle);
}
/* dont allow reuse */
/* don't allow reuse */
PyCapsule_SetName(py_handle, RNA_CAPSULE_ID_INVALID);
Py_RETURN_NONE;

View File

@@ -54,7 +54,7 @@ parse_syntax_error(PyObject *err, PyObject **message, const char **filename,
/* new style errors. `err' is an instance */
if (! (v = PyObject_GetAttrString(err, "msg")))
if (!(v = PyObject_GetAttrString(err, "msg")))
goto finally;
*message = v;
@@ -62,7 +62,7 @@ parse_syntax_error(PyObject *err, PyObject **message, const char **filename,
goto finally;
if (v == Py_None)
*filename = NULL;
else if (! (*filename = _PyUnicode_AsString(v)))
else if (!(*filename = _PyUnicode_AsString(v)))
goto finally;
Py_DECREF(v);
@@ -131,8 +131,8 @@ void python_script_error_jump(const char *filepath, int *lineno, int *offset)
if (parse_syntax_error(value, &message, &filename, lineno, offset, &text)) {
/* python adds a '/', prefix, so check for both */
if ((BLI_path_cmp(filename, filepath) == 0) ||
((filename[0] == '\\' || filename[0] == '/') && BLI_path_cmp(filename + 1, filepath) == 0)
) {
((filename[0] == '\\' || filename[0] == '/') && BLI_path_cmp(filename + 1, filepath) == 0))
{
/* good */
}
else {

View File

@@ -77,7 +77,7 @@ static struct PyModuleDef gpumodule = {
PyMODINIT_FUNC
PyInit_gpu(void)
{
PyObject* m;
PyObject *m;
m = PyModule_Create(&gpumodule);
if (m == NULL)
@@ -155,14 +155,14 @@ PyDoc_STRVAR(GPU_export_shader_doc,
" :return: Dictionary defining the shader, uniforms and attributes.\n"
" :rtype: Dict"
);
static PyObject* GPU_export_shader(PyObject* UNUSED(self), PyObject *args, PyObject *kwds)
static PyObject *GPU_export_shader(PyObject *UNUSED(self), PyObject *args, PyObject *kwds)
{
PyObject* pyscene;
PyObject* pymat;
PyObject* result;
PyObject* dict;
PyObject* val;
PyObject* seq;
PyObject *pyscene;
PyObject *pymat;
PyObject *result;
PyObject *dict;
PyObject *val;
PyObject *seq;
int i;
Scene *scene;
@@ -174,7 +174,7 @@ static PyObject* GPU_export_shader(PyObject* UNUSED(self), PyObject *args, PyObj
static const char *kwlist[] = {"scene", "material", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwds, "OO:export_shader", (char**)(kwlist), &pyscene, &pymat))
if (!PyArg_ParseTupleAndKeywords(args, kwds, "OO:export_shader", (char **)(kwlist), &pyscene, &pymat))
return NULL;
scene = (Scene *)PyC_RNA_AsPointer(pyscene, "Scene");
@@ -202,7 +202,7 @@ static PyObject* GPU_export_shader(PyObject* UNUSED(self), PyObject *args, PyObj
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++) {
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);
@@ -230,7 +230,7 @@ static PyObject* GPU_export_shader(PyObject* UNUSED(self), PyObject *args, PyObj
Py_DECREF(seq);
seq = PyList_New(BLI_countlist(&shader->attributes));
for (i=0, attribute=shader->attributes.first; attribute; attribute=attribute->next, i++) {
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);
@@ -260,9 +260,9 @@ static PyMethodDef meth_export_shader[] = {
{"export_shader", (PyCFunction)GPU_export_shader, METH_VARARGS | METH_KEYWORDS, GPU_export_shader_doc}
};
PyObject* GPU_initPython(void)
PyObject *GPU_initPython(void)
{
PyObject* module = PyInit_gpu();
PyObject *module = PyInit_gpu();
PyModule_AddObject(module, "export_shader", (PyObject *)PyCFunction_New(meth_export_shader, NULL));
PyDict_SetItemString(PyImport_GetModuleDict(), "gpu", module);

View File

@@ -32,5 +32,5 @@
/**
* Initalizes the gpu Python module.
*/
PyObject* GPU_initPython(void);
PyObject *GPU_initPython(void);