From b612f004edbc424efd46a689636942ceb84841df Mon Sep 17 00:00:00 2001 From: Marcelo Matus Date: Tue, 11 Apr 2006 01:42:10 +0000 Subject: [PATCH] better error message for overloading, as suggested by Tijs Michels, and doc fixes, provided by Olly git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@9048 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- SWIG/Source/Modules/python.cxx | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/SWIG/Source/Modules/python.cxx b/SWIG/Source/Modules/python.cxx index 9c1c0d8ee..a7a7d8a95 100644 --- a/SWIG/Source/Modules/python.cxx +++ b/SWIG/Source/Modules/python.cxx @@ -1535,9 +1535,21 @@ public: Append(f->code,"Py_INCREF(Py_NotImplemented);\n"); Append(f->code,"return Py_NotImplemented;\n"); } else { + Node *sibl = n; + while (Getattr(sibl,"sym:previousSibling")) + sibl = Getattr(sibl,"sym:previousSibling"); // go all the way up + String *protoTypes = NewString(""); + do { + Printf(protoTypes, " %s(%s)\\n", + Getattr(sibl,"name"),ParmList_protostr(Getattr(sibl,"wrap:parms"))); + } while ((sibl = Getattr(sibl,"sym:nextSibling"))); Append(f->code,"fail:\n"); - Printf(f->code,"SWIG_SetErrorMsg(PyExc_NotImplementedError,\"No matching function for overloaded '%s'\");\n", symname); + Printf(f->code, "SWIG_SetErrorMsg(PyExc_NotImplementedError," + "\"Wrong number of arguments for overloaded function '%s'.\\n" + " Possible C/C++ prototypes are:\\n%s\");\n", + symname, protoTypes); Append(f->code,"return NULL;\n"); + Delete(protoTypes); } Printv(f->code,"}\n",NIL); Wrapper_print(f,f_wrappers); @@ -3603,7 +3615,7 @@ int PYTHON::classDirectorMethod(Node *n, Node *parent, String *super) { Append(w->code, "if (!swig_get_self()) {\n"); - Printf(w->code, " Swig::DirectorException::raise(\"'self' unitialized, maybe you forgot to call %s.__init__.\");\n", classname); + Printf(w->code, " Swig::DirectorException::raise(\"'self' uninitialized, maybe you forgot to call %s.__init__.\");\n", classname); Append(w->code, "}\n"); Append(w->code,"#if defined(SWIG_PYTHON_DIRECTOR_VTABLE)\n"); Printf(w->code, "const size_t swig_method_index = %d;\n", director_method_index++);