diff options
author | Campbell Barton <ideasman42@gmail.com> | 2009-12-04 00:53:01 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2009-12-04 00:53:01 +0300 |
commit | 3b0e182f716b2541fc77fe3b4bac18a529143c29 (patch) | |
tree | dfb6580ba524446ea3c237d488e0b9a519c3135a /source/blender/python | |
parent | a4d8c4a7452669d56a7b7a21b50f96f00d783e0e (diff) |
- property decorators for setting attributes didnt work, hack to prevent every instance of an BPyStructRNA to have its own dictionary, set the tp_dictoffset to 0. attempted to use __slots__ but this doesnt work for some reason.
- made bone.length writable
Diffstat (limited to 'source/blender/python')
-rw-r--r-- | source/blender/python/intern/bpy_rna.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index fd5e1ddf75c..e657cfc79e2 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -1738,19 +1738,22 @@ static int pyrna_struct_setattro( BPy_StructRNA *self, PyObject *pyname, PyObjec PropertyRNA *prop = RNA_struct_find_property(&self->ptr, name); if (prop==NULL) { + return PyObject_GenericSetAttr((PyObject *)self, pyname, value); +#if 0 // XXX - This currently allows anything to be assigned to an rna prop, need to see how this should be used // but for now it makes porting scripts confusing since it fails silently. // edit: allowing this for setting classes internal attributes. // edit: allow this for any attribute that alredy exists as a python attr if ( (name[0]=='_' /* || pyrna_struct_pydict_contains(self, pyname) */ ) && !BPy_StructRNA_CheckExact(self) && - PyObject_GenericSetAttr((PyObject *)self, pyname, value) >= 0) { + return 0; } else { PyErr_Format( PyExc_AttributeError, "StructRNA - Attribute \"%.200s\" not found", name); return -1; } +#endif } if (!RNA_property_editable(&self->ptr, prop)) { @@ -2984,6 +2987,9 @@ static PyObject* pyrna_srna_ExternalType(StructRNA *srna) PyObject *base_compare= pyrna_srna_PyBase(srna); PyObject *bases= PyObject_GetAttrString(newclass, "__bases__"); + // XXX - highly dodgy!, this stops blender from creating __dict__ in instances + ((PyTypeObject *)newclass)->tp_dictoffset = 0; + if(PyTuple_GET_SIZE(bases)) { PyObject *base= PyTuple_GET_ITEM(bases, 0); @@ -3039,6 +3045,9 @@ static PyObject* pyrna_srna_Subtype(StructRNA *srna) if (newclass) { + // XXX - highly dodgy!, this stops blender from creating __dict__ in instances + ((PyTypeObject *)newclass)->tp_dictoffset = 0; + /* srna owns one, and the other is owned by the caller */ pyrna_subtype_set_rna(newclass, srna); |