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:
parent
8b7c0afcfc
commit
83bd820285
27 changed files with 178 additions and 106 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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 */
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue