[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [47680] trunk/blender/source/blender: change RNA_struct_find_function to accept a type rather then a PointerRNA, add a check duplicate functions are not defined.

Campbell Barton ideasman42 at gmail.com
Sun Jun 10 15:35:09 CEST 2012


Revision: 47680
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=47680
Author:   campbellbarton
Date:     2012-06-10 13:34:59 +0000 (Sun, 10 Jun 2012)
Log Message:
-----------
change RNA_struct_find_function to accept a type rather then a PointerRNA, add a check duplicate functions are not defined.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/include/UI_interface.h
    trunk/blender/source/blender/editors/interface/interface_handlers.c
    trunk/blender/source/blender/makesrna/RNA_access.h
    trunk/blender/source/blender/makesrna/intern/rna_access.c
    trunk/blender/source/blender/makesrna/intern/rna_define.c
    trunk/blender/source/blender/python/intern/bpy_rna.c

Modified: trunk/blender/source/blender/editors/include/UI_interface.h
===================================================================
--- trunk/blender/source/blender/editors/include/UI_interface.h	2012-06-10 13:25:04 UTC (rev 47679)
+++ trunk/blender/source/blender/editors/include/UI_interface.h	2012-06-10 13:34:59 UTC (rev 47680)
@@ -195,7 +195,8 @@
 /*#define FUN	192*/ /*UNUSED*/
 #define BIT 256
 
-#define BUTPOIN (128 + 64 + 32)
+/* button reqyires a pointer */
+#define BUTPOIN (FLO | SHO | CHA)
 
 #define BUT (1 << 9)
 #define ROW (2 << 9)

Modified: trunk/blender/source/blender/editors/interface/interface_handlers.c
===================================================================
--- trunk/blender/source/blender/editors/interface/interface_handlers.c	2012-06-10 13:25:04 UTC (rev 47679)
+++ trunk/blender/source/blender/editors/interface/interface_handlers.c	2012-06-10 13:34:59 UTC (rev 47680)
@@ -3819,22 +3819,21 @@
 	Histogram *hist = (Histogram *)but->poin;
 	/* rcti rect; */
 	int changed = 1;
-	float /* dx, */ dy, yfac = 1.f; /* UNUSED */
+	float /* dx, */ dy; /* UNUSED */
 	
 	/* rect.xmin = but->x1; rect.xmax = but->x2; */
 	/* rect.ymin = but->y1; rect.ymax = but->y2; */
 	
 	/* dx = mx - data->draglastx; */ /* UNUSED */
 	dy = my - data->draglasty;
-	
-	
+
 	if (in_scope_resize_zone(but, data->dragstartx, data->dragstarty)) {
 		/* resize histogram widget itself */
 		hist->height = (but->y2 - but->y1) + (data->dragstarty - my);
 	}
 	else {
 		/* scale histogram values */
-		yfac = MIN2(powf(hist->ymax, 2.f), 1.f) * 0.5f;
+		const float yfac = MIN2(powf(hist->ymax, 2.f), 1.f) * 0.5f;
 		hist->ymax += dy * yfac;
 	
 		CLAMP(hist->ymax, 1.f, 100.f);

Modified: trunk/blender/source/blender/makesrna/RNA_access.h
===================================================================
--- trunk/blender/source/blender/makesrna/RNA_access.h	2012-06-10 13:25:04 UTC (rev 47679)
+++ trunk/blender/source/blender/makesrna/RNA_access.h	2012-06-10 13:34:59 UTC (rev 47680)
@@ -675,7 +675,7 @@
 const struct ListBase *RNA_struct_type_properties(StructRNA *srna);
 PropertyRNA *RNA_struct_type_find_property(StructRNA *srna, const char *identifier);
 
-FunctionRNA *RNA_struct_find_function(PointerRNA *ptr, const char *identifier);
+FunctionRNA *RNA_struct_find_function(StructRNA *srna, const char *identifier);
 const struct ListBase *RNA_struct_type_functions(StructRNA *srna);
 
 char *RNA_struct_name_get_alloc(PointerRNA *ptr, char *fixedbuf, int fixedlen, int *r_len);

Modified: trunk/blender/source/blender/makesrna/intern/rna_access.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_access.c	2012-06-10 13:25:04 UTC (rev 47679)
+++ trunk/blender/source/blender/makesrna/intern/rna_access.c	2012-06-10 13:34:59 UTC (rev 47680)
@@ -664,12 +664,12 @@
 	return BLI_findstring_ptr(&srna->cont.properties, identifier, offsetof(PropertyRNA, identifier));
 }
 
-FunctionRNA *RNA_struct_find_function(PointerRNA *ptr, const char *identifier)
+FunctionRNA *RNA_struct_find_function(StructRNA *srna, const char *identifier)
 {
 #if 1
 	FunctionRNA *func;
 	StructRNA *type;
-	for (type = ptr->type; type; type = type->base) {
+	for (type = srna; type; type = type->base) {
 		func = (FunctionRNA *)BLI_findstring_ptr(&type->functions, identifier, offsetof(FunctionRNA, identifier));
 		if (func) {
 			return func;
@@ -683,7 +683,7 @@
 	PropertyRNA *iterprop;
 	FunctionRNA *func;
 
-	RNA_pointer_create(NULL, &RNA_Struct, ptr->type, &tptr);
+	RNA_pointer_create(NULL, &RNA_Struct, srna, &tptr);
 	iterprop = RNA_struct_find_property(&tptr, "functions");
 
 	func = NULL;
@@ -5132,7 +5132,7 @@
 {
 	FunctionRNA *func;
 
-	func = RNA_struct_find_function(ptr, identifier);
+	func = RNA_struct_find_function(ptr->type, identifier);
 
 	if (func)
 		return RNA_function_call(C, reports, ptr, func, parms);
@@ -5160,7 +5160,7 @@
 {
 	FunctionRNA *func;
 
-	func = RNA_struct_find_function(ptr, identifier);
+	func = RNA_struct_find_function(ptr->type, identifier);
 
 	if (func) {
 		va_list args;
@@ -5535,7 +5535,7 @@
 {
 	FunctionRNA *func;
 
-	func = RNA_struct_find_function(ptr, identifier);
+	func = RNA_struct_find_function(ptr->type, identifier);
 
 	if (func)
 		return RNA_function_call_direct_va(C, reports, ptr, func, format, args);

Modified: trunk/blender/source/blender/makesrna/intern/rna_define.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_define.c	2012-06-10 13:25:04 UTC (rev 47679)
+++ trunk/blender/source/blender/makesrna/intern/rna_define.c	2012-06-10 13:34:59 UTC (rev 47680)
@@ -29,6 +29,7 @@
 #include <limits.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <stddef.h>
 #include <string.h>
 #include <ctype.h>
 
@@ -38,6 +39,7 @@
 #include "DNA_sdna_types.h"
 
 #include "BLI_utildefines.h"
+#include "BLI_listbase.h"
 #include "BLI_ghash.h"
 
 #include "RNA_define.h"
@@ -2631,6 +2633,11 @@
 	FunctionRNA *func;
 	FunctionDefRNA *dfunc;
 
+	if (BLI_findstring_ptr(&srna->functions, identifier, offsetof(FunctionRNA, identifier))) {
+		fprintf(stderr, "%s: %s.%s already defined.\n", __func__, srna->identifier, identifier);
+		return NULL;
+	}
+
 	func = rna_def_function(srna, identifier);
 
 	if (!DefRNA.preprocess) {

Modified: trunk/blender/source/blender/python/intern/bpy_rna.c
===================================================================
--- trunk/blender/source/blender/python/intern/bpy_rna.c	2012-06-10 13:25:04 UTC (rev 47679)
+++ trunk/blender/source/blender/python/intern/bpy_rna.c	2012-06-10 13:34:59 UTC (rev 47680)
@@ -3467,7 +3467,7 @@
 		ret = pyrna_prop_to_py(&self->ptr, prop);
 	}
 	/* RNA function only if callback is declared (no optional functions) */
-	else if ((func = RNA_struct_find_function(&self->ptr, name)) && RNA_function_defined(func)) {
+	else if ((func = RNA_struct_find_function(self->ptr.type, name)) && RNA_function_defined(func)) {
 		ret = pyrna_func_to_py(&self->ptr, func);
 	}
 	else if (self->ptr.type == &RNA_Context) {
@@ -3780,7 +3780,7 @@
 
 				return ret;
 			}
-			else if ((func = RNA_struct_find_function(&r_ptr, name))) {
+			else if ((func = RNA_struct_find_function(r_ptr.type, name))) {
 				PyObject *self_collection = pyrna_struct_CreatePyObject(&r_ptr);
 				ret = pyrna_func_to_py(&((BPy_DummyPointerRNA *)self_collection)->ptr, func);
 				Py_DECREF(self_collection);




More information about the Bf-blender-cvs mailing list