[Lua, Python, Tcl] C/C++ prototypes shown in error message when calling an overloaded method with incorrect arguments improved to show always show fully qualified name and if a const method. Also fixed other Lua error messages in generated code which weren't consistently using the fully qualified C++ name.

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12655 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
William S Fulton 2011-05-05 06:23:02 +00:00
commit b78392832f
7 changed files with 52 additions and 17 deletions

View file

@ -4,6 +4,14 @@ See the RELEASENOTES file for a summary of changes in each release.
Version 2.0.4 (in progress)
===========================
2011-05-05: wsfulton
[Lua, Python, Tcl] C/C++ prototypes shown in error message when calling an overloaded
method with incorrect arguments improved to show always show fully qualified name
and if a const method.
Also fixed other Lua error messages in generated code which weren't consistently
using the fully qualified C++ name - requested by Gedalia Pasternak.
2011-04-29: szager
Bug 2635919: Convenience method to convert std::map to a python dict.

View file

@ -446,10 +446,8 @@ public:
String *argument_check = NewString("");
String *argument_parse = NewString("");
String *checkfn = NULL;
// String *numoutputs=NULL;
char source[64];
//Printf(argument_check, "SWIG_check_num_args(\"%s\",%d,%d)\n",name,num_required,num_arguments);
Printf(argument_check, "SWIG_check_num_args(\"%s\",%d,%d)\n",name,num_required+args_to_ignore,num_arguments+args_to_ignore);
Printf(argument_check, "SWIG_check_num_args(\"%s\",%d,%d)\n",Swig_name_str(n),num_required+args_to_ignore,num_arguments+args_to_ignore);
for (i = 0, p = l; i < num_arguments; i++) {
@ -485,7 +483,7 @@ public:
} else {
Printf(argument_check, "if(lua_gettop(L)>=%s && !%s(L,%s))", source, checkfn, source);
}
Printf(argument_check, " SWIG_fail_arg(\"%s\",%s,\"%s\");\n", name, source, SwigType_str(pt, 0));
Printf(argument_check, " SWIG_fail_arg(\"%s\",%s,\"%s\");\n", Swig_name_str(n), source, SwigType_str(pt, 0));
}
/* NEW LANGUAGE NOTE:***********************************************
lua states the number of arguments passed to a function using the fn
@ -719,7 +717,9 @@ public:
sibl = Getattr(sibl, "sym:previousSibling"); // go all the way up
String *protoTypes = NewString("");
do {
Printf(protoTypes, "\n\" %s(%s)\\n\"", SwigType_str(Getattr(sibl, "name"), 0), ParmList_protostr(Getattr(sibl, "wrap:parms")));
String *fulldecl = Swig_name_decl(sibl);
Printf(protoTypes, "\n\" %s\\n\"", fulldecl);
Delete(fulldecl);
} while ((sibl = Getattr(sibl, "sym:nextSibling")));
Printf(f->code, "lua_pushstring(L,\"Wrong arguments for overloaded function '%s'\\n\"\n"
"\" Possible C/C++ prototypes are:\\n\"%s);\n",symname,protoTypes);

View file

@ -1917,7 +1917,9 @@ public:
sibl = Getattr(sibl, "sym:previousSibling"); // go all the way up
String *protoTypes = NewString("");
do {
Printf(protoTypes, "\n\" %s(%s)\\n\"", SwigType_str(Getattr(sibl, "name"), 0), ParmList_protostr(Getattr(sibl, "wrap:parms")));
String *fulldecl = Swig_name_decl(sibl);
Printf(protoTypes, "\n\" %s\\n\"", fulldecl);
Delete(fulldecl);
} while ((sibl = Getattr(sibl, "sym:nextSibling")));
Append(f->code, "fail:\n");
Printf(f->code, "SWIG_SetErrorMsg(PyExc_NotImplementedError,"

View file

@ -536,7 +536,9 @@ public:
sibl = Getattr(sibl, "sym:previousSibling"); // go all the way up
String *protoTypes = NewString("");
do {
Printf(protoTypes, "\n\" %s(%s)\\n\"", SwigType_str(Getattr(sibl, "name"), 0), ParmList_protostr(Getattr(sibl, "wrap:parms")));
String *fulldecl = Swig_name_decl(sibl);
Printf(protoTypes, "\n\" %s\\n\"", fulldecl);
Delete(fulldecl);
} while ((sibl = Getattr(sibl, "sym:nextSibling")));
Printf(df->code, "Tcl_SetResult(interp,(char *) "
"\"Wrong number or type of arguments for overloaded function '%s'.\\n\""

View file

@ -77,7 +77,7 @@ int ParmList_is_compactdefargs(ParmList *p) {
* ParmList_errorstr()
*
* Generate a prototype string suitable for use in error/warning messages.
* This function is aware of hidden parameters.
* Similar to ParmList_protostr() but is also aware of hidden parameters.
* ---------------------------------------------------------------------- */
/* Discussion. This function is used to generate error messages, but take

View file

@ -1617,21 +1617,20 @@ void Swig_name_inherit(String *base, String *derived) {
}
/* -----------------------------------------------------------------------------
* void Swig_name_decl()
* void Swig_name_str()
*
* Return a stringified version of a C/C++ declaration without the return type.
* Return a stringified version of a C/C++ symbol from a node.
* The node passed in is expected to be a function, constructor, destructor or
* variable. Some example return values:
* "MyNameSpace::MyTemplate<MyNameSpace::ABC >::~MyTemplate()"
* "MyNameSpace::ABC::ABC(int,double)"
* "MyNameSpace::ABC::constmethod(int) const"
* "MyNameSpace::MyTemplate<MyNameSpace::ABC >::~MyTemplate"
* "MyNameSpace::ABC::ABC"
* "MyNameSpace::ABC::constmethod"
* "MyNameSpace::ABC::variablename"
*
* ----------------------------------------------------------------------------- */
String *Swig_name_decl(Node *n) {
String *Swig_name_str(Node *n) {
String *qname;
String *decl;
String *qualifier = Swig_symbol_qualified(n);
String *name = Swig_scopename_last(Getattr(n, "name"));
if (qualifier)
@ -1657,13 +1656,36 @@ String *Swig_name_decl(Node *n) {
Printf(qname, "%s::", qualifier);
Printf(qname, "%s", SwigType_str(name, 0));
Delete(name);
Delete(qualifier);
return qname;
}
/* -----------------------------------------------------------------------------
* void Swig_name_decl()
*
* Return a stringified version of a C/C++ declaration without the return type.
* The node passed in is expected to be a function, constructor, destructor or
* variable. Some example return values:
* "MyNameSpace::MyTemplate<MyNameSpace::ABC >::~MyTemplate()"
* "MyNameSpace::ABC::ABC(int,double)"
* "MyNameSpace::ABC::constmethod(int) const"
* "MyNameSpace::ABC::variablename"
*
* ----------------------------------------------------------------------------- */
String *Swig_name_decl(Node *n) {
String *qname;
String *decl;
qname = Swig_name_str(n);
if (checkAttribute(n, "kind", "variable"))
decl = NewStringf("%s", qname);
else
decl = NewStringf("%s(%s)%s", qname, ParmList_errorstr(Getattr(n, "parms")), SwigType_isconst(Getattr(n, "decl")) ? " const" : "");
Delete(name);
Delete(qualifier);
Delete(qname);
return decl;

View file

@ -285,6 +285,7 @@ extern int ParmList_is_compactdefargs(ParmList *p);
extern String *Swig_name_make(Node *n, String *prefix, const_String_or_char_ptr cname, SwigType *decl, String *oldname);
extern String *Swig_name_warning(Node *n, String *prefix, String *name, SwigType *decl);
extern String *Swig_name_str(Node *n);
extern String *Swig_name_decl(Node *n);
extern String *Swig_name_fulldecl(Node *n);