UNUSED() macro so -Wunused-parameter can be used with GCC without so many warnings.

applied to python api and exotic.c, removed some args being passed down which were not needed.

keyword args for new mathutils types were being ignored when they should raise an error.
This commit is contained in:
2010-10-13 23:25:08 +00:00
parent a90f876948
commit be32cf8b32
23 changed files with 198 additions and 168 deletions

View File

@@ -34,7 +34,9 @@
#include "BLI_path_util.h"
#include "BLI_bpath.h"
#include "BKE_utildefines.h"
/* external util modules */
#include "../generic/geometry.h"
#include "../generic/bgl.h"
@@ -51,7 +53,7 @@ static char bpy_script_paths_doc[] =
" :return: (system, user) strings will be empty when not found.\n"
" :rtype: tuple of strigs\n";
PyObject *bpy_script_paths(PyObject *self)
PyObject *bpy_script_paths(PyObject *UNUSED(self))
{
PyObject *ret= PyTuple_New(2);
char *path;
@@ -73,7 +75,7 @@ static char bpy_blend_paths_doc[] =
" :type absolute: boolean\n"
" :return: path list.\n"
" :rtype: list of strigs\n";
static PyObject *bpy_blend_paths(PyObject * self, PyObject *args, PyObject *kw)
static PyObject *bpy_blend_paths(PyObject *UNUSED(self), PyObject *args, PyObject *kw)
{
struct BPathIterator bpi;
PyObject *list = PyList_New(0), *st; /* stupidly big string to be safe */
@@ -124,7 +126,7 @@ static char bpy_user_resource_doc[] =
" :type subdir: string\n"
" :return: a path.\n"
" :rtype: string\n";
static PyObject *bpy_user_resource(PyObject * self, PyObject *args, PyObject *kw)
static PyObject *bpy_user_resource(PyObject *UNUSED(self), PyObject *args, PyObject *kw)
{
char *type;
char *subdir= NULL;

View File

@@ -26,6 +26,7 @@
#include "BLI_path_util.h"
#include "BKE_utildefines.h"
#include "BKE_blender.h"
#include "BKE_global.h"
#include "structseq.h"
@@ -116,21 +117,15 @@ static PyObject *make_app_info(void)
/* a few getsets because it makes sense for them to be in bpy.app even though
* they are not static */
static PyObject *bpy_app_debug_get(PyObject *self, void *closure)
static PyObject *bpy_app_debug_get(PyObject *UNUSED(self), void *UNUSED(closure))
{
(void)(self);
(void)(closure);
return PyBool_FromLong(G.f & G_DEBUG);
}
static int bpy_app_debug_set(PyObject *self, PyObject *value, void *closure)
static int bpy_app_debug_set(PyObject *UNUSED(self), PyObject *value, void *UNUSED(closure))
{
int param= PyObject_IsTrue(value);
(void)(self);
(void)(closure);
if(param < 0) {
PyErr_SetString(PyExc_TypeError, "bpy.app.debug can only be True/False");
return -1;
@@ -142,12 +137,9 @@ static int bpy_app_debug_set(PyObject *self, PyObject *value, void *closure)
return 0;
}
static PyObject *bpy_app_tempdir_get(PyObject *self, void *closure)
static PyObject *bpy_app_tempdir_get(PyObject *UNUSED(self), void *UNUSED(closure))
{
extern char btempdir[];
(void)(self);
(void)(closure);
return PyC_UnicodeFromByte(btempdir);
}

View File

@@ -237,7 +237,7 @@ static char *copy_values(PyObject *seq, PointerRNA *ptr, PropertyRNA *prop, int
return data;
}
static int py_to_array(PyObject *py, PointerRNA *ptr, PropertyRNA *prop, ParameterList *parms, char *param_data, ItemTypeCheckFunc check_item_type, const char *item_type_str, int item_size, ItemConvertFunc convert_item, RNA_SetArrayFunc rna_set_array, const char *error_prefix)
static int py_to_array(PyObject *py, PointerRNA *ptr, PropertyRNA *prop, char *param_data, ItemTypeCheckFunc check_item_type, const char *item_type_str, int item_size, ItemConvertFunc convert_item, RNA_SetArrayFunc rna_set_array, const char *error_prefix)
{
int totdim, dim_size[MAX_ARRAY_DIMENSION];
int totitem;
@@ -358,18 +358,18 @@ static void bool_set_index(PointerRNA *ptr, PropertyRNA *prop, int index, void *
RNA_property_boolean_set_index(ptr, prop, index, *(int*)value);
}
int pyrna_py_to_array(PointerRNA *ptr, PropertyRNA *prop, ParameterList *parms, char *param_data, PyObject *py, const char *error_prefix)
int pyrna_py_to_array(PointerRNA *ptr, PropertyRNA *prop, char *param_data, PyObject *py, const char *error_prefix)
{
int ret;
switch (RNA_property_type(prop)) {
case PROP_FLOAT:
ret= py_to_array(py, ptr, prop, parms, param_data, py_float_check, "float", sizeof(float), py_to_float, (RNA_SetArrayFunc)RNA_property_float_set_array, error_prefix);
ret= py_to_array(py, ptr, prop, param_data, py_float_check, "float", sizeof(float), py_to_float, (RNA_SetArrayFunc)RNA_property_float_set_array, error_prefix);
break;
case PROP_INT:
ret= py_to_array(py, ptr, prop, parms, param_data, py_int_check, "int", sizeof(int), py_to_int, (RNA_SetArrayFunc)RNA_property_int_set_array, error_prefix);
ret= py_to_array(py, ptr, prop, param_data, py_int_check, "int", sizeof(int), py_to_int, (RNA_SetArrayFunc)RNA_property_int_set_array, error_prefix);
break;
case PROP_BOOLEAN:
ret= py_to_array(py, ptr, prop, parms, param_data, py_bool_check, "boolean", sizeof(int), py_to_bool, (RNA_SetArrayFunc)RNA_property_boolean_set_array, error_prefix);
ret= py_to_array(py, ptr, prop, param_data, py_bool_check, "boolean", sizeof(int), py_to_bool, (RNA_SetArrayFunc)RNA_property_boolean_set_array, error_prefix);
break;
default:
PyErr_SetString(PyExc_TypeError, "not an array type");

View File

@@ -43,6 +43,7 @@
#include "BLI_math_base.h"
#include "BLI_string.h"
#include "BKE_utildefines.h"
#include "BKE_context.h"
#include "BKE_text.h"
#include "BKE_font.h" /* only for utf8towchar */
@@ -104,7 +105,8 @@ void bpy_context_set(bContext *C, PyGILState_STATE *gilstate)
}
}
void bpy_context_clear(bContext *C, PyGILState_STATE *gilstate)
/* context should be used but not now because it causes some bugs */
void bpy_context_clear(bContext *UNUSED(C), PyGILState_STATE *gilstate)
{
py_call_level--;

View File

@@ -40,7 +40,7 @@
#include "MEM_guardedalloc.h"
#include "BKE_report.h"
static PyObject *pyop_poll( PyObject * self, PyObject * args)
static PyObject *pyop_poll(PyObject *UNUSED(self), PyObject *args)
{
wmOperatorType *ot;
char *opname;
@@ -80,7 +80,7 @@ static PyObject *pyop_poll( PyObject * self, PyObject * args)
return ret;
}
static PyObject *pyop_call( PyObject * self, PyObject * args)
static PyObject *pyop_call(PyObject *UNUSED(self), PyObject *args)
{
wmOperatorType *ot;
int error_val = 0;
@@ -196,7 +196,7 @@ static PyObject *pyop_call( PyObject * self, PyObject * args)
}
static PyObject *pyop_as_string( PyObject * self, PyObject * args)
static PyObject *pyop_as_string(PyObject *UNUSED(self), PyObject *args)
{
wmOperatorType *ot;
PointerRNA ptr;
@@ -248,7 +248,7 @@ static PyObject *pyop_as_string( PyObject * self, PyObject * args)
return pybuf;
}
static PyObject *pyop_dir(PyObject *self)
static PyObject *pyop_dir(PyObject *UNUSED(self))
{
PyObject *list = PyList_New(0), *name;
wmOperatorType *ot;
@@ -262,7 +262,7 @@ static PyObject *pyop_dir(PyObject *self)
return list;
}
static PyObject *pyop_getrna(PyObject *self, PyObject *value)
static PyObject *pyop_getrna(PyObject *UNUSED(self), PyObject *value)
{
wmOperatorType *ot;
PointerRNA ptr;

View File

@@ -84,7 +84,7 @@ void macro_wrapper(wmOperatorType *ot, void *userdata)
operator_properties_init(ot);
}
PyObject *PYOP_wrap_macro_define(PyObject *self, PyObject *args)
PyObject *PYOP_wrap_macro_define(PyObject *UNUSED(self), PyObject *args)
{
wmOperatorType *ot;
wmOperatorTypeMacro *otmacro;

View File

@@ -58,7 +58,7 @@
#include "../generic/IDProp.h" /* for IDprop lookups */
#include "../generic/py_capi_utils.h"
static int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, ParameterList *parms, void *data, PyObject *value, const char *error_prefix);
static int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, void *data, PyObject *value, const char *error_prefix);
static PyObject *pyrna_prop_array_subscript_slice(BPy_PropertyArrayRNA *self, PointerRNA *ptr, PropertyRNA *prop, int start, int stop, int length);
static Py_ssize_t pyrna_prop_array_length(BPy_PropertyArrayRNA *self);
static Py_ssize_t pyrna_prop_collection_length(BPy_PropertyRNA *self);
@@ -135,7 +135,7 @@ static int mathutils_rna_vector_set(BaseMathObject *bmo, int subtype)
return 1;
}
static int mathutils_rna_vector_get_index(BaseMathObject *bmo, int subtype, int index)
static int mathutils_rna_vector_get_index(BaseMathObject *bmo, int UNUSED(subtype), int index)
{
BPy_PropertyRNA *self= (BPy_PropertyRNA *)bmo->cb_user;
@@ -146,7 +146,7 @@ static int mathutils_rna_vector_get_index(BaseMathObject *bmo, int subtype, int
return 1;
}
static int mathutils_rna_vector_set_index(BaseMathObject *bmo, int subtype, int index)
static int mathutils_rna_vector_set_index(BaseMathObject *bmo, int UNUSED(subtype), int index)
{
BPy_PropertyRNA *self= (BPy_PropertyRNA *)bmo->cb_user;
@@ -176,7 +176,7 @@ Mathutils_Callback mathutils_rna_array_cb = {
/* bpyrna matrix callbacks */
static int mathutils_rna_matrix_cb_index= -1; /* index for our callbacks */
static int mathutils_rna_matrix_get(BaseMathObject *bmo, int subtype)
static int mathutils_rna_matrix_get(BaseMathObject *bmo, int UNUSED(subtype))
{
BPy_PropertyRNA *self= (BPy_PropertyRNA *)bmo->cb_user;
@@ -187,7 +187,7 @@ static int mathutils_rna_matrix_get(BaseMathObject *bmo, int subtype)
return 1;
}
static int mathutils_rna_matrix_set(BaseMathObject *bmo, int subtype)
static int mathutils_rna_matrix_set(BaseMathObject *bmo, int UNUSED(subtype))
{
BPy_PropertyRNA *self= (BPy_PropertyRNA *)bmo->cb_user;
@@ -864,7 +864,7 @@ int pyrna_pydict_to_props(PointerRNA *ptr, PyObject *kw, int all_args, const cha
break;
}
} else {
if (pyrna_py_to_prop(ptr, prop, NULL, NULL, item, error_prefix)) {
if (pyrna_py_to_prop(ptr, prop, NULL, item, error_prefix)) {
error_val= -1;
break;
}
@@ -918,7 +918,7 @@ static PyObject *pyrna_func_to_py(BPy_DummyPointerRNA *pyrna, FunctionRNA *func)
static int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, ParameterList *parms, void *data, PyObject *value, const char *error_prefix)
static int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, void *data, PyObject *value, const char *error_prefix)
{
/* XXX hard limits should be checked here */
int type = RNA_property_type(prop);
@@ -941,7 +941,7 @@ static int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, ParameterList *p
return -1;
}
/* done getting the length */
ok= pyrna_py_to_array(ptr, prop, parms, data, value, error_prefix);
ok= pyrna_py_to_array(ptr, prop, data, value, error_prefix);
if (!ok) {
/* PyErr_Format(PyExc_AttributeError, "%.200s %s", error_prefix, error_str); */
@@ -1391,7 +1391,7 @@ static PyObject *pyrna_prop_collection_subscript_str(BPy_PropertyRNA *self, cons
}
/* static PyObject *pyrna_prop_array_subscript_str(BPy_PropertyRNA *self, char *keyname) */
static PyObject *pyrna_prop_collection_subscript_slice(PointerRNA *ptr, PropertyRNA *prop, int start, int stop, int length)
static PyObject *pyrna_prop_collection_subscript_slice(PointerRNA *ptr, PropertyRNA *prop, int start, int stop)
{
PointerRNA newptr;
PyObject *list = PyList_New(stop - start);
@@ -1513,7 +1513,7 @@ static PyObject *pyrna_prop_collection_subscript(BPy_PropertyRNA *self, PyObject
return PyList_New(0);
}
else if (step == 1) {
return pyrna_prop_collection_subscript_slice(&self->ptr, self->prop, start, stop, len);
return pyrna_prop_collection_subscript_slice(&self->ptr, self->prop, start, stop);
}
else {
PyErr_SetString(PyExc_TypeError, "bpy_prop_collection[slice]: slice steps not supported with rna");
@@ -2431,7 +2431,7 @@ static char pyrna_struct_type_recast_doc[] =
" :return: a new instance of this object with the type initialized again.\n"
" :rtype: subclass of :class:`bpy_struct`";
static PyObject *pyrna_struct_type_recast(BPy_StructRNA *self, PyObject *args)
static PyObject *pyrna_struct_type_recast(BPy_StructRNA *self)
{
PointerRNA r_ptr;
RNA_pointer_recast(&self->ptr, &r_ptr);
@@ -2751,7 +2751,7 @@ static int pyrna_struct_setattro( BPy_StructRNA *self, PyObject *pyname, PyObjec
PyErr_SetString(PyExc_AttributeError, "bpy_struct: del not supported");
return -1;
}
return pyrna_py_to_prop(&self->ptr, prop, NULL, NULL, value, "bpy_struct: item.attr = val:");
return pyrna_py_to_prop(&self->ptr, prop, NULL, value, "bpy_struct: item.attr = val:");
}
else {
return PyObject_GenericSetAttr((PyObject *)self, pyname, value);
@@ -2835,7 +2835,7 @@ static int pyrna_prop_collection_setattro( BPy_PropertyRNA *self, PyObject *pyna
else if(RNA_property_collection_type_get(&self->ptr, self->prop, &r_ptr)) {
if ((prop = RNA_struct_find_property(&r_ptr, name))) {
/* pyrna_py_to_prop sets its own exceptions */
return pyrna_py_to_prop(&r_ptr, prop, NULL, NULL, value, "BPy_PropertyRNA - Attribute (setattr):");
return pyrna_py_to_prop(&r_ptr, prop, NULL, value, "BPy_PropertyRNA - Attribute (setattr):");
}
}
@@ -3409,7 +3409,7 @@ static struct PyMethodDef pyrna_prop_collection_idprop_methods[] = {
/* only needed for subtyping, so a new class gets a valid BPy_StructRNA
* todo - also accept useful args */
static PyObject * pyrna_struct_new(PyTypeObject *type, PyObject *args, PyObject *kwds) {
static PyObject * pyrna_struct_new(PyTypeObject *type, PyObject *args, PyObject *UNUSED(kwds)) {
BPy_StructRNA *base;
@@ -3432,7 +3432,7 @@ static PyObject * pyrna_struct_new(PyTypeObject *type, PyObject *args, PyObject
/* only needed for subtyping, so a new class gets a valid BPy_StructRNA
* todo - also accept useful args */
static PyObject * pyrna_prop_new(PyTypeObject *type, PyObject *args, PyObject *kwds) {
static PyObject * pyrna_prop_new(PyTypeObject *type, PyObject *args, PyObject *UNUSED(kwds)) {
BPy_PropertyRNA *base;
@@ -3454,7 +3454,7 @@ static PyObject * pyrna_prop_new(PyTypeObject *type, PyObject *args, PyObject *k
}
}
PyObject *pyrna_param_to_py(PointerRNA *ptr, ParameterList *parms, PropertyRNA *prop, void *data)
PyObject *pyrna_param_to_py(PointerRNA *ptr, PropertyRNA *prop, void *data)
{
PyObject *ret;
int type = RNA_property_type(prop);
@@ -3704,7 +3704,7 @@ static PyObject * pyrna_func_call(PyObject *self, PyObject *args, PyObject *kw)
continue;
}
err= pyrna_py_to_prop(&funcptr, parm, &parms, iter.data, item, "");
err= pyrna_py_to_prop(&funcptr, parm, iter.data, item, "");
if(err!=0) {
/* the error generated isnt that useful, so generate it again with a useful prefix
@@ -3717,7 +3717,7 @@ static PyObject * pyrna_func_call(PyObject *self, PyObject *args, PyObject *kw)
else
snprintf(error_prefix, sizeof(error_prefix), "%s.%s(): error with argument %d, \"%s\" - ", RNA_struct_identifier(self_ptr->type), RNA_function_identifier(self_func), i, parm_id);
pyrna_py_to_prop(&funcptr, parm, &parms, iter.data, item, error_prefix);
pyrna_py_to_prop(&funcptr, parm, iter.data, item, error_prefix);
break;
}
@@ -3822,13 +3822,13 @@ static PyObject * pyrna_func_call(PyObject *self, PyObject *args, PyObject *kw)
flag= RNA_property_flag(parm);
if (flag & PROP_OUTPUT)
PyTuple_SET_ITEM(ret, i++, pyrna_param_to_py(&funcptr, &parms, parm, iter.data));
PyTuple_SET_ITEM(ret, i++, pyrna_param_to_py(&funcptr, parm, iter.data));
}
RNA_parameter_list_end(&iter);
}
else
ret= pyrna_param_to_py(&funcptr, &parms, pret_single, retdata_single);
ret= pyrna_param_to_py(&funcptr, pret_single, retdata_single);
/* possible there is an error in conversion */
if(ret==NULL)
@@ -5012,7 +5012,7 @@ static int bpy_class_validate(PointerRNA *dummyptr, void *py_data, int *have_fun
if(strcmp(identifier, rna_attr) == 0) { \
item= PyObject_GetAttrString(py_class, py_attr); \
if(item && item != Py_None) { \
if(pyrna_py_to_prop(dummyptr, prop, NULL, NULL, item, "validating class error:") != 0) { \
if(pyrna_py_to_prop(dummyptr, prop, NULL, item, "validating class error:") != 0) { \
Py_DECREF(item); \
return -1; \
} \
@@ -5036,7 +5036,7 @@ static int bpy_class_validate(PointerRNA *dummyptr, void *py_data, int *have_fun
else {
Py_DECREF(item); /* no need to keep a ref, the class owns it */
if(pyrna_py_to_prop(dummyptr, prop, NULL, NULL, item, "validating class error:") != 0)
if(pyrna_py_to_prop(dummyptr, prop, NULL, item, "validating class error:") != 0)
return -1;
}
}
@@ -5156,7 +5156,7 @@ static int bpy_class_call(PointerRNA *ptr, FunctionRNA *func, ParameterList *par
continue;
}
parmitem= pyrna_param_to_py(&funcptr, parms, parm, iter.data);
parmitem= pyrna_param_to_py(&funcptr, parm, iter.data);
PyTuple_SET_ITEM(args, i, parmitem);
i++;
}
@@ -5191,7 +5191,7 @@ static int bpy_class_call(PointerRNA *ptr, FunctionRNA *func, ParameterList *par
err= -1;
}
else if(ret_len==1) {
err= pyrna_py_to_prop(&funcptr, pret_single, parms, retdata_single, ret, "calling class function:");
err= pyrna_py_to_prop(&funcptr, pret_single, retdata_single, ret, "calling class function:");
}
else if (ret_len > 1) {
@@ -5214,7 +5214,7 @@ static int bpy_class_call(PointerRNA *ptr, FunctionRNA *func, ParameterList *par
/* only useful for single argument returns, we'll need another list loop for multiple */
if (flag & PROP_OUTPUT) {
err= pyrna_py_to_prop(&funcptr, parm, parms, iter.data, PyTuple_GET_ITEM(ret, i++), "calling class function:");
err= pyrna_py_to_prop(&funcptr, parm, iter.data, PyTuple_GET_ITEM(ret, i++), "calling class function:");
if(err)
break;
}
@@ -5328,7 +5328,7 @@ void pyrna_free_types(void)
* - Should still be fixed - Campbell
* */
static PyObject *pyrna_basetype_register(PyObject *self, PyObject *py_class)
static PyObject *pyrna_basetype_register(PyObject *UNUSED(self), PyObject *py_class)
{
bContext *C= NULL;
ReportList reports;
@@ -5425,7 +5425,7 @@ static int pyrna_srna_contains_pointer_prop_srna(StructRNA *srna_props, StructRN
return 0;
}
static PyObject *pyrna_basetype_unregister(PyObject *self, PyObject *py_class)
static PyObject *pyrna_basetype_unregister(PyObject *UNUSED(self), PyObject *py_class)
{
bContext *C= NULL;
StructUnregisterFunc unreg;

View File

@@ -99,7 +99,7 @@ void pyrna_alloc_types(void);
void pyrna_free_types(void);
/* primitive type conversion */
int pyrna_py_to_array(PointerRNA *ptr, PropertyRNA *prop, ParameterList *parms, char *param_data, PyObject *py, const char *error_prefix);
int pyrna_py_to_array(PointerRNA *ptr, PropertyRNA *prop, char *param_data, PyObject *py, const char *error_prefix);
int pyrna_py_to_array_index(PointerRNA *ptr, PropertyRNA *prop, int arraydim, int arrayoffset, int index, PyObject *py, const char *error_prefix);
PyObject *pyrna_array_index(PointerRNA *ptr, PropertyRNA *prop, int index);

View File

@@ -27,6 +27,7 @@
#include "bpy_util.h"
#include "DNA_screen_types.h"
#include "BKE_utildefines.h"
#include "BKE_context.h"
#include "ED_space_api.h"
@@ -34,7 +35,7 @@
#define RNA_CAPSULE_ID "RNA_HANDLE"
#define RNA_CAPSULE_ID_INVALID "RNA_HANDLE_REMOVED"
void cb_region_draw(const bContext *C, ARegion *ar, void *customdata)
void cb_region_draw(const bContext *C, ARegion *UNUSED(ar), void *customdata)
{
PyObject *cb_func, *cb_args, *result;
PyGILState_STATE gilstate;