- rna bugfix where ints were not clamped and would overflow, now raise an error and print valid range.
- fixed WM_OT_context_cycle_int was causing problems with int overflow, now it cycles properly. - rename QUOTE macro to STRINGIFY_ARG, and added STRINGIFY, which is used more often since it gives the value as a string.
This commit is contained in:
@@ -266,9 +266,9 @@ class WM_OT_context_cycle_int(bpy.types.Operator):
|
||||
if value != eval("context.%s" % data_path):
|
||||
# relies on rna clamping int's out of the range
|
||||
if self.reverse:
|
||||
value = (1 << 32)
|
||||
value = (1 << 31) - 1
|
||||
else:
|
||||
value = - (1 << 32)
|
||||
value = -1 << 31
|
||||
|
||||
exec("context.%s=value" % data_path)
|
||||
|
||||
|
||||
@@ -38,8 +38,11 @@
|
||||
#define TRUE 1
|
||||
#endif
|
||||
|
||||
/* Macro to convert a value to string in the preprocessor */
|
||||
#define QUOTE(x) #x
|
||||
/* Macro to convert a value to string in the preprocessor
|
||||
* STRINGIFY_ARG: gives the defined name in the string
|
||||
* STRINGIFY: gives the defined value. */
|
||||
#define STRINGIFY_ARG(x) #x
|
||||
#define STRINGIFY(x) STRINGIFY_ARG(x)
|
||||
|
||||
/* these values need to be hardcoded in structs, dna does not recognize defines */
|
||||
/* also defined in DNA_space_types.h */
|
||||
|
||||
@@ -2177,15 +2177,6 @@ static int flyEnd(bContext *C, FlyInfo *fly)
|
||||
object_mat3_to_rot(v3d->camera, mat3, TRUE);
|
||||
DAG_id_flush_update(&v3d->camera->id, OB_RECALC_OB);
|
||||
}
|
||||
|
||||
#if 0 //XXX2.5
|
||||
if (IS_AUTOKEY_MODE(NORMAL)) {
|
||||
allqueue(REDRAWIPO, 0);
|
||||
allspace(REMAKEIPO, 0);
|
||||
allqueue(REDRAWNLA, 0);
|
||||
allqueue(REDRAWTIME, 0);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else { /* not camera */
|
||||
/* Apply the fly mode view */
|
||||
|
||||
@@ -515,15 +515,12 @@ static void init(void)
|
||||
{
|
||||
memset(nodes, 0, sizeof nodes);
|
||||
|
||||
#define Str(x) #x
|
||||
|
||||
#define DefNode(Category, ID, DefFunc, EnumName, StructName, UIName, UIDesc) \
|
||||
reg_node(ID, Category_##Category, EnumName, Str(Category##StructName), #Category, UIName, UIDesc);
|
||||
reg_node(ID, Category_##Category, EnumName, STRINGIFY_ARG(Category##StructName), #Category, UIName, UIDesc);
|
||||
|
||||
#include "rna_nodetree_types.h"
|
||||
|
||||
#undef DefNode
|
||||
#undef Str
|
||||
|
||||
reg_node(NODE_GROUP, Category_GroupNode, "GROUP", "NodeGroup", "Node", "Group", "");
|
||||
}
|
||||
|
||||
@@ -246,7 +246,7 @@ static PyObject *BPy_BoolVectorProperty(PyObject *self, PyObject *args, PyObject
|
||||
}
|
||||
|
||||
if(size < 1 || size > PYRNA_STACK_ARRAY) {
|
||||
PyErr_Format(PyExc_TypeError, "BoolVectorProperty(size=%d): size must be between 0 and %d.", size, PYRNA_STACK_ARRAY);
|
||||
PyErr_Format(PyExc_TypeError, "BoolVectorProperty(size=%d): size must be between 0 and " STRINGIFY(PYRNA_STACK_ARRAY), size);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -369,7 +369,7 @@ static PyObject *BPy_IntVectorProperty(PyObject *self, PyObject *args, PyObject
|
||||
}
|
||||
|
||||
if(size < 1 || size > PYRNA_STACK_ARRAY) {
|
||||
PyErr_Format(PyExc_TypeError, "IntVectorProperty(size=%d): size must be between 0 and %d.", size, PYRNA_STACK_ARRAY);
|
||||
PyErr_Format(PyExc_TypeError, "IntVectorProperty(size=%d): size must be between 0 and " STRINGIFY(PYRNA_STACK_ARRAY), size);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -503,7 +503,7 @@ static PyObject *BPy_FloatVectorProperty(PyObject *self, PyObject *args, PyObjec
|
||||
}
|
||||
|
||||
if(size < 1 || size > PYRNA_STACK_ARRAY) {
|
||||
PyErr_Format(PyExc_TypeError, "FloatVectorProperty(size=%d): size must be between 0 and %d.", size, PYRNA_STACK_ARRAY);
|
||||
PyErr_Format(PyExc_TypeError, "FloatVectorProperty(size=%d): size must be between 0 and " STRINGIFY(PYRNA_STACK_ARRAY), size);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -962,7 +962,7 @@ static int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, ParameterList *p
|
||||
if(RNA_property_flag(prop) & PROP_OUTPUT)
|
||||
param = PyObject_IsTrue( value );
|
||||
else
|
||||
param = PyLong_AsSsize_t( value );
|
||||
param = PyLong_AsLong( value );
|
||||
|
||||
if( param < 0 || param > 1) {
|
||||
PyErr_Format(PyExc_TypeError, "%.200s %.200s.%.200s expected True/False or 0/1", error_prefix, RNA_struct_identifier(ptr->type), RNA_property_identifier(prop));
|
||||
@@ -975,14 +975,20 @@ static int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, ParameterList *p
|
||||
}
|
||||
case PROP_INT:
|
||||
{
|
||||
int param = PyLong_AsSsize_t(value);
|
||||
if (param==-1 && PyErr_Occurred()) {
|
||||
int overflow;
|
||||
long param= PyLong_AsLongAndOverflow(value, &overflow);
|
||||
if(overflow || (param > INT_MAX) || (param < INT_MIN)) {
|
||||
PyErr_Format(PyExc_TypeError, "%.200s %.200s.%.200s value not in 'int' range (" STRINGIFY(INT_MIN) ", " STRINGIFY(INT_MAX) ")", error_prefix, RNA_struct_identifier(ptr->type), RNA_property_identifier(prop));
|
||||
return -1;
|
||||
}
|
||||
else if (param==-1 && PyErr_Occurred()) {
|
||||
PyErr_Format(PyExc_TypeError, "%.200s %.200s.%.200s expected an int type", error_prefix, RNA_struct_identifier(ptr->type), RNA_property_identifier(prop));
|
||||
return -1;
|
||||
} else {
|
||||
RNA_property_int_clamp(ptr, prop, ¶m);
|
||||
if(data) *((int*)data)= param;
|
||||
else RNA_property_int_set(ptr, prop, param);
|
||||
int param_i= (int)param;
|
||||
RNA_property_int_clamp(ptr, prop, ¶m_i);
|
||||
if(data) *((int*)data)= param_i;
|
||||
else RNA_property_int_set(ptr, prop, param_i);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -1261,7 +1267,7 @@ static int pyrna_py_to_prop_array_index(BPy_PropertyArrayRNA *self, int index, P
|
||||
switch (type) {
|
||||
case PROP_BOOLEAN:
|
||||
{
|
||||
int param = PyLong_AsSsize_t( value );
|
||||
int param = PyLong_AsLong( value );
|
||||
|
||||
if( param < 0 || param > 1) {
|
||||
PyErr_SetString(PyExc_TypeError, "expected True/False or 0/1");
|
||||
@@ -1273,7 +1279,7 @@ static int pyrna_py_to_prop_array_index(BPy_PropertyArrayRNA *self, int index, P
|
||||
}
|
||||
case PROP_INT:
|
||||
{
|
||||
int param = PyLong_AsSsize_t(value);
|
||||
int param = PyLong_AsLong(value);
|
||||
if (param==-1 && PyErr_Occurred()) {
|
||||
PyErr_SetString(PyExc_TypeError, "expected an int type");
|
||||
ret = -1;
|
||||
@@ -1529,7 +1535,7 @@ static PyObject *pyrna_prop_array_subscript(BPy_PropertyArrayRNA *self, PyObject
|
||||
Py_ssize_t i = PyNumber_AsSsize_t(key, PyExc_IndexError);
|
||||
if (i == -1 && PyErr_Occurred())
|
||||
return NULL;
|
||||
return pyrna_prop_array_subscript_int(self, PyLong_AsSsize_t(key));
|
||||
return pyrna_prop_array_subscript_int(self, PyLong_AsLong(key));
|
||||
}
|
||||
else if (PySlice_Check(key)) {
|
||||
Py_ssize_t start, stop, step, slicelength;
|
||||
@@ -1613,7 +1619,7 @@ static int prop_subscript_ass_array_slice(PointerRNA *ptr, PropertyRNA *prop, in
|
||||
RNA_property_boolean_get_array(ptr, prop, values);
|
||||
|
||||
for(count=start; count<stop; count++)
|
||||
values[count] = PyLong_AsSsize_t(PySequence_Fast_GET_ITEM(value, count-start));
|
||||
values[count] = PyLong_AsLong(PySequence_Fast_GET_ITEM(value, count-start));
|
||||
|
||||
if(PyErr_Occurred()) ret= -1;
|
||||
else RNA_property_boolean_set_array(ptr, prop, values);
|
||||
@@ -1634,7 +1640,7 @@ static int prop_subscript_ass_array_slice(PointerRNA *ptr, PropertyRNA *prop, in
|
||||
RNA_property_int_get_array(ptr, prop, values);
|
||||
|
||||
for(count=start; count<stop; count++) {
|
||||
ival = PyLong_AsSsize_t(PySequence_Fast_GET_ITEM(value, count-start));
|
||||
ival = PyLong_AsLong(PySequence_Fast_GET_ITEM(value, count-start));
|
||||
CLAMP(ival, min, max);
|
||||
values[count] = ival;
|
||||
}
|
||||
@@ -2854,7 +2860,7 @@ static PyObject *pyrna_prop_collection_idprop_add(BPy_PropertyRNA *self)
|
||||
|
||||
static PyObject *pyrna_prop_collection_idprop_remove(BPy_PropertyRNA *self, PyObject *value)
|
||||
{
|
||||
int key= PyLong_AsSsize_t(value);
|
||||
int key= PyLong_AsLong(value);
|
||||
|
||||
if (key==-1 && PyErr_Occurred()) {
|
||||
PyErr_SetString( PyExc_TypeError, "bpy_prop_collection.remove(): expected one int argument");
|
||||
@@ -3201,13 +3207,13 @@ static PyObject *foreach_getset(BPy_PropertyRNA *self, PyObject *args, int set)
|
||||
item= PySequence_GetItem(seq, i);
|
||||
switch(raw_type) {
|
||||
case PROP_RAW_CHAR:
|
||||
((char *)array)[i]= (char)PyLong_AsSsize_t(item);
|
||||
((char *)array)[i]= (char)PyLong_AsLong(item);
|
||||
break;
|
||||
case PROP_RAW_SHORT:
|
||||
((short *)array)[i]= (short)PyLong_AsSsize_t(item);
|
||||
((short *)array)[i]= (short)PyLong_AsLong(item);
|
||||
break;
|
||||
case PROP_RAW_INT:
|
||||
((int *)array)[i]= (int)PyLong_AsSsize_t(item);
|
||||
((int *)array)[i]= (int)PyLong_AsLong(item);
|
||||
break;
|
||||
case PROP_RAW_FLOAT:
|
||||
((float *)array)[i]= (float)PyFloat_AsDouble(item);
|
||||
@@ -4971,7 +4977,7 @@ static int bpy_class_validate(PointerRNA *dummyptr, void *py_data, int *have_fun
|
||||
|
||||
if (func_arg_count >= 0) { /* -1 if we dont care*/
|
||||
py_arg_count = PyObject_GetAttrString(PyFunction_GET_CODE(item), "co_argcount");
|
||||
arg_count = PyLong_AsSsize_t(py_arg_count);
|
||||
arg_count = PyLong_AsLong(py_arg_count);
|
||||
Py_DECREF(py_arg_count);
|
||||
|
||||
/* note, the number of args we check for and the number of args we give to
|
||||
|
||||
@@ -893,12 +893,6 @@ static uiBlock *wm_block_create_redo(bContext *C, ARegion *ar, void *arg_op)
|
||||
op->properties= IDP_New(IDP_GROUP, val, "wmOperatorProperties");
|
||||
}
|
||||
|
||||
// XXX - hack, only for editing docs
|
||||
if(strcmp(op->type->idname, "WM_OT_doc_edit")==0) {
|
||||
columns= 1;
|
||||
width= 500;
|
||||
}
|
||||
|
||||
RNA_pointer_create(&wm->id, op->type->srna, op->properties, &ptr);
|
||||
layout= uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 0, 0, width, 20, style);
|
||||
uiItemL(layout, op->type->name, 0);
|
||||
|
||||
@@ -27,10 +27,9 @@
|
||||
* ***** END GPL LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
#define STRINGIFY(x) XSTRINGIFY(x)
|
||||
#define XSTRINGIFY(x) #x
|
||||
|
||||
#ifdef BUILD_DATE
|
||||
#include "BKE_utildefines.h"
|
||||
|
||||
char build_date[]= STRINGIFY(BUILD_DATE);
|
||||
char build_time[]= STRINGIFY(BUILD_TIME);
|
||||
char build_rev[]= STRINGIFY(BUILD_REV);
|
||||
|
||||
@@ -993,7 +993,7 @@ void setupArguments(bContext *C, bArgs *ba, SYS_SystemHandle *syshandle)
|
||||
BLI_argsAdd(ba, 4, "-E", "--engine", "<engine>\n\tSpecify the render engine\n\tuse -E help to list available engines", set_engine, C);
|
||||
|
||||
BLI_argsAdd(ba, 4, "-F", "--render-format", format_doc, set_image_type, C);
|
||||
BLI_argsAdd(ba, 4, "-t", "--threads", "<threads>\n\tUse amount of <threads> for rendering in background\n\t[1-" QUOTE(BLENDER_MAX_THREADS) "], 0 for systems processor count.", set_threads, NULL);
|
||||
BLI_argsAdd(ba, 4, "-t", "--threads", "<threads>\n\tUse amount of <threads> for rendering in background\n\t[1-" STRINGIFY(BLENDER_MAX_THREADS) "], 0 for systems processor count.", set_threads, NULL);
|
||||
BLI_argsAdd(ba, 4, "-x", "--use-extension", "<bool>\n\tSet option to add the file extension to the end of the file", set_extension, C);
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user