Merged changes in the trunk up to revision 44797.

Conflicts resolved:
doc/python_api/sphinx_doc_gen.py
source/blender/makesdna/DNA_mesh_types.h
source/blender/makesrna/intern/rna_action.c
source/blender/makesrna/intern/rna_ID.c
source/blender/makesrna/intern/rna_mesh.c
This commit is contained in:
2012-03-10 21:56:23 +00:00
828 changed files with 28231 additions and 25725 deletions

View File

@@ -229,9 +229,9 @@ static PyObject *bpy_import_test(const char *modname)
return mod;
}
/*****************************************************************************
* Description: Creates the bpy module and adds it to sys.modules for importing
*****************************************************************************/
/******************************************************************************
* Description: Creates the bpy module and adds it to sys.modules for importing
******************************************************************************/
void BPy_init_modules(void)
{
extern BPy_StructRNA *bpy_context_module;

View File

@@ -108,6 +108,8 @@ static PyObject *make_app_info(void)
PyStructSequence_SET_ITEM(app_info, pos++, PyLong_FromLong(flag))
#define SetStrItem(str) \
PyStructSequence_SET_ITEM(app_info, pos++, PyUnicode_FromString(str))
#define SetBytesItem(str) \
PyStructSequence_SET_ITEM(app_info, pos++, PyBytes_FromString(str))
#define SetObjItem(obj) \
PyStructSequence_SET_ITEM(app_info, pos++, obj)
@@ -121,27 +123,28 @@ static PyObject *make_app_info(void)
SetStrItem(BLI_program_path());
SetObjItem(PyBool_FromLong(G.background));
/* build info */
/* build info, use bytes since we can't assume _any_ encoding:
* see patch [#30154] for issue */
#ifdef BUILD_DATE
SetStrItem(build_date);
SetStrItem(build_time);
SetStrItem(build_rev);
SetStrItem(build_platform);
SetStrItem(build_type);
SetStrItem(build_cflags);
SetStrItem(build_cxxflags);
SetStrItem(build_linkflags);
SetStrItem(build_system);
SetBytesItem(build_date);
SetBytesItem(build_time);
SetBytesItem(build_rev);
SetBytesItem(build_platform);
SetBytesItem(build_type);
SetBytesItem(build_cflags);
SetBytesItem(build_cxxflags);
SetBytesItem(build_linkflags);
SetBytesItem(build_system);
#else
SetStrItem("Unknown");
SetStrItem("Unknown");
SetStrItem("Unknown");
SetStrItem("Unknown");
SetStrItem("Unknown");
SetStrItem("Unknown");
SetStrItem("Unknown");
SetStrItem("Unknown");
SetStrItem("Unknown");
SetBytesItem("Unknown");
SetBytesItem("Unknown");
SetBytesItem("Unknown");
SetBytesItem("Unknown");
SetBytesItem("Unknown");
SetBytesItem("Unknown");
SetBytesItem("Unknown");
SetBytesItem("Unknown");
SetBytesItem("Unknown");
#endif
SetObjItem(BPY_app_ffmpeg_struct());
@@ -149,6 +152,7 @@ static PyObject *make_app_info(void)
#undef SetIntItem
#undef SetStrItem
#undef SetBytesItem
#undef SetObjItem
if (PyErr_Occurred()) {

View File

@@ -68,11 +68,11 @@ static PyStructSequence_Desc app_cb_info_desc = {
(sizeof(app_cb_info_fields) / sizeof(PyStructSequence_Field)) - 1
};
/*
#if (BLI_CB_EVT_TOT != ((sizeof(app_cb_info_fields)/sizeof(PyStructSequence_Field))))
# error "Callbacks are out of sync"
#if 0
# if (BLI_CB_EVT_TOT != ((sizeof(app_cb_info_fields)/sizeof(PyStructSequence_Field))))
# error "Callbacks are out of sync"
# endif
#endif
*/
/* --------------------------------------------------------------------------*/
/* permanent tagging code */

View File

@@ -77,7 +77,7 @@
/* for internal use, when starting and ending python scripts */
/* incase a python script triggers another python call, stop bpy_context_clear from invalidating */
/* in case a python script triggers another python call, stop bpy_context_clear from invalidating */
static int py_call_level = 0;
BPy_StructRNA *bpy_context_module = NULL; /* for fast access */
@@ -671,11 +671,11 @@ int BPY_context_member_get(bContext *C, const char *member, bContextDataResult *
PyObject *list_item = PySequence_Fast_GET_ITEM(seq_fast, i);
if (BPy_StructRNA_Check(list_item)) {
/*
#if 0
CollectionPointerLink *link = MEM_callocN(sizeof(CollectionPointerLink), "bpy_context_get");
link->ptr = ((BPy_StructRNA *)item)->ptr;
BLI_addtail(&result->list, link);
*/
#endif
ptr = &(((BPy_StructRNA *)list_item)->ptr);
CTX_data_list_add(result, ptr->id.data, ptr->type, ptr->data);
}

View File

@@ -92,5 +92,5 @@ void BPY_atexit_unregister(void)
BLI_assert(func_bpy_atregister != NULL);
atexit_func_call("unregister", func_bpy_atregister);
func_bpy_atregister = NULL; /* don't really need to set but just incase */
func_bpy_atregister = NULL; /* don't really need to set but just in case */
}

View File

@@ -257,8 +257,7 @@ static PyObject *pyop_call(PyObject *UNUSED(self), PyObject *args)
}
BKE_reports_clear(reports);
if ((reports->flag & RPT_FREE) == 0)
{
if ((reports->flag & RPT_FREE) == 0) {
MEM_freeN(reports);
}
}
@@ -434,7 +433,7 @@ static PyObject *pyop_getinstance(PyObject *UNUSED(self), PyObject *value)
op = PyMem_MALLOC(sizeof(wmOperator));
memset(op, 0, sizeof(wmOperator));
#endif
BLI_strncpy(op->idname, op->idname, sizeof(op->idname)); /* incase its needed */
BLI_strncpy(op->idname, op->idname, sizeof(op->idname)); /* in case its needed */
op->type = ot;
RNA_pointer_create(NULL, &RNA_Operator, op, &ptr);

View File

@@ -59,13 +59,13 @@ extern BPy_StructRNA *bpy_context_module;
static EnumPropertyItem property_flag_items[] = {
{PROP_HIDDEN, "HIDDEN", 0, "Hidden", ""},
{PROP_SKIP_SAVE, "SKIP_SAVE", 0, "Skip Save", ""},
{PROP_ANIMATABLE, "ANIMATABLE", 0, "Animateable", ""},
{PROP_ANIMATABLE, "ANIMATABLE", 0, "Animatable", ""},
{0, NULL, 0, NULL, NULL}};
static EnumPropertyItem property_flag_enum_items[] = {
{PROP_HIDDEN, "HIDDEN", 0, "Hidden", ""},
{PROP_SKIP_SAVE, "SKIP_SAVE", 0, "Skip Save", ""},
{PROP_ANIMATABLE, "ANIMATABLE", 0, "Animateable", ""},
{PROP_ANIMATABLE, "ANIMATABLE", 0, "Animatable", ""},
{PROP_ENUM_FLAG, "ENUM_FLAG", 0, "Enum Flag", ""},
{0, NULL, 0, NULL, NULL}};

View File

@@ -121,7 +121,7 @@ int pyrna_prop_validity_check(BPy_PropertyRNA *self)
static void pyrna_invalidate(BPy_DummyPointerRNA *self)
{
self->ptr.type = NULL; /* this is checked for validity */
self->ptr.id.data = NULL; /* should not be needed but prevent bad pointer access, just incase */
self->ptr.id.data = NULL; /* should not be needed but prevent bad pointer access, just in case */
}
#endif
@@ -1284,7 +1284,7 @@ static PyObject *pyrna_enum_to_py(PointerRNA *ptr, PropertyRNA *prop, int val)
else {
const char *ptr_name = RNA_struct_name_get_alloc(ptr, NULL, 0, NULL);
/* prefer not fail silently incase of api errors, maybe disable it later */
/* 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),
@@ -1309,11 +1309,11 @@ static PyObject *pyrna_enum_to_py(PointerRNA *ptr, PropertyRNA *prop, int val)
if (free)
MEM_freeN(enum_item);
/*
#if 0
PyErr_Format(PyExc_AttributeError,
"RNA Error: Current value \"%d\" matches no enum", val);
ret = NULL;
*/
#endif
}
}
@@ -2549,10 +2549,12 @@ static PyObject *pyrna_prop_array_subscript(BPy_PropertyArrayRNA *self, PyObject
{
PYRNA_PROP_CHECK_OBJ((BPy_PropertyRNA *)self);
/*if (PyUnicode_Check(key)) {
#if 0
if (PyUnicode_Check(key)) {
return pyrna_prop_array_subscript_str(self, _PyUnicode_AsString(key));
}
else */
else
#endif
if (PyIndex_Check(key)) {
Py_ssize_t i = PyNumber_AsSsize_t(key, PyExc_IndexError);
if (i == -1 && PyErr_Occurred())
@@ -2619,7 +2621,7 @@ static int prop_subscript_ass_array_slice(PointerRNA *ptr, PropertyRNA *prop,
if (PySequence_Fast_GET_SIZE(value) != stop-start) {
Py_DECREF(value);
PyErr_SetString(PyExc_TypeError,
"bpy_prop_array[slice] = value: resizing bpy_struct arrays isn't supported");
"bpy_prop_array[slice] = value: re-sizing bpy_struct arrays isn't supported");
return -1;
}
@@ -3359,7 +3361,7 @@ static PyObject *pyrna_struct_dir(BPy_StructRNA *self)
PYRNA_STRUCT_CHECK_OBJ(self);
/* Include this incase this instance is a subtype of a python class
/* Include this in case this instance is a subtype of a python class
* In these instances we may want to return a function or variable provided by the subtype
* */
ret = PyList_New(0);
@@ -3496,7 +3498,7 @@ static PyObject *pyrna_struct_getattro(BPy_StructRNA *self, PyObject *pyname)
name);
ret = NULL;
#endif
/* Include this incase this instance is a subtype of a python class
/* Include this in case this instance is a subtype of a python class
* In these instances we may want to return a function or variable provided by the subtype
*
* Also needed to return methods when its not a subtype
@@ -3576,14 +3578,14 @@ static int pyrna_struct_meta_idprop_setattro(PyObject *cls, PyObject *attr, PyOb
if (srna == NULL) {
/* allow setting on unregistered classes which can be registered later on */
/*
#if 0
if (value && is_deferred_prop) {
PyErr_Format(PyExc_AttributeError,
"pyrna_struct_meta_idprop_setattro() unable to get srna from class '%.200s'",
((PyTypeObject *)cls)->tp_name);
return -1;
}
*/
#endif
/* srna_from_self may set an error */
PyErr_Clear();
return PyType_Type.tp_setattro(cls, attr, value);
@@ -3693,7 +3695,7 @@ static PyObject *pyrna_prop_dir(BPy_PropertyRNA *self)
PyObject *ret;
PointerRNA r_ptr;
/* Include this incase this instance is a subtype of a python class
/* Include this in case this instance is a subtype of a python class
* In these instances we may want to return a function or variable provided by the subtype
* */
ret = PyList_New(0);
@@ -4571,14 +4573,14 @@ static PyObject *pyrna_struct_new(PyTypeObject *type, PyObject *args, PyObject *
else if (PyType_IsSubtype(Py_TYPE(base), &pyrna_struct_Type)) {
/* this almost never runs, only when using user defined subclasses of built-in object.
* this isn't common since its NOT related to registerable subclasses. eg:
>>> class MyObSubclass(bpy.types.Object):
... def test_func(self):
... print(100)
...
>>> myob = MyObSubclass(bpy.context.object)
>>> myob.test_func()
100
*
* >>> class MyObSubclass(bpy.types.Object):
* ... def test_func(self):
* ... print(100)
* ...
* >>> myob = MyObSubclass(bpy.context.object)
* >>> myob.test_func()
* 100
*
* Keep this since it could be useful.
*/
@@ -4866,7 +4868,7 @@ static PyObject *pyrna_func_call(BPy_FunctionRNA *self, PyObject *args, PyObject
}
/* for testing */
/*
#if 0
{
const char *fn;
int lineno;
@@ -4874,7 +4876,7 @@ static PyObject *pyrna_func_call(BPy_FunctionRNA *self, PyObject *args, PyObject
printf("pyrna_func_call > %.200s.%.200s : %.200s:%d\n",
RNA_struct_identifier(self_ptr->type), RNA_function_identifier(self_func), fn, lineno);
}
*/
#endif
/* include the ID pointer for pyrna_param_to_py() so we can include the
* ID pointer on return values, this only works when returned values have
@@ -5104,14 +5106,14 @@ static PyObject *pyrna_func_call(BPy_FunctionRNA *self, PyObject *args, PyObject
#ifdef DEBUG_STRING_FREE
/*
#if 0
if (PyList_GET_SIZE(string_free_ls)) {
printf("%.200s.%.200s(): has %d strings\n",
RNA_struct_identifier(self_ptr->type),
RNA_function_identifier(self_func),
(int)PyList_GET_SIZE(string_free_ls));
}
*/
#endif
Py_DECREF(string_free_ls);
#undef DEBUG_STRING_FREE
#endif
@@ -6018,10 +6020,10 @@ static PyObject* pyrna_srna_Subtype(StructRNA *srna)
* mainly for the purposing of matching the C/rna type hierarchy */
else {
/* subclass equivalents
- class myClass(myBase):
some = 'value' # or ...
- myClass = type(name='myClass', bases=(myBase,), dict={'__module__':'bpy.types'})
*/
* - class myClass(myBase):
* some = 'value' # or ...
* - myClass = type(name='myClass', bases=(myBase,), dict={'__module__':'bpy.types'})
*/
/* Assume RNA_struct_py_type_get(srna) was already checked */
PyObject *py_base = pyrna_srna_PyBase(srna);
@@ -6523,8 +6525,10 @@ static int deferred_register_prop(StructRNA *srna, PyObject *key, PyObject *item
/* Since this is a class dict, ignore args that can't be passed */
/* for testing only */
/* PyC_ObSpit("Why doesn't this work??", item);
PyErr_Print(); */
#if 0
PyC_ObSpit("Why doesn't this work??", item);
PyErr_Print();
#endif
PyErr_Clear();
}
}
@@ -6886,9 +6890,12 @@ static int bpy_class_call(bContext *C, PointerRNA *ptr, FunctionRNA *func, Param
rna_disallow_writes = TRUE;
/* 'almost' all the time calling the class isn't needed.
* We could just do...
* We could just do... */
#if 0
py_class_instance = py_srna;
Py_INCREF(py_class_instance);
#endif
/*
* This would work fine but means __init__ functions wouldnt run.
* none of blenders default scripts use __init__ but its nice to call it
* for general correctness. just to note why this is here when it could be safely removed.
@@ -7230,14 +7237,14 @@ static PyObject *pyrna_register_class(PyObject *UNUSED(self), PyObject *py_class
return NULL;
/* fails in cases, cant use this check but would like to :| */
/*
#if 0
if (RNA_struct_py_type_get(srna)) {
PyErr_Format(PyExc_ValueError,
"register_class(...): %.200s's parent class %.200s is already registered, this is not allowed",
((PyTypeObject *)py_class)->tp_name, RNA_struct_identifier(srna));
return NULL;
}
*/
#endif
/* check that we have a register callback for this type */
reg = RNA_struct_register(srna);
@@ -7271,7 +7278,7 @@ static PyObject *pyrna_register_class(PyObject *UNUSED(self), PyObject *py_class
pyrna_subtype_set_rna(py_class, srna_new); /* takes a ref to py_class */
/* old srna still references us, keep the check incase registering somehow can free it */
/* old srna still references us, keep the check in case registering somehow can free it */
if (RNA_struct_py_type_get(srna)) {
RNA_struct_py_type_set(srna, NULL);
// Py_DECREF(py_class); // should be able to do this XXX since the old rna adds a new ref.
@@ -7352,11 +7359,13 @@ static PyObject *pyrna_unregister_class(PyObject *UNUSED(self), PyObject *py_cla
return NULL;
}
/*if (PyDict_GetItem(((PyTypeObject *)py_class)->tp_dict, bpy_intern_str_bl_rna) == NULL) {
#if 0
if (PyDict_GetItem(((PyTypeObject *)py_class)->tp_dict, bpy_intern_str_bl_rna) == NULL) {
PWM_cursor_wait(0);
PyErr_SetString(PyExc_ValueError, "unregister_class(): not a registered as a subclass");
return NULL;
}*/
}
#endif
if (!pyrna_write_check()) {
PyErr_Format(PyExc_RuntimeError,

View File

@@ -50,17 +50,17 @@ typedef void (*RNA_SetArrayFunc)(PointerRNA *, PropertyRNA *, const char *);
typedef void (*RNA_SetIndexFunc)(PointerRNA *, PropertyRNA *, int index, void *);
/*
arr[3][4][5]
0 1 2 <- dimension index
*/
* arr[3][4][5]
* 0 1 2 <- dimension index
*/
/*
arr[2] = x
py_to_array_index(arraydim=0, arrayoffset=0, index=2)
validate_array(lvalue_dim=0)
... make real index ...
*/
* arr[2] = x
*
* py_to_array_index(arraydim=0, arrayoffset=0, index=2)
* validate_array(lvalue_dim=0)
* ... make real index ...
*/
/* 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. */
@@ -101,8 +101,8 @@ static int validate_array_type(PyObject *seq, int dim, int totdim, int dimsize[]
* dim = 0 */
else if (PySequence_Size(item) != dimsize[dim + 1]) {
/* BLI_snprintf(error_str, error_str_size,
"sequences of dimension %d should contain %d items",
(int)dim + 1, (int)dimsize[dim + 1]); */
* "sequences of dimension %d should contain %d items",
* (int)dim + 1, (int)dimsize[dim + 1]); */
PyErr_Format(PyExc_ValueError, "%s sequences of dimension %d should contain %d items",
error_prefix, (int)dim + 1, (int)dimsize[dim + 1]);
ok = 0;
@@ -205,8 +205,8 @@ static int validate_array_length(PyObject *rvalue, PointerRNA *ptr, PropertyRNA
/* length is flexible */
if (!RNA_property_dynamic_array_set_length(ptr, prop, tot)) {
/* BLI_snprintf(error_str, error_str_size,
"%s.%s: array length cannot be changed to %d",
RNA_struct_identifier(ptr->type), RNA_property_identifier(prop), tot); */
* "%s.%s: array length cannot be changed to %d",
* RNA_struct_identifier(ptr->type), RNA_property_identifier(prop), tot); */
PyErr_Format(PyExc_ValueError, "%s %s.%s: array length cannot be changed to %d",
error_prefix, RNA_struct_identifier(ptr->type), RNA_property_identifier(prop), tot);
return -1;
@@ -232,18 +232,18 @@ static int validate_array_length(PyObject *rvalue, PointerRNA *ptr, PropertyRNA
len = 1;
/* arr[3][4][5]
arr[2] = x
dimsize = {4, 5}
dimsize[1] = 4
dimsize[2] = 5
lvalue_dim = 0, totdim = 3
arr[2][3] = x
lvalue_dim = 1
arr[2][3][4] = x
lvalue_dim = 2 */
*
* arr[2] = x
* dimsize = {4, 5}
* dimsize[1] = 4
* dimsize[2] = 5
* lvalue_dim = 0, totdim = 3
*
* arr[2][3] = x
* lvalue_dim = 1
*
* arr[2][3][4] = x
* lvalue_dim = 2 */
for (i = lvalue_dim; i < totdim; i++)
len *= dimsize[i];
}
@@ -462,12 +462,12 @@ static int py_to_array_index(PyObject *py, PointerRNA *ptr, PropertyRNA *prop,
/* convert index */
/* arr[3][4][5]
arr[2] = x
lvalue_dim = 0, index = 0 + 2 * 4 * 5
arr[2][3] = x
lvalue_dim = 1, index = 40 + 3 * 5 */
*
* arr[2] = x
* lvalue_dim = 0, index = 0 + 2 * 4 * 5
*
* arr[2][3] = x
* lvalue_dim = 1, index = 40 + 3 * 5 */
lvalue_dim++;
@@ -677,12 +677,12 @@ PyObject *pyrna_py_from_array_index(BPy_PropertyArrayRNA *self, PointerRNA *ptr,
ret->arraydim = arraydim + 1;
/* arr[3][4][5]
x = arr[2]
index = 0 + 2 * 4 * 5
x = arr[2][3]
index = offset + 3 * 5 */
*
* x = arr[2]
* index = 0 + 2 * 4 * 5
*
* x = arr[2][3]
* index = offset + 3 * 5 */
for (i = arraydim + 1; i < totdim; i++)
index *= dimsize[i];

View File

@@ -29,6 +29,9 @@
#include <Python.h>
#include <frameobject.h>
#include "BLI_path_util.h"
#include "BLI_string.h"
#include "bpy_traceback.h"
static const char *traceback_filepath(PyTracebackObject *tb, PyObject **coerce)
@@ -127,8 +130,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 ((strcmp(filename, filepath) == 0) ||
((filename[0] == '\\' || filename[0] == '/') && strcmp(filename + 1, filepath) == 0)
if ((BLI_path_cmp(filename, filepath) == 0) ||
((filename[0] == '\\' || filename[0] == '/') && BLI_path_cmp(filename + 1, filepath) == 0)
) {
/* good */
}
@@ -152,7 +155,7 @@ void python_script_error_jump(const char *filepath, int *lineno, int *offset)
{
PyObject *coerce;
const char *tb_filepath = traceback_filepath(tb, &coerce);
const int match = strcmp(tb_filepath, filepath) != 0;
const int match = BLI_path_cmp(tb_filepath, filepath) != 0;
Py_DECREF(coerce);
if (match) {

View File

@@ -70,7 +70,7 @@ static struct PyModuleDef gpumodule = {
"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. */
* or -1 if the module keeps state in global variables. */
NULL, NULL, NULL, NULL, NULL
};