Merged changes in the trunk up to revision 35618.
Conflicts resolved: source/blender/makesrna/RNA_types.h source/blender/makesrna/intern/rna_main_api.c
This commit is contained in:
@@ -60,10 +60,12 @@ typedef struct {
|
||||
static PyObject *bpy_lib_load(PyObject *self, PyObject *args, PyObject *kwds);
|
||||
static PyObject *bpy_lib_enter(BPy_Library *self, PyObject *args);
|
||||
static PyObject *bpy_lib_exit(BPy_Library *self, PyObject *args);
|
||||
static PyObject *bpy_lib_dir(BPy_Library *self);
|
||||
|
||||
static PyMethodDef bpy_lib_methods[] = {
|
||||
{"__enter__", (PyCFunction)bpy_lib_enter, METH_NOARGS},
|
||||
{"__exit__", (PyCFunction)bpy_lib_exit, METH_VARARGS},
|
||||
{"__dir__", (PyCFunction)bpy_lib_dir, METH_NOARGS},
|
||||
{NULL} /* sentinel */
|
||||
};
|
||||
|
||||
@@ -100,7 +102,7 @@ PyTypeObject bpy_lib_Type = {
|
||||
NULL, /* reprfunc tp_str; */
|
||||
|
||||
/* will only use these if this is a subtype of a py class */
|
||||
PyObject_GenericGetAttr, /* getattrofunc tp_getattro; */
|
||||
NULL /*PyObject_GenericGetAttr is assigned later */, /* getattrofunc tp_getattro; */
|
||||
NULL, /* setattrofunc tp_setattro; */
|
||||
|
||||
/* Functions to access object as input/output buffer */
|
||||
@@ -153,7 +155,19 @@ PyTypeObject bpy_lib_Type = {
|
||||
NULL
|
||||
};
|
||||
|
||||
|
||||
static char 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"
|
||||
;
|
||||
static PyObject *bpy_lib_load(PyObject *UNUSED(self), PyObject *args, PyObject *kwds)
|
||||
{
|
||||
static const char *kwlist[] = {"filepath", "link", "relative", NULL};
|
||||
@@ -166,8 +180,8 @@ static PyObject *bpy_lib_load(PyObject *UNUSED(self), PyObject *args, PyObject *
|
||||
|
||||
ret= PyObject_New(BPy_Library, &bpy_lib_Type);
|
||||
|
||||
BLI_strncpy(ret->relpath, filename, sizeof(BPy_Library));
|
||||
BLI_strncpy(ret->abspath, filename, sizeof(BPy_Library));
|
||||
BLI_strncpy(ret->relpath, filename, sizeof(ret->relpath));
|
||||
BLI_strncpy(ret->abspath, filename, sizeof(ret->abspath));
|
||||
BLI_path_abs(ret->abspath, G.main->name);
|
||||
|
||||
ret->blo_handle= NULL;
|
||||
@@ -306,6 +320,7 @@ static PyObject *bpy_lib_exit(BPy_Library *self, PyObject *UNUSED(args))
|
||||
/* exception raised above, XXX, this leaks some memory */
|
||||
BLO_blendhandle_close(self->blo_handle);
|
||||
self->blo_handle= NULL;
|
||||
flag_all_listbases_ids(LIB_PRE_EXISTING, 0);
|
||||
return NULL;
|
||||
}
|
||||
else {
|
||||
@@ -331,11 +346,20 @@ static PyObject *bpy_lib_exit(BPy_Library *self, PyObject *UNUSED(args))
|
||||
}
|
||||
}
|
||||
|
||||
static PyObject *bpy_lib_dir(BPy_Library *self)
|
||||
{
|
||||
return PyDict_Keys(self->dict);
|
||||
}
|
||||
|
||||
|
||||
int bpy_lib_init(PyObject *mod_par)
|
||||
{
|
||||
static PyMethodDef load_meth= {"load", (PyCFunction)bpy_lib_load, METH_STATIC|METH_VARARGS|METH_KEYWORDS};
|
||||
static PyMethodDef load_meth= {"load", (PyCFunction)bpy_lib_load, METH_STATIC|METH_VARARGS|METH_KEYWORDS, bpy_lib_load_doc};
|
||||
PyModule_AddObject(mod_par, "_library_load", PyCFunction_New(&load_meth, NULL));
|
||||
|
||||
/* some compilers dont like accessing this directly, delay assignment */
|
||||
bpy_lib_Type.tp_getattro= PyObject_GenericGetAttr;
|
||||
|
||||
if(PyType_Ready(&bpy_lib_Type) < 0)
|
||||
return -1;
|
||||
|
||||
|
||||
@@ -2967,9 +2967,15 @@ static PyObject *pyrna_struct_meta_idprop_getattro(PyObject *cls, PyObject *attr
|
||||
static int pyrna_struct_meta_idprop_setattro(PyObject *cls, PyObject *attr, PyObject *value)
|
||||
{
|
||||
StructRNA *srna= srna_from_self(cls, "StructRNA.__setattr__");
|
||||
const int is_deferred_prop= (value && pyrna_is_deferred_prop(value));
|
||||
|
||||
if(srna && !pyrna_write_check() && (is_deferred_prop || RNA_struct_type_find_property(srna, _PyUnicode_AsString(attr)))) {
|
||||
PyErr_Format(PyExc_AttributeError, "pyrna_struct_meta_idprop_setattro() can't set in readonly state '%.200s.%S'", ((PyTypeObject *)cls)->tp_name, attr);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(srna == NULL) {
|
||||
if(value && pyrna_is_deferred_prop(value)) {
|
||||
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;
|
||||
}
|
||||
@@ -2981,7 +2987,7 @@ static int pyrna_struct_meta_idprop_setattro(PyObject *cls, PyObject *attr, PyOb
|
||||
|
||||
if(value) {
|
||||
/* check if the value is a property */
|
||||
if(pyrna_is_deferred_prop(value)) {
|
||||
if(is_deferred_prop) {
|
||||
int ret= deferred_register_prop(srna, attr, value);
|
||||
if(ret == -1) {
|
||||
/* error set */
|
||||
@@ -3138,16 +3144,19 @@ static PyObject *pyrna_prop_collection_getattro(BPy_PropertyRNA *self, PyObject
|
||||
|
||||
PyObject *ret= PyObject_GenericGetAttr((PyObject *)self, pyname);
|
||||
|
||||
if(ret == NULL) {
|
||||
if(ret == NULL && name[0] != '_') { /* avoid inheriting __call__ and similar */
|
||||
/* since this is least common case, handle it last */
|
||||
PointerRNA r_ptr;
|
||||
PyObject *error_type, *error_value, *error_traceback;
|
||||
PyErr_Fetch(&error_type, &error_value, &error_traceback);
|
||||
PyErr_Clear();
|
||||
|
||||
if(RNA_property_collection_type_get(&self->ptr, self->prop, &r_ptr)) {
|
||||
PyObject *cls= pyrna_struct_Subtype(&r_ptr); /* borrows */
|
||||
PyObject *cls;
|
||||
|
||||
PyObject *error_type, *error_value, *error_traceback;
|
||||
PyErr_Fetch(&error_type, &error_value, &error_traceback);
|
||||
PyErr_Clear();
|
||||
|
||||
cls= pyrna_struct_Subtype(&r_ptr); /* borrows */
|
||||
ret= PyObject_GenericGetAttr(cls, pyname);
|
||||
/* restore the original error */
|
||||
if(ret == NULL) {
|
||||
PyErr_Restore(error_type, error_value, error_traceback);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user