diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-06-10 17:34:59 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-06-10 17:34:59 +0400 |
commit | f6e21881f5d0f86725836391d20949fe0343bd19 (patch) | |
tree | 12287d7789e683c69ce8c3157293edf7f0f283d2 | |
parent | 219eca0f515f9a54953566539520fde37f2ea13b (diff) |
change RNA_struct_find_function to accept a type rather then a PointerRNA, add a check duplicate functions are not defined.
-rw-r--r-- | source/blender/editors/include/UI_interface.h | 3 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_handlers.c | 7 | ||||
-rw-r--r-- | source/blender/makesrna/RNA_access.h | 2 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_access.c | 12 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_define.c | 7 | ||||
-rw-r--r-- | source/blender/python/intern/bpy_rna.c | 4 |
6 files changed, 21 insertions, 14 deletions
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index b82a0c5e480..bb6f9fad771 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -195,7 +195,8 @@ typedef struct uiLayout uiLayout; /*#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) diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 8753c427816..a2adbd7a143 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -3819,22 +3819,21 @@ static int ui_numedit_but_HISTOGRAM(uiBut *but, uiHandleButtonData *data, int mx 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); diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h index 37455563ee0..8fc39c95d81 100644 --- a/source/blender/makesrna/RNA_access.h +++ b/source/blender/makesrna/RNA_access.h @@ -675,7 +675,7 @@ int RNA_struct_contains_property(PointerRNA *ptr, PropertyRNA *prop_test); 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); diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index 5e8c6b33b0d..c8ca0be8ab7 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -664,12 +664,12 @@ PropertyRNA *RNA_struct_type_find_property(StructRNA *srna, const char *identifi 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 @@ FunctionRNA *RNA_struct_find_function(PointerRNA *ptr, const char *identifier) 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 @@ int RNA_function_call_lookup(bContext *C, ReportList *reports, PointerRNA *ptr, { 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 @@ int RNA_function_call_direct_lookup(bContext *C, ReportList *reports, PointerRNA { 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 @@ int RNA_function_call_direct_va_lookup(bContext *C, ReportList *reports, Pointer { 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); diff --git a/source/blender/makesrna/intern/rna_define.c b/source/blender/makesrna/intern/rna_define.c index 7d73de00b49..02d8cbef4a3 100644 --- a/source/blender/makesrna/intern/rna_define.c +++ b/source/blender/makesrna/intern/rna_define.c @@ -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 *RNA_def_function(StructRNA *srna, const char *identifier, const cha 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) { diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index 873f5353bff..04f9a90f0d2 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -3467,7 +3467,7 @@ static PyObject *pyrna_struct_getattro(BPy_StructRNA *self, PyObject *pyname) 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 @@ static PyObject *pyrna_prop_collection_getattro(BPy_PropertyRNA *self, PyObject 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); |