Improve -debug-tmused output so that the typemap method name is always shown - it was missing when the typemap came from a %apply.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11808 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
ff1cc536a5
commit
0f93753a08
2 changed files with 72 additions and 9 deletions
|
|
@ -681,8 +681,9 @@ these methods is described later.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
<em>modifiers</em> is an optional comma separated list of <tt>name="value"</tt> values. These
|
<em>modifiers</em> is an optional comma separated list of <tt>name="value"</tt> values.
|
||||||
are sometimes to attach extra information to a typemap and is often target-language dependent.
|
These are sometimes to attach extra information to a typemap and is often target-language dependent.
|
||||||
|
They are also known as typemap attributes.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1557,19 +1558,81 @@ example.h:39: Searching for a suitable 'in' typemap for: char *buffer
|
||||||
<p>
|
<p>
|
||||||
The second option for debugging is <tt>-debug-tmused</tt> and this displays the typemaps used.
|
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.
|
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.
|
The output displays the type, and name if present, the typemap method in brackets and then the actual typemap used.
|
||||||
|
Below is the output for the example code at the start of this section on debugging.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<div class="shell">
|
<div class="shell">
|
||||||
<pre>
|
<pre>
|
||||||
$ swig -perl -debug-tmused example.i
|
$ swig -perl -debug-tmused example.i
|
||||||
example.h:3: Using %typemap(in) SWIGTYPE [] for: Row4 rows[10]
|
example.h:3: Typemap for Row4 rows[10] (in) : %typemap(in) SWIGTYPE []
|
||||||
example.h:3: Using %typemap(typecheck) SWIGTYPE * for: Row4 rows[10]
|
example.h:3: Typemap for Row4 rows[10] (typecheck) : %typemap(typecheck) SWIGTYPE *
|
||||||
example.h:3: Using %typemap(freearg) SWIGTYPE [] for: Row4 rows[10]
|
example.h:3: Typemap for Row4 rows[10] (freearg) : %typemap(freearg) SWIGTYPE []
|
||||||
example.h:3: Using %typemap(out) void for: void foo
|
example.h:3: Typemap for void foo (out) : %typemap(out) void
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Now, consider the following interface file:
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<div class="code">
|
||||||
|
<pre>
|
||||||
|
%module example
|
||||||
|
|
||||||
|
%{
|
||||||
|
void set_value(const char* val) {}
|
||||||
|
%}
|
||||||
|
|
||||||
|
%typemap(check) char *NON_NULL {
|
||||||
|
if (!$1) {
|
||||||
|
/* ... error handling ... */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
%apply SWIGTYPE * { const char* val, const char* another_value } // use default pointer handling instead of strings
|
||||||
|
|
||||||
|
%typemap(check) const char* val = char* NON_NULL;
|
||||||
|
|
||||||
|
%typemap(arginit, noblock=1) const char* val {
|
||||||
|
$1 = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
void set_value(const char* val);
|
||||||
|
|
||||||
|
</pre>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
and the output debug:
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<div class="shell">
|
||||||
|
<pre>
|
||||||
|
swig -perl5 -debug-tmused example.i
|
||||||
|
example.i:21: Typemap for char const *val (arginit) : %typemap(arginit) char const *val
|
||||||
|
example.i:21: Typemap for char const *val (in) : %apply SWIGTYPE * { char const *val }
|
||||||
|
example.i:21: Typemap for char const *val (typecheck) : %apply SWIGTYPE * { char const *val }
|
||||||
|
example.i:21: Typemap for char const *val (check) : %typemap(check) char const *val = char *NON_NULL
|
||||||
|
example.i:21: Typemap for char const *val (freearg) : %apply SWIGTYPE * { char const *val }
|
||||||
|
example.i:21: Typemap for void set_value (out) : %typemap(out) void
|
||||||
|
</pre>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
The following observations about what is displayed can be noted (the same applies for <tt>-debug-tmsearch</tt>):
|
||||||
|
<li>
|
||||||
|
The relevant typemap is shown, but for typemap copying, the appropriate <tt>%typemap</tt> or <tt>%apply</tt> is displayed, for example, the "check" and "in" typemaps.
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
The typemap modifiers are not shown, eg the <tt>noblock=1</tt> modifier in the "arginit" typemap.
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
The exact <tt>%apply</tt> statement might look different to what is in the actual code. For example, the <tt>const char* another_value</tt> is not shown as it is not relevant here.
|
||||||
|
Also the types may be displayed slightly differently - <tt>char const *</tt> and not <tt>const char*</tt>.
|
||||||
|
</li>
|
||||||
|
</p>
|
||||||
|
|
||||||
<H2><a name="Typemaps_nn21"></a>10.4 Code generation rules</H2>
|
<H2><a name="Typemaps_nn21"></a>10.4 Code generation rules</H2>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -883,7 +883,7 @@ static Hash *typemap_search_multi(const_String_or_char_ptr tmap_method, ParmList
|
||||||
debug_search_result_display(tm);
|
debug_search_result_display(tm);
|
||||||
if (typemaps_used_debug && (in_typemap_search_multi == 0) && tm) {
|
if (typemaps_used_debug && (in_typemap_search_multi == 0) && tm) {
|
||||||
String *typestr = SwigType_str(type, name);
|
String *typestr = SwigType_str(type, name);
|
||||||
Swig_diagnostic(Getfile(parms), Getline(parms), "Using %%%s for: %s\n", Getattr(tm, "source"), typestr);
|
Swig_diagnostic(Getfile(parms), Getline(parms), "Typemap for %s (%s) : %%%s\n", typestr, tmap_method, Getattr(tm, "source"));
|
||||||
assert(Getfile(parms) && Len(Getfile(parms)) > 0); /* Missing file and line numbering information */
|
assert(Getfile(parms) && Len(Getfile(parms)) > 0); /* Missing file and line numbering information */
|
||||||
Delete(typestr);
|
Delete(typestr);
|
||||||
}
|
}
|
||||||
|
|
@ -1363,7 +1363,7 @@ static String *Swig_typemap_lookup_impl(const_String_or_char_ptr tmap_method, No
|
||||||
debug_search_result_display(tm);
|
debug_search_result_display(tm);
|
||||||
if (typemaps_used_debug && tm) {
|
if (typemaps_used_debug && tm) {
|
||||||
String *typestr = SwigType_str(type, qpname ? qpname : pname);
|
String *typestr = SwigType_str(type, qpname ? qpname : pname);
|
||||||
Swig_diagnostic(Getfile(node), Getline(node), "Using %%%s for: %s\n", Getattr(tm, "source"), typestr);
|
Swig_diagnostic(Getfile(node), Getline(node), "Typemap for %s (%s) : %%%s\n", typestr, tmap_method, Getattr(tm, "source"));
|
||||||
assert(Getfile(node) && Len(Getfile(node)) > 0); /* Missing file and line numbering information */
|
assert(Getfile(node) && Len(Getfile(node)) > 0); /* Missing file and line numbering information */
|
||||||
Delete(typestr);
|
Delete(typestr);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue