static PyObject *BPy_BoolVectorProperty(PyObject *self, PyObject *args, PyObject *kw) { StructRNA *srna; BPY_PROPDEF_HEAD(BoolVectorProperty) if(srna) { static const char *kwlist[]= {"attr", "name", "description", "default", "options", "subtype", "size", "update", NULL}; const char *id=NULL, *name="", *description=""; int id_len; int def[PYRNA_STACK_ARRAY]={0}; int size=3; PropertyRNA *prop; PyObject *pydef= NULL; PyObject *pyopts= NULL; int opts=0; char *pysubtype= NULL; int subtype= PROP_NONE; PyObject *update_cb= NULL; if (!PyArg_ParseTupleAndKeywords(args, kw, "s#|ssOO!siO:BoolVectorProperty", (char **)kwlist, &id, &id_len, &name, &description, &pydef, &PySet_Type, &pyopts, &pysubtype, &size, &update_cb)) { return NULL; } BPY_PROPDEF_SUBTYPE_CHECK(BoolVectorProperty, property_flag_items, property_subtype_array_items) if(size < 1 || size > PYRNA_STACK_ARRAY) { PyErr_Format(PyExc_TypeError, "BoolVectorProperty(size=%d): size must be between 0 and " STRINGIFY(PYRNA_STACK_ARRAY), size); return NULL; } if(pydef && PyC_AsArray(def, pydef, size, &PyBool_Type, FALSE, "BoolVectorProperty(default=sequence)") < 0) return NULL; if (bpy_prop_callback_check(update_cb, 2) == -1) { return NULL; } // prop= RNA_def_boolean_array(srna, id, size, pydef ? def:NULL, name, description); prop= RNA_def_property(srna, id, PROP_BOOLEAN, subtype); RNA_def_property_array(prop, size); if(pydef) RNA_def_property_boolean_array_default(prop, def); RNA_def_property_ui_text(prop, name, description); if(pyopts) { if(opts & PROP_HIDDEN) RNA_def_property_flag(prop, PROP_HIDDEN); if((opts & PROP_ANIMATABLE)==0) RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); } bpy_prop_callback_assign(prop, update_cb); RNA_def_property_duplicate_pointers(srna, prop); } Py_RETURN_NONE; }
/* sequence slice (set): idparr[a:b] = value */ static int BPy_IDArray_ass_slice(BPy_IDArray *self, int begin, int end, PyObject *seq) { IDProperty *prop = self->prop; short is_double = 0; const PyTypeObject *py_type = idp_array_py_type(self, &is_double); const size_t elem_size = is_double ? sizeof(double) : sizeof(float); size_t alloc_len; size_t size; void *vec; CLAMP(begin, 0, prop->len); CLAMP(end, 0, prop->len); begin = MIN2(begin, end); size = (end - begin); alloc_len = size * elem_size; vec = MEM_mallocN(alloc_len, "array assignment"); /* NOTE: we count on int/float being the same size here */ if (PyC_AsArray(vec, seq, size, py_type, is_double, "slice assignment: ") == -1) { MEM_freeN(vec); return -1; } memcpy((void *)(((char *)IDP_Array(prop)) + (begin * elem_size)), vec, alloc_len); MEM_freeN(vec); return 0; }
static PyObject *BPy_FloatVectorProperty(PyObject *self, PyObject *args, PyObject *kw) { StructRNA *srna; BPY_PROPDEF_HEAD(FloatVectorProperty) if(srna) { static const char *kwlist[] = {"attr", "name", "description", "default", "min", "max", "soft_min", "soft_max", "step", "precision", "options", "subtype", "size", NULL}; const char *id=NULL, *name="", *description=""; int id_len; float min=-FLT_MAX, max=FLT_MAX, soft_min=-FLT_MAX, soft_max=FLT_MAX, step=3, def[PYRNA_STACK_ARRAY]={0.0f}; int precision= 2, size=3; PropertyRNA *prop; PyObject *pydef= NULL; PyObject *pyopts= NULL; int opts=0; char *pysubtype= NULL; int subtype= PROP_NONE; if (!PyArg_ParseTupleAndKeywords(args, kw, "s#|ssOfffffiO!si:FloatVectorProperty", (char **)kwlist, &id, &id_len, &name, &description, &pydef, &min, &max, &soft_min, &soft_max, &step, &precision, &PySet_Type, &pyopts, &pysubtype, &size)) return NULL; BPY_PROPDEF_SUBTYPE_CHECK(FloatVectorProperty, property_flag_items, property_subtype_array_items) if(size < 1 || size > PYRNA_STACK_ARRAY) { PyErr_Format(PyExc_TypeError, "FloatVectorProperty(size=%d): size must be between 0 and " STRINGIFY(PYRNA_STACK_ARRAY), size); return NULL; } if(pydef && PyC_AsArray(def, pydef, size, &PyFloat_Type, "FloatVectorProperty(default=sequence)") < 0) return NULL; prop= RNA_def_property(srna, id, PROP_FLOAT, subtype); RNA_def_property_array(prop, size); if(pydef) RNA_def_property_float_array_default(prop, def); RNA_def_property_range(prop, min, max); RNA_def_property_ui_text(prop, name, description); RNA_def_property_ui_range(prop, MAX2(soft_min, min), MIN2(soft_max, max), step, precision); if(pyopts) { if(opts & PROP_HIDDEN) RNA_def_property_flag(prop, PROP_HIDDEN); if((opts & PROP_ANIMATABLE)==0) RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); } RNA_def_property_duplicate_pointers(srna, prop); } Py_RETURN_NONE; }