Merged changes in the trunk up to revision 54421.
Conflicts resolved: release/datafiles/startup.blend release/scripts/startup/bl_ui/properties_render.py source/blender/SConscript source/blender/blenloader/intern/readfile.c
This commit is contained in:
@@ -419,6 +419,14 @@ static PyObject *bpy_bmedge_is_manifold_get(BPy_BMEdge *self)
|
||||
return PyBool_FromLong(BM_edge_is_manifold(self->e));
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(bpy_bmedge_is_contiguous_doc,
|
||||
"True when this edge is manifold, between two faces with the same winding (read-only).\n\n:type: boolean"
|
||||
);
|
||||
static PyObject *bpy_bmedge_is_contiguous_get(BPy_BMEdge *self)
|
||||
{
|
||||
BPY_BM_CHECK_OBJ(self);
|
||||
return PyBool_FromLong(BM_edge_is_contiguous(self->e));
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(bpy_bmedge_is_wire_doc,
|
||||
"True when this edge is not connected to any faces (read-only).\n\n:type: boolean"
|
||||
@@ -566,6 +574,15 @@ static PyObject *bpy_bmloop_link_loop_radial_prev_get(BPy_BMLoop *self)
|
||||
return BPy_BMLoop_CreatePyObject(self->bm, self->l->radial_prev);
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(bpy_bm_is_convex_doc,
|
||||
"True when this loop is at the convex corner of a face, depends on a valid face normal (read-only).\n\n:type: :class:`BMLoop`"
|
||||
);
|
||||
static PyObject *bpy_bm_is_convex_get(BPy_BMLoop *self)
|
||||
{
|
||||
BPY_BM_CHECK_OBJ(self);
|
||||
return PyBool_FromLong(BM_loop_is_convex(self->l));
|
||||
}
|
||||
|
||||
/* ElemSeq
|
||||
* ^^^^^^^ */
|
||||
|
||||
@@ -680,10 +697,11 @@ static PyGetSetDef bpy_bmedge_getseters[] = {
|
||||
{(char *)"link_loops", (getter)bpy_bmelemseq_elem_get, (setter)NULL, (char *)bpy_bmedge_link_loops_doc, (void *)BM_LOOPS_OF_EDGE},
|
||||
|
||||
/* readonly checks */
|
||||
{(char *)"is_manifold", (getter)bpy_bmedge_is_manifold_get, (setter)NULL, (char *)bpy_bmedge_is_manifold_doc, NULL},
|
||||
{(char *)"is_wire", (getter)bpy_bmedge_is_wire_get, (setter)NULL, (char *)bpy_bmedge_is_wire_doc, NULL},
|
||||
{(char *)"is_manifold", (getter)bpy_bmedge_is_manifold_get, (setter)NULL, (char *)bpy_bmedge_is_manifold_doc, NULL},
|
||||
{(char *)"is_contiguous", (getter)bpy_bmedge_is_contiguous_get, (setter)NULL, (char *)bpy_bmedge_is_contiguous_doc, NULL},
|
||||
{(char *)"is_wire", (getter)bpy_bmedge_is_wire_get, (setter)NULL, (char *)bpy_bmedge_is_wire_doc, NULL},
|
||||
{(char *)"is_boundary", (getter)bpy_bmedge_is_boundary_get, (setter)NULL, (char *)bpy_bmedge_is_boundary_doc, NULL},
|
||||
{(char *)"is_valid", (getter)bpy_bm_is_valid_get, (setter)NULL, (char *)bpy_bm_is_valid_doc, NULL},
|
||||
{(char *)"is_valid", (getter)bpy_bm_is_valid_get, (setter)NULL, (char *)bpy_bm_is_valid_doc, NULL},
|
||||
|
||||
{NULL, NULL, NULL, NULL, NULL} /* Sentinel */
|
||||
};
|
||||
@@ -736,7 +754,8 @@ static PyGetSetDef bpy_bmloop_getseters[] = {
|
||||
{(char *)"link_loop_radial_prev", (getter)bpy_bmloop_link_loop_radial_prev_get, (setter)NULL, (char *)bpy_bmloop_link_loop_radial_prev_doc, NULL},
|
||||
|
||||
/* readonly checks */
|
||||
{(char *)"is_valid", (getter)bpy_bm_is_valid_get, (setter)NULL, (char *)bpy_bm_is_valid_doc, NULL},
|
||||
{(char *)"is_convex", (getter)bpy_bm_is_convex_get, (setter)NULL, (char *)bpy_bm_is_convex_doc, NULL},
|
||||
{(char *)"is_valid", (getter)bpy_bm_is_valid_get, (setter)NULL, (char *)bpy_bm_is_valid_doc, NULL},
|
||||
|
||||
{NULL, NULL, NULL, NULL, NULL} /* Sentinel */
|
||||
};
|
||||
|
||||
@@ -1454,6 +1454,8 @@ static PyObject *BPyInit_idprop_types(void)
|
||||
|
||||
submodule = PyModule_Create(&IDProp_types_module_def);
|
||||
|
||||
IDProp_Init_Types();
|
||||
|
||||
#define MODULE_TYPE_ADD(s, t) \
|
||||
PyModule_AddObject(s, t.tp_name, (PyObject *)&t); Py_INCREF((PyObject *)&t)
|
||||
|
||||
@@ -1497,7 +1499,7 @@ PyObject *BPyInit_idprop(void)
|
||||
|
||||
mod = PyModule_Create(&IDProp_module_def);
|
||||
|
||||
/* bmesh.types */
|
||||
/* idprop.types */
|
||||
PyModule_AddObject(mod, "types", (submodule = BPyInit_idprop_types()));
|
||||
PyDict_SetItemString(sys_modules, PyModule_GetName(submodule), submodule);
|
||||
Py_INCREF(submodule);
|
||||
|
||||
@@ -310,11 +310,33 @@ void BPY_python_start(int argc, const char **argv)
|
||||
(void)argv;
|
||||
|
||||
/* must run before python initializes */
|
||||
PyImport_ExtendInittab(bpy_internal_modules);
|
||||
/* broken in py3.3, load explicitly below */
|
||||
// PyImport_ExtendInittab(bpy_internal_modules);
|
||||
#endif
|
||||
|
||||
bpy_intern_string_init();
|
||||
|
||||
|
||||
#ifdef WITH_PYTHON_MODULE
|
||||
{
|
||||
/* Manually load all modules */
|
||||
struct _inittab *inittab_item;
|
||||
PyObject *sys_modules = PyImport_GetModuleDict();
|
||||
|
||||
for (inittab_item = bpy_internal_modules; inittab_item->name; inittab_item++) {
|
||||
PyObject *mod = inittab_item->initfunc();
|
||||
if (mod) {
|
||||
PyDict_SetItemString(sys_modules, inittab_item->name, mod);
|
||||
}
|
||||
else {
|
||||
PyErr_Print();
|
||||
PyErr_Clear();
|
||||
}
|
||||
// Py_DECREF(mod); /* ideally would decref, but in this case we never want to free */
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* bpy.* and lets us import it */
|
||||
BPy_init_modules();
|
||||
|
||||
@@ -743,6 +765,7 @@ int BPY_context_member_get(bContext *C, const char *member, bContextDataResult *
|
||||
|
||||
//result->ptr = ((BPy_StructRNA *)item)->ptr;
|
||||
CTX_data_pointer_set(result, ptr->id.data, ptr->type, ptr->data);
|
||||
CTX_data_type_set(result, CTX_DATA_TYPE_POINTER);
|
||||
done = true;
|
||||
}
|
||||
else if (PySequence_Check(item)) {
|
||||
@@ -773,12 +796,12 @@ int BPY_context_member_get(bContext *C, const char *member, bContextDataResult *
|
||||
|
||||
}
|
||||
Py_DECREF(seq_fast);
|
||||
|
||||
CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION);
|
||||
done = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (done == 0) {
|
||||
if (done == false) {
|
||||
if (item) printf("PyContext '%s' not a valid type\n", member);
|
||||
else printf("PyContext '%s' not found\n", member);
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
PyObject *bpy_intern_str_register;
|
||||
PyObject *bpy_intern_str_unregister;
|
||||
PyObject *bpy_intern_str_bl_rna;
|
||||
PyObject *bpy_intern_str_bl_property;
|
||||
PyObject *bpy_intern_str_order;
|
||||
PyObject *bpy_intern_str_attr;
|
||||
PyObject *bpy_intern_str___slots__;
|
||||
@@ -46,6 +47,7 @@ void bpy_intern_string_init(void)
|
||||
bpy_intern_str_register = PyUnicode_FromString("register");
|
||||
bpy_intern_str_unregister = PyUnicode_FromString("unregister");
|
||||
bpy_intern_str_bl_rna = PyUnicode_FromString("bl_rna");
|
||||
bpy_intern_str_bl_property = PyUnicode_FromString("bl_property");
|
||||
bpy_intern_str_order = PyUnicode_FromString("order");
|
||||
bpy_intern_str_attr = PyUnicode_FromString("attr");
|
||||
bpy_intern_str___slots__ = PyUnicode_FromString("__slots__");
|
||||
@@ -58,6 +60,7 @@ void bpy_intern_string_exit(void)
|
||||
Py_DECREF(bpy_intern_str_register);
|
||||
Py_DECREF(bpy_intern_str_unregister);
|
||||
Py_DECREF(bpy_intern_str_bl_rna);
|
||||
Py_DECREF(bpy_intern_str_bl_property);
|
||||
Py_DECREF(bpy_intern_str_order);
|
||||
Py_DECREF(bpy_intern_str_attr);
|
||||
Py_DECREF(bpy_intern_str___slots__);
|
||||
|
||||
@@ -30,6 +30,7 @@ void bpy_intern_string_exit(void);
|
||||
extern PyObject *bpy_intern_str_register;
|
||||
extern PyObject *bpy_intern_str_unregister;
|
||||
extern PyObject *bpy_intern_str_bl_rna;
|
||||
extern PyObject *bpy_intern_str_bl_property;
|
||||
extern PyObject *bpy_intern_str_order;
|
||||
extern PyObject *bpy_intern_str_attr;
|
||||
extern PyObject *bpy_intern_str___slots__;
|
||||
|
||||
@@ -29,10 +29,8 @@
|
||||
* functionality.
|
||||
*/
|
||||
|
||||
|
||||
#include <Python.h>
|
||||
|
||||
#include "bpy_operator_wrap.h"
|
||||
#include "WM_api.h"
|
||||
#include "WM_types.h"
|
||||
|
||||
@@ -42,6 +40,8 @@
|
||||
#include "RNA_define.h"
|
||||
|
||||
#include "bpy_rna.h"
|
||||
#include "bpy_intern_string.h"
|
||||
#include "bpy_operator_wrap.h" /* own include */
|
||||
|
||||
static void operator_properties_init(wmOperatorType *ot)
|
||||
{
|
||||
@@ -57,6 +57,66 @@ static void operator_properties_init(wmOperatorType *ot)
|
||||
PyErr_Print(); /* failed to register operator props */
|
||||
PyErr_Clear();
|
||||
}
|
||||
|
||||
/* set the default property: ot->prop */
|
||||
{
|
||||
/* picky developers will notice that 'bl_property' won't work with inheritance
|
||||
* get direct from the dict to avoid raising a load of attribute errors (yes this isnt ideal) - campbell */
|
||||
PyTypeObject *py_class = ot->ext.data;
|
||||
PyObject *py_class_dict = py_class->tp_dict;
|
||||
PyObject *bl_property = PyDict_GetItem(py_class_dict, bpy_intern_str_bl_property);
|
||||
const char *prop_id;
|
||||
bool prop_raise_error;
|
||||
|
||||
if (bl_property) {
|
||||
if (PyUnicode_Check(bl_property)) {
|
||||
/* since the property is explicitly given, raise an error if its not found */
|
||||
prop_id = _PyUnicode_AsString(bl_property);
|
||||
prop_raise_error = true;
|
||||
}
|
||||
else {
|
||||
PyErr_Format(PyExc_ValueError,
|
||||
"%.200s.bl_property should be a string, not %.200s",
|
||||
ot->idname, Py_TYPE(bl_property)->tp_name);
|
||||
|
||||
/* this could be done cleaner, for now its OK */
|
||||
PyErr_Print();
|
||||
PyErr_Clear();
|
||||
|
||||
prop_id = NULL;
|
||||
prop_raise_error = false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* fallback to hard-coded string (pre 2.66, could be deprecated) */
|
||||
prop_id = "type";
|
||||
prop_raise_error = false;
|
||||
}
|
||||
|
||||
if (prop_id) {
|
||||
PointerRNA ptr;
|
||||
PropertyRNA *prop;
|
||||
|
||||
RNA_pointer_create(NULL, ot->srna, NULL, &ptr);
|
||||
prop = RNA_struct_find_property(&ptr, prop_id);
|
||||
if (prop) {
|
||||
ot->prop = prop;
|
||||
}
|
||||
else {
|
||||
if (prop_raise_error) {
|
||||
PyErr_Format(PyExc_ValueError,
|
||||
"%.200s.bl_property '%.200s' not found",
|
||||
ot->idname, prop_id);
|
||||
|
||||
/* this could be done cleaner, for now its OK */
|
||||
PyErr_Print();
|
||||
PyErr_Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/* end 'ot->prop' assignment */
|
||||
|
||||
}
|
||||
|
||||
void operator_wrapper(wmOperatorType *ot, void *userdata)
|
||||
@@ -68,18 +128,6 @@ void operator_wrapper(wmOperatorType *ot, void *userdata)
|
||||
ot->srna = srna; /* restore */
|
||||
|
||||
operator_properties_init(ot);
|
||||
|
||||
/* XXX - not nice, set the first enum as searchable, should have a way for python to set */
|
||||
{
|
||||
PointerRNA ptr;
|
||||
PropertyRNA *prop;
|
||||
|
||||
RNA_pointer_create(NULL, ot->srna, NULL, &ptr);
|
||||
prop = RNA_struct_find_property(&ptr, "type");
|
||||
if (prop) {
|
||||
ot->prop = prop;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void macro_wrapper(wmOperatorType *ot, void *userdata)
|
||||
|
||||
@@ -1624,10 +1624,6 @@ static int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, void *data, PyOb
|
||||
}
|
||||
else {
|
||||
/* Unicode String */
|
||||
#ifdef WITH_INTERNATIONAL
|
||||
bool do_translate = RNA_property_flag(prop) & PROP_STRING_PY_TRANSLATE;
|
||||
#endif /* WITH_INTERNATIONAL */
|
||||
|
||||
#ifdef USE_STRING_COERCE
|
||||
PyObject *value_coerce = NULL;
|
||||
if (ELEM3(subtype, PROP_FILEPATH, PROP_DIRPATH, PROP_FILENAME)) {
|
||||
@@ -1641,13 +1637,6 @@ static int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, void *data, PyOb
|
||||
param = _PyUnicode_AsString(value);
|
||||
#endif /* USE_STRING_COERCE */
|
||||
|
||||
/* Any half-brained compiler should be able to optimize this out when WITH_INTERNATIONAL is off */
|
||||
#ifdef WITH_INTERNATIONAL
|
||||
if (do_translate) {
|
||||
param = IFACE_(param);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (param == NULL) {
|
||||
if (PyUnicode_Check(value)) {
|
||||
/* there was an error assigning a string type,
|
||||
@@ -4527,7 +4516,7 @@ PyDoc_STRVAR(pyrna_prop_collection_foreach_get_doc,
|
||||
"\n"
|
||||
" .. code-block:: python\n"
|
||||
"\n"
|
||||
" collection.foreach_get(someseq, attr)\n"
|
||||
" collection.foreach_get(attr, someseq)\n"
|
||||
"\n"
|
||||
" # Python equivalent\n"
|
||||
" for i in range(len(seq)): someseq[i] = getattr(collection, attr)\n"
|
||||
@@ -4547,7 +4536,7 @@ PyDoc_STRVAR(pyrna_prop_collection_foreach_set_doc,
|
||||
"\n"
|
||||
" .. code-block:: python\n"
|
||||
"\n"
|
||||
" collection.foreach_set(seq, attr)\n"
|
||||
" collection.foreach_set(attr, seq)\n"
|
||||
"\n"
|
||||
" # Python equivalent\n"
|
||||
" for i in range(len(seq)): setattr(collection[i], attr, seq[i])\n"
|
||||
@@ -6542,6 +6531,9 @@ static PyObject *pyrna_basetype_dir(BPy_BaseTypeRNA *self)
|
||||
|
||||
static PyTypeObject pyrna_basetype_Type = BLANK_PYTHON_TYPE;
|
||||
|
||||
/**
|
||||
* Accessed from Python as 'bpy.types'
|
||||
*/
|
||||
PyObject *BPY_rna_types(void)
|
||||
{
|
||||
BPy_BaseTypeRNA *self;
|
||||
|
||||
Reference in New Issue
Block a user