Add typemaps used debugging option (-debug-tmused). Fix missing file/line numbers for typemap warnings and in the output from the -debug-tmsearch/-debug-tmused options

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11802 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
William S Fulton 2010-01-04 19:33:52 +00:00
commit 83bd820285
27 changed files with 178 additions and 106 deletions

View file

@ -1,6 +1,16 @@
Version 1.3.41 (in progress)
============================
2010-01-03: wsfulton
Fix missing file/line numbers for typemap warnings and in output from the
-debug-tmsearch/-debug-tmused options.
2010-01-03: wsfulton
Add typemaps used debugging option (-debug-tmused). When used each line displays
the typemap used for each type for which code is being generated including the file
and line number related to the type. This is effectively a condensed form of the
-debug-tmsearch option. Documented in Typemaps.html.
2009-12-23: wsfulton
Fix for %javaexception and directors so that all the appropriate throws clauses
are generated. Problem reported by Peter Greenwood.

View file

@ -1437,7 +1437,11 @@ but all subsequent arguments must match exactly.
<p>
The <tt>-debug-tmsearch</tt> command line option is available for debugging typemap searches.
There are two useful debug command line options available for debugging typemaps, <tt>-debug-tmsearch</tt> and <tt>-debug-tmused</tt>.
</p>
<p>
The <tt>-debug-tmsearch</tt> option is a verbose option for debugging typemap searches.
This can be very useful for watching the pattern matching process in action and for debugging which typemaps are used.
The option displays all the typemaps and types that are looked for until a successful pattern match is made.
As the display includes searches for each and every type needed for wrapping, the amount of information displayed can be large.
@ -1462,9 +1466,9 @@ A sample of the debugging output is shown below for the "in" typemap:
<div class="shell">
<pre>
swig -debug-tmsearch example.i
swig -perl -debug-tmsearch example.i
...
example.h:26: Searching for a suitable 'in' typemap for: Row4 rows[10]
example.h:3: Searching for a suitable 'in' typemap for: Row4 rows[10]
Looking for: Row4 rows[10]
Looking for: Row4 [10]
Looking for: Row4 rows[ANY]
@ -1550,6 +1554,22 @@ example.h:39: Searching for a suitable 'in' typemap for: char *buffer
</pre>
</div>
<p>
The second option for debugging is <tt>-debug-tmused</tt> and this displays the typemaps used.
This option is a less verbose version of the <tt>-debug-tmsearch</tt> option as it only displays each successfully found typemap on a separate single line.
The output below is for the example code at the start of this section on debugging.
</p>
<div class="shell">
<pre>
$ swig -perl -debug-tmused example.i
example.h:3: Using %typemap(in) SWIGTYPE [] for: Row4 rows[10]
example.h:3: Using %typemap(typecheck) SWIGTYPE * for: Row4 rows[10]
example.h:3: Using %typemap(freearg) SWIGTYPE [] for: Row4 rows[10]
example.h:3: Using %typemap(out) void for: void foo
</pre>
</div>
<H2><a name="Typemaps_nn21"></a>10.4 Code generation rules</H2>

View file

@ -53,7 +53,7 @@ extern "C" {
extern void Swig_cparse_replace_descriptor(String *s);
extern void cparse_normalize_void(Node *);
extern Parm *Swig_cparse_parm(String *s);
extern ParmList *Swig_cparse_parms(String *s);
extern ParmList *Swig_cparse_parms(String *s, Node *file_line_node);
/* templ.c */

View file

@ -2724,11 +2724,11 @@ typemap_parm : type typemap_parameter_declarator {
Parm *parm;
SwigType_push($1,$2.type);
$$ = new_node("typemapitem");
parm = NewParm($1,$2.id);
parm = NewParmWithoutFileLineInfo($1,$2.id);
Setattr($$,"pattern",parm);
Setattr($$,"parms", $2.parms);
Delete(parm);
/* $$ = NewParm($1,$2.id);
/* $$ = NewParmWithoutFileLineInfo($1,$2.id);
Setattr($$,"parms",$2.parms); */
}
| LPAREN parms RPAREN {
@ -3983,7 +3983,7 @@ cpp_template_decl : TEMPLATE LESSTHAN template_parms GREATERTHAN {
SwigType *rtt = Swig_symbol_typedef_reduce(tt.item,0);
SwigType *ttr = Swig_symbol_type_qualify(rtt,0);
Parm *newp = NewParm(ttr, 0);
Parm *newp = NewParmWithoutFileLineInfo(ttr, 0);
if (partialparms)
set_nextSibling(parm_current, newp);
else
@ -4129,7 +4129,7 @@ templateparameters : templateparameter templateparameterstail {
;
templateparameter : templcpptype {
$$ = NewParm(NewString($1), 0);
$$ = NewParmWithoutFileLineInfo(NewString($1), 0);
}
| parm {
$$ = $1;
@ -4708,7 +4708,7 @@ ptail : COMMA parm ptail {
parm : rawtype parameter_declarator {
SwigType_push($1,$2.type);
$$ = NewParm($1,$2.id);
$$ = NewParmWithoutFileLineInfo($1,$2.id);
Setfile($$,cparse_file);
Setline($$,cparse_line);
if ($2.defarg) {
@ -4717,7 +4717,7 @@ parm : rawtype parameter_declarator {
}
| TEMPLATE LESSTHAN cpptype GREATERTHAN cpptype idcolon def_args {
$$ = NewParm(NewStringf("template<class> %s %s", $5,$6), 0);
$$ = NewParmWithoutFileLineInfo(NewStringf("template<class> %s %s", $5,$6), 0);
Setfile($$,cparse_file);
Setline($$,cparse_line);
if ($7.val) {
@ -4726,7 +4726,7 @@ parm : rawtype parameter_declarator {
}
| PERIOD PERIOD PERIOD {
SwigType *t = NewString("v(...)");
$$ = NewParm(t, 0);
$$ = NewParmWithoutFileLineInfo(t, 0);
Setfile($$,cparse_file);
Setline($$,cparse_line);
}
@ -4789,7 +4789,7 @@ valparm : parm {
}
| valexpr {
$$ = NewParm(0,0);
$$ = NewParmWithoutFileLineInfo(0,0);
Setfile($$,cparse_file);
Setline($$,cparse_line);
Setattr($$,"value",$1.val);
@ -6226,14 +6226,16 @@ Parm *Swig_cparse_parm(String *s) {
}
ParmList *Swig_cparse_parms(String *s) {
ParmList *Swig_cparse_parms(String *s, Node *file_line_node) {
String *ns;
char *cs = Char(s);
if (cs && cs[0] != '(') {
ns = NewStringf("(%s);",s);
} else {
ns = NewStringf("%s;",s);
}
}
Setfile(ns, Getfile(file_line_node));
Setline(ns, Getline(file_line_node));
Seek(ns,0,SEEK_SET);
scanner_file(ns);
top = 0;

View file

@ -262,7 +262,7 @@ int Swig_cparse_template_expand(Node *n, String *rname, ParmList *tparms, Symtab
/* Look for partial specialization matching */
if (Getattr(n, "partialargs")) {
Parm *p, *tp;
ParmList *ptargs = SwigType_function_parms(Getattr(n, "partialargs"));
ParmList *ptargs = SwigType_function_parms(Getattr(n, "partialargs"), n);
p = ptargs;
tp = tparms;
while (p && tp) {

View file

@ -518,7 +518,7 @@ class Allocate:public Dispatcher {
*/
String *scatchlist = Getattr(n, "feature:catches");
if (scatchlist) {
catchlist = Swig_cparse_parms(scatchlist);
catchlist = Swig_cparse_parms(scatchlist, n);
if (catchlist) {
Setattr(n, "catchlist", catchlist);
mark_exception_classes(catchlist);

View file

@ -618,12 +618,12 @@ int CFFI::enumDeclaration(Node *n) {
slot_name_keywords = true;
//Registering the enum name to the cin and cout typemaps
Parm *pattern = NewParm(name, NULL);
Parm *pattern = NewParm(name, NULL, n);
Swig_typemap_register("cin", pattern, lisp_name, NULL, NULL);
Swig_typemap_register("cout", pattern, lisp_name, NULL, NULL);
Delete(pattern);
//Registering with the kind, i.e., enum
pattern = NewParm(NewStringf("enum %s", name), NULL);
pattern = NewParm(NewStringf("enum %s", name), NULL, n);
Swig_typemap_register("cin", pattern, lisp_name, NULL, NULL);
Swig_typemap_register("cout", pattern, lisp_name, NULL, NULL);
Delete(pattern);
@ -688,7 +688,7 @@ void CFFI::emit_class(Node *n) {
Printf(f_clos, "\n(cl:defclass %s%s", lisp_name, supers);
Printf(f_clos, "\n ((ff-pointer :reader ff-pointer)))\n\n");
Parm *pattern = NewParm(Getattr(n, "name"), NULL);
Parm *pattern = NewParm(Getattr(n, "name"), NULL, n);
Swig_typemap_register("lispclass", pattern, lisp_name, NULL, NULL);
SwigType_add_pointer(Getattr(pattern, "type"));
@ -758,7 +758,7 @@ void CFFI::emit_class(Node *n) {
Delete(supers);
// Delete(ns_list);
// Parm *pattern = NewParm(name,NULL);
// Parm *pattern = NewParm(name, NULL, n);
// Swig_typemap_register("cin",pattern,lisp_name,NULL,NULL);
//Swig_typemap_register("cout",pattern,lisp_name,NULL,NULL);
//Delete(pattern);
@ -787,12 +787,12 @@ void CFFI::emit_struct_union(Node *n, bool un = false) {
//Register the struct/union name to the cin and cout typemaps
Parm *pattern = NewParm(name, NULL);
Parm *pattern = NewParm(name, NULL, n);
Swig_typemap_register("cin", pattern, lisp_name, NULL, NULL);
Swig_typemap_register("cout", pattern, lisp_name, NULL, NULL);
Delete(pattern);
//Registering with the kind, i.e., struct or union
pattern = NewParm(NewStringf("%s %s", kind, name), NULL);
pattern = NewParm(NewStringf("%s %s", kind, name), NULL, n);
Swig_typemap_register("cin", pattern, lisp_name, NULL, NULL);
Swig_typemap_register("cout", pattern, lisp_name, NULL, NULL);
Delete(pattern);

View file

@ -452,7 +452,7 @@ String *CLISP::get_ffi_type(Node *n, SwigType *ty) {
SwigType *cp = Copy(ty);
SwigType *fn = SwigType_pop_function(cp);
String *args = NewString("");
ParmList *pl = SwigType_function_parms(fn);
ParmList *pl = SwigType_function_parms(fn, n);
if (ParmList_len(pl) != 0) {
Printf(args, "(:arguments ");
}

View file

@ -86,13 +86,6 @@ class CSHARP:public Language {
enum EnumFeature { SimpleEnum, TypeunsafeEnum, TypesafeEnum, ProperEnum };
static Parm *NewParmFromNode(SwigType *type, const_String_or_char_ptr name, Node *n) {
Parm *p = NewParm(type, name);
Setfile(p, Getfile(n));
Setline(p, Getline(n));
return p;
}
public:
/* -----------------------------------------------------------------------------
@ -3331,7 +3324,7 @@ public:
}
/* Create the intermediate class wrapper */
Parm *tp = NewParmFromNode(returntype, empty_str, n);
Parm *tp = NewParm(returntype, empty_str, n);
tm = Swig_typemap_lookup("imtype", tp, "", 0);
if (tm) {
@ -3351,7 +3344,7 @@ public:
Swig_warning(WARN_CSHARP_TYPEMAP_CSTYPE_UNDEF, input_file, line_number, "No imtype typemap defined for %s\n", SwigType_str(returntype, 0));
}
Parm *retpm = NewParmFromNode(returntype, empty_str, n);
Parm *retpm = NewParm(returntype, empty_str, n);
if ((c_ret_type = Swig_typemap_lookup("ctype", retpm, "", 0))) {
@ -3438,7 +3431,7 @@ public:
if (ctypeout)
c_param_type = ctypeout;
Parm *tp = NewParmFromNode(c_param_type, empty_str, n);
Parm *tp = NewParm(c_param_type, empty_str, n);
String *desc_tm = NULL;
/* Add to local variables */
@ -3593,7 +3586,7 @@ public:
String *upcall = NewStringf("%s(%s)", symname, imcall_args);
if (!is_void) {
Parm *tp = NewParmFromNode(returntype, empty_str, n);
Parm *tp = NewParm(returntype, empty_str, n);
if ((tm = Swig_typemap_lookup("csdirectorout", tp, "", 0))) {
substituteClassname(returntype, tm);
@ -3619,7 +3612,7 @@ public:
if (!is_void) {
String *jresult_str = NewString("jresult");
String *result_str = NewString("c_result");
Parm *tp = NewParmFromNode(returntype, result_str, n);
Parm *tp = NewParm(returntype, result_str, n);
/* Copy jresult into c_result... */
if ((tm = Swig_typemap_lookup("directorout", tp, result_str, w))) {

View file

@ -1407,16 +1407,18 @@ public:
}
{
/* Hack alert: will cleanup later -- Dave */
Node *n = NewHash();
Setattr(n, "name", var_name);
Setattr(n, "sym:name", iname);
Setattr(n, "type", nctype);
SetFlag(n, "feature:immutable");
Node *nn = NewHash();
Setfile(nn, Getfile(n));
Setline(nn, Getline(n));
Setattr(nn, "name", var_name);
Setattr(nn, "sym:name", iname);
Setattr(nn, "type", nctype);
SetFlag(nn, "feature:immutable");
if (constasvar) {
SetFlag(n, "feature:constasvar");
SetFlag(nn, "feature:constasvar");
}
variableWrapper(n);
Delete(n);
variableWrapper(nn);
Delete(nn);
}
Delete(var_name);
Delete(nctype);

View file

@ -83,13 +83,6 @@ class JAVA:public Language {
enum EnumFeature { SimpleEnum, TypeunsafeEnum, TypesafeEnum, ProperEnum };
static Parm *NewParmFromNode(SwigType *type, const_String_or_char_ptr name, Node *n) {
Parm *p = NewParm(type, name);
Setfile(p, Getfile(n));
Setline(p, Getline(n));
return p;
}
public:
/* -----------------------------------------------------------------------------
@ -1981,7 +1974,7 @@ public:
if (qualifier)
SwigType_push(this_type, qualifier);
SwigType_add_pointer(this_type);
Parm *this_parm = NewParm(this_type, name);
Parm *this_parm = NewParm(this_type, name, n);
Swig_typemap_attach_parms("jtype", this_parm, NULL);
Swig_typemap_attach_parms("jstype", this_parm, NULL);
@ -3389,7 +3382,7 @@ public:
}
/* Create the intermediate class wrapper */
Parm *tp = NewParmFromNode(returntype, empty_str, n);
Parm *tp = NewParm(returntype, empty_str, n);
tm = Swig_typemap_lookup("jtype", tp, "", 0);
if (tm) {
@ -3401,7 +3394,7 @@ public:
String *cdesc = NULL;
SwigType *covariant = Getattr(n, "covariant");
SwigType *adjustedreturntype = covariant ? covariant : returntype;
Parm *adjustedreturntypeparm = NewParmFromNode(adjustedreturntype, empty_str, n);
Parm *adjustedreturntypeparm = NewParm(adjustedreturntype, empty_str, n);
if ((tm = Swig_typemap_lookup("directorin", adjustedreturntypeparm, "", 0))
&& (cdesc = Getattr(adjustedreturntypeparm, "tmap:directorin:descriptor"))) {
@ -3421,10 +3414,10 @@ public:
/* Get the JNI field descriptor for this return type, add the JNI field descriptor
to jniret_desc */
Parm *retpm = NewParmFromNode(returntype, empty_str, n);
Parm *retpm = NewParm(returntype, empty_str, n);
if ((c_ret_type = Swig_typemap_lookup("jni", retpm, "", 0))) {
Parm *tp = NewParmFromNode(c_ret_type, empty_str, n);
Parm *tp = NewParm(c_ret_type, empty_str, n);
if (!is_void && !ignored_method) {
String *jretval_decl = NewStringf("%s jresult", c_ret_type);
@ -3526,7 +3519,7 @@ public:
}
/* Start the Java field descriptor for the intermediate class's upcall (insert self object) */
Parm *tp = NewParmFromNode(c_classname, empty_str, n);
Parm *tp = NewParm(c_classname, empty_str, n);
String *jdesc;
if ((tm = Swig_typemap_lookup("directorin", tp, "", 0))
@ -3568,7 +3561,7 @@ public:
/* Get parameter's intermediary C type */
if ((c_param_type = Getattr(p, "tmap:jni"))) {
Parm *tp = NewParmFromNode(c_param_type, empty_str, n);
Parm *tp = NewParm(c_param_type, empty_str, n);
String *desc_tm = NULL, *jdesc = NULL, *cdesc = NULL;
/* Add to local variables */
@ -3728,7 +3721,7 @@ public:
addThrows(n, "feature:except", n);
if (!is_void) {
Parm *tp = NewParmFromNode(returntype, empty_str, n);
Parm *tp = NewParm(returntype, empty_str, n);
if ((tm = Swig_typemap_lookup("javadirectorout", tp, "", 0))) {
addThrows(n, "tmap:javadirectorout", tp);
@ -3772,7 +3765,7 @@ public:
if (!is_void) {
String *jresult_str = NewString("jresult");
String *result_str = NewString("c_result");
Parm *tp = NewParmFromNode(returntype, result_str, n);
Parm *tp = NewParm(returntype, result_str, n);
/* Copy jresult into c_result... */
if ((tm = Swig_typemap_lookup("directorout", tp, result_str, w))) {
@ -3865,7 +3858,7 @@ public:
SwigType_add_pointer(jenv_type);
p = NewParmFromNode(jenv_type, NewString("jenv"), n);
p = NewParm(jenv_type, NewString("jenv"), n);
Setattr(p, "arg:byname", "1");
set_nextSibling(p, NULL);
@ -3902,7 +3895,7 @@ public:
String *jenv_type = NewString("JNIEnv");
SwigType_add_pointer(jenv_type);
p = NewParmFromNode(jenv_type, NewString("jenv"), n);
p = NewParm(jenv_type, NewString("jenv"), n);
set_nextSibling(p, parms);
parms = p;

View file

@ -900,7 +900,7 @@ int Language::cDeclaration(Node *n) {
Delete(ty);
ty = fullty;
fullty = 0;
ParmList *parms = SwigType_function_parms(ty);
ParmList *parms = SwigType_function_parms(ty, n);
Setattr(n, "parms", parms);
}
/* Transform the node into a 'function' node and emit */
@ -1188,6 +1188,8 @@ int Language::memberfunctionHandler(Node *n) {
Setattr(cbn, "type", cbty);
Setattr(cbn, "value", cbvalue);
Setattr(cbn, "name", name);
Setfile(cbn, Getfile(n));
Setline(cbn, Getline(n));
memberconstantHandler(cbn);
Setattr(n, "feature:callback:name", Swig_name_member(ClassPrefix, cbname));
@ -1478,7 +1480,7 @@ int Language::membervariableHandler(Node *n) {
Parm *p;
String *gname;
SwigType *vty;
p = NewParm(type, 0);
p = NewParm(type, 0, n);
gname = NewStringf(AttributeFunctionGet, symname);
if (!Extend) {
ActionFunc = Copy(Swig_cmemberget_call(name, type));
@ -1904,12 +1906,14 @@ int Language::classDirectorDisown(Node *n) {
String *type = NewString(ClassType);
String *name = NewString("self");
SwigType_add_pointer(type);
Parm *p = NewParm(type, name);
Parm *p = NewParm(type, name, n);
Delete(name);
Delete(type);
type = NewString("void");
String *action = NewString("");
Printv(action, "{\n", "Swig::Director *director = dynamic_cast<Swig::Director *>(arg1);\n", "if (director) director->swig_disown();\n", "}\n", NULL);
Setfile(disown, Getfile(n));
Setline(disown, Getline(n));
Setattr(disown, "wrap:action", action);
Setattr(disown, "name", mrename);
Setattr(disown, "sym:name", mrename);
@ -2162,7 +2166,7 @@ static void addCopyConstructor(Node *n) {
if (!symname) {
symname = Copy(csymname);
}
Parm *p = NewParm(cc, "other");
Parm *p = NewParm(cc, "other", n);
Setattr(cn, "name", name);
Setattr(cn, "sym:name", symname);

View file

@ -71,6 +71,7 @@ static const char *usage1 = (const char *) "\
-debug-typedef - Display information about the types and typedefs in the interface\n\
-debug-typemap - Display typemap debugging information\n\
-debug-tmsearch - Display typemap search debugging information\n\
-debug-tmused - Display typemaps used debugging information\n\
-directors - Turn on director mode for all the classes, mainly for testing\n\
-dirprot - Turn on wrapping of protected members for director classes (default)\n\
-D<symbol> - Define a symbol <symbol> (for conditional compilation)\n\
@ -659,6 +660,9 @@ void SWIG_getoptions(int argc, char *argv[]) {
} else if (strcmp(argv[i], "-debug-tmsearch") == 0) {
Swig_typemap_search_debug_set();
Swig_mark_arg(i);
} else if (strcmp(argv[i], "-debug-tmused") == 0) {
Swig_typemap_used_debug_set();
Swig_mark_arg(i);
} else if (strcmp(argv[i], "-module") == 0) {
Swig_mark_arg(i);
if (argv[i + 1]) {

View file

@ -647,13 +647,15 @@ public:
{
/* Hack alert: will cleanup later -- Dave */
Node *n = NewHash();
Setattr(n, "name", var_name);
Setattr(n, "sym:name", iname);
Setattr(n, "type", type);
SetFlag(n, "feature:immutable");
variableWrapper(n);
Delete(n);
Node *nn = NewHash();
Setfile(nn, Getfile(n));
Setline(nn, Getline(n));
Setattr(nn, "name", var_name);
Setattr(nn, "sym:name", iname);
Setattr(nn, "type", type);
SetFlag(nn, "feature:immutable");
variableWrapper(nn);
Delete(nn);
}
}
Delete(proc_name);

View file

@ -1727,7 +1727,7 @@ public:
ParmList *superparms = Getattr(n, "parms");
ParmList *parms = CopyParmList(superparms);
String *type = NewString("CAML_VALUE");
p = NewParm(type, NewString("self"));
p = NewParm(type, NewString("self"), n);
q = Copy(p);
set_nextSibling(q, superparms);
set_nextSibling(p, parms);
@ -1780,7 +1780,7 @@ public:
ParmList *superparms = Getattr(n, "parms");
ParmList *parms = CopyParmList(superparms);
String *type = NewString("CAML_VALUE");
p = NewParm(type, NewString("self"));
p = NewParm(type, NewString("self"), n);
q = Copy(p);
set_nextSibling(p, parms);
parms = p;

View file

@ -956,7 +956,7 @@ public:
String *name = NewString("self");
String *type = NewString("void");
SwigType_add_pointer(type);
self = NewParm(type, name);
self = NewParm(type, name, n);
Delete(type);
Delete(name);
Setattr(self, "lname", "self_obj");
@ -1051,7 +1051,7 @@ public:
ParmList *parms = CopyParmList(superparms);
String *type = NewString("void");
SwigType_add_pointer(type);
p = NewParm(type, NewString("self"));
p = NewParm(type, NewString("self"), n);
set_nextSibling(p, parms);
parms = p;

View file

@ -2323,7 +2323,7 @@ done:
ParmList *parms = CopyParmList(superparms);
String *type = NewString("zval");
SwigType_add_pointer(type);
p = NewParm(type, NewString("self"));
p = NewParm(type, NewString("self"), n);
set_nextSibling(p, parms);
parms = p;

View file

@ -2625,7 +2625,7 @@ public:
ParmList *parms = CopyParmList(superparms);
String *type = NewString("PyObject");
SwigType_add_pointer(type);
p = NewParm(type, NewString("self"));
p = NewParm(type, NewString("self"), n);
set_nextSibling(p, parms);
parms = p;
@ -3205,7 +3205,7 @@ public:
String *name = NewString("self");
String *type = NewString("PyObject");
SwigType_add_pointer(type);
self = NewParm(type, name);
self = NewParm(type, name, n);
Delete(type);
Delete(name);
Setattr(self, "lname", "O");

View file

@ -588,7 +588,7 @@ String * R::createFunctionPointerHandler(SwigType *t, Node *n, int *numArgs) {
// ParmList *parms = Getattr(n, "parms");
// memory leak
ParmList *parms = SwigType_function_parms(SwigType_del_pointer(Copy(t)));
ParmList *parms = SwigType_function_parms(SwigType_del_pointer(Copy(t)), n);
// if (debugMode) {
@ -712,10 +712,7 @@ String * R::createFunctionPointerHandler(SwigType *t, Node *n, int *numArgs) {
XXX Have to be a little more clever so that we can deal with struct A * - the * is getting lost.
Is this still true? If so, will a SwigType_push() solve things?
*/
Node *bbase = NewHash();
Setattr(bbase, "type", rettype);
Setattr(bbase, "name", NewString("result"));
Parm *bbase = NewParm(rettype, "result", n);
String *returnTM = Swig_typemap_lookup("in", bbase, "result", f);
if(returnTM) {
String *tm = returnTM;

View file

@ -2590,7 +2590,7 @@ public:
Parm *self;
String *name = NewString("self");
String *type = NewString("VALUE");
self = NewParm(type, name);
self = NewParm(type, name, n);
Delete(type);
Delete(name);
Setattr(self, "lname", "Qnil");
@ -2812,7 +2812,7 @@ public:
ParmList *superparms = Getattr(n, "parms");
ParmList *parms = CopyParmList(superparms);
String *type = NewString("VALUE");
p = NewParm(type, NewString("self"));
p = NewParm(type, NewString("self"), n);
set_nextSibling(p, parms);
parms = p;

View file

@ -803,7 +803,7 @@ int Swig_MethodToFunction(Node *n, String *classname, int flags, SwigType *direc
SwigType_push(type, qualifier);
}
SwigType_add_pointer(type);
p = NewParm(type, "self");
p = NewParm(type, "self", n);
Setattr(p, "self", "1");
Setattr(p, "hidden","1");
/*
@ -1155,7 +1155,7 @@ int Swig_DestructorToFunction(Node *n, String *classname, int cplus, int flags)
type = NewString(classname);
SwigType_add_pointer(type);
p = NewParm(type, "self");
p = NewParm(type, "self", n);
Setattr(p, "self", "1");
Setattr(p, "hidden", "1");
Setattr(p, "wrap:disown", "1");
@ -1238,13 +1238,13 @@ int Swig_MembersetToFunction(Node *n, String *classname, int flags) {
t = NewString(classname);
SwigType_add_pointer(t);
parms = NewParm(t, "self");
parms = NewParm(t, "self", n);
Setattr(parms, "self", "1");
Setattr(parms, "hidden","1");
Delete(t);
ty = Swig_wrapped_member_var_type(type, varcref);
p = NewParm(ty, name);
p = NewParm(ty, name, n);
Setattr(parms, "hidden", "1");
set_nextSibling(parms, p);
@ -1327,7 +1327,7 @@ int Swig_MembergetToFunction(Node *n, String *classname, int flags) {
t = NewString(classname);
SwigType_add_pointer(t);
parms = NewParm(t, "self");
parms = NewParm(t, "self", n);
Setattr(parms, "self", "1");
Setattr(parms, "hidden","1");
Delete(t);
@ -1383,7 +1383,7 @@ int Swig_VarsetToFunction(Node *n, int flags) {
type = Getattr(n, "type");
nname = SwigType_namestr(name);
ty = Swig_wrapped_var_type(type, varcref);
parms = NewParm(ty, name);
parms = NewParm(ty, name, n);
if (flags & CWRAP_EXTEND) {
String *sname = Swig_name_set(name);

View file

@ -14,10 +14,25 @@ char cvsroot_parms_c[] = "$Id$";
/* ------------------------------------------------------------------------
* NewParm()
*
* Create a new parameter from datatype 'type' and name 'name'.
* Create a new parameter from datatype 'type' and name 'name' copying
* the file and line number from the Node file_line_node.
* ------------------------------------------------------------------------ */
Parm *NewParm(SwigType *type, const_String_or_char_ptr name) {
Parm *NewParm(SwigType *type, const_String_or_char_ptr name, Node *file_line_node) {
Parm *p = NewParmWithoutFileLineInfo(type, name);
Setfile(p, Getfile(file_line_node));
Setline(p, Getline(file_line_node));
return p;
}
/* ------------------------------------------------------------------------
* NewParmWithoutFileLineInfo()
*
* Create a new parameter from datatype 'type' and name 'name' without any
* file / line numbering information.
* ------------------------------------------------------------------------ */
Parm *NewParmWithoutFileLineInfo(SwigType *type, const_String_or_char_ptr name) {
Parm *p = NewHash();
set_nodeType(p, "parm");
if (type) {

View file

@ -123,7 +123,7 @@ extern "C" {
extern SwigType *SwigType_add_function(SwigType *t, ParmList *parms);
extern SwigType *SwigType_add_template(SwigType *t, ParmList *parms);
extern SwigType *SwigType_pop_function(SwigType *t);
extern ParmList *SwigType_function_parms(SwigType *t);
extern ParmList *SwigType_function_parms(SwigType *t, Node *file_line_node);
extern List *SwigType_split(const SwigType *t);
extern String *SwigType_pop(SwigType *t);
extern void SwigType_push(SwigType *t, SwigType *s);
@ -371,6 +371,7 @@ extern int ParmList_is_compactdefargs(ParmList *p);
extern void Swig_typemap_clear_apply(ParmList *pattern);
extern void Swig_typemap_debug(void);
extern void Swig_typemap_search_debug_set(void);
extern void Swig_typemap_used_debug_set(void);
extern String *Swig_typemap_lookup(const_String_or_char_ptr tmap_method, Node *n, const_String_or_char_ptr lname, Wrapper *f);
extern String *Swig_typemap_lookup_out(const_String_or_char_ptr tmap_method, Node *n, const_String_or_char_ptr lname, Wrapper *f, String *actioncode);

View file

@ -11,7 +11,8 @@
/* $Id: swig.h 9629 2006-12-30 18:27:47Z beazley $ */
/* Individual parameters */
extern Parm *NewParm(SwigType *type, const_String_or_char_ptr name);
extern Parm *NewParm(SwigType *type, const_String_or_char_ptr name, Node *file_line_node);
extern Parm *NewParmWithoutFileLineInfo(SwigType *type, const_String_or_char_ptr name);
extern Parm *CopyParm(Parm *p);
/* Parameter lists */

View file

@ -1807,7 +1807,7 @@ ParmList *Swig_symbol_template_defargs(Parm *parms, Parm *targs, Symtab *tscope,
ntq = ty;
}
/* Printf(stderr,"value %s %s %s\n",value,ntr,ntq); */
cp = NewParm(ntq, 0);
cp = NewParmWithoutFileLineInfo(ntq, 0);
if (lp)
set_nextSibling(lp, cp);
else
@ -1884,7 +1884,7 @@ SwigType *Swig_symbol_template_deftype(const SwigType *type, Symtab *tscope) {
String *tprefix = SwigType_templateprefix(base);
String *targs = SwigType_templateargs(base);
String *tsuffix = SwigType_templatesuffix(base);
ParmList *tparms = SwigType_function_parms(targs);
ParmList *tparms = SwigType_function_parms(targs, 0);
Node *tempn = Swig_symbol_clookup_local(tprefix, tscope);
if (!tempn && tsuffix && Len(tsuffix)) {
tempn = Swig_symbol_clookup(tprefix, 0);

View file

@ -18,9 +18,10 @@ char cvsroot_typemap_c[] = "$Id$";
#endif
static int typemap_search_debug = 0;
static int typemaps_used_debug = 0;
static int in_typemap_search_multi = 0;
static void replace_embedded_typemap(String *s, ParmList *parm_sublist, Wrapper *f);
static void replace_embedded_typemap(String *s, ParmList *parm_sublist, Wrapper *f, Node *file_line_node);
/* -----------------------------------------------------------------------------
* Typemaps are stored in a collection of nested hash tables. Something like
@ -266,6 +267,8 @@ static void typemap_register(const_String_or_char_ptr tmap_method, ParmList *par
else
typemap = NewStringf("typemap(%s) %s", actual_tmap_method, parms_str);
Setfile(tm2, Getfile(code));
Setline(tm2, Getline(code));
Setattr(tm2, "code", code);
Setattr(tm2, "type", type);
Setattr(tm2, "typemap", typemap);
@ -871,6 +874,12 @@ static Hash *typemap_search_multi(const_String_or_char_ptr tmap_method, ParmList
if (typemap_search_debug && (in_typemap_search_multi == 0))
debug_search_result_display(tm);
if (typemaps_used_debug && tm) {
String *typestr = SwigType_str(type, name);
Swig_diagnostic(Getfile(parms), Getline(parms), "Using %%%s for: %s\n", Getattr(tm, "typemap"), typestr);
assert(Getfile(parms) && Len(Getfile(parms)) > 0); /* Missing file and line numbering information */
Delete(typestr);
}
return tm;
}
@ -1345,6 +1354,13 @@ static String *Swig_typemap_lookup_impl(const_String_or_char_ptr tmap_method, No
tm = typemap_search(tmap_method, type, pname, qpname, &mtype, node);
if (typemap_search_debug)
debug_search_result_display(tm);
if (typemaps_used_debug && tm) {
String *typestr = SwigType_str(type, qpname ? qpname : pname);
Swig_diagnostic(Getfile(node), Getline(node), "Using %%%s for: %s\n", Getattr(tm, "typemap"), typestr);
assert(Getfile(node) && Len(Getfile(node)) > 0); /* Missing file and line numbering information */
Delete(typestr);
}
Delete(qpname);
qpname = 0;
@ -1450,9 +1466,9 @@ static String *Swig_typemap_lookup_impl(const_String_or_char_ptr tmap_method, No
}
{
ParmList *parm_sublist = NewParm(type, pname);
ParmList *parm_sublist = NewParmWithoutFileLineInfo(type, pname);
Setattr(parm_sublist, "lname", lname);
replace_embedded_typemap(s, parm_sublist, f);
replace_embedded_typemap(s, parm_sublist, f, tm);
Delete(parm_sublist);
}
@ -1730,7 +1746,7 @@ void Swig_typemap_attach_parms(const_String_or_char_ptr tmap_method, ParmList *p
typemap_locals(s, locals, f, argnum);
}
replace_embedded_typemap(s, firstp, f);
replace_embedded_typemap(s, firstp, f, tm);
/* Replace the argument number */
sprintf(temp, "%d", argnum);
@ -1851,7 +1867,7 @@ static List *split_embedded_typemap(String *s) {
* $typemap(in, (Foo<int, bool> a, int b)) # multi-argument typemap matching %typemap(in) (Foo<int, bool> a, int b) {...}
* ----------------------------------------------------------------------------- */
static void replace_embedded_typemap(String *s, ParmList *parm_sublist, Wrapper *f) {
static void replace_embedded_typemap(String *s, ParmList *parm_sublist, Wrapper *f, Node *file_line_node) {
char *start = 0;
while ((start = strstr(Char(s), "$TYPEMAP("))) { /* note $typemap capitalisation to $TYPEMAP hack */
@ -1895,7 +1911,7 @@ static void replace_embedded_typemap(String *s, ParmList *parm_sublist, Wrapper
/* the second parameter might contain multiple sub-parameters for multi-argument
* typemap matching, so split these parameters apart */
to_match_parms = Swig_cparse_parms(Getitem(l, 1));
to_match_parms = Swig_cparse_parms(Getitem(l, 1), file_line_node);
if (to_match_parms) {
Parm *p = to_match_parms;
Parm *sub_p = parm_sublist;
@ -2029,3 +2045,13 @@ void Swig_typemap_search_debug_set(void) {
typemap_search_debug = 1;
}
/* -----------------------------------------------------------------------------
* Swig_typemap_used_debug_set()
*
* Turn on typemaps used debug display
* ----------------------------------------------------------------------------- */
void Swig_typemap_used_debug_set(void) {
typemaps_used_debug = 1;
}

View file

@ -781,13 +781,15 @@ int SwigType_isfunction(SwigType *t) {
return 0;
}
ParmList *SwigType_function_parms(SwigType *t) {
/* Create a list of parameters from the type t, using the file_line_node Node for
* file and line numbering for the parameters */
ParmList *SwigType_function_parms(SwigType *t, Node *file_line_node) {
List *l = SwigType_parmlist(t);
Hash *p, *pp = 0, *firstp = 0;
Iterator o;
for (o = First(l); o.item; o = Next(o)) {
p = NewParm(o.item, 0);
p = file_line_node ? NewParm(o.item, 0, file_line_node) : NewParmWithoutFileLineInfo(o.item, 0);
if (!firstp)
firstp = p;
if (pp) {