[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [32456] trunk/blender/source/blender: UNUSED() macro so -Wunused-parameter can be used with GCC without so many warnings.

Campbell Barton ideasman42 at gmail.com
Thu Oct 14 01:25:08 CEST 2010


Revision: 32456
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=32456
Author:   campbellbarton
Date:     2010-10-14 01:25:08 +0200 (Thu, 14 Oct 2010)

Log Message:
-----------
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.

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/BKE_utildefines.h
    trunk/blender/source/blender/blenkernel/intern/exotic.c
    trunk/blender/source/blender/python/generic/IDProp.c
    trunk/blender/source/blender/python/generic/bgl.c
    trunk/blender/source/blender/python/generic/blf_api.c
    trunk/blender/source/blender/python/generic/bpy_internal_import.c
    trunk/blender/source/blender/python/generic/geometry.c
    trunk/blender/source/blender/python/generic/mathutils.c
    trunk/blender/source/blender/python/generic/mathutils_color.c
    trunk/blender/source/blender/python/generic/mathutils_euler.c
    trunk/blender/source/blender/python/generic/mathutils_matrix.c
    trunk/blender/source/blender/python/generic/mathutils_quat.c
    trunk/blender/source/blender/python/generic/mathutils_vector.c
    trunk/blender/source/blender/python/generic/noise.c
    trunk/blender/source/blender/python/intern/bpy.c
    trunk/blender/source/blender/python/intern/bpy_app.c
    trunk/blender/source/blender/python/intern/bpy_array.c
    trunk/blender/source/blender/python/intern/bpy_interface.c
    trunk/blender/source/blender/python/intern/bpy_operator.c
    trunk/blender/source/blender/python/intern/bpy_operator_wrap.c
    trunk/blender/source/blender/python/intern/bpy_rna.c
    trunk/blender/source/blender/python/intern/bpy_rna.h
    trunk/blender/source/blender/python/intern/bpy_rna_callback.c

Modified: trunk/blender/source/blender/blenkernel/BKE_utildefines.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_utildefines.h	2010-10-13 22:20:34 UTC (rev 32455)
+++ trunk/blender/source/blender/blenkernel/BKE_utildefines.h	2010-10-13 23:25:08 UTC (rev 32456)
@@ -44,6 +44,12 @@
 #define STRINGIFY_ARG(x) #x
 #define STRINGIFY(x) STRINGIFY_ARG(x)
 
+#ifdef __GNUC__
+#  define UNUSED(x) x __attribute__((__unused__))
+#else
+#  define UNUSED(x) x
+#endif
+
 /* these values need to be hardcoded in structs, dna does not recognize defines */
 /* also defined in DNA_space_types.h */
 #ifndef FILE_MAXDIR

Modified: trunk/blender/source/blender/blenkernel/intern/exotic.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/exotic.c	2010-10-13 22:20:34 UTC (rev 32455)
+++ trunk/blender/source/blender/blenkernel/intern/exotic.c	2010-10-13 23:25:08 UTC (rev 32456)
@@ -557,7 +557,7 @@
 	return numfacets;
 }
 
-static int write_object_stl(FILE *fpSTL, Scene *scene, Object *ob, Mesh *me)
+static int write_object_stl(FILE *fpSTL, Scene *scene, Object *ob)
 {
 	int  numfacets = 0;
 	DerivedMesh *dm = mesh_get_derived_final(scene, ob, CD_MASK_BAREMESH);
@@ -572,7 +572,6 @@
 void write_stl(Scene *scene, char *str)
 {
 	Object *ob;
-	Mesh   *me;
 	Base   *base;
 	FILE   *fpSTL;
 	int    numfacets = 0;
@@ -605,9 +604,8 @@
 		if (base->flag & SELECT) {
 			ob = base->object;
 			if (ob->type == OB_MESH) {
-				me = ob->data;
-				if (me)
-					numfacets += write_object_stl(fpSTL, scene, ob, me);
+				if(ob->data)
+					numfacets += write_object_stl(fpSTL, scene, ob);
 			}
 		}
 		base= base->next;
@@ -978,7 +976,7 @@
 	return 1;
 }
 
-static int dxf_get_layer_col(char *layer) 
+static int dxf_get_layer_col(char *UNUSED(layer)) 
 {
 	return 1;
 }
@@ -1016,8 +1014,8 @@
 		/* three types of enters, \n \r and \r\n  */
 		if(c == '\n') break;
 		if(c=='\r') {
-			c= getc(dxf_fp);				// read the linefeed from stream
-			if(c != 10) ungetc(c, dxf_fp);	// put back, if it's not one...
+			c= getc(fp);				// read the linefeed from stream
+			if(c != 10) ungetc(c, fp);	// put back, if it's not one...
 			break;
 		}
 	}

Modified: trunk/blender/source/blender/python/generic/IDProp.c
===================================================================
--- trunk/blender/source/blender/python/generic/IDProp.c	2010-10-13 22:20:34 UTC (rev 32455)
+++ trunk/blender/source/blender/python/generic/IDProp.c	2010-10-13 23:25:08 UTC (rev 32456)
@@ -24,6 +24,7 @@
  */
 
 #include "BKE_idprop.h"
+#include "BKE_utildefines.h"
 #include "IDProp.h"
 #include "MEM_guardedalloc.h"
 
@@ -177,12 +178,12 @@
 	return 0;
 }
 
-PyObject *BPy_IDGroup_GetName(BPy_IDProperty *self, void *bleh)
+PyObject *BPy_IDGroup_GetName(BPy_IDProperty *self, void *UNUSED(closure))
 {
 	return PyUnicode_FromString(self->prop->name);
 }
 
-static int BPy_IDGroup_SetName(BPy_IDProperty *self, PyObject *value, void *bleh)
+static int BPy_IDGroup_SetName(BPy_IDProperty *self, PyObject *value, void *UNUSED(closure))
 {
 	char *st;
 	if (!PyUnicode_Check(value)) {
@@ -860,7 +861,7 @@
 
 static PyObject *IDArray_repr(BPy_IDArray *self)
 {
-	return PyUnicode_FromString("(ID Array)");
+	return PyUnicode_FromFormat("(ID Array [%d])", self->prop->len);
 }
 
 
@@ -1071,7 +1072,7 @@
 
 static PyObject *IDGroup_Iter_repr(BPy_IDGroup_Iter *self)
 {
-	return PyUnicode_FromString("(ID Property Group)");
+	return PyUnicode_FromFormat("(ID Property Group Iter \"%s\")", self->group->prop->name);
 }
 
 static PyObject *BPy_Group_Iter_Next(BPy_IDGroup_Iter *self)

Modified: trunk/blender/source/blender/python/generic/bgl.c
===================================================================
--- trunk/blender/source/blender/python/generic/bgl.c	2010-10-13 22:20:34 UTC (rev 32455)
+++ trunk/blender/source/blender/python/generic/bgl.c	2010-10-13 23:25:08 UTC (rev 32456)
@@ -35,6 +35,8 @@
 #include <GL/glew.h>
 #include "MEM_guardedalloc.h"
 
+#include "BKE_utildefines.h"
+
 static char Method_Buffer_doc[] =
 	"(type, dimensions, [template]) - Create a new Buffer object\n\n\
 (type) - The format to store data in\n\
@@ -51,7 +53,7 @@
 square buffer. Passing [16, 16, 32] will create a 3 dimensional\n\
 buffer which is twice as deep as it is wide or high.";
 
-static PyObject *Method_Buffer( PyObject * self, PyObject * args );
+static PyObject *Method_Buffer( PyObject * self, PyObject *args );
 
 /* Buffer sequence methods */
 
@@ -99,7 +101,7 @@
 /* #ifndef __APPLE__ */
 
 #define BGL_Wrap(nargs, funcname, ret, arg_list) \
-static PyObject *Method_##funcname (PyObject *self, PyObject *args) {\
+static PyObject *Method_##funcname (PyObject *UNUSED(self), PyObject *args) {\
 	arg_def##nargs arg_list; \
 	ret_def_##ret; \
 	if(!PyArg_ParseTuple(args, arg_str##nargs arg_list, arg_ref##nargs arg_list)) return NULL;\
@@ -108,7 +110,7 @@
 }
 
 #define BGLU_Wrap(nargs, funcname, ret, arg_list) \
-static PyObject *Method_##funcname (PyObject *self, PyObject *args) {\
+static PyObject *Method_##funcname (PyObject *UNUSED(self), PyObject *args) {\
 	arg_def##nargs arg_list; \
 	ret_def_##ret; \
 	if(!PyArg_ParseTuple(args, arg_str##nargs arg_list, arg_ref##nargs arg_list)) return NULL;\
@@ -181,7 +183,7 @@
 }
 
 #define MAX_DIMENSIONS	256
-static PyObject *Method_Buffer (PyObject *self, PyObject *args)
+static PyObject *Method_Buffer (PyObject *UNUSED(self), PyObject *args)
 {
 	PyObject *length_ob= NULL, *template= NULL;
 	Buffer *buffer;

Modified: trunk/blender/source/blender/python/generic/blf_api.c
===================================================================
--- trunk/blender/source/blender/python/generic/blf_api.c	2010-10-13 22:20:34 UTC (rev 32455)
+++ trunk/blender/source/blender/python/generic/blf_api.c	2010-10-13 23:25:08 UTC (rev 32456)
@@ -26,6 +26,7 @@
 #include "blf_api.h"
 
 #include "../../blenfont/BLF_api.h"
+#include "BKE_utildefines.h"
 
 static char py_blf_position_doc[] =
 ".. function:: position(fontid, x, y, z)\n"
@@ -41,7 +42,7 @@
 "   :arg z: Z axis position to draw the text.\n"
 "   :type z: float\n";
 
-static PyObject *py_blf_position(PyObject *self, PyObject *args)
+static PyObject *py_blf_position(PyObject *UNUSED(self), PyObject *args)
 {
 	int fontid;
 	float x, y, z;
@@ -67,7 +68,7 @@
 "   :arg dpi: dots per inch value to use for drawing.\n"
 "   :type dpi: int\n";
 
-static PyObject *py_blf_size(PyObject *self, PyObject *args)
+static PyObject *py_blf_size(PyObject *UNUSED(self), PyObject *args)
 {
 	int fontid, size, dpi;
 
@@ -90,7 +91,7 @@
 "   :arg aspect: The aspect ratio for text drawing to use.\n"
 "   :type aspect: float\n";
 
-static PyObject *py_blf_aspect(PyObject *self, PyObject *args)
+static PyObject *py_blf_aspect(PyObject *UNUSED(self), PyObject *args)
 {
 	float aspect;
 	int fontid;
@@ -114,7 +115,7 @@
 "   :arg radius: The radius for blurring text (in pixels).\n"
 "   :type radius: int\n";
 
-static PyObject *py_blf_blur(PyObject *self, PyObject *args)
+static PyObject *py_blf_blur(PyObject *UNUSED(self), PyObject *args)
 {
 	int blur, fontid;
 
@@ -137,7 +138,7 @@
 "   :arg text: the text to draw.\n"
 "   :type text: string\n";
 
-static PyObject *py_blf_draw(PyObject *self, PyObject *args)
+static PyObject *py_blf_draw(PyObject *UNUSED(self), PyObject *args)
 {
 	char *text;
 	int fontid;
@@ -162,7 +163,7 @@
 "   :return: the width and height of the text.\n"
 "   :rtype: tuple of 2 floats\n";
 
-static PyObject *py_blf_dimensions(PyObject *self, PyObject *args)
+static PyObject *py_blf_dimensions(PyObject *UNUSED(self), PyObject *args)
 {
 	char *text;
 	float r_width, r_height;
@@ -196,7 +197,7 @@
 "   :arg ymax: Clip the drawing area by these bounds.\n"
 "   :type ymax: float\n";
 
-static PyObject *py_blf_clipping(PyObject *self, PyObject *args)
+static PyObject *py_blf_clipping(PyObject *UNUSED(self), PyObject *args)
 {
 	float xmin, ymin, xmax, ymax;
 	int fontid;
@@ -219,7 +220,7 @@
 "   :arg option: One of ROTATION, CLIPPING, SHADOW or KERNING_DEFAULT.\n"
 "   :type option: int\n";
 
-static PyObject *py_blf_disable(PyObject *self, PyObject *args)
+static PyObject *py_blf_disable(PyObject *UNUSED(self), PyObject *args)
 {
 	int option, fontid;
 
@@ -241,7 +242,7 @@
 "   :arg option: One of ROTATION, CLIPPING, SHADOW or KERNING_DEFAULT.\n"
 "   :type option: int\n";
 
-static PyObject *py_blf_enable(PyObject *self, PyObject *args)
+static PyObject *py_blf_enable(PyObject *UNUSED(self), PyObject *args)
 {
 	int option, fontid;
 
@@ -263,7 +264,7 @@
 "   :arg angle: The angle for text drawing to use.\n"
 "   :type angle: float\n";
 
-static PyObject *py_blf_rotation(PyObject *self, PyObject *args)
+static PyObject *py_blf_rotation(PyObject *UNUSED(self), PyObject *args)
 {
 	float angle;
 	int fontid;
@@ -294,7 +295,7 @@
 "   :arg a: Shadow color (alpha channel 0.0 - 1.0).\n"
 "   :type a: float\n";
 
-static PyObject *py_blf_shadow(PyObject *self, PyObject *args)
+static PyObject *py_blf_shadow(PyObject *UNUSED(self), PyObject *args)
 {
 	int level, fontid;
 	float r, g, b, a;
@@ -324,7 +325,7 @@
 "   :arg y: Horizontal shadow offset value in pixels.\n"
 "   :type y: float\n";
 
-static PyObject *py_blf_shadow_offset(PyObject *self, PyObject *args)
+static PyObject *py_blf_shadow_offset(PyObject *UNUSED(self), PyObject *args)
 {
 	int x, y, fontid;
 
@@ -346,7 +347,7 @@
 "   :return: the new font's fontid or -1 if there was an error.\n"
 "   :rtype: integer\n";
 
-static PyObject *py_blf_load(PyObject *self, PyObject *args)
+static PyObject *py_blf_load(PyObject *UNUSED(self), PyObject *args)
 {
 	char* filename;
 

Modified: trunk/blender/source/blender/python/generic/bpy_internal_import.c
===================================================================
--- trunk/blender/source/blender/python/generic/bpy_internal_import.c	2010-10-13 22:20:34 UTC (rev 32455)
+++ trunk/blender/source/blender/python/generic/bpy_internal_import.c	2010-10-13 23:25:08 UTC (rev 32456)
@@ -30,6 +30,7 @@
 #include "DNA_text_types.h"
 
 #include "MEM_guardedalloc.h"
+#include "BKE_utildefines.h" /* UNUSED */	
 #include "BKE_text.h" /* txt_to_buf */	
 #include "BKE_main.h"
 #include "BKE_global.h" /* grr, only for G.sce */
@@ -191,7 +192,7 @@
 }
 
 
-static PyObject *blender_import( PyObject * self, PyObject * args,  PyObject * kw)
+static PyObject *blender_import(PyObject *UNUSED(self), PyObject *args,  PyObject * kw)
 {
 	PyObject *exception, *err, *tb;
 	char *name;
@@ -244,7 +245,7 @@

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list