[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [32271] trunk/blender: - rna bugfix where ints were not clamped and would overflow, now raise an error and print valid range.
Campbell Barton
ideasman42 at gmail.com
Sun Oct 3 03:44:00 CEST 2010
Revision: 32271
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=32271
Author: campbellbarton
Date: 2010-10-03 03:44:00 +0200 (Sun, 03 Oct 2010)
Log Message:
-----------
- 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.
Modified Paths:
--------------
trunk/blender/release/scripts/op/wm.py
trunk/blender/source/blender/blenkernel/BKE_utildefines.h
trunk/blender/source/blender/editors/space_view3d/view3d_view.c
trunk/blender/source/blender/makesrna/intern/rna_nodetree.c
trunk/blender/source/blender/python/intern/bpy_props.c
trunk/blender/source/blender/python/intern/bpy_rna.c
trunk/blender/source/blender/windowmanager/intern/wm_operators.c
trunk/blender/source/creator/buildinfo.c
trunk/blender/source/creator/creator.c
Modified: trunk/blender/release/scripts/op/wm.py
===================================================================
--- trunk/blender/release/scripts/op/wm.py 2010-10-03 01:32:01 UTC (rev 32270)
+++ trunk/blender/release/scripts/op/wm.py 2010-10-03 01:44:00 UTC (rev 32271)
@@ -266,9 +266,9 @@
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)
Modified: trunk/blender/source/blender/blenkernel/BKE_utildefines.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_utildefines.h 2010-10-03 01:32:01 UTC (rev 32270)
+++ trunk/blender/source/blender/blenkernel/BKE_utildefines.h 2010-10-03 01:44:00 UTC (rev 32271)
@@ -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 */
Modified: trunk/blender/source/blender/editors/space_view3d/view3d_view.c
===================================================================
--- trunk/blender/source/blender/editors/space_view3d/view3d_view.c 2010-10-03 01:32:01 UTC (rev 32270)
+++ trunk/blender/source/blender/editors/space_view3d/view3d_view.c 2010-10-03 01:44:00 UTC (rev 32271)
@@ -2177,15 +2177,6 @@
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 */
Modified: trunk/blender/source/blender/makesrna/intern/rna_nodetree.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_nodetree.c 2010-10-03 01:32:01 UTC (rev 32270)
+++ trunk/blender/source/blender/makesrna/intern/rna_nodetree.c 2010-10-03 01:44:00 UTC (rev 32271)
@@ -515,15 +515,12 @@
{
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", "");
}
Modified: trunk/blender/source/blender/python/intern/bpy_props.c
===================================================================
--- trunk/blender/source/blender/python/intern/bpy_props.c 2010-10-03 01:32:01 UTC (rev 32270)
+++ trunk/blender/source/blender/python/intern/bpy_props.c 2010-10-03 01:44:00 UTC (rev 32271)
@@ -246,7 +246,7 @@
}
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 @@
}
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 @@
}
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;
}
Modified: trunk/blender/source/blender/python/intern/bpy_rna.c
===================================================================
--- trunk/blender/source/blender/python/intern/bpy_rna.c 2010-10-03 01:32:01 UTC (rev 32270)
+++ trunk/blender/source/blender/python/intern/bpy_rna.c 2010-10-03 01:44:00 UTC (rev 32271)
@@ -962,7 +962,7 @@
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 @@
}
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 @@
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 @@
}
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 @@
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 @@
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 @@
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_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 @@
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 @@
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
Modified: trunk/blender/source/blender/windowmanager/intern/wm_operators.c
===================================================================
--- trunk/blender/source/blender/windowmanager/intern/wm_operators.c 2010-10-03 01:32:01 UTC (rev 32270)
+++ trunk/blender/source/blender/windowmanager/intern/wm_operators.c 2010-10-03 01:44:00 UTC (rev 32271)
@@ -893,12 +893,6 @@
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);
Modified: trunk/blender/source/creator/buildinfo.c
===================================================================
--- trunk/blender/source/creator/buildinfo.c 2010-10-03 01:32:01 UTC (rev 32270)
+++ trunk/blender/source/creator/buildinfo.c 2010-10-03 01:44:00 UTC (rev 32271)
@@ -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);
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list