Merged changes in the trunk up to revision 25149.
After the merge operation, running the diff command showed that the branch had a significant amount of differences from the trunk revision 25149. I had no idea where these differences came from. To resolve them and make the branch up-to-date, I just copied the following files from the trunk: release/scripts/io/import_anim_bvh.py release/scripts/io/import_scene_obj.py release/scripts/ui/space_image.py release/scripts/ui/space_view3d.py source/blender/blenkernel/intern/object.c source/blender/blenlib/BLI_math_base.h source/blender/blenlib/intern/math_base.c source/blender/editors/animation/anim_markers.c source/blender/editors/armature/armature_intern.h source/blender/editors/armature/armature_ops.c source/blender/editors/armature/editarmature.c source/blender/editors/curve/curve_intern.h source/blender/editors/curve/curve_ops.c source/blender/editors/include/ED_mesh.h source/blender/editors/include/ED_object.h source/blender/editors/include/ED_particle.h source/blender/editors/mesh/editface.c source/blender/editors/mesh/editmesh_mods.c source/blender/editors/mesh/mesh_intern.h source/blender/editors/mesh/mesh_ops.c source/blender/editors/metaball/mball_edit.c source/blender/editors/metaball/mball_intern.h source/blender/editors/metaball/mball_ops.c source/blender/editors/object/object_intern.h source/blender/editors/object/object_lattice.c source/blender/editors/object/object_ops.c source/blender/editors/object/object_select.c source/blender/editors/physics/particle_edit.c source/blender/editors/physics/physics_intern.h source/blender/editors/physics/physics_ops.c source/blender/editors/sculpt_paint/paint_intern.h source/blender/editors/sculpt_paint/paint_ops.c source/blender/editors/sculpt_paint/paint_utils.c source/blender/editors/space_view3d/view3d_select.c source/blender/editors/uvedit/uvedit_ops.c source/blender/windowmanager/WM_api.h source/blender/windowmanager/intern/wm_operators.c
This commit is contained in:
@@ -48,6 +48,7 @@ static PyObject *Vector_Negate( VectorObject * self );
|
||||
static PyObject *Vector_Resize2D( VectorObject * self );
|
||||
static PyObject *Vector_Resize3D( VectorObject * self );
|
||||
static PyObject *Vector_Resize4D( VectorObject * self );
|
||||
static PyObject *Vector_ToTuple( VectorObject * self, PyObject *value );
|
||||
static PyObject *Vector_ToTrackQuat( VectorObject * self, PyObject * args );
|
||||
static PyObject *Vector_Reflect( VectorObject *self, VectorObject *value );
|
||||
static PyObject *Vector_Cross( VectorObject * self, VectorObject * value );
|
||||
@@ -61,6 +62,7 @@ static struct PyMethodDef Vector_methods[] = {
|
||||
{"resize2D", (PyCFunction) Vector_Resize2D, METH_NOARGS, NULL},
|
||||
{"resize3D", (PyCFunction) Vector_Resize3D, METH_NOARGS, NULL},
|
||||
{"resize4D", (PyCFunction) Vector_Resize4D, METH_NOARGS, NULL},
|
||||
{"toTuple", (PyCFunction) Vector_ToTuple, METH_O, NULL},
|
||||
{"toTrackQuat", ( PyCFunction ) Vector_ToTrackQuat, METH_VARARGS, NULL},
|
||||
{"reflect", ( PyCFunction ) Vector_Reflect, METH_O, NULL},
|
||||
{"cross", ( PyCFunction ) Vector_Cross, METH_O, NULL},
|
||||
@@ -236,6 +238,33 @@ static PyObject *Vector_Resize4D(VectorObject * self)
|
||||
Py_INCREF(self);
|
||||
return (PyObject*)self;
|
||||
}
|
||||
|
||||
/*----------------------------Vector.resize4D() ------------------
|
||||
resize the vector to x,y,z,w */
|
||||
static PyObject *Vector_ToTuple(VectorObject * self, PyObject *value)
|
||||
{
|
||||
int ndigits= PyLong_AsSsize_t(value);
|
||||
int x;
|
||||
|
||||
PyObject *ret;
|
||||
|
||||
if(ndigits > 22 || ndigits < 0) { /* accounts for non ints */
|
||||
PyErr_SetString(PyExc_TypeError, "vector.key(ndigits): ndigits must be between 0 and 21");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(!BaseMath_ReadCallback(self))
|
||||
return NULL;
|
||||
|
||||
ret= PyTuple_New(self->size);
|
||||
|
||||
for(x = 0; x < self->size; x++) {
|
||||
PyTuple_SET_ITEM(ret, x, PyFloat_FromDouble(double_round((double)self->vec[x], ndigits)));
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*----------------------------Vector.toTrackQuat(track, up) ----------------------
|
||||
extract a quaternion from the vector and the track and up axis */
|
||||
static PyObject *Vector_ToTrackQuat( VectorObject * self, PyObject * args )
|
||||
|
||||
@@ -60,7 +60,7 @@ static PyObject *pyop_call( PyObject * self, PyObject * args)
|
||||
if (!PyArg_ParseTuple(args, "sO|O!i:_bpy.ops.call", &opname, &context_dict, &PyDict_Type, &kw, &context))
|
||||
return NULL;
|
||||
|
||||
ot= WM_operatortype_find(opname, TRUE);
|
||||
ot= WM_operatortype_exists(opname);
|
||||
|
||||
if (ot == NULL) {
|
||||
PyErr_Format( PyExc_SystemError, "_bpy.ops.call: operator \"%s\"could not be found", opname);
|
||||
@@ -245,6 +245,8 @@ PyObject *BPY_operator_module( void )
|
||||
static PyMethodDef pyop_dir_meth = {"dir", (PyCFunction) pyop_dir, METH_NOARGS, NULL};
|
||||
static PyMethodDef pyop_getrna_meth = {"get_rna", (PyCFunction) pyop_getrna, METH_O, NULL};
|
||||
static PyMethodDef pyop_add_meth = {"add", (PyCFunction) PYOP_wrap_add, METH_O, NULL};
|
||||
static PyMethodDef pyop_add_macro_meth ={"add_macro", (PyCFunction) PYOP_wrap_add_macro, METH_O, NULL};
|
||||
static PyMethodDef pyop_macro_def_meth ={"macro_define", (PyCFunction) PYOP_wrap_macro_define, METH_VARARGS, NULL};
|
||||
static PyMethodDef pyop_remove_meth = {"remove", (PyCFunction) PYOP_wrap_remove, METH_O, NULL};
|
||||
|
||||
PyObject *submodule = PyModule_New("_bpy.ops");
|
||||
@@ -255,6 +257,8 @@ PyObject *BPY_operator_module( void )
|
||||
PyModule_AddObject( submodule, "dir", PyCFunction_New(&pyop_dir_meth, NULL) );
|
||||
PyModule_AddObject( submodule, "get_rna", PyCFunction_New(&pyop_getrna_meth, NULL) );
|
||||
PyModule_AddObject( submodule, "add", PyCFunction_New(&pyop_add_meth, NULL) );
|
||||
PyModule_AddObject( submodule, "add_macro", PyCFunction_New(&pyop_add_macro_meth, NULL) );
|
||||
PyModule_AddObject( submodule, "macro_define",PyCFunction_New(&pyop_macro_def_meth, NULL) );
|
||||
PyModule_AddObject( submodule, "remove", PyCFunction_New(&pyop_remove_meth, NULL) );
|
||||
|
||||
return submodule;
|
||||
|
||||
@@ -342,6 +342,80 @@ void PYTHON_OT_wrapper(wmOperatorType *ot, void *userdata)
|
||||
}
|
||||
}
|
||||
|
||||
void PYTHON_OT_MACRO_wrapper(wmOperatorType *ot, void *userdata)
|
||||
{
|
||||
PyObject *py_class = (PyObject *)userdata;
|
||||
PyObject *item;
|
||||
|
||||
/* identifiers */
|
||||
item= PyObject_GetAttrString(py_class, PYOP_ATTR_IDNAME_BL);
|
||||
ot->idname= _PyUnicode_AsString(item);
|
||||
Py_DECREF(item);
|
||||
|
||||
item= PyObject_GetAttrString(py_class, PYOP_ATTR_UINAME);
|
||||
if (item) {
|
||||
ot->name= _PyUnicode_AsString(item);
|
||||
Py_DECREF(item);
|
||||
}
|
||||
else {
|
||||
ot->name= ot->idname;
|
||||
PyErr_Clear();
|
||||
}
|
||||
|
||||
item= PyObject_GetAttrString(py_class, PYOP_ATTR_DESCRIPTION);
|
||||
ot->description= (item && PyUnicode_Check(item)) ? _PyUnicode_AsString(item):"undocumented python operator";
|
||||
Py_XDECREF(item);
|
||||
|
||||
if (PyObject_HasAttrString(py_class, "poll"))
|
||||
ot->pyop_poll= PYTHON_OT_poll;
|
||||
if (PyObject_HasAttrString(py_class, "draw"))
|
||||
ot->ui= PYTHON_OT_draw;
|
||||
|
||||
ot->pyop_data= userdata;
|
||||
|
||||
/* flags */
|
||||
ot->flag= OPTYPE_MACRO; /* macro at least */
|
||||
|
||||
item= PyObject_GetAttrString(py_class, PYOP_ATTR_REGISTER);
|
||||
if (item) {
|
||||
ot->flag |= PyObject_IsTrue(item)!=0 ? OPTYPE_REGISTER:0;
|
||||
Py_DECREF(item);
|
||||
}
|
||||
else {
|
||||
PyErr_Clear();
|
||||
}
|
||||
item= PyObject_GetAttrString(py_class, PYOP_ATTR_UNDO);
|
||||
if (item) {
|
||||
ot->flag |= PyObject_IsTrue(item)!=0 ? OPTYPE_UNDO:0;
|
||||
Py_DECREF(item);
|
||||
}
|
||||
else {
|
||||
PyErr_Clear();
|
||||
}
|
||||
|
||||
/* Can't use this because it returns a dict proxy
|
||||
*
|
||||
* item= PyObject_GetAttrString(py_class, "__dict__");
|
||||
*/
|
||||
item= ((PyTypeObject*)py_class)->tp_dict;
|
||||
if(item) {
|
||||
/* only call this so pyrna_deferred_register_props gives a useful error
|
||||
* WM_operatortype_append_macro_ptr will call RNA_def_struct_identifier
|
||||
* later */
|
||||
RNA_def_struct_identifier(ot->srna, ot->idname);
|
||||
|
||||
if(pyrna_deferred_register_props(ot->srna, item)!=0) {
|
||||
/* failed to register operator props */
|
||||
PyErr_Print();
|
||||
PyErr_Clear();
|
||||
|
||||
}
|
||||
}
|
||||
else {
|
||||
PyErr_Clear();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* pyOperators - Operators defined IN Python */
|
||||
PyObject *PYOP_wrap_add(PyObject *self, PyObject *py_class)
|
||||
@@ -407,6 +481,116 @@ PyObject *PYOP_wrap_add(PyObject *self, PyObject *py_class)
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
/* pyOperators - Macro Operators defined IN Python */
|
||||
PyObject *PYOP_wrap_add_macro(PyObject *self, PyObject *py_class)
|
||||
{
|
||||
PyObject *base_class, *item;
|
||||
wmOperatorType *ot;
|
||||
|
||||
|
||||
char *idname= NULL;
|
||||
char idname_bl[OP_MAX_TYPENAME]; /* converted to blender syntax */
|
||||
|
||||
static struct BPY_class_attr_check pyop_class_attr_values[]= {
|
||||
{PYOP_ATTR_IDNAME, 's', -1, OP_MAX_TYPENAME-3, 0}, /* -3 because a.b -> A_OT_b */
|
||||
{PYOP_ATTR_UINAME, 's', -1,-1, BPY_CLASS_ATTR_OPTIONAL},
|
||||
{PYOP_ATTR_DESCRIPTION, 's', -1,-1, BPY_CLASS_ATTR_NONE_OK},
|
||||
{"poll", 'f', 2, -1, BPY_CLASS_ATTR_OPTIONAL},
|
||||
{"draw", 'f', 2, -1, BPY_CLASS_ATTR_OPTIONAL},
|
||||
{NULL, 0, 0, 0}
|
||||
};
|
||||
|
||||
//PyObject bpy_mod= PyDict_GetItemString(PyEval_GetGlobals(), "bpy");
|
||||
PyObject *bpy_mod= PyImport_ImportModuleLevel("bpy", NULL, NULL, NULL, 0);
|
||||
base_class = PyObject_GetAttrStringArgs(bpy_mod, 2, "types", "Macro");
|
||||
Py_DECREF(bpy_mod);
|
||||
|
||||
if(BPY_class_validate("Macro", py_class, base_class, pyop_class_attr_values, NULL) < 0) {
|
||||
return NULL; /* BPY_class_validate sets the error */
|
||||
}
|
||||
Py_DECREF(base_class);
|
||||
|
||||
/* class name is used for operator ID - this can be changed later if we want */
|
||||
item= PyObject_GetAttrString(py_class, PYOP_ATTR_IDNAME);
|
||||
idname = _PyUnicode_AsString(item);
|
||||
|
||||
|
||||
/* annoying conversion! */
|
||||
WM_operator_bl_idname(idname_bl, idname);
|
||||
Py_DECREF(item);
|
||||
|
||||
item= PyUnicode_FromString(idname_bl);
|
||||
PyObject_SetAttrString(py_class, PYOP_ATTR_IDNAME_BL, item);
|
||||
idname = _PyUnicode_AsString(item);
|
||||
Py_DECREF(item);
|
||||
/* end annoying conversion! */
|
||||
|
||||
|
||||
/* remove if it already exists */
|
||||
if ((ot=WM_operatortype_exists(idname))) {
|
||||
if(ot->pyop_data) {
|
||||
Py_XDECREF((PyObject*)ot->pyop_data);
|
||||
}
|
||||
WM_operatortype_remove(idname);
|
||||
}
|
||||
|
||||
Py_INCREF(py_class);
|
||||
WM_operatortype_append_macro_ptr(PYTHON_OT_MACRO_wrapper, py_class);
|
||||
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
PyObject *PYOP_wrap_macro_define(PyObject *self, PyObject *args)
|
||||
{
|
||||
wmOperatorType *ot;
|
||||
wmOperatorTypeMacro *otmacro;
|
||||
PyObject *macro;
|
||||
PyObject *item;
|
||||
PointerRNA ptr_otmacro;
|
||||
|
||||
char *opname;
|
||||
char *macroname;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "Os:_bpy.ops.macro_define", ¯o, &opname))
|
||||
return NULL;
|
||||
|
||||
if (WM_operatortype_exists(opname) == NULL) {
|
||||
PyErr_Format(PyExc_ValueError, "Macro Define: '%s' is not a valid operator id", opname);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* identifiers */
|
||||
item= PyObject_GetAttrString(macro, PYOP_ATTR_IDNAME_BL);
|
||||
|
||||
if (!item) {
|
||||
item= PyObject_GetAttrString(macro, PYOP_ATTR_IDNAME);
|
||||
|
||||
if (!item) {
|
||||
PyErr_Format(PyExc_ValueError, "Macro Define: not a valid Macro class");
|
||||
} else {
|
||||
macroname= _PyUnicode_AsString(item);
|
||||
PyErr_Format(PyExc_ValueError, "Macro Define: '%s' hasn't been registered yet", macroname);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
macroname= _PyUnicode_AsString(item);
|
||||
|
||||
ot = WM_operatortype_exists(macroname);
|
||||
|
||||
if (!ot) {
|
||||
PyErr_Format(PyExc_ValueError, "Macro Define: '%s' is not a valid macro or hasn't been registered yet", macroname);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
otmacro = WM_operatortype_macro_define(ot, opname);
|
||||
|
||||
RNA_pointer_create(NULL, &RNA_OperatorTypeMacro, otmacro, &ptr_otmacro);
|
||||
|
||||
return pyrna_struct_CreatePyObject(&ptr_otmacro);
|
||||
}
|
||||
|
||||
|
||||
PyObject *PYOP_wrap_remove(PyObject *self, PyObject *value)
|
||||
{
|
||||
PyObject *py_class;
|
||||
|
||||
@@ -29,6 +29,8 @@
|
||||
|
||||
/* these are used for operator methods, used by bpy_operator.c */
|
||||
PyObject *PYOP_wrap_add(PyObject *self, PyObject *args);
|
||||
PyObject *PYOP_wrap_add_macro(PyObject *self, PyObject *args);
|
||||
PyObject *PYOP_wrap_macro_define(PyObject *self, PyObject *args);
|
||||
PyObject *PYOP_wrap_remove(PyObject *self, PyObject *args);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -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)) {
|
||||
@@ -2983,13 +2986,18 @@ static PyObject* pyrna_srna_ExternalType(StructRNA *srna)
|
||||
if(newclass) {
|
||||
PyObject *base_compare= pyrna_srna_PyBase(srna);
|
||||
PyObject *bases= PyObject_GetAttrString(newclass, "__bases__");
|
||||
//PyObject *slots= PyObject_GetAttrString(newclass, "__slots__"); // cant do this because it gets superclasses values!
|
||||
PyObject *slots = PyDict_GetItemString(((PyTypeObject *)newclass)->tp_dict, "__slots__");
|
||||
|
||||
if(PyTuple_GET_SIZE(bases)) {
|
||||
if(slots==NULL) {
|
||||
fprintf(stderr, "pyrna_srna_ExternalType: expected class '%s' to have __slots__ defined\n\nSee bpy_types.py\n", idname);
|
||||
newclass= NULL;
|
||||
}
|
||||
else if(PyTuple_GET_SIZE(bases)) {
|
||||
PyObject *base= PyTuple_GET_ITEM(bases, 0);
|
||||
|
||||
if(base_compare != base) {
|
||||
PyLineSpit();
|
||||
fprintf(stderr, "pyrna_srna_ExternalType: incorrect subclassing of SRNA '%s'\n", idname);
|
||||
fprintf(stderr, "pyrna_srna_ExternalType: incorrect subclassing of SRNA '%s'\nSee bpy_types.py\n", idname);
|
||||
PyObSpit("Expected! ", base_compare);
|
||||
newclass= NULL;
|
||||
}
|
||||
@@ -3032,13 +3040,12 @@ static PyObject* pyrna_srna_Subtype(StructRNA *srna)
|
||||
if(!descr) descr= "(no docs)";
|
||||
|
||||
/* always use O not N when calling, N causes refcount errors */
|
||||
newclass = PyObject_CallFunction( (PyObject*)&PyType_Type, "s(O){ssss}", idname, py_base, "__module__","bpy.types", "__doc__",descr);
|
||||
newclass = PyObject_CallFunction( (PyObject*)&PyType_Type, "s(O){sssss()}", idname, py_base, "__module__","bpy.types", "__doc__",descr, "__slots__");
|
||||
/* newclass will now have 2 ref's, ???, probably 1 is internal since decrefing here segfaults */
|
||||
|
||||
/* PyObSpit("new class ref", newclass); */
|
||||
|
||||
if (newclass) {
|
||||
|
||||
/* srna owns one, and the other is owned by the caller */
|
||||
pyrna_subtype_set_rna(newclass, srna);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user