From 03ac417e7ff3d72340475fd505f87454b48da6f3 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 28 Feb 2008 23:14:07 +0000 Subject: [PATCH] simpler error display for method names using new Swig_name_decl() git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10281 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Modules/allocate.cxx | 2 +- Source/Modules/lang.cxx | 17 +++--------- Source/Modules/overload.cxx | 54 +++++++++++++++++-------------------- 3 files changed, 29 insertions(+), 44 deletions(-) diff --git a/Source/Modules/allocate.cxx b/Source/Modules/allocate.cxx index a45959205..e8397e6a6 100644 --- a/Source/Modules/allocate.cxx +++ b/Source/Modules/allocate.cxx @@ -613,7 +613,7 @@ Allocate(): if (na) { Swig_warning(WARN_TYPE_ABSTRACT, Getfile(n), Getline(n), "Class '%s' might be abstract, " "no constructors generated,\n", SwigType_namestr(Getattr(n, "name"))); - Swig_warning(WARN_TYPE_ABSTRACT, Getfile(na), Getline(na), " method '%s' might not be implemented.\n", SwigType_namestr(Getattr(na, "name"))); + Swig_warning(WARN_TYPE_ABSTRACT, Getfile(na), Getline(na), "Method %s might not be implemented.\n", Swig_name_decl(na)); if (!Getattr(n, "abstract")) { List *abstract = NewList(); Append(abstract, na); diff --git a/Source/Modules/lang.cxx b/Source/Modules/lang.cxx index 2f3e98672..c633e1dce 100644 --- a/Source/Modules/lang.cxx +++ b/Source/Modules/lang.cxx @@ -2300,8 +2300,6 @@ int Language::classDeclaration(Node *n) { } /* Check symbol name for template. If not renamed. Issue a warning */ - /* Printf(stdout,"sym:name = %s\n", symname); */ - if (!validIdentifier(symname)) { Swig_warning(WARN_LANG_IDENTIFIER, input_file, line_number, "Can't wrap class %s unless renamed to a valid identifier.\n", SwigType_namestr(symname)); return SWIG_NOWRAP; @@ -2481,8 +2479,7 @@ int Language::constructorDeclaration(Node *n) { return SWIG_NOWRAP; if (Extend) { - /* extend default constructor can be safely ignored if there is - already one */ + /* extend default constructor can be safely ignored if there is already one */ int num_required = ParmList_numrequired(Getattr(n, "parms")); if ((num_required == 0) && Getattr(CurrentClass, "has_default_constructor")) { return SWIG_NOWRAP; @@ -2495,8 +2492,7 @@ int Language::constructorDeclaration(Node *n) { } } - /* clean protected overloaded constructors, in case they are not - needed anymore */ + /* clean protected overloaded constructors, in case they are not needed anymore */ Node *over = Swig_symbol_isoverloaded(n); if (over && !Getattr(CurrentClass, "sym:cleanconstructor")) { int dirclass = Swig_directorclass(CurrentClass); @@ -2546,15 +2542,10 @@ int Language::constructorDeclaration(Node *n) { if (Getattr(over, "copy_constructor")) over = Getattr(over, "sym:nextSibling"); if (over != n) { - String *oname = NewStringf("%s::%s", ClassName, Swig_scopename_last(SwigType_namestr(name))); - String *cname = NewStringf("%s::%s", ClassName, Swig_scopename_last(SwigType_namestr(Getattr(over, "name")))); - SwigType *decl = Getattr(n, "decl"); Swig_warning(WARN_LANG_OVERLOAD_CONSTRUCT, input_file, line_number, - "Overloaded constructor ignored. %s\n", SwigType_str(decl, SwigType_namestr(oname))); + "Overloaded constructor ignored. %s\n", Swig_name_decl(n)); Swig_warning(WARN_LANG_OVERLOAD_CONSTRUCT, Getfile(over), Getline(over), - "Previous declaration is %s\n", SwigType_str(Getattr(over, "decl"), SwigType_namestr(cname))); - Delete(oname); - Delete(cname); + "Previous declaration is %s\n", Swig_name_decl(over)); } else { constructorHandler(n); } diff --git a/Source/Modules/overload.cxx b/Source/Modules/overload.cxx index fbd1a7e7d..d16913885 100644 --- a/Source/Modules/overload.cxx +++ b/Source/Modules/overload.cxx @@ -126,13 +126,13 @@ static List *Swig_overload_rank(Node *n, bool script_lang_wrapping) { String *t2 = Getattr(p2, "tmap:typecheck:precedence"); if ((!t1) && (!nodes[i].error)) { Swig_warning(WARN_TYPEMAP_TYPECHECK, Getfile(nodes[i].n), Getline(nodes[i].n), - "Overloaded %s(%s) not supported (no type checking rule for '%s').\n", - Getattr(nodes[i].n, "name"), ParmList_str_defaultargs(Getattr(nodes[i].n, "parms")), SwigType_str(Getattr(p1, "type"), 0)); + "Overloaded method %s not supported (no type checking rule for '%s').\n", + Swig_name_decl(nodes[i].n), SwigType_str(Getattr(p1, "type"), 0)); nodes[i].error = 1; } else if ((!t2) && (!nodes[j].error)) { Swig_warning(WARN_TYPEMAP_TYPECHECK, Getfile(nodes[j].n), Getline(nodes[j].n), - "Overloaded %s(%s) not supported (no type checking rule for '%s').\n", - Getattr(nodes[j].n, "name"), ParmList_str_defaultargs(Getattr(nodes[j].n, "parms")), SwigType_str(Getattr(p2, "type"), 0)); + "Overloaded method %s not supported (no type checking rule for '%s').\n", + Swig_name_decl(nodes[j].n), SwigType_str(Getattr(p2, "type"), 0)); nodes[j].error = 1; } if (t1 && t2) { @@ -223,14 +223,13 @@ static List *Swig_overload_rank(Node *n, bool script_lang_wrapping) { if (!nodes[j].error) { if (script_lang_wrapping) { Swig_warning(WARN_LANG_OVERLOAD_CONST, Getfile(nodes[j].n), Getline(nodes[j].n), - "Overloaded %s(%s) const ignored. Non-const method at %s:%d used.\n", - Getattr(nodes[j].n, "name"), ParmList_errorstr(nodes[j].parms), Getfile(nodes[i].n), Getline(nodes[i].n)); + "Overloaded method %s ignored. Non-const method %s at %s:%d used.\n", + Swig_name_decl(nodes[j].n), Swig_name_decl(nodes[i].n), Getfile(nodes[i].n), Getline(nodes[i].n)); } else { if (!Getattr(nodes[j].n, "overload:ignore")) Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[j].n), Getline(nodes[j].n), - "Overloaded method %s(%s) ignored. Method %s(%s) const at %s:%d used.\n", - Getattr(nodes[j].n, "name"), ParmList_errorstr(nodes[j].parms), - Getattr(nodes[i].n, "name"), ParmList_errorstr(nodes[i].parms), Getfile(nodes[i].n), Getline(nodes[i].n)); + "Overloaded method %s ignored. Method %s at %s:%d used.\n", + Swig_name_decl(nodes[j].n), Swig_name_decl(nodes[i].n), Getfile(nodes[i].n), Getline(nodes[i].n)); } } nodes[j].error = 1; @@ -239,14 +238,13 @@ static List *Swig_overload_rank(Node *n, bool script_lang_wrapping) { if (!nodes[j].error) { if (script_lang_wrapping) { Swig_warning(WARN_LANG_OVERLOAD_CONST, Getfile(nodes[j].n), Getline(nodes[j].n), - "Overloaded %s(%s) const ignored. Non-const method at %s:%d used.\n", - Getattr(nodes[j].n, "name"), ParmList_errorstr(nodes[j].parms), Getfile(nodes[i].n), Getline(nodes[i].n)); + "Overloaded method %s ignored. Non-const method %s at %s:%d used.\n", + Swig_name_decl(nodes[j].n), Swig_name_decl(nodes[i].n), Getfile(nodes[i].n), Getline(nodes[i].n)); } else { if (!Getattr(nodes[j].n, "overload:ignore")) Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[j].n), Getline(nodes[j].n), - "Overloaded method %s(%s) const ignored. Method %s(%s) at %s:%d used.\n", - Getattr(nodes[j].n, "name"), ParmList_errorstr(nodes[j].parms), - Getattr(nodes[i].n, "name"), ParmList_errorstr(nodes[i].parms), Getfile(nodes[i].n), Getline(nodes[i].n)); + "Overloaded method %s ignored. Method %s at %s:%d used.\n", + Swig_name_decl(nodes[j].n), Swig_name_decl(nodes[i].n), Getfile(nodes[i].n), Getline(nodes[i].n)); } } nodes[j].error = 1; @@ -260,19 +258,15 @@ static List *Swig_overload_rank(Node *n, bool script_lang_wrapping) { if (!nodes[j].error) { if (script_lang_wrapping) { Swig_warning(WARN_LANG_OVERLOAD_SHADOW, Getfile(nodes[j].n), Getline(nodes[j].n), - "Overloaded %s(%s)%s is shadowed by %s(%s)%s at %s:%d.\n", - Getattr(nodes[j].n, "name"), ParmList_errorstr(nodes[j].parms), - SwigType_isconst(Getattr(nodes[j].n, "decl")) ? " const" : "", - Getattr(nodes[i].n, "name"), ParmList_errorstr(nodes[i].parms), - SwigType_isconst(Getattr(nodes[i].n, "decl")) ? " const" : "", Getfile(nodes[i].n), Getline(nodes[i].n)); + "Overloaded method %s is shadowed by %s at %s:%d.\n", + Swig_name_decl(nodes[j].n), Swig_name_decl(nodes[i].n), + Getfile(nodes[i].n), Getline(nodes[i].n)); } else { if (!Getattr(nodes[j].n, "overload:ignore")) Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[j].n), Getline(nodes[j].n), - "Overloaded method %s(%s)%s ignored. Method %s(%s)%s at %s:%d used.\n", - Getattr(nodes[j].n, "name"), ParmList_errorstr(nodes[j].parms), - SwigType_isconst(Getattr(nodes[j].n, "decl")) ? " const" : "", - Getattr(nodes[i].n, "name"), ParmList_errorstr(nodes[i].parms), - SwigType_isconst(Getattr(nodes[i].n, "decl")) ? " const" : "", Getfile(nodes[i].n), Getline(nodes[i].n)); + "Overloaded method %s ignored. Method %s at %s:%d used.\n", + Swig_name_decl(nodes[j].n), Swig_name_decl(nodes[i].n), + Getfile(nodes[i].n), Getline(nodes[i].n)); } nodes[j].error = 1; } @@ -497,8 +491,8 @@ String *Swig_overload_dispatch_cast(Node *n, const String_or_char *fmt, int *max if (!Getattr(pj, "tmap:in:SWIGTYPE") && Getattr(pj, "tmap:typecheck:SWIGTYPE")) { /* we emit a warning if the argument defines the 'in' typemap, but not the 'typecheck' one */ Swig_warning(WARN_TYPEMAP_TYPECHECK_UNDEF, Getfile(ni), Getline(ni), - "Overloaded %s(%s) with no explicit typecheck typemap for arg %d of type '%s'\n", - Getattr(n, "name"), ParmList_str_defaultargs(pi), j + 1, SwigType_str(Getattr(pj, "type"), 0)); + "Overloaded method %s with no explicit typecheck typemap for arg %d of type '%s'\n", + Swig_name_decl(n), j, SwigType_str(Getattr(pj, "type"), 0)); } Parm *pj1 = Getattr(pj, "tmap:in:next"); if (pj1) @@ -670,8 +664,8 @@ String *Swig_overload_dispatch_fast(Node *n, const String_or_char *fmt, int *max if (!Getattr(pj, "tmap:in:SWIGTYPE") && Getattr(pj, "tmap:typecheck:SWIGTYPE")) { /* we emit a warning if the argument defines the 'in' typemap, but not the 'typecheck' one */ Swig_warning(WARN_TYPEMAP_TYPECHECK_UNDEF, Getfile(ni), Getline(ni), - "Overloaded %s(%s) with no explicit typecheck typemap for arg %d of type '%s'\n", - Getattr(n, "name"), ParmList_str_defaultargs(pi), j + 1, SwigType_str(Getattr(pj, "type"), 0)); + "Overloaded method %s with no explicit typecheck typemap for arg %d of type '%s'\n", + Swig_name_decl(n), j, SwigType_str(Getattr(pj, "type"), 0)); } Parm *pj1 = Getattr(pj, "tmap:in:next"); if (pj1) @@ -764,8 +758,8 @@ String *Swig_overload_dispatch(Node *n, const String_or_char *fmt, int *maxargs) if (!Getattr(pj, "tmap:in:SWIGTYPE") && Getattr(pj, "tmap:typecheck:SWIGTYPE")) { /* we emit a warning if the argument defines the 'in' typemap, but not the 'typecheck' one */ Swig_warning(WARN_TYPEMAP_TYPECHECK_UNDEF, Getfile(ni), Getline(ni), - "Overloaded %s(%s) with no explicit typecheck typemap for arg %d of type '%s'\n", - Getattr(n, "name"), ParmList_str_defaultargs(pi), j + 1, SwigType_str(Getattr(pj, "type"), 0)); + "Overloaded method %s with no explicit typecheck typemap for arg %d of type '%s'\n", + Swig_name_decl(n), j, SwigType_str(Getattr(pj, "type"), 0)); } Parm *pk = Getattr(pj, "tmap:in:next"); if (pk)