aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcelo Matus <mmatus@acms.arizona.edu>2006-01-07 06:59:32 +0000
committerMarcelo Matus <mmatus@acms.arizona.edu>2006-01-07 06:59:32 +0000
commit6e95b6433bcfbcb86519d29eb2876982bcc34771 (patch)
treeffc87403a8c09a4e28e2c92514052c5653dea154
parentab0b0ece71e36acae4611d85f947584145d0dfd9 (diff)
downloadswig-6e95b6433bcfbcb86519d29eb2876982bcc34771.tar.gz
add macros/names to avoid numeric warning codes. use them in tcl,perl,ruby and python
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@8274 626c5289-ae23-0410-ae9c-e8d60b6d4f22
-rw-r--r--Lib/perl5/cni.i2
-rw-r--r--Lib/perl5/perlkw.swg4
-rw-r--r--Lib/perl5/perlopers.swg39
-rw-r--r--Lib/python/pyopers.swg39
-rw-r--r--Lib/python/pythonkw.swg4
-rw-r--r--Lib/python/std_carray.i2
-rw-r--r--Lib/ruby/rubykw.swg2
-rw-r--r--Lib/ruby/rubyopers.swg41
-rw-r--r--Lib/swig.swg206
-rw-r--r--Lib/swigwarn.swg4
-rw-r--r--Lib/swigwarnings.swg129
-rw-r--r--Lib/tcl/tclkw.swg4
-rw-r--r--Lib/tcl/tclopers.swg22
13 files changed, 297 insertions, 201 deletions
diff --git a/Lib/perl5/cni.i b/Lib/perl5/cni.i
index 817f70565..c4d4eafa8 100644
--- a/Lib/perl5/cni.i
+++ b/Lib/perl5/cni.i
@@ -1,4 +1,4 @@
-%warnfilter(314) java::lang::ref;
+%warnfilter(SWIGWARN_PARSE_KEYWORD) java::lang::ref;
%{
#undef STATIC
diff --git a/Lib/perl5/perlkw.swg b/Lib/perl5/perlkw.swg
index 6fab240fa..71a229c66 100644
--- a/Lib/perl5/perlkw.swg
+++ b/Lib/perl5/perlkw.swg
@@ -1,6 +1,6 @@
/* Warnings for Perl keywords */
-#define PERLKW(x) %namewarn("314:" `x` " is a perl keyword") `x`
-#define PERLBN(x) %namewarn("321:" `x` " conflicts with a built-in name in perl") "::" `x`
+#define PERLKW(x) %keywordwarn(`x` " is a perl keyword") `x`
+#define PERLBN(x) %builtinwarn(`x` " conflicts with a built-in name in perl") "::" `x`
/*
diff --git a/Lib/perl5/perlopers.swg b/Lib/perl5/perlopers.swg
index 6cd52e52f..96b3f5977 100644
--- a/Lib/perl5/perlopers.swg
+++ b/Lib/perl5/perlopers.swg
@@ -33,23 +33,26 @@
%rename(__call__) *::operator();
/* Ignored operators */
-%ignorewarn("390:operator+ ignored") operator+();
-%ignorewarn("390:operator+ ignored") operator+() const;
-%ignorewarn("362:operator= ignored") operator=;
-%ignorewarn("365:operator+= ignored") operator+=;
-%ignorewarn("366:operator-= ignored") operator-=;
-%ignorewarn("367:operator*= ignored") operator*=;
-%ignorewarn("368:operator/= ignored") operator/=;
-%ignorewarn("369:operator%= ignored") operator%=;
-%ignorewarn("375:operator<<= ignored") operator<<=;
-%ignorewarn("376:operator>>= ignored") operator>>=;
-%ignorewarn("371:operator&= ignored") operator&=;
-%ignorewarn("372:operator|= ignored") operator|=;
-%ignorewarn("370:operator^= ignored") operator^=;
-%ignorewarn("381:operator&& ignored") operator&&;
-%ignorewarn("382:operator|| ignored") operator||;
-%ignorewarn("387:operator-> ignored") operator->;
-%ignorewarn("386:operator->* ignored") operator->*;
-%ignorewarn("389:operator[] ignored (consider using %extend)") operator[];
+%ignoreoperator(PLUS) operator+();
+%ignoreoperator(PLUS) operator+() const;
+%ignoreoperator(PLUSEQ) operator+=;
+%ignoreoperator(MINUSEQ) operator-=;
+%ignoreoperator(MULEQ) operator*=;
+%ignoreoperator(DIVEQ) operator/=;
+%ignoreoperator(MODEQ) operator%=;
+%ignoreoperator(LSHIFTEQ) operator<<=;
+%ignoreoperator(RSHIFTEQ) operator>>=;
+%ignoreoperator(ANDEQ) operator&=;
+%ignoreoperator(OREQ) operator|=;
+%ignoreoperator(XOREQ) operator^=;
+%ignoreoperator(LNOT) operator!;
+%ignoreoperator(LAND) operator&&;
+%ignoreoperator(LOR) operator||;
+%ignoreoperator(EQ) operator=;
+%ignoreoperator(PLUSPLUS) operator++;
+%ignoreoperator(MINUSMINUS) operator--;
+%ignoreoperator(ARROWSTAR) operator->*;
+%ignoreoperator(INDEX) operator[];
+
#endif /* __cplusplus */
diff --git a/Lib/python/pyopers.swg b/Lib/python/pyopers.swg
index 0317e7968..2d63b58b0 100644
--- a/Lib/python/pyopers.swg
+++ b/Lib/python/pyopers.swg
@@ -38,14 +38,14 @@
%rename(__call__) *::operator();
/* Ignored operators */
-%ignorewarn("361:operator! ignored") operator!;
-%ignorewarn("381:operator&& ignored") operator&&;
-%ignorewarn("382:operator|| ignored") operator||;
-%ignorewarn("362:operator= ignored") *::operator=;
-%ignorewarn("383:operator++ ignored") *::operator++;
-%ignorewarn("384:operator-- ignored") *::operator--;
-%ignorewarn("386:operator->* ignored") *::operator->*;
-%ignorewarn("389:operator[] ignored (consider using %extend)") *::operator[];
+%ignoreoperator(LNOT) operator!;
+%ignoreoperator(LAND) operator&&;
+%ignoreoperator(LOR) operator||;
+%ignoreoperator(EQ) *::operator=;
+%ignoreoperator(PLUSPLUS) *::operator++;
+%ignoreoperator(MINUSMINUS) *::operator--;
+%ignoreoperator(ARROWSTAR) *::operator->*;
+%ignoreoperator(INDEX) *::operator[];
/*
Inplace operator declarations.
@@ -107,17 +107,18 @@
/* C++ operator aliases */
-%ignorewarn("381:operator and ignored") operator and; // `and' `&&'
-%ignorewarn("361:operator not ignored") operator not; // `not' `!'
-%ignorewarn("382:operator or ignored") operator or; // `or' `||'
-%pyinplaceoper(__iand__, *::operator and_eq); // `and_eq' `&='
-%pybinoperator(__and__, *::operator bitand) // `bitand' `&'
-%pybinoperator(__or__, *::operator bitor); // `bitor' `|'
-%rename(__invert__) *::operator compl; // `compl' `~'
-%pybinoperator(__ne__, *::operator not_eq); // `not_eq' `!='
-%pyinplaceoper(__ior__, *::operator or_eq); // `or_eq' `|='
-%pybinoperator(__xor__, *::operator xor); // `xor' `^'
-%pyinplaceoper(__ixor__, *::operator xor_eq); // `xor_eq' `^='
+%ignoreoperator(LAND) operator and; // `and' `&&'
+%ignoreoperator(LNOT) operator not; // `not' `!'
+%ignoreoperator(LOR) operator or; // `or' `||'
+
+%pyinplaceoper(__iand__, *::operator and_eq); // `and_eq' `&='
+%pybinoperator(__and__, *::operator bitand) // `bitand' `&'
+%pybinoperator(__or__, *::operator bitor); // `bitor' `|'
+%rename(__invert__) *::operator compl; // `compl' `~'
+%pybinoperator(__ne__, *::operator not_eq); // `not_eq' `!='
+%pyinplaceoper(__ior__, *::operator or_eq); // `or_eq' `|='
+%pybinoperator(__xor__, *::operator xor); // `xor' `^'
+%pyinplaceoper(__ixor__, *::operator xor_eq); // `xor_eq' `^='
/* Finally, in python we need to mark the binary operations to fail as
diff --git a/Lib/python/pythonkw.swg b/Lib/python/pythonkw.swg
index 0960af5fb..f57d34ce4 100644
--- a/Lib/python/pythonkw.swg
+++ b/Lib/python/pythonkw.swg
@@ -2,8 +2,8 @@
Warnings for Python keywords, built-in names and bad names.
*/
-#define PYTHONKW(x) %namewarn("314:" `x` " is a python keyword, symbol will be renamed as '_" `x`"'", rename="_%s") `x`
-#define PYTHONBN(x) %namewarn("321:" `x` " conflicts with a built-in name in python") "::"`x`
+#define PYTHONKW(x) %keywordwarn(`x` " is a python keyword, symbol will be renamed as '_" `x`"'", rename="_%s") `x`
+#define PYTHONBN(x) %builtinwarn(`x` " conflicts with a built-in name in python") "::"`x`
/*
diff --git a/Lib/python/std_carray.i b/Lib/python/std_carray.i
index a12c52fe6..2e40757f2 100644
--- a/Lib/python/std_carray.i
+++ b/Lib/python/std_carray.i
@@ -13,7 +13,7 @@ namespace swig {
}
}
-%warnfilter(389) std::carray::operator[];
+%warnfilter(SWIGWARN_IGNORE_OPERATOR_INDEX) std::carray::operator[];
%extend std::carray {
%fragment(SWIG_Traits_frag(std::carray<_Type, _Size >), "header",
diff --git a/Lib/ruby/rubykw.swg b/Lib/ruby/rubykw.swg
index 6813cc529..3d76610a9 100644
--- a/Lib/ruby/rubykw.swg
+++ b/Lib/ruby/rubykw.swg
@@ -2,7 +2,7 @@
#define __ruby_rubykw_swg__
/* Warnings for Ruby keywords */
-#define RUBYKW(x) %namewarn("314:'" `x` "' is a ruby keyword, and it will renamed as 'C_"`x`"'",rename="C_%s") `x`
+#define RUBYKW(x) %keywordwanr("'" `x` "' is a ruby keyword, and it will renamed as 'C_"`x`"'",rename="C_%s") `x`
/*
diff --git a/Lib/ruby/rubyopers.swg b/Lib/ruby/rubyopers.swg
index 66da96928..d1ac8bf06 100644
--- a/Lib/ruby/rubyopers.swg
+++ b/Lib/ruby/rubyopers.swg
@@ -28,25 +28,28 @@
/* Special cases */
%rename(__call__) *::operator();
+/* Ignored inplace operators */
+%ignoreoperator(NOTEQUAL) operator!=;
+%ignoreoperator(PLUSEQ) operator+=;
+%ignoreoperator(MINUSEQ) operator-=;
+%ignoreoperator(MULEQ) operator*=;
+%ignoreoperator(DIVEQ) operator/=;
+%ignoreoperator(MODEQ) operator%=;
+%ignoreoperator(LSHIFTEQ) operator<<=;
+%ignoreoperator(RSHIFTEQ) operator>>=;
+%ignoreoperator(ANDEQ) operator&=;
+%ignoreoperator(OREQ) operator|=;
+%ignoreoperator(XOREQ) operator^=;
+
/* Ignored operators */
-%ignorewarn("378:operator!= ignored") operator!=;
-%ignorewarn("365:operator+= ignored") operator+=;
-%ignorewarn("366:operator-= ignored") operator-=;
-%ignorewarn("367:operator*= ignored") operator*=;
-%ignorewarn("368:operator/= ignored") operator/=;
-%ignorewarn("369:operator%= ignored") operator%=;
-%ignorewarn("375:operator<<= ignored") operator<<=;
-%ignorewarn("376:operator>>= ignored") operator>>=;
-%ignorewarn("371:operator&= ignored") operator&=;
-%ignorewarn("372:operator|= ignored") operator|=;
-%ignorewarn("370:operator^= ignored") operator^=;
-%ignorewarn("362:operator= ignored") operator=;
-%ignorewarn("383:operator++ ignored") operator++;
-%ignorewarn("384:operator-- ignored") operator--;
-%ignorewarn("381:operator&& ignored") operator&&;
-%ignorewarn("382:operator|| ignored") operator||;
-// %ignorewarn("387:operator-> ignored") operator->;
-%ignorewarn("386:operator->* ignored") operator->*;
-%ignorewarn("389:operator[] ignored (consider using %extend)") operator[];
+%ignoreoperator(LNOT) operator!;
+%ignoreoperator(LAND) operator&&;
+%ignoreoperator(LOR) operator||;
+%ignoreoperator(EQ) operator=;
+%ignoreoperator(PLUSPLUS) operator++;
+%ignoreoperator(MINUSMINUS) operator--;
+%ignoreoperator(ARROWSTAR) operator->*;
+%ignoreoperator(INDEX) operator[];
+
#endif /* __cplusplus */
diff --git a/Lib/swig.swg b/Lib/swig.swg
index a2d60dc9c..8ae990c77 100644
--- a/Lib/swig.swg
+++ b/Lib/swig.swg
@@ -7,6 +7,10 @@
* included at the top of each input file.
* ----------------------------------------------------------------------------- */
+/* -----------------------------------------------------------------------------
+ * User Directives
+ * ----------------------------------------------------------------------------- */
+
/* Deprecated SWIG directives */
#define %disabledoc %warn "104:%disabledoc is deprecated"
@@ -126,92 +130,98 @@
#define %nonaturalvar %feature("naturalvar","0")
#define %clearnaturalvar %feature("naturalvar","")
-/* Common features */
-
-/* Warnings */
-#define %_warnfilter(...) %feature("warnfilter",`__VA_ARGS__`)
-#define %warnfilter(...) %_warnfilter(__VA_ARGS__)
+/* Contract support - Experimental and undocumented */
+#define %contract %feature("contract")
+/* Macro for setting a dynamic cast function */
+%define DYNAMIC_CAST(mangle,func)
+%init %{
+ mangle->dcast = (swig_dycast_func) func;
+%}
+%enddef
+/* aggregation support */
/*
- Include the internal swig macro codes. These macros correspond to
- the one found in Source/Include/swigwarn.h plus the 'SWIG'prefix.
-
- For example, in the include file you will find
-
- WARN_TYPEMAP_CHARLEAK
-
- and in the interface you use the code for filters as
+ This macro performs constant aggregation. Basically the idea of
+ constant aggregation is that you can group a collection of constants
+ together. For example, suppose you have some code like this:
- %warnfilter(SWIGWARN_TYPEMAP_CHARLEAK);
+ #define UP 1
+ #define DOWN 2
+ #define LEFT 3
+ #define RIGHT 4
-*/
-%include <swigwarn.swg>
+ Now, suppose you had a function like this:
-/* Warnings messages used in typemaps. Message names will be the same
- as those in Lib/swigwarn.swg but with the suffix _MSG.
-
- For example, for the code SWIGWARN_TYPEMAP_CHARLEAK, once you use
+ int move(int direction)
- %warning_msg(SWIGWARN_TYPEMAP_CHARLEAK,<msg>);
+ In this case, you might want to restrict the direction argument to one of the supplied
+ constant names. To do this, you could write some typemap code by hand. Alternatively,
+ you can use the %aggregate_check macro defined here to create a simple check function
+ for you. Here is an example:
- you use the message in your typemap as
+ %aggregate_check(int, check_direction, UP, DOWN, LEFT, RIGHT);
- %typemap(varin,warning=SWIGWARN_TYPEMAP_CHARLEAK_MSG) char *
+ Now, using a typemap
- while you suppress the warning using
+ %typemap(check) int direction {
+ if (!check_direction($1)) SWIG_exception(SWIG_ValueError,"Bad direction.");
+ }
- %warnfilter(SWIGWARN_TYPEMAP_CHARLEAK);
+ or a contract (better)
- as described above.
-
+ %contract move(int x) {
+ require:
+ check_direction(x);
+ }
*/
-
-
-/* macros to create warning messages */
-%define %_warning_msg(Def, Val, Msg)
-%define Def `Val`":"`Msg` %enddef
-%enddef
-%define %warning_msg(x,msg)
-%_warning_msg(x##_MSG, x, msg)
+
+%define %aggregate_check(TYPE, NAME, FIRST, ...)
+%wrapper %{
+static int NAME(TYPE x) {
+ static TYPE values[] = { FIRST, ##__VA_ARGS__ };
+ static int size = sizeof(values);
+ int i,j;
+ for (i = 0, j = 0; i < size; i+=sizeof(TYPE),j++) {
+ if (x == values[j]) return 1;
+ }
+ return 0;
+}
+%}
%enddef
-/* specific warning messages */
-%warning_msg(SWIGWARN_TYPEMAP_CHARLEAK, "Setting const char * member may leak memory.")
-%warning_msg(SWIGWARN_TYPEMAP_SWIGTYPELEAK, "Setting a pointer/reference variable may leak memory.");
-%warning_msg(SWIGWARN_TYPEMAP_THREAD_UNSAFE, "Thread/reentrant unsafe wrapping, consider returning by value instead.");
-%warning_msg(SWIGWARN_TYPEMAP_DIRECTOROUT_PTR, "Returning a pointer or reference in a director method is not recommended.");
+/* -----------------------------------------------------------------------------
+ * Include all the warnings labels and macros
+ * ----------------------------------------------------------------------------- */
-/* Old warning messages names, for compatibility */
-%define SWIG_WARN_TYPEMAP_CHARLEAK SWIGWARN_TYPEMAP_CHARLEAK_MSG %enddef
-%define SWIG_WARN_TYPEMAP_SWIGTYPELEAK SWIGWARN_TYPEMAP_SWIGTYPELEAK_MSG %enddef
-%define SWIG_WARN_TYPEMAP_THREAD_UNSAFE SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG %enddef
-%define SWIG_WARN_TYPEMAP_DIRECTOROUT_PTR SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG %enddef
-
-/* Contract support - Experimental and undocumented */
-
-#define %contract %feature("contract")
+%include <swigwarnings.swg>
-/* Default handling of certain overloaded operators */
+/* -----------------------------------------------------------------------------
+ * Default handling of certain overloaded operators
+ * ----------------------------------------------------------------------------- */
#ifdef __cplusplus
-%ignorewarn("350:operator new ignored") operator new;
-%ignorewarn("351:operator delete ignored") operator delete;
-%ignorewarn("394:operator new[] ignored") operator new[];
-%ignorewarn("395:operator delete[] ignored") operator delete[];
+%ignorewarn(SWIGWARN_IGNORE_OPERATOR_NEW_MSG) operator new;
+%ignorewarn(SWIGWARN_IGNORE_OPERATOR_DELETE_MSG) operator delete;
+%ignorewarn(SWIGWARN_IGNORE_OPERATOR_NEWARR_MSG) operator new[];
+%ignorewarn(SWIGWARN_IGNORE_OPERATOR_DELARR_MSG) operator delete[];
/* Smart pointer handling */
%rename(__deref__) *::operator->;
-%rename(__ref__) *::operator*();
-%rename(__ref__) *::operator*() const;
+%rename(__ref__) *::operator*();
+%rename(__ref__) *::operator*() const;
/* Define std namespace */
namespace std {
}
#endif
+/* -----------------------------------------------------------------------------
+ * Default char * and C array typemaps
+ * ----------------------------------------------------------------------------- */
+
/* Set up the typemap for handling new return strings */
#ifdef __cplusplus
@@ -232,7 +242,7 @@ namespace std {
$1 = 0;
}
}
-%typemap(memberin,warning="451:Setting const char * member may leak memory.") const char * {
+%typemap(memberin,warning=SWIGWARN_TYPEMAP_CHARLEAK_MSG) const char * {
if ($input) {
$1 = ($1_type) (new char[strlen($input)+1]);
strcpy((char *) $1,$input);
@@ -249,7 +259,7 @@ namespace std {
$1 = 0;
}
}
-%typemap(globalin,warning="451:Setting const char * variable may leak memory.") const char * {
+%typemap(globalin,warning=SWIGWARN_TYPEMAP_CHARLEAK_MSG) const char * {
if ($input) {
$1 = ($1_type) (new char[strlen($input)+1]);
strcpy((char *) $1,$input);
@@ -267,7 +277,7 @@ namespace std {
$1 = 0;
}
}
-%typemap(memberin,warning="451:Setting const char * member may leak memory.") const char * {
+%typemap(memberin,warning=SWIGWARN_TYPEMAP_CHARLEAK_MSG) const char * {
if ($input) {
$1 = ($1_type) malloc(strlen($input)+1);
strcpy((char*)$1,$input);
@@ -284,7 +294,7 @@ namespace std {
$1 = 0;
}
}
-%typemap(globalin,warning="451:Setting const char * variable may leak memory.") const char * {
+%typemap(globalin,warning=SWIGWARN_TYPEMAP_CHARLEAK_MSG) const char * {
if ($input) {
$1 = ($1_type) malloc(strlen($input)+1);
strcpy((char*)$1,$input);
@@ -363,6 +373,10 @@ namespace std {
%typemap(in,numinputs=0) SWIGTYPE *VARARGS_SENTINEL, SWIGTYPE VARARGS_SENTINEL "";
+/* -----------------------------------------------------------------------------
+ * Overloading support
+ * ----------------------------------------------------------------------------- */
+
/*
* Function/method overloading support. This is done through typemaps,
* but also involve a precedence level.
@@ -370,12 +384,8 @@ namespace std {
/* Macro for overload resolution */
-%define %typecheck(_x, _opt...)
-#if #_opt != ""
-%typemap(typecheck, precedence=_x, _opt)
-#else
+%define %typecheck(_x...)
%typemap(typecheck, precedence=_x)
-#endif
%enddef
/* Macros for precedence levels */
@@ -442,6 +452,13 @@ namespace std {
%define SWIG_TYPECHECK_DOUBLE_PTR 2090 %enddef
%define SWIG_TYPECHECK_CHAR_PTR 2130 %enddef
+
+/* -----------------------------------------------------------------------------
+ * Runtime code
+ * ----------------------------------------------------------------------------- */
+
+/* The SwigValueWrapper class */
+
/*
* This template wrapper is used to handle C++ objects that are passed or
* returned by value. This is necessary to handle objects that define
@@ -514,64 +531,7 @@ private:
%}
#endif
-/* Macro for setting a dynamic cast function */
-%define DYNAMIC_CAST(mangle,func)
-%init %{
- mangle->dcast = (swig_dycast_func) func;
-%}
-%enddef
-
-/*
-
- This macro performs constant aggregation. Basically the idea of
- constant aggregation is that you can group a collection of constants
- together. For example, suppose you have some code like this:
-
- #define UP 1
- #define DOWN 2
- #define LEFT 3
- #define RIGHT 4
-
- Now, suppose you had a function like this:
-
- int move(int direction)
-
- In this case, you might want to restrict the direction argument to one of the supplied
- constant names. To do this, you could write some typemap code by hand. Alternatively,
- you can use the %aggregate_check macro defined here to create a simple check function
- for you. Here is an example:
-
- %aggregate_check(int, check_direction, UP, DOWN, LEFT, RIGHT);
-
- Now, using a typemap
-
- %typemap(check) int direction {
- if (!check_direction($1)) SWIG_exception(SWIG_ValueError,"Bad direction.");
- }
-
- or a contract (better)
-
- %contract move(int x) {
- require:
- check_direction(x);
- }
-*/
-
-%define %aggregate_check(TYPE, NAME, FIRST, ...)
-%wrapper %{
-static int NAME(TYPE x) {
- static TYPE values[] = { FIRST, ##__VA_ARGS__ };
- static int size = sizeof(values);
- int i,j;
- for (i = 0, j = 0; i < size; i+=sizeof(TYPE),j++) {
- if (x == values[j]) return 1;
- }
- return 0;
-}
-%}
-%enddef
-
-
+/* The swiglabels */
%insert("runtime") "swiglabels.swg"
diff --git a/Lib/swigwarn.swg b/Lib/swigwarn.swg
index 08dcf2d3b..f59514cf4 100644
--- a/Lib/swigwarn.swg
+++ b/Lib/swigwarn.swg
@@ -128,8 +128,8 @@
%define SWIGWARN_IGNORE_OPERATOR_UMUL 392 %enddef /* * */
%define SWIGWARN_IGNORE_OPERATOR_UAND 393 %enddef /* & */
%define SWIGWARN_IGNORE_OPERATOR_NEWARR 394 %enddef /* new [] */
-%define SWIGWARN_IGNORE_OEPRATOR_DELARR 395 %enddef /* delete [] */
-%define SWIGWARN_IGNORE_OEPRATOR_REF 396 %enddef /* operator *() */
+%define SWIGWARN_IGNORE_OPERATOR_DELARR 395 %enddef /* delete [] */
+%define SWIGWARN_IGNORE_OPERATOR_REF 396 %enddef /* operator *() */
/* 394-399 are reserved */
diff --git a/Lib/swigwarnings.swg b/Lib/swigwarnings.swg
new file mode 100644
index 000000000..8b85993fa
--- /dev/null
+++ b/Lib/swigwarnings.swg
@@ -0,0 +1,129 @@
+/*
+ Include the internal swig macro codes. These macros correspond to
+ the one found in Source/Include/swigwarn.h plus the 'SWIG'prefix.
+
+ For example, in the include file 'swigwarn.h' you will find
+
+ #define WARN_TYPEMAP_CHARLEAK ...
+
+ and in the 'swigwarn.swg' interface, you will see
+
+ %define SWIGWARN_TYPEMAP_CHARLEAK ...
+
+ This code can be used in warning filters as follows:
+
+ %warnfilter(SWIGWARN_TYPEMAP_CHARLEAK);
+
+ Warnings messages used in typemaps. Message names will be the same
+ as those in Lib/swigwarn.swg but with the suffix _MSG.
+
+ For example, for the code SWIGWARN_TYPEMAP_CHARLEAK, once you use
+
+ %typemapmsg(CHARLEAK,<msg>);
+
+ you use the message in your typemap as
+
+ %typemap(varin,warning=SWIGWARN_TYPEMAP_CHARLEAK_MSG) char *
+
+ while you suppress the warning using
+
+ %warnfilter(SWIGWARN_TYPEMAP_CHARLEAK);
+
+ as described above.
+*/
+
+%include <swigwarn.swg>
+
+
+
+/* -----------------------------------------------------------------------------
+ * Auxiliar macros
+ * ----------------------------------------------------------------------------- */
+
+/* Macro to define warning messages */
+%define %_warningmsg(Val, Msg...) `Val`":"Msg %enddef
+%define %warningmsg(Val, Msg...) %_warningmsg(Val, Msg) %enddef
+
+/* Macro to define warning macros */
+%define %_warningmacro(Def, Val, Msg)
+%define Def %warningmsg(Val, Msg) %enddef
+%enddef
+%define %warningmacro(x,msg)
+%_warningmacro(x##_MSG, x, msg)
+%enddef
+
+/* -----------------------------------------------------------------------------
+ * Define typemap macro messages
+ * ----------------------------------------------------------------------------- */
+
+%define %typemapmsg(TMap, msg) %warningmacro(SWIGWARN_TYPEMAP_##TMap,msg) %enddef
+
+%typemapmsg(CHARLEAK, "Setting a const char * variable may leak memory.")
+%typemapmsg(SWIGTYPELEAK, "Setting a pointer/reference variable may leak memory.");
+%typemapmsg(THREAD_UNSAFE, "Thread/reentrant unsafe wrapping, consider returning by value instead.");
+%typemapmsg(DIRECTOROUT_PTR, "Returning a pointer or reference in a director method is not recommended.");
+
+/* Old warning messages names, for compatibility */
+%define SWIG_WARN_TYPEMAP_CHARLEAK SWIGWARN_TYPEMAP_CHARLEAK_MSG %enddef
+%define SWIG_WARN_TYPEMAP_SWIGTYPELEAK SWIGWARN_TYPEMAP_SWIGTYPELEAK_MSG %enddef
+%define SWIG_WARN_TYPEMAP_THREAD_UNSAFE SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG %enddef
+%define SWIG_WARN_TYPEMAP_DIRECTOROUT_PTR SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG %enddef
+
+/* -----------------------------------------------------------------------------
+ * Define operator warning macro messages
+ * ----------------------------------------------------------------------------- */
+
+%define %ignoreopermsg(Oper, msg) %warningmacro(SWIGWARN_IGNORE_OPERATOR_##Oper,msg) %enddef
+
+%ignoreopermsg(NEW, "operator new ignored");
+%ignoreopermsg(DELETE, "operator delete ignored");
+%ignoreopermsg(NEWARR, "operator new[] ignored");
+%ignoreopermsg(DELARR, "operator delete[] ignored");
+
+%ignoreopermsg(PLUS, "operator+ ignored");
+%ignoreopermsg(MINUS, "operator- ignored");
+%ignoreopermsg(MUL, "operator* ignored");
+%ignoreopermsg(DIV, "operator/ ignored");
+%ignoreopermsg(MOD, "operator% ignored");
+%ignoreopermsg(XOR, "operator^ ignored");
+%ignoreopermsg(AND, "operator& ignored");
+%ignoreopermsg(OR, "operator| ignored");
+%ignoreopermsg(NOT, "operator~ ignored");
+%ignoreopermsg(LNOT, "operator! ignored");
+%ignoreopermsg(LAND, "operator&& ignored");
+%ignoreopermsg(LOR, "operator|| ignored");
+%ignoreopermsg(EQ, "operator= ignored");
+%ignoreopermsg(PLUSPLUS, "operator++ ignored");
+%ignoreopermsg(MINUSMINUS,"operator-- ignored");
+%ignoreopermsg(ARROWSTAR, "operator->* ignored");
+%ignoreopermsg(INDEX, "operator[] ignored (consider using %extend)");
+%ignoreopermsg(NOTEQUAL, "operator!= ignored");
+%ignoreopermsg(PLUSEQ, "operator+= ignored");
+%ignoreopermsg(MINUSEQ, "operator-= ignored");
+%ignoreopermsg(MULEQ, "operator*= ignored");
+%ignoreopermsg(DIVEQ, "operator/= ignored");
+%ignoreopermsg(MODEQ, "operator%= ignored");
+%ignoreopermsg(LSHIFTEQ, "operator<<= ignored");
+%ignoreopermsg(RSHIFTEQ, "operator>>= ignored");
+%ignoreopermsg(ANDEQ, "operator&= ignored");
+%ignoreopermsg(OREQ, "operator|= ignored");
+%ignoreopermsg(XOREQ, "operator^= ignored");
+
+%define %ignoreoperator(Oper) %ignorewarn(SWIGWARN_IGNORE_OPERATOR_##Oper##_MSG) %enddef
+
+/* -----------------------------------------------------------------------------
+ * Macros for keyword and built-in names
+ * ----------------------------------------------------------------------------- */
+
+%define %keywordwarn(msg...) %namewarn(%warningmsg(SWIGWARN_PARSE_KEYWORD, msg)) %enddef
+%define %builtinwarn(msg...) %namewarn(%warningmsg(SWIGWARN_PARSE_BUILTIN_NAME, msg)) %enddef
+
+
+/* -----------------------------------------------------------------------------
+ * Warning filter feature
+ * ----------------------------------------------------------------------------- */
+
+#define %_warnfilter(filter...) %feature("warnfilter",`filter`)
+#define %warnfilter(filter...) %_warnfilter(filter)
+
+
diff --git a/Lib/tcl/tclkw.swg b/Lib/tcl/tclkw.swg
index 64cf611d6..1cca5cad6 100644
--- a/Lib/tcl/tclkw.swg
+++ b/Lib/tcl/tclkw.swg
@@ -3,8 +3,8 @@
// Some special reserved words in classes
-%namewarn("314:cget is a tcl reserved method name") *::cget;
-%namewarn("314:configure is a tcl reserved method name") *::configure;
+%keywordwarn("cget is a tcl reserved method name") *::cget;
+%keywordwarn("configure is a tcl reserved method name") *::configure;
#endif //__tcl_tclkw_swg__
diff --git a/Lib/tcl/tclopers.swg b/Lib/tcl/tclopers.swg
index c03424801..98aaadf1e 100644
--- a/Lib/tcl/tclopers.swg
+++ b/Lib/tcl/tclopers.swg
@@ -23,16 +23,16 @@
%rename("=") *::operator=;
/* Ignored operators */
-%ignorewarn("378:operator!= ignored") operator!=;
-%ignorewarn("365:operator+= ignored") operator+=;
-%ignorewarn("366:operator-= ignored") operator-=;
-%ignorewarn("367:operator*= ignored") operator*=;
-%ignorewarn("368:operator/= ignored") operator/=;
-%ignorewarn("369:operator%= ignored") operator%=;
-%ignorewarn("375:operator<<= ignored") operator<<=;
-%ignorewarn("376:operator>>= ignored") operator>>=;
-%ignorewarn("371:operator&= ignored") operator&=;
-%ignorewarn("372:operator|= ignored") operator|=;
-%ignorewarn("370:operator^= ignored") operator^=;
+%ignoreoperator(NOTEQUAL) operator!=;
+%ignoreoperator(PLUSEQ) operator+=;
+%ignoreoperator(MINUSEQ) operator-=;
+%ignoreoperator(MULEQ) operator*=;
+%ignoreoperator(DIVEQ) operator/=;
+%ignoreoperator(MODEQ) operator%=;
+%ignoreoperator(LSHIFTEQ) operator<<=;
+%ignoreoperator(RSHIFTEQ) operator>>=;
+%ignoreoperator(ANDEQ) operator&=;
+%ignoreoperator(OREQ) operator|=;
+%ignoreoperator(XOREQ) operator^=;
#endif