- turn RNA_warning into a macro which includes the function name (was being written in manually but had incorrect func names in places).

- add __func__ define to BLI_utildefines.h for MSVC.
This commit is contained in:
Campbell Barton 2011-09-09 01:29:53 +00:00
parent ae7401751c
commit a59ba9a519
7 changed files with 67 additions and 54 deletions

@ -176,6 +176,12 @@
/* useful for debugging */
#define AT __FILE__ ":" STRINGIFY(__LINE__)
/* so we can use __func__ everywhere */
#if defined(_MSC_VER)
# define __func__ __FUNCTION__
#endif
/* UNUSED macro, for function argument */
#ifdef __GNUC__
# define UNUSED(x) UNUSED_ ## x __attribute__((__unused__))

@ -630,7 +630,7 @@ PointerRNA uiItemFullO(uiLayout *layout, const char *opname, const char *name, i
if(!ot) {
ui_item_disabled(layout, opname);
RNA_warning("uiItemFullO: unknown operator '%s'\n", opname);
RNA_warning("unknown operator '%s'", opname);
return PointerRNA_NULL;
}
@ -737,7 +737,7 @@ void uiItemsFullEnumO(uiLayout *layout, const char *opname, const char *propname
if(!ot || !ot->srna) {
ui_item_disabled(layout, opname);
RNA_warning("uiItemsFullEnumO: %s '%s'\n", ot ? "unknown operator" : "operator missing srna", opname);
RNA_warning("%s '%s'", ot ? "unknown operator" : "operator missing srna", opname);
return;
}
@ -815,7 +815,7 @@ void uiItemEnumO_value(uiLayout *layout, const char *name, int icon, const char
/* pass */
}
else {
RNA_warning("uiItemEnumO_value: %s.%s not found.\n", RNA_struct_identifier(ptr.type), propname);
RNA_warning("%s.%s not found.", RNA_struct_identifier(ptr.type), propname);
return;
}
@ -844,7 +844,7 @@ void uiItemEnumO_string(uiLayout *layout, const char *name, int icon, const char
RNA_property_enum_items(layout->root->block->evil_C, &ptr, prop, &item, NULL, &free);
if(item==NULL || RNA_enum_value_from_id(item, value_str, &value)==0) {
if(free) MEM_freeN(item);
RNA_warning("uiItemEnumO_string: %s.%s, enum %s not found.\n", RNA_struct_identifier(ptr.type), propname, value_str);
RNA_warning("%s.%s, enum %s not found.", RNA_struct_identifier(ptr.type), propname, value_str);
return;
}
@ -852,7 +852,7 @@ void uiItemEnumO_string(uiLayout *layout, const char *name, int icon, const char
MEM_freeN(item);
}
else {
RNA_warning("uiItemEnumO_string: %s.%s not found.\n", RNA_struct_identifier(ptr.type), propname);
RNA_warning("%s.%s not found.", RNA_struct_identifier(ptr.type), propname);
return;
}
@ -1059,7 +1059,7 @@ void uiItemR(uiLayout *layout, PointerRNA *ptr, const char *propname, int flag,
if(!prop) {
ui_item_disabled(layout, propname);
RNA_warning("uiItemR: property not found: %s.%s\n", RNA_struct_identifier(ptr->type), propname);
RNA_warning("property not found: %s.%s", RNA_struct_identifier(ptr->type), propname);
return;
}
@ -1072,7 +1072,7 @@ void uiItemEnumR(uiLayout *layout, const char *name, int icon, struct PointerRNA
if(!prop || RNA_property_type(prop) != PROP_ENUM) {
ui_item_disabled(layout, propname);
RNA_warning("uiItemEnumR: property not found: %s.%s\n", RNA_struct_identifier(ptr->type), propname);
RNA_warning("property not found: %s.%s", RNA_struct_identifier(ptr->type), propname);
return;
}
@ -1087,7 +1087,7 @@ void uiItemEnumR_string(uiLayout *layout, struct PointerRNA *ptr, const char *pr
if(!prop || RNA_property_type(prop) != PROP_ENUM) {
ui_item_disabled(layout, propname);
RNA_warning("uiItemEnumR_string: enum property not found: %s.%s\n", RNA_struct_identifier(ptr->type), propname);
RNA_warning("enum property not found: %s.%s", RNA_struct_identifier(ptr->type), propname);
return;
}
@ -1096,7 +1096,7 @@ void uiItemEnumR_string(uiLayout *layout, struct PointerRNA *ptr, const char *pr
if(!RNA_enum_value_from_id(item, value, &ivalue)) {
if(free) MEM_freeN(item);
ui_item_disabled(layout, propname);
RNA_warning("uiItemEnumR: enum property value not found: %s\n", value);
RNA_warning("enum property value not found: %s", value);
return;
}
@ -1121,12 +1121,12 @@ void uiItemsEnumR(uiLayout *layout, struct PointerRNA *ptr, const char *propname
if(!prop) {
ui_item_disabled(layout, propname);
RNA_warning("uiItemsEnumR: enum property not found: %s.%s\n", RNA_struct_identifier(ptr->type), propname);
RNA_warning("enum property not found: %s.%s", RNA_struct_identifier(ptr->type), propname);
return;
}
if(RNA_property_type(prop) != PROP_ENUM) {
RNA_warning("uiItemsEnumR: not an enum property: %s.%s\n", RNA_struct_identifier(ptr->type), propname);
RNA_warning("not an enum property: %s.%s", RNA_struct_identifier(ptr->type), propname);
return;
}
else {
@ -1314,13 +1314,13 @@ void uiItemPointerR(uiLayout *layout, struct PointerRNA *ptr, const char *propna
prop= RNA_struct_find_property(ptr, propname);
if(!prop) {
RNA_warning("uiItemPointerR: property not found: %s.%s\n", RNA_struct_identifier(ptr->type), propname);
RNA_warning("property not found: %s.%s", RNA_struct_identifier(ptr->type), propname);
return;
}
type= RNA_property_type(prop);
if(!ELEM(type, PROP_POINTER, PROP_STRING)) {
RNA_warning("uiItemPointerR: property %s must be a pointer or string.\n", propname);
RNA_warning("property %s must be a pointer or string.", propname);
return;
}
@ -1328,11 +1328,11 @@ void uiItemPointerR(uiLayout *layout, struct PointerRNA *ptr, const char *propna
if(!searchprop) {
RNA_warning("uiItemPointerR: search collection property not found: %s.%s\n", RNA_struct_identifier(ptr->type), searchpropname);
RNA_warning("search collection property not found: %s.%s", RNA_struct_identifier(ptr->type), searchpropname);
return;
}
else if (RNA_property_type(searchprop) != PROP_COLLECTION) {
RNA_warning("uiItemPointerR: search collection property is not a collection type: %s.%s\n", RNA_struct_identifier(ptr->type), searchpropname);
RNA_warning("search collection property is not a collection type: %s.%s", RNA_struct_identifier(ptr->type), searchpropname);
return;
}
@ -1417,7 +1417,7 @@ void uiItemM(uiLayout *layout, bContext *UNUSED(C), const char *menuname, const
mt= WM_menutype_find(menuname, FALSE);
if(mt==NULL) {
RNA_warning("uiItemM: not found %s\n", menuname);
RNA_warning("not found %s", menuname);
return;
}
@ -1537,12 +1537,12 @@ void uiItemMenuEnumO(uiLayout *layout, const char *opname, const char *propname,
if(!ot) {
ui_item_disabled(layout, opname);
RNA_warning("uiItemMenuEnumO: unknown operator '%s'\n", opname);
RNA_warning("unknown operator '%s'", opname);
return;
}
if(!ot->srna) {
ui_item_disabled(layout, opname);
RNA_warning("uiItemMenuEnumO: operator missing srna '%s'\n", opname);
RNA_warning("operator missing srna '%s'", opname);
return;
}
@ -1575,7 +1575,7 @@ void uiItemMenuEnumR(uiLayout *layout, struct PointerRNA *ptr, const char *propn
prop= RNA_struct_find_property(ptr, propname);
if(!prop) {
ui_item_disabled(layout, propname);
RNA_warning("uiItemMenuEnumR: property not found: %s.%s\n", RNA_struct_identifier(ptr->type), propname);
RNA_warning("property not found: %s.%s", RNA_struct_identifier(ptr->type), propname);
return;
}

@ -245,7 +245,7 @@ static void template_id_cb(bContext *C, void *arg_litem, void *arg_event)
switch(event) {
case UI_ID_BROWSE:
case UI_ID_PIN:
RNA_warning("warning, id event %d shouldnt come here\n", event);
RNA_warning("warning, id event %d shouldnt come here", event);
break;
case UI_ID_OPEN:
case UI_ID_ADD_NEW:
@ -488,7 +488,7 @@ static void ui_template_id(uiLayout *layout, bContext *C, PointerRNA *ptr, const
prop= RNA_struct_find_property(ptr, propname);
if(!prop || RNA_property_type(prop) != PROP_POINTER) {
RNA_warning("uiTemplateID: pointer property not found: %s.%s\n", RNA_struct_identifier(ptr->type), propname);
RNA_warning("pointer property not found: %s.%s", RNA_struct_identifier(ptr->type), propname);
return;
}
@ -549,11 +549,11 @@ void uiTemplateAnyID(uiLayout *layout, PointerRNA *ptr, const char *propname, co
propType= RNA_struct_find_property(ptr, proptypename);
if (!propID || RNA_property_type(propID) != PROP_POINTER) {
RNA_warning("uiTemplateAnyID: pointer property not found: %s.%s\n", RNA_struct_identifier(ptr->type), propname);
RNA_warning("pointer property not found: %s.%s", RNA_struct_identifier(ptr->type), propname);
return;
}
if (!propType || RNA_property_type(propType) != PROP_ENUM) {
RNA_warning("uiTemplateAnyID: pointer-type property not found: %s.%s\n", RNA_struct_identifier(ptr->type), proptypename);
RNA_warning("pointer-type property not found: %s.%s", RNA_struct_identifier(ptr->type), proptypename);
return;
}
@ -592,7 +592,7 @@ void uiTemplatePathBuilder(uiLayout *layout, PointerRNA *ptr, const char *propna
/* check that properties are valid */
propPath= RNA_struct_find_property(ptr, propname);
if (!propPath || RNA_property_type(propPath) != PROP_STRING) {
RNA_warning("uiTemplatePathBuilder: path property not found: %s.%s\n", RNA_struct_identifier(ptr->type), propname);
RNA_warning("path property not found: %s.%s", RNA_struct_identifier(ptr->type), propname);
return;
}
@ -855,7 +855,7 @@ uiLayout *uiTemplateModifier(uiLayout *layout, bContext *C, PointerRNA *ptr)
/* verify we have valid data */
if(!RNA_struct_is_a(ptr->type, &RNA_Modifier)) {
RNA_warning("uiTemplateModifier: Expected modifier on object.\n");
RNA_warning("Expected modifier on object.");
return NULL;
}
@ -863,7 +863,7 @@ uiLayout *uiTemplateModifier(uiLayout *layout, bContext *C, PointerRNA *ptr)
md= ptr->data;
if(!ob || !(GS(ob->id.name) == ID_OB)) {
RNA_warning("uiTemplateModifier: Expected modifier on object.\n");
RNA_warning("expected modifier on object.");
return NULL;
}
@ -1084,7 +1084,7 @@ uiLayout *uiTemplateConstraint(uiLayout *layout, PointerRNA *ptr)
/* verify we have valid data */
if(!RNA_struct_is_a(ptr->type, &RNA_Constraint)) {
RNA_warning("uiTemplateConstraint: Expected constraint on object.\n");
RNA_warning("Expected constraint on object.");
return NULL;
}
@ -1092,7 +1092,7 @@ uiLayout *uiTemplateConstraint(uiLayout *layout, PointerRNA *ptr)
con= ptr->data;
if(!ob || !(GS(ob->id.name) == ID_OB)) {
RNA_warning("uiTemplateConstraint: Expected constraint on object.\n");
RNA_warning("Expected constraint on object.");
return NULL;
}
@ -1138,7 +1138,7 @@ void uiTemplatePreview(uiLayout *layout, ID *id, int show_buttons, ID *parent, M
PointerRNA texture_ptr;
if(id && !ELEM4(GS(id->name), ID_MA, ID_TE, ID_WO, ID_LA)) {
RNA_warning("uiTemplatePreview: Expected ID of type material, texture, lamp or world.\n");
RNA_warning("expected ID of type material, texture, lamp or world.");
return;
}
@ -1844,12 +1844,14 @@ void uiTemplateCurveMapping(uiLayout *layout, PointerRNA *ptr, const char *propn
PointerRNA cptr;
if(!prop) {
RNA_warning("uiTemplateCurveMapping: curve property not found: %s.%s\n", RNA_struct_identifier(ptr->type), propname);
RNA_warning("curve property not found: %s.%s",
RNA_struct_identifier(ptr->type), propname);
return;
}
if(RNA_property_type(prop) != PROP_POINTER) {
RNA_warning("uiTemplateCurveMapping: curve is not a pointer: %s.%s\n", RNA_struct_identifier(ptr->type), propname);
RNA_warning("curve is not a pointer: %s.%s",
RNA_struct_identifier(ptr->type), propname);
return;
}
@ -1879,7 +1881,7 @@ void uiTemplateColorWheel(uiLayout *layout, PointerRNA *ptr, const char *propnam
float softmin, softmax, step, precision;
if (!prop) {
RNA_warning("uiTemplateColorWheel: property not found: %s.%s\n", RNA_struct_identifier(ptr->type), propname);
RNA_warning("property not found: %s.%s", RNA_struct_identifier(ptr->type), propname);
return;
}
@ -1949,7 +1951,7 @@ void uiTemplateLayers(uiLayout *layout, PointerRNA *ptr, const char *propname,
prop= RNA_struct_find_property(ptr, propname);
if (!prop) {
RNA_warning("uiTemplateLayer: layers property not found: %s.%s\n", RNA_struct_identifier(ptr->type), propname);
RNA_warning("layers property not found: %s.%s", RNA_struct_identifier(ptr->type), propname);
return;
}
@ -1966,7 +1968,7 @@ void uiTemplateLayers(uiLayout *layout, PointerRNA *ptr, const char *propname,
if(used_ptr && used_propname) {
used_prop= RNA_struct_find_property(used_ptr, used_propname);
if (!used_prop) {
RNA_warning("uiTemplateLayer: used layers property not found: %s.%s\n", RNA_struct_identifier(ptr->type), used_propname);
RNA_warning("used layers property not found: %s.%s", RNA_struct_identifier(ptr->type), used_propname);
return;
}
@ -2157,7 +2159,7 @@ void uiTemplateList(uiLayout *layout, bContext *C, PointerRNA *ptr, const char *
pa= block->panel;
if(!pa) {
RNA_warning("uiTemplateList: only works inside a panel.\n");
RNA_warning("only works inside a panel.");
return;
}
@ -2167,28 +2169,28 @@ void uiTemplateList(uiLayout *layout, bContext *C, PointerRNA *ptr, const char *
if(ptr->data) {
prop= RNA_struct_find_property(ptr, propname);
if(!prop) {
RNA_warning("uiTemplateList: property not found: %s.%s\n", RNA_struct_identifier(ptr->type), propname);
RNA_warning("property not found: %s.%s", RNA_struct_identifier(ptr->type), propname);
return;
}
}
activeprop= RNA_struct_find_property(activeptr, activepropname);
if(!activeprop) {
RNA_warning("uiTemplateList: property not found: %s.%s\n", RNA_struct_identifier(ptr->type), activepropname);
RNA_warning("property not found: %s.%s", RNA_struct_identifier(ptr->type), activepropname);
return;
}
if(prop) {
type= RNA_property_type(prop);
if(type != PROP_COLLECTION) {
RNA_warning("uiTemplateList: Expected collection property.\n");
RNA_warning("uiExpected collection property.");
return;
}
}
activetype= RNA_property_type(activeprop);
if(activetype != PROP_INT) {
RNA_warning("uiTemplateList: Expected integer property.\n");
RNA_warning("expected integer property.");
return;
}

@ -974,7 +974,11 @@ int RNA_function_call_direct_va_lookup(struct bContext *C, struct ReportList *re
short RNA_type_to_ID_code(StructRNA *type);
StructRNA *ID_code_to_RNA_type(short idcode);
void RNA_warning(const char *format, ...)
/* macro which inserts the function name */
#define RNA_warning(format, args...) _RNA_warning("%s: " format "\n", __func__, ##args)
void _RNA_warning(const char *format, ...)
#ifdef __GNUC__
__attribute__ ((format (printf, 1, 2)))
#endif

@ -5374,7 +5374,8 @@ int RNA_property_copy(PointerRNA *ptr, PointerRNA *fromptr, PropertyRNA *prop, i
return 0;
}
void RNA_warning(const char *format, ...)
/* use RNA_warning macro which includes __func__ suffix */
void _RNA_warning(const char *format, ...)
{
va_list args;

@ -46,7 +46,7 @@ static void rna_uiItemR(uiLayout *layout, PointerRNA *ptr, const char *propname,
int flag= 0;
if(!prop) {
RNA_warning("rna_uiItemR: property not found: %s.%s\n", RNA_struct_identifier(ptr->type), propname);
RNA_warning("property not found: %s.%s", RNA_struct_identifier(ptr->type), propname);
return;
}

@ -5443,7 +5443,7 @@ static PyObject* pyrna_srna_ExternalType(StructRNA *srna)
if(bpy_types==NULL) {
PyErr_Print();
PyErr_Clear();
fprintf(stderr, "pyrna_srna_ExternalType: failed to find 'bpy_types' module\n");
fprintf(stderr, "%s: failed to find 'bpy_types' module\n", __func__);
return NULL;
}
bpy_types_dict= PyModule_GetDict(bpy_types); // borrow
@ -5457,18 +5457,18 @@ static PyObject* pyrna_srna_ExternalType(StructRNA *srna)
PyObject *base_compare= pyrna_srna_PyBase(srna);
//PyObject *slots= PyObject_GetAttrString(newclass, "__slots__"); // cant do this because it gets superclasses values!
//PyObject *bases= PyObject_GetAttrString(newclass, "__bases__"); // can do this but faster not to.
PyObject *bases= ((PyTypeObject *)newclass)->tp_bases;
PyObject *slots= PyDict_GetItem(((PyTypeObject *)newclass)->tp_dict, bpy_intern_str___slots__);
PyObject *tp_bases= ((PyTypeObject *)newclass)->tp_bases;
PyObject *tp_slots= PyDict_GetItem(((PyTypeObject *)newclass)->tp_dict, bpy_intern_str___slots__);
if(slots==NULL) {
fprintf(stderr, "pyrna_srna_ExternalType: expected class '%s' to have __slots__ defined\n\nSee bpy_types.py\n", idname);
if(tp_slots==NULL) {
fprintf(stderr, "%s: expected class '%s' to have __slots__ defined\n\nSee bpy_types.py\n", __func__, idname);
newclass= NULL;
}
else if(PyTuple_GET_SIZE(bases)) {
PyObject *base= PyTuple_GET_ITEM(bases, 0);
else if(PyTuple_GET_SIZE(tp_bases)) {
PyObject *base= PyTuple_GET_ITEM(tp_bases, 0);
if(base_compare != base) {
fprintf(stderr, "pyrna_srna_ExternalType: incorrect subclassing of SRNA '%s'\nSee bpy_types.py\n", idname);
fprintf(stderr, "%s: incorrect subclassing of SRNA '%s'\nSee bpy_types.py\n", __func__, idname);
PyC_ObSpit("Expected! ", base_compare);
newclass= NULL;
}
@ -5538,7 +5538,7 @@ static PyObject* pyrna_srna_Subtype(StructRNA *srna)
}
else {
/* this should not happen */
printf("Error registering '%s'\n", idname);
printf("%s: error registering '%s'\n", __func__, idname);
PyErr_Print();
PyErr_Clear();
}
@ -5581,7 +5581,7 @@ PyObject *pyrna_struct_CreatePyObject(PointerRNA *ptr)
Py_DECREF(tp); /* srna owns, cant hold a ref */
}
else {
fprintf(stderr, "Could not make type\n");
fprintf(stderr, "%s: could not make type\n", __func__);
pyrna= (BPy_StructRNA *) PyObject_GC_New(BPy_StructRNA, &pyrna_struct_Type);
#ifdef USE_WEAKREFS
pyrna->in_weakreflist= NULL;
@ -6231,10 +6231,10 @@ static int bpy_class_call(bContext *C, PointerRNA *ptr, FunctionRNA *func, Param
#endif
py_class= RNA_struct_py_type_get(ptr->type);
/* rare case. can happen when registering subclasses */
if(py_class==NULL) {
fprintf(stderr, "bpy_class_call(): unable to get python class for rna struct '%.200s'\n", RNA_struct_identifier(ptr->type));
fprintf(stderr, "%s: unable to get python class for rna struct '%.200s'\n",
__func__, RNA_struct_identifier(ptr->type));
return -1;
}