Expand special variables in typemap warnings
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12832 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
0463a49df5
commit
3c1ca906ac
5 changed files with 53 additions and 12 deletions
|
|
@ -5,6 +5,11 @@ See the RELEASENOTES file for a summary of changes in each release.
|
||||||
Version 2.0.5 (in progress)
|
Version 2.0.5 (in progress)
|
||||||
===========================
|
===========================
|
||||||
|
|
||||||
|
2011-11-03: wsfulton
|
||||||
|
Expand special variables in typemap warnings, eg:
|
||||||
|
|
||||||
|
%typemap(in, warning="1000:Test warning for 'in' typemap for $1_type $1_name") int "..."
|
||||||
|
|
||||||
2011-11-01: wsfulton
|
2011-11-01: wsfulton
|
||||||
Fix named output typemaps not being used when the symbol uses a qualifier and contains
|
Fix named output typemaps not being used when the symbol uses a qualifier and contains
|
||||||
a number, eg:
|
a number, eg:
|
||||||
|
|
|
||||||
|
|
@ -205,6 +205,13 @@ $source by $input and $target by $1. For typemaps related to return values (ou
|
||||||
argout,ret,except), replace $source by $1 and $target by $result. See the file
|
argout,ret,except), replace $source by $1 and $target by $result. See the file
|
||||||
Doc/Manual/Typemaps.html for complete details.
|
Doc/Manual/Typemaps.html for complete details.
|
||||||
|
|
||||||
|
:::::::::::::::::::::::::::::::: swig_typemap_warn.i :::::::::::::::::::::::::::::::::::
|
||||||
|
swig_typemap_warn.i:7: Warning 1001: Test warning for 'out' typemap for double mmm (result) - name: mmm symname: mmm &1_ltype: double * descriptor: SWIGTYPE_double
|
||||||
|
swig_typemap_warn.i:7: Warning 1000: Test warning for 'in' typemap for int abc (arg1) - argnum: 1 &1_ltype: int * descriptor: SWIGTYPE_int
|
||||||
|
swig_typemap_warn.i:7: Warning 1000: Test warning for 'in' typemap for int arg2 (arg2) - argnum: 2 &1_ltype: int * descriptor: SWIGTYPE_int
|
||||||
|
swig_typemap_warn.i:7: Warning 1000: Test warning for 'in' typemap for int abc (arg1) - argnum: 1 &1_ltype: int * descriptor: SWIGTYPE_int
|
||||||
|
swig_typemap_warn.i:7: Warning 1000: Test warning for 'in' typemap for int arg2 (arg2) - argnum: 2 &1_ltype: int * descriptor: SWIGTYPE_int
|
||||||
|
|
||||||
:::::::::::::::::::::::::::::::: cpp_bad_extern.i :::::::::::::::::::::::::::::::::::
|
:::::::::::::::::::::::::::::::: cpp_bad_extern.i :::::::::::::::::::::::::::::::::::
|
||||||
cpp_bad_extern.i:5: Warning 313: Unrecognized extern type "INTERCAL".
|
cpp_bad_extern.i:5: Warning 313: Unrecognized extern type "INTERCAL".
|
||||||
cpp_bad_extern.i:7: Warning 313: Unrecognized extern type "INTERCAL".
|
cpp_bad_extern.i:7: Warning 313: Unrecognized extern type "INTERCAL".
|
||||||
|
|
|
||||||
|
|
@ -58,6 +58,7 @@ swig_identifier
|
||||||
swig_insert_bad
|
swig_insert_bad
|
||||||
swig_typemap_copy
|
swig_typemap_copy
|
||||||
swig_typemap_old
|
swig_typemap_old
|
||||||
|
swig_typemap_warn
|
||||||
'
|
'
|
||||||
|
|
||||||
# Files run in C++ mode
|
# Files run in C++ mode
|
||||||
|
|
|
||||||
7
Examples/test-suite/errors/swig_typemap_warn.i
Normal file
7
Examples/test-suite/errors/swig_typemap_warn.i
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
%module xxx
|
||||||
|
|
||||||
|
%typemap(in, warning="1000:Test warning for 'in' typemap for $1_type $1_name ($1) - argnum: $argnum &1_ltype: $&1_ltype descriptor: $1_descriptor") int ""
|
||||||
|
|
||||||
|
%typemap(out, warning="1001:Test warning for 'out' typemap for $1_type $1_name ($1) - name: $name symname: $symname &1_ltype: $&1_ltype descriptor: $1_descriptor") double ""
|
||||||
|
|
||||||
|
double mmm(int abc, int);
|
||||||
|
|
@ -1254,16 +1254,15 @@ static void typemap_locals(DOHString * s, ParmList *l, Wrapper *f, int argnum) {
|
||||||
* typemap_warn()
|
* typemap_warn()
|
||||||
*
|
*
|
||||||
* If any warning message is attached to this parameter's "tmap:<method>:warning"
|
* If any warning message is attached to this parameter's "tmap:<method>:warning"
|
||||||
* attribute, print that warning message.
|
* attribute, return the warning message (special variables will need expanding
|
||||||
|
* before displaying the warning).
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
static void typemap_warn(const_String_or_char_ptr tmap_method, Parm *p) {
|
static String *typemap_warn(const_String_or_char_ptr tmap_method, Parm *p) {
|
||||||
String *temp = NewStringf("%s:warning", tmap_method);
|
String *temp = NewStringf("%s:warning", tmap_method);
|
||||||
String *w = Getattr(p, typemap_method_name(temp));
|
String *w = Getattr(p, typemap_method_name(temp));
|
||||||
Delete(temp);
|
Delete(temp);
|
||||||
if (w) {
|
return w ? Copy(w) : 0;
|
||||||
Swig_warning(0, Getfile(p), Getline(p), "%s\n", w);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
|
|
@ -1298,6 +1297,7 @@ static String *Swig_typemap_lookup_impl(const_String_or_char_ptr tmap_method, No
|
||||||
Hash *tm = 0;
|
Hash *tm = 0;
|
||||||
String *s = 0;
|
String *s = 0;
|
||||||
String *sdef = 0;
|
String *sdef = 0;
|
||||||
|
String *warning = 0;
|
||||||
ParmList *locals;
|
ParmList *locals;
|
||||||
ParmList *kw;
|
ParmList *kw;
|
||||||
char temp[256];
|
char temp[256];
|
||||||
|
|
@ -1443,10 +1443,16 @@ static String *Swig_typemap_lookup_impl(const_String_or_char_ptr tmap_method, No
|
||||||
lname = clname;
|
lname = clname;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
warning = typemap_warn(cmethod, node);
|
||||||
|
|
||||||
if (mtype && SwigType_isarray(mtype)) {
|
if (mtype && SwigType_isarray(mtype)) {
|
||||||
num_substitutions = typemap_replace_vars(s, locals, mtype, type, pname, (char *) lname, 1);
|
num_substitutions = typemap_replace_vars(s, locals, mtype, type, pname, (char *) lname, 1);
|
||||||
|
if (warning)
|
||||||
|
typemap_replace_vars(warning, 0, mtype, type, pname, (char *) lname, 1);
|
||||||
} else {
|
} else {
|
||||||
num_substitutions = typemap_replace_vars(s, locals, type, type, pname, (char *) lname, 1);
|
num_substitutions = typemap_replace_vars(s, locals, type, type, pname, (char *) lname, 1);
|
||||||
|
if (warning)
|
||||||
|
typemap_replace_vars(warning, 0, type, type, pname, (char *) lname, 1);
|
||||||
}
|
}
|
||||||
if (optimal_substitution && num_substitutions > 1) {
|
if (optimal_substitution && num_substitutions > 1) {
|
||||||
Swig_warning(WARN_TYPEMAP_OUT_OPTIMAL_MULTIPLE, Getfile(node), Getline(node), "Multiple calls to %s might be generated due to\n", Swig_name_decl(node));
|
Swig_warning(WARN_TYPEMAP_OUT_OPTIMAL_MULTIPLE, Getfile(node), Getline(node), "Multiple calls to %s might be generated due to\n", Swig_name_decl(node));
|
||||||
|
|
@ -1467,8 +1473,16 @@ static String *Swig_typemap_lookup_impl(const_String_or_char_ptr tmap_method, No
|
||||||
Replace(s, "$name", pname, DOH_REPLACE_ANY);
|
Replace(s, "$name", pname, DOH_REPLACE_ANY);
|
||||||
|
|
||||||
symname = Getattr(node, "sym:name");
|
symname = Getattr(node, "sym:name");
|
||||||
if (symname) {
|
if (symname)
|
||||||
Replace(s, "$symname", symname, DOH_REPLACE_ANY);
|
Replace(s, "$symname", symname, DOH_REPLACE_ANY);
|
||||||
|
|
||||||
|
/* Print warnings, if any */
|
||||||
|
if (warning) {
|
||||||
|
Replace(warning, "$name", pname, DOH_REPLACE_ANY);
|
||||||
|
if (symname)
|
||||||
|
Replace(warning, "$symname", symname, DOH_REPLACE_ANY);
|
||||||
|
Swig_warning(0, Getfile(node), Getline(node), "%s\n", warning);
|
||||||
|
Delete(warning);
|
||||||
}
|
}
|
||||||
|
|
||||||
Setattr(node, typemap_method_name(tmap_method), s);
|
Setattr(node, typemap_method_name(tmap_method), s);
|
||||||
|
|
@ -1483,9 +1497,6 @@ static String *Swig_typemap_lookup_impl(const_String_or_char_ptr tmap_method, No
|
||||||
Setattr(node, typemap_method_name(temp), "1");
|
Setattr(node, typemap_method_name(temp), "1");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Print warnings, if any */
|
|
||||||
typemap_warn(cmethod, node);
|
|
||||||
|
|
||||||
/* Look for code fragments */
|
/* Look for code fragments */
|
||||||
{
|
{
|
||||||
String *fragment;
|
String *fragment;
|
||||||
|
|
@ -1606,6 +1617,7 @@ void Swig_typemap_attach_parms(const_String_or_char_ptr tmap_method, ParmList *p
|
||||||
int nmatch = 0;
|
int nmatch = 0;
|
||||||
int i;
|
int i;
|
||||||
String *s;
|
String *s;
|
||||||
|
String *warning = 0;
|
||||||
ParmList *locals;
|
ParmList *locals;
|
||||||
int argnum = 0;
|
int argnum = 0;
|
||||||
char temp[256];
|
char temp[256];
|
||||||
|
|
@ -1705,6 +1717,7 @@ void Swig_typemap_attach_parms(const_String_or_char_ptr tmap_method, ParmList *p
|
||||||
if (locals)
|
if (locals)
|
||||||
locals = CopyParmList(locals);
|
locals = CopyParmList(locals);
|
||||||
firstp = p;
|
firstp = p;
|
||||||
|
warning = typemap_warn(tmap_method, firstp);
|
||||||
#ifdef SWIG_DEBUG
|
#ifdef SWIG_DEBUG
|
||||||
Printf(stdout, "nmatch: %d\n", nmatch);
|
Printf(stdout, "nmatch: %d\n", nmatch);
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -1722,9 +1735,13 @@ void Swig_typemap_attach_parms(const_String_or_char_ptr tmap_method, ParmList *p
|
||||||
|
|
||||||
if (mtype) {
|
if (mtype) {
|
||||||
typemap_replace_vars(s, locals, mtype, type, pname, lname, i + 1);
|
typemap_replace_vars(s, locals, mtype, type, pname, lname, i + 1);
|
||||||
|
if (warning)
|
||||||
|
typemap_replace_vars(warning, 0, mtype, type, pname, lname, i + 1);
|
||||||
Delattr(p, "tmap:match");
|
Delattr(p, "tmap:match");
|
||||||
} else {
|
} else {
|
||||||
typemap_replace_vars(s, locals, type, type, pname, lname, i + 1);
|
typemap_replace_vars(s, locals, type, type, pname, lname, i + 1);
|
||||||
|
if (warning)
|
||||||
|
typemap_replace_vars(warning, 0, type, type, pname, lname, i + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Checkattr(tm, "type", "SWIGTYPE")) {
|
if (Checkattr(tm, "type", "SWIGTYPE")) {
|
||||||
|
|
@ -1750,6 +1767,13 @@ void Swig_typemap_attach_parms(const_String_or_char_ptr tmap_method, ParmList *p
|
||||||
#endif
|
#endif
|
||||||
Setattr(firstp, typemap_method_name(tmap_method), s); /* Code object */
|
Setattr(firstp, typemap_method_name(tmap_method), s); /* Code object */
|
||||||
|
|
||||||
|
/* Print warnings, if any */
|
||||||
|
if (warning) {
|
||||||
|
Replace(warning, "$argnum", temp, DOH_REPLACE_ANY);
|
||||||
|
Swig_warning(0, Getfile(firstp), Getline(firstp), "%s\n", warning);
|
||||||
|
Delete(warning);
|
||||||
|
}
|
||||||
|
|
||||||
if (locals) {
|
if (locals) {
|
||||||
sprintf(temp, "%s:locals", cmethod);
|
sprintf(temp, "%s:locals", cmethod);
|
||||||
Setattr(firstp, typemap_method_name(temp), locals);
|
Setattr(firstp, typemap_method_name(temp), locals);
|
||||||
|
|
@ -1763,9 +1787,6 @@ void Swig_typemap_attach_parms(const_String_or_char_ptr tmap_method, ParmList *p
|
||||||
/* Attach kwargs */
|
/* Attach kwargs */
|
||||||
typemap_attach_kwargs(tm, tmap_method, firstp);
|
typemap_attach_kwargs(tm, tmap_method, firstp);
|
||||||
|
|
||||||
/* Print warnings, if any */
|
|
||||||
typemap_warn(tmap_method, firstp);
|
|
||||||
|
|
||||||
/* Look for code fragments */
|
/* Look for code fragments */
|
||||||
typemap_emit_code_fragments(tmap_method, firstp);
|
typemap_emit_code_fragments(tmap_method, firstp);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue