summaryrefslogtreecommitdiff
path: root/Lib
diff options
context:
space:
mode:
authorMarcelo Matus <mmatus@acms.arizona.edu>2005-10-24 14:59:05 +0000
committerMarcelo Matus <mmatus@acms.arizona.edu>2005-10-24 14:59:05 +0000
commit3c65cea431715a5942e729c510f3e02ac5c35e61 (patch)
treebe33a88ec23740caf9c1b010ec268a0472868247 /Lib
parent733d3388620de44c41d80d376eb9bf4cc955fee4 (diff)
downloadswig-3c65cea431715a5942e729c510f3e02ac5c35e61.tar.gz
Perl added to the Unified typemap library, cleaner way to use the library, and 'normalized' macro names
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@7707 626c5289-ae23-0410-ae9c-e8d60b6d4f22
Diffstat (limited to 'Lib')
-rw-r--r--Lib/allkw.swg1
-rw-r--r--Lib/exception.i5
-rw-r--r--Lib/perl5/carrays.i2
-rw-r--r--Lib/perl5/cdata.i1
-rw-r--r--Lib/perl5/cmalloc.i1
-rw-r--r--Lib/perl5/cpointer.i1
-rw-r--r--Lib/perl5/cstring.i1
-rw-r--r--Lib/perl5/exception.i1
-rw-r--r--Lib/perl5/perl5.swg595
-rw-r--r--Lib/perl5/perlerrors.swg54
-rw-r--r--Lib/perl5/perlfragments.swg23
-rw-r--r--Lib/perl5/perlkw.swg251
-rw-r--r--Lib/perl5/perlmacros.swg17
-rw-r--r--Lib/perl5/perlopers.swg52
-rw-r--r--Lib/perl5/perlprimtypes.swg209
-rw-r--r--Lib/perl5/perlrun.swg299
-rw-r--r--Lib/perl5/perlruntime.swg101
-rw-r--r--Lib/perl5/perlstrings.swg48
-rw-r--r--Lib/perl5/perltypemaps.swg44
-rw-r--r--Lib/perl5/perluserdir.swg2
-rw-r--r--Lib/perl5/std_string.i77
-rw-r--r--Lib/perl5/typemaps.i598
-rw-r--r--Lib/python/argcargv.i10
-rw-r--r--Lib/python/attribute.i18
-rw-r--r--Lib/python/ccomplex.i6
-rw-r--r--Lib/python/cstring.i9
-rw-r--r--Lib/python/cwstring.i9
-rw-r--r--Lib/python/file.i2
-rw-r--r--Lib/python/pyapi.swg2
-rw-r--r--Lib/python/pycomplex.swg9
-rw-r--r--Lib/python/pycontainer.swg8
-rw-r--r--Lib/python/pyinit.swg2
-rw-r--r--Lib/python/pyprimtypes.swg118
-rw-r--r--Lib/python/pyrun.swg10
-rw-r--r--Lib/python/pystdcommon.swg20
-rw-r--r--Lib/python/pystrings.swg11
-rw-r--r--Lib/python/pyswigtype.swg2
-rw-r--r--Lib/python/pytuplehlp.swg2
-rw-r--r--Lib/python/pytypemaps.swg27
-rw-r--r--Lib/python/pywstrings.swg12
-rw-r--r--Lib/python/std_basic_string.i8
-rw-r--r--Lib/python/std_complex.i8
-rw-r--r--Lib/python/std_pair.i4
-rw-r--r--Lib/python/std_string.i29
-rw-r--r--Lib/python/std_wstring.i30
-rw-r--r--Lib/ruby/cstring.i9
-rw-r--r--Lib/ruby/rubyapi.swg2
-rw-r--r--Lib/ruby/rubyprimtypes.swg197
-rw-r--r--Lib/ruby/rubyrun.swg12
-rw-r--r--Lib/ruby/rubystrings.swg12
-rw-r--r--Lib/ruby/rubytypemaps.swg28
-rw-r--r--Lib/ruby/rubywstrings.swg74
-rw-r--r--Lib/ruby/std_string.i29
-rw-r--r--Lib/std/std_common.i20
-rw-r--r--Lib/std/std_container.i6
-rw-r--r--Lib/tcl/cstring.i9
-rw-r--r--Lib/tcl/cwstring.i12
-rw-r--r--Lib/tcl/std_string.i35
-rw-r--r--Lib/tcl/std_wstring.i37
-rw-r--r--Lib/tcl/tclerrors.swg2
-rw-r--r--Lib/tcl/tclinit.swg2
-rw-r--r--Lib/tcl/tclmacros.swg29
-rw-r--r--Lib/tcl/tclprimtypes.swg223
-rw-r--r--Lib/tcl/tclrun.swg17
-rw-r--r--Lib/tcl/tclstrings.swg7
-rw-r--r--Lib/tcl/tclswigtype.swg2
-rw-r--r--Lib/tcl/tcltypemaps.swg24
-rw-r--r--Lib/tcl/tclwstrings.swg59
-rw-r--r--Lib/typemaps/README60
-rw-r--r--Lib/typemaps/carrays.swg10
-rw-r--r--Lib/typemaps/cdata.swg2
-rw-r--r--Lib/typemaps/cpointer.swg12
-rw-r--r--Lib/typemaps/cstring.swg282
-rw-r--r--Lib/typemaps/cstrings.swg280
-rw-r--r--Lib/typemaps/cwstring.swg10
-rw-r--r--Lib/typemaps/enumint.swg24
-rw-r--r--Lib/typemaps/exception.swg24
-rw-r--r--Lib/typemaps/fragmacros.swg143
-rw-r--r--Lib/typemaps/fragments.swg289
-rw-r--r--Lib/typemaps/implicit.swg14
-rw-r--r--Lib/typemaps/inoutlist.swg114
-rw-r--r--Lib/typemaps/primtypes.swg126
-rw-r--r--Lib/typemaps/ptrtypes.swg138
-rw-r--r--Lib/typemaps/std_string.swg71
-rw-r--r--Lib/typemaps/std_strings.swg65
-rw-r--r--Lib/typemaps/std_wstring.swg25
-rw-r--r--Lib/typemaps/string.swg3
-rw-r--r--Lib/typemaps/strings.swg154
-rw-r--r--Lib/typemaps/swigmacros.swg210
-rw-r--r--Lib/typemaps/swigobject.swg10
-rw-r--r--Lib/typemaps/swigtype.swg283
-rw-r--r--Lib/typemaps/swigtypemaps.swg79
-rw-r--r--Lib/typemaps/typemaps.swg2
-rw-r--r--Lib/typemaps/valtypes.swg135
-rw-r--r--Lib/typemaps/void.swg20
-rw-r--r--Lib/typemaps/wstring.swg4
96 files changed, 2855 insertions, 3320 deletions
diff --git a/Lib/allkw.swg b/Lib/allkw.swg
index caa7fd137..d4f7d8876 100644
--- a/Lib/allkw.swg
+++ b/Lib/allkw.swg
@@ -25,6 +25,7 @@
%include "ocaml/ocamlkw.swg"
%include "ruby/rubykw.swg"
%include "tcl/tclkw.swg"
+%include "perl5/perlkw.swg"
#endif //__Lib_allkw_swg__
diff --git a/Lib/exception.i b/Lib/exception.i
index 531b1a584..7a6800bf7 100644
--- a/Lib/exception.i
+++ b/Lib/exception.i
@@ -8,11 +8,6 @@
%insert("runtime") "swigerrors.swg"
-#ifdef SWIGPERL5
-%{
-#define SWIG_exception(a,b) SWIG_croak(b)
-%}
-#endif
#ifdef SWIGPHP4
%{
diff --git a/Lib/perl5/carrays.i b/Lib/perl5/carrays.i
new file mode 100644
index 000000000..8be67abce
--- /dev/null
+++ b/Lib/perl5/carrays.i
@@ -0,0 +1,2 @@
+%include <typemaps/carrays.swg>
+
diff --git a/Lib/perl5/cdata.i b/Lib/perl5/cdata.i
new file mode 100644
index 000000000..367965990
--- /dev/null
+++ b/Lib/perl5/cdata.i
@@ -0,0 +1 @@
+%include <typemaps/cdata.swg>
diff --git a/Lib/perl5/cmalloc.i b/Lib/perl5/cmalloc.i
new file mode 100644
index 000000000..248f06b96
--- /dev/null
+++ b/Lib/perl5/cmalloc.i
@@ -0,0 +1 @@
+%include <typemaps/cmalloc.swg>
diff --git a/Lib/perl5/cpointer.i b/Lib/perl5/cpointer.i
new file mode 100644
index 000000000..d824792fa
--- /dev/null
+++ b/Lib/perl5/cpointer.i
@@ -0,0 +1 @@
+%include <typemaps/cpointer.swg>
diff --git a/Lib/perl5/cstring.i b/Lib/perl5/cstring.i
new file mode 100644
index 000000000..ede9c596a
--- /dev/null
+++ b/Lib/perl5/cstring.i
@@ -0,0 +1 @@
+%include <typemaps/cstring.swg>
diff --git a/Lib/perl5/exception.i b/Lib/perl5/exception.i
new file mode 100644
index 000000000..0246cfde8
--- /dev/null
+++ b/Lib/perl5/exception.i
@@ -0,0 +1 @@
+%include <typemaps/exception.swg>
diff --git a/Lib/perl5/perl5.swg b/Lib/perl5/perl5.swg
index 80c47397a..b66446e02 100644
--- a/Lib/perl5/perl5.swg
+++ b/Lib/perl5/perl5.swg
@@ -1,583 +1,52 @@
-/* -----------------------------------------------------------------------------
- * perl5.swg
+/* ------------------------------------------------------------
+ * perl.swg
*
- * Perl 5 configuration file
- * ----------------------------------------------------------------------------- */
-
-%runtime "swigrun.swg" // Common C API type-checking code
-%runtime "perlrun.swg" // Perl runtime functions
-%runtime "noembed.h" // undefine Perl5 macros
-
-#define %perlcode %insert("perl")
-
-/* Typemaps for input parameters */
-
-%typemap(in) int, short, long, signed char, enum SWIGTYPE
- "$1 = ($1_ltype) SvIV($input);";
-
-%typemap(in) bool
- "$1 = SvIV($input) ? true : false;";
-
-%typemap(in) unsigned int, unsigned short, unsigned long, unsigned char
- "$1 = ($1_ltype) SvUV($input);";
-
-%typemap(in) char
- "$1 = ($1_ltype) *SvPV($input,PL_na);";
-
-%typemap(in) float, double
- "$1 = ($1_ltype) SvNV($input);\n";
-
-%typemap(in) long long "$1 = ($1_ltype) strtoll(SvPV($input, PL_na), 0, 0);";
-%typemap(in) unsigned long long "$1 = ($1_ltype) strtoull(SvPV($input, PL_na), 0, 0);";
-
-%typemap(in) char *
- "if (!SvOK((SV*) $input)) $1 = 0;
- else $1 = ($1_ltype) SvPV($input, PL_na);";
-
-%typemap(in) char [ANY]
- "$1 = SvPV($input,PL_na);\n";
-
-%typemap(in) SWIGTYPE *, SWIGTYPE [], SWIGTYPE & {
- if (SWIG_ConvertPtr($input, (void **) &$1, $1_descriptor,0) < 0) {
- SWIG_croak("Type error in argument $argnum of $symname. Expected $1_mangle");
- }
-}
-
-%typemap(in) void * {
- if (SWIG_ConvertPtr($input, (void **) &$1, 0,0) < 0) {
- SWIG_croak("Type error in argument $argnum of $symname. Expected $1_mangle");
- }
-}
-
-/* Object passed by value. Convert to a pointer */
-%typemap(in) SWIGTYPE {
- $&1_ltype argp;
- if (SWIG_ConvertPtr($input,(void **) &argp, $&1_descriptor,0) < 0) {
- SWIG_croak("Type error in argument $argnum of $symname. Expected $&1_mangle");
- }
- $1 = *argp;
-}
-
-/* Pointer to a class member */
-%typemap(in) SWIGTYPE (CLASS::*) {
- if ((SWIG_ConvertPacked($input, (void *) &$1, sizeof($1_type), $1_descriptor,0)) < 0) {
- SWIG_croak("Type error in argument $argnum of $symname. Expected $&1_mangle");
- }
-}
-
-/* Const primitive references. Passed by value */
-
-%typemap(in) const int & (int temp),
- const short & (short temp),
- const long & (long temp),
- const signed char & (signed char temp),
- const enum SWIGTYPE & ($*1_ltype temp)
- "temp = ($*1_ltype) SvIV($input);
- $1 = &temp;";
-
-%typemap(in) const bool & (bool temp)
- "temp = SvIV($input) ? true : false;
- $1 = &temp;";
-
-%typemap(in) const unsigned int & (unsigned int temp),
- const unsigned short & (unsigned short temp),
- const unsigned long & (unsigned long temp),
- const unsigned char & (unsigned char temp)
- "temp = ($*1_ltype) SvUV($input);
- $1 = &temp;";
-
-%typemap(in) const float & (float temp),
- const double & (double temp)
- "temp = ($*1_ltype) SvNV($input);
- $1 = &temp;";
-
-%typemap(in) const long long & ($*1_ltype temp)
- "temp = ($*1_ltype) strtoll(SvPV($input,PL_na),0,0);
- $1 = &temp;";
-
-%typemap(in) const unsigned long long & ($*1_ltype temp)
- "temp = ($*1_ltype) strtoull(SvPV($input, PL_na),0,0);
- $1 = &temp;";
-
-%typemap(in) const char &(char temp) {
- temp = *SvPV($input,PL_na);
- $1 = &temp;
-}
-
-/* Typemap for output values */
-
-%typemap(out) int, short, long, signed char, bool, enum SWIGTYPE
- "ST(argvi) = sv_newmortal();
- sv_setiv(ST(argvi++), (IV) $1);";
-
-%typemap(out) unsigned int, unsigned short, unsigned long, unsigned char
- "ST(argvi) = sv_newmortal();
- sv_setuv(ST(argvi++), (UV) $1);";
-
-%typemap(out) float, double
- "ST(argvi) = sv_newmortal();
- sv_setnv(ST(argvi++), (double) $1);";
-
-%typemap(out) char
- "ST(argvi) = sv_newmortal();
- sv_setpvn((SV*)ST(argvi++), &$1, 1);";
-
-%typemap(out) char *
- "ST(argvi) = sv_newmortal();
- if ($1) {
- sv_setpv((SV*)ST(argvi++), (char *) $1);
- } else {
- sv_setsv((SV*)ST(argvi++), &PL_sv_undef);
- }";
-
-%typemap(out) long long {
- char temp[256];
- sprintf(temp,"%lld", (long long) $1);
- ST(argvi) = sv_newmortal();
- sv_setpv((SV*)ST(argvi++), temp);
-}
-
-%typemap(out) unsigned long long {
- char temp[256];
- sprintf(temp,"%llu", (unsigned long long) $1);
- ST(argvi) = sv_newmortal();
- sv_setpv((SV*)ST(argvi++), temp);
-}
-
-%typemap(out) SWIGTYPE *, SWIGTYPE [], SWIGTYPE &
- "ST(argvi) = sv_newmortal();
- SWIG_MakePtr(ST(argvi++), (void *) $1, $1_descriptor, $shadow|$owner);";
-
-
-%typemap(out) SWIGTYPE
-#ifdef __cplusplus
-{
- $&1_ltype resultobj = new $1_ltype(($1_ltype &)$1);
- ST(argvi) = sv_newmortal();
- SWIG_MakePtr(ST(argvi++), (void *) resultobj, $&1_descriptor, $shadow|SWIG_OWNER);
-}
-#else
-{
- $&1_ltype resultobj = ($&1_ltype) malloc(sizeof($1_type));
- memmove(resultobj, &$1, sizeof($1_type));
- ST(argvi) = sv_newmortal();
- SWIG_MakePtr(ST(argvi++), (void *) resultobj, $&1_descriptor, $shadow|SWIG_OWNER);
-}
-#endif
-
-/* Dynamic casts */
-
-%typemap(out) SWIGTYPE *DYNAMIC, SWIGTYPE &DYNAMIC {
- swig_type_info *ty = SWIG_TypeDynamicCast($1_descriptor, (void **) &$1);
- ST(argvi) = sv_newmortal();
- SWIG_MakePtr(ST(argvi++), (void *) $1, ty, $shadow|$owner);
-}
-
-/* Member pointer */
-%typemap(out) SWIGTYPE (CLASS::*) {
- ST(argvi) = sv_newmortal();
- SWIG_MakePackedObj(ST(argvi), (void *) &$1, sizeof($1_type), $1_descriptor);
- argvi++;
-}
-
-%typemap(out) void "";
-
-/* Typemap for character array returns */
-
-%typemap(out) char [ANY]
- "ST(argvi) = sv_newmortal();
- sv_setpv((SV*)ST(argvi++),(char *) $1);";
-
-
-
-/* References to primitive types. Return by value */
-
-%typemap(out) const int &,
- const short &,
- const long &,
- const signed char &,
- const bool &,
- const enum SWIGTYPE &
- "ST(argvi) = sv_newmortal();
- sv_setiv(ST(argvi++), (IV) *($1));";
-
-%typemap(out) const unsigned int &,
- const unsigned short &,
- const unsigned long &,
- const unsigned char &
- "ST(argvi) = sv_newmortal();
- sv_setuv(ST(argvi++), (UV) *($1));";
-
-%typemap(out) const float &, const double &
- "ST(argvi) = sv_newmortal();
- sv_setnv(ST(argvi++), (double) *($1));";
-
-%typemap(out) const long long & {
- char temp[256];
- sprintf(temp,"%lld", (long long)*($1));
- ST(argvi) = sv_newmortal();
- sv_setpv((SV*)ST(argvi++), temp);
-}
-
-%typemap(out) const unsigned long long & {
- char temp[256];
- sprintf(temp,"%llu", (unsigned long long)*($1));
- ST(argvi) = sv_newmortal();
- sv_setpv((SV*)ST(argvi++), temp);
-}
-
-%typemap(out) const char &
- "ST(argvi) = sv_newmortal();
- sv_setpvn((SV*)ST(argvi++), $1, 1);";
-
-
-/* Variable input */
-
-%typemap(varin) int, short, long, signed char
- "$1 = ($1_ltype) SvIV($input);";
-
-%typemap(varin) bool
- "$1 = SvIV($input) ? true : false;";
-
-%typemap(varin) unsigned int, unsigned short, unsigned long, unsigned char
- "$1 = ($1_ltype) SvUV($input);";
-
-%typemap(varin) char
- "$1 = ($1_ltype) *SvPV($input,PL_na);";
-
-%typemap(varin) float, double
- "$1 = ($1_ltype) SvNV($input);\n";
-
-%typemap(varin) long long "$1 = ($1_ltype) strtoll(SvPV($input, PL_na), 0, 0);";
-%typemap(varin) unsigned long long "$1 = ($1_ltype) strtoull(SvPV($input, PL_na), 0, 0);";
-
-%typemap(varin) SWIGTYPE * {
- void *temp;
- if (SWIG_ConvertPtr($input, &temp, $1_descriptor,0) < 0) {
- croak("Type error in argument $argnum of $symname. Expected $1_mangle");
- }
- $1 = ($1_ltype) temp;
-}
-
-%typemap(varin) SWIGTYPE [ANY] {
- int i;
- $1_basetype *temp;
- $1_basetype *b = ($1_basetype *) $1;
- if (SWIG_ConvertPtr($input, (void **) &temp, $1_descriptor,0) < 0) {
- croak("Type error in argument $argnum of $symname. Expected $1_mangle");
- }
- for (i = 0; i < $1_size; i++) b[i] = temp[i];
-}
-
-%typemap(varin,warning="462:Unable to set dimensionless array variable") SWIGTYPE []
-{
- croak("C/C++ variable '$name' is read-only");
-}
-
-%typemap(varin) SWIGTYPE & {
- void *temp;
- if (SWIG_ConvertPtr($input, &temp, $1_descriptor,0) < 0) {
- croak("Type error in argument $argnum of $symname. Expected $1_mangle");
- }
- $1 = *($1_ltype) temp;
-}
-
-%typemap(varin) void * {
- void *temp;
- if (SWIG_ConvertPtr($input, &temp, 0,0) < 0) {
- croak("Type error in argument $argnum of $symname. Expected $1_mangle");
- }
- $1 = temp;
-}
-
-/* Object passed by value. Convert to a pointer */
-%typemap(varin) SWIGTYPE {
- $&1_ltype temp;
- if (SWIG_ConvertPtr($input,(void **) &temp, $&1_descriptor,0) < 0) {
- croak("Type error in argument $argnum of $symname. Expected $&1_mangle");
- }
- $1 = *temp;
-}
-
-/* Member pointer */
-%typemap(varin) SWIGTYPE (CLASS::*) {
- char temp[sizeof($1_type)];
- if (SWIG_ConvertPacked($input, (void *) temp, sizeof($1_type), $1_descriptor, 0) < 0) {
- croak("Type error in argument $argnum of $symname. Expected $&1_mangle");
- }
- memmove((void *) &$1, temp, sizeof($1_type));
-}
-
-/* Const primitive references. Passed by value */
-
-%typemap(varin) const int & (int temp),
- const short & (short temp),
- const long & (long temp),
- const signed char & (signed char temp),
- const enum SWIGTYPE & ($*1_ltype temp)
- "temp = ($*1_ltype) SvIV($input);
- $1 = &temp;";
-
-%typemap(varin) const bool & (bool temp)
- "temp = SvIV($input) ? true : false;
- $1 = &temp;";
-
-%typemap(varin) const unsigned int & (unsigned int temp),
- const unsigned short & (unsigned short temp),
- const unsigned long & (unsigned long temp),
- const unsigned char & (unsigned char temp)
- "temp = ($*1_ltype) SvUV($input);
- $1 = &temp;";
-
-%typemap(varin) const float & (float temp),
- const double & (double temp)
- "temp = ($*1_ltype) SvNV($input);
- $1 = &temp;";
-
-%typemap(varin) const long long & ($*1_ltype temp)
- "temp = ($1_ltype) strtoll(SvPV($input,PL_na),0,0);
- $1 = &temp;";
-
-%typemap(varin) const unsigned long long & ($*1_ltype temp)
- "temp = ($1_ltype) strtoull(SvPV($input, PL_na),0,0);
- $1 = &temp;";
-
-%typemap(varin) const char &(char temp) {
- temp = *SvPV($input,PL_na);
- $1 = &temp;
-}
-
-%typemap(varin) char *
-#ifdef __cplusplus
-{
- char *_a = (char *) SvPV(sv,PL_na);
- if ($1) delete [] $1;
- $1 = new char[strlen(_a)+1];
- strcpy((char *)$1,_a);
-}
-#else
-{
- char *_a = (char *) SvPV(sv,PL_na);
- if ($1) free((char *) $1);
- $1 = (char *) malloc(strlen(_a)+1);
- strcpy((char *)$1,_a);
-}
-#endif
-
-%typemap(varin,warning="451:Setting const char * variable may leak memory") const char *
-#ifdef __cplusplus
-{
- char *_a = (char *) SvPV(sv,PL_na);
- $1 = new char[strlen(_a)+1];
- strcpy((char *)$1,_a);
-}
-#else
-{
- char *_a = (char *) SvPV(sv,PL_na);
- $1 = (char *) malloc(strlen(_a)+1);
- strcpy((char *)$1,_a);
-}
-#endif
-
-%typemap(varin) char [ANY]
- "strncpy($1, (char *) SvPV(sv,PL_na), $1_dim0);";
-
-%typemap(varin,warning="462: Unable to set variable of type char []") char []
- { croak("Variable $symname is read-only."); }
-
-%typemap(varin) enum SWIGTYPE {
- if (sizeof(int) != sizeof($1)) {
- croak("enum variable '$name' can not be set.");
- }
- *(int *)(void *)&($1) = SvIV($input);
-}
-
-/* --- Typemaps for variable output --- */
-
-%typemap(varout) int, short, long, signed char, bool, enum SWIGTYPE
- "sv_setiv($result, (IV) $1);";
-
-%typemap(varout) unsigned int, unsigned short, unsigned long, unsigned char
- "sv_setuv($result, (UV) $1);";
-
-%typemap(varout) float, double
- "sv_setnv($result, (double) $1);";
-
-%typemap(varout) char
- "sv_setpvn((SV *) $result, &$1, 1);";
-
-%typemap(varout) long long {
- char temp[256];
- sprintf(temp,"%lld",(long long)$1);
- sv_setpv((SV *) $result, temp);
-}
-
-%typemap(varout) unsigned long long {
- char temp[256];
- sprintf(temp,"%llu",(unsigned long long)$1);
- sv_setpv((SV *) $result, temp);
-}
-
-%typemap(varout) char *, char [ANY]
- "if ($1) {
- sv_setpv((SV*)$result, (char *) $1);
- } else {
- sv_setsv((SV*)$result, &PL_sv_undef);
- }";
-
-//%typemap(varout) SWIGTYPE *, SWIGTYPE &, SWIGTYPE []
-// "SWIG_MakePtr($result, (void *) $1, $1_descriptor);";
-
-%typemap(varout,type="$1_descriptor") SWIGTYPE *, SWIGTYPE []
- "sv_setiv(SvRV($result),(IV) $1);";
-
-%typemap(varout,type="$1_descriptor") SWIGTYPE &
- "sv_setiv(SvRV($result),(IV) &$1);";
-
-//%typemap(varout) SWIGTYPE
-// "SWIG_MakePtr($result, (void *) &$1, $&1_descriptor);";
-
-%typemap(varout,type="$&1_descriptor") SWIGTYPE
- "sv_setiv(SvRV($result), (IV) &$1);";
-
-%typemap(varout,type="$1_descriptor") SWIGTYPE (CLASS::*) {
- SWIG_MakePackedObj($result, (void *) &$1, sizeof($1_type), $1_descriptor);
-}
-
-/* --- Typemaps for constants --- *
-
-/* --- Constants --- */
-
-%typemap(consttab) int, unsigned int, short, unsigned short, long, unsigned long, unsigned char, signed char, bool, enum SWIGTYPE
- { SWIG_INT, (char *) SWIG_prefix "$symname", (long) $value, 0, 0, 0}
-
-%typemap(consttab) float, double
- { SWIG_FLOAT, (char *) SWIG_prefix "$symname", 0, (double) $value, 0, 0}
-
-%typemap(consttab) char, char *
- { SWIG_STRING, (char *) SWIG_prefix "$symname", 0, 0, (void *)$value, 0}
-
-%typemap(consttab) long long, unsigned long long
- { SWIG_STRING, (char *) SWIG_prefix "$symname", 0, 0, (void *) "$value", 0}
-
-%typemap(consttab) SWIGTYPE *, SWIGTYPE &, SWIGTYPE []
- { SWIG_POINTER, (char *) SWIG_prefix "$symname", 0, 0, (void *)$value, &$1_descriptor}
-
-%typemap(consttab) SWIGTYPE (CLASS::*)
- { SWIG_BINARY, (char *) SWIG_prefix "$symname", sizeof($type), 0, (void *)&$value, &$1_descriptor}
-
+ * Perl configuration module.
+ * ------------------------------------------------------------ */
/* ------------------------------------------------------------
- * String & length
+ * Inner macros
* ------------------------------------------------------------ */
-
-%typemap(in) (char *STRING, int LENGTH) {
- STRLEN temp;
- $1 = ($1_ltype) SvPV($input,temp);
- $2 = ($2_ltype) temp;
-}
+%include <perlmacros.swg>
/* ------------------------------------------------------------
- * Typechecking rules
+ * Error manipulation
* ------------------------------------------------------------ */
-
-%typecheck(SWIG_TYPECHECK_INTEGER)
- int, short, long,
- unsigned int, unsigned short, unsigned long,
- signed char, unsigned char,
- long long, unsigned long long,
- const int &, const short &, const long &,
- const unsigned int &, const unsigned short &, const unsigned long &,
- const long long &, const unsigned long long &,
- enum SWIGTYPE, const enum SWIGTYPE &,
- bool, const bool &
-{
- $1 = SvIOK($input) ? 1 : 0;
-}
-
-%typecheck(SWIG_TYPECHECK_DOUBLE)
- float, double,
- const float &, const double &
-{
- $1 = SvNIOK($input) ? 1 : 0;
-}
-
-%typecheck(SWIG_TYPECHECK_CHAR) char {
- $1 = SvPOK($input) ? 1 : 0;
-}
-
-%typecheck(SWIG_TYPECHECK_STRING) char * {
- $1 = SvPOK($input) ? 1 : 0;
-}
-
-%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [] {
- void *tmp;
- if (SWIG_ConvertPtr($input, (void **) &tmp, $1_descriptor, 0) == -1) {
- $1 = 0;
- } else {
- $1 = 1;
- }
-}
-
-%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE {
- void *tmp;
- if (SWIG_ConvertPtr($input, (void **) &tmp, $&1_descriptor, 0) == -1) {
- $1 = 0;
- } else {
- $1 = 1;
- }
-}
-
-%typecheck(SWIG_TYPECHECK_VOIDPTR) void * {
- void *tmp;
- if (SWIG_ConvertPtr($input, (void **) &tmp, 0, 0) == -1) {
- $1 = 0;
- } else {
- $1 = 1;
- }
-}
+%include <perlerrors.swg>
/* ------------------------------------------------------------
- * Exception handling
+ * The runtime part
* ------------------------------------------------------------ */
+%include <perlruntime.swg>
-%typemap(throws) int,
- long,
- short,
- unsigned int,
- unsigned long,
- unsigned short {
- SWIG_SetErrorf("%d", $1); SWIG_fail;
-}
+/* ------------------------------------------------------------
+ * Special user directives
+ * ------------------------------------------------------------ */
+%include <perluserdir.swg>
-/* throws real objects */
-%typemap(throws) SWIGTYPE
-{
- SV *esv=sv_newmortal();
- $&1_ltype copy = new $1_ltype(($1_ltype &)$1);
- SWIG_MakePtr(esv, (void *) copy,
- $&1_descriptor, SWIG_OWNER);
- SWIG_croakSV(esv);
-}
+/* ------------------------------------------------------------
+ * Look for user fragments file.
+ * ------------------------------------------------------------ */
+%include "perlfragments.swg"
-%typemap(throws) SWIGTYPE, SWIGTYPE &, SWIGTYPE *, SWIGTYPE [ANY] %{
- (void)$1;
- SWIG_croak("C++ $1_type exception thrown");
-%}
+/* ------------------------------------------------------------
+ * Typemap specializations
+ * ------------------------------------------------------------ */
+%include <perltypemaps.swg>
-%typemap(throws) enum SWIGTYPE %{
- (void)$1;
- SWIG_croak("C++ $1_type exception thrown");
-%}
+/* ------------------------------------------------------------
+ * Overloaded operator support
+ * ------------------------------------------------------------ */
+%include <perlopers.swg>
-%typemap(throws) char * {
- SWIG_croak($1);
-}
+/* ------------------------------------------------------------
+ * Warnings for Perl keywords
+ * ------------------------------------------------------------ */
+%include <perlkw.swg>
/* ------------------------------------------------------------
- * ANSI C typemaps
+ * The Perl initialization function
* ------------------------------------------------------------ */
+%include <perlinit.swg>
-%apply unsigned long { size_t };
-%include "perlinit.swg"
diff --git a/Lib/perl5/perlerrors.swg b/Lib/perl5/perlerrors.swg
new file mode 100644
index 000000000..ee05bcf04
--- /dev/null
+++ b/Lib/perl5/perlerrors.swg
@@ -0,0 +1,54 @@
+/* -----------------------------------------------------------------------------
+ * error manipulation
+ * ----------------------------------------------------------------------------- */
+
+%insert("runtime") "swigerrors.swg"
+
+%insert("header") %{
+
+SWIGINTERN const char*
+SWIG_Perl_ErrorType(int code) {
+ const char* type = 0;
+ switch(code) {
+ case SWIG_MemoryError:
+ type = "MemoryError";
+ break;
+ case SWIG_IOError:
+ type = "IOError";
+ break;
+ case SWIG_RuntimeError:
+ type = "RuntimeError";
+ break;
+ case SWIG_IndexError:
+ type = "IndexError";
+ break;
+ case SWIG_TypeError:
+ type = "TypeError";
+ break;
+ case SWIG_DivisionByZero:
+ type = "ZeroDivisionError";
+ break;
+ case SWIG_OverflowError:
+ type = "OverflowError";
+ break;
+ case SWIG_SyntaxError:
+ type = "SyntaxError";
+ break;
+ case SWIG_ValueError:
+ type = "ValueError";
+ break;
+ case SWIG_SystemError:
+ type = "SystemError";
+ break;
+ case SWIG_AttributeError:
+ type = "AttributeError";
+ break;
+ default:
+ type = "RuntimeError";
+ }
+ return type;
+}
+
+%}
+
+
diff --git a/Lib/perl5/perlfragments.swg b/Lib/perl5/perlfragments.swg
new file mode 100644
index 000000000..8b63ee3a2
--- /dev/null
+++ b/Lib/perl5/perlfragments.swg
@@ -0,0 +1,23 @@
+/*
+
+ Create a file with this name, 'fragments.i', in your working
+ directory and add all the %fragments you want to take precedence
+ over the ones defined by default by swig.
+
+ For example, if you add:
+
+ %fragment(SWIG_AsVal_frag(int),"header") {
+ SWIGINTERNINLINE int
+ SWIG_AsVal(int)(PyObject *obj, int *val)
+ {
+ <your code here>;
+ }
+ }
+
+ this will replace the code used to retreive an integer value for all
+ the typemaps that need it, including:
+
+ int, std::vector<int>, std::list<std::pair<int,int> >, etc.
+
+
+*/
diff --git a/Lib/perl5/perlkw.swg b/Lib/perl5/perlkw.swg
new file mode 100644
index 000000000..6fab240fa
--- /dev/null
+++ b/Lib/perl5/perlkw.swg
@@ -0,0 +1,251 @@
+/* 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`
+
+
+/*
+
+ From http://www.rocketaware.com/perl/perlfunc/
+
+*/
+
+/* Functions for SCALARs or strings*/
+PERLBN(chomp);
+PERLBN(chop);
+PERLBN(chr);
+PERLBN(crypt);
+PERLBN(hex);
+PERLBN(index);
+PERLBN(lc);
+PERLBN(lcfirst);
+PERLBN(length);
+PERLBN(oct);
+PERLBN(ord);
+PERLBN(pack);
+PERLBN(reverse);
+PERLBN(rindex);
+PERLBN(sprintf);
+PERLBN(substr);
+PERLBN(uc);
+PERLBN(ucfirst);
+
+/* Regular expressions and pattern matching */
+PERLBN(m);
+PERLBN(pos);
+PERLBN(quotemeta);
+PERLBN(split);
+PERLBN(study);
+
+/* Numeric functions */
+PERLBN(abs);
+PERLBN(atan2);
+PERLBN(cos);
+PERLBN(exp);
+PERLBN(hex);
+PERLBN(int);
+PERLBN(log);
+PERLBN(oct);
+PERLBN(rand);
+PERLBN(sin);
+PERLBN(sqrt);
+PERLBN(srand);
+
+
+/* Functions for real @ARRAYs*/
+PERLBN(pop);
+PERLBN(push);
+PERLBN(shift);
+PERLBN(splice);
+PERLBN(unshift);
+
+/* Functions for list data*/
+PERLBN(grep);
+PERLBN(join);
+PERLBN(map);
+PERLBN(qw);
+PERLBN(reverse);
+PERLBN(sort);
+PERLBN(unpack);
+
+
+/* Functions for real %HASHes*/
+PERLBN(delete);
+PERLBN(each);
+PERLBN(exists);
+PERLBN(keys);
+PERLBN(values);
+
+
+/* Input and output functions*/
+
+PERLBN(binmode);
+PERLBN(close);
+PERLBN(closedir);
+PERLBN(dbmclose);
+PERLBN(dbmopen);
+PERLBN(die);
+PERLBN(eof);
+PERLBN(fileno);
+PERLBN(flock);
+PERLBN(format);
+PERLBN(getc);
+PERLBN(print);
+PERLBN(printf);
+PERLBN(read);
+PERLBN(readdir);
+PERLBN(rewinddir);
+PERLBN(seek);
+PERLBN(seekdir);
+PERLBN(select);
+PERLBN(syscall);
+PERLBN(sysread);
+PERLBN(sysseek);
+PERLBN(syswrite);
+PERLBN(tell);
+PERLBN(telldir);
+PERLBN(truncate);
+PERLBN(warn);
+PERLBN(write);
+
+
+/* Functions for fixed length data or records*/
+PERLBN(pack);
+PERLBN(read);
+PERLBN(syscall);
+PERLBN(sysread);
+PERLBN(syswrite);
+PERLBN(unpack);
+PERLBN(vec);
+
+
+/* Functions for filehandles, files, or directories */
+PERLBN(chdir);
+PERLBN(chmod);
+PERLBN(chown);
+PERLBN(chroot);
+PERLBN(fcntl);
+PERLBN(glob);
+PERLBN(ioctl);
+PERLBN(link);
+PERLBN(lstat);
+PERLBN(mkdir);
+PERLBN(open);
+PERLBN(opendir);
+PERLBN(readlink);
+PERLBN(rename);
+PERLBN(rmdir);
+PERLBN(stat);
+PERLBN(symlink);
+PERLBN(umask);
+PERLBN(unlink);
+PERLBN(utime);
+
+
+/* Keywords related to the control flow of your perl program */
+PERLKW(caller);
+PERLKW(continue);
+PERLKW(die);
+PERLKW(do);
+PERLKW(dump);
+PERLKW(eval);
+PERLKW(exit);
+PERLKW(goto);
+PERLKW(last);
+PERLKW(next);
+PERLKW(redo);
+PERLKW(return);
+PERLKW(sub);
+PERLKW(wantarray);
+
+
+/* Keywords related to scoping */
+PERLKW(caller);
+PERLKW(import);
+PERLKW(local);
+PERLKW(my);
+PERLKW(package);
+PERLKW(use);
+
+
+/* Miscellaneous functions */
+PERLBN("defined");
+PERLBN(dump);
+PERLBN(eval);
+PERLBN(formline);
+PERLBN(local);
+PERLBN(my);
+PERLBN(reset);
+PERLBN(scalar);
+PERLBN(undef);
+PERLBN(wantarray);
+
+
+/* Functions for processes and process groups */
+PERLBN(alarm);
+PERLBN(exec);
+PERLBN(fork);
+PERLBN(getpgrp);
+PERLBN(getppid);
+PERLBN(getpriority);
+PERLBN(kill);
+PERLBN(pipe);
+PERLBN(setpgrp);
+PERLBN(setpriority);
+PERLBN(sleep);
+PERLBN(system);
+PERLBN(times);
+PERLBN(wait);
+PERLBN(waitpid);
+
+
+/* Keywords related to perl modules */
+PERLKW(do);
+PERLKW(import);
+PERLKW(no);
+PERLKW(package);
+PERLKW(require);
+PERLKW(use);
+
+
+/* Keywords related to classes and object-orientedness */
+PERLKW(bless);
+PERLKW(dbmclose);
+PERLKW(dbmopen);
+PERLKW(package);
+PERLKW(ref);
+PERLKW(tie);
+PERLKW(tied);
+PERLKW(untie);
+PERLKW(use);
+
+/* Functions new in perl5 */
+PERLBN(abs);
+PERLBN(bless);
+PERLBN(chomp);
+PERLBN(chr);
+PERLBN(exists);
+PERLBN(formline);
+PERLBN(glob);
+PERLBN(import);
+PERLBN(lc);
+PERLBN(lcfirst);
+PERLBN(map);
+PERLBN(my);
+PERLBN(no);
+PERLBN(prototype);
+PERLBN(qx);
+PERLBN(qw);
+PERLBN(readline);
+PERLBN(readpipe);
+PERLBN(ref);
+PERLBN(sub);
+PERLBN(sysopen);
+PERLBN(tie);
+PERLBN(tied);
+PERLBN(uc);
+PERLBN(ucfirst);
+PERLBN(untie);
+PERLBN(use);
+
+#undef PERLKW
+#undef PERLBN
diff --git a/Lib/perl5/perlmacros.swg b/Lib/perl5/perlmacros.swg
new file mode 100644
index 000000000..7d7ba440d
--- /dev/null
+++ b/Lib/perl5/perlmacros.swg
@@ -0,0 +1,17 @@
+/*
+ in Perl we need to pass the CPerl value, sometimes,
+ so, we define decl/call macros as needed.
+*/
+
+
+#define SWIG_ASPTR_DECL_ARGS SWIG_PERL_DECL_ARGS_2
+#define SWIG_ASPTR_CALL_ARGS SWIG_PERL_CALL_ARGS_2
+
+#define SWIG_ASVAL_DECL_ARGS SWIG_PERL_DECL_ARGS_2
+#define SWIG_ASVAL_CALL_ARGS SWIG_PERL_CALL_ARGS_2
+
+#define SWIG_FROM_DECL_ARGS SWIG_PERL_DECL_ARGS_1
+#define SWIG_FROM_CALL_ARGS SWIG_PERL_CALL_ARGS_1
+
+%include <typemaps/swigmacros.swg>
+
diff --git a/Lib/perl5/perlopers.swg b/Lib/perl5/perlopers.swg
new file mode 100644
index 000000000..66da96928
--- /dev/null
+++ b/Lib/perl5/perlopers.swg
@@ -0,0 +1,52 @@
+/* ------------------------------------------------------------
+ * Overloaded operator support
+ * ------------------------------------------------------------ */
+
+#ifdef __cplusplus
+
+%rename(__add__) *::operator+;
+%rename(__pos__) *::operator+();
+%rename(__pos__) *::operator+() const;
+%rename(__sub__) *::operator-;
+%rename(__neg__) *::operator-();
+%rename(__neg__) *::operator-() const;
+%rename(__mul__) *::operator*;
+%rename(__div__) *::operator/;
+%rename(__mod__) *::operator%;
+%rename(__lshift__) *::operator<<;
+%rename(__rshift__) *::operator>>;
+%rename(__and__) *::operator&;
+%rename(__or__) *::operator|;
+%rename(__xor__) *::operator^;
+%rename(__invert__) *::operator~;
+%rename(__lt__) *::operator<;
+%rename(__le__) *::operator<=;
+%rename(__gt__) *::operator>;
+%rename(__ge__) *::operator>=;
+%rename(__eq__) *::operator==;
+
+/* Special cases */
+%rename(__call__) *::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[];
+
+#endif /* __cplusplus */
diff --git a/Lib/perl5/perlprimtypes.swg b/Lib/perl5/perlprimtypes.swg
new file mode 100644
index 000000000..6735c0107
--- /dev/null
+++ b/Lib/perl5/perlprimtypes.swg
@@ -0,0 +1,209 @@
+/* ------------------------------------------------------------
+ * Primitive Types
+ * ------------------------------------------------------------ */
+
+
+/* boolean */
+
+%fragment(SWIG_From_frag(bool),"header") {
+SWIGINTERN SV *
+SWIG_From_dec(bool)(bool value)
+{
+ SV *obj = sv_newmortal();
+ sv_setiv(obj, value ? 1 : 0);
+ return obj;
+}
+}
+
+%fragment(SWIG_AsVal_frag(bool),"header",fragment=SWIG_AsVal_frag(long)) {
+SWIGINTERN int
+SWIG_AsVal_dec(bool)(SV *obj, bool *val)
+{
+ long v;
+ if (SWIG_AsVal(long)(obj, val ? &v : 0) == SWIG_OK) {
+ if (val) *val = v ? true : false;
+ return SWIG_OK;
+ }
+ return SWIG_TypeError;
+}
+}
+
+/* long */
+
+%fragment(SWIG_From_frag(long),"header") {
+SWIGINTERNINLINE SV *
+SWIG_From_dec(long)(long value)
+{
+ SV *obj = sv_newmortal();
+ sv_setiv(obj, (IV) value);
+ return obj;
+}
+}
+
+
+%fragment(SWIG_AsVal_frag(long),"header") {
+SWIGINTERN int
+SWIG_AsVal_dec(long)(SV *obj, long* val)
+{
+ if (SvIOK(obj)) {
+ if (val) *val = SvIV(obj);
+ return SWIG_OK;
+ }
+ return SWIG_TypeError;
+}
+}
+
+/* unsigned long */
+
+%fragment(SWIG_From_frag(unsigned long),"header") {
+SWIGINTERNINLINE SV *
+SWIG_From_dec(unsigned long)(unsigned long value)
+{
+ SV *obj = sv_newmortal();
+ sv_setuv(obj, (UV) value);
+ return obj;
+}
+}
+
+
+%fragment(SWIG_AsVal_frag(unsigned long),"header") {
+SWIGINTERN int
+SWIG_AsVal_dec(unsigned long)(SV *obj, unsigned long *val)
+{
+ if (SvUOK(obj)) {
+ if (val) *val = SvUV(obj);
+ return SWIG_OK;
+ } else if (SvIOK(obj)) {
+ long v = SvIV(obj);
+ if (v > 0) {
+ if (val) *val = SvUV(obj);
+ return SWIG_OK;
+ } else {
+ return SWIG_OverflowError;
+ }
+ }
+ return SWIG_TypeError;
+}
+}
+
+/* long long */
+
+%fragment(SWIG_From_frag(long long),"header",
+ fragment=SWIG_From_frag(long),
+ fragment="<limits.h>") {
+SWIGINTERNINLINE SV *
+SWIG_From_dec(long long)(long long value)
+{
+ if (((long long) LONG_MIN <= value) && (value <= (long long) LONG_MAX)) {
+ return SWIG_From(long)(%numeric_cast(value,long));
+ } else {
+ char temp[256];
+ SV *obj = sv_newmortal();
+ snprintf(temp, sizeof(temp),"%lld", value);
+ sv_setpv(obj, temp);
+ return obj;
+ }
+}
+}
+
+%fragment(SWIG_AsVal_frag(long long),"header") {
+SWIGINTERN int
+SWIG_AsVal_dec(long long)(SV *obj, long long *val)
+{
+ if (SvIOK(obj)) {
+ if (val) *val = SvIV(obj);
+ return SWIG_OK;
+ } else {
+ const char *nptr = SvPV(obj, PL_na);
+ if (nptr) {
+ char *endptr;
+ long long v = strtoll(nptr, &endptr,0);
+ if (errno == ERANGE) {
+ errno = 0;
+ return SWIG_OverflowError;
+ } else {
+ if (*endptr == '\0') {
+ if (val) *val = v;
+ return SWIG_OK;
+ }
+ }
+ }
+ }
+ return SWIG_TypeError;
+}
+}
+
+
+/* unsigned long long */
+
+%fragment(SWIG_From_frag(unsigned long long),"header",
+ fragment=SWIG_From_frag(long long),
+ fragment="<limits.h>") {
+SWIGINTERNINLINE SV *
+SWIG_From_dec(unsigned long long)(unsigned long long value)
+{
+ if (value < (unsigned long long) LONG_MAX) {
+ return SWIG_From(long long)(%numeric_cast(value, long long));
+ } else {
+ char temp[256];
+ SV *obj = sv_newmortal();
+ snprintf(temp, sizeof(temp),"%llu", value);
+ sv_setpv(obj, temp);
+ return obj;
+ }
+}
+}
+
+%fragment(SWIG_AsVal_frag(unsigned long long),"header") {
+SWIGINTERN int
+SWIG_AsVal_dec(unsigned long long)(SV *obj, unsigned long long *val)
+{
+ if (SvUOK(obj)) {
+ if (val) *val = SvUV(obj);
+ return SWIG_OK;
+ } else {
+ const char *nptr = SvPV(obj, PL_na);
+ if (nptr) {
+ char *endptr;
+ unsigned long long v = strtoull(nptr, &endptr,0);
+ if (errno == ERANGE) {
+ errno = 0;
+ return SWIG_OverflowError;
+ } else {
+ if (*endptr == '\0') {
+ if (val) *val = v;
+ return SWIG_OK;
+ }
+ }
+ }
+ }
+ return SWIG_TypeError;
+}
+}
+
+/* double */
+
+%fragment(SWIG_From_frag(double),"header") {
+SWIGINTERNINLINE SV *
+SWIG_From_dec(double)(double value)
+{
+ SV *obj = sv_newmortal();
+ sv_setnv(obj, value);
+ return obj;
+}
+}
+
+%fragment(SWIG_AsVal_frag(double),"header") {
+SWIGINTERN int
+SWIG_AsVal_dec(double)(SV *obj, double *val)
+{
+ if (SvNIOK(obj)) {
+ if (val) *val = SvNV(obj);
+ return SWIG_OK;
+ }
+
+ return SWIG_TypeError;
+}
+}
+
+
diff --git a/Lib/perl5/perlrun.swg b/Lib/perl5/perlrun.swg
index 88253ed75..8213a6796 100644
--- a/Lib/perl5/perlrun.swg
+++ b/Lib/perl5/perlrun.swg
@@ -1,183 +1,90 @@
-/* ---------------------------------------------------------------------- -*- c -*-
- * perl5.swg
+/***********************************************************************
+ * perlrun.swg
*
- * Perl5 runtime library
- * $Header$
- * ----------------------------------------------------------------------------- */
-
-#define SWIGPERL
-#define SWIGPERL5
-#ifdef __cplusplus
-/* Needed on some windows machines---since MS plays funny games with the header files under C++ */
-#include <math.h>
-#include <stdlib.h>
-extern "C" {
+ * This file contains the runtime support for Ruby modules
+ * and includes code for managing global variables and pointer
+ * type checking.
+ *
+ ************************************************************************/
+#ifdef PERL_OBJECT
+#define SWIG_PERL_OBJECT_DECL CPerlObj *pPerl,
+#define SWIG_PERL_OBJECT_CALL pPerl,
+#else
+#define SWIG_PERL_OBJECT_DECL
+#define SWIG_PERL_OBJECT_CALL
#endif
-#include "EXTERN.h"
-#include "perl.h"
-#include "XSUB.h"
-/* Get rid of free and malloc defined by perl */
-#undef free
-#undef malloc
+/* Common SWIG API */
-#ifndef pTHX_
-#define pTHX_
-#endif
+/* for raw pointers */
+#define SWIG_ConvertPtr(obj, pp, type, flags) SWIG_Perl_ConvertPtr(SWIG_PERL_OBJECT_CALL obj, pp, type, flags)
+#define SWIG_NewPointerObj(p, type, flags) SWIG_Perl_NewPointerObj(SWIG_PERL_OBJECT_CALL p, type, flags)
-#include <string.h>
-#ifdef __cplusplus
-}
-#endif
+/* for raw packed data */
+#define SWIG_ConvertPacked(obj, p, s, type) SWIG_Perl_ConvertPacked(SWIG_PERL_OBJECT_CALL obj, p, s, type)
+#define SWIG_NewPackedObj(p, s, type) SWIG_Perl_NewPackedObj(SWIG_PERL_OBJECT_CALL p, s, type)
-/* Macro to call an XS function */
+/* for class or struct pointers */
+#define SWIG_ConvertInstance(obj, pptr, type, flags) SWIG_ConvertPtr(obj, pptr, type, flags)
+#define SWIG_NewInstanceObj(ptr, type, flags) SWIG_NewPointerObj(ptr, type, flags)
-#ifdef PERL_OBJECT
-# define SWIG_CALLXS(_name) _name(cv,pPerl)
-#else
-# ifndef MULTIPLICITY
-# define SWIG_CALLXS(_name) _name(cv)
-# else
-# define SWIG_CALLXS(_name) _name(PERL_GET_THX, cv)
-# endif
-#endif
+/* for C or C++ function pointers */
+#define SWIG_ConvertFunctionPtr(obj, pptr, type) SWIG_ConvertPtr(obj, pptr, type, 0)
+#define SWIG_NewFunctionPtrObj(ptr, type) SWIG_NewPointerObj(ptr, type, 0)
-/* Contract support */
+/* for C++ member pointers, ie, member methods */
+#define SWIG_ConvertMember(obj, ptr, sz, ty) SWIG_ConvertPacked(obj, ptr, sz, ty)
+#define SWIG_NewMemberObj(ptr, sz, type) SWIG_NewPackedObj(ptr, sz, type)
-#define SWIG_contract_assert(expr,msg) if (!(expr)) { SWIG_croak(msg); } else
-/* Note: SwigMagicFuncHack is a typedef used to get the C++ compiler to just shut up already */
+/* Runtime API */
-#ifdef PERL_OBJECT
-#define MAGIC_PPERL CPerlObj *pPerl = (CPerlObj *) this;
-typedef int (CPerlObj::*SwigMagicFunc)(SV *, MAGIC *);
+#define SWIG_GetModule(clientdata) SWIG_Perl_GetModule()
+#define SWIG_SetModule(clientdata, pointer) SWIG_Perl_SetModule(pointer)
-#ifdef __cplusplus
-extern "C" {
-#endif
-typedef int (CPerlObj::*SwigMagicFuncHack)(SV *, MAGIC *);
-#ifdef __cplusplus
-}
-#endif
-#define SWIG_MAGIC(a,b) (SV *a, MAGIC *b)
-#define SWIGCLASS_STATIC
-#else
-#define MAGIC_PPERL
-#define SWIGCLASS_STATIC static
-#ifndef MULTIPLICITY
-#define SWIG_MAGIC(a,b) (SV *a, MAGIC *b)
-typedef int (*SwigMagicFunc)(SV *, MAGIC *);
+/* Error manipulation */
-#ifdef __cplusplus
-extern "C" {
-#endif
-typedef int (*SwigMagicFuncHack)(SV *, MAGIC *);
-#ifdef __cplusplus
-}
-#endif
+#define SWIG_ErrorType(code) SWIG_Perl_ErrorType(code)
+#define SWIG_Error(code, msg) sv_setpvf(perl_get_sv("@", TRUE), "%s error %s\n", SWIG_ErrorType(code), msg)
+#define SWIG_fail goto fail
+/* Perl-specific SWIG API */
-#else
-#define SWIG_MAGIC(a,b) (struct interpreter *interp, SV *a, MAGIC *b)
-typedef int (*SwigMagicFunc)(struct interpreter *, SV *, MAGIC *);
-#ifdef __cplusplus
-extern "C" {
-#endif
-typedef int (*SwigMagicFuncHack)(struct interpreter *, SV *, MAGIC *);
-#ifdef __cplusplus
-}
-#endif
+#define SWIG_MakePtr(sv, ptr, type, flags) SWIG_Perl_MakePtr(SWIG_PERL_OBJECT_CALL sv, ptr, type, flags)
+#define SWIG_MakePackedObj(sv, p, s, type) SWIG_Perl_MakePackedObj(SWIG_PERL_OBJECT_CALL sv, p, s, type)
+#define SWIG_SetError(str) SWIG_Error(SWIG_RuntimeError, str)
-#endif
-#endif
-
-#if defined(WIN32) && defined(PERL_OBJECT) && !defined(PerlIO_exportFILE)
-#define PerlIO_exportFILE(fh,fl) (FILE*)(fh)
-#endif
-/* Modifications for newer Perl 5.005 releases */
-
-#if !defined(PERL_REVISION) || ((PERL_REVISION >= 5) && ((PERL_VERSION < 5) || ((PERL_VERSION == 5) && (PERL_SUBVERSION < 50))))
-# ifndef PL_sv_yes
-# define PL_sv_yes sv_yes
-# endif
-# ifndef PL_sv_undef
-# define PL_sv_undef sv_undef
-# endif
-# ifndef PL_na
-# define PL_na na
-# endif
-#endif
+#define SWIG_PERL_DECL_ARGS_1(arg1) (SWIG_PERL_OBJECT_DECL arg1)
+#define SWIG_PERL_CALL_ARGS_1(arg1) (SWIG_PERL_OBJECT_CALL arg1)
+#define SWIG_PERL_DECL_ARGS_2(arg1, arg2) (SWIG_PERL_OBJECT_DECL arg1, arg2)
+#define SWIG_PERL_CALL_ARGS_2(arg1, arg2) (SWIG_PERL_OBJECT_CALL arg1, arg2)
-#include <stdlib.h>
+/* -----------------------------------------------------------------------------
+ * pointers/data manipulation
+ * ----------------------------------------------------------------------------- */
#ifdef __cplusplus
extern "C" {
+#if 0
+} /* cc-mode */
#endif
-
-#define SWIG_OWNER 1
-#define SWIG_SHADOW 2
-
-/* Common SWIG API */
-
-#ifdef PERL_OBJECT
-# define SWIG_ConvertPtr(obj, pp, type, flags) \
- SWIG_Perl_ConvertPtr(pPerl, obj, pp, type, flags)
-# define SWIG_NewPointerObj(p, type, flags) \
- SWIG_Perl_NewPointerObj(pPerl, p, type, flags)
-# define SWIG_MakePackedObj(sv, p, s, type) \
- SWIG_Perl_MakePackedObj(pPerl, sv, p, s, type)
-# define SWIG_ConvertPacked(obj, p, s, type, flags) \
- SWIG_Perl_ConvertPacked(pPerl, obj, p, s, type, flags)
-
-#else
-# define SWIG_ConvertPtr(obj, pp, type, flags) \
- SWIG_Perl_ConvertPtr(obj, pp, type, flags)
-# define SWIG_NewPointerObj(p, type, flags) \
- SWIG_Perl_NewPointerObj(p, type, flags)
-# define SWIG_MakePackedObj(sv, p, s, type) \
- SWIG_Perl_MakePackedObj(sv, p, s, type )
-# define SWIG_ConvertPacked(obj, p, s, type, flags) \
- SWIG_Perl_ConvertPacked(obj, p, s, type, flags)
-#endif
-
-/* Runtime API */
-#define SWIG_GetModule(clientdata) SWIG_Perl_GetModule()
-#define SWIG_SetModule(clientdata, pointer) SWIG_Perl_SetModule(pointer)
-
-/* Perl-specific API */
-#ifdef PERL_OBJECT
-# define SWIG_MakePtr(sv, ptr, type, flags) \
- SWIG_Perl_MakePtr(pPerl, sv, ptr, type, flags)
-# define SWIG_SetError(str) \
- SWIG_Perl_SetError(pPerl, str)
-#else
-# define SWIG_MakePtr(sv, ptr, type, flags) \
- SWIG_Perl_MakePtr(sv, ptr, type, flags)
-# define SWIG_SetError(str) \
- SWIG_Perl_SetError(str)
-# define SWIG_SetErrorSV(str) \
- SWIG_Perl_SetErrorSV(str)
#endif
-#define SWIG_SetErrorf SWIG_Perl_SetErrorf
-
+#define SWIG_OWNER SWIG_POINTER_OWN
+#define SWIG_SHADOW SWIG_OWNER << 1
-#ifdef PERL_OBJECT
-# define SWIG_MAYBE_PERL_OBJECT CPerlObj *pPerl,
-#else
-# define SWIG_MAYBE_PERL_OBJECT
-#endif
+#define SWIG_MAYBE_PERL_OBJECT SWIG_PERL_OBJECT_DECL
-static swig_cast_info *
+SWIGRUNTIME swig_cast_info *
SWIG_Perl_TypeCheckRV(SWIG_MAYBE_PERL_OBJECT SV *rv, swig_type_info *ty) {
SWIG_TypeCheck_Template(sv_derived_from(rv, (char *) iter->type->name), ty);
}
/* Function for getting a pointer value */
-static int
+SWIGRUNTIME int
SWIG_Perl_ConvertPtr(SWIG_MAYBE_PERL_OBJECT SV *sv, void **ptr, swig_type_info *_t, int flags) {
swig_cast_info *tc;
void *voidptr = (void *)0;
@@ -201,7 +108,7 @@ SWIG_Perl_ConvertPtr(SWIG_MAYBE_PERL_OBJECT SV *sv, void **ptr, swig_type_info *
}
}
} else {
- return -1;
+ return SWIG_ERROR;
}
} else {
tmp = SvIV((SV*)SvRV(sv));
@@ -209,37 +116,36 @@ SWIG_Perl_ConvertPtr(SWIG_MAYBE_PERL_OBJECT SV *sv, void **ptr, swig_type_info *
voidptr = (void *)tmp;
if (!_t) {
*(ptr) = voidptr;
- return 0;
+ return SWIG_OK;
}
} else if (! SvOK(sv)) { /* Check for undef */
*(ptr) = (void *) 0;
- return 0;
+ return SWIG_OK;
} else if (SvTYPE(sv) == SVt_RV) { /* Check for NULL pointer */
- *(ptr) = (void *) 0;
- if (!SvROK(sv))
- return 0;
- else
- return -1;
+ if (!SvROK(sv)) {
+ *(ptr) = (void *) 0;
+ return SWIG_OK;
+ } else {
+ return SWIG_ERROR;
+ }
} else { /* Don't know what it is */
- *(ptr) = (void *) 0;
- return -1;
+ return SWIG_ERROR;
}
if (_t) {
/* Now see if the types match */
char *_c = HvNAME(SvSTASH(SvRV(sv)));
tc = SWIG_TypeCheck(_c,_t);
if (!tc) {
- *ptr = voidptr;
- return -1;
+ return SWIG_ERROR;
}
*ptr = SWIG_TypeCast(tc,voidptr);
- return 0;
+ return SWIG_OK;
}
*ptr = voidptr;
- return 0;
+ return SWIG_OK;
}
-static void
+SWIGRUNTIME void
SWIG_Perl_MakePtr(SWIG_MAYBE_PERL_OBJECT SV *sv, void *ptr, swig_type_info *t, int flags) {
if (ptr && (flags & SWIG_SHADOW)) {
SV *self;
@@ -268,15 +174,15 @@ SWIG_Perl_MakePtr(SWIG_MAYBE_PERL_OBJECT SV *sv, void *ptr, swig_type_info *t, i
}
}
-static SWIGINLINE SV *
+SWIGRUNTIMEINLINE SV *
SWIG_Perl_NewPointerObj(SWIG_MAYBE_PERL_OBJECT void *ptr, swig_type_info *t, int flags) {
SV *result = sv_newmortal();
SWIG_MakePtr(result, ptr, t, flags);
return result;
}
-static void
- SWIG_Perl_MakePackedObj(SWIG_MAYBE_PERL_OBJECT SV *sv, void *ptr, int sz, swig_type_info *type) {
+SWIGRUNTIME void
+SWIG_Perl_MakePackedObj(SWIG_MAYBE_PERL_OBJECT SV *sv, void *ptr, int sz, swig_type_info *type) {
char result[1024];
char *r = result;
if ((2*sz + 1 + strlen(type->name)) > 1000) return;
@@ -286,49 +192,35 @@ static void
sv_setpv(sv, result);
}
+SWIGRUNTIME SV *
+SWIG_Perl_NewPackedObj(SWIG_MAYBE_PERL_OBJECT void *ptr, int sz, swig_type_info *type) {
+ SV *result = sv_newmortal();
+ SWIG_Perl_MakePackedObj(result, ptr, sz, type);
+ return result;
+}
+
/* Convert a packed value value */
-static int
-SWIG_Perl_ConvertPacked(SWIG_MAYBE_PERL_OBJECT SV *obj, void *ptr, int sz, swig_type_info *ty, int flags) {
+SWIGRUNTIME int
+SWIG_Perl_ConvertPacked(SWIG_MAYBE_PERL_OBJECT SV *obj, void *ptr, int sz, swig_type_info *ty) {
swig_cast_info *tc;
const char *c = 0;
- if ((!obj) || (!SvOK(obj))) return -1;
+ if ((!obj) || (!SvOK(obj))) return SWIG_ERROR;
c = SvPV(obj, PL_na);
/* Pointer values must start with leading underscore */
- if (*c != '_') return -1;
+ if (*c != '_') return SWIG_ERROR;
c++;
c = SWIG_UnpackData(c,ptr,sz);
if (ty) {
tc = SWIG_TypeCheck(c,ty);
- if (!tc) return -1;
+ if (!tc) return SWIG_ERROR;
}
- return 0;
+ return SWIG_OK;
}
-static SWIGINLINE void
-SWIG_Perl_SetError(SWIG_MAYBE_PERL_OBJECT const char *error) {
- if (error) sv_setpv(perl_get_sv("@", TRUE), error);
-}
-
-static SWIGINLINE void
-SWIG_Perl_SetErrorSV(SWIG_MAYBE_PERL_OBJECT SV *error) {
- if (error) sv_setsv(perl_get_sv("@", TRUE), error);
-}
-
-static void
-SWIG_Perl_SetErrorf(const char *fmt, ...) {
- va_list args;
- va_start(args, fmt);
- sv_vsetpvfn(perl_get_sv("@", TRUE), fmt, strlen(fmt), &args, Null(SV**), 0, Null(bool*));
- va_end(args);
-}
/* Macros for low-level exception handling */
-#define SWIG_fail goto fail
-#define SWIG_croak(x) { SWIG_SetError(x); goto fail; }
-#define SWIG_croakSV(x) { SWIG_SetErrorSV(x); goto fail; }
-/* most preprocessors do not support vararg macros :-( */
-/* #define SWIG_croakf(x...) { SWIG_SetErrorf(x); goto fail; } */
+#define SWIG_croak(x) { SWIG_Error(SWIG_RuntimeError, x); SWIG_fail; }
typedef XS(SwigPerlWrapper);
@@ -358,9 +250,6 @@ typedef struct swig_constant_info {
swig_type_info **ptype;
} swig_constant_info;
-#ifdef __cplusplus
-}
-#endif
/* Structure for variable table */
typedef struct {
@@ -374,14 +263,15 @@ typedef struct {
#ifndef PERL_OBJECT
#define swig_create_magic(s,a,b,c) _swig_create_magic(s,a,b,c)
#ifndef MULTIPLICITY
- static void _swig_create_magic(SV *sv, char *name, int (*set)(SV *, MAGIC *), int (*get)(SV *,MAGIC *)) {
+ SWIGRUNTIME void _swig_create_magic(SV *sv, char *name, int (*set)(SV *, MAGIC *), int (*get)(SV *,MAGIC *))
#else
- static void _swig_create_magic(SV *sv, char *name, int (*set)(struct interpreter*, SV *, MAGIC *), int (*get)(struct interpreter*, SV *,MAGIC *)) {
+ SWIGRUNTIME void _swig_create_magic(SV *sv, char *name, int (*set)(struct interpreter*, SV *, MAGIC *), int (*get)(struct interpreter*, SV *,MAGIC *))
#endif
#else
# define swig_create_magic(s,a,b,c) _swig_create_magic(pPerl,s,a,b,c)
-static void _swig_create_magic(CPerlObj *pPerl, SV *sv, const char *name, int (CPerlObj::*set)(SV *, MAGIC *), int (CPerlObj::*get)(SV *, MAGIC *)) {
+SWIGRUNTIME void _swig_create_magic(CPerlObj *pPerl, SV *sv, const char *name, int (CPerlObj::*set)(SV *, MAGIC *), int (CPerlObj::*get)(SV *, MAGIC *))
#endif
+{
MAGIC *mg;
sv_magic(sv,sv,'U',(char *) name,strlen(name));
mg = mg_find(sv,'U');
@@ -394,7 +284,7 @@ static void _swig_create_magic(CPerlObj *pPerl, SV *sv, const char *name, int (C
}
-static swig_module_info *
+SWIGRUNTIME swig_module_info *
SWIG_Perl_GetModule() {
static void *type_pointer = (void *)0;
SV *pointer;
@@ -410,7 +300,7 @@ SWIG_Perl_GetModule() {
return (swig_module_info *) type_pointer;
}
-static void
+SWIGRUNTIME void
SWIG_Perl_SetModule(swig_module_info *module) {
SV *pointer;
@@ -418,3 +308,10 @@ SWIG_Perl_SetModule(swig_module_info *module) {
pointer = get_sv("swig_runtime_data::type_pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME, TRUE);
sv_setiv(pointer, PTR2IV(module));
}
+
+#ifdef __cplusplus
+#if 0
+{ /* cc-mode */
+#endif
+}
+#endif
diff --git a/Lib/perl5/perlruntime.swg b/Lib/perl5/perlruntime.swg
new file mode 100644
index 000000000..9291d49c2
--- /dev/null
+++ b/Lib/perl5/perlruntime.swg
@@ -0,0 +1,101 @@
+%insert(runtime) %{
+
+#include <EXTERN.h>
+#include <perl.h>
+#include <XSUB.h>
+
+/* Get rid of free and malloc defined by perl */
+#undef free
+#undef malloc
+
+#ifndef pTHX_
+#define pTHX_
+#endif
+
+#include <string.h>
+
+/* Macro to call an XS function */
+
+#ifdef PERL_OBJECT
+# define SWIG_CALLXS(_name) _name(cv,pPerl)
+#else
+# ifndef MULTIPLICITY
+# define SWIG_CALLXS(_name) _name(cv)
+# else
+# define SWIG_CALLXS(_name) _name(PERL_GET_THX, cv)
+# endif
+#endif
+
+/* Note: SwigMagicFuncHack is a typedef used to get the C++ compiler to just shut up already */
+
+#ifdef PERL_OBJECT
+#define MAGIC_PPERL CPerlObj *pPerl = (CPerlObj *) this;
+typedef int (CPerlObj::*SwigMagicFunc)(SV *, MAGIC *);
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+typedef int (CPerlObj::*SwigMagicFuncHack)(SV *, MAGIC *);
+#ifdef __cplusplus
+}
+#endif
+
+#define SWIG_MAGIC(a,b) (SV *a, MAGIC *b)
+#define SWIGCLASS_STATIC
+#else
+#define MAGIC_PPERL
+#define SWIGCLASS_STATIC static
+#ifndef MULTIPLICITY
+#define SWIG_MAGIC(a,b) (SV *a, MAGIC *b)
+typedef int (*SwigMagicFunc)(SV *, MAGIC *);
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+typedef int (*SwigMagicFuncHack)(SV *, MAGIC *);
+#ifdef __cplusplus
+}
+#endif
+
+
+#else
+#define SWIG_MAGIC(a,b) (struct interpreter *interp, SV *a, MAGIC *b)
+typedef int (*SwigMagicFunc)(struct interpreter *, SV *, MAGIC *);
+#ifdef __cplusplus
+extern "C" {
+#endif
+typedef int (*SwigMagicFuncHack)(struct interpreter *, SV *, MAGIC *);
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+#endif
+
+#if defined(WIN32) && defined(PERL_OBJECT) && !defined(PerlIO_exportFILE)
+#define PerlIO_exportFILE(fh,fl) (FILE*)(fh)
+#endif
+
+/* Modifications for newer Perl 5.005 releases */
+
+#if !defined(PERL_REVISION) || ((PERL_REVISION >= 5) && ((PERL_VERSION < 5) || ((PERL_VERSION == 5) && (PERL_SUBVERSION < 50))))
+# ifndef PL_sv_yes
+# define PL_sv_yes sv_yes
+# endif
+# ifndef PL_sv_undef
+# define PL_sv_undef sv_undef
+# endif
+# ifndef PL_na
+# define PL_na na
+# endif
+#endif
+
+#include <stdlib.h>
+
+%}
+
+
+%runtime "swigrun.swg" // Common C API type-checking code
+%runtime "perlrun.swg" // Perl runtime functions
+%runtime "noembed.h" // undefine Perl5 macros
+
diff --git a/Lib/perl5/perlstrings.swg b/Lib/perl5/perlstrings.swg
new file mode 100644
index 000000000..c1b29b5f4
--- /dev/null
+++ b/Lib/perl5/perlstrings.swg
@@ -0,0 +1,48 @@
+/* ------------------------------------------------------------
+ * utility methods for char strings
+ * ------------------------------------------------------------ */
+
+%fragment("SWIG_AsCharPtrAndSize","header") {
+SWIGINTERN int
+SWIG_AsCharPtrAndSize(SV *obj, char** cptr, size_t* psize, int *alloc)
+{
+ static swig_type_info* pchar_info = 0;
+ char* vptr = 0;
+ if (!pchar_info) pchar_info = SWIG_TypeQuery("char *");
+ if (SWIG_ConvertPtr(obj, (void**)&vptr, pchar_info, 0) == SWIG_OK) {
+ if (cptr) *cptr = vptr;
+ if (psize) *psize = vptr ? (strlen(vptr) + 1) : 0;
+ if (alloc) *alloc = SWIG_OLDOBJ;
+ return SWIG_OK;
+ } else {
+ if (SvPOK(obj)) {
+ STRLEN len = 0;
+ char *cstr = SvPV(obj, len);
+ size_t size = len + 1;
+ if (cptr) {
+ if (alloc) {
+ if (*alloc == SWIG_NEWOBJ) {
+ *cptr = %new_copy_array(cstr, size, char);
+ } else {
+ *cptr = cstr;
+ *alloc = SWIG_OLDOBJ;
+ }
+ }
+ }
+ if (psize) *psize = size;
+ return SWIG_OK;
+ }
+ }
+ return SWIG_TypeError;
+}
+}
+
+%fragment("SWIG_FromCharPtrAndSize","header") {
+SWIGINTERNINLINE SV *
+SWIG_FromCharPtrAndSize(const char* carray, size_t size)
+{
+ SV *obj = sv_newmortal();
+ sv_setpv(obj, carray);
+ return obj;
+}
+}
diff --git a/Lib/perl5/perltypemaps.swg b/Lib/perl5/perltypemaps.swg
new file mode 100644
index 000000000..fb993a9ed
--- /dev/null
+++ b/Lib/perl5/perltypemaps.swg
@@ -0,0 +1,44 @@
+/* -----------------------------------------------------------------------------
+ * Typemap specializations
+ * ----------------------------------------------------------------------------- */
+
+/* no director supported in Perl */
+#ifdef SWIG_DIRECTOR_TYPEMAPS
+#undef SWIG_DIRECTOR_TYPEMAPS
+#endif
+
+
+/* -----------------------------------------------------------------------------
+ * Basic definitions
+ *
+ * ----------------------------------------------------------------------------- */
+
+#define %newpointer_flags $shadow
+#define %newinstance_flags $shadow
+
+#define SWIG_Object SV *
+#define VOID_Object $result; argvi=0
+
+#define %set_output(obj) $result = obj; argvi++
+#define %append_output(obj) if (argvi >= items) EXTEND(sp,1); %set_output(obj)
+#define %set_varoutput(obj) sv_setsv($result,obj);
+#define %raise(obj, type, desc) sv_setsv(perl_get_sv("@", TRUE), obj); croak(Nullch)
+%define %set_constant(name, obj) {
+ SV *sv = get_sv((char*) SWIG_prefix name, TRUE | 0x2);
+ sv_setsv(sv, obj);
+ SvREADONLY_on(sv);
+}
+%enddef
+
+
+/* -----------------------------------------------------------------------------
+ * All the typemaps
+ * ----------------------------------------------------------------------------- */
+
+
+%include <perlprimtypes.swg>
+%include <perlstrings.swg>
+
+%include <typemaps/swigtypemaps.swg>
+
+
diff --git a/Lib/perl5/perluserdir.swg b/Lib/perl5/perluserdir.swg
new file mode 100644
index 000000000..718440e83
--- /dev/null
+++ b/Lib/perl5/perluserdir.swg
@@ -0,0 +1,2 @@
+#define %perlcode %insert("perl")
+
diff --git a/Lib/perl5/std_string.i b/Lib/perl5/std_string.i
index c32fc1065..6f34f1847 100644
--- a/Lib/perl5/std_string.i
+++ b/Lib/perl5/std_string.i
@@ -1,75 +1,2 @@
-//
-// SWIG typemaps for std::string
-// Roy M. LeCates
-// October 23, 2002
-//
-// Perl implementation
-
-
-// ------------------------------------------------------------------------
-// std::string is typemapped by value
-// This can prevent exporting methods which return a string
-// in order for the user to modify it.
-// However, I think I'll wait until someone asks for it...
-// ------------------------------------------------------------------------
-
-%include exception.i
-
-%{
-#include <string>
-%}
-
-namespace std {
-
- class string;
-
- /* Overloading check */
- %typemap(typecheck) string = char *;
- %typemap(typecheck) const string & = char *;
-
- %typemap(in) string {
- STRLEN len;
- const char *ptr = SvPV($input, len);
- if (!ptr) {
- SWIG_croak("Undefined variable in argument $argnum of $symname.");
- } else {
- $1 = std::string(ptr, len);
- }
- }
-
- %typemap(in) string *INPUT(std::string temp),
- const string & (std::string temp) {
- STRLEN len;
- const char *ptr = SvPV($input, len);
- if (!ptr) {
- SWIG_croak("Undefined variable in argument $argnum of $symname.");
- } else {
- temp.assign(ptr, len);
- $1 = &temp;
- }
- }
-
- %typemap(out) string {
- if (argvi >= items) EXTEND(sp, 1); // bump stack ptr, if needed
- char *data = const_cast<char*>($1.data());
- sv_setpvn($result = sv_newmortal(), data, $1.size());
- ++argvi;
- }
-
- %typemap(out) const string & {
- if (argvi >= items) EXTEND(sp, 1); // bump stack ptr, if needed
- char *data = const_cast<char*>($1->data());
- sv_setpvn($result = sv_newmortal(), data, $1->size());
- ++argvi;
- }
-
- %typemap(throws) const string & {
- SWIG_croak($1.c_str());
- }
-
- %typemap(throws) string {
- SWIG_croak($1.c_str());
- }
-
-}
-
+%include <perlstrings.swg>
+%include <typemaps/std_string.swg>
diff --git a/Lib/perl5/typemaps.i b/Lib/perl5/typemaps.i
index 52f4ceb12..1f9b9c432 100644
--- a/Lib/perl5/typemaps.i
+++ b/Lib/perl5/typemaps.i
@@ -1,597 +1 @@
-//
-// SWIG Typemap library
-// Dave Beazley
-// May 5, 1997
-//
-// Perl5 implementation
-//
-// This library provides standard typemaps for modifying SWIG's behavior.
-// With enough entries in this file, I hope that very few people actually
-// ever need to write a typemap.
-//
-
-/*
-The SWIG typemap library provides a language independent mechanism for
-supporting output arguments, input values, and other C function
-calling mechanisms. The primary use of the library is to provide a
-better interface to certain C function--especially those involving
-pointers.
-*/
-
-// INPUT typemaps.
-// These remap a C pointer to be an "INPUT" value which is passed by value
-// instead of reference.
-
-
-/*
-The following methods can be applied to turn a pointer into a simple
-"input" value. That is, instead of passing a pointer to an object,
-you would use a real value instead.
-
- int *INPUT
- short *INPUT
- long *INPUT
- long long *INPUT
- unsigned int *INPUT
- unsigned short *INPUT
- unsigned long *INPUT
- unsigned long long *INPUT
- unsigned char *INPUT
- bool *INPUT
- float *INPUT
- double *INPUT
-
-To use these, suppose you had a C function like this :
-
- double fadd(double *a, double *b) {
- return *a+*b;
- }
-
-You could wrap it with SWIG as follows :
-
- %include typemaps.i
- double fadd(double *INPUT, double *INPUT);
-
-or you can use the %apply directive :
-
- %include typemaps.i
- %apply double *INPUT { double *a, double *b };
- double fadd(double *a, double *b);
-
-*/
-
-%define INPUT_TYPEMAP(type, converter)
-%typemap(in) type *INPUT(type temp), type &INPUT(type temp) {
- temp = (type) converter($input);
- $1 = &temp;
-}
-%typemap(typecheck) type *INPUT = type;
-%typemap(typecheck) type &INPUT = type;
-%enddef
-
-INPUT_TYPEMAP(float, SvNV);
-INPUT_TYPEMAP(double, SvNV);
-INPUT_TYPEMAP(int, SvIV);
-INPUT_TYPEMAP(long, SvIV);
-INPUT_TYPEMAP(short, SvIV);
-INPUT_TYPEMAP(signed char, SvIV);
-INPUT_TYPEMAP(unsigned int, SvUV);
-INPUT_TYPEMAP(unsigned long, SvUV);
-INPUT_TYPEMAP(unsigned short, SvUV);
-INPUT_TYPEMAP(unsigned char, SvUV);
-
-%typemap(in) bool *INPUT(bool temp), bool &INPUT(bool temp) {
- temp = SvIV($input) ? true : false;
- $1 = &temp;
-}
-%typemap(typecheck) bool *INPUT = bool;
-%typemap(typecheck) bool &INPUT = bool;
-
-%typemap(in) long long *INPUT($*1_ltype temp), long long &INPUT($*1_ltype temp) {
- temp = strtoll(SvPV($input,PL_na), 0, 0);
- $1 = &temp;
-}
-%typemap(typecheck) long long *INPUT = long long;
-%typemap(typecheck) long long &INPUT = long long;
-
-%typemap(in) unsigned long long *INPUT($*1_ltype temp), unsigned long long &INPUT($*1_ltype temp) {
- temp = strtoull(SvPV($input,PL_na), 0, 0);
- $1 = &temp;
-}
-%typemap(typecheck) unsigned long long *INPUT = unsigned long long;
-%typemap(typecheck) unsigned long long &INPUT = unsigned long long;
-
-
-#undef INPUT_TYPEMAP
-
-// OUTPUT typemaps. These typemaps are used for parameters that
-// are output only. The output value is appended to the result as
-// a list element.
-
-/*
-The following methods can be applied to turn a pointer into an "output"
-value. When calling a function, no input value would be given for
-a parameter, but an output value would be returned. In the case of
-multiple output values, functions will return a Perl array.
-
- int *OUTPUT
- short *OUTPUT
- long *OUTPUT
- long long *OUTPUT
- unsigned int *OUTPUT
- unsigned short *OUTPUT
- unsigned long *OUTPUT
- unsigned long long *OUTPUT
- unsigned char *OUTPUT
- bool *OUTPUT
- float *OUTPUT
- double *OUTPUT
-
-For example, suppose you were trying to wrap the modf() function in the
-C math library which splits x into integral and fractional parts (and
-returns the integer part in one of its parameters).:
-
- double modf(double x, double *ip);
-
-You could wrap it with SWIG as follows :
-
- %include typemaps.i
- double modf(double x, double *OUTPUT);
-
-or you can use the %apply directive :
-
- %include typemaps.i
- %apply double *OUTPUT { double *ip };
- double modf(double x, double *ip);
-
-The Perl output of the function would be an array containing both
-output values.
-
-*/
-
-// Force the argument to be ignored.
-
-%typemap(in,numinputs=0) int *OUTPUT(int temp), int &OUTPUT(int temp),
- short *OUTPUT(short temp), short &OUTPUT(short temp),
- long *OUTPUT(long temp), long &OUTPUT(long temp),
- unsigned int *OUTPUT(unsigned int temp), unsigned int &OUTPUT(unsigned int temp),
- unsigned short *OUTPUT(unsigned short temp), unsigned short &OUTPUT(unsigned short temp),
- unsigned long *OUTPUT(unsigned long temp), unsigned long &OUTPUT(unsigned long temp),
- unsigned char *OUTPUT(unsigned char temp), unsigned char &OUTPUT(unsigned char temp),
- signed char *OUTPUT(signed char temp), signed char &OUTPUT(signed char temp),
- bool *OUTPUT(bool temp), bool &OUTPUT(bool temp),
- float *OUTPUT(float temp), float &OUTPUT(float temp),
- double *OUTPUT(double temp), double &OUTPUT(double temp),
- long long *OUTPUT($*1_ltype temp), long long &OUTPUT($*1_ltype temp),
- unsigned long long *OUTPUT($*1_ltype temp), unsigned long long &OUTPUT($*1_ltype temp)
-"$1 = &temp;";
-
-%typemap(argout) int *OUTPUT, int &OUTPUT,
- short *OUTPUT, short &OUTPUT,
- long *OUTPUT, long &OUTPUT,
- signed char *OUTPUT, signed char &OUTPUT,
- bool *OUTPUT, bool &OUTPUT
-{
- if (argvi >= items) {
- EXTEND(sp,1);
- }
- $result = sv_newmortal();
- sv_setiv($result,(IV) *($1));
- argvi++;
-}
-
-%typemap(argout) unsigned int *OUTPUT, unsigned int &OUTPUT,
- unsigned short *OUTPUT, unsigned short &OUTPUT,
- unsigned long *OUTPUT, unsigned long &OUTPUT,
- unsigned char *OUTPUT, unsigned char &OUTPUT
-{
- if (argvi >= items) {
- EXTEND(sp,1);
- }
- $result = sv_newmortal();
- sv_setuv($result,(UV) *($1));
- argvi++;
-}
-
-
-
-%typemap(argout) float *OUTPUT, float &OUTPUT,
- double *OUTPUT, double &OUTPUT
-{
- if (argvi >= items) {
- EXTEND(sp,1);
- }
- $result = sv_newmortal();
- sv_setnv($result,(double) *($1));
- argvi++;
-}
-
-%typemap(argout) long long *OUTPUT, long long &OUTPUT {
- char temp[256];
- if (argvi >= items) {
- EXTEND(sp,1);
- }
- sprintf(temp,"%lld", (long long)*($1));
- $result = sv_newmortal();
- sv_setpv($result,temp);
- argvi++;
-}
-
-%typemap(argout) unsigned long long *OUTPUT, unsigned long long &OUTPUT {
- char temp[256];
- if (argvi >= items) {
- EXTEND(sp,1);
- }
- sprintf(temp,"%llu", (unsigned long long)*($1));
- $result = sv_newmortal();
- sv_setpv($result,temp);
- argvi++;
-}
-
-// INOUT
-// Mappings for an argument that is both an input and output
-// parameter
-
-/*
-The following methods can be applied to make a function parameter both
-an input and output value. This combines the behavior of both the
-"INPUT" and "OUTPUT" methods described earlier. Output values are
-returned in the form of a Perl array.
-
- int *INOUT
- short *INOUT
- long *INOUT
- long long *INOUT
- unsigned int *INOUT
- unsigned short *INOUT
- unsigned long *INOUT
- unsigned long long *INOUT
- unsigned char *INOUT
- bool *INOUT
- float *INOUT
- double *INOUT
-
-For example, suppose you were trying to wrap the following function :
-
- void neg(double *x) {
- *x = -(*x);
- }
-
-You could wrap it with SWIG as follows :
-
- %include typemaps.i
- void neg(double *INOUT);
-
-or you can use the %apply directive :
-
- %include typemaps.i
- %apply double *INOUT { double *x };
- void neg(double *x);
-
-Unlike C, this mapping does not directly modify the input value.
-Rather, the modified input value shows up as the return value of the
-function. Thus, to apply this function to a Perl variable you might
-do this :
-
- $x = neg($x);
-
-*/
-
-%typemap(in) int *INOUT = int *INPUT;
-%typemap(in) short *INOUT = short *INPUT;
-%typemap(in) long *INOUT = long *INPUT;
-%typemap(in) unsigned *INOUT = unsigned *INPUT;
-%typemap(in) unsigned short *INOUT = unsigned short *INPUT;
-%typemap(in) unsigned long *INOUT = unsigned long *INPUT;
-%typemap(in) unsigned char *INOUT = unsigned char *INPUT;
-%typemap(in) signed char *INOUT = signed char *INPUT;
-%typemap(in) bool *INOUT = bool *INPUT;
-%typemap(in) float *INOUT = float *INPUT;
-%typemap(in) double *INOUT = double *INPUT;
-%typemap(in) long long *INOUT = long long *INPUT;
-%typemap(in) unsigned long long *INOUT = unsigned long long *INPUT;
-
-%typemap(in) int &INOUT = int &INPUT;
-%typemap(in) short &INOUT = short &INPUT;
-%typemap(in) long &INOUT = long &INPUT;
-%typemap(in) unsigned &INOUT = unsigned &INPUT;
-%typemap(in) unsigned short &INOUT = unsigned short &INPUT;
-%typemap(in) unsigned long &INOUT = unsigned long &INPUT;
-%typemap(in) unsigned char &INOUT = unsigned char &INPUT;
-%typemap(in) signed char &INOUT = signed char &INPUT;
-%typemap(in) bool &INOUT = bool &INPUT;
-%typemap(in) float &INOUT = float &INPUT;
-%typemap(in) double &INOUT = double &INPUT;
-%typemap(in) long long &INOUT = long long &INPUT;
-%typemap(in) unsigned long long &INOUT = unsigned long long &INPUT;
-
-
-%typemap(argout) int *INOUT = int *OUTPUT;
-%typemap(argout) short *INOUT = short *OUTPUT;
-%typemap(argout) long *INOUT = long *OUTPUT;
-%typemap(argout) unsigned *INOUT = unsigned *OUTPUT;
-%typemap(argout) unsigned short *INOUT = unsigned short *OUTPUT;
-%typemap(argout) unsigned long *INOUT = unsigned long *OUTPUT;
-%typemap(argout) unsigned char *INOUT = unsigned char *OUTPUT;
-%typemap(argout) signed char *INOUT = signed char *OUTPUT;
-%typemap(argout) bool *INOUT = bool *OUTPUT;
-%typemap(argout) float *INOUT = float *OUTPUT;
-%typemap(argout) double *INOUT = double *OUTPUT;
-%typemap(argout) long long *INOUT = long long *OUTPUT;
-%typemap(argout) unsigned long long *INOUT = unsigned long long *OUTPUT;
-
-
-%typemap(argout) int &INOUT = int &OUTPUT;
-%typemap(argout) short &INOUT = short &OUTPUT;
-%typemap(argout) long &INOUT = long &OUTPUT;
-%typemap(argout) unsigned &INOUT = unsigned &OUTPUT;
-%typemap(argout) unsigned short &INOUT = unsigned short &OUTPUT;
-%typemap(argout) unsigned long &INOUT = unsigned long &OUTPUT;
-%typemap(argout) unsigned char &INOUT = unsigned char &OUTPUT;
-%typemap(argout) signed char &INOUT = signed char &OUTPUT;
-%typemap(argout) bool &INOUT = bool &OUTPUT;
-%typemap(argout) float &INOUT = float &OUTPUT;
-%typemap(argout) double &INOUT = double &OUTPUT;
-%typemap(argout) long long &INOUT = long long &OUTPUT;
-%typemap(argout) unsigned long long &INOUT = unsigned long long &OUTPUT;
-
-// REFERENCE
-// Accept Perl references as pointers
-
-/*
-The following methods make Perl references work like simple C
-pointers. References can only be used for simple input/output
-values, not C arrays however. It should also be noted that
-REFERENCES are specific to Perl and not supported in other
-scripting languages at this time.
-
- int *REFERENCE
- short *REFERENCE
- long *REFERENCE
- unsigned int *REFERENCE
- unsigned short *REFERENCE
- unsigned long *REFERENCE
- unsigned char *REFERENCE
- float *REFERENCE
- double *REFERENCE
-
-For example, suppose you were trying to wrap the following function :
-
- void neg(double *x) {
- *x = -(*x);
- }
-
-You could wrap it with SWIG as follows :
-
- %include typemaps.i
- void neg(double *REFERENCE);
-
-or you can use the %apply directive :
-
- %include typemaps.i
- %apply double *REFERENCE { double *x };
- void neg(double *x);
-
-Unlike the INOUT mapping described previous, this approach directly
-modifies the value of a Perl reference. Thus, you could use it
-as follows :
-
- $x = 3;
- neg(\$x);
- print "$x\n"; # Should print out -3.
-
-*/
-
-%typemap(in) double *REFERENCE (double dvalue), double &REFERENCE(double dvalue)
-{
- SV *tempsv;
- if (!SvROK($input)) {
- SWIG_croak("expected a reference");
- }
- tempsv = SvRV($input);
- if ((!SvNOK(tempsv)) && (!SvIOK(tempsv))) {
- printf("Received %d\n", SvTYPE(tempsv));
- SWIG_croak("Expected a double reference.");
- }
- dvalue = SvNV(tempsv);
- $1 = &dvalue;
-}
-
-%typemap(in) float *REFERENCE (float dvalue), float &REFERENCE(float dvalue)
-{
- SV *tempsv;
- if (!SvROK($input)) {
- SWIG_croak("expected a reference");
- }
- tempsv = SvRV($input);
- if ((!SvNOK(tempsv)) && (!SvIOK(tempsv))) {
- SWIG_croak("expected a double reference");
- }
- dvalue = (float) SvNV(tempsv);
- $1 = &dvalue;
-}
-
-%typemap(in) int *REFERENCE (int dvalue), int &REFERENCE (int dvalue)
-{
- SV *tempsv;
- if (!SvROK($input)) {
- SWIG_croak("expected a reference");
- }
- tempsv = SvRV($input);
- if (!SvIOK(tempsv)) {
- SWIG_croak("expected a integer reference");
- }
- dvalue = SvIV(tempsv);
- $1 = &dvalue;
-}
-
-%typemap(in) short *REFERENCE (short dvalue), short &REFERENCE(short dvalue)
-{
- SV *tempsv;
- if (!SvROK($input)) {
- SWIG_croak("expected a reference");
- }
- tempsv = SvRV($input);
- if (!SvIOK(tempsv)) {
- SWIG_croak("expected a integer reference");
- }
- dvalue = (short) SvIV(tempsv);
- $1 = &dvalue;
-}
-%typemap(in) long *REFERENCE (long dvalue), long &REFERENCE(long dvalue)
-{
- SV *tempsv;
- if (!SvROK($input)) {
- SWIG_croak("expected a reference");
- }
- tempsv = SvRV($input);
- if (!SvIOK(tempsv)) {
- SWIG_croak("expected a integer reference");
- }
- dvalue = (long) SvIV(tempsv);
- $1 = &dvalue;
-}
-%typemap(in) unsigned int *REFERENCE (unsigned int dvalue), unsigned int &REFERENCE(unsigned int dvalue)
-{
- SV *tempsv;
- if (!SvROK($input)) {
- SWIG_croak("expected a reference");
- }
- tempsv = SvRV($input);
- if (!SvIOK(tempsv)) {
- SWIG_croak("expected a integer reference");
- }
- dvalue = (unsigned int) SvUV(tempsv);
- $1 = &dvalue;
-}
-%typemap(in) unsigned short *REFERENCE (unsigned short dvalue), unsigned short &REFERENCE(unsigned short dvalue)
-{
- SV *tempsv;
- if (!SvROK($input)) {
- SWIG_croak("expected a reference");
- }
- tempsv = SvRV($input);
- if (!SvIOK(tempsv)) {
- SWIG_croak("expected a integer reference");
- }
- dvalue = (unsigned short) SvUV(tempsv);
- $1 = &dvalue;
-}
-%typemap(in) unsigned long *REFERENCE (unsigned long dvalue), unsigned long &REFERENCE(unsigned long dvalue)
-{
- SV *tempsv;
- if (!SvROK($input)) {
- SWIG_croak("expected a reference");
- }
- tempsv = SvRV($input);
- if (!SvIOK(tempsv)) {
- SWIG_croak("expected a integer reference");
- }
- dvalue = (unsigned long) SvUV(tempsv);
- $1 = &dvalue;
-}
-
-%typemap(in) unsigned char *REFERENCE (unsigned char dvalue), unsigned char &REFERENCE(unsigned char dvalue)
-{
- SV *tempsv;
- if (!SvROK($input)) {
- SWIG_croak("expected a reference");
- }
- tempsv = SvRV($input);
- if (!SvIOK(tempsv)) {
- SWIG_croak("expected a integer reference");
- }
- dvalue = (unsigned char) SvUV(tempsv);
- $1 = &dvalue;
-}
-
-%typemap(in) signed char *REFERENCE (signed char dvalue), signed char &REFERENCE(signed char dvalue)
-{
- SV *tempsv;
- if (!SvROK($input)) {
- SWIG_croak("expected a reference");
- }
- tempsv = SvRV($input);
- if (!SvIOK(tempsv)) {
- SWIG_croak("expected a integer reference");
- }
- dvalue = (signed char) SvIV(tempsv);
- $1 = &dvalue;
-}
-
-%typemap(in) bool *REFERENCE (bool dvalue), bool &REFERENCE(bool dvalue)
-{
- SV *tempsv;
- if (!SvROK($input)) {
- SWIG_croak("expected a reference");
- }
- tempsv = SvRV($input);
- if (!SvIOK(tempsv)) {
- SWIG_croak("expected a integer reference");
- }
- dvalue = (bool) SvIV(tempsv);
- $1 = &dvalue;
-}
-
-%typemap(argout) double *REFERENCE, double &REFERENCE,
- float *REFERENCE, float &REFERENCE
-{
- SV *tempsv;
- tempsv = SvRV($arg);
- if (!$1) SWIG_croak("expected a reference");
- sv_setnv(tempsv, (double) *$1);
-}
-
-%typemap(argout) int *REFERENCE, int &REFERENCE,
- short *REFERENCE, short &REFERENCE,
- long *REFERENCE, long &REFERENCE,
- signed char *REFERENCE, unsigned char &REFERENCE,
- bool *REFERENCE, bool &REFERENCE
-{
- SV *tempsv;
- tempsv = SvRV($input);
- if (!$1) SWIG_croak("expected a reference");
- sv_setiv(tempsv, (IV) *$1);
-}
-
-%typemap(argout) unsigned int *REFERENCE, unsigned int &REFERENCE,
- unsigned short *REFERENCE, unsigned short &REFERENCE,
- unsigned long *REFERENCE, unsigned long &REFERENCE,
- unsigned char *REFERENCE, unsigned char &REFERENCE
-{
- SV *tempsv;
- tempsv = SvRV($input);
- if (!$1) SWIG_croak("expected a reference");
- sv_setuv(tempsv, (UV) *$1);
-}
-
-/* Overloading information */
-
-%typemap(typecheck) double *INOUT = double;
-%typemap(typecheck) bool *INOUT = bool;
-%typemap(typecheck) signed char *INOUT = signed char;
-%typemap(typecheck) unsigned char *INOUT = unsigned char;
-%typemap(typecheck) unsigned long *INOUT = unsigned long;
-%typemap(typecheck) unsigned short *INOUT = unsigned short;
-%typemap(typecheck) unsigned int *INOUT = unsigned int;
-%typemap(typecheck) long *INOUT = long;
-%typemap(typecheck) short *INOUT = short;
-%typemap(typecheck) int *INOUT = int;
-%typemap(typecheck) float *INOUT = float;
-%typemap(typecheck) long long *INOUT = long long;
-%typemap(typecheck) unsigned long long *INOUT = unsigned long long;
-
-%typemap(typecheck) double &INOUT = double;
-%typemap(typecheck) bool &INOUT = bool;
-%typemap(typecheck) signed char &INOUT = signed char;
-%typemap(typecheck) unsigned char &INOUT = unsigned char;
-%typemap(typecheck) unsigned long &INOUT = unsigned long;
-%typemap(typecheck) unsigned short &INOUT = unsigned short;
-%typemap(typecheck) unsigned int &INOUT = unsigned int;
-%typemap(typecheck) long &INOUT = long;
-%typemap(typecheck) short &INOUT = short;
-%typemap(typecheck) int &INOUT = int;
-%typemap(typecheck) float &INOUT = float;
-%typemap(typecheck) long long &INOUT = long long;
-%typemap(typecheck) unsigned long long &INOUT = unsigned long long;
-
+%include <typemaps/typemaps.swg>
diff --git a/Lib/python/argcargv.i b/Lib/python/argcargv.i
index 8e068d00f..1795f342c 100644
--- a/Lib/python/argcargv.i
+++ b/Lib/python/argcargv.i
@@ -16,14 +16,14 @@ SWIG_AsArgcArgv(PyObject* input,
list = PyList_Check(input);
if (list || PyTuple_Check(input)) {
*argc = list ? PyList_Size(input) : PyTuple_Size(input);
- argv = SWIG_new_array(*argc + 1, char*);
+ argv = %new_array(*argc + 1, char*);
*owner = 1;
for (; i < *argc; ++i) {
PyObject *obj = list ? PyList_GetItem(input,i) : PyTuple_GetItem(input,i);
char *cptr = 0; size_t size = 0; int alloc = 0;
if (SWIG_AsCharPtrAndSize(obj, &cptr, &size, &alloc) == SWIG_OK) {
if (cptr && size) {
- argv[i] = (alloc == SWIG_NEWOBJ) ? cptr : SWIG_new_copy_array(cptr, size, char);
+ argv[i] = (alloc == SWIG_NEWOBJ) ? cptr : %new_copy_array(cptr, size, char);
} else {
argv[i] = 0;
}
@@ -58,7 +58,7 @@ SWIG_AsArgcArgv(PyObject* input,
argv = SWIG_AsArgcArgv($input, $descriptor(char**), &argc, &owner);
if (!argv) {
$1 = 0; $2 = 0;
- SWIG_arg_fail(SWIG_TypeError, "int ARGC, char **ARGV", $argnum);
+ %argument_fail(SWIG_TypeError, "int ARGC, char **ARGV", $argnum);
} else {
$1 = ($1_ltype) argc;
$2 = ($2_ltype) argv;
@@ -69,9 +69,9 @@ SWIG_AsArgcArgv(PyObject* input,
if (owner$argnum) {
size_t i = argc$argnum;
while (i) {
- SWIG_delete_array(argv$argnum[--i]);
+ %delete_array(argv$argnum[--i]);
}
- SWIG_delete_array(argv$argnum);
+ %delete_array(argv$argnum);
}
}
diff --git a/Lib/python/attribute.i b/Lib/python/attribute.i
index 63833eaba..99dd2a3f1 100644
--- a/Lib/python/attribute.i
+++ b/Lib/python/attribute.i
@@ -71,9 +71,9 @@
NOTE: remember that if the type contains commas, such as
'std::pair<int,int>', you need to use the macro like:
- %attribute_ref(A, SWIG_arg(std::pair<int,int>), pval);
+ %attribute_ref(A, %arg(std::pair<int,int>), pval);
- where SWIG_arg() 'normalize' the type to be understood as a single
+ where %arg() 'normalize' the type to be understood as a single
argument, otherwise the macro will get confused (see the 'cpp'
documentation).
@@ -115,10 +115,10 @@
%ignore Class::get;
#if #__VA_ARGS__ != ""
%ignore Class::__VA_ARGS__;
- %_attribute(SWIG_arg(Class), Wrap, SWIG_arg(type),
+ %_attribute(%arg(Class), Wrap, %arg(type),
attr, _t->get(), _t->__VA_ARGS__(_val))
#else
- %_attribute(SWIG_arg(Class), Wrap, SWIG_arg(type),
+ %_attribute(%arg(Class), Wrap, %arg(type),
attr, _t->get(),
fprintf(stderr,"'attr' is a read-only attribute"))
#endif
@@ -127,15 +127,15 @@
%define %_attribute_ref_T(Class, Wrap, type, refname, attr)
%ignore Class::refname();
%ignore Class::refname() const;
-%_attribute(SWIG_arg(Class), Wrap, SWIG_arg(type),
+%_attribute(%arg(Class), Wrap, %arg(type),
attr, _t->refname(), _t->refname() = _val)
%enddef
%define %attribute_ref_T(Class, Wrap, type, refname, ...)
#if #__VA_ARGS__ == ""
- %_attribute_ref_T(SWIG_arg(Class), Wrap, SWIG_arg(type), refname, refname)
+ %_attribute_ref_T(%arg(Class), Wrap, %arg(type), refname, refname)
#else
- %_attribute_ref_T(SWIG_arg(Class), Wrap, SWIG_arg(type), refname, __VA_ARGS__)
+ %_attribute_ref_T(%arg(Class), Wrap, %arg(type), refname, __VA_ARGS__)
#endif
%enddef
@@ -144,9 +144,9 @@
//
%define %attribute(Class, type, attr, get, ...)
- %attribute_T(SWIG_arg(Class), SWIG_Mangle(Class), SWIG_arg(type), attr, get, __VA_ARGS__)
+ %attribute_T(%arg(Class), %mangle(Class), %arg(type), attr, get, __VA_ARGS__)
%enddef
%define %attribute_ref(Class, type, refname, ...)
- %attribute_ref_T(SWIG_arg(Class), SWIG_Mangle(Class), SWIG_arg(type), refname, __VA_ARGS__)
+ %attribute_ref_T(%arg(Class), %mangle(Class), %arg(type), refname, __VA_ARGS__)
%enddef
diff --git a/Lib/python/ccomplex.i b/Lib/python/ccomplex.i
index 721123d9b..f7b2e4589 100644
--- a/Lib/python/ccomplex.i
+++ b/Lib/python/ccomplex.i
@@ -19,6 +19,6 @@
%swig_cplxdbl_convn(complex, CCplxConst, creal, cimag);
/* declaring the typemaps */
-%typemap_primitive(SWIG_TYPECHECK_CPLXFLT, float complex);
-%typemap_primitive(SWIG_TYPECHECK_CPLXDBL, double complex);
-%typemap_primitive(SWIG_TYPECHECK_CPLXDBL, complex);
+%typemaps_primitive(SWIG_TYPECHECK_CPLXFLT, float complex);
+%typemaps_primitive(SWIG_TYPECHECK_CPLXDBL, double complex);
+%typemaps_primitive(SWIG_TYPECHECK_CPLXDBL, complex);
diff --git a/Lib/python/cstring.i b/Lib/python/cstring.i
index 7eea70a35..ede9c596a 100644
--- a/Lib/python/cstring.i
+++ b/Lib/python/cstring.i
@@ -1,10 +1 @@
%include <typemaps/cstring.swg>
-%include <pystrings.swg>
-
-%typemap_cstrings(%cstring,
- char,
- SWIG_AsCharPtr,
- SWIG_AsCharPtrAndSize,
- SWIG_FromCharPtr,
- SWIG_FromCharPtrAndSize);
-
diff --git a/Lib/python/cwstring.i b/Lib/python/cwstring.i
index b37fd4e4a..2824d9c7b 100644
--- a/Lib/python/cwstring.i
+++ b/Lib/python/cwstring.i
@@ -1,10 +1,3 @@
-%include <typemaps/cstring.swg>
%include <pywstrings.swg>
-
-%typemap_cstrings(%cwstring,
- wchar_t,
- SWIG_AsWCharPtr,
- SWIG_AsWCharPtrAndSize,
- SWIG_FromWCharPtr,
- SWIG_FromWCharPtrAndSize);
+%include <typemaps/cwstring.swg>
diff --git a/Lib/python/file.i b/Lib/python/file.i
index 25ea1dfdd..9ce953297 100644
--- a/Lib/python/file.i
+++ b/Lib/python/file.i
@@ -37,4 +37,4 @@ SWIG_AsFilePtr(PyObject *obj) {
}
/* defining the typemaps */
-%typemap_asval(SWIG_CCode(POINTER), SWIG_AsValFilePtr, "SWIG_AsValFilePtr", FILE*);
+%typemaps_asval(%checkcode(POINTER), SWIG_AsValFilePtr, "SWIG_AsValFilePtr", FILE*);
diff --git a/Lib/python/pyapi.swg b/Lib/python/pyapi.swg
index 8c946297d..28cd836a6 100644
--- a/Lib/python/pyapi.swg
+++ b/Lib/python/pyapi.swg
@@ -30,7 +30,7 @@ typedef struct swig_const_info {
* Append a value to the result obj
* ----------------------------------------------------------------------------- */
SWIGINTERN PyObject*
-SWIG_Python_AppendResult(PyObject* result, PyObject* obj) {
+SWIG_Python_AppendOutput(PyObject* result, PyObject* obj) {
if (!result) {
result = obj;
} else if (result == Py_None) {
diff --git a/Lib/python/pycomplex.swg b/Lib/python/pycomplex.swg
index ef7d90b46..6402610fc 100644
--- a/Lib/python/pycomplex.swg
+++ b/Lib/python/pycomplex.swg
@@ -12,7 +12,7 @@
%fragment(SWIG_From_frag(Type),"header")
{
SWIGINTERNINLINE PyObject*
-SWIG_From(Type)(SWIG_cplusplus(const Type&, Type) c)
+SWIG_From(Type)(%ifcplusplus(const Type&, Type) c)
{
return PyComplex_FromDoubles(Real(c), Imag(c));
}
@@ -46,7 +46,6 @@ SWIG_AsVal(Type) (PyObject *o, Type* val)
/* the float case */
%define %swig_cplxflt_conv(Type, Constructor, Real, Imag)
%fragment(SWIG_AsVal_frag(Type),"header",
- fragment="SWIG_CheckDoubleInRange",
fragment=SWIG_AsVal_frag(float)) {
SWIGINTERN int
SWIG_AsVal(Type)(PyObject *o, Type *val)
@@ -55,11 +54,11 @@ SWIG_AsVal(Type)(PyObject *o, Type *val)
double re = PyComplex_RealAsDouble(o);
double im = PyComplex_ImagAsDouble(o);
if ((-FLT_MAX <= re && re <= FLT_MAX) && (-FLT_MAX <= im && im <= FLT_MAX)) {
- if (val) *val = Constructor(SWIG_numeric_cast(re, float),
- SWIG_numeric_cast(im, float));
+ if (val) *val = Constructor(%numeric_cast(re, float),
+ %numeric_cast(im, float));
return SWIG_OK;
} else {
- return SWIG_TypeError;
+ return SWIG_OverflowError;
}
} else {
float re;
diff --git a/Lib/python/pycontainer.swg b/Lib/python/pycontainer.swg
index 780cf4f78..220b70843 100644
--- a/Lib/python/pycontainer.swg
+++ b/Lib/python/pycontainer.swg
@@ -142,7 +142,7 @@ namespace swig
char msg[1024];
snprintf(msg, sizeof(msg), "in sequence element %d ", _index);
if (!PyErr_Occurred()) {
- SWIG_type_error(swig::type_name<T>());
+ %type_error(swig::type_name<T>());
}
SWIG_Python_AddErrorMsg(msg);
SWIG_Python_AddErrorMsg(e.what());
@@ -371,7 +371,7 @@ namespace swig
%enddef
%define %swig_sequence_methods_common(Sequence...)
- %swig_container_methods(SWIG_arg(Sequence))
+ %swig_container_methods(%arg(Sequence))
%fragment("PySequence_Base");
%extend {
@@ -402,7 +402,7 @@ namespace swig
%enddef
%define %swig_sequence_methods(Sequence...)
- %swig_sequence_methods_common(SWIG_arg(Sequence))
+ %swig_sequence_methods_common(%arg(Sequence))
%extend {
const value_type& __getitem__(difference_type i) const throw (std::out_of_range) {
return *(swig::cgetpos(self, i));
@@ -419,7 +419,7 @@ namespace swig
%enddef
%define %swig_sequence_methods_val(Sequence...)
- %swig_sequence_methods_common(SWIG_arg(Sequence))
+ %swig_sequence_methods_common(%arg(Sequence))
%extend {
value_type __getitem__(difference_type i) throw (std::out_of_range) {
return *(swig::cgetpos(self, i));
diff --git a/Lib/python/pyinit.swg b/Lib/python/pyinit.swg
index 212fe1ec8..cf9351bb6 100644
--- a/Lib/python/pyinit.swg
+++ b/Lib/python/pyinit.swg
@@ -195,7 +195,7 @@ SWIG_Python_InstallConstants(PyObject *d, swig_const_info constants[]) {
obj = SWIG_NewPointerObj(constants[i].pvalue, *(constants[i]).ptype,0);
break;
case SWIG_PY_BINARY:
- obj = SWIG_NewPackedObj(constants[i].pvalue, constants[i].lvalue, *(constants[i].ptype), 0);
+ obj = SWIG_NewPackedObj(constants[i].pvalue, constants[i].lvalue, *(constants[i].ptype));
break;
default:
obj = 0;
diff --git a/Lib/python/pyprimtypes.swg b/Lib/python/pyprimtypes.swg
index e0f05e832..b48c8900f 100644
--- a/Lib/python/pyprimtypes.swg
+++ b/Lib/python/pyprimtypes.swg
@@ -1,19 +1,3 @@
-%include <typemaps/primtypes.swg>
-
-/* Macro for 'signed long' derived types */
-
-%define %type_slong(Type, Frag, Min, Max)
-%derived_type_from(long, Type)
-%signed_derived_type_asval(long, Type, Frag, Min, Max)
-%enddef
-
-/* Macro for 'unsigned long' derived types */
-
-%define %type_ulong(Type, Frag, Max)
-%derived_type_from(unsigned long, Type)
-%unsigned_derived_type_asval(unsigned long, Type, Frag, Max)
-%enddef
-
/* ------------------------------------------------------------
* Primitive Types
* ------------------------------------------------------------ */
@@ -50,33 +34,11 @@ SWIG_AsVal_dec(bool)(PyObject *obj, bool *val)
}
}
-/* signed/unsigned char */
-
-%type_slong(signed char, "<limits.h>", SCHAR_MIN, SCHAR_MAX)
-%type_ulong(unsigned char, "<limits.h>", UCHAR_MAX)
-
-/* short/unsigned short */
-
-%type_slong(short, "<limits.h>", SHRT_MIN, SHRT_MAX)
-%type_ulong(unsigned short, "<limits.h>", USHRT_MAX)
-
-/* int/unsigned int */
-
-%type_slong(int, "<limits.h>", INT_MIN, INT_MAX)
-%type_ulong(unsigned int, "<limits.h>", UINT_MAX)
-
-/* signed/unsigned wchar_t */
-
-#ifdef __cplusplus
-%type_slong(signed wchar_t, "<wchar.h>", WCHAR_MIN, WCHAR_MAX)
-%type_ulong(unsigned wchar_t, "<wchar.h>", UWCHAR_MAX)
-#endif
-
/* long */
%fragment(SWIG_From_frag(long),"header",
fragment="<limits.h>") {
- SWIG_define(SWIG_From_dec(long), PyInt_FromLong)
+ %define_as(SWIG_From_dec(long), PyInt_FromLong)
}
%fragment(SWIG_AsVal_frag(long),"header") {
@@ -107,7 +69,7 @@ SWIGINTERNINLINE PyObject*
SWIG_From_dec(unsigned long)(unsigned long value)
{
return (value > LONG_MAX) ?
- PyLong_FromUnsignedLong(value) : PyInt_FromLong(SWIG_numeric_cast(value,long));
+ PyLong_FromUnsignedLong(value) : PyInt_FromLong(%numeric_cast(value,long));
}
}
@@ -145,7 +107,7 @@ SWIGINTERNINLINE PyObject*
SWIG_From_dec(long long)(long long value)
{
return ((value < LONG_MIN) || (value > LONG_MAX)) ?
- PyLong_FromLongLong(value) : PyInt_FromLong(SWIG_numeric_cast(value,long));
+ PyLong_FromLongLong(value) : PyInt_FromLong(%numeric_cast(value,long));
}
}
@@ -178,7 +140,7 @@ SWIGINTERNINLINE PyObject*
SWIG_From_dec(unsigned long long)(unsigned long long value)
{
return (value > LONG_MAX) ?
- PyLong_FromUnsignedLongLong(value) : PyInt_FromLong(SWIG_numeric_cast(value,long));
+ PyLong_FromUnsignedLongLong(value) : PyInt_FromLong(%numeric_cast(value,long));
}
}
@@ -205,15 +167,10 @@ SWIG_AsVal_dec(unsigned long long)(PyObject *obj, unsigned long long *val)
}
}
-/* float */
-
-%derived_type_from(double, float)
-%signed_derived_type_asval(double, float, "<float.h>", -FLT_MAX, FLT_MAX)
-
/* double */
%fragment(SWIG_From_frag(double),"header") {
- SWIG_define(SWIG_From_dec(double), PyFloat_FromDouble)
+ %define_as(SWIG_From_dec(double), PyFloat_FromDouble)
}
%fragment(SWIG_AsVal_frag(double),"header") {
@@ -239,70 +196,5 @@ SWIG_AsVal_dec(double)(PyObject *obj, double *val)
}
}
-/* char */
-
-%fragment(SWIG_From_frag(char),"header") {
-SWIGINTERNINLINE PyObject*
-SWIG_From_dec(char)(char c)
-{
- return PyString_FromStringAndSize(&c,1);
-}
-}
-%fragment(SWIG_AsVal_frag(char),"header",
- fragment="SWIG_AsCharArray",
- fragment=SWIG_AsVal_frag(signed char)) {
-SWIGINTERN int
-SWIG_AsVal_dec(char)(PyObject *obj, char *val)
-{
- if (SWIG_AsCharArray(obj, val, 1) == SWIG_OK) {
- return SWIG_OK;
- } else {
- signed char v;
- int res = SWIG_AsVal(signed char)(obj, &v);
- if (res == SWIG_OK && val) *val = (char)(v);
- return res;
- }
- }
-}
-
-/* wchar_t */
-
-
-%fragment(SWIG_From_frag(wchar_t),"header") {
-SWIGINTERNINLINE PyObject*
-SWIG_From_dec(wchar_t)(wchar_t c)
-{
- return PyUnicode_FromWideChar(&c, 1);
-}
-}
-
-%fragment(SWIG_AsVal_frag(wchar_t),"header",
- fragment="SWIG_AsWCharArray",
- fragment=SWIG_AsVal_frag(long)) {
-SWIGINTERN int
-SWIG_AsVal_dec(wchar_t)(PyObject *obj, wchar_t *val)
-{
- if (SWIG_AsWCharArray(obj, val, 1) == SWIG_OK) {
- return SWIG_OK;
- } else {
- long v;
- int res = SWIG_AsVal(long)(obj, &v);
- if (res == SWIG_OK) {
- if (WCHAR_MIN <= v && v <= WCHAR_MAX) {
- if (val) *val = (wchar_t)(v);
- return SWIG_OK;
- } else {
- return SWIG_OverflowError;
- }
- }
- return res;
- }
-}
-}
-
-/* ------------------------------------------------------------
- * Apply the primitive typemap for all the types with checkcode
- * ------------------------------------------------------------ */
-%apply_checkctypes(%typemap_primitive)
diff --git a/Lib/python/pyrun.swg b/Lib/python/pyrun.swg
index 3a6a82605..7e7287a95 100644
--- a/Lib/python/pyrun.swg
+++ b/Lib/python/pyrun.swg
@@ -15,19 +15,19 @@
#define SWIG_NewPointerObj(ptr, type, flags) SWIG_Python_NewPointerObj(ptr, type, flags)
/* for raw packed data */
-#define SWIG_ConvertPacked(obj, ptr, sz, ty, flags) SWIG_Python_ConvertPacked(obj, ptr, sz, ty, flags)
-#define SWIG_NewPackedObj(ptr, sz, type, flags) SWIG_Python_NewPackedObj(ptr, sz, type)
+#define SWIG_ConvertPacked(obj, ptr, sz, ty) SWIG_Python_ConvertPacked(obj, ptr, sz, ty)
+#define SWIG_NewPackedObj(ptr, sz, type) SWIG_Python_NewPackedObj(ptr, sz, type)
/* for class or struct pointers */
#define SWIG_ConvertInstance(obj, pptr, type, flags) SWIG_Python_ConvertPtr(obj, pptr, type, flags)
#define SWIG_NewInstanceObj(ptr, type, flags) SWIG_Python_NewPointerObj(ptr, type, flags)
/* for C or C++ function pointers */
-#define SWIG_ConvertFunctionPtr(obj, pptr, type, flags) SWIG_Python_ConvertPtr(obj, pptr, type, flags)
+#define SWIG_ConvertFunctionPtr(obj, pptr, type) SWIG_Python_ConvertPtr(obj, pptr, type, 0)
#define SWIG_NewFunctionPtrObj(ptr, type) SWIG_Python_NewPointerObj(ptr, type, 0)
/* for C++ member pointers, ie, member methods */
-#define SWIG_ConvertMember(obj, ptr, sz, ty, flags) SWIG_Python_ConvertPacked(obj, ptr, sz, ty, flags)
+#define SWIG_ConvertMember(obj, ptr, sz, ty) SWIG_Python_ConvertPacked(obj, ptr, sz, ty)
#define SWIG_NewMemberObj(ptr, sz, type) SWIG_Python_NewPackedObj(ptr, sz, type)
@@ -504,7 +504,7 @@ SWIG_Python_ConvertPtr(PyObject *obj, void **ptr, swig_type_info *ty, int flags)
/* Convert a packed value value */
SWIGRUNTIME int
-SWIG_Python_ConvertPacked(PyObject *obj, void *ptr, size_t sz, swig_type_info *ty, int flags) {
+SWIG_Python_ConvertPacked(PyObject *obj, void *ptr, size_t sz, swig_type_info *ty) {
swig_cast_info *tc;
const char *c = 0;
diff --git a/Lib/python/pystdcommon.swg b/Lib/python/pystdcommon.swg
index 373d6f313..8f23c2685 100644
--- a/Lib/python/pystdcommon.swg
+++ b/Lib/python/pystdcommon.swg
@@ -74,7 +74,7 @@ namespace swig {
if ((res != 0) && p) {
typedef typename noconst_traits<Type>::noconst_type noconst_type;
*(const_cast<noconst_type*>(val)) = *p;
- if (res == SWIG_NEWOBJ) SWIG_delete(p);
+ if (res == SWIG_NEWOBJ) %delete(p);
return SWIG_OK;
} else {
return SWIG_ERROR;
@@ -114,7 +114,7 @@ namespace swig {
Type v;
if (!obj || (asval(obj, &v) != SWIG_OK)) {
if (!PyErr_Occurred()) {
- SWIG_type_error(swig::type_name<Type>());
+ %type_error(swig::type_name<Type>());
}
if (throw_error) throw std::invalid_argument("bad type");
}
@@ -130,7 +130,7 @@ namespace swig {
if (res && v) {
if (res == SWIG_NEWOBJ) {
Type r(*v);
- SWIG_delete(v);
+ %delete(v);
return r;
} else {
return *v;
@@ -139,7 +139,7 @@ namespace swig {
// Uninitialized return value, no Type() constructor required.
static Type *v_def = (Type*) malloc(sizeof(Type));
if (!PyErr_Occurred()) {
- SWIG_type_error(swig::type_name<Type>());
+ %type_error(swig::type_name<Type>());
}
if (throw_error) throw std::invalid_argument("bad type");
memset(v_def,0,sizeof(Type));
@@ -157,7 +157,7 @@ namespace swig {
return v;
} else {
if (!PyErr_Occurred()) {
- SWIG_type_error(swig::type_name<Type>());
+ %type_error(swig::type_name<Type>());
}
if (throw_error) throw std::invalid_argument("bad type");
return 0;
@@ -252,8 +252,8 @@ namespace swig {
%enddef
-#define specialize_std_vector(Type,Check,As,From) %specialize_std_container(SWIG_arg(Type),Check,As,From)
-#define specialize_std_list(Type,Check,As,From) %specialize_std_container(SWIG_arg(Type),Check,As,From)
-#define specialize_std_deque(Type,Check,As,From) %specialize_std_container(SWIG_arg(Type),Check,As,From)
-#define specialize_std_set(Type,Check,As,From) %specialize_std_container(SWIG_arg(Type),Check,As,From)
-#define specialize_std_multiset(Type,Check,As,From) %specialize_std_container(SWIG_arg(Type),Check,As,From)
+#define specialize_std_vector(Type,Check,As,From) %specialize_std_container(%arg(Type),Check,As,From)
+#define specialize_std_list(Type,Check,As,From) %specialize_std_container(%arg(Type),Check,As,From)
+#define specialize_std_deque(Type,Check,As,From) %specialize_std_container(%arg(Type),Check,As,From)
+#define specialize_std_set(Type,Check,As,From) %specialize_std_container(%arg(Type),Check,As,From)
+#define specialize_std_multiset(Type,Check,As,From) %specialize_std_container(%arg(Type),Check,As,From)
diff --git a/Lib/python/pystrings.swg b/Lib/python/pystrings.swg
index 9ea99df46..f28722abf 100644
--- a/Lib/python/pystrings.swg
+++ b/Lib/python/pystrings.swg
@@ -35,7 +35,7 @@ SWIG_AsCharPtrAndSize(PyObject *obj, char** cptr, size_t* psize, int *alloc)
if (*alloc == SWIG_NEWOBJ)
#endif
{
- *cptr = SWIG_new_copy_array(cstr, len + 1, char);
+ *cptr = %new_copy_array(cstr, len + 1, char);
*alloc = SWIG_NEWOBJ;
}
else {
@@ -60,10 +60,10 @@ SWIG_FromCharPtrAndSize(const char* carray, size_t size)
{
if (carray) {
if (size > INT_MAX) {
- return SWIG_NewPointerObj(SWIG_const_cast(carray,char *),
+ return SWIG_NewPointerObj(%const_cast(carray,char *),
SWIG_TypeQuery("char *"), 0);
} else {
- return PyString_FromStringAndSize(carray, SWIG_numeric_cast(size,int));
+ return PyString_FromStringAndSize(carray, %numeric_cast(size,int));
}
} else {
Py_INCREF(Py_None);
@@ -72,9 +72,4 @@ SWIG_FromCharPtrAndSize(const char* carray, size_t size)
}
}
-/* ------------------------------------------------------------
- * The plain char * handling
- * ------------------------------------------------------------ */
-%include <typemaps/strings.swg>
-%typemap_string(char, Char, SWIG_AsCharPtrAndSize, SWIG_FromCharPtrAndSize, strlen)
diff --git a/Lib/python/pyswigtype.swg b/Lib/python/pyswigtype.swg
index c21f24d4e..fcecbdcb6 100644
--- a/Lib/python/pyswigtype.swg
+++ b/Lib/python/pyswigtype.swg
@@ -1,5 +1,3 @@
-%include <typemaps/swigtype.swg>
-
/* ------------------------------------------------------------
* --- Consttab --- needed for callbacks, it should be removed later.
* ------------------------------------------------------------ */
diff --git a/Lib/python/pytuplehlp.swg b/Lib/python/pytuplehlp.swg
index 8b4b419eb..32e158035 100644
--- a/Lib/python/pytuplehlp.swg
+++ b/Lib/python/pytuplehlp.swg
@@ -5,4 +5,4 @@
*/
#warning "Deprecated file: Don't use t_output_helper anymore,"
-#warning "use SWIG_Python_AppendResult or SWIG_append_result instead."
+#warning "use SWIG_Python_AppendOutput or %append_output instead."
diff --git a/Lib/python/pytypemaps.swg b/Lib/python/pytypemaps.swg
index 90e4f9633..08d52b9ae 100644
--- a/Lib/python/pytypemaps.swg
+++ b/Lib/python/pytypemaps.swg
@@ -16,37 +16,30 @@
* Basic definitions
* ----------------------------------------------------------------------------- */
-%define_swig_object(PyObject *)
+#define SWIG_Object PyObject *
+#define VOID_Object (Py_INCREF(Py_None) ? Py_None : 0)
-#define SWIG_VoidObject() (Py_INCREF(Py_None) ? Py_None : 0)
-#define SWIG_SetResultObj(obj) $result = obj
-#define SWIG_AppendResultObj(obj) $result = SWIG_Python_AppendResult($result, obj)
-#define SWIG_SetConstantObj(name, obj) SWIG_block(PyObject *_obj = obj; PyDict_SetItemString(d, name, _obj); Py_DECREF(_obj))
-#define SWIG_Raise(obj, type, desc) PyObject *_obj = obj; PyErr_SetObject(SWIG_Python_ExceptionType(desc), _obj); Py_DECREF(_obj)
-#define SWIG_DirOutFail(code, msg) Swig::DirectorTypeMismatchException::raise(SWIG_ErrorType(code), msg)
+#define SWIG_AppendOutput(result,obj) SWIG_Python_AppendOutput(result, obj)
+#define SWIG_SetConstant(name, obj) %block(PyObject *_obj = obj; PyDict_SetItemString(d, name, _obj); Py_DECREF(_obj))
+#define SWIG_Raise(obj, type, desc) PyObject *_obj = obj; PyErr_SetObject(SWIG_Python_ExceptionType(desc), _obj); Py_DECREF(_obj)
+#define SWIG_DirOutFail(code, msg) Swig::DirectorTypeMismatchException::raise(SWIG_ErrorType(code), msg)
/* -----------------------------------------------------------------------------
* All the typemaps
* ----------------------------------------------------------------------------- */
-%include <typemaps/exception.swg>
-%include <pyswigtype.swg>
-%include <typemaps/void.swg>
-%include <typemaps/valtypes.swg>
-%include <typemaps/ptrtypes.swg>
-%include <typemaps/swigobject.swg>
-%include <typemaps/inoutlist.swg>
%include <pyprimtypes.swg>
%include <pystrings.swg>
-%include <typemaps/misctypes.swg>
-%include <typemaps/enumint.swg>
+%include <typemaps/swigtypemaps.swg>
+/* fix for callbacks */
+%include <pyswigtype.swg>
/* -----------------------------------------------------------------------------
* Backward compatibility output helper
* ----------------------------------------------------------------------------- */
%fragment("t_output_helper","header") %{
-#define t_output_helper SWIG_Python_AppendResult
+#define t_output_helper SWIG_Python_AppendOutput
%}
diff --git a/Lib/python/pywstrings.swg b/Lib/python/pywstrings.swg
index bd0dea188..887774528 100644
--- a/Lib/python/pywstrings.swg
+++ b/Lib/python/pywstrings.swg
@@ -25,7 +25,7 @@ SWIG_AsWCharPtrAndSize(PyObject *obj, wchar_t **cptr, size_t *psize, int *alloc)
if (isunicode) {
int len = PyUnicode_GetSize(obj);
if (cptr) {
- *cptr = SWIG_new_array(len + 1, wchar_t);
+ *cptr = %new_array(len + 1, wchar_t);
PyUnicode_AsWideChar((PyUnicodeObject *)obj, *cptr, len);
(*cptr)[len] = 0;
}
@@ -45,10 +45,10 @@ SWIG_FromWCharPtrAndSize(const wchar_t * carray, size_t size)
{
if (carray) {
if (size > INT_MAX) {
- return SWIG_NewPointerObj(SWIG_const_cast(carray,wchar_t *),
+ return SWIG_NewPointerObj(%const_cast(carray,wchar_t *),
SWIG_TypeQuery("wchar_t *"), 0);
} else {
- return PyUnicode_FromWideChar(carray, SWIG_numeric_cast(size,int));
+ return PyUnicode_FromWideChar(carray, %numeric_cast(size,int));
}
} else {
Py_INCREF(Py_None);
@@ -57,10 +57,4 @@ SWIG_FromWCharPtrAndSize(const wchar_t * carray, size_t size)
}
}
-/* ------------------------------------------------------------
- * The plain wchar_t * handling
- * ------------------------------------------------------------ */
-
-%include <typemaps/strings.swg>
-%typemap_string(wchar_t, WChar, SWIG_AsWCharPtrAndSize, SWIG_FromWCharPtrAndSize, wcslen);
diff --git a/Lib/python/std_basic_string.i b/Lib/python/std_basic_string.i
index d0db4c5c4..cb372d2ef 100644
--- a/Lib/python/std_basic_string.i
+++ b/Lib/python/std_basic_string.i
@@ -23,7 +23,7 @@ SWIG_AsPtr(std::basic_string<char>)(PyObject* obj, std::string **val)
if (SWIG_AsCharPtrAndSize(obj, &buf, &size, &alloc) == SWIG_OK) {
if (buf) {
if (val) *val = new std::string(buf, size - 1);
- if (alloc == SWIG_NEWOBJ) SWIG_delete_array(buf);
+ if (alloc == SWIG_NEWOBJ) %delete_array(buf);
return SWIG_NEWOBJ;
}
} else {
@@ -47,7 +47,7 @@ SWIGINTERNINLINE PyObject*
}
%include <std/std_basic_string.i>
-%typemap_asptrfromn(SWIG_CCode(STRING), std::basic_string<char>);
+%typemaps_asptrfromn(%checkcode(STRING), std::basic_string<char>);
#endif
@@ -71,7 +71,7 @@ SWIGINTERN int
if (SWIG_AsWCharPtrAndSize(obj, &buf, &size, &alloc) == SWIG_OK) {
if (buf) {
if (val) *val = new std::wstring(buf, size - 1);
- if (alloc == SWIG_NEWOBJ) SWIG_delete_array(buf);
+ if (alloc == SWIG_NEWOBJ) %delete_array(buf);
return SWIG_NEWOBJ;
}
} else {
@@ -94,6 +94,6 @@ SWIGINTERNINLINE PyObject*
}
}
-%typemap_asptrfromn(SWIG_CCode(UNISTRING), std::basic_string<wchar_t>);
+%typemaps_asptrfromn(%checkcode(UNISTRING), std::basic_string<wchar_t>);
#endif
diff --git a/Lib/python/std_complex.i b/Lib/python/std_complex.i
index fbb8dbb44..f3ef1e39a 100644
--- a/Lib/python/std_complex.i
+++ b/Lib/python/std_complex.i
@@ -4,6 +4,8 @@
%include <pycomplex.swg>
+
+
%{
#include <complex>
%}
@@ -17,6 +19,8 @@
std::complex<float>, std::real, std::imag)
-%typemap_primitive(SWIG_CCode(CPLXDBL), std::complex<double>);
-%typemap_primitive(SWIG_CCode(CPLXFLT), std::complex<float>);
+%typemaps_primitive(%checkcode(CPLXDBL), std::complex<double>);
+%typemaps_primitive(%checkcode(CPLXFLT), std::complex<float>);
+
+
diff --git a/Lib/python/std_pair.i b/Lib/python/std_pair.i
index fa1f35dc4..9721bc30f 100644
--- a/Lib/python/std_pair.i
+++ b/Lib/python/std_pair.i
@@ -16,14 +16,14 @@
T *pfirst = 0;
U *psecond = 0;
if (val) {
- *val = SWIG_new(std::pair<T,U>);
+ *val = %new_instance(std::pair<T,U>);
pfirst = &((*val)->first);
psecond = &((*val)->second);
}
if ((swig::asval(first,pfirst) == SWIG_OK) && (swig::asval(second,psecond) == SWIG_OK)) {
return SWIG_NEWOBJ;
} else {
- SWIG_delete(*val);
+ %delete(*val);
}
} else {
value_type *p;
diff --git a/Lib/python/std_string.i b/Lib/python/std_string.i
index 2c5fcf31b..dc1378ae6 100644
--- a/Lib/python/std_string.i
+++ b/Lib/python/std_string.i
@@ -1,30 +1 @@
-//
-// std::string
-//
-
-#ifndef SWIG_STD_BASIC_STRING
-#define SWIG_STD_STRING
-
-%{
-#include <string>
-%}
-
-namespace std
-{
- class string;
-}
-
%include <typemaps/std_string.swg>
-%include <pystrings.swg>
-
-%std_string_asptr(std::string, char, SWIG_AsCharPtrAndSize)
-%std_string_from(std::string, SWIG_FromCharPtrAndSize)
-%std_string_asval(std::string)
-
-%typemap_asptrfromn(SWIG_CCode(STRING), std::string);
-
-#else
-
-%include <std/std_string.i>
-
-#endif
diff --git a/Lib/python/std_wstring.i b/Lib/python/std_wstring.i
index 1569d3b7e..ef8628137 100644
--- a/Lib/python/std_wstring.i
+++ b/Lib/python/std_wstring.i
@@ -1,31 +1,3 @@
-//
-// std::wstring
-//
-
-#ifndef SWIG_STD_BASIC_STRING
-#define SWIG_STD_WSTRING
-
-%{
-#include <cwchar>
-#include <string>
-%}
-
-namespace std
-{
- class wstring;
-}
-
-%include <typemaps/std_string.swg>
%include <pywstrings.swg>
+%include <typemaps/std_wstring.swg>
-%std_string_asptr(std::wstring, wchar_t, SWIG_AsWCharPtrAndSize)
-%std_string_from(std::wstring, SWIG_FromWCharPtrAndSize)
-%std_string_asval(std::wstring)
-
-%typemap_asptrfromn(SWIG_CCode(UNISTRING), std::wstring);
-
-#else
-
-%include <std/std_wstring.i>
-
-#endif
diff --git a/Lib/ruby/cstring.i b/Lib/ruby/cstring.i
index 8ac2d55ce..ede9c596a 100644
--- a/Lib/ruby/cstring.i
+++ b/Lib/ruby/cstring.i
@@ -1,10 +1 @@
%include <typemaps/cstring.swg>
-%include <rubystrings.swg>
-
-%typemap_cstrings(%cstring,
- char,
- SWIG_AsCharPtr,
- SWIG_AsCharPtrAndSize,
- SWIG_FromCharPtr,
- SWIG_FromCharPtrAndSize);
-
diff --git a/Lib/ruby/rubyapi.swg b/Lib/ruby/rubyapi.swg
index 0563fd130..7883e9e6c 100644
--- a/Lib/ruby/rubyapi.swg
+++ b/Lib/ruby/rubyapi.swg
@@ -7,7 +7,7 @@ extern "C" {
#endif
SWIGINTERN VALUE
-SWIG_Ruby_AppendResult(VALUE target, VALUE o) {
+SWIG_Ruby_AppendOutput(VALUE target, VALUE o) {
if (NIL_P(target)) {
target = o;
} else {
diff --git a/Lib/ruby/rubyprimtypes.swg b/Lib/ruby/rubyprimtypes.swg
index 41e0eb9b2..f1969cd1a 100644
--- a/Lib/ruby/rubyprimtypes.swg
+++ b/Lib/ruby/rubyprimtypes.swg
@@ -1,33 +1,30 @@
-%include <typemaps/primtypes.swg>
-
-/* Macro for 'signed long' derived types */
-
-%define %type_slong(Type, Frag, Min, Max)
-%derived_type_from(long, Type)
-%signed_derived_type_asval(long, Type, Frag, Min, Max)
-%enddef
-
-/* Macro for 'unsigned long' derived types */
-
-%define %type_ulong(Type, Frag, Max)
-%derived_type_from(unsigned long, Type)
-%unsigned_derived_type_asval(unsigned long, Type, Frag, Max)
-%enddef
-
/* ------------------------------------------------------------
* Primitive Types
* ------------------------------------------------------------ */
+/* auxiliar ruby fail method */
+
%fragment("SWIG_ruby_failed","header")
{
SWIGINTERN VALUE
SWIG_ruby_failed()
{
return Qnil;
+}
}
-
+
+%define %ruby_aux_method(Type, Method, Action)
+SWIGINTERN VALUE SWIG_AUX_##Method##(VALUE *args)
+{
+ VALUE obj = args[0];
+ VALUE type = TYPE(obj);
+ Type *res = (Type *)(args[1]);
+ *res = Action;
+ return obj;
}
+%enddef
+
/* boolean */
@@ -61,48 +58,24 @@ SWIG_AsVal_dec(bool)(VALUE obj, bool *val)
}
}
-/* signed/unsigned char */
-
-%type_slong(signed char, "<limits.h>", SCHAR_MIN, SCHAR_MAX)
-%type_ulong(unsigned char, "<limits.h>", UCHAR_MAX)
-
-/* short/unsigned short */
-
-%type_slong(short, "<limits.h>", SHRT_MIN, SHRT_MAX)
-%type_ulong(unsigned short, "<limits.h>", USHRT_MAX)
-
-/* int/unsigned int */
-
-%type_slong(int, "<limits.h>", INT_MIN, INT_MAX)
-%type_ulong(unsigned int, "<limits.h>", UINT_MAX)
-
-/* signed/unsigned wchar_t */
-
-#ifdef __cplusplus
-%type_slong(signed wchar_t, "<wchar.h>", WCHAR_MIN, WCHAR_MAX)
-%type_ulong(unsigned wchar_t, "<wchar.h>", UWCHAR_MAX)
-#endif
-
/* long */
%fragment(SWIG_From_frag(long),"header",
fragment="<limits.h>") {
- SWIG_define(SWIG_From_dec(long), LONG2NUM)
+ %define_as(SWIG_From_dec(long), LONG2NUM)
}
%fragment(SWIG_AsVal_frag(long),"header",fragment="SWIG_ruby_failed") {
-SWIGINTERN VALUE SWIG_num2long(VALUE *args)
-{
- *((long *)(args[1])) = NUM2LONG(args[0]);
- return args[0];
-}
+%ruby_aux_method(long, NUM2LONG, type == T_FIXNUM ? NUM2LONG(obj) : rb_big2long(obj))
+
SWIGINTERN int
SWIG_AsVal_dec(long)(VALUE obj, long* val)
{
- if (obj != Qnil && ((TYPE(obj) == T_FIXNUM) || (TYPE(obj) == T_BIGNUM))) {
+ VALUE type = TYPE(obj);
+ if ((type == T_FIXNUM) || (type == T_BIGNUM)) {
long v;
VALUE a[2] = { obj, (VALUE)(&v) };
- if (rb_rescue(RUBY_METHOD_FUNC(SWIG_num2long), (VALUE)a, RUBY_METHOD_FUNC(SWIG_ruby_failed), 0) != Qnil) {
+ if (rb_rescue(RUBY_METHOD_FUNC(SWIG_AUX_NUM2LONG), (VALUE)a, RUBY_METHOD_FUNC(SWIG_ruby_failed), 0) != Qnil) {
if (val) *val = v;
return SWIG_OK;
}
@@ -123,18 +96,16 @@ SWIG_From_dec(unsigned long)(unsigned long value)
}
%fragment(SWIG_AsVal_frag(unsigned long),"header",fragment="SWIG_ruby_failed") {
-SWIGINTERN VALUE SWIG_num2ulong(VALUE *args)
-{
- *((unsigned long *)(args[1])) = NUM2ULONG(args[0]);
- return args[0];
-}
+%ruby_aux_method(unsigned long, NUM2ULONG, type == T_FIXNUM ? NUM2ULONG(obj) : rb_big2ulong(obj))
+
SWIGINTERN int
SWIG_AsVal_dec(unsigned long)(VALUE obj, unsigned long *val)
{
- if (obj != Qnil && ((TYPE(obj) == T_FIXNUM) || (TYPE(obj) == T_BIGNUM))) {
+ VALUE type = TYPE(obj);
+ if ((type == T_FIXNUM) || (type == T_BIGNUM)) {
unsigned long v;
VALUE a[2] = { obj, (VALUE)(&v) };
- if (rb_rescue(RUBY_METHOD_FUNC(SWIG_num2ulong), (VALUE)a, RUBY_METHOD_FUNC(SWIG_ruby_failed), 0) != Qnil) {
+ if (rb_rescue(RUBY_METHOD_FUNC(SWIG_AUX_NUM2ULONG), (VALUE)a, RUBY_METHOD_FUNC(SWIG_ruby_failed), 0) != Qnil) {
if (val) *val = v;
return SWIG_OK;
}
@@ -156,18 +127,16 @@ SWIG_From_dec(long long)(long long value)
}
%fragment(SWIG_AsVal_frag(long long),"header",fragment="SWIG_ruby_failed") {
-SWIGINTERN VALUE SWIG_num2longlong(VALUE *args)
-{
- *((long long *)(args[1])) = NUM2LL(args[0]);
- return args[0];
-}
+%ruby_aux_method(long long, NUM2LL, type == T_FIXNUM ? NUM2LL(obj) : rb_big2ll(obj))
+
SWIGINTERN int
SWIG_AsVal_dec(long long)(VALUE obj, long long *val)
{
- if (obj != Qnil && ((TYPE(obj) == T_FIXNUM) || (TYPE(obj) == T_BIGNUM))) {
+ VALUE type = TYPE(obj);
+ if ((type == T_FIXNUM) || (type == T_BIGNUM)) {
long long v;
VALUE a[2] = { obj, (VALUE)(&v) };
- if (rb_rescue(RUBY_METHOD_FUNC(SWIG_num2longlong), (VALUE)a, RUBY_METHOD_FUNC(SWIG_ruby_failed), 0) != Qnil) {
+ if (rb_rescue(RUBY_METHOD_FUNC(SWIG_AUX_NUM2LL), (VALUE)a, RUBY_METHOD_FUNC(SWIG_ruby_failed), 0) != Qnil) {
if (val) *val = v;
return SWIG_OK;
}
@@ -189,18 +158,16 @@ SWIG_From_dec(unsigned long long)(unsigned long long value)
}
%fragment(SWIG_AsVal_frag(unsigned long long),"header",fragment="SWIG_ruby_failed") {
-SWIGINTERN VALUE SWIG_num2ulonglong(VALUE *args)
-{
- *((unsigned long long *)(args[1])) = NUM2ULL(args[0]);
- return args[0];
-}
+%ruby_aux_method(long long, NUM2ULL, type == T_FIXNUM ? NUM2ULL(obj) : rb_big2ull(obj))
+
SWIGINTERN int
SWIG_AsVal_dec(unsigned long long)(VALUE obj, unsigned long long *val)
-{
- if (obj != Qnil && ((TYPE(obj) == T_FIXNUM) || (TYPE(obj) == T_BIGNUM))) {
+{
+ VALUE type = TYPE(obj);
+ if ((type == T_FIXNUM) || (type == T_BIGNUM)) {
unsigned long long v;
VALUE a[2] = { obj, (VALUE)(&v) };
- if (rb_rescue(RUBY_METHOD_FUNC(SWIG_num2ulonglong), (VALUE)a, RUBY_METHOD_FUNC(SWIG_ruby_failed), 0) != Qnil) {
+ if (rb_rescue(RUBY_METHOD_FUNC(SWIG_AUX_NUM2ULL), (VALUE)a, RUBY_METHOD_FUNC(SWIG_ruby_failed), 0) != Qnil) {
if (val) *val = v;
return SWIG_OK;
}
@@ -209,30 +176,23 @@ SWIG_AsVal_dec(unsigned long long)(VALUE obj, unsigned long long *val)
}
}
-/* float */
-
-%derived_type_from(double, float)
-%signed_derived_type_asval(double, float, "<float.h>", -FLT_MAX, FLT_MAX)
-
/* double */
%fragment(SWIG_From_frag(double),"header") {
- SWIG_define(SWIG_From_dec(double), rb_float_new)
+ %define_as(SWIG_From_dec(double), rb_float_new)
}
%fragment(SWIG_AsVal_frag(double),"header",fragment="SWIG_ruby_failed") {
-SWIGINTERN VALUE SWIG_num2dbl(VALUE *args)
-{
- *((double *)(args[1])) = NUM2DBL(args[0]);
- return args[0];
-}
+%ruby_aux_method(double, NUM2DBL, (type == T_FLOAT ? NUM2DBL(obj) : (type == T_FIXNUM ? (double) FIX2INT(obj) : rb_big2dbl(obj))))
+
SWIGINTERN int
SWIG_AsVal_dec(double)(VALUE obj, double *val)
{
- if (obj != Qnil &&((TYPE(obj) == T_FLOAT) || (TYPE(obj) == T_FIXNUM) || (TYPE(obj) == T_BIGNUM))) {
+ VALUE type = TYPE(obj);
+ if ((type == T_FLOAT) || (type == T_FIXNUM) || (type == T_BIGNUM)) {
double v;
VALUE a[2] = { obj, (VALUE)(&v) };
- if (rb_rescue(RUBY_METHOD_FUNC(SWIG_num2dbl), (VALUE)a, RUBY_METHOD_FUNC(SWIG_ruby_failed), 0) != Qnil) {
+ if (rb_rescue(RUBY_METHOD_FUNC(SWIG_AUX_NUM2DBL), (VALUE)a, RUBY_METHOD_FUNC(SWIG_ruby_failed), 0) != Qnil) {
if (val) *val = v;
return SWIG_OK;
}
@@ -241,77 +201,4 @@ SWIG_AsVal_dec(double)(VALUE obj, double *val)
}
}
-/* char */
-
-%fragment(SWIG_From_frag(char),"header") {
-SWIGINTERNINLINE VALUE
-SWIG_From_dec(char)(char c)
-{
- return rb_str_new(&c,1);
-}
-}
-
-%fragment(SWIG_AsVal_frag(char),"header",
- fragment="SWIG_AsCharArray",
- fragment=SWIG_AsVal_frag(signed char)) {
-SWIGINTERN int
-SWIG_AsVal_dec(char)(VALUE obj, char *val)
-{
- signed char v;
- if (SWIG_AsVal(signed char)(obj, &v) == SWIG_OK) {
- if (val) *val = (char)(v);
- return SWIG_OK;
- } else {
- if (SWIG_AsCharArray(obj, val, 1) == SWIG_OK) {
- return SWIG_OK;
- }
- }
- return SWIG_TypeError;
- }
-}
-
-/* wchar_t */
-
-
-%fragment(SWIG_From_frag(wchar_t),"header",
- fragment=SWIG_From_frag(char),
- fragment=SWIG_From_frag(long)) {
-SWIGINTERNINLINE VALUE
-SWIG_From_dec(wchar_t)(wchar_t c)
-{
- if (CHAR_MIN <= v && v <= CHAR_MAX) {
- return SWIG_From(char)((char)c);
- } else {
- return SWIG_From(long)((long)c);
- }
-}
-}
-
-%fragment(SWIG_AsVal_frag(wchar_t),"header",
- fragment="SWIG_AsWCharArray",
- fragment=SWIG_AsVal_frag(long)) {
-SWIGINTERN int
-SWIG_AsVal_dec(wchar_t)(VALUE obj, wchar_t *val)
-{
- char v;
- if (SWIG_AsVal(char)(obj, &v) == SWIG_OK) {
- if (val) *val = (wchar_t)(v);
- return SWIG_OK;
- } else {
- long v;
- if (SWIG_AsVal(long)(obj, &v) == SWIG_OK) {
- if (WCHAR_MIN <= v && v <= WCHAR_MAX) {
- if (val) *val = (wchar_t)(v);
- return SWIG_OK;
- }
- }
- }
- return SWIG_TypeError;
-}
-}
-
-/* ------------------------------------------------------------
- * Apply the primitive typemap for all the types with checkcode
- * ------------------------------------------------------------ */
-%apply_checkctypes(%typemap_primitive)
diff --git a/Lib/ruby/rubyrun.swg b/Lib/ruby/rubyrun.swg
index cb894f909..4ecb3281d 100644
--- a/Lib/ruby/rubyrun.swg
+++ b/Lib/ruby/rubyrun.swg
@@ -12,19 +12,19 @@
#define SWIG_NewPointerObj(ptr, type, flags) SWIG_Ruby_NewPointerObj(ptr, type, flags)
/* for raw packed data */
-#define SWIG_ConvertPacked(obj, ptr, sz, ty, flags) SWIG_Ruby_ConvertPacked(obj, ptr, sz, ty, flags)
-#define SWIG_NewPackedObj(ptr, sz, type, flags) SWIG_Ruby_NewPackedObj(ptr, sz, type)
+#define SWIG_ConvertPacked(obj, ptr, sz, ty) SWIG_Ruby_ConvertPacked(obj, ptr, sz, ty, flags)
+#define SWIG_NewPackedObj(ptr, sz, type) SWIG_Ruby_NewPackedObj(ptr, sz, type)
/* for class or struct pointers */
#define SWIG_ConvertInstance(obj, pptr, type, flags) SWIG_Ruby_ConvertPtr(obj, pptr, type, flags)
#define SWIG_NewInstanceObj(ptr, type, flags) SWIG_Ruby_NewPointerObj(ptr, type, flags)
/* for C or C++ function pointers */
-#define SWIG_ConvertFunctionPtr(obj, pptr, type, flags) SWIG_Ruby_ConvertPtr(obj, pptr, type, flags)
+#define SWIG_ConvertFunctionPtr(obj, pptr, type) SWIG_Ruby_ConvertPtr(obj, pptr, type, 0)
#define SWIG_NewFunctionPtrObj(ptr, type) SWIG_Ruby_NewPointerObj(ptr, type, 0)
/* for C++ member pointers, ie, member methods */
-#define SWIG_ConvertMember(obj, ptr, sz, ty, flags) SWIG_Ruby_ConvertPacked(obj, ptr, sz, ty, flags)
+#define SWIG_ConvertMember(obj, ptr, sz, ty) SWIG_Ruby_ConvertPacked(obj, ptr, sz, ty)
#define SWIG_NewMemberObj(ptr, sz, type) SWIG_Ruby_NewPackedObj(ptr, sz, type)
@@ -44,7 +44,7 @@
/* Ruby-specific SWIG API */
#define SWIG_InitRuntime() SWIG_Ruby_InitRuntime()
-#define SWIG_define_class(ty) SWIG_Ruby_define_class(ty)
+#define SWIG_define_class(ty) SWIG_Ruby_define_class(ty)
#define SWIG_NewClassInstance(value, ty) SWIG_Ruby_NewClassInstance(value, ty)
#define SWIG_MangleStr(value) SWIG_Ruby_MangleStr(value)
#define SWIG_CheckConvert(value, ty) SWIG_Ruby_CheckConvert(value, ty)
@@ -243,7 +243,7 @@ SWIG_Ruby_NewPackedObj(void *ptr, int sz, swig_type_info *type) {
/* Convert a packed value value */
SWIGRUNTIME int
-SWIG_Ruby_ConvertPacked(VALUE obj, void *ptr, int sz, swig_type_info *ty, int flags) {
+SWIG_Ruby_ConvertPacked(VALUE obj, void *ptr, int sz, swig_type_info *ty) {
swig_cast_info *tc;
const char *c;
diff --git a/Lib/ruby/rubystrings.swg b/Lib/ruby/rubystrings.swg
index 53c587b86..cbe20a712 100644
--- a/Lib/ruby/rubystrings.swg
+++ b/Lib/ruby/rubystrings.swg
@@ -21,7 +21,7 @@ SWIG_AsCharPtrAndSize(VALUE obj, char** cptr, size_t* psize, int *alloc)
if (cptr) {
if (alloc) {
if (*alloc == SWIG_NEWOBJ) {
- *cptr = SWIG_new_copy_array(cstr, size, char);
+ *cptr = %new_copy_array(cstr, size, char);
} else {
*cptr = cstr;
*alloc = SWIG_OLDOBJ;
@@ -42,9 +42,9 @@ SWIG_FromCharPtrAndSize(const char* carray, size_t size)
{
if (carray) {
if (size > LONG_MAX) {
- return SWIG_NewPointerObj(SWIG_const_cast(carray,char *), SWIG_TypeQuery("char *"), 0);
+ return SWIG_NewPointerObj(%const_cast(carray,char *), SWIG_TypeQuery("char *"), 0);
} else {
- return rb_str_new(carray, SWIG_numeric_cast(size,long));
+ return rb_str_new(carray, %numeric_cast(size,long));
}
} else {
return Qnil;
@@ -52,9 +52,3 @@ SWIG_FromCharPtrAndSize(const char* carray, size_t size)
}
}
-/* ------------------------------------------------------------
- * The plain char * handling
- * ------------------------------------------------------------ */
-
-%include <typemaps/strings.swg>
-%typemap_string(char, Char, SWIG_AsCharPtrAndSize, SWIG_FromCharPtrAndSize, strlen)
diff --git a/Lib/ruby/rubytypemaps.swg b/Lib/ruby/rubytypemaps.swg
index c555921f3..7110b80bb 100644
--- a/Lib/ruby/rubytypemaps.swg
+++ b/Lib/ruby/rubytypemaps.swg
@@ -10,37 +10,31 @@
/* -----------------------------------------------------------------------------
* Basic definitions
* ----------------------------------------------------------------------------- */
+#define %convertptr_flags $track
+#define %newpointer_flags $track
+#define %newinstance_flags $track
-%define_swig_object(VALUE)
+#define SWIG_Object VALUE
+#define VOID_Object Qnil
-#define SWIG_VoidObject() Qnil
-#define SWIG_SetResultObj(obj) $result = obj
-#define SWIG_AppendResultObj(obj) $result = SWIG_Ruby_AppendResult($result, obj)
-#define SWIG_SetConstantObj(name, obj) rb_define_const($module, name, obj)
-#define SWIG_Raise(obj, type, desc) rb_exc_raise(rb_exc_new3(rb_eRuntimeError, rb_obj_as_string(obj)))
-#define SWIG_DirOutFail(code, msg) Swig::DirectorTypeMismatchException::raise(SWIG_ErrorType(code), msg)
+#define SWIG_AppendOutput(result,obj) SWIG_Ruby_AppendOutput(result, obj)
+#define SWIG_SetConstant(name, obj) rb_define_const($module, name, obj)
+#define SWIG_Raise(obj, type, desc) rb_exc_raise(rb_exc_new3(rb_eRuntimeError, rb_obj_as_string(obj)))
+#define SWIG_DirOutFail(code, msg) Swig::DirectorTypeMismatchException::raise(SWIG_ErrorType(code), msg)
/* -----------------------------------------------------------------------------
* All the typemaps
* ----------------------------------------------------------------------------- */
-%include <typemaps/exception.swg>
-%include <typemaps/swigtype.swg>
-%include <typemaps/void.swg>
-%include <typemaps/valtypes.swg>
-%include <typemaps/ptrtypes.swg>
-%include <typemaps/swigobject.swg>
-%include <typemaps/inoutlist.swg>
%include <rubyprimtypes.swg>
%include <rubystrings.swg>
-%include <typemaps/misctypes.swg>
-%include <typemaps/enumint.swg>
+%include <typemaps/swigtypemaps.swg>
/* -----------------------------------------------------------------------------
* Backward compatibility output helper
* ----------------------------------------------------------------------------- */
%fragment("output_helper","header") %{
-#define output_helper SWIG_Ruby_AppendResult
+#define output_helper SWIG_Ruby_AppendOutput
%}
diff --git a/Lib/ruby/rubywstrings.swg b/Lib/ruby/rubywstrings.swg
deleted file mode 100644
index 4f4959844..000000000
--- a/Lib/ruby/rubywstrings.swg
+++ /dev/null
@@ -1,74 +0,0 @@
-/* ------------------------------------------------------------
- * utility methods for wchar_t strings
- * ------------------------------------------------------------ */
-
-/*
- Ruby doesn't support the wchar_t, so, we need to use an 'opaque' type.
- */
-
-%types(ruby_wchar_array *);
-
-%fragment("ruby_wchar_array","header",fragment="<wchar.h>") {
- struct ruby_wchar_array {
- wchar_t *cptr;
- size_t size;
- };
-
- SWIGINTERN get_ruby_wchar_array_info() {
- static swig_type_info* ruby_wchar_array_info = 0;
- if (!ruby_wchar_array_info) ruby_wchar_array_info = SWIG_TypeQuery("ruby_wchar_array *");
- return ruby_wchar_array_info;
- }
-}
-
-%fragment("SWIG_AsWCharPtrAndSize","header",fragment="ruby_wchar_array") {
-SWIGINTERN int
-SWIG_AsWCharPtrAndSize(PyObject *obj, wchar_t **cptr, size_t *psize, int *alloc)
-{
- static swig_type_info* ptr_wchar_info = 0;
- wchar_t * vptr = 0;
- if (!ptr_wchar_info) ptr_wchar_info = SWIG_TypeQuery("wchar_t *");
- if (SWIG_ConvertPtr(obj, (void**)&vptr, ptr_wchar_info, 0) != SWIG_OK) {
- if (cptr) *cptr = vptr;
- if (psize) *psize = vptr ? (wcslen(vptr) + 1) : 0;
- return SWIG_OK;
- } else {
- ruby_wchar_array *vptr = 0;
- if (SWIG_ConvertPtr(obj, (void**)&vptr, get_ruby_wchar_array_info(), 0) != SWIG_OK) {
- if (cptr) *cptr = vptr->cptr;
- if (psize) *psize = vprtr->size;
- return SWIG_OK;
- }
- }
- return SWIG_TypeError;
-}
-}
-
-%fragment("SWIG_FromWCharPtrAndSize","header",fragment="ruby_wchar_array") {
-SWIGINTERNINLINE PyObject *
-SWIG_FromWCharPtrAndSize(const wchar_t * carray, size_t size)
-{
- ruby_wchar_array *vptr = SWIG_new(ruby_wchar_array);
- vptr->cptr = carray;
- vptr->size = size;
- return SWIG_NewPointerObj(SWIG_const_cast(carray,wchar_t *), get_ruby_wchar_array_info(), 1);
-}
-}
-
-%fragment("SWIG_FromWCharPtr","header",fragment="<wchar.h>") {
-SWIGINTERNINLINE PyObject *
-SWIG_FromWCharPtr(const wchar_t * carray)
-{
- static swig_type_info* wchar_ptr_info = 0;
- if (!wchar_array_info) wchar_ptr_info = SWIG_TypeQuery("wchar_t *");
- return SWIG_NewPointerObj(SWIG_const_cast(carray,wchar_t *), wchar_ptr_info, 0);
-}
-}
-
-/* ------------------------------------------------------------
- * The plain wchar_t * handling
- * ------------------------------------------------------------ */
-
-%include <typemaps/strbase.swg>
-%typemap_string(wchar_t, WChar, SWIG_AsWCharPtrAndSize, SWIG_FromWCharPtrAndSize, wcslen);
-
diff --git a/Lib/ruby/std_string.i b/Lib/ruby/std_string.i
index a0ec522bc..dc1378ae6 100644
--- a/Lib/ruby/std_string.i
+++ b/Lib/ruby/std_string.i
@@ -1,30 +1 @@
-//
-// std::string
-//
-
-#ifndef SWIG_STD_BASIC_STRING
-#define SWIG_STD_STRING
-
-%{
-#include <string>
-%}
-
-namespace std
-{
- class string;
-}
-
%include <typemaps/std_string.swg>
-%include <rubystrings.swg>
-
-%std_string_asptr(std::string, char, SWIG_AsCharPtrAndSize)
-%std_string_from(std::string, SWIG_FromCharPtrAndSize)
-%std_string_asval(std::string)
-
-%typemap_asptrfromn(SWIG_CCode(STRING), std::string);
-
-#else
-
-%include <std/std_string.i>
-
-#endif
diff --git a/Lib/std/std_common.i b/Lib/std/std_common.i
index b8a915a2b..7a932d758 100644
--- a/Lib/std/std_common.i
+++ b/Lib/std/std_common.i
@@ -160,11 +160,11 @@ namespace swig {
*/
%define %typemap_traits(Code,Type...)
- %typemap_asvalfrom(SWIG_arg(Code),
- SWIG_arg(swig::asval<Type >),
- SWIG_arg(swig::from),
- SWIG_arg(SWIG_Traits_frag(Type)),
- SWIG_arg(SWIG_Traits_frag(Type)),
+ %typemaps_asvalfrom(%arg(Code),
+ %arg(swig::asval<Type >),
+ %arg(swig::from),
+ %arg(SWIG_Traits_frag(Type)),
+ %arg(SWIG_Traits_frag(Type)),
Type);
%enddef
@@ -174,11 +174,11 @@ namespace swig {
*/
%define %typemap_traits_ptr(Code,Type...)
- %typemap_asptrfrom(SWIG_arg(Code),
- SWIG_arg(swig::asptr),
- SWIG_arg(swig::from),
- SWIG_arg(SWIG_Traits_frag(Type)),
- SWIG_arg(SWIG_Traits_frag(Type)),
+ %typemaps_asptrfrom(%arg(Code),
+ %arg(swig::asptr),
+ %arg(swig::from),
+ %arg(SWIG_Traits_frag(Type)),
+ %arg(SWIG_Traits_frag(Type)),
Type);
%enddef
diff --git a/Lib/std/std_container.i b/Lib/std/std_container.i
index 463d0cb6b..834a2b28a 100644
--- a/Lib/std/std_container.i
+++ b/Lib/std/std_container.i
@@ -37,7 +37,7 @@
%define %std_sequence_methods_common(sequence)
- %std_container_methods(SWIG_arg(sequence));
+ %std_container_methods(%arg(sequence));
sequence(size_type size);
void pop_back();
@@ -55,7 +55,7 @@
%define %std_sequence_methods(sequence)
- %std_sequence_methods_common(SWIG_arg(sequence));
+ %std_sequence_methods_common(%arg(sequence));
sequence(size_type size, const value_type& value);
void push_back(const value_type& x);
@@ -76,7 +76,7 @@
%define %std_sequence_methods_val(sequence...)
- %std_sequence_methods_common(SWIG_arg(sequence));
+ %std_sequence_methods_common(%arg(sequence));
sequence(size_type size, value_type value);
void push_back(value_type x);
diff --git a/Lib/tcl/cstring.i b/Lib/tcl/cstring.i
index 6772ccc46..ede9c596a 100644
--- a/Lib/tcl/cstring.i
+++ b/Lib/tcl/cstring.i
@@ -1,10 +1 @@
%include <typemaps/cstring.swg>
-%include <tclstrings.swg>
-
-%typemap_cstrings(%cstring,
- char,
- SWIG_AsCharPtr,
- SWIG_AsCharPtrAndSize,
- SWIG_FromCharPtr,
- SWIG_FromCharPtrAndSize);
-
diff --git a/Lib/tcl/cwstring.i b/Lib/tcl/cwstring.i
index fbdfc924a..b17ca763c 100644
--- a/Lib/tcl/cwstring.i
+++ b/Lib/tcl/cwstring.i
@@ -1,10 +1,2 @@
-%include <typemaps/cstring.swg>
-%include <pywstrings.swg>
-
-%typemap_cstrings(%cwstring,
- wchar_t,
- SWIG_AsWCharPtr,
- SWIG_AsWCharPtrAndSize,
- SWIG_FromWCharPtr,
- SWIG_FromWCharArray);
-
+%include <tclwstrings.swg>
+%include <typemaps/cwstring.swg>
diff --git a/Lib/tcl/std_string.i b/Lib/tcl/std_string.i
index 9a850fa12..5b31b28c7 100644
--- a/Lib/tcl/std_string.i
+++ b/Lib/tcl/std_string.i
@@ -1,37 +1,2 @@
-//
-// std::string
-//
-
-#ifndef SWIG_STD_BASIC_STRING
-#define SWIG_STD_STRING
-
-%{
-#include <string>
-%}
-
-namespace std
-{
- class string;
-}
-
%include <typemaps/std_string.swg>
-%include <tclstrings.swg>
-
-%fragment("Tcl_std_string_asptr","header",fragment="SWIG_AsCharPtrAndSize") {
-%tcl_asptr_decl(std::string)
-}
-%fragment("Tcl_std_string_asval","header",fragment="Tcl_std_string_asptr") {
-%tcl_asptr_decl(std::string)
-}
-
-%std_string_asptr_frag(std::string, char, SWIG_AsCharPtrAndSize, "Tcl_std_string_asptr")
-%std_string_asval_frag(std::string, "Tcl_std_string_asval")
-%std_string_from(std::string, SWIG_FromCharPtrAndSize)
-
-%typemap_asptrfromn(SWIG_CCode(STRING), std::string);
-
-#else
-
-%include <std/std_string.i>
-#endif
diff --git a/Lib/tcl/std_wstring.i b/Lib/tcl/std_wstring.i
index 39fa92c8b..f13261492 100644
--- a/Lib/tcl/std_wstring.i
+++ b/Lib/tcl/std_wstring.i
@@ -1,37 +1,2 @@
-//
-// std::wstring
-//
-
-#ifndef SWIG_STD_BASIC_STRING
-#define SWIG_STD_WSTRING
-
-%{
-#include <string>
-%}
-
-namespace std
-{
- class wstring;
-}
-
-%include <typemaps/std_string.i>
%include <tclwstrings.swg>
-
-%fragment("Tcl_std_wstring_asptr","header",fragment="SWIG_AsCharPtrAndSize") {
-%tcl_asptr_decl(std::wstring)
-}
-%fragment("Tcl_std_wstring_asval","header",fragment="Tcl_std_wstring_asptr") {
-%tcl_asptr_decl(std::wstring)
-}
-
-%std_string_asptr_frag(std::wstring, wchar_t, SWIG_AsCharPtrAndSize, "Tcl_std_wstring_asptr")
-%std_string_asval_frag(std::wstring, "Tcl_std_wstring_asval")
-%std_string_from(std::wstring, SWIG_FromCharPtrAndSize)
-
-%typemap_asptrfromn(SWIG_CCode(UNISTRING), std::wstring);
-
-#else
-
-%include <std/std_string.i>
-
-#endif
+%include <typemaps/std_wstring.swg>
diff --git a/Lib/tcl/tclerrors.swg b/Lib/tcl/tclerrors.swg
index 68281cd5c..66e689dac 100644
--- a/Lib/tcl/tclerrors.swg
+++ b/Lib/tcl/tclerrors.swg
@@ -64,6 +64,8 @@ SWIG_Tcl_SetErrorMsg(Tcl_Interp *interp, const char *ctype, const char *mesg)
{
Tcl_ResetResult(interp);
Tcl_SetErrorCode(interp, "SWIG", ctype, NULL);
+ Tcl_AddErrorInfo(interp, ctype);
+ Tcl_AddErrorInfo(interp, " ");
Tcl_AddErrorInfo(interp, mesg);
}
diff --git a/Lib/tcl/tclinit.swg b/Lib/tcl/tclinit.swg
index a9807f459..93d984ae2 100644
--- a/Lib/tcl/tclinit.swg
+++ b/Lib/tcl/tclinit.swg
@@ -50,7 +50,7 @@ SWIG_Tcl_InstallConstants(Tcl_Interp *interp, swig_const_info constants[]) {
obj = SWIG_NewPointerObj(constants[i].pvalue, *(constants[i]).ptype,0);
break;
case SWIG_TCL_BINARY:
- obj = SWIG_NewPackedObj(constants[i].pvalue, constants[i].lvalue, *(constants[i].ptype),0);
+ obj = SWIG_NewPackedObj(constants[i].pvalue, constants[i].lvalue, *(constants[i].ptype));
break;
default:
obj = 0;
diff --git a/Lib/tcl/tclmacros.swg b/Lib/tcl/tclmacros.swg
index 80da82bfb..ffbf830ba 100644
--- a/Lib/tcl/tclmacros.swg
+++ b/Lib/tcl/tclmacros.swg
@@ -1,26 +1,15 @@
-%include <typemaps/swigmacros.swg>
-
-
-/* aux macros to deal with the interp argument */
+/*
+ in Tcl we need to pass the interp value, so, we
+ define decl/call macros as needed.
+*/
-#undef SWIG_As_dec
-#undef SWIG_AsPtr_dec
-#undef SWIG_AsVal_dec
+#define SWIG_ASPTR_DECL_ARGS SWIG_TCL_DECL_ARGS_2
+#define SWIG_ASPTR_CALL_ARGS SWIG_TCL_CALL_ARGS_2
-#define SWIG_Tcl_AsVal(Type...) SWIG_Tcl_ ## AsVal ## _ ## #@Type
-#define SWIG_AsVal_dec(Type...) SWIG_ ## AsVal_dec ## _ ## #@Type
-
-#define SWIG_Tcl_AsPtr(Type...) SWIG_Tcl_ ## AsPtr ## _ ## #@Type
-#define SWIG_AsPtr_dec(Type...) SWIG_ ## AsPtr_dec ## _ ## #@Type
+#define SWIG_ASVAL_DECL_ARGS SWIG_TCL_DECL_ARGS_2
+#define SWIG_ASVAL_CALL_ARGS SWIG_TCL_CALL_ARGS_2
+%include <typemaps/swigmacros.swg>
-%define %tcl_asval_decl(Type...)
-%#define SWIG_AsVal_dec(Type)(obj,val) SWIG_Tcl_AsVal(Type)(Tcl_Interp *interp, obj, val)
-%#define SWIG_AsVal(Type)(obj,val) SWIG_Tcl_AsVal(Type)(interp, obj, val)
-%enddef
-%define %tcl_asptr_decl(Type...)
-%#define SWIG_AsPtr_dec(Type)(obj,ptr) SWIG_Tcl_AsPtr(Type)(Tcl_Interp *interp, obj, ptr)
-%#define SWIG_AsPtr(Type)(obj,ptr) SWIG_Tcl_AsPtr(Type)(interp, obj, ptr)
-%enddef
diff --git a/Lib/tcl/tclprimtypes.swg b/Lib/tcl/tclprimtypes.swg
index 94fac7c1b..e38600b9e 100644
--- a/Lib/tcl/tclprimtypes.swg
+++ b/Lib/tcl/tclprimtypes.swg
@@ -1,25 +1,3 @@
-%include <typemaps/primtypes.swg>
-
-/* Macro for 'signed long' derived types */
-
-%define %type_slong(Type, Frag, Min, Max)
-%derived_type_from(long, Type)
-%fragment("Tcl_asval_"{Type},"header",fragment=Frag) %{
-%tcl_asval_decl(Type)
-%}
-%signed_derived_type_asval(long, Type, "Tcl_asval_"{Type} , Min, Max)
-%enddef
-
-/* Macro for 'unsigned long' derived types */
-
-%define %type_ulong(Type, Frag, Max)
-%derived_type_from(unsigned long, Type)
-%fragment("Tcl_asval_"{Type},"header",fragment=Frag) %{
-%tcl_asval_decl(Type)
-%}
-%unsigned_derived_type_asval(unsigned long, Type, "Tcl_asval_"{Type}, Max)
-%enddef
-
/* ------------------------------------------------------------
* Primitive Types
* ------------------------------------------------------------ */
@@ -27,12 +5,10 @@
/* boolean */
%fragment(SWIG_From_frag(bool),"header") {
- SWIG_define(SWIG_From_dec(bool), Tcl_NewBooleanObj)
+ %define_as(SWIG_From_dec(bool), Tcl_NewBooleanObj)
}
%fragment(SWIG_AsVal_frag(bool),"header") {
-%tcl_asval_decl(bool)
-
SWIGINTERN int
SWIG_AsVal_dec(bool)(Tcl_Obj *obj, bool *val)
{
@@ -45,29 +21,6 @@ SWIG_AsVal_dec(bool)(Tcl_Obj *obj, bool *val)
}
}
-/* signed/unsigned char */
-
-%type_slong(signed char, "<limits.h>", SCHAR_MIN, SCHAR_MAX)
-%type_ulong(unsigned char, "<limits.h>", UCHAR_MAX)
-
-/* short/unsigned short */
-
-%type_slong(short, "<limits.h>", SHRT_MIN, SHRT_MAX)
-%type_ulong(unsigned short, "<limits.h>", USHRT_MAX)
-
-/* int/unsigned int */
-
-%type_slong(int, "<limits.h>", INT_MIN, INT_MAX)
-%type_ulong(unsigned int, "<limits.h>", UINT_MAX)
-
-/* signed/unsigned wchar_t */
-
-#ifdef __cplusplus
-%type_slong(signed wchar_t, "<wchar.h>", WCHAR_MIN, WCHAR_MAX)
-%type_ulong(unsigned wchar_t, "<wchar.h>", UWCHAR_MAX)
-#endif
-
-
/* long */
%fragment(SWIG_From_frag(long),"header",
@@ -76,7 +29,7 @@ SWIGINTERNINLINE Tcl_Obj*
SWIG_From_dec(long)(long value)
{
if (((long) INT_MIN <= value) && (value <= (long) INT_MAX)) {
- return Tcl_NewIntObj(SWIG_numeric_cast(value,int));
+ return Tcl_NewIntObj(%numeric_cast(value,int));
} else {
return Tcl_NewLongObj(value);
}
@@ -84,8 +37,6 @@ SWIG_From_dec(long)(long value)
}
%fragment(SWIG_AsVal_frag(long),"header") {
-%tcl_asval_decl(long)
-
SWIGINTERN int
SWIG_AsVal_dec(long)(Tcl_Obj *obj, long* val)
{
@@ -106,7 +57,7 @@ SWIGINTERNINLINE Tcl_Obj*
SWIG_From_dec(unsigned long)(unsigned long value)
{
if (value < (unsigned long) LONG_MAX) {
- return SWIG_From(long)(SWIG_numeric_cast(value, long));
+ return SWIG_From(long)(%numeric_cast(value, long));
} else {
char temp[256];
snprintf(temp, sizeof(temp),"%lu", value);
@@ -116,25 +67,34 @@ SWIG_From_dec(unsigned long)(unsigned long value)
}
%fragment(SWIG_AsVal_frag(unsigned long),"header") {
-%tcl_asval_decl(unsigned long)
-
SWIGINTERN int
SWIG_AsVal_dec(unsigned long)(Tcl_Obj *obj, unsigned long *val) {
- int len = 0;
- const char *nptr = Tcl_GetStringFromObj(obj, &len);
- if (nptr && len > 0) {
- char *endptr;
- unsigned long v = strtoul(nptr, &endptr,0);
- if (errno == ERANGE) {
- errno = 0;
- return SWIG_OverflowError;
+ long v;
+ if (Tcl_GetLongFromObj(0,obj, &v) == TCL_OK) {
+ if (v > 0) {
+ if (val) *val = (long) v;
+ return SWIG_OK;
} else {
- if (*endptr == '\0') {
- if (val) *val = v;
- return SWIG_OK;
+ return SWIG_OverflowError;
+ }
+ } else {
+ int len = 0;
+ const char *nptr = Tcl_GetStringFromObj(obj, &len);
+ if (nptr && len > 0) {
+ char *endptr;
+ unsigned long v = strtoul(nptr, &endptr,0);
+ if (errno == ERANGE) {
+ errno = 0;
+ return SWIG_OverflowError;
+ } else {
+ if (*endptr == '\0') {
+ if (val) *val = v;
+ return SWIG_OK;
+ }
}
}
}
+
return SWIG_TypeError;
}
}
@@ -148,7 +108,7 @@ SWIGINTERNINLINE Tcl_Obj*
SWIG_From_dec(long long)(long long value)
{
if (((long long) LONG_MIN <= value) && (value <= (long long) LONG_MAX)) {
- return SWIG_From(long)(SWIG_numeric_cast(value,long));
+ return SWIG_From(long)(%numeric_cast(value,long));
} else {
char temp[256];
snprintf(temp, sizeof(temp),"%lld", value);
@@ -158,23 +118,27 @@ SWIG_From_dec(long long)(long long value)
}
%fragment(SWIG_AsVal_frag(long long),"header") {
-%tcl_asval_decl(long long)
-
SWIGINTERN int
SWIG_AsVal_dec(long long)(Tcl_Obj *obj, long long *val)
{
- int len = 0;
- const char *nptr = Tcl_GetStringFromObj(obj, &len);
- if (nptr && len > 0) {
- char *endptr;
- long long v = strtoll(nptr, &endptr,0);
- if (errno == ERANGE) {
- errno = 0;
- return SWIG_OverflowError;
- } else {
- if (*endptr == '\0') {
- if (val) *val = v;
- return SWIG_OK;
+ long v;
+ if (Tcl_GetLongFromObj(0,obj, &v) == TCL_OK) {
+ if (val) *val = v;
+ return SWIG_OK;
+ } else {
+ int len = 0;
+ const char *nptr = Tcl_GetStringFromObj(obj, &len);
+ if (nptr && len > 0) {
+ char *endptr;
+ long long v = strtoll(nptr, &endptr,0);
+ if (errno == ERANGE) {
+ errno = 0;
+ return SWIG_OverflowError;
+ } else {
+ if (*endptr == '\0') {
+ if (val) *val = v;
+ return SWIG_OK;
+ }
}
}
}
@@ -191,7 +155,7 @@ SWIGINTERNINLINE Tcl_Obj*
SWIG_From_dec(unsigned long long)(unsigned long long value)
{
if (value < (unsigned long long) LONG_MAX) {
- return SWIG_From(long long)(SWIG_numeric_cast(value, long long));
+ return SWIG_From(long long)(%numeric_cast(value, long long));
} else {
char temp[256];
snprintf(temp, sizeof(temp),"%llu", value);
@@ -202,23 +166,31 @@ SWIG_From_dec(unsigned long long)(unsigned long long value)
%fragment(SWIG_AsVal_frag(unsigned long long),"header",
fragment=SWIG_AsVal_frag(unsigned long)) {
-%tcl_asval_decl(unsigned long long)
-
SWIGINTERN int
SWIG_AsVal_dec(unsigned long long)(Tcl_Obj *obj, unsigned long long *val)
{
- int len = 0;
- const char *nptr = Tcl_GetStringFromObj(obj, &len);
- if (nptr && len > 0) {
- char *endptr;
- unsigned long long v = strtoull(nptr, &endptr,0);
- if (errno == ERANGE) {
- errno = 0;
- return SWIG_OverflowError;
+ long v;
+ if (Tcl_GetLongFromObj(0,obj, &v) == TCL_OK) {
+ if (v > 0) {
+ if (val) *val = (long) v;
+ return SWIG_OK;
} else {
- if (*endptr == '\0') {
- if (val) *val = v;
- return SWIG_OK;
+ return SWIG_OverflowError;
+ }
+ } else {
+ int len = 0;
+ const char *nptr = Tcl_GetStringFromObj(obj, &len);
+ if (nptr && len > 0) {
+ char *endptr;
+ unsigned long long v = strtoull(nptr, &endptr,0);
+ if (errno == ERANGE) {
+ errno = 0;
+ return SWIG_OverflowError;
+ } else {
+ if (*endptr == '\0') {
+ if (val) *val = v;
+ return SWIG_OK;
+ }
}
}
}
@@ -226,23 +198,13 @@ SWIG_AsVal_dec(unsigned long long)(Tcl_Obj *obj, unsigned long long *val)
}
}
-/* float */
-
-%derived_type_from(double, float)
-%fragment("Tcl_asval_float","header",fragment="<float.h>") {
-%tcl_asval_decl(float)
-}
-%signed_derived_type_asval(double, float, "Tcl_asval_float", -FLT_MAX, FLT_MAX)
-
/* double */
%fragment(SWIG_From_frag(double),"header") {
- SWIG_define(SWIG_From_dec(double), Tcl_NewDoubleObj)
+ %define_as(SWIG_From(double), Tcl_NewDoubleObj)
}
%fragment(SWIG_AsVal_frag(double),"header") {
-%tcl_asval_decl(double)
-
SWIGINTERN int
SWIG_AsVal_dec(double)(Tcl_Obj *obj, double *val)
{
@@ -255,54 +217,3 @@ SWIG_AsVal_dec(double)(Tcl_Obj *obj, double *val)
}
}
-/* char */
-
-%fragment(SWIG_From_frag(char),"header") {
-SWIGINTERNINLINE Tcl_Obj*
-SWIG_From_dec(char)(char c)
-{
- return Tcl_NewStringObj(&c,1);
-}
-}
-
-%fragment(SWIG_AsVal_frag(char),"header",
- fragment="SWIG_AsCharArray",
- fragment=SWIG_AsVal_frag(signed char)) {
-%tcl_asval_decl(char)
-
-SWIGINTERNINLINE int
-SWIG_AsVal_dec(char)(Tcl_Obj *obj, char *val)
-{
- return SWIG_AsCharArray(obj, val, 1) == SWIG_OK ? SWIG_OK : SWIG_TypeError;
-}
-}
-
-
-/* wchar_t */
-
-%fragment(SWIG_From_frag(wchar_t),"header") {
-SWIGINTERNINLINE Tcl_Obj*
-SWIG_From_dec(wchar_t)(wchar_t c)
-{
- return Tcl_NewUnicodeObj(&c, 1);
-}
-}
-
-%fragment(SWIG_AsVal_frag(wchar_t),"header",
- fragment="SWIG_AsWCharArray",
- fragment="<wchar.h>",
- fragment=SWIG_AsVal_frag(long)) {
-%tcl_asval_decl(wchar_t)
-
-SWIGINTERNINLINE int
-SWIG_AsVal_dec(wchar_t)(Tcl_Obj *obj, wchar_t *val)
-{
- return (SWIG_AsWCharArray(obj, val, 1) == SWIG_OK) ? SWIG_OK : SWIG_TypeError;
-}
-}
-
-/* ------------------------------------------------------------
- * Apply the primitive typemap for all the types with checkcode
- * ------------------------------------------------------------ */
-
-%apply_checkctypes(%typemap_primitive)
diff --git a/Lib/tcl/tclrun.swg b/Lib/tcl/tclrun.swg
index a43aa0c9a..9d215fa43 100644
--- a/Lib/tcl/tclrun.swg
+++ b/Lib/tcl/tclrun.swg
@@ -14,20 +14,20 @@
#define SWIG_NewPointerObj(ptr, type, flags) SWIG_Tcl_NewPointerObj(ptr, type, flags)
/* for raw packed data */
-#define SWIG_ConvertPacked(obj, ptr, sz, ty, flags) SWIG_Tcl_ConvertPacked(interp, obj, ptr, sz, ty, flags)
-#define SWIG_NewPackedObj(ptr, sz, type, flags) SWIG_Tcl_NewPackedObj(ptr, sz, type, flags)
+#define SWIG_ConvertPacked(obj, ptr, sz, ty) SWIG_Tcl_ConvertPacked(interp, obj, ptr, sz, ty)
+#define SWIG_NewPackedObj(ptr, sz, type) SWIG_Tcl_NewPackedObj(ptr, sz, type)
/* for class or struct pointers */
#define SWIG_ConvertInstance(obj, pptr, type, flags) SWIG_Tcl_ConvertPtr(interp, obj, pptr, type, flags)
#define SWIG_NewInstanceObj(thisvalue, type, flags) SWIG_Tcl_NewInstanceObj(interp, thisvalue, type, flags)
/* for C or C++ function pointers */
-#define SWIG_ConvertFunctionPtr(obj, pptr, type, flags) SWIG_Tcl_ConvertPtr(interp, obj, pptr, type, flags)
+#define SWIG_ConvertFunctionPtr(obj, pptr, type) SWIG_Tcl_ConvertPtr(interp, obj, pptr, type, 0)
#define SWIG_NewFunctionPtrObj(ptr, type) SWIG_Tcl_NewPointerObj(ptr, type, 0)
/* for C++ member pointers, ie, member methods */
-#define SWIG_ConvertMember(obj, ptr, sz, ty, flags) SWIG_Tcl_ConvertPacked(interp,obj, ptr, sz, ty, flags)
-#define SWIG_NewMemberObj(ptr, sz, type) SWIG_Tcl_NewPackedObj(ptr, sz, type, 0)
+#define SWIG_ConvertMember(obj, ptr, sz, ty) SWIG_Tcl_ConvertPacked(interp,obj, ptr, sz, ty)
+#define SWIG_NewMemberObj(ptr, sz, type) SWIG_Tcl_NewPackedObj(ptr, sz, type)
/* Runtime API */
@@ -58,6 +58,8 @@
#define SWIG_ObjectDelete SWIG_Tcl_ObjectDelete
+#define SWIG_TCL_DECL_ARGS_2(arg1, arg2) (Tcl_Interp *interp, arg1, arg2)
+#define SWIG_TCL_CALL_ARGS_2(arg1, arg2) (interp, arg1, arg2)
/* -----------------------------------------------------------------------------
* pointers/data manipulation
* ----------------------------------------------------------------------------- */
@@ -165,7 +167,7 @@ SWIG_Tcl_PointerTypeFromString(char *c) {
/* Convert a packed value value */
SWIGRUNTIME int
-SWIG_Tcl_ConvertPacked(Tcl_Interp *interp, Tcl_Obj *obj, void *ptr, int sz, swig_type_info *ty, int flags) {
+SWIG_Tcl_ConvertPacked(Tcl_Interp *interp, Tcl_Obj *obj, void *ptr, int sz, swig_type_info *ty) {
swig_cast_info *tc;
const char *c;
@@ -211,14 +213,13 @@ SWIG_Tcl_NewPointerObj(void *ptr, swig_type_info *type, int flags) {
}
SWIGRUNTIME Tcl_Obj *
-SWIG_Tcl_NewPackedObj(void *ptr, int sz, swig_type_info *type, int flags) {
+SWIG_Tcl_NewPackedObj(void *ptr, int sz, swig_type_info *type) {
char result[1024];
char *r = result;
if ((2*sz + 1 + strlen(type->name)) > 1000) return 0;
*(r++) = '_';
r = SWIG_PackData(r,ptr,sz);
strcpy(r,type->name);
- flags = 0;
return Tcl_NewStringObj(result,-1);
}
diff --git a/Lib/tcl/tclstrings.swg b/Lib/tcl/tclstrings.swg
index e934dddad..540d6270e 100644
--- a/Lib/tcl/tclstrings.swg
+++ b/Lib/tcl/tclstrings.swg
@@ -24,13 +24,8 @@ SWIG_AsCharPtrAndSize(Tcl_Obj *obj, char** cptr, size_t* psize, int *alloc)
SWIGINTERNINLINE Tcl_Obj *
SWIG_FromCharPtrAndSize(const char* carray, size_t size)
{
- return (size < INT_MAX) ? Tcl_NewStringObj(carray, SWIG_numeric_cast(size,int)) : NULL;
+ return (size < INT_MAX) ? Tcl_NewStringObj(carray, %numeric_cast(size,int)) : NULL;
}
}
-/* ------------------------------------------------------------
- * The plain char * handling
- * ------------------------------------------------------------ */
-%include <typemaps/strings.swg>
-%typemap_string(char, Char, SWIG_AsCharPtrAndSize, SWIG_FromCharPtrAndSize, strlen)
diff --git a/Lib/tcl/tclswigtype.swg b/Lib/tcl/tclswigtype.swg
index 525e7a093..a79bdfd1e 100644
--- a/Lib/tcl/tclswigtype.swg
+++ b/Lib/tcl/tclswigtype.swg
@@ -1,5 +1,3 @@
-%include <typemaps/swigtype.swg>
-
%typemap(out) SWIGTYPE = SWIGTYPE INSTANCE;
%typemap(out) SWIGTYPE * = SWIGTYPE *INSTANCE;
%typemap(out) SWIGTYPE & = SWIGTYPE &INSTANCE;
diff --git a/Lib/tcl/tcltypemaps.swg b/Lib/tcl/tcltypemaps.swg
index cdcd5c2ff..b037c4cd2 100644
--- a/Lib/tcl/tcltypemaps.swg
+++ b/Lib/tcl/tcltypemaps.swg
@@ -11,27 +11,21 @@
* Basic definitions
* ----------------------------------------------------------------------------- */
-%define_swig_object(Tcl_Obj *)
+#define SWIG_Object Tcl_Obj *
+#define VOID_Object NULL
-#define SWIG_VoidObject() NULL
-#define SWIG_SetResultObj(obj) $result = obj
-#define SWIG_AppendResultObj(obj) $result = (Tcl_ListObjAppendElement(NULL,$result,obj) == TCL_OK) ? $result : NULL
-#define SWIG_SetConstantObj(name, obj) SWIG_Tcl_SetConstantObj(interp, name, obj)
+#define SWIG_AppendOutput(result,obj) (Tcl_ListObjAppendElement(NULL,result,obj) == TCL_OK) ? result : NULL
+#define SWIG_SetConstant(name, obj) SWIG_Tcl_SetConstantObj(interp, name, obj)
#define SWIG_Raise(obj,type,desc) SWIG_Tcl_SetErrorObj(interp,type,obj)
-#define SWIG_DirOutFail(code, msg) /* no directors supported */
/* -----------------------------------------------------------------------------
* All the typemaps
* ----------------------------------------------------------------------------- */
-%include <typemaps/exception.swg>
-%include <tclswigtype.swg>
-%include <typemaps/void.swg>
-%include <typemaps/valtypes.swg>
-%include <typemaps/ptrtypes.swg>
-%include <typemaps/swigobject.swg>
-%include <typemaps/inoutlist.swg>
%include <tclprimtypes.swg>
%include <tclstrings.swg>
-%include <typemaps/misctypes.swg>
-%include <typemaps/enumint.swg>
+%include <typemaps/swigtypemaps.swg>
+
+/* fix for instances */
+%include <tclswigtype.swg>
+
diff --git a/Lib/tcl/tclwstrings.swg b/Lib/tcl/tclwstrings.swg
index 8ac2101ca..fd413c6a8 100644
--- a/Lib/tcl/tclwstrings.swg
+++ b/Lib/tcl/tclwstrings.swg
@@ -2,35 +2,64 @@
* utility methods for wchar strings
* ------------------------------------------------------------ */
-%fragment("SWIG_AsCharPtrAndSize","header") {
+%{
+#include <wchar.h>
+%}
+
+%fragment("SWIG_AsWCharPtrAndSize","header") {
SWIGINTERN int
SWIG_AsWCharPtrAndSize(Tcl_Obj *obj, wchar_t** cptr, size_t* psize, int *alloc)
{
int len = 0;
- wchar_t *cstr = Tcl_GetUnicodeFromObj(obj, &len);
- if (cstr) {
- if (cptr) *cptr = cstr;
+ Tcl_UniChar *ustr = Tcl_GetUnicodeFromObj(obj, &len);
+ if (ustr) {
+ if (cptr) {
+ Tcl_Encoding encoding = NULL;
+ char *src = (char *) ustr;
+ int srcLen = (len)*sizeof(Tcl_UniChar);
+ int dstLen = sizeof(wchar_t)*(len + 1);
+ char *dst = %new_array(dstLen, char);
+ int flags = 0;
+ Tcl_EncodingState *statePtr = 0;
+ int srcRead = 0;
+ int dstWrote = 0;
+ int dstChars = 0;
+ Tcl_UtfToExternal(0, encoding, src, srcLen, flags, statePtr, dst,
+ dstLen, &srcRead, &dstWrote, &dstChars);
+
+ if (alloc) *alloc = SWIG_NEWOBJ;
+ }
if (psize) *psize = len + 1;
- if (alloc) *alloc = SWIG_OLDOBJ;
return SWIG_OK;
}
return SWIG_TypeError;
}
}
-%fragment("SWIG_FromWCharPtrAndSize","header",
- fragment="<limits.h>") {
+%fragment("SWIG_FromWCharPtrAndSize","header") {
SWIGINTERNINLINE Tcl_Obj *
SWIG_FromWCharPtrAndSize(const wchar_t* carray, size_t size)
{
- return (size < INT_MAX) ? Tcl_NewUnicodeObj(carray, SWIG_numeric_cast(size,int)) : NULL;
+ Tcl_Obj *res = NULL;
+ if (size < INT_MAX) {
+ Tcl_Encoding encoding = NULL;
+ char *src = (char *) carray;
+ int srcLen = (size)*sizeof(wchar_t);
+ int dstLen = (size)*sizeof(Tcl_UniChar);
+ char *dst = %new_array(dstLen, char);
+ int flags = 0;
+ Tcl_EncodingState *statePtr = 0;
+ int srcRead = 0;
+ int dstWrote = 0;
+ int dstChars = 0;
+
+ Tcl_ExternalToUtf(0, encoding, src, srcLen, flags, statePtr, dst,
+ dstLen, &srcRead, &dstWrote, &dstChars);
+
+ res = Tcl_NewUnicodeObj((Tcl_UniChar*)dst, size);
+ %delete_array(dst);
+ }
+ return res;
}
}
-
-/* ------------------------------------------------------------
- * The plain char * handling
- * ------------------------------------------------------------ */
-
-%include <typemaps/strings.swg>
-%typemap_string(wchar_t, WChar, SWIG_AsWCharPtrAndSize, SWIG_FromWCharPtrAndSize, wcslen)
diff --git a/Lib/typemaps/README b/Lib/typemaps/README
index d01da504b..785c57224 100644
--- a/Lib/typemaps/README
+++ b/Lib/typemaps/README
@@ -1,16 +1,54 @@
+Still in developing, but if you are interested into looking around,
+start with
+
+
+ swigtypemaps.swg
+
+which is the head file. Also read the docs for %fragments in
+
+ fragments.swg
+
+and follow the definitions in one of the supported languages:
+
+ python, perl, ruby, tcl
+
+
+
+
/* -----------------------------------------------------------------------------
* Internal typemap specializations
* ----------------------------------------------------------------------------- */
-enumint.swg enum especializations as int types
-inoutlist.swg return the OUTPUT types in a list
-misctypes.swg Miscellaneos types (size_t, ptrdiff_t, etc)
-primtypes.swg Macros to manage primitive types (shot,int,double,etc)
-ptrtypes.swg Typemaps for types with a 'ptr' behavior
-strings.swg String base typemaps
-cstring.swg Various forms of C character string handling
-swigobject.swg Language object, such as PyObject, Tcl_Obj, etc
-swigtype.swg SWIGTYPE
-valtypes.swg Typemaps for types with a 'by value' behavior
-void.swg void * typemaps
+
+carrays.swg Implement the carrays.i library
+cdata.swg Implement the cdata.i library
+cmalloc.swg Implement the cmalloc.i library
+cpointer.swg Implement the cpointer.i library
+cstring.swg Implement the cstring.i library typemaps for char *
+cwstring.swg Implement the cstring.i library typemaps for wchar_t *
+exception.swg Implement the exception.i library
implicit.swg Allow the use of implicit C++ constructors
+
+string.swg Typemaps for char * string
+wstring.swg Typemaps for wchar_t * string
+std_string.swg Typemaps for std::string
+std_wstring.swg Typemaps for std::wstring
+swigtype.swg Typemaps for the SWIGTYPE type
+void.swg Typemaps for the 'void' type
+enumint.swg Typemaps for enums treated as 'int'
+swigobject.swg Typemaps for the SWIG_Object as in PyObject, Tcl_Obj, etc.
+misctypes.swg Typemaps for miscellaneos types (size_t, ptrdiff_t, etc)
+ptrtypes.swg Typemaps for types with a 'ptr' behavior
+valtypes.swg Typemaps for 'by value' types
+inoutlist.swg IN/OUTPUT/INOUT typemaps, where the OUTPUT values are returned in a list
+primtypes.swg Common macros to manage primitive types (short,int,double,etc)
+
+cstrings.swg Common macros to implemented the cstring/cwstring libraries
+std_strings.swg Common macros to implemented the std::string/std::wstring typemaps
+strings.swg Common macros and typemaps for string and wstring (char *, wchar_t *)
+
+swigmacros.swg Basic macros
+fragments.swg Macros for fragment manipulations
+
+
+typemaps.swg The old typemaps.i library, not needed anymore
diff --git a/Lib/typemaps/carrays.swg b/Lib/typemaps/carrays.swg
index ad116f50a..2f0f2c9f1 100644
--- a/Lib/typemaps/carrays.swg
+++ b/Lib/typemaps/carrays.swg
@@ -25,11 +25,11 @@
%define %array_functions(TYPE,NAME)
%{
static TYPE *new_##NAME(size_t nelements) {
- return SWIG_new_array(nelements, TYPE);
+ return %new_array(nelements, TYPE);
}
static void delete_##NAME(TYPE *ary) {
- SWIG_delete_array(ary);
+ %delete_array(ary);
}
static TYPE NAME##_getitem(TYPE *ary, size_t index) {
@@ -82,11 +82,11 @@ typedef struct NAME {
%extend NAME {
NAME(size_t nelements) {
- return SWIG_new_array(nelements, TYPE);
+ return %new_array(nelements, TYPE);
}
~NAME() {
- SWIG_delete_array(self);
+ %delete_array(self);
}
TYPE getitem(size_t index) {
@@ -102,7 +102,7 @@ typedef struct NAME {
}
static NAME *frompointer(TYPE *t) {
- return SWIG_static_cast(t, NAME *);
+ return %static_cast(t, NAME *);
}
};
diff --git a/Lib/typemaps/cdata.swg b/Lib/typemaps/cdata.swg
index 349f34507..2eff94e11 100644
--- a/Lib/typemaps/cdata.swg
+++ b/Lib/typemaps/cdata.swg
@@ -20,7 +20,7 @@ typedef struct SWIGCDATA {
* ----------------------------------------------------------------------------- */
%typemap(out,noblock=1,fragment="SWIG_FromCharPtrAndSize") SWIGCDATA {
- $result = SWIG_FromCharPtrAndSize($1.data,$1.len);
+ %set_output(SWIG_FromCharPtrAndSize($1.data,$1.len));
}
%typemap(in) (const void *indata, int inlen) = (char *STRING, int SIZE);
diff --git a/Lib/typemaps/cpointer.swg b/Lib/typemaps/cpointer.swg
index bfd2d2a67..1737f4f14 100644
--- a/Lib/typemaps/cpointer.swg
+++ b/Lib/typemaps/cpointer.swg
@@ -55,10 +55,10 @@ typedef struct {
%extend NAME {
NAME() {
- return SWIG_new(TYPE);
+ return %new_instance(TYPE);
}
~NAME() {
- if (self) SWIG_delete(self);
+ if (self) %delete(self);
}
}
@@ -109,15 +109,15 @@ typedef struct {
%define %pointer_functions(TYPE,NAME)
%{
static TYPE *new_##NAME() {
- return SWIG_new(TYPE);
+ return %new_instance(TYPE);
}
static TYPE *copy_##NAME(TYPE value) {
- return SWIG_new_copy(value, TYPE);
+ return %new_copy(value, TYPE);
}
static void delete_##NAME(TYPE *self) {
- if (self) SWIG_delete(self);
+ if (self) %delete(self);
}
static void NAME ##_assign(TYPE *self, TYPE value) {
@@ -146,7 +146,7 @@ TYPE NAME##_value(TYPE *self);
%define %pointer_cast(TYPE1,TYPE2,NAME)
%inline %{
TYPE2 NAME(TYPE1 x) {
- return SWIG_static_cast(x, TYPE2);
+ return %static_cast(x, TYPE2);
}
%}
%enddef
diff --git a/Lib/typemaps/cstring.swg b/Lib/typemaps/cstring.swg
index 2bc9d0665..e774c4312 100644
--- a/Lib/typemaps/cstring.swg
+++ b/Lib/typemaps/cstring.swg
@@ -1,275 +1,9 @@
-/*
- * cstring.i
- * $Header$
- *
- * Author(s): David Beazley (beazley@cs.uchicago.edu)
- *
- * This file provides typemaps and macros for dealing with various forms
- * of C character string handling. The primary use of this module
- * is in returning character data that has been allocated or changed in
- * some way.
- */
-
-%define %typemap_cstrings(Name, Char,
- SWIG_AsCharPtr,
- SWIG_AsCharPtrAndSize,
- SWIG_FromCharPtr,
- SWIG_FromCharPtrAndSize)
-
-/* %cstring_input_binary(TYPEMAP, SIZE)
- *
- * Macro makes a function accept binary string data along with
- * a size. For example:
- *
- * %cstring_input_binary(Char *buff, int size);
- * void foo(Char *buff, int size) {
- * }
- *
- */
-
-%define Name ## _input_binary(TYPEMAP, SIZE)
-%typemap(in,noblock=1,fragment=#SWIG_AsCharPtrAndSize) (TYPEMAP, SIZE)
- (Char *buf = 0, size_t size = 0, int alloc = 0) {
- if (SWIG_AsCharPtrAndSize($input, &buf, &size, &alloc) != SWIG_OK) {
- SWIG_arg_fail(SWIG_TypeError, "(TYPEMAP, SIZE)", $argnum);
- }
- $1 = ($1_ltype) buf;
- $2 = ($2_ltype) size - 1;
-}
-%typemap(freearg,noblock=1) (TYPEMAP, SIZE) {
- if (alloc$argnum == SWIG_NEWOBJ) SWIG_delete_array(buf$argnum);
-}
-%enddef
-
-
-/*
- * %cstring_bounded_output(TYPEMAP, MAX)
- *
- * This macro is used to return a NULL-terminated output string of
- * some maximum length. For example:
- *
- * %cstring_bounded_output(Char *outx, 512);
- * void foo(Char *outx) {
- * sprintf(outx,"blah blah\n");
- * }
- *
- */
-
-%define Name ## _bounded_output(TYPEMAP,MAX)
-%typemap(in,noblock=1,numinputs=0) TYPEMAP (Char temp[MAX+1]) {
- $1 = ($1_ltype) temp;
-}
-%typemap(freearg,noblock=1) TYPEMAP "";
-%typemap(argout,noblock=1,fragment= #SWIG_FromCharPtr ) TYPEMAP {
- $1[MAX] = 0;
- SWIG_append_result(SWIG_FromCharPtr($1));
-}
-%enddef
-
-
-/*
- * %cstring_chunk_output(TYPEMAP, SIZE)
- *
- * This macro is used to return a chunk of binary string data.
- * Embedded NULLs are okay. For example:
- *
- * %cstring_chunk_output(Char *outx, 512);
- * void foo(Char *outx) {
- * memmove(outx, somedata, 512);
- * }
- *
- */
-
-%define Name ## _chunk_output(TYPEMAP,SIZE)
-%typemap(in,noblock=1,numinputs=0) TYPEMAP(Char temp[SIZE]) {
- $1 = ($1_ltype) temp;
-}
-%typemap(freearg,noblock=1) TYPEMAP "";
-%typemap(argout,noblock=1,fragment= #SWIG_FromCharPtrAndSize) TYPEMAP {
- SWIG_append_result(SWIG_FromCharPtrAndSize($1,SIZE));
-}
-%enddef
-
-
-/*
- * %cstring_bounded_mutable(TYPEMAP, SIZE)
- *
- * This macro is used to wrap a string that's going to mutate.
- *
- * %cstring_bounded_mutable(Char *in, 512);
- * void foo(in *x) {
- * while (*x) {
- * *x = toupper(*x);
- * x++;
- * }
- * }
- *
- */
-
-
-%define Name ## _bounded_mutable(TYPEMAP,MAX)
-%typemap(in,noblock=1,fragment=#SWIG_AsCharPtrAndSize) TYPEMAP
- (Char temp[MAX+1], Char *t = 0, size_t n = 0, int alloc = 0) {
- if (SWIG_AsCharPtrAndSize($input, &t, &n, &alloc) != SWIG_OK) {
- SWIG_arg_fail(SWIG_TypeError, "TYPEMAP", $argnum);
- }
- if ( n > (size_t) MAX ) n = (size_t) MAX;
- memcpy(temp, t, sizeof(Char)*n);
- if (alloc == SWIG_NEWOBJ) SWIG_delete_array(t);
- temp[n - 1] = 0;
- $1 = ($1_ltype) temp;
-}
-%typemap(freearg,noblock=1) TYPEMAP "";
-%typemap(argout,noblock=1,fragment=#SWIG_FromCharPtr) TYPEMAP {
- $1[MAX] = 0;
- SWIG_append_result(SWIG_FromCharPtr($1));
-}
-%enddef
-
-
-/*
- * %cstring_mutable(TYPEMAP [, expansion])
- *
- * This macro is used to wrap a string that will mutate in place.
- * It may change size up to a user-defined expansion.
- *
- * %cstring_mutable(Char *in);
- * void foo(in *x) {
- * while (*x) {
- * *x = toupper(*x);
- * x++;
- * }
- * }
- *
- */
-
-%define Name ## _mutable(TYPEMAP,EXP...)
-%typemap(in,noblock=1,fragment=#SWIG_AsCharPtrAndSize) TYPEMAP
- (Char* t = 0, size_t n = 0, int alloc = 0, size_t expansion = 0) {
-#if #EXP != ""
- expansion += EXP;
-#endif
- if (SWIG_AsCharPtrAndSize($input, &t, &n, &alloc) != SWIG_OK) {
- SWIG_arg_fail(SWIG_TypeError, "TYPEMAP", $argnum);
- }
- $1 = SWIG_new_array(n+expansion, $*1_ltype);
- memcpy($1,t,sizeof(Char)*n);
- if (alloc == SWIG_NEWOBJ) SWIG_delete_array(t);
- $1[n-1] = 0;
-}
-%typemap(freearg,noblock=1) TYPEMAP "";
-%typemap(argout,noblock=1,fragment=#SWIG_FromCharPtr) TYPEMAP {
- SWIG_append_result(SWIG_FromCharPtr($1));
- SWIG_delete_array($1);
-}
-%enddef
-
-/*
- * %cstring_output_maxsize(TYPEMAP, SIZE)
- *
- * This macro returns data in a string of some user-defined size.
- *
- * %cstring_output_maxsize(Char *outx, int max) {
- * void foo(Char *outx, int max) {
- * sprintf(outx,"blah blah\n");
- * }
- */
-
-%define Name ## _output_maxsize(TYPEMAP, SIZE)
-%typemap(in,noblock=1,fragment=SWIG_AsVal_frag(unsigned long)) (TYPEMAP, SIZE) (unsigned long size) {
- if (SWIG_AsVal(unsigned long)($input, &size) != SWIG_OK) {
- SWIG_arg_fail(SWIG_TypeError, "(TYPEMAP, SIZE)", $argnum);
- }
- $2 = SWIG_numeric_cast(size, $2_ltype);
- $1 = SWIG_new_array(size+1, $*1_ltype);
-}
-%typemap(argout,noblock=1,fragment=#SWIG_FromCharPtr) (TYPEMAP,SIZE) {
- SWIG_append_result(SWIG_FromCharPtr($1));
- SWIG_delete_array($1);
-}
-%enddef
-
-/*
- * %cstring_output_withsize(TYPEMAP, SIZE)
- *
- * This macro is used to return Character data along with a size
- * parameter.
- *
- * %cstring_output_maxsize(Char *outx, int *max) {
- * void foo(Char *outx, int *max) {
- * sprintf(outx,"blah blah\n");
- * *max = strlen(outx);
- * }
- */
-
-%define Name ## _output_withsize(TYPEMAP, SIZE)
-%typemap(in,noblock=1,fragment=SWIG_As_frag(unsigned long)) (TYPEMAP, SIZE) (unsigned long n) {
- if (SWIG_AsVal(unsigned long)($input, &n) != SWIG_OK) {
- SWIG_arg_fail(SWIG_TypeError, "(TYPEMAP, SIZE)", $argnum);
- }
- $1 = SWIG_new_array(n+1, $*1_ltype);
- $2 = SWIG_new($*2_ltype);
- *$2 = SWIG_numeric_cast(n, $*2_ltype);
-}
-%typemap(argout,noblock=1,fragment=#SWIG_FromCharPtrAndSize) (TYPEMAP,SIZE) {
- SWIG_append_result(SWIG_FromCharPtrAndSize($1,*$2));
- SWIG_delete_array($1);
- SWIG_delete($2);
-}
-%enddef
-
-
-/*
- * %cstring_output_allocate(TYPEMAP, RELEASE)
- *
- * This macro is used to return Character data that was
- * allocated with new or malloc.
- *
- * %cstring_output_allocated(Char **outx, free($1));
- * void foo(Char **outx) {
- * *outx = (Char *) malloc(512);
- * sprintf(outx,"blah blah\n");
- * }
- */
-
-%define Name ## _output_allocate(TYPEMAP, RELEASE)
-%typemap(in,noblock=1,numinputs=0) TYPEMAP($*1_ltype temp = 0) {
- $1 = &temp;
-}
-%typemap(argout,noblock=1,fragment=#SWIG_FromCharPtr) TYPEMAP {
- if (*$1) {
- SWIG_append_result(SWIG_FromCharPtr(*$1));
- RELEASE;
- }
-}
-%enddef
-
-
-/*
- * %cstring_output_allocate_size(TYPEMAP, SIZE, RELEASE)
- *
- * This macro is used to return Character data that was
- * allocated with new or malloc.
- *
- * %cstring_output_allocated(Char **outx, int *sz, free($1));
- * void foo(Char **outx, int *sz) {
- * *outx = (Char *) malloc(512);
- * sprintf(outx,"blah blah\n");
- * *sz = strlen(outx);
- * }
- */
-
-%define Name ## _output_allocate_size(TYPEMAP, SIZE, RELEASE)
-%typemap(in,noblock=1,numinputs=0) (TYPEMAP, SIZE) ($*1_ltype temp = 0, $*2_ltype tempn) {
- $1 = &temp; $2 = &tempn;
-}
-%typemap(argout,noblock=1,fragment=#SWIG_FromCharPtrAndSize)(TYPEMAP,SIZE) {
- if (*$1) {
- SWIG_append_result(SWIG_FromCharPtrAndSize(*$1,*$2));
- RELEASE;
- }
-}
-%enddef
-
-%enddef
+%include <typemaps/cstrings.swg>
+
+%typemaps_cstring(%cstring,
+ char,
+ SWIG_AsCharPtr,
+ SWIG_AsCharPtrAndSize,
+ SWIG_FromCharPtr,
+ SWIG_FromCharPtrAndSize);
diff --git a/Lib/typemaps/cstrings.swg b/Lib/typemaps/cstrings.swg
new file mode 100644
index 000000000..af59c5e50
--- /dev/null
+++ b/Lib/typemaps/cstrings.swg
@@ -0,0 +1,280 @@
+/*
+ * cstring.i
+ * $Header$
+ *
+ * Author(s): David Beazley (beazley@cs.uchicago.edu)
+ *
+ * This file provides typemaps and macros for dealing with various forms
+ * of C character string handling. The primary use of this module
+ * is in returning character data that has been allocated or changed in
+ * some way.
+ */
+
+%define %typemaps_cstring(Name, Char,
+ SWIG_AsCharPtr,
+ SWIG_AsCharPtrAndSize,
+ SWIG_FromCharPtr,
+ SWIG_FromCharPtrAndSize)
+
+
+/* %cstring_input_binary(TYPEMAP, SIZE)
+ *
+ * Macro makes a function accept binary string data along with
+ * a size. For example:
+ *
+ * %cstring_input_binary(Char *buff, int size);
+ * void foo(Char *buff, int size) {
+ * }
+ *
+ */
+
+%define Name ## _input_binary(TYPEMAP, SIZE)
+%typemap(in,noblock=1,fragment=#SWIG_AsCharPtrAndSize) (TYPEMAP, SIZE)
+ (Char *buf = 0, size_t size = 0, int alloc = 0) {
+ if (SWIG_AsCharPtrAndSize($input, &buf, &size, &alloc) != SWIG_OK) {
+ %argument_fail(SWIG_TypeError, "(TYPEMAP, SIZE)", $argnum);
+ }
+ $1 = ($1_ltype) buf;
+ $2 = ($2_ltype) size - 1;
+}
+%typemap(freearg,noblock=1) (TYPEMAP, SIZE) {
+ if (alloc$argnum == SWIG_NEWOBJ) %delete_array(buf$argnum);
+}
+%enddef
+
+
+
+/*
+ * %cstring_bounded_output(TYPEMAP, MAX)
+ *
+ * This macro is used to return a NULL-terminated output string of
+ * some maximum length. For example:
+ *
+ * %cstring_bounded_output(Char *outx, 512);
+ * void foo(Char *outx) {
+ * sprintf(outx,"blah blah\n");
+ * }
+ *
+ */
+
+%define Name ## _bounded_output(TYPEMAP,MAX)
+%typemap(in,noblock=1,numinputs=0) TYPEMAP (Char temp[MAX+1]) {
+ $1 = ($1_ltype) temp;
+}
+%typemap(freearg,noblock=1) TYPEMAP "";
+%typemap(argout,noblock=1,fragment= #SWIG_FromCharPtr ) TYPEMAP {
+ $1[MAX] = 0;
+ %append_output(SWIG_FromCharPtr($1));
+}
+%enddef
+
+
+
+/*
+ * %cstring_chunk_output(TYPEMAP, SIZE)
+ *
+ * This macro is used to return a chunk of binary string data.
+ * Embedded NULLs are okay. For example:
+ *
+ * %cstring_chunk_output(Char *outx, 512);
+ * void foo(Char *outx) {
+ * memmove(outx, somedata, 512);
+ * }
+ *
+ */
+
+%define Name ## _chunk_output(TYPEMAP,SIZE)
+%typemap(in,noblock=1,numinputs=0) TYPEMAP(Char temp[SIZE]) {
+ $1 = ($1_ltype) temp;
+}
+%typemap(freearg,noblock=1) TYPEMAP "";
+%typemap(argout,noblock=1,fragment= #SWIG_FromCharPtrAndSize) TYPEMAP {
+ %append_output(SWIG_FromCharPtrAndSize($1,SIZE));
+}
+%enddef
+
+
+
+/*
+ * %cstring_bounded_mutable(TYPEMAP, SIZE)
+ *
+ * This macro is used to wrap a string that's going to mutate.
+ *
+ * %cstring_bounded_mutable(Char *in, 512);
+ * void foo(in *x) {
+ * while (*x) {
+ * *x = toupper(*x);
+ * x++;
+ * }
+ * }
+ *
+ */
+
+
+%define Name ## _bounded_mutable(TYPEMAP,MAX)
+%typemap(in,noblock=1,fragment=#SWIG_AsCharPtrAndSize) TYPEMAP
+ (Char temp[MAX+1], Char *t = 0, size_t n = 0, int alloc = 0) {
+ if (SWIG_AsCharPtrAndSize($input, &t, &n, &alloc) != SWIG_OK) {
+ %argument_fail(SWIG_TypeError, "TYPEMAP", $argnum);
+ }
+ if ( n > (size_t) MAX ) n = (size_t) MAX;
+ memcpy(temp, t, sizeof(Char)*n);
+ if (alloc == SWIG_NEWOBJ) %delete_array(t);
+ temp[n - 1] = 0;
+ $1 = ($1_ltype) temp;
+}
+%typemap(freearg,noblock=1) TYPEMAP "";
+%typemap(argout,noblock=1,fragment=#SWIG_FromCharPtr) TYPEMAP {
+ $1[MAX] = 0;
+ %append_output(SWIG_FromCharPtr($1));
+}
+%enddef
+
+
+/*
+ * %cstring_mutable(TYPEMAP [, expansion])
+ *
+ * This macro is used to wrap a string that will mutate in place.
+ * It may change size up to a user-defined expansion.
+ *
+ * %cstring_mutable(Char *in);
+ * void foo(in *x) {
+ * while (*x) {
+ * *x = toupper(*x);
+ * x++;
+ * }
+ * }
+ *
+ */
+
+%define Name ## _mutable(TYPEMAP,EXP...)
+%typemap(in,noblock=1,fragment=#SWIG_AsCharPtrAndSize) TYPEMAP
+ (Char* t = 0, size_t n = 0, int alloc = 0, size_t expansion = 0) {
+#if #EXP != ""
+ expansion += EXP;
+#endif
+ if (SWIG_AsCharPtrAndSize($input, &t, &n, &alloc) != SWIG_OK) {
+ %argument_fail(SWIG_TypeError, "TYPEMAP", $argnum);
+ }
+ $1 = %new_array(n+expansion, $*1_ltype);
+ memcpy($1,t,sizeof(Char)*n);
+ if (alloc == SWIG_NEWOBJ) %delete_array(t);
+ $1[n-1] = 0;
+}
+%typemap(freearg,noblock=1) TYPEMAP "";
+%typemap(argout,noblock=1,fragment=#SWIG_FromCharPtr) TYPEMAP {
+ %append_output(SWIG_FromCharPtr($1));
+ %delete_array($1);
+}
+%enddef
+
+
+/*
+ * %cstring_output_maxsize(TYPEMAP, SIZE)
+ *
+ * This macro returns data in a string of some user-defined size.
+ *
+ * %cstring_output_maxsize(Char *outx, int max) {
+ * void foo(Char *outx, int max) {
+ * sprintf(outx,"blah blah\n");
+ * }
+ */
+
+%define Name ## _output_maxsize(TYPEMAP, SIZE)
+%typemap(in,noblock=1,fragment=SWIG_AsVal_frag(unsigned long)) (TYPEMAP, SIZE) (unsigned long size) {
+ if (SWIG_AsVal(unsigned long)($input, &size) != SWIG_OK) {
+ %argument_fail(SWIG_TypeError, "(TYPEMAP, SIZE)", $argnum);
+ }
+ $2 = %numeric_cast(size, $2_ltype);
+ $1 = %new_array(size+1, $*1_ltype);
+}
+%typemap(argout,noblock=1,fragment=#SWIG_FromCharPtr) (TYPEMAP,SIZE) {
+ %append_output(SWIG_FromCharPtr($1));
+ %delete_array($1);
+}
+%enddef
+
+/*
+ * %cstring_output_withsize(TYPEMAP, SIZE)
+ *
+ * This macro is used to return Character data along with a size
+ * parameter.
+ *
+ * %cstring_output_maxsize(Char *outx, int *max) {
+ * void foo(Char *outx, int *max) {
+ * sprintf(outx,"blah blah\n");
+ * *max = strlen(outx);
+ * }
+ */
+
+%define Name ## _output_withsize(TYPEMAP, SIZE)
+%typemap(in,noblock=1,fragment=SWIG_AsVal_frag(unsigned long)) (TYPEMAP, SIZE) (unsigned long n) {
+ if (SWIG_AsVal(unsigned long)($input, &n) != SWIG_OK) {
+ %argument_fail(SWIG_TypeError, "(TYPEMAP, SIZE)", $argnum);
+ }
+ $1 = %new_array(n+1, $*1_ltype);
+ $2 = %new_instance($*2_ltype);
+ *$2 = %numeric_cast(n, $*2_ltype);
+}
+%typemap(argout,noblock=1,fragment=#SWIG_FromCharPtrAndSize) (TYPEMAP,SIZE) {
+ %append_output(SWIG_FromCharPtrAndSize($1,*$2));
+ %delete_array($1);
+ %delete($2);
+}
+%enddef
+
+
+/*
+ * %cstring_output_allocate(TYPEMAP, RELEASE)
+ *
+ * This macro is used to return Character data that was
+ * allocated with new or malloc.
+ *
+ * %cstring_output_allocated(Char **outx, free($1));
+ * void foo(Char **outx) {
+ * *outx = (Char *) malloc(512);
+ * sprintf(outx,"blah blah\n");
+ * }
+ */
+
+%define Name ## _output_allocate(TYPEMAP, RELEASE)
+%typemap(in,noblock=1,numinputs=0) TYPEMAP($*1_ltype temp = 0) {
+ $1 = &temp;
+}
+%typemap(argout,noblock=1,fragment=#SWIG_FromCharPtr) TYPEMAP {
+ if (*$1) {
+ %append_output(SWIG_FromCharPtr(*$1));
+ RELEASE;
+ }
+}
+%enddef
+
+
+/*
+ * %cstring_output_allocate_size(TYPEMAP, SIZE, RELEASE)
+ *
+ * This macro is used to return Character data that was
+ * allocated with new or malloc.
+ *
+ * %cstring_output_allocated(Char **outx, int *sz, free($1));
+ * void foo(Char **outx, int *sz) {
+ * *outx = (Char *) malloc(512);
+ * sprintf(outx,"blah blah\n");
+ * *sz = strlen(outx);
+ * }
+ */
+
+%define Name ## _output_allocate_size(TYPEMAP, SIZE, RELEASE)
+%typemap(in,noblock=1,numinputs=0) (TYPEMAP, SIZE) ($*1_ltype temp = 0, $*2_ltype tempn) {
+ $1 = &temp; $2 = &tempn;
+}
+%typemap(argout,noblock=1,fragment=#SWIG_FromCharPtrAndSize)(TYPEMAP,SIZE) {
+ if (*$1) {
+ %append_output(SWIG_FromCharPtrAndSize(*$1,*$2));
+ RELEASE;
+ }
+}
+%enddef
+
+%enddef
+
diff --git a/Lib/typemaps/cwstring.swg b/Lib/typemaps/cwstring.swg
new file mode 100644
index 000000000..933f9a3a6
--- /dev/null
+++ b/Lib/typemaps/cwstring.swg
@@ -0,0 +1,10 @@
+%include <typemaps/cstrings.swg>
+%include <typemaps/wstring.swg>
+
+%typemaps_cstring(%cwstring,
+ wchar_t,
+ SWIG_AsWCharPtr,
+ SWIG_AsWCharPtrAndSize,
+ SWIG_FromWCharPtr,
+ SWIG_FromWCharPtrAndSize);
+
diff --git a/Lib/typemaps/enumint.swg b/Lib/typemaps/enumint.swg
index f18d196ca..a76b664a8 100644
--- a/Lib/typemaps/enumint.swg
+++ b/Lib/typemaps/enumint.swg
@@ -8,20 +8,20 @@
%typemap(in,fragment=SWIG_AsVal_frag(int),noblock=1) const enum SWIGTYPE& (int val, int ecode, $basetype temp) {
ecode = SWIG_AsVal(int)($input, &val);
if (ecode != SWIG_OK) {
- SWIG_arg_fail(ecode, "$basetype", $argnum);
+ %argument_fail(ecode, "$type", $argnum);
} else {
- temp = SWIG_static_cast(val,$basetype);
+ temp = %static_cast(val,$basetype);
$1 = &temp;
}
}
%typemap(varin,fragment=SWIG_AsVal_frag(int),noblock=1) enum SWIGTYPE {
if (sizeof(int) != sizeof($1)) {
- SWIG_var_fail(SWIG_AttributeError,"$type", "$name");
+ %variable_fail(SWIG_AttributeError,"$type", "arch, read-only $name");
} else {
- int ecode = SWIG_AsVal(int)($input, SWIG_reinterpret_cast(&$1,int*));
+ int ecode = SWIG_AsVal(int)($input, %reinterpret_cast(&$1,int*));
if (ecode != SWIG_OK) {
- SWIG_var_fail(ecode, "$type", "$name");
+ %variable_fail(ecode, "$type", "$name");
}
}
}
@@ -29,18 +29,18 @@
/*
typemaps needed due to unnamed enums
*/
-%define SWIG_ENUM_OUT_TYPEMAPS(from_meth,frag)
+%define %enum_out_typemaps(from_meth,frag)
%typemap(out,noblock=1,fragment=frag) enum SWIGTYPE {
- $result = from_meth(($1));
+ %set_output(from_meth(($1)));
}
%typemap(out,noblock=1,fragment=frag) const enum SWIGTYPE& {
- $result = from_meth((*$1));
+ %set_output(from_meth((*$1)));
}
%typemap(varout,noblock=1,fragment=frag) enum SWIGTYPE, const enum SWIGTYPE& {
- $result = from_meth($1);
+ %set_varoutput(from_meth($1));
}
%typemap(constcode,noblock=1,fragment=frag) enum SWIGTYPE {
- SWIG_set_constant("$symname", from_meth($value));
+ %set_constant("$symname", from_meth($value));
}
%typemap(directorin,noblock=1,fragment=frag) enum SWIGTYPE *DIRECTORIN {
$input = from_meth(*$1_name);
@@ -49,11 +49,11 @@
$input = from_meth($1_name);
}
%typemap(throws,noblock=1,fragment=frag) enum SWIGTYPE {
- SWIG_raise(from_meth($1),"$type",0);
+ %raise(from_meth($1),"$type",0);
}
%enddef
-SWIG_ENUM_OUT_TYPEMAPS(SWIG_From(int),SWIG_From_frag(int));
+%enum_out_typemaps(SWIG_From(int),SWIG_From_frag(int));
diff --git a/Lib/typemaps/exception.swg b/Lib/typemaps/exception.swg
index 781f74f58..c7b6b1c23 100644
--- a/Lib/typemaps/exception.swg
+++ b/Lib/typemaps/exception.swg
@@ -1,13 +1,29 @@
// This SWIG library file provides language independent exception handling
%include <typemaps/swigmacros.swg>
+
+/* macros for error manipulation */
+#define %nullref_fmt() "invalid null reference "
+#define %varfail_fmt(_type,_name) "in variable '"_name"' of type '"_type"'"
+#define %argfail_fmt(_type,_argn) "in argument " #_argn" of type '" _type"'"
+#define %outfail_fmt(_type) "in output value of type '"_type"'"
+#define %argnullref_fmt(_type, _argn) %nullref_fmt() %argfail_fmt(_type, _argn)
+#define %varnullref_fmt(_type, _name) %nullref_fmt() %varfail_fmt(_type, _name)
+#define %outnullref_fmt(_type) %nullref_fmt() %outfail_fmt(_type)
+
+/* setting an error */
+#define %error(code,msg...) SWIG_Error(code, msg)
+#define %type_error(msg...) SWIG_Error(SWIG_TypeError, msg)
+
+
+
%insert("runtime") {
- SWIG_define(SWIG_exception(code, msg),
- SWIG_block(SWIG_error(code, msg); SWIG_fail))
+ %define_as(SWIG_exception(code, msg),
+ %block(%error(code, msg); SWIG_fail))
- SWIG_define(SWIG_contract_assert(expr, msg),
- if (!(expr)) { SWIG_error(SWIG_RuntimeError, msg); SWIG_fail; } else)
+ %define_as(SWIG_contract_assert(expr, msg),
+ if (!(expr)) { %error(SWIG_RuntimeError, msg); SWIG_fail; } else)
}
diff --git a/Lib/typemaps/fragmacros.swg b/Lib/typemaps/fragmacros.swg
new file mode 100644
index 000000000..98b27221a
--- /dev/null
+++ b/Lib/typemaps/fragmacros.swg
@@ -0,0 +1,143 @@
+/*
+ Special macros to define and use fragment names and declarations.
+
+ These macros generate the names used in fragments, for example, a
+ typical use will be:
+
+ %fragment(SWIG_From_frag(bool),"header") {
+ SWIGINTERNINLINE PyObject*
+ SWIG_From_dec(bool)(bool value)
+ {
+ PyObject *obj = value ? Py_True : Py_False;
+ Py_INCREF(obj);
+ return obj;
+ }
+ }
+
+ and then you can call the method using
+
+ %typemap(out,fragment=SWIG_From_frag(bool)) bool {
+ %set_output(SWIG_From(bool)($1));
+ }
+
+ when the typemap get generated, the proper fragment for the
+ SWIG_From(bool) method will be included.
+
+ */
+
+
+
+#define SWIG_Traits_frag(Type...) %string_type(Traits, Type)
+#define SWIG_AsPtr_frag(Type...) %string_type(AsPtr, Type)
+#define SWIG_AsVal_frag(Type...) %string_type(AsVal, Type)
+#define SWIG_From_frag(Type...) %string_type(From, Type)
+
+
+#ifndef SWIG_ASVAL_DECL_ARGS
+#define SWIG_ASVAL_DECL_ARGS
+#endif
+
+#ifndef SWIG_ASPTR_DECL_ARGS
+#define SWIG_ASPTR_DECL_ARGS
+#endif
+
+#ifndef SWIG_FROM_DECL_ARGS
+#define SWIG_FROM_DECL_ARGS
+#endif
+
+#ifndef SWIG_ASVAL_CALL_ARGS
+#define SWIG_ASVAL_CALL_ARGS
+#endif
+
+#ifndef SWIG_ASPTR_CALL_ARGS
+#define SWIG_ASPTR_CALL_ARGS
+#endif
+
+#ifndef SWIG_FROM_CALL_ARGS
+#define SWIG_FROM_CALL_ARGS
+#endif
+
+
+#define SWIG_AsVal_dec(Type...) %name_type(AsVal, Type) SWIG_ASVAL_DECL_ARGS
+#define SWIG_AsPtr_dec(Type...) %name_type(AsPtr, Type) SWIG_ASPTR_DECL_ARGS
+#define SWIG_From_dec(Type...) %name_type(From, Type) SWIG_FROM_DECL_ARGS
+
+#define SWIG_AsVal(Type...) %name_type(AsVal, Type) SWIG_ASVAL_CALL_ARGS
+#define SWIG_AsPtr(Type...) %name_type(AsPtr, Type) SWIG_ASPTR_CALL_ARGS
+#define SWIG_From(Type...) %name_type(From, Type) SWIG_FROM_CALL_ARGS
+
+
+
+
+/* ------------------------------------------------------------
+ * common macro helpers
+ * ------------------------------------------------------------ */
+
+
+/* Macros for numeric types */
+
+%define %numeric_type_from(Type, Base)
+%fragment(SWIG_From_frag(Type),"header",
+ fragment=SWIG_From_frag(Base)) {
+SWIGINTERNINLINE SWIG_Object
+SWIG_From_dec(Type)(Type value)
+{
+ return SWIG_From(Base)(value);
+}
+}
+%enddef
+
+%define %numeric_type_asval(Type, Base, Frag, OverflowCond)
+%fragment(SWIG_AsVal_frag(Type),"header",
+ fragment=Frag,
+ fragment=SWIG_AsVal_frag(Base)) {
+SWIGINTERN int
+SWIG_AsVal_dec(Type)(SWIG_Object obj, Type *val)
+{
+ Base v;
+ int res = SWIG_AsVal(Base)(obj, &v);
+ if (res == SWIG_OK) {
+ if (OverflowCond) {
+ return SWIG_OverflowError;
+ } else {
+ if (val) *val = %numeric_cast(v, Type);
+ return SWIG_OK;
+ }
+ }
+ return res;
+}
+}
+%enddef
+
+%define %numeric_signed_type_asval(Type, Base, Frag, Min, Max)
+%numeric_type_asval(Type, Base, Frag, (v < Min || v > Max))
+%enddef
+
+%define %numeric_unsigned_type_asval(Type, Base, Frag, Max)
+%numeric_type_asval(Type, Base, Frag, (v > Max))
+%enddef
+
+
+/* Macro for 'signed long' derived types */
+
+%define %numeric_slong(Type, Frag, Min, Max)
+%numeric_type_from(Type, long)
+%numeric_signed_type_asval(Type, long, Frag , Min, Max)
+%enddef
+
+/* Macro for 'unsigned long' derived types */
+
+%define %numeric_ulong(Type, Frag, Max)
+%numeric_type_from(Type, unsigned long)
+%numeric_unsigned_type_asval(Type, unsigned long, Frag, Max)
+%enddef
+
+
+/* Macro for 'double' derived types */
+
+%define %numeric_double(Type, Frag, Min, Max)
+%numeric_type_from(Type, double)
+%numeric_signed_type_asval(Type, double, Frag , Min, Max)
+%enddef
+
+
diff --git a/Lib/typemaps/fragments.swg b/Lib/typemaps/fragments.swg
new file mode 100644
index 000000000..1e42b5ceb
--- /dev/null
+++ b/Lib/typemaps/fragments.swg
@@ -0,0 +1,289 @@
+/*
+ Fragments:
+ ==========
+
+ Second to typemaps, fragments is one the most powerfull and
+ dangerous swig feature. So, if you are starting to read about them,
+ make sure you read all the document.
+
+ Basics:
+ =======
+
+ Fragments provide a way to include or generate code into "on-demand"
+ as the typemaps could require.
+
+ For example, if you have a very long typemap
+
+ %typemap(in) MyClass * {
+ MyClass *value = 0;
+
+ <very long typemap>
+ ....
+ value = somewhere_converted_from_input_object_here($input);
+ ...
+ <very long typemap>
+
+ $result = value;
+ }
+
+ very soon you will discoverd yourself copying the same long
+ conversion code in several typemaps, such as varin, directorout,
+ etc. Also, you wil discover that swig copy verbatim the same very
+ long conversion code for every argument that requires it, making the
+ code very large too.
+
+ To eliminate this automatic or manual code copying, we define a
+ fragment that includes the common conversion code:
+
+ %fragment("AsMyClass","header") {
+ MyClass *AsMyClass(PyObject *obj) {
+ MyClass *value = 0;
+ <very long conversion>
+ ....
+ value = somewhere_converted_from_input_object_here(obj);
+ ...
+ <very long conversion>
+
+ return value;
+ }
+ }
+
+ %typemap(in,fragment="AsMyClass") MyClass * {
+ $result = AsMyClass($input);
+ }
+
+ %typemap(varin,fragment="AsMyClass") MyClass * {
+ $result = AsMyClass($input);
+ }
+
+ When the 'in' or 'varin' typemaps for MyClass are invoked, the
+ fragment "AsMyClass" is added to the "header" section, and then the
+ typemap code is emitted. Hence, the method AsMyClass will be
+ included in the wrapping code and it will be available at the time
+ the typemap is applied.
+
+ To define a fragment then you need a name, a section where it goes,
+ and the code. Usually the section refers to the "header" part, and
+ both string and braces forms are accepted, ie:
+
+ %fragment("my_name","header") { ... }
+ %fragment("my_name","header") "...";
+
+ To ensure all the fragment/typemap engine works as expected, there
+ are some rules that fragments follow:
+
+ 1.- A fragment is added to the wrapping code only once, ie, for the
+ method:
+
+ int foo(MyClass *a, MyClass *b);
+
+ the wrapped code will look as much as:
+
+ MyClass *AsMyClass(PyObject *obj) {
+ .....
+ }
+
+ int _wrap_foo(...) {
+ ....
+ arg1 = AsMyClass(obj1);
+ arg2 = AsMyClass(obj2);
+ ...
+ result = foo(arg1, arg2);
+ }
+
+
+ even when there will be duplicated typemap to process 'a' and
+ 'b', the 'AsMyClass' method will be defined only once.
+
+
+ 2.- A fragment can only defined once, and the first definition
+ is the only one taking in account. All other definitions of the
+ same fragments are silently ignored. For example, you can have
+
+
+ %fragment("AsMyClass","header") { <definition 1> }
+ ....
+ %fragment("AsMyClass","header") { <definition 2> }
+
+ and then only the first definition is considered. In this way
+ you can change the 'system' fragments by including yours first.
+
+ Note that this behavior is opposite to the typemaps, where the
+ last typemap applied or defined prevails. Fragment follows the
+ first-in-first-out convention since they are intended to be
+ "global", while typemaps intend to be "locally" specialyzed.
+
+ 3.- Fragments names can not contain commas.
+
+
+ A fragment can include one or more additional fragments, for example:
+
+ %fragment("<limits.h>", "header") {
+ #include <limits.h>
+ }
+
+
+ %fragment("AsMyClass", "header", fragment="<limits.h>") {
+ MyClass *AsMyClass(PyObject *obj) {
+ MyClass *value = 0;
+ int ival = somewhere_converted_from_input_object_here(obj)
+ ...
+ if (ival < CHAR_MIN) {
+ value = something_from_ival(ival);
+ } else {
+ ...
+ }
+ ...
+ return value;
+ }
+ }
+
+ in this case, when the "AsMyClass" fragment is emitted, it also
+ trigger the inclusion of the "<limits.h>" fragment.
+
+ You can add as many fragments as you want, for example
+
+ %fragment("bigfragment","header", fragment="frag1", fragment="frag2", fragment="frag3") "";
+
+ here, when the "bigfragment" is included, the three fragments "frag1",
+ "frag2" and "frag3" are included. Note that as "bigframent" is defined
+ empty, "", it does not add any code by itself, buy only trigger the
+ inclusion of the other fragments.
+
+ In a typemap you can also include more than one fragment, but since the
+ syntax is different, you need to specify them in a 'comma separated'
+ list, for example, considering the previous example:
+
+ %typemap(in,fragment="frag1,frag2,frag3") {...}
+
+ is equivalent to
+
+ %typemap(in,fragment="bigfragment") {...}
+
+
+ Fragment type specialization
+ ============================
+
+ Fragments can be "type specialized". The syntax is as follows
+
+ %fragment("name","header") { a type independent fragment }
+ %fragment("name" {Type}, "header") {typethe dependent fragment }
+
+ and they can also, as typemaps, be used inside templates, for exampe:
+
+ template <class T>
+ struct A {
+ %fragment("incode"{A<T>},"header") {
+ 'incode' specialized fragment
+ }
+
+ %typemap(in,fragment="incode"{A<T>}) {
+ here we use the 'type specialized'
+ fragment "incode"{A<T>}
+ }
+ };
+
+ which could seems a not much interesting feature, but is
+ fundamental for automatic typemap and template specialization.
+
+
+ Fragments and automatic typemap specialozation:
+ ===============================================
+
+ Since fragments can be type specialized, they can be elegantly used
+ to specialized typemaps .
+
+ For example, if you have something like:
+
+ %fragment("incode"{float}, "header") {
+ float in_mehtod_float(PyObject *obj) {
+ ...
+ }
+ }
+
+ %fragment("incode"{long}, "header") {
+ float in_mehtod_long(PyObject *obj) {
+ ...
+ }
+ }
+
+ %define %my_typemaps(Type)
+ %typemaps(in,fragment="incode"{Type}) {
+ value = in_method_##Type(obj);
+ }
+ %enddef
+
+ %my_typemaps(float);
+ %my_typemaps(long);
+
+ then the proper "incode"{float,double} fragment will be included,
+ and the proper in_method_{float,double} will be called.
+
+ Since this is a recurrent fragmen use, we provide a couple of
+ macros that make the automatic generation of typemaps easier:
+
+
+ Consider for example the following code:
+
+ %fragment(SWIG_From_frag(bool),"header") {
+ static PyObject*
+ SWIG_From_dec(bool)(bool value)
+ {
+ PyObject *obj = value ? Py_True : Py_False;
+ Py_INCREF(obj);
+ return obj;
+ }
+ }
+
+ %typemap(out,fragment=SWIG_From_frag(bool)) bool {
+ $result = SWIG_From(bool)($1));
+ }
+
+ Here the macros
+
+ SWIG_From_frag => fragment
+ SWIG_From_dec => declaration
+ SWIG_From => call
+
+ allow you to define/include a fragment, and declare and call the
+ 'from-bool' method as needed. In the simpler case, these macros
+ just return something like
+
+ SWIG_From_frag(bool) => "SWIG_From_bool"
+ SWIG_From_dec(bool) => SWIG_From_bool
+ SWIG_From(bool) => SWIG_From_bool
+
+ But they are specialized for the different languages requirements,
+ such as perl or tcl that requires passing the interpreter pointer,
+ and also they can manage C++ ugly types, for example:
+
+ SWIG_From_frag(std::complex<double>) => "SWIG_From_std_complex_Sl_double_Sg_"
+ SWIG_From_dec(std::complex<double>) => SWIG_From_std_complex_Sl_double_Sg_
+ SWIG_From(std::complex<double>) => SWIG_From_std_complex_Sl_double_Sg_
+
+
+ Hence, to declare methods to use with typemaps, always use the
+ SWIG_From* macros. In the same way, the SWIG_AsVal* and SWIG_AsPtr*
+ set of macros are provided.
+
+*/
+
+
+/* ------------------------------------------------------------
+ * common fragments
+ * ------------------------------------------------------------ */
+
+
+%fragment("<limits.h>","header") %{
+#include <limits.h>
+%}
+
+%fragment("<wchar.h>","header") %{
+#include <wchar.h>
+%}
+
+%fragment("<float.h>","header") %{
+#include <float.h>
+%}
+
+
diff --git a/Lib/typemaps/implicit.swg b/Lib/typemaps/implicit.swg
index 6025a1962..5997c5b44 100644
--- a/Lib/typemaps/implicit.swg
+++ b/Lib/typemaps/implicit.swg
@@ -33,12 +33,10 @@
The plain implicit macro takes care of simple type list. If it doesn't
work because you are passing template types with commas, then use
- the %implicit_{1,2,3} versions and/or the SWIG_arg macro.
+ the %implicit_{1,2,3} versions and/or the %arg macro.
*/
-%check_swig_object()
-
%define %implicit_type(Type...)
%traits_swigtype(Type);
%enddef
@@ -49,7 +47,7 @@
if (swig::asval<Type >(obj, 0) == SWIG_OK) {
Type _v;
swig::asval<Type >(obj, &_v);
- if (val) *val = new value_type(_v);
+ if (val) *val = %new_copy(_v, value_type);
return SWIG_NEWOBJ;
}
%enddef
@@ -86,7 +84,7 @@ namespace swig {
}
%}
-%typemap_traits_ptr(SWIG_CCode(POINTER),Type);
+%typemap_traits_ptr(%checkcode(POINTER),Type);
%enddef
/* implicit_1 */
@@ -121,7 +119,7 @@ namespace swig {
}
%}
-%typemap_traits_ptr(SWIG_CCode(POINTER),Type);
+%typemap_traits_ptr(%checkcode(POINTER),Type);
%enddef
@@ -159,7 +157,7 @@ namespace swig {
}
%}
-%typemap_traits_ptr(SWIG_CCode(POINTER),Type);
+%typemap_traits_ptr(%checkcode(POINTER),Type);
%enddef
@@ -200,5 +198,5 @@ namespace swig {
}
%}
-%typemap_traits_ptr(SWIG_CCode(POINTER),Type);
+%typemap_traits_ptr(%checkcode(POINTER),Type);
%enddef
diff --git a/Lib/typemaps/inoutlist.swg b/Lib/typemaps/inoutlist.swg
index df35f3898..afee057ed 100644
--- a/Lib/typemaps/inoutlist.swg
+++ b/Lib/typemaps/inoutlist.swg
@@ -3,34 +3,29 @@
* Define the IN/OUTPUT typemaps assuming the output parameters are
* returned in a list, i.e., they are not directly modified.
*
- * The user should provide the SWIG_append_result(result, obj) method,
+ * The user should provide the %append_output(result, obj) method,
* via a macro, which append a particular object to the result.
*
*
* In Tcl, for example, the file is used as:
*
- * #define SWIG_append_result(obj) Tcl_ListObjAppendElement(interp,Tcl_GetObjResult(interp),obj);
+ * #define %append_output(obj) Tcl_ListObjAppendElement(interp,Tcl_GetObjResult(interp),obj);
* %include <typemaps/inoutlist.swg>
*
* while in Python it is used as:
*
- * #define SWIG_append_result(obj) $result = SWIG_Python_AppendResult($result, obj)
+ * #define %append_output(obj) $result = SWIG_Python_AppendResult($result, obj)
* %include <typemaps/inoutlist.swg>
*
* where the method SWIG_Python_AppendResult is defined inside the
- * SWIG_append_result fragment.
+ * %append_output fragment.
*
- * If you forget to define SWIG_append_result, this file will generate
+ * If you forget to define %append_output, this file will generate
* an error.
*
* ------------------------------------------------------------ */
-#ifndef SWIG_append_result
-#error Undefined Method SWIG_append_result: used in the OUTPUT typemaps
-#endif
-
-
//
// Uncomment the following definition if you don't want the in/out
// typemaps by default, ie, you prefer to use typemaps.i.
@@ -76,60 +71,60 @@ or you can use the %apply directive :
*/
#ifdef SWIG_INPUT_ACCEPT_PTRS
-#define SWIG_CheckInputPtr(input,arg,desc,disown) (SWIG_ConvertPtr(input,SWIG_as_voidptrptr(arg),desc,disown) == SWIG_OK)
+#define %check_input_ptr(input,arg,desc,disown) (SWIG_ConvertPtr(input,%as_voidptrptr(arg),desc,disown) == SWIG_OK)
#else
-#define SWIG_CheckInputPtr(input,arg,desc,disown) (0)
+#define %check_input_ptr(input,arg,desc,disown) (0)
#endif
-%define _SWIG_VALUE_INPUT_TYPEMAP(code, asval_meth, asval_frag, Type)
+%define %_value_input_typemap(code, asval_meth, asval_frag, Type)
%typemap(in,noblock=1,fragment=asval_frag) Type *INPUT ($*ltype temp, int res = 0) {
- if (!SWIG_CheckInputPtr($input,&$1,$descriptor,$disown)) {
+ if (!%check_input_ptr($input,&$1,$descriptor,$disown)) {
Type val;
int ecode = asval_meth($input, &val);
if (ecode != SWIG_OK) {
- SWIG_arg_fail(ecode, "$*ltype",$argnum);
+ %argument_fail(ecode, "$*ltype",$argnum);
}
- temp = SWIG_static_cast(val, $*ltype);
+ temp = %static_cast(val, $*ltype);
$1 = &temp;
res = SWIG_NEWOBJ;
}
}
%typemap(in,noblock=1,fragment=asval_frag) Type &INPUT($*ltype temp, int res = 0) {
- if (!SWIG_CheckInputPtr($input,&$1,$descriptor,$disown)) {
+ if (!%check_input_ptr($input,&$1,$descriptor,$disown)) {
Type val;
int ecode = asval_meth($input, &val);
if (ecode != SWIG_OK) {
- SWIG_arg_fail(ecode, "$*ltype",$argnum);
+ %argument_fail(ecode, "$*ltype",$argnum);
}
- temp = SWIG_static_cast(val, $*ltype);
+ temp = %static_cast(val, $*ltype);
$1 = &temp;
res = SWIG_NEWOBJ;
}
}
%typemap(typecheck,noblock=1,precedence=code,fragment=asval_frag) Type *INPUT, Type &INPUT {
void *ptr;
- $1 = ((asval_meth($input, 0) == SWIG_OK) || (SWIG_CheckInputPtr($input,&ptr,$1_descriptor,0)));
+ $1 = ((asval_meth($input, 0) == SWIG_OK) || (%check_input_ptr($input,&ptr,$1_descriptor,0)));
}
%enddef
-%define _SWIG_PTR_INPUT_TYPEMAP(code,asptr_meth,asptr_frag,Type)
+%define %_ptr_input_typemap(code,asptr_meth,asptr_frag,Type)
%typemap(in,noblock=1,fragment=asptr_frag) Type *INPUT(int res = 0) {
res = asptr_meth($input, &$1);
if (!res) {
- SWIG_arg_fail(SWIG_TypeError,"$type",$argnum);
+ %argument_fail(SWIG_TypeError,"$type",$argnum);
}
}
%typemap(in,noblock=1,fragment=asptr_frag) Type &INPUT(int res = 0) {
res = asptr_meth($input, &$1);
if (!res) {
- SWIG_arg_fail(SWIG_TypeError,"$type",$argnum);
+ %argument_fail(SWIG_TypeError,"$type",$argnum);
}
if (!$1) {
- SWIG_arg_nullref("$type",$argnum);
+ %argument_nullref("$type",$argnum);
}
}
%typemap(freearg,noblock=1) Type *INPUT, Type &INPUT {
- if (res$argnum == SWIG_NEWOBJ) SWIG_delete($1);
+ if (res$argnum == SWIG_NEWOBJ) %delete($1);
}
%typemap(typecheck,noblock=1,precedence=code,fragment=asptr_frag) Type *INPUT, Type &INPUT {
$1 = asptr_meth($input, (Type**)0) != 0;
@@ -167,15 +162,18 @@ values.
*/
-%define _SWIG_VALUE_OUTPUT_TYPEMAP(from_meth, from_frag, Type)
+%define %_value_output_typemap(from_meth, from_frag, Type)
%typemap(in,numinputs=0,noblock=1)
Type *OUTPUT ($*1_ltype temp, int res = SWIG_NEWOBJ),
Type &OUTPUT ($*1_ltype temp, int res = SWIG_NEWOBJ) {
$1 = &temp;
}
%typemap(argout,noblock=1,fragment=from_frag) Type *OUTPUT, Type &OUTPUT {
- SWIG_append_result(((res$argnum == SWIG_NEWOBJ) ?
- from_meth((*$1)) : SWIG_NewPointerObj((void*)($1), $1_descriptor, 0)));
+ if (res$argnum == SWIG_NEWOBJ) {
+ %append_output(from_meth((*$1)));
+ } else {
+ %append_output(SWIG_NewPointerObj((void*)($1), $1_descriptor, 0));
+ }
}
%enddef
@@ -218,7 +216,7 @@ phased out in future releases.
*/
-%define _SWIG_VALUE_INOUT_TYPEMAP(Type)
+%define %_value_inout_typemap(Type)
%typemap(in) Type *INOUT = Type *INPUT;
%typemap(in) Type &INOUT = Type &INPUT;
%typemap(typecheck) Type *INOUT = Type *INPUT;
@@ -228,51 +226,51 @@ phased out in future releases.
%enddef
-%define _SWIG_PTR_INOUT_TYPEMAP(Type)
- _SWIG_VALUE_INOUT_TYPEMAP(SWIG_arg(Type))
+%define %_ptr_inout_typemap(Type)
+ %_value_inout_typemap(%arg(Type))
%typemap(freearg) Type *INOUT = Type *INPUT;
%typemap(freearg) Type &INOUT = Type &INPUT;
%enddef
#ifndef SWIG_INOUT_NODEF
-#define SWIG_VALUE_INPUT_TYPEMAP(code,_a,_af,...) \
- _SWIG_VALUE_INPUT_TYPEMAP(SWIG_arg(code),SWIG_arg(_a), \
- SWIG_arg(_af),SWIG_arg(__VA_ARGS__))
+#define %value_input_typemap(code,_a,_af,...) \
+ %_value_input_typemap(%arg(code),%arg(_a), \
+ %arg(_af),%arg(__VA_ARGS__))
-#define SWIG_PTR_INPUT_TYPEMAP(code,_a,_af,...) \
- _SWIG_PTR_INPUT_TYPEMAP(SWIG_arg(code),SWIG_arg(_a),SWIG_arg(_af), \
- SWIG_arg(__VA_ARGS__))
+#define %ptr_input_typemap(code,_a,_af,...) \
+ %_ptr_input_typemap(%arg(code),%arg(_a),%arg(_af), \
+ %arg(__VA_ARGS__))
-#define SWIG_VALUE_OUTPUT_TYPEMAP(_f,_ff,...) \
- _SWIG_VALUE_OUTPUT_TYPEMAP(SWIG_arg(_f),SWIG_arg(_ff),SWIG_arg(__VA_ARGS__))
+#define %value_output_typemap(_f,_ff,...) \
+ %_value_output_typemap(%arg(_f),%arg(_ff),%arg(__VA_ARGS__))
-#define SWIG_VALUE_INOUT_TYPEMAP(...) _SWIG_VALUE_INOUT_TYPEMAP(SWIG_arg(__VA_ARGS__))
-#define SWIG_PTR_INOUT_TYPEMAP(...) _SWIG_PTR_INOUT_TYPEMAP(SWIG_arg(__VA_ARGS__))
+#define %value_inout_typemap(...) %_value_inout_typemap(%arg(__VA_ARGS__))
+#define %ptr_inout_typemap(...) %_ptr_inout_typemap(%arg(__VA_ARGS__))
#else /* You need to include typemaps.i */
-#define SWIG_VALUE_OUTPUT_TYPEMAP(...)
-#define SWIG_VALUE_INPUT_TYPEMAP(...)
-#define SWIG_VALUE_INOUT_TYPEMAP(...)
-#define SWIG_PTR_INPUT_TYPEMAP(...)
-#define SWIG_PTR_INOUT_TYPEMAP(...)
+#define %value_output_typemap(...)
+#define %value_input_typemap(...)
+#define %value_inout_typemap(...)
+#define %ptr_input_typemap(...)
+#define %ptr_inout_typemap(...)
#endif /* SWIG_INOUT_DEFAULT */
-%define %typemap_inout(Code, AsValMeth, FromMeth, AsValFrag, FromFrag, Type...)
- _SWIG_VALUE_INPUT_TYPEMAP(SWIG_arg(Code), SWIG_arg(AsValMeth),
- SWIG_arg(AsValFrag), SWIG_arg(Type));
- _SWIG_VALUE_OUTPUT_TYPEMAP(SWIG_arg(FromMeth), SWIG_arg(FromFrag), SWIG_arg(Type));
- _SWIG_VALUE_INOUT_TYPEMAP(SWIG_arg(Type));
+%define %typemaps_inout(Code, AsValMeth, FromMeth, AsValFrag, FromFrag, Type...)
+ %_value_input_typemap(%arg(Code), %arg(AsValMeth),
+ %arg(AsValFrag), %arg(Type));
+ %_value_output_typemap(%arg(FromMeth), %arg(FromFrag), %arg(Type));
+ %_value_inout_typemap(%arg(Type));
%enddef
-%define %typemap_inoutn(Code,Type...)
- %typemap_inout(SWIG_arg(Code),
- SWIG_arg(SWIG_AsVal(Type)),
- SWIG_arg(SWIG_From(Type)),
- SWIG_arg(SWIG_AsVal_frag(Type)),
- SWIG_arg(SWIG_From_frag(Type)),
- SWIG_arg(Type));
+%define %typemaps_inoutn(Code,Type...)
+ %typemaps_inout(%arg(Code),
+ %arg(SWIG_AsVal(Type)),
+ %arg(SWIG_From(Type)),
+ %arg(SWIG_AsVal_frag(Type)),
+ %arg(SWIG_From_frag(Type)),
+ %arg(Type));
%enddef
diff --git a/Lib/typemaps/primtypes.swg b/Lib/typemaps/primtypes.swg
index 183d76a5e..ee95a3fcb 100644
--- a/Lib/typemaps/primtypes.swg
+++ b/Lib/typemaps/primtypes.swg
@@ -1,9 +1,40 @@
/* ------------------------------------------------------------
- * typemap for primitive type with no pointer representation
+ * Basic fragments derived from long and double types
* ------------------------------------------------------------ */
-%define %typemap_primitive(Code, Type...)
-%typemap_asvalfromn(SWIG_arg(Code), Type);
+/* signed/unsigned char */
+
+%numeric_slong(signed char, "<limits.h>", SCHAR_MIN, SCHAR_MAX)
+%numeric_ulong(unsigned char, "<limits.h>", UCHAR_MAX)
+
+/* short/unsigned short */
+
+%numeric_slong(short, "<limits.h>", SHRT_MIN, SHRT_MAX)
+%numeric_ulong(unsigned short, "<limits.h>", USHRT_MAX)
+
+/* int/unsigned int */
+
+%numeric_slong(int, "<limits.h>", INT_MIN, INT_MAX)
+%numeric_ulong(unsigned int, "<limits.h>", UINT_MAX)
+
+/* signed/unsigned wchar_t */
+
+#ifdef __cplusplus
+%numeric_slong(signed wchar_t, "<wchar.h>", WCHAR_MIN, WCHAR_MAX)
+%numeric_ulong(unsigned wchar_t, "<wchar.h>", UWCHAR_MAX)
+#endif
+
+/* float */
+
+%numeric_double(float, "<float.h>", -FLT_MAX, FLT_MAX)
+
+
+/* ------------------------------------------------------------
+ * typemap macro for primitive types with asval/from methods
+ * ------------------------------------------------------------ */
+
+%define %typemaps_primitive(Code, Type)
+ %typemaps_asvalfromn(%arg(Code), Type);
%enddef
/* ------------------------------------------------------------
@@ -14,7 +45,7 @@
%define _apply_macro(macro, arg2, arg1...)
#if #arg1 != ""
- macro(SWIG_arg(arg1),arg2);
+ macro(%arg(arg1),arg2);
#else
macro(arg2);
#endif
@@ -53,80 +84,27 @@ _apply_macro(Macro, std::complex<double>, __VA_ARGS__);
%enddef
%define %apply_checkctypes(Macro)
-Macro(SWIG_CCode(BOOL), bool);
-Macro(SWIG_CCode(INT8), signed char);
-Macro(SWIG_CCode(UINT8), unsigned char);
-Macro(SWIG_CCode(INT16), short);
-Macro(SWIG_CCode(UINT16), unsigned short);
-Macro(SWIG_CCode(INT32), int);
-Macro(SWIG_CCode(UINT32), unsigned int);
-Macro(SWIG_CCode(INT64), long);
-Macro(SWIG_CCode(UINT64), unsigned long);
-Macro(SWIG_CCode(INT128), long long);
-Macro(SWIG_CCode(UINT128), unsigned long long);
-Macro(SWIG_CCode(FLOAT), float);
-Macro(SWIG_CCode(DOUBLE), double);
-Macro(SWIG_CCode(CHAR), char);
-Macro(SWIG_CCode(UNICHAR), wchar_t);
+Macro(%checkcode(BOOL), bool);
+Macro(%checkcode(INT8), signed char);
+Macro(%checkcode(UINT8), unsigned char);
+Macro(%checkcode(INT16), short);
+Macro(%checkcode(UINT16), unsigned short);
+Macro(%checkcode(INT32), int);
+Macro(%checkcode(UINT32), unsigned int);
+Macro(%checkcode(INT64), long);
+Macro(%checkcode(UINT64), unsigned long);
+Macro(%checkcode(INT128), long long);
+Macro(%checkcode(UINT128), unsigned long long);
+Macro(%checkcode(FLOAT), float);
+Macro(%checkcode(DOUBLE), double);
+Macro(%checkcode(CHAR), char);
+Macro(%checkcode(UNICHAR), wchar_t);
%enddef
-
/* ------------------------------------------------------------
- * common fragments and macro helpers
+ * Apply the primitive typemap for all the types with checkcode
* ------------------------------------------------------------ */
-
-%fragment("<limits.h>","header") %{
-#include <limits.h>
-%}
-
-%fragment("<wchar.h>","header") %{
-#include <wchar.h>
-%}
-
-%fragment("<float.h>","header") %{
-#include <float.h>
-%}
-
-/* Macros for derived types */
-
-%define %derived_type_from(Base, Type)
-%fragment(SWIG_From_frag(Type),"header",
- fragment=SWIG_From_frag(Base)) {
- SWIG_define(SWIG_From_dec(Type), SWIG_From_dec(Base))
-}
-%enddef
-
-%define %derived_type_asval(Base, Type, Frag, OverflowCond)
-%check_swig_object()
-
-%fragment(SWIG_AsVal_frag(Type),"header",
- fragment=Frag,
- fragment=SWIG_AsVal_frag(Base)) {
-SWIGINTERN int
-SWIG_AsVal_dec(Type)(SWIG_Object obj, Type *val)
-{
- Base v;
- int res = SWIG_AsVal(Base)(obj, &v);
- if (res == SWIG_OK) {
- if (OverflowCond) {
- return SWIG_OverflowError;
- } else {
- if (val) *val = SWIG_numeric_cast(v, Type);
- return SWIG_OK;
- }
- }
- return res;
-}
-}
-%enddef
-
-%define %signed_derived_type_asval(Base, Type, Frag, Min, Max)
-%derived_type_asval(Base, Type, Frag, (v < Min || v > Max))
-%enddef
-
-%define %unsigned_derived_type_asval(Base, Type, Frag, Max)
-%derived_type_asval(Base, Type, Frag, (v > Max))
-%enddef
+%apply_checkctypes(%typemaps_primitive);
diff --git a/Lib/typemaps/ptrtypes.swg b/Lib/typemaps/ptrtypes.swg
index c6400dfb6..4b3df7391 100644
--- a/Lib/typemaps/ptrtypes.swg
+++ b/Lib/typemaps/ptrtypes.swg
@@ -1,82 +1,101 @@
-/*
- Value typemaps (Type, const Type&) for "Ptr" types, such as swig
- wrapped classes, that define the AsPtr/From methods
-*/
+/*---------------------------------------------------------------------
+ * Value typemaps (Type, const Type&) for "Ptr" types, such as swig
+ * wrapped classes, that define the AsPtr/From methods
+ *
+ * To apply them, just use one of the following macros:
+ *
+ * %typemaps_asptr(CheckCode, AsPtrMeth, AsPtrFrag, Type)
+ * %typemaps_asptrfrom(CheckCode, AsPtrMeth, FromMeth, AsPtrFrag, FromFrag, Type)
+ *
+ * or the simpler and normalize form:
+ *
+ * %typemaps_asptrfromn(CheckCode, Type)
+ *
+ * Also, you can use the individual typemap definitions:
+ *
+ * %ptr_in_typemap(asptr_meth,frag,Type)
+ * %ptr_varin_typemap(asptr_meth,frag,Type)
+ * %ptr_typecheck_typemap(check,asptr_meth,frag,Type)
+ * %ptr_directorout_typemap(asptr_meth,frag,Type)
+ *
+ *---------------------------------------------------------------------*/
+
+%include <typemaps/valtypes.swg>
/* in */
-%define SWIG_PTR_IN_TYPEMAP(asptr_meth,frag,Type...)
+%define %ptr_in_typemap(asptr_meth,frag,Type...)
%typemap(in,fragment=frag) Type {
Type *ptr = (Type *)0;
int res = asptr_meth($input, &ptr);
- if (!res || !ptr) { SWIG_arg_fail(SWIG_TypeError, "$type", $argnum); }
+ if (!res || !ptr) { %argument_fail(SWIG_TypeError, "$type", $argnum); }
$1 = *ptr;
- if (res == SWIG_NEWOBJ) SWIG_delete(ptr);
+ if (res == SWIG_NEWOBJ) %delete(ptr);
}
%typemap(in,fragment=frag) const Type & (int res = 0) {
Type *ptr = (Type *)0;
res = asptr_meth($input, &ptr);
- if (!res) { SWIG_arg_fail(SWIG_TypeError,"$type",$argnum); }
- if (!ptr) { SWIG_arg_nullref("$type",$argnum); }
+ if (!res) { %argument_fail(SWIG_TypeError,"$type",$argnum); }
+ if (!ptr) { %argument_nullref("$type",$argnum); }
$1 = ptr;
}
%typemap(freearg,noblock=1) const Type & {
- if (res$argnum == SWIG_NEWOBJ) SWIG_delete($1);
+ if (res$argnum == SWIG_NEWOBJ) %delete($1);
}
%enddef
/* varin */
-%define SWIG_PTR_VARIN_TYPEMAP(asptr_meth,frag,Type...)
+%define %ptr_varin_typemap(asptr_meth,frag,Type...)
%typemap(varin,fragment=frag) Type {
Type *ptr = (Type *)0;
int res = asptr_meth($input, &ptr);
- if (!res || !ptr) { SWIG_var_fail(SWIG_TypeError, "$type", "$name"); }
+ if (!res || !ptr) { %variable_fail(SWIG_TypeError, "$type", "$name"); }
$1 = *ptr;
- if (res == SWIG_NEWOBJ) SWIG_delete(ptr);
+ if (res == SWIG_NEWOBJ) %delete(ptr);
}
%enddef
#ifdef SWIG_DIRECTOR_TYPEMAPS
/* directorout */
-%define SWIG_PTR_DIRECTOROUT_TYPEMAP(asptr_meth,frag,Type...)
+%define %ptr_directorout_typemap(asptr_meth,frag,Type...)
%typemap(directorargout,noblock=1,fragment=frag) Type *DIRECTOROUT ($*ltype temp) {
Type *optr = 0;
int ores = $input ? asptr_meth($input, &optr) : 0;
if (!ores || !optr) {
- SWIG_dout_fail(SWIG_TypeError,"$type");
+ %dirout_fail(SWIG_TypeError,"$type");
}
temp = *optr;
$result = &temp;
- if (ores == SWIG_NEWOBJ) SWIG_delete(optr);
+ if (ores == SWIG_NEWOBJ) %delete(optr);
}
%typemap(directorout,noblock=1,fragment=frag) Type {
Type *optr = 0;
int ores = asptr_meth($input, &optr);
if (!ores || !optr) {
- SWIG_dout_fail(SWIG_TypeError,"$type");
+ %dirout_fail(SWIG_TypeError,"$type");
}
$result = *optr;
- if (ores == SWIG_NEWOBJ) SWIG_delete(optr);
+ if (ores == SWIG_NEWOBJ) %delete(optr);
}
%typemap(directorout,noblock=1,fragment=frag,warning=SWIG_WARN_TYPEMAP_THREAD_UNSAFE) const Type& {
Type *optr = 0;
int ores = asptr_meth($input, &optr);
if (!ores) {
- SWIG_dout_fail(SWIG_TypeError,"$type");
+ %dirout_fail(SWIG_TypeError,"$type");
} else {
if (!optr) {
- SWIG_dout_nullref("$type");
+ %dirout_nullref("$type");
}
}
if (ores == SWIG_NEWOBJ) {
/* Possible thread/reentrant problem here! */
static $*ltype temp = *optr;
$result = &temp;
- SWIG_delete(optr);
+ %delete(optr);
} else {
$result = optr;
}
@@ -88,26 +107,26 @@
#else
-#define SWIG_PTR_DIRECTOROUT_TYPEMAP(asptr_meth,frag,Type...)
+#define %ptr_directorout_typemap(asptr_meth,frag,Type...)
#endif /* SWIG_DIRECTOR_TYPEMAPS */
/* typecheck */
-%define SWIG_PTR_TYPECHECK_TYPEMAP(check,asptr_meth,frag,Type...)
+%define %ptr_typecheck_typemap(check,asptr_meth,frag,Type...)
%typemap(typecheck,precedence=check,fragment=frag)
Type, const Type&
"$1 = asptr_meth($input, (Type**)(0));";
%enddef
-/*
- typemap definition for types with AsPtr/From methods
- */
-%define %typemap_asptrfrom(CheckCode, AsPtrMeth, FromMeth, AsPtrFrag, FromFrag, Type...)
- %fragment(SWIG_AsVal_frag(Type),"header",
- fragment=SWIG_AsPtr_frag(Type)) %{
- SWIGINTERNINLINE int
+/*---------------------------------------------------------------------
+ * typemap definition for types with asptr method
+ *---------------------------------------------------------------------*/
+
+%define %typemaps_asptr(CheckCode, AsPtrMeth, AsPtrFrag, Type...)
+ %fragment(SWIG_AsVal_frag(Type),"header",fragment=SWIG_AsPtr_frag(Type)) {
+ SWIGINTERNINLINE int
SWIG_AsVal(Type)(SWIG_Object obj, Type *val)
{
Type *v = (Type *)0;
@@ -115,43 +134,38 @@
if (!res || !v) return SWIG_ERROR;
if (val) {
*val = *v;
- if (res == SWIG_NEWOBJ) SWIG_delete(v);
+ if (res == SWIG_NEWOBJ) %delete(v);
}
return SWIG_OK;
}
- %}
- %fragment(SWIG_As_frag(Type),"header",
- fragment=SWIG_AsVal_frag(Type)) %{
- SWIGINTERNINLINE Type
- SWIG_As(Type)(SWIG_Object obj)
- {
- Type v;
- SWIG_AsVal(Type)(obj, &v);
- return v;
- }
- %}
- SWIG_PTR_IN_TYPEMAP(SWIG_arg(AsPtrMeth), SWIG_arg(AsPtrFrag), Type);
- SWIG_PTR_VARIN_TYPEMAP(SWIG_arg(AsPtrMeth), SWIG_arg(AsPtrFrag), Type);
- SWIG_PTR_DIRECTOROUT_TYPEMAP(SWIG_arg(AsPtrMeth), SWIG_arg(AsPtrFrag), Type);
- SWIG_PTR_TYPECHECK_TYPEMAP(SWIG_arg(CheckCode), SWIG_arg(AsPtrMeth),
- SWIG_arg(AsPtrFrag), Type);
- %typemap_from(SWIG_arg(FromMeth), SWIG_arg(FromFrag), Type);
-
- SWIG_PTR_INPUT_TYPEMAP(SWIG_arg(CheckCode),SWIG_arg(AsPtrMeth),
- SWIG_arg(AsPtrFrag),Type);
- SWIG_VALUE_OUTPUT_TYPEMAP(SWIG_arg(FromMeth), SWIG_arg(FromFrag), Type);
- SWIG_PTR_INOUT_TYPEMAP(Type);
+ }
+ %ptr_in_typemap(%arg(AsPtrMeth), %arg(AsPtrFrag), Type);
+ %ptr_varin_typemap(%arg(AsPtrMeth), %arg(AsPtrFrag), Type);
+ %ptr_directorout_typemap(%arg(AsPtrMeth), %arg(AsPtrFrag), Type);
+ %ptr_typecheck_typemap(%arg(CheckCode), %arg(AsPtrMeth),%arg(AsPtrFrag), Type);
+ %ptr_input_typemap(%arg(CheckCode),%arg(AsPtrMeth),%arg(AsPtrFrag),Type);
+%enddef
+
+/*---------------------------------------------------------------------
+ * typemap definition for types with asptr/from methods
+ *---------------------------------------------------------------------*/
+
+%define %typemaps_asptrfrom(CheckCode, AsPtrMeth, FromMeth, AsPtrFrag, FromFrag, Type...)
+ %typemaps_asptr(%arg(CheckCode), %arg(AsPtrMeth), %arg(AsPtrFrag), Type)
+ %typemaps_from(%arg(FromMeth), %arg(FromFrag), Type);
+ %value_output_typemap(%arg(FromMeth), %arg(FromFrag), Type);
+ %ptr_inout_typemap(Type);
%enddef
-/*
- typemap for simple swig types with only AsPtr/From methods
-*/
+/*---------------------------------------------------------------------
+ * typemap definition for types with for 'normalized' asptr/from methods
+ *---------------------------------------------------------------------*/
-%define %typemap_asptrfromn(CheckCode, Type...)
-%typemap_asptrfrom(SWIG_arg(CheckCode),
- SWIG_arg(SWIG_AsPtr(Type)),
- SWIG_arg(SWIG_From(Type)),
- SWIG_arg(SWIG_AsPtr_frag(Type)),
- SWIG_arg(SWIG_From_frag(Type)),
+%define %typemaps_asptrfromn(CheckCode, Type...)
+%typemaps_asptrfrom(%arg(CheckCode),
+ %arg(SWIG_AsPtr(Type)),
+ %arg(SWIG_From(Type)),
+ %arg(SWIG_AsPtr_frag(Type)),
+ %arg(SWIG_From_frag(Type)),
Type);
%enddef
diff --git a/Lib/typemaps/std_string.swg b/Lib/typemaps/std_string.swg
index 0342b6184..ef05606b4 100644
--- a/Lib/typemaps/std_string.swg
+++ b/Lib/typemaps/std_string.swg
@@ -1,69 +1,24 @@
//
// String
//
+#ifndef SWIG_STD_BASIC_STRING
+#define SWIG_STD_STRING
+%include <typemaps/std_strings.swg>
-
-
-
-/* defining the String asptr/from methods */
-
-%define %std_string_asptr_frag(String, Char, SWIG_AsCharPtrAndSize, Frag)
-%check_swig_object()
-%fragment(SWIG_AsPtr_frag(String),"header",fragment=Frag) {
-SWIGINTERN int
-SWIG_AsPtr_dec(String)(SWIG_Object obj, String **val)
+%{
+#include <string>
+%}
+
+namespace std
{
- static swig_type_info* string_info = SWIG_TypeQuery(#String " *");
- String *vptr;
- if (SWIG_ConvertPtr(obj, (void**)&vptr, string_info, 0) != -1) {
- if (val) *val = vptr;
- return SWIG_OLDOBJ;
- } else {
- Char* buf = 0 ; size_t size = 0; int alloc = SWIG_OLDOBJ;
- if (SWIG_AsCharPtrAndSize(obj, &buf, &size, &alloc) == SWIG_OK) {
- if (buf) {
- if (val) *val = new String(buf, size - 1);
- if (alloc == SWIG_NEWOBJ) SWIG_delete_array(buf);
- return SWIG_NEWOBJ;
- }
- }
- return 0;
- }
-}
+ class string;
}
-%enddef
-%define %std_string_from_frag(String, SWIG_FromCharPtrAndSize, Frag)
-%check_swig_object()
-%fragment(SWIG_From_frag(String),"header",fragment=Frag) {
-SWIGINTERNINLINE SWIG_Object
-SWIG_From_dec(String)(const String& s)
-{
- return SWIG_FromCharPtrAndSize(s.data(), s.size());
-}
-}
-%enddef
+%typemaps_std_string(std::string, char, SWIG_AsCharPtrAndSize, SWIG_FromCharPtrAndSize, %checkcode(STRING));
-%define %std_string_asval_frag(String, Frag)
-%check_swig_object()
-%fragment(SWIG_AsVal_frag(String),"header", fragment=Frag) {
-SWIGINTERN int
-SWIG_AsVal_dec(String)(SWIG_Object obj, String *val)
-{
- String* s;
- int res = SWIG_AsPtr(String)(obj, &s);
- if ((res != 0) && s) {
- if (val) *val = *s;
- if (res == SWIG_NEWOBJ) delete s;
- return SWIG_OK;
- }
- return SWIG_TypeError;
-}
-}
-%enddef
+#else
+%include <std/std_string.i>
-#define %std_string_asptr(String, Char, Method) %std_string_asptr_frag(String, Char, Method, #Method)
-#define %std_string_asval(String) %std_string_asval_frag(String, SWIG_AsPtr_frag(String))
-#define %std_string_from(String, Method) %std_string_from_frag(String, Method, #Method)
+#endif
diff --git a/Lib/typemaps/std_strings.swg b/Lib/typemaps/std_strings.swg
new file mode 100644
index 000000000..ddba34b1f
--- /dev/null
+++ b/Lib/typemaps/std_strings.swg
@@ -0,0 +1,65 @@
+
+/* defining the String asptr/from methods */
+
+%define %std_string_asptr(String, Char, SWIG_AsCharPtrAndSize, Frag)
+%fragment(SWIG_AsPtr_frag(String),"header",fragment=Frag) {
+SWIGINTERN int
+SWIG_AsPtr_dec(String)(SWIG_Object obj, String **val)
+{
+ static swig_type_info* string_info = SWIG_TypeQuery(#String " *");
+ String *vptr;
+ if (SWIG_ConvertPtr(obj, (void**)&vptr, string_info, 0) != -1) {
+ if (val) *val = vptr;
+ return SWIG_OLDOBJ;
+ } else {
+ Char* buf = 0 ; size_t size = 0; int alloc = SWIG_OLDOBJ;
+ if (SWIG_AsCharPtrAndSize(obj, &buf, &size, &alloc) == SWIG_OK) {
+ if (buf) {
+ if (val) *val = new String(buf, size - 1);
+ if (alloc == SWIG_NEWOBJ) %delete_array(buf);
+ return SWIG_NEWOBJ;
+ }
+ }
+ return 0;
+ }
+}
+}
+%enddef
+
+%define %std_string_from(String, SWIG_FromCharPtrAndSize, Frag)
+%fragment(SWIG_From_frag(String),"header",fragment=Frag) {
+SWIGINTERNINLINE SWIG_Object
+SWIG_From_dec(String)(const String& s)
+{
+ return SWIG_FromCharPtrAndSize(s.data(), s.size());
+}
+}
+%enddef
+
+%define %std_string_asval(String)
+%fragment(SWIG_AsVal_frag(String),"header", fragment=SWIG_AsPtr_frag(String)) {
+SWIGINTERN int
+SWIG_AsVal_dec(String)(SWIG_Object obj, String *val)
+{
+ String* s;
+ int res = SWIG_AsPtr(String)(obj, &s);
+ if ((res != 0) && s) {
+ if (val) *val = *s;
+ if (res == SWIG_NEWOBJ) delete s;
+ return SWIG_OK;
+ }
+ return SWIG_TypeError;
+}
+}
+%enddef
+
+
+%define %typemaps_std_string(String, Char, AsPtrMethod, FromMethod, CheckCode)
+
+%std_string_asptr(String, Char, AsPtrMethod, #AsPtrMethod)
+%std_string_asval(String)
+%std_string_from(String, FromMethod, #FromMethod)
+
+%typemaps_asptrfromn(%arg(CheckCode), String);
+
+%enddef
diff --git a/Lib/typemaps/std_wstring.swg b/Lib/typemaps/std_wstring.swg
new file mode 100644
index 000000000..6b9702751
--- /dev/null
+++ b/Lib/typemaps/std_wstring.swg
@@ -0,0 +1,25 @@
+%include <typemaps/wstring.swg>
+
+#ifndef SWIG_STD_BASIC_STRING
+#define SWIG_STD_WSTRING
+
+%include <typemaps/std_strings.swg>
+
+%{
+#include <cwchar>
+#include <string>
+%}
+
+namespace std
+{
+ class wstring;
+}
+
+%typemaps_std_string(std::wstring, wchar_t, SWIG_AsWCharPtrAndSize, SWIG_FromWCharPtrAndSize, %checkcode(UNISTRING));
+
+
+#else
+
+%include <std/std_wstring.i>
+
+#endif
diff --git a/Lib/typemaps/string.swg b/Lib/typemaps/string.swg
new file mode 100644
index 000000000..d03ef6e6e
--- /dev/null
+++ b/Lib/typemaps/string.swg
@@ -0,0 +1,3 @@
+%include <typemaps/strings.swg>
+%typemaps_string(char, Char, SWIG_AsCharPtrAndSize, SWIG_FromCharPtrAndSize, strlen,
+ "<limits.h>", CHAR_MIN, CHAR_MAX)
diff --git a/Lib/typemaps/strings.swg b/Lib/typemaps/strings.swg
index b5fe5a229..7740e3a81 100644
--- a/Lib/typemaps/strings.swg
+++ b/Lib/typemaps/strings.swg
@@ -31,33 +31,33 @@
Char * (Char *buf = 0, int alloc = 0),
const Char * (Char *buf = 0, int alloc = SWIG_OLDOBJ) {
if (SWIG_AsCharPtr($input, &buf, &alloc) != SWIG_OK) {
- SWIG_arg_fail(SWIG_TypeError,"$type",$argnum);
+ %argument_fail(SWIG_TypeError,"$type",$argnum);
}
$1 = buf;
}
%typemap(freearg,noblock=1) Char *, const Char * {
- if (alloc$argnum == SWIG_NEWOBJ) SWIG_delete_array(buf$argnum);
+ if (alloc$argnum == SWIG_NEWOBJ) %delete_array(buf$argnum);
}
%typemap(in,noblock=1,fragment=#SWIG_AsCharPtr) Char const*& (Char *buf = 0, int alloc = 0) {
if (SWIG_AsCharPtr($input, &buf, &alloc) != SWIG_OK) {
- SWIG_arg_fail(SWIG_TypeError,"$type",$argnum);
+ %argument_fail(SWIG_TypeError,"$type",$argnum);
}
$1 = &temp;
}
%typemap(freearg, noblock=1) Char const*& {
- if (alloc$argnum == SWIG_NEWOBJ) SWIG_delete_array(buf$argnum);
+ if (alloc$argnum == SWIG_NEWOBJ) %delete_array(buf$argnum);
}
/* out */
%typemap(out,noblock=1,fragment=#SWIG_FromCharPtr) Char *, const Char* {
- SWIG_set_result(SWIG_FromCharPtr($1));
+ %set_output(SWIG_FromCharPtr($1));
}
%typemap(out,noblock=1,fragment=#SWIG_FromCharPtr) Char const*& {
- SWIG_set_result(SWIG_FromCharPtr(*$1));
+ %set_output(SWIG_FromCharPtr(*$1));
}
@@ -66,41 +66,41 @@
%typemap(varin,noblock=1,fragment=#SWIG_AsCharPtrAndSize) Char * {
Char *cptr = 0; size_t csize = 0; int alloc = SWIG_NEWOBJ;
if (SWIG_AsCharPtrAndSize($input, &cptr, &csize, &alloc) != SWIG_OK) {
- SWIG_var_fail(SWIG_TypeError,"$type","$name");
+ %variable_fail(SWIG_TypeError,"$type","$name");
}
- if ($1) SWIG_delete_array($1);
+ if ($1) %delete_array($1);
if (alloc == SWIG_NEWOBJ) {
$1 = cptr;
} else {
- $1 = csize ? SWIG_new_copy_array(cptr, csize, Char) : 0;
+ $1 = csize ? %new_copy_array(cptr, csize, Char) : 0;
}
}
%typemap(varin,noblock=1,fragment=#SWIG_AsCharPtrAndSize,warning="451:Setting const Char * variable may leak memory") const Char * {
Char *cptr = 0; size_t csize = 0; int alloc = SWIG_NEWOBJ;
if (SWIG_AsCharPtrAndSize($input, &cptr, &csize, &alloc) != SWIG_OK) {
- SWIG_var_fail(SWIG_TypeError, "$type", "$name");
+ %variable_fail(SWIG_TypeError, "$type", "$name");
}
if (alloc == SWIG_NEWOBJ) {
$1 = cptr;
} else {
- $1 = csize ? SWIG_new_copy_array(cptr, csize, Char) : 0;
+ $1 = csize ? %new_copy_array(cptr, csize, Char) : 0;
}
}
/* varout */
%typemap(varout,noblock=1,fragment=#SWIG_FromCharPtr) Char*, const Char* {
- $result = SWIG_FromCharPtr($1);
+ %set_varoutput(SWIG_FromCharPtr($1));
}
/* meberin */
%typemap(memberin,noblock=1) Char * {
- if ($1) SWIG_delete_array($1);
+ if ($1) %delete_array($1);
if ($input) {
size_t size = SWIG_CharPtrLen($input) + 1;
- $1 = SWIG_new_copy_array($input, size, Char);
+ $1 = %new_copy_array($input, size, Char);
} else {
$1 = 0;
}
@@ -109,7 +109,7 @@
%typemap(memberin,noblock=1,warning="451:Setting const char * member may leak memory.") const Char * {
if ($input) {
size_t size = SWIG_CharPtrLen($input) + 1;
- $1 = SWIG_new_copy_array($input, size, Char);
+ $1 = %new_copy_array($input, size, Char);
} else {
$1 = 0;
}
@@ -118,10 +118,10 @@
/* globalin */
%typemap(globalin,noblock=1) Char * {
- if ($1) SWIG_delete_array($1);
+ if ($1) %delete_array($1);
if ($input) {
size_t size = SWIG_CharPtrLen($input) + 1;
- $1 = SWIG_new_copy_array($input, size, Char);
+ $1 = %new_copy_array($input, size, Char);
} else {
$1 = 0;
}
@@ -130,7 +130,7 @@
%typemap(globalin,noblock=1,warning="451:Setting const char * variable may leak memory.") const Char * {
if ($input) {
size_t size = SWIG_CharPtrLen($input) + 1;
- $1 = SWIG_new_copy_array($input, size, Char);
+ $1 = %new_copy_array($input, size, Char);
} else {
$1 = 0;
}
@@ -140,7 +140,7 @@
%typemap(constcode,noblock=1,fragment=#SWIG_FromCharPtr)
Char *, Char const*, Char * const, Char const* const {
- SWIG_set_constant("$symname", SWIG_FromCharPtr($value));
+ %set_constant("$symname", SWIG_FromCharPtr($value));
}
@@ -159,14 +159,14 @@
%typemap(directorout,noblock=1,fragment=#SWIG_AsCharPtr) Char * (Char* buf = 0, int alloc = 0) {
if (SWIG_AsCharPtr($input, &buf, &alloc) != SWIG_OK) {
- SWIG_dout_fail(SWIG_TypeError, "$type");
+ %dirout_fail(SWIG_TypeError, "$type");
}
$result = buf;
}
%typemap(directorout,noblock=1,fragment=#SWIG_AsCharPtr) Char * const& (Char* buf = 0, int alloc = 0) {
if (SWIG_AsCharPtr($input, &buf, &alloc) != SWIG_OK) {
- SWIG_dout_fail(SWIG_TypeError, "$type");
+ %dirout_fail(SWIG_TypeError, "$type");
}
$result = ($1_ltype) &buf;
}
@@ -184,7 +184,7 @@
/* throws */
%typemap(throws,noblock=1,fragment=#SWIG_FromCharPtr) Char * {
- SWIG_raise(SWIG_FromCharPtr($1), "$type", 0);
+ %raise(SWIG_FromCharPtr($1), "$type", 0);
}
@@ -197,7 +197,7 @@
%typemap(varin,noblock=1,warning="462:Unable to set variable of type Char []") Char []
{
- SWIG_var_fail(SWIG_AttributeError, "$type", "read-only $name");
+ %variable_fail(SWIG_AttributeError, "$type", "read-only $name");
}
@@ -226,7 +226,7 @@
const Char [ANY](Char temp[$1_dim0])
{
if (SWIG_AsCharArray($input, temp, $1_dim0) != SWIG_OK) {
- SWIG_arg_fail(SWIG_TypeError,"$type",$argnum);
+ %argument_fail(SWIG_TypeError,"$type",$argnum);
}
$1 = temp;
}
@@ -234,7 +234,7 @@
%typemap(in,noblock=1,fragment=#SWIG_AsCharArray) const Char (&)[ANY] (Char temp[$1_dim0])
{
if (SWIG_AsCharArray($input, temp, $1_dim0) != SWIG_OK) {
- SWIG_arg_fail(SWIG_TypeError,"$type",$argnum);
+ %argument_fail(SWIG_TypeError,"$type",$argnum);
}
$1 = &temp;
}
@@ -246,7 +246,7 @@
%#ifndef SWIG_PRESERVE_CARRAY_SIZE
while (size && ($1[size - 1] == '\0')) --size;
%#endif
- SWIG_set_result(SWIG_FromCharPtrAndSize($1, size));
+ %set_output(SWIG_FromCharPtrAndSize($1, size));
}
/* varin */
@@ -254,7 +254,7 @@
%typemap(varin,noblock=1,fragment=#SWIG_AsCharArray) Char [ANY]
{
if (SWIG_AsCharArray($input, $1, $1_dim0) != SWIG_OK) {
- SWIG_var_fail(SWIG_TypeError, "$type", "$name");
+ %variable_fail(SWIG_TypeError, "$type", "$name");
}
}
@@ -266,7 +266,7 @@
%#ifndef SWIG_PRESERVE_CARRAY_SIZE
while (size && ($1[size - 1] == '\0')) --size;
%#endif
- $result = SWIG_FromCharPtrAndSize($1, size);
+ %set_varoutput(SWIG_FromCharPtrAndSize($1, size));
}
/* constant */
@@ -278,7 +278,7 @@
%#ifndef SWIG_PRESERVE_CARRAY_SIZE
while (size && ($value[size - 1] == '\0')) --size;
%#endif
- SWIG_set_constant("$symname", SWIG_FromCharPtrAndSize($value,size));
+ %set_constant("$symname", SWIG_FromCharPtrAndSize($value,size));
}
@@ -302,7 +302,7 @@
const Char [ANY] (Char temp[$result_dim0])
{
if (SWIG_AsCharArray($input, temp, $result_dim0) != SWIG_OK) {
- SWIG_dout_fail(SWIG_TypeError, "$type");
+ %dirout_fail(SWIG_TypeError, "$type");
}
$result = temp;
}
@@ -327,7 +327,7 @@
%#ifndef SWIG_PRESERVE_CARRAY_SIZE
while (size && ($1[size - 1] == '\0')) --size;
%#endif
- SWIG_raise(SWIG_FromCharPtrAndSize($1, size), "$type", 0);
+ %raise(SWIG_FromCharPtrAndSize($1, size), "$type", 0);
}
/* -------------------------------------------------------------------
@@ -337,13 +337,13 @@
%typemap(varout,noblock=1,fragment=#SWIG_FromCharPtrAndSize)
Char FIXSIZE[ANY], const Char FIXSIZE[ANY]
{
- $result = SWIG_FromCharPtrAndSize($1, $1_dim0);
+ %set_varoutput(SWIG_FromCharPtrAndSize($1, $1_dim0));
}
%typemap(out,noblock=1,fragment=#SWIG_FromCharPtrAndSize)
Char FIXSIZE[ANY], const Char FIXSIZE[ANY]
{
- SWIG_set_result(SWIG_FromCharPtrAndSize($1, $1_dim0));
+ %set_output(SWIG_FromCharPtrAndSize($1, $1_dim0));
}
#ifdef SWIG_DIRECTOR_TYPEMAPS
@@ -358,7 +358,7 @@
%typemap(throws,noblock=1,fragment=#SWIG_FromCharPtrAndSize)
Char FIXSIZE[ANY], const Char FIXSIZE[ANY] {
- SWIG_raise(SWIG_FromCharPtrAndSize($1, $1_dim0), "$type", 0);
+ %raise(SWIG_FromCharPtrAndSize($1, $1_dim0), "$type", 0);
}
/* ------------------------------------------------------------
@@ -371,13 +371,13 @@
(const Char *STRING, size_t LENGTH) (Char *buf = 0, size_t size = 0, int alloc = SWIG_OLDOBJ)
{
if (SWIG_AsCharPtrAndSize($input, &buf, &size, &alloc) != SWIG_OK) {
- SWIG_arg_fail(SWIG_TypeError,"$type",$argnum);
+ %argument_fail(SWIG_TypeError,"$type",$argnum);
}
- $1 = SWIG_static_cast(buf, $1_ltype);
- $2 = SWIG_numeric_cast(size - 1, $2_ltype);
+ $1 = %static_cast(buf, $1_ltype);
+ $2 = %numeric_cast(size - 1, $2_ltype);
}
%typemap(freearg,noblock=1) (Char *STRING, size_t LENGTH) {
- if (alloc$argnum == SWIG_NEWOBJ) SWIG_delete_array(buf$argnum);
+ if (alloc$argnum == SWIG_NEWOBJ) %delete_array(buf$argnum);
}
/* old 'int' form */
%typemap(in) (Char *STRING, int LENGTH) = (Char *STRING, size_t LENGTH);
@@ -390,13 +390,13 @@
(const Char *STRING, size_t SIZE) (Char *buf = 0, size_t size = 0, int alloc = SWIG_OLDOBJ)
{
if (SWIG_AsCharPtrAndSize($input, &buf, &size, &alloc) != SWIG_OK) {
- SWIG_arg_fail(SWIG_TypeError,"$type",$argnum);
+ %argument_fail(SWIG_TypeError,"$type",$argnum);
}
- $1 = SWIG_static_cast(buf, $1_ltype);
- $2 = SWIG_numeric_cast(size, $2_ltype);
+ $1 = %static_cast(buf, $1_ltype);
+ $2 = %numeric_cast(size, $2_ltype);
}
%typemap(freearg, noblock=1) (Char *STRING, size_t SIZE) {
- if (alloc$argnum == SWIG_NEWOBJ) SWIG_delete_array(buf$argnum);
+ if (alloc$argnum == SWIG_NEWOBJ) %delete_array(buf$argnum);
}
/* old 'int' form */
%typemap(in) (Char *STRING, int SIZE) = (Char *STRING, size_t SIZE);
@@ -411,13 +411,13 @@
(size_t LENGHT, const Char *STRING) (Char *buf = 0, size_t size = 0, int alloc = SWIG_OLDOBJ)
{
if (SWIG_AsCharPtrAndSize($input, &buf, &size, &alloc) != SWIG_OK) {
- SWIG_arg_fail(SWIG_TypeError,"$type",$argnum);
+ %argument_fail(SWIG_TypeError,"$type",$argnum);
}
- $2 = SWIG_static_cast(buf, $2_ltype) ;
- $1 = SWIG_numeric_cast(size - 1, $1_ltype) ;
+ $2 = %static_cast(buf, $2_ltype) ;
+ $1 = %numeric_cast(size - 1, $1_ltype) ;
}
%typemap(freearg, noblock=1) (size_t LENGTH, Char *STRING) {
- if (alloc$argnum == SWIG_NEWOBJ) SWIG_delete_array(buf$argnum);
+ if (alloc$argnum == SWIG_NEWOBJ) %delete_array(buf$argnum);
}
/* old 'int' form */
%typemap(in) (int LENGTH, Char *STRING) = (size_t LENGTH, Char *STRING);
@@ -429,13 +429,13 @@
(size_t SIZE, const Char *STRING) (Char *buf = 0, size_t size = 0, int alloc = SWIG_OLDOBJ)
{
if (SWIG_AsCharPtrAndSize($input, &buf, &size, &alloc) != SWIG_OK) {
- SWIG_arg_fail(SWIG_TypeError, "$type",$argnum);
+ %argument_fail(SWIG_TypeError, "$type",$argnum);
}
- $2 = SWIG_static_cast(buf, $2_ltype) ;
- $1 = SWIG_numeric_cast(size, $1_ltype) ;
+ $2 = %static_cast(buf, $2_ltype) ;
+ $1 = %numeric_cast(size, $1_ltype) ;
}
%typemap(freearg, noblock=1) (size_t SIZE, Char *STRING) {
- if (alloc$argnum == SWIG_NEWOBJ) SWIG_delete_array(buf$argnum);
+ if (alloc$argnum == SWIG_NEWOBJ) %delete_array(buf$argnum);
}
/* old 'int' form */
%typemap(in) (int SIZE, Char *STRING) = (size_t SIZE, Char *STRING);
@@ -444,11 +444,17 @@
%enddef
-%define %typemap_string(Char, CharName,
+
+/* ------------------------------------------------------------
+ * --- String fragment methods ---
+ * ------------------------------------------------------------ */
+
+
+%define %typemaps_string(Char, CharName,
SWIG_AsCharPtrAndSize,
SWIG_FromCharPtrAndSize,
- SWIG_CharPtrLen)
-/* String fragment methods */
+ SWIG_CharPtrLen,
+ FragLimits, CHAR_MIN, CHAR_MAX)
%fragment("SWIG_From"#CharName"Ptr","header",fragment=#SWIG_FromCharPtrAndSize) {
SWIGINTERNINLINE SWIG_Object
@@ -467,11 +473,9 @@ SWIG_From##CharName##Array(const Char *cptr, size_t size)
}
%fragment("SWIG_As" #CharName "Ptr","header",fragment=#SWIG_AsCharPtrAndSize) {
- SWIG_define(SWIG_As##CharName##Ptr(obj, val, alloc), SWIG_AsCharPtrAndSize(obj, val, NULL, alloc))
+ %define_as(SWIG_As##CharName##Ptr(obj, val, alloc), SWIG_AsCharPtrAndSize(obj, val, NULL, alloc))
}
-%check_swig_object()
-
%fragment("SWIG_As" #CharName "Array","header",fragment=#SWIG_AsCharPtrAndSize) {
SWIGINTERN int
SWIG_As##CharName##Array(SWIG_Object obj, Char *val, size_t size)
@@ -484,15 +488,49 @@ SWIG_As##CharName##Array(SWIG_Object obj, Char *val, size_t size)
if (csize) memcpy(val, cptr, csize*sizeof(Char));
if (csize < size) memset(val + csize, 0, (size - csize)*sizeof(Char));
}
- if (alloc == SWIG_NEWOBJ) SWIG_delete_array(cptr);
+ if (alloc == SWIG_NEWOBJ) %delete_array(cptr);
return SWIG_OK;
}
- if (alloc == SWIG_NEWOBJ) SWIG_delete_array(cptr);
+ if (alloc == SWIG_NEWOBJ) %delete_array(cptr);
}
return SWIG_TypeError;
}
}
+/* Char */
+
+%fragment(SWIG_From_frag(Char),"header",fragment=#SWIG_FromCharPtrAndSize) {
+SWIGINTERNINLINE SWIG_Object
+SWIG_From_dec(Char)(Char c)
+{
+ return SWIG_FromCharPtrAndSize(&c,1);
+}
+}
+
+%fragment(SWIG_AsVal_frag(Char),"header",
+ fragment="SWIG_As"#CharName"Array",
+ fragment=FragLimits,
+ fragment=SWIG_AsVal_frag(long)) {
+SWIGINTERN int
+SWIG_AsVal_dec(Char)(SWIG_Object obj, Char *val)
+{
+ int res = SWIG_As##CharName##Array(obj, val, 1);
+ if (res != SWIG_OK) {
+ long v;
+ res = SWIG_AsVal(long)(obj, (val ? &v : 0));
+ if (res == SWIG_OK) {
+ if ((CHAR_MIN <= v) && (v <= CHAR_MAX)) {
+ if (val) *val = %numeric_cast(v, Char);
+ } else {
+ res = SWIG_OverflowError;
+ }
+ }
+ }
+ return res;
+}
+}
+
+
%_typemap_string(Char,
SWIG_AsCharPtrAndSize,
SWIG_FromCharPtrAndSize,
diff --git a/Lib/typemaps/swigmacros.swg b/Lib/typemaps/swigmacros.swg
index 9cfca8670..7405ab367 100644
--- a/Lib/typemaps/swigmacros.swg
+++ b/Lib/typemaps/swigmacros.swg
@@ -2,13 +2,31 @@
* SWIG API. Portion only visible from SWIG
* ----------------------------------------------------------------------------- */
-/* basic preprocessor macros */
+/* -----------------------------------------------------------------------------
+ * Basic preprocessor macros
+ * ----------------------------------------------------------------------------- */
+
+#define %arg(Arg...) Arg
+#define %str(Type...) #Type
+#define %block(Block...) do { Block; } while(0)
+
+/* define a new macro */
+%define %define_as(Def, Val...)
+%#define Def Val
+%enddef
-#define SWIG_arg(Arg...) Arg
-#define SWIG_str(Type...) #Type
-#define SWIG_block(Block...) do { Block; } while(0)
+/* include C++ or else value */
+%define %ifcplusplus(cppval, nocppval)
+#ifdef __cplusplus
+cppval
+#else
+nocppval
+#endif
+%enddef
-/* casting operators */
+/* -----------------------------------------------------------------------------
+ * Casting operators
+ * ----------------------------------------------------------------------------- */
#ifdef SWIG_NO_CPLUSPLUS_CAST
/* Disable 'modern' cplusplus casting operators */
@@ -18,156 +36,74 @@
#endif
#if defined(__cplusplus) && defined(SWIG_CPLUSPLUS_CAST)
-# define SWIG_const_cast(a,Type...) const_cast<Type >(a)
-# define SWIG_static_cast(a,Type...) static_cast<Type >(a)
-# define SWIG_reinterpret_cast(a,Type...) reinterpret_cast<Type >(a)
-# define SWIG_numeric_cast(a,Type...) static_cast<Type >(a)
-# define SWIG_as_voidptr(a) const_cast<void *>(static_cast<const void *>(a))
-# define SWIG_as_voidptrptr(a) reinterpret_cast<void **>(a)
+# define %const_cast(a,Type...) const_cast<Type >(a)
+# define %static_cast(a,Type...) static_cast<Type >(a)
+# define %reinterpret_cast(a,Type...) reinterpret_cast<Type >(a)
+# define %numeric_cast(a,Type...) static_cast<Type >(a)
+# define %as_voidptr(a) const_cast<void *>(static_cast<const void *>(a))
+# define %as_voidptrptr(a) reinterpret_cast<void **>(a)
#else /* C case */
-# define SWIG_const_cast(a,Type...) (Type)(a)
-# define SWIG_static_cast(a,Type...) (Type)(a)
-# define SWIG_reinterpret_cast(a,Type...) (Type)(a)
-# define SWIG_numeric_cast(a,Type...) (Type)(a)
-# define SWIG_as_voidptr(a) (void *)(a)
-# define SWIG_as_voidptrptr(a) (void **)(a)
+# define %const_cast(a,Type...) (Type)(a)
+# define %static_cast(a,Type...) (Type)(a)
+# define %reinterpret_cast(a,Type...) (Type)(a)
+# define %numeric_cast(a,Type...) (Type)(a)
+# define %as_voidptr(a) (void *)(a)
+# define %as_voidptrptr(a) (void **)(a)
#endif /* __cplusplus */
-/* macros for allocating/freeing elements */
+/* -----------------------------------------------------------------------------
+ * Allocating/freeing elements
+ * ----------------------------------------------------------------------------- */
#if defined(__cplusplus)
-# define SWIG_new(Type...) (new Type)
-# define SWIG_new_copy(val,Type...) (new Type(SWIG_static_cast(val, const Type&)))
-# define SWIG_new_array(size,Type...) (new Type[size])
-# define SWIG_new_copy_array(ptr,size,Type...) SWIG_reinterpret_cast(memcpy(SWIG_new_array(size,Type), ptr, sizeof(Type)*(size)), Type*)
-# define SWIG_delete(cptr) delete cptr
-# define SWIG_delete_array(cptr) delete[] cptr
+# define %new_instance(Type...) (new Type)
+# define %new_copy(val,Type...) (new Type(%static_cast(val, const Type&)))
+# define %new_array(size,Type...) (new Type[size])
+# define %new_copy_array(ptr,size,Type...) %reinterpret_cast(memcpy(%new_array(size,Type), ptr, sizeof(Type)*(size)), Type*)
+# define %delete(cptr) delete cptr
+# define %delete_array(cptr) delete[] cptr
#else /* C case */
-# define SWIG_new(Type...) (Type *)malloc(sizeof(Type))
-# define SWIG_new_copy(val,Type...) (Type *)memcpy(SWIG_new(Type),&val,sizeof(Type))
-# define SWIG_new_array(size,Type...) (Type *)malloc((size)*sizeof(Type))
-# define SWIG_new_copy_array(ptr,size,Type...) (Type *)memcpy(SWIG_new_array(size,Type), ptr, sizeof(Type)*(size))
-# define SWIG_delete(cptr) free((char*)cptr)
-# define SWIG_delete_array(cptr) free((char*)cptr)
+# define %new_instance(Type...) (Type *)malloc(sizeof(Type))
+# define %new_copy(val,Type...) (Type *)memcpy(%new_instance(Type),&val,sizeof(Type))
+# define %new_array(size,Type...) (Type *)malloc((size)*sizeof(Type))
+# define %new_copy_array(ptr,size,Type...) (Type *)memcpy(%new_array(size,Type), ptr, sizeof(Type)*(size))
+# define %delete(cptr) free((char*)cptr)
+# define %delete_array(cptr) free((char*)cptr)
#endif /* __cplusplus */
-/* macros for fragments/typemaps */
-
-#define SWIG_Mangle(Type...) #@Type
-#define SWIG_Descriptor(Type...) SWIGTYPE_ ## #@Type
-#define SWIG_NameType(Name, Type...) SWIG_ ## Name ## _ ## #@Type
-#define SWIG_StringType(Name, Type...) "SWIG_" #Name "_" {Type}
-
-#define SWIG_AsVal(Type...) SWIG_NameType(AsVal, Type)
-#define SWIG_AsPtr(Type...) SWIG_NameType(AsPtr, Type)
-#define SWIG_As(Type...) SWIG_NameType(As, Type)
-#define SWIG_From(Type...) SWIG_NameType(From, Type)
-#define SWIG_Check(Type...) SWIG_NameType(Check, Type)
-#define SWIG_OrderType(Type...) SWIG_NameType(OrderType, Type)
-#define SWIG_EqualType(Type...) SWIG_NameType(EqualType, Type)
-
-#define SWIG_AsVal_dec(Type...) SWIG_NameType(AsVal, Type)
-#define SWIG_AsPtr_dec(Type...) SWIG_NameType(AsPtr, Type)
-#define SWIG_As_dec(Type...) SWIG_NameType(As, Type)
-#define SWIG_From_dec(Type...) SWIG_NameType(From, Type)
-#define SWIG_Check_dec(Type...) SWIG_NameType(Check, Type)
-
-#define SWIG_Traits_frag(Type...) SWIG_StringType(Traits, Type)
-#define SWIG_AsPtr_frag(Type...) SWIG_StringType(AsPtr, Type)
-#define SWIG_AsVal_frag(Type...) SWIG_StringType(AsVal, Type)
-#define SWIG_As_frag(Type...) SWIG_StringType(As, Type)
-#define SWIG_From_frag(Type...) SWIG_StringType(From, Type)
-#define SWIG_Check_frag(Type...) SWIG_StringType(Check, Type)
-
-#define SWIG_CCode(Type...) SWIG_NameType(TYPECHECK, Type)
-#define SWIG_CCode_frag(Type...) SWIG_StringType(TYPECHECK, Type)
-
-
-/* macros for result manipulation */
-
-#define SWIG_set_result(obj) SWIG_SetResultObj(obj)
-#define SWIG_append_result(obj) SWIG_AppendResultObj(obj)
-#define SWIG_set_constant(name,value) SWIG_SetConstantObj(name,value)
-
-/* macros for error manipulation */
-#define SWIG_NullRefFmt() "invalid null reference "
-#define SWIG_VarFailFmt(_type,_name) "in variable '"_name"' of type '"_type"'"
-#define SWIG_ArgFailFmt(_type,_argn) "in argument " #_argn" of type '" _type"'"
-#define SWIG_OutFailFmt(_type) "in output value of type '"_type"'"
-#define SWIG_ArgNullRefFmt(_type, _argn) SWIG_NullRefFmt() SWIG_ArgFailFmt(_type, _argn)
-#define SWIG_VarNullRefFmt(_type, _name) SWIG_NullRefFmt() SWIG_VarFailFmt(_type, _name)
-#define SWIG_OutNullRefFmt(_type) SWIG_NullRefFmt() SWIG_OutFailFmt(_type)
-
-#define SWIG_ArgFail(code,type,argn) SWIG_Error(code, SWIG_ArgFailFmt(type, argn))
-#define SWIG_VarFail(code,type,name) SWIG_Error(code, SWIG_VarFailFmt(type, name))
-#define SWIG_ArgNullRef(type,argn) SWIG_Error(SWIG_ValueError, SWIG_ArgNullRefFmt(type, argn))
-#define SWIG_VarNullRef(type,name) SWIG_Error(SWIG_ValueError, SWIG_VarNullRefFmt(type, name))
-#define SWIG_OutNullRef(type) SWIG_Error(SWIG_ValueError, SWIG_OutNullRefFmt(type))
-
-
-/* setting an error */
-#define SWIG_error(code,msg...) SWIG_Error(code, msg)
-#define SWIG_type_error(msg...) SWIG_Error(SWIG_TypeError, msg)
-
-
-/* setting an error and exit */
-#define SWIG_error_block(Block...) SWIG_block(Block)
-
-#define SWIG_arg_fail(code, type, arg) SWIG_error_block(SWIG_ArgFail(code, type, arg); SWIG_fail)
-#define SWIG_arg_nullref(type, arg) SWIG_error_block(SWIG_ArgNullRef(type, arg); SWIG_fail)
-
-#define SWIG_member_fail(code, type, name) SWIG_error_block(SWIG_VarFail(code, type, name); SWIG_fail)
-#define SWIG_member_nullref(type, name) SWIG_error_block(SWIG_VarNullRef(type, name); SWIG_fail)
-
-#define SWIG_global_fail(code, type, name) SWIG_error_block(SWIG_VarFail(code, type, name); SWIG_fail)
-#define SWIG_global_nullref(type, name) SWIG_error_block(SWIG_VarNullRef(type, name); SWIG_fail)
-
-#define SWIG_var_fail(code, type, name) SWIG_error_block(SWIG_VarFail(code, type, name); SWIG_fail)
-#define SWIG_var_nullref(type, name) SWIG_error_block(SWIG_VarNullRef(type, name); SWIG_fail)
+/* -----------------------------------------------------------------------------
+ * Swig names and mangling
+ * ----------------------------------------------------------------------------- */
-#define SWIG_dout_fail(code, type) SWIG_DirOutFail(code, SWIG_OutFailFmt(type))
-#define SWIG_dout_nullref(type) SWIG_DirOutFail(SWIG_ValueError, SWIG_OutNullRefFmt(type))
+#define %mangle(Type...) #@Type
+#define %name_type(Name, Type...) SWIG_ ## Name ## _ ## #@Type
+#define %string_type(Name, Type...) "SWIG_" #Name "_" {Type}
+#define %checkcode(Code) %name_type(TYPECHECK, Code)
-#define SWIG_raise(obj, type, desc) SWIG_error_block(SWIG_Raise(obj, type, desc); SWIG_fail)
/*
- Macros to define and check the Language dependent Swig object
-
- Use it, for example in Tcl, as
+ Macros to define language dependent object and the void object.
+ Use them, for example in Tcl, as
%define_swig_object(Tcl_Obj *)
+ %define_void_object(NULL)
*/
-#define SWIG_Object __NULL__
-%define %define_swig_object(Obj)
-#undef SWIG_Object
-#define SWIG_Object Obj
+/* VOID_Object */
+%define %define_void_object(Obj)
+#define VOID_Object Obj
%enddef
-%define %check_swig_object()
-#if SWIG_str(SWIG_Object) == "__NULL__"
-#error "SWIG_Object must be defined using %define_swig_object"
-#endif
+/* SWIG_Object */
+%define %define_swig_object(Obj)
+#define SWIG_Object Obj
%enddef
/* -----------------------------------------------------------------------------
- * Auxiliar macros used to write typemaps
+ * Auxiliar ugly macros used to write typemaps
* ----------------------------------------------------------------------------- */
-/* define a new macro */
-%define SWIG_define(Def, Val...)
-%#define Def Val
-%enddef
-
-/* include C++ or C value */
-%define SWIG_cplusplus(cppval, cval)
-#ifdef __cplusplus
-cppval
-#else
-cval
-#endif
-%enddef
/* for loop for macro with one argument */
%define %_formacro_1(macro, arg1,...)
@@ -212,6 +148,9 @@ macro(arg1, arg2)
%swig_equal_type and %swig_order_type flagged a type of having equal (==,!=)
and/or order methods (<=,>=,<,>).
*/
+#define SWIG_OrderType(Type...) %name_type(OrderType, Type)
+#define SWIG_EqualType(Type...) %name_type(EqualType, Type)
+
#define %swig_equal_type(...) %swig_mark_flag(SWIG_EqualType(__VA_ARGS__))
#define %swig_order_type(...) \
%swig_mark_flag(SWIG_EqualType(__VA_ARGS__)) \
@@ -234,11 +173,16 @@ _expr
%enddef
%define %evalif(_x,...)
- %_evalif(SWIG_arg(_x),SWIG_arg(__VA_ARGS__))
+ %_evalif(%arg(_x),%arg(__VA_ARGS__))
%enddef
%define %evalif_2(_x,_y,...)
- %_evalif_2(SWIG_arg(_x),SWIG_arg(_y),SWIG_arg(__VA_ARGS__))
+ %_evalif_2(%arg(_x),%arg(_y),%arg(__VA_ARGS__))
%enddef
+/* -----------------------------------------------------------------------------
+ * Include special macros for fragments
+ * ----------------------------------------------------------------------------- */
+
+%include <typemaps/fragmacros.swg>
diff --git a/Lib/typemaps/swigobject.swg b/Lib/typemaps/swigobject.swg
index 049e56ef0..23107cb3b 100644
--- a/Lib/typemaps/swigobject.swg
+++ b/Lib/typemaps/swigobject.swg
@@ -2,22 +2,24 @@
* Language Object * - Just pass straight through unmodified
* ------------------------------------------------------------ */
-%check_swig_object()
+#if !defined(SWIG_Object)
+#error "SWIG_Object must be defined using %define_swig_object"
+#endif
%typemap(in) SWIG_Object "$1 = $input;";
%typemap(out,noblock=1) SWIG_Object {
- SWIG_set_result($1);
+ $result = $1;
}
%typecheck(SWIG_TYPECHECK_POINTER) SWIG_Object "$1 = ($input != 0);";
%typemap(throws,noblock=1) SWIG_Object {
- SWIG_raise($1, "$type", 0);
+ %raise($1, "$type", 0);
}
%typemap(constcode,noblock=1) SWIG_Object {
- SWIG_set_constant("$symname", $value);
+ %set_constant("$symname", $value);
}
#ifdef SWIG_DIRECTOR_TYPEMAPS
diff --git a/Lib/typemaps/swigtype.swg b/Lib/typemaps/swigtype.swg
index 3556a9053..567fc4ae6 100644
--- a/Lib/typemaps/swigtype.swg
+++ b/Lib/typemaps/swigtype.swg
@@ -3,36 +3,39 @@
* ----------------------------------------------------------------------------- */
/* Pointers and arrays */
-%typemap(in, noblock=1) SWIGTYPE *, SWIGTYPE [] {
- if (SWIG_ConvertPtr($input, SWIG_as_voidptrptr(&$1),$descriptor, $disown) != SWIG_OK) {
- SWIG_arg_fail(SWIG_TypeError, "$type", $argnum);
+%typemap(in, noblock=1) SWIGTYPE * (void *argp), SWIGTYPE [] (void *argp) {
+ if (SWIG_ConvertPtr($input, &argp,$descriptor, $disown | %convertptr_flags) != SWIG_OK) {
+ %argument_fail(SWIG_TypeError, "$type", $argnum);
}
+ $1 = %reinterpret_cast(argp, $ltype);
}
%typemap(freearg) SWIGTYPE *, SWIGTYPE [] "";
-%typemap(in, noblock=1) SWIGTYPE* const& ($*ltype temp) {
- if (SWIG_ConvertPtr($input, SWIG_as_voidptrptr(&temp), $*descriptor, $disown) != SWIG_OK) {
- SWIG_arg_fail(SWIG_TypeError, "$*ltype", $argnum);
+%typemap(in, noblock=1) SWIGTYPE* const& (void *argp, $*ltype temp) {
+ if (SWIG_ConvertPtr($input, &argp, $*descriptor, $disown | %convertptr_flags) != SWIG_OK) {
+ %argument_fail(SWIG_TypeError, "$*ltype", $argnum);
}
+ temp = %reinterpret_cast(argp, $*ltype);
$1 = &temp;
}
/* Reference */
-%typemap(in, noblock=1) SWIGTYPE & {
- if (SWIG_ConvertPtr($input, SWIG_as_voidptrptr(&$1), $descriptor, 0) != SWIG_OK) {
- SWIG_arg_fail(SWIG_TypeError, "$type", $argnum);
+%typemap(in, noblock=1) SWIGTYPE & (void *argp) {
+ if (SWIG_ConvertPtr($input, &argp, $descriptor, %convertptr_flags) != SWIG_OK) {
+ %argument_fail(SWIG_TypeError, "$type", $argnum);
}
- if (!$1) { SWIG_arg_nullref("$type", $argnum); }
+ if (!argp) { %argument_nullref("$type", $argnum); }
+ $1 = %reinterpret_cast(argp, $ltype);
}
/* By value */
-%typemap(in,noblock=1) SWIGTYPE ($&ltype argp) {
- if (SWIG_ConvertPtr($input, SWIG_as_voidptrptr(&argp), $&descriptor, 0) != SWIG_OK) {
- SWIG_arg_fail(SWIG_TypeError, "$type", $argnum);
+%typemap(in,noblock=1) SWIGTYPE (void *argp) {
+ if (SWIG_ConvertPtr($input, &argp, $&descriptor, %convertptr_flags) != SWIG_OK) {
+ %argument_fail(SWIG_TypeError, "$type", $argnum);
}
- if (!argp) { SWIG_arg_nullref("$type", $argnum); }
- $1 = *argp;
+ if (!argp) { %argument_nullref("$type", $argnum); }
+ $1 = *(%reinterpret_cast(argp, $&ltype));
}
/* -----------------------------------------------------------------------------
@@ -41,16 +44,16 @@
/* Pointers, references */
%typemap(out,noblock=1) SWIGTYPE *, SWIGTYPE &, SWIGTYPE[] {
- SWIG_set_result(SWIG_NewPointerObj(SWIG_as_voidptr($1), $descriptor, $owner));
+ %set_output(SWIG_NewPointerObj(%as_voidptr($1), $descriptor, $owner | %newpointer_flags));
}
%typemap(out, noblock=1) SWIGTYPE* const& {
- SWIG_set_result(SWIG_NewPointerObj(SWIG_as_voidptr(*$1), $*descriptor, $owner));
+ %set_output(SWIG_NewPointerObj(%as_voidptr(*$1), $*descriptor, $owner | %newpointer_flags));
}
/* Return by value */
%typemap(out, noblock=1) SWIGTYPE {
- SWIG_set_result(SWIG_NewPointerObj(SWIG_new_copy($1, $ltype), $&descriptor, SWIG_POINTER_OWN));
+ %set_output(SWIG_NewPointerObj(%new_copy($1, $ltype), $&descriptor, SWIG_POINTER_OWN | %newpointer_flags));
}
/* -----------------------------------------------------------------------------
@@ -60,46 +63,46 @@
/* memberin/globalin/varin, for fix arrays. */
%typemap(memberin) SWIGTYPE [ANY] {
- $basetype *inp = SWIG_static_cast($input, $basetype *);
+ $basetype *inp = %static_cast($input, $basetype *);
if (inp) {
- $basetype *dest = SWIG_static_cast($1, $basetype *);
+ $basetype *dest = %static_cast($1, $basetype *);
size_t ii = 0;
for (; ii < $dim0; ++ii) dest[ii] = inp[ii];
} else {
- SWIG_member_nullref("$type","$name");
+ %variable_nullref("$type","$name");
}
}
%typemap(globalin) SWIGTYPE [ANY] {
- $basetype *inp = SWIG_static_cast($input, $basetype *);
+ $basetype *inp = %static_cast($input, $basetype *);
if (inp) {
- $basetype *dest = SWIG_static_cast($1, $basetype *);
+ $basetype *dest = %static_cast($1, $basetype *);
size_t ii = 0;
for (; ii < $dim0; ++ii) dest[ii] = inp[ii];
} else {
- SWIG_global_nullref("$type","$name");
+ %variable_nullref("$type","$name");
}
}
%typemap(varin,noblock=1) SWIGTYPE [ANY] {
$basetype *inp = 0;
- if (SWIG_ConvertPtr($input, SWIG_as_voidptrptr(&inp), $descriptor, 0) != SWIG_OK) {
- SWIG_var_fail(SWIG_TypeError, "$type", "$name");
+ if (SWIG_ConvertPtr($input, %as_voidptrptr(&inp), $descriptor, %convertptr_flags) != SWIG_OK) {
+ %variable_fail(SWIG_TypeError, "$type", "$name");
} else if (inp) {
size_t ii = 0;
- $basetype *dest = SWIG_static_cast($1, $basetype *);
+ $basetype *dest = %static_cast($1, $basetype *);
for (; ii < $dim0; ++ii) dest[ii] = inp[ii];
} else {
- SWIG_var_nullref("$type", "$name");
+ %variable_nullref("$type", "$name");
}
}
/* memberin/globalin/varin, for fix double arrays. */
%typemap(memberin) SWIGTYPE [ANY][ANY] {
- $basetype (*inp)[$dim1] = SWIG_static_cast($input, $basetype (*)[$dim1]);
+ $basetype (*inp)[$dim1] = %static_cast($input, $basetype (*)[$dim1]);
if (inp) {
- $basetype (*dest)[$dim1] = SWIG_static_cast($1, $basetype (*)[$dim1]);
+ $basetype (*dest)[$dim1] = %static_cast($1, $basetype (*)[$dim1]);
size_t ii = 0;
for (; ii < $dim0; ++ii) {
$basetype *ip = inp[ii];
@@ -108,18 +111,18 @@
size_t jj = 0;
for (; jj < $dim1; ++jj) dp[jj] = ip[jj];
} else {
- SWIG_member_nullref("$type","$name");
+ %variable_nullref("$type","$name");
}
}
} else {
- SWIG_member_nullref("$type","$name");
+ %variable_nullref("$type","$name");
}
}
%typemap(globalin) SWIGTYPE [ANY][ANY] {
- $basetype (*inp)[$dim1] = SWIG_static_cast($input, $basetype (*)[$dim1]);
+ $basetype (*inp)[$dim1] = %static_cast($input, $basetype (*)[$dim1]);
if (inp) {
- $basetype (*dest)[$dim1] = SWIG_static_cast($1, $basetype (*)[$dim1]);
+ $basetype (*dest)[$dim1] = %static_cast($1, $basetype (*)[$dim1]);
size_t ii = 0;
for (; ii < $dim0; ++ii) {
$basetype *ip = inp[ii];
@@ -128,20 +131,20 @@
size_t jj = 0;
for (; jj < $dim1; ++jj) dp[jj] = ip[jj];
} else {
- SWIG_global_nullref("$type","$name");
+ %variable_nullref("$type","$name");
}
}
} else {
- SWIG_global_nullref("$type","$name");
+ %variable_nullref("$type","$name");
}
}
%typemap(varin,noblock=1) SWIGTYPE [ANY][ANY] {
$basetype (*inp)[$dim1] = 0;
- if (SWIG_ConvertPtr($input, SWIG_as_voidptrptr(&inp), $descriptor, 0) != SWIG_OK) {
- SWIG_var_fail(SWIG_TypeError, "$type", "$name");
+ if (SWIG_ConvertPtr($input, %as_voidptrptr(&inp), $descriptor, %convertptr_flags) != SWIG_OK) {
+ %variable_fail(SWIG_TypeError, "$type", "$name");
} else if (inp) {
- $basetype (*dest)[$dim1] = SWIG_static_cast($1, $basetype (*)[$dim1]);
+ $basetype (*dest)[$dim1] = %static_cast($1, $basetype (*)[$dim1]);
size_t ii = 0;
for (; ii < $dim0; ++ii) {
$basetype *ip = inp[ii];
@@ -150,11 +153,11 @@
size_t jj = 0;
for (; jj < $dim1; ++jj) dp[jj] = ip[jj];
} else {
- SWIG_var_nullref("$type", "$name");
+ %variable_nullref("$type", "$name");
}
}
} else {
- SWIG_var_nullref("$type", "$name");
+ %variable_nullref("$type", "$name");
}
}
@@ -162,37 +165,37 @@
%typemap(varin,noblock=1) SWIGTYPE * {
void *temp = 0;
- if (SWIG_ConvertPtr($input, &temp, $descriptor, 0) != SWIG_OK) {
- SWIG_var_fail(SWIG_TypeError, "$type", "$name");
+ if (SWIG_ConvertPtr($input, &temp, $descriptor, %convertptr_flags) != SWIG_OK) {
+ %variable_fail(SWIG_TypeError, "$type", "$name");
}
$1 = ($ltype) temp;
}
%typemap(varin,noblock=1,warning="462:Unable to set dimensionless array variable") SWIGTYPE []
{
- SWIG_var_fail(SWIG_AttributeError, "$type", "read-only $name");
+ %variable_fail(SWIG_AttributeError, "$type", "read-only $name");
}
%typemap(varin,noblock=1) SWIGTYPE & {
void *temp = 0;
- if (SWIG_ConvertPtr($input, &temp, $descriptor, 0) != SWIG_OK) {
- SWIG_var_fail(SWIG_TypeError, "$type", "$name");
+ if (SWIG_ConvertPtr($input, &temp, $descriptor, %convertptr_flags) != SWIG_OK) {
+ %variable_fail(SWIG_TypeError, "$type", "$name");
}
if (!temp) {
- SWIG_var_nullref("$type", "$name");
+ %variable_nullref("$type", "$name");
}
- $1 = *(SWIG_reinterpret_cast(temp, $ltype));
+ $1 = *(%reinterpret_cast(temp, $ltype));
}
%typemap(varin,noblock=1) SWIGTYPE {
void *temp = 0;
- if (SWIG_ConvertPtr($input, &temp, $&descriptor, 0) != SWIG_OK) {
- SWIG_var_fail(SWIG_TypeError, "$type", "$name");
+ if (SWIG_ConvertPtr($input, &temp, $&descriptor, %convertptr_flags) != SWIG_OK) {
+ %variable_fail(SWIG_TypeError, "$type", "$name");
}
if (!temp) {
- SWIG_var_nullref("$type", "$name");
+ %variable_nullref("$type", "$name");
}
- $1 = *(SWIG_reinterpret_cast(temp, $&type));
+ $1 = *(%reinterpret_cast(temp, $&type));
}
/* -----------------------------------------------------------------------------
@@ -201,21 +204,21 @@
/* Pointers and arrays */
%typemap(varout, noblock=1) SWIGTYPE * {
- $result = SWIG_NewPointerObj(SWIG_as_voidptr($1), $descriptor, 0);
+ %set_varoutput(SWIG_NewPointerObj(%as_voidptr($1), $descriptor, %newpointer_flags));
}
%typemap(varout, noblock=1) SWIGTYPE [] {
- $result = SWIG_NewPointerObj(SWIG_as_voidptr($1), $descriptor, 0);
+ %set_varoutput(SWIG_NewPointerObj(%as_voidptr($1), $descriptor, %newpointer_flags));
}
/* References */
%typemap(varout, noblock=1) SWIGTYPE & {
- $result = SWIG_NewPointerObj(SWIG_as_voidptr(&$1), $descriptor, 0);
+ %set_varoutput(SWIG_NewPointerObj(%as_voidptr(&$1), $descriptor, %newpointer_flags));
}
/* Value */
%typemap(varout, noblock=1) SWIGTYPE {
- $result = SWIG_NewPointerObj(SWIG_as_voidptr(&$1), $&descriptor, 0);
+ %set_varoutput(SWIG_NewPointerObj(%as_voidptr(&$1), $&descriptor, %newpointer_flags));
}
/* ------------------------------------------------------------
@@ -237,50 +240,6 @@
$1 = (SWIG_ConvertPtr($input, &ptr, $&descriptor, 0) == SWIG_OK) && (ptr != 0);
}
-/* ------------------------------------------------------------
- * --- CLASS::* typemaps ---
- * ------------------------------------------------------------ */
-
-%typemap(in,noblock=1) SWIGTYPE (CLASS::*) {
- if (SWIG_ConvertMember($input, SWIG_as_voidptr(&$1), sizeof($type),$descriptor, 0) != SWIG_OK) {
- SWIG_arg_fail(SWIG_TypeError,"$type",$argnum);
- }
-}
-
-%typemap(out,noblock=1) SWIGTYPE (CLASS::*) {
- SWIG_set_result(SWIG_NewMemberObj(SWIG_as_voidptr(&$1), sizeof($type), $descriptor));
-}
-
-%typemap(varin,noblock=1) SWIGTYPE (CLASS::*) {
- if (SWIG_ConvertMember($input,SWIG_as_voidptr(&$1), sizeof($type), $descriptor,0) != SWIG_OK) {
- SWIG_var_fail(SWIG_TypeError, "$type", "$name");
- }
-}
-
-%typemap(varout,noblock=1) SWIGTYPE (CLASS::*) {
- $result = SWIG_NewMemberObj(SWIG_as_voidptr(&$1), sizeof($type), $descriptor);
-}
-
-
-/* ------------------------------------------------------------
- * --- function ptr typemaps ---
- * ------------------------------------------------------------ */
-
-/*
- ISO C++ doesn't allow direct casting of a function ptr to a object
- ptr. So, maybe the ptr sizes are not the same, and we need to take
- some providences.
- */
-%typemap(in, noblock=1) SWIGTYPE ((*)(ANY)) {
- if (SWIG_ConvertFunctionPtr($input, SWIG_as_voidptrptr(&$1), $descriptor, 0) != SWIG_OK) {
- SWIG_arg_fail(SWIG_TypeError,"$type",$argnum);
- }
-}
-
-%typemap(out, noblock=1) SWIGTYPE ((*)(ANY)) {
- SWIG_set_result(SWIG_NewFunctionPtrObj((void *)($1), $descriptor));
-}
-
/* -----------------------------------------------------------------------------
* --- Director typemaps --- *
@@ -292,37 +251,37 @@
/* directorin */
%typemap(directorin,noblock=1) SWIGTYPE* {
- $input = SWIG_NewPointerObj(SWIG_as_voidptr($1_name), $descriptor, 0);
+ $input = SWIG_NewPointerObj(%as_voidptr($1_name), $descriptor, %newpointer_flags);
}
%typemap(directorin,noblock=1) SWIGTYPE {
- $input = SWIG_NewPointerObj(SWIG_as_voidptr(&$1_name), $&descriptor, 0);
+ $input = SWIG_NewPointerObj(%as_voidptr(&$1_name), $&descriptor, %newpointer_flags);
}
%typemap(directorin,noblock=1) SWIGTYPE& {
- $input = SWIG_NewPointerObj(SWIG_as_voidptr(&$1_name), $descriptor, 0);
+ $input = SWIG_NewPointerObj(%as_voidptr(&$1_name), $descriptor, %newpointer_flags);
}
/* directorout */
%typemap(directorout,noblock=1) SWIGTYPE (void * argp) {
- if (SWIG_ConvertPtr($input,&argp,$&descriptor, 0) != SWIG_OK) {
- SWIG_dout_fail(SWIG_TypeError,"$type");
+ if (SWIG_ConvertPtr($input,&argp,$&descriptor, %convertptr_flags) != SWIG_OK) {
+ %dirout_fail(SWIG_TypeError,"$type");
}
- $result = *(SWIG_reinterpret_cast(argp, $&ltype));
+ $result = *(%reinterpret_cast(argp, $&ltype));
}
%typemap(directorout,noblock=1) SWIGTYPE *(void *argp), SWIGTYPE [](void *argp) {
- if (SWIG_ConvertPtr($input, &argp, $descriptor, 0) != SWIG_OK) {
- SWIG_dout_fail(SWIG_TypeError,"$type");
+ if (SWIG_ConvertPtr($input, &argp, $descriptor, %convertptr_flags) != SWIG_OK) {
+ %dirout_fail(SWIG_TypeError,"$type");
}
- $result = SWIG_reinterpret_cast(argp, $ltype);
+ $result = %reinterpret_cast(argp, $ltype);
}
%typemap(directorout,noblock=1) SWIGTYPE &(void *argp) {
- if (SWIG_ConvertPtr($input, &argp, $descriptor, $disown ) != SWIG_OK) {
- SWIG_dout_fail(SWIG_TypeError,"$type");
+ if (SWIG_ConvertPtr($input, &argp, $descriptor, $disown | %convertptr_flags) != SWIG_OK) {
+ %dirout_fail(SWIG_TypeError,"$type");
}
- if (!argp) { SWIG_dout_nullref("$type"); }
- $result = SWIG_reinterpret_cast(argp, $ltype);
+ if (!argp) { %dirout_nullref("$type"); }
+ $result = %reinterpret_cast(argp, $ltype);
}
#endif /* SWIG_DIRECTOR_TYPEMAPS */
@@ -332,44 +291,84 @@
* ------------------------------------------------------------ */
%typemap(constcode,noblock=1) SWIGTYPE *, SWIGTYPE &, SWIGTYPE []{
- SWIG_set_constant("$symname", SWIG_NewPointerObj(SWIG_as_voidptr($value),$descriptor,0));
-}
-
-%typemap(constcode,noblock=1) SWIGTYPE (CLASS::*) {
- SWIG_set_constant("$symname", SWIG_NewPackedObj(SWIG_as_voidptr(&$value), sizeof($type), $descriptor, 0));
+ %set_constant("$symname", SWIG_NewPointerObj(%as_voidptr($value),$descriptor,%newpointer_flags));
}
%typemap(constcode,noblock=1) SWIGTYPE {
- SWIG_set_constant("$symname", SWIG_NewPointerObj(SWIG_as_voidptr(&$value),$&descriptor,0));
-}
-
-%typemap(constcode,noblock=1) SWIGTYPE ((*)(ANY)){
- if (sizeof($type) == sizeof(void *)) {
- SWIG_set_constant("$symname", SWIG_NewPointerObj((void *)$value, $descriptor, 0));
- } else {
- SWIG_set_constant("$symname", SWIG_NewPackedObj((void *)$value, sizeof($type), $descriptor, 0));
- }
+ %set_constant("$symname", SWIG_NewPointerObj(%as_voidptr(&$value),$&descriptor,%newpointer_flags));
}
-
/* ------------------------------------------------------------
* --- Exception handling ---
* ------------------------------------------------------------ */
%typemap(throws,noblock=1) SWIGTYPE {
- SWIG_raise(SWIG_NewPointerObj(SWIG_new_copy($1, $ltype),$&descriptor,SWIG_POINTER_OWN), "$type", $&descriptor);
+ %raise(SWIG_NewPointerObj(%new_copy($1, $ltype),$&descriptor,SWIG_POINTER_OWN), "$type", $&descriptor);
}
%typemap(throws,noblock=1) SWIGTYPE * {
- SWIG_raise(SWIG_NewPointerObj(SWIG_as_voidptr($1),$descriptor,0), "$type", $descriptor);
+ %raise(SWIG_NewPointerObj(%as_voidptr($1),$descriptor,0), "$type", $descriptor);
}
%typemap(throws,noblock=1) SWIGTYPE [ANY] {
- SWIG_raise(SWIG_NewPointerObj(SWIG_as_voidptr($1),$descriptor,0), "$type", $descriptor);
+ %raise(SWIG_NewPointerObj(%as_voidptr($1),$descriptor,0), "$type", $descriptor);
}
%typemap(throws,noblock=1) SWIGTYPE & {
- SWIG_raise(SWIG_NewPointerObj(SWIG_as_voidptr(&$1),$descriptor,0), "$type", $descriptor);
+ %raise(SWIG_NewPointerObj(%as_voidptr(&$1),$descriptor,0), "$type", $descriptor);
+}
+
+/* ------------------------------------------------------------
+ * --- CLASS::* typemaps ---
+ * ------------------------------------------------------------ */
+
+%typemap(in,noblock=1) SWIGTYPE (CLASS::*) {
+ if (SWIG_ConvertMember($input, %as_voidptr(&$1), sizeof($type),$descriptor) != SWIG_OK) {
+ %argument_fail(SWIG_TypeError,"$type",$argnum);
+ }
+}
+
+%typemap(out,noblock=1) SWIGTYPE (CLASS::*) {
+ %set_output(SWIG_NewMemberObj(%as_voidptr(&$1), sizeof($type), $descriptor));
+}
+
+%typemap(varin,noblock=1) SWIGTYPE (CLASS::*) {
+ if (SWIG_ConvertMember($input,%as_voidptr(&$1), sizeof($type), $descriptor) != SWIG_OK) {
+ %variable_fail(SWIG_TypeError, "$type", "$name");
+ }
+}
+
+%typemap(varout,noblock=1) SWIGTYPE (CLASS::*) {
+ %set_varoutput(SWIG_NewMemberObj(%as_voidptr(&$1), sizeof($type), $descriptor));
+}
+
+%typemap(constcode,noblock=1) SWIGTYPE (CLASS::*) {
+ %set_constant("$symname", SWIG_NewMemberObj(%as_voidptr(&$value), sizeof($type), $descriptor));
+}
+
+
+/* ------------------------------------------------------------
+ * --- function ptr typemaps ---
+ * ------------------------------------------------------------ */
+
+/*
+ ISO C++ doesn't allow direct casting of a function ptr to a object
+ ptr. So, maybe the ptr sizes are not the same, and we need to take
+ some providences.
+ */
+%typemap(in, noblock=1) SWIGTYPE ((*)(ANY)) {
+ if (SWIG_ConvertFunctionPtr($input, %as_voidptrptr(&$1), $descriptor) != SWIG_OK) {
+ %argument_fail(SWIG_TypeError,"$type",$argnum);
+ }
+}
+
+%typemap(out, noblock=1) SWIGTYPE ((*)(ANY)) {
+ %set_output(SWIG_NewFunctionPtrObj((void *)($1), $descriptor));
+}
+
+
+%typemap(constcode, noblock=1) SWIGTYPE ((*)(ANY)){
+ %set_constant("$symname", SWIG_NewFunctionPtrObj((void *)$value, $descriptor));
}
/* ------------------------------------------------------------
@@ -384,15 +383,15 @@
/* DISOWN typemap */
%typemap(in, noblock=1) SWIGTYPE *DISOWN {
- if (SWIG_ConvertPtr($input, SWIG_as_voidptrptr(&$1), $descriptor, SWIG_POINTER_DISOWN) != SWIG_OK) {
- SWIG_arg_fail(SWIG_TypeError,"$type", $argnum);
+ if (SWIG_ConvertPtr($input, %as_voidptrptr(&$1), $descriptor, SWIG_POINTER_DISOWN | %convertptr_flags) != SWIG_OK) {
+ %argument_fail(SWIG_TypeError,"$type", $argnum);
}
}
%typemap(varin,noblock=1) SWIGTYPE *DISOWN {
void *temp = 0;
- if (SWIG_ConvertPtr($input, &temp, $descriptor, SWIG_POINTER_DISOWN) != SWIG_OK) {
- SWIG_var_fail(SWIG_TypeError, "$type", "$name");
+ if (SWIG_ConvertPtr($input, &temp, $descriptor, SWIG_POINTER_DISOWN | %convertptr_flags) != SWIG_OK) {
+ %variable_fail(SWIG_TypeError, "$type", "$name");
}
$1 = ($ltype) temp;
}
@@ -400,27 +399,27 @@
/* DYNAMIC typemap */
%typemap(out,noblock=1) SWIGTYPE *DYNAMIC, SWIGTYPE &DYNAMIC {
- SWIG_set_result(SWIG_NewPointerObj(SWIG_as_voidptr($1), SWIG_TypeDynamicCast($descriptor, SWIG_as_voidptrptr(&$1)), $owner));
+ %set_output(SWIG_NewPointerObj(%as_voidptr($1), SWIG_TypeDynamicCast($descriptor, %as_voidptrptr(&$1)), $owner | %newpointer_flags));
}
/* INSTANCE typemap */
%typemap(out,noblock=1) SWIGTYPE INSTANCE {
- SWIG_set_result(SWIG_NewInstanceObj(SWIG_new_copy($1, $1_ltype), $&1_descriptor,SWIG_POINTER_OWN));
+ %set_output(SWIG_NewInstanceObj(%new_copy($1, $1_ltype), $&1_descriptor, SWIG_POINTER_OWN | %newinstance_flags));
}
%typemap(out,noblock=1) SWIGTYPE *INSTANCE, SWIGTYPE &INSTANCE, SWIGTYPE INSTANCE[] {
- SWIG_set_result(SWIG_NewInstanceObj(SWIG_as_voidptr($1), $1_descriptor, $owner));
+ %set_output(SWIG_NewInstanceObj(%as_voidptr($1), $1_descriptor, $owner | %newinstance_flags));
}
%typemap(varout,noblock=1) SWIGTYPE *INSTANCE, SWIGTYPE INSTANCE[] {
- $result = SWIG_NewInstanceObj(SWIG_as_voidptr($1), $1_descriptor, 0);
+ %set_varoutput(SWIG_NewInstanceObj(%as_voidptr($1), $1_descriptor, %newinstance_flags));
}
%typemap(varout,noblock=1) SWIGTYPE &INSTANCE {
- $result = SWIG_NewInstanceObj(SWIG_as_voidptr(&$1), $1_descriptor, 0);
+ %set_varoutput(SWIG_NewInstanceObj(%as_voidptr(&$1), $1_descriptor, %newinstance_flags));
}
%typemap(varout,noblock=1) SWIGTYPE INSTANCE {
- $result = SWIG_NewInstanceObj(SWIG_as_voidptr(&$1), $&1_descriptor, 0);
+ %set_varoutput(SWIG_NewInstanceObj(%as_voidptr(&$1), $&1_descriptor, %newinstance_flags));
}
diff --git a/Lib/typemaps/swigtypemaps.swg b/Lib/typemaps/swigtypemaps.swg
new file mode 100644
index 000000000..2061e2ea3
--- /dev/null
+++ b/Lib/typemaps/swigtypemaps.swg
@@ -0,0 +1,79 @@
+/* -----------------------------------------------------------------------------
+ * Typemap specializations
+ * ----------------------------------------------------------------------------- */
+
+/* flags for new/convert methods */
+
+#ifndef %convertptr_flags
+%ignore %convertptr_flags;
+#define %convertptr_flags 0
+#endif
+
+#ifndef %newpointer_flags
+%ignore %newpointer_flags;
+#define %newpointer_flags 0
+#endif
+
+#ifndef %newinstance_flags
+%ignore %newinstance_flags;
+#define %newinstance_flags 0
+#endif
+
+/* output and constant manipulation */
+
+#ifndef %set_varoutput
+#define %set_varoutput(obj) $result = obj
+#endif
+
+#ifndef %set_output
+#define %set_output(obj) $result = obj
+#endif
+
+#ifndef %append_output
+#define %append_output(obj) $result = SWIG_AppendOutput($result,obj)
+#endif
+
+#ifndef %set_constant
+#define %set_constant(name,value) SWIG_SetConstant(name,value)
+#endif
+
+/* setting an error and exit */
+#define %error_block(Block...) %block(Block)
+#define %argument_fail(code, type, argn) %error_block(SWIG_Error(code, %argfail_fmt(type, argn)); SWIG_fail)
+#define %argument_nullref(type, argn) %error_block(SWIG_Error(SWIG_ValueError, %argnullref_fmt(type, argn)); SWIG_fail)
+#define %variable_fail(code, type, name) %error_block(SWIG_Error(code, %varfail_fmt(type, name)); SWIG_fail)
+#define %variable_nullref(type, name) %error_block(SWIG_Error(SWIG_ValueError, %varnullref_fmt(type, name)); SWIG_fail)
+
+
+#ifndef %raise
+#define %raise(obj, type, desc) %error_block(SWIG_Raise(obj, type, desc); SWIG_fail)
+#endif
+
+#ifdef SWIG_DIRECTOR_TYPEMAPS
+#define %dirout_fail(code, type) SWIG_DirOutFail(code, %outfail_fmt(type))
+#define %dirout_nullref(type) SWIG_DirOutFail(SWIG_ValueError, %outnullref_fmt(type))
+#endif
+
+
+
+
+
+
+/* -----------------------------------------------------------------------------
+ * All the typemaps
+ * ----------------------------------------------------------------------------- */
+
+%include <typemaps/fragments.swg>
+%include <typemaps/exception.swg>
+%include <typemaps/swigtype.swg>
+%include <typemaps/void.swg>
+%include <typemaps/swigobject.swg>
+%include <typemaps/valtypes.swg>
+%include <typemaps/ptrtypes.swg>
+%include <typemaps/inoutlist.swg>
+%include <typemaps/primtypes.swg>
+%include <typemaps/string.swg>
+%include <typemaps/misctypes.swg>
+%include <typemaps/enumint.swg>
+
+
diff --git a/Lib/typemaps/typemaps.swg b/Lib/typemaps/typemaps.swg
index 9b200b810..55099de39 100644
--- a/Lib/typemaps/typemaps.swg
+++ b/Lib/typemaps/typemaps.swg
@@ -162,6 +162,6 @@ phased out in future releases.
#ifdef SWIG_INOUT_NODEF
-%apply_checkctypes(%typemap_inoutn)
+%apply_checkctypes(%typemaps_inoutn)
#endif
diff --git a/Lib/typemaps/valtypes.swg b/Lib/typemaps/valtypes.swg
index 290370f88..973a8723e 100644
--- a/Lib/typemaps/valtypes.swg
+++ b/Lib/typemaps/valtypes.swg
@@ -2,68 +2,89 @@
* Value typemaps (Type, const Type&) for value types, such as
* fundamental types (int, double), that define the AsVal/From
* methods.
+ *
+ * To apply them, just use one of the following macros:
+ *
+ * %typemaps_from(FromMeth, FromFrag, Type)
+ * %typemaps_asval(CheckCode, AsValMeth, AsValFrag, Type)
+ * %typemaps_asvalfrom(CheckCode, AsValMeth, FromMeth, AsValFrag, FromFrag, Type)
+ *
+ * or the simpler and normalize form:
+ *
+ * %typemaps_asvalfromn(CheckCode, Type)
+ *
+ * Also, you can use the individual typemap definitions:
+ *
+ * %value_in_typemap(asval_meth,frag,Type)
+ * %value_varin_typemap(asval_meth,frag,Type)
+ * %value_typecheck_typemap(checkcode,asval_meth,frag,Type)
+ * %value_directorout_typemap(asval_meth,frag,Type)
+ *
+ * %value_out_typemap(from_meth,frag,Type)
+ * %value_varout_typemap(from_meth,frag,Type)
+ * %value_constcode_typemap(from_meth,frag,Type)
+ * %value_directorin_typemap(from_meth,frag,Type)
+ * %value_throws_typemap(from_meth,frag,Type)
+ *
*---------------------------------------------------------------------*/
/* in */
-%define SWIG_VALUE_IN_TYPEMAP(asval_meth,frag,Type...)
+%define %value_in_typemap(asval_meth,frag,Type...)
%typemap(in,noblock=1,fragment=frag) Type (Type val, int ecode = 0) {
ecode = asval_meth($input, &val);
if (ecode != SWIG_OK) {
- SWIG_arg_fail(ecode, "$ltype", $argnum);
- } else {
- $1 = SWIG_static_cast(val,$ltype);
- }
+ %argument_fail(ecode, "$ltype", $argnum);
+ }
+ $1 = %static_cast(val,$ltype);
}
%typemap(in,noblock=1,fragment=frag) const Type & ($*ltype temp, Type val, int ecode = 0) {
ecode = asval_meth($input, &val);
if (ecode != SWIG_OK) {
- SWIG_arg_fail(ecode, "$*ltype", $argnum);
- } else {
- temp = SWIG_static_cast(val, $*ltype);
- $1 = &temp;
- }
+ %argument_fail(ecode, "$*ltype", $argnum);
+ }
+ temp = %static_cast(val, $*ltype);
+ $1 = &temp;
}
%enddef
/* out */
-%define SWIG_VALUE_OUT_TYPEMAP(from_meth,frag,Type...)
+%define %value_out_typemap(from_meth,frag,Type...)
%typemap(out,noblock=1,fragment=frag) Type, const Type {
- SWIG_set_result(from_meth(SWIG_static_cast($1,Type)));
+ %set_output(from_meth(%static_cast($1,Type)));
}
%typemap(out,noblock=1,fragment=frag) const Type& {
- SWIG_set_result(from_meth(SWIG_static_cast(*$1,Type)));
+ %set_output(from_meth(%static_cast(*$1,Type)));
}
%enddef
/* varin */
-%define SWIG_VALUE_VARIN_TYPEMAP(asval_meth,frag,Type...)
+%define %value_varin_typemap(asval_meth,frag,Type...)
%typemap(varin,noblock=1,fragment=frag) Type {
Type val;
int res = asval_meth($input, &val);
if (res != SWIG_OK) {
- SWIG_var_fail(res, "$type", "$name");
- } else {
- $1 = SWIG_static_cast(val,$ltype);
+ %variable_fail(res, "$type", "$name");
}
+ $1 = %static_cast(val,$ltype);
}
%enddef
/* varout */
-%define SWIG_VALUE_VAROUT_TYPEMAP(from_meth,frag,Type...)
+%define %value_varout_typemap(from_meth,frag,Type...)
%typemap(varout,noblock=1,fragment=frag) Type, const Type& {
- $result = from_meth(SWIG_static_cast($1,$basetype));
+ %set_varoutput(from_meth(%static_cast($1,$basetype)));
}
%enddef
/* constant installation code */
-%define SWIG_VALUE_CONSTCODE_TYPEMAP(from_meth,frag,Type...)
+%define %value_constcode_typemap(from_meth,frag,Type...)
%typemap(constcode,noblock=1,fragment=frag) Type {
- SWIG_set_constant("$symname", from_meth(SWIG_static_cast($value,Type)));
+ %set_constant("$symname", from_meth(%static_cast($value,Type)));
}
%enddef
@@ -72,41 +93,41 @@
/* directorin */
-%define SWIG_VALUE_DIRECTORIN_TYPEMAP(from_meth,frag,Type...)
+%define %value_directorin_typemap(from_meth,frag,Type...)
%typemap(directorin,noblock=1,fragment=frag) Type *DIRECTORIN {
- $input = from_meth(SWIG_static_cast(*$1_name,Type));
+ $input = from_meth(%static_cast(*$1_name,Type));
}
%typemap(directorin,noblock=1,fragment=frag) Type, const Type& {
- $input = from_meth(SWIG_static_cast($1_name,Type));
+ $input = from_meth(%static_cast($1_name,Type));
}
%enddef
/* directorout */
-%define SWIG_VALUE_DIRECTOROUT_TYPEMAP(asval_meth,frag,Type...)
+%define %value_directorout_typemap(asval_meth,frag,Type...)
%typemap(directorargout,noblock=1,fragment=frag) Type *DIRECTOROUT {
Type val;
int res = asval_meth($input, &val);
if (res != SWIG_OK) {
- SWIG_dout_fail(res, "$type");
+ %dirout_fail(res, "$type");
}
- *$result = SWIG_static_cast(val, $type);
+ *$result = %static_cast(val, $type);
}
%typemap(directorout,noblock=1,fragment=frag) Type {
Type val;
int res = asval_meth($input, &val);
if (res != SWIG_OK) {
- SWIG_dout_fail(res, "$type");
+ %dirout_fail(res, "$type");
}
- $result = SWIG_static_cast(val,$type);
+ $result = %static_cast(val,$type);
}
%typemap(directorout,noblock=1,fragment=frag,warning=SWIG_WARN_TYPEMAP_THREAD_UNSAFE) const Type& {
Type val;
int res = asval_meth($input, &val);
if (res != SWIG_OK) {
- SWIG_dout_fail(res, "$type");
+ %dirout_fail(res, "$type");
}
- static $basetype temp = SWIG_static_cast(val, $basetype);
+ static $basetype temp = %static_cast(val, $basetype);
$result = &temp;
}
%typemap(directorout,fragment=frag) Type &DIRECTOROUT = Type
@@ -114,23 +135,23 @@
#else
-#define SWIG_VALUE_DIRECTORIN_TYPEMAP(from_meth,frag,Type...)
-#define SWIG_VALUE_DIRECTOROUT_TYPEMAP(asval_meth,frag,Type...)
+#define %value_directorin_typemap(from_meth,frag,Type...)
+#define %value_directorout_typemap(asval_meth,frag,Type...)
#endif /* SWIG_DIRECTOR_TYPEMAPS */
/* throws */
-%define SWIG_VALUE_THROWS_TYPEMAP(from_meth,frag,Type...)
+%define %value_throws_typemap(from_meth,frag,Type...)
%typemap(throws,noblock=1,fragment=frag) Type {
- SWIG_raise(from_meth(SWIG_static_cast($1,Type)), "$type", 0);
+ %raise(from_meth(%static_cast($1,Type)), "$type", 0);
}
%enddef
/* typecheck */
-%define SWIG_VALUE_TYPECHECK_TYPEMAP(check,asval_meth,frag,Type...)
+%define %value_typecheck_typemap(check,asval_meth,frag,Type...)
%typemap(typecheck,noblock=1,precedence=check,fragment=frag) Type, const Type& {
$1 = (asval_meth($input, 0) == SWIG_OK);
}
@@ -139,25 +160,25 @@
/*---------------------------------------------------------------------
* typemap definition for types with AsVal methods
*---------------------------------------------------------------------*/
-%define %typemap_asval(CheckCode, AsValMeth, AsValFrag, Type...)
- SWIG_VALUE_IN_TYPEMAP(SWIG_arg(AsValMeth), SWIG_arg(AsValFrag), Type);
- SWIG_VALUE_VARIN_TYPEMAP(SWIG_arg(AsValMeth), SWIG_arg(AsValFrag), Type);
- SWIG_VALUE_DIRECTOROUT_TYPEMAP(SWIG_arg(AsValMeth), SWIG_arg(AsValFrag), Type);
- SWIG_VALUE_TYPECHECK_TYPEMAP(SWIG_arg(CheckCode), SWIG_arg(AsValMeth), SWIG_arg(AsValFrag), Type);
- SWIG_VALUE_INPUT_TYPEMAP(SWIG_arg(CheckCode), SWIG_arg(AsValMeth), SWIG_arg(AsValFrag), Type);
+%define %typemaps_asval(CheckCode, AsValMeth, AsValFrag, Type...)
+ %value_in_typemap(%arg(AsValMeth), %arg(AsValFrag), Type);
+ %value_varin_typemap(%arg(AsValMeth), %arg(AsValFrag), Type);
+ %value_directorout_typemap(%arg(AsValMeth), %arg(AsValFrag), Type);
+ %value_typecheck_typemap(%arg(CheckCode), %arg(AsValMeth), %arg(AsValFrag), Type);
+ %value_input_typemap(%arg(CheckCode), %arg(AsValMeth), %arg(AsValFrag), Type);
%enddef
/*---------------------------------------------------------------------
* typemap definition for types with from method
*---------------------------------------------------------------------*/
-%define %typemap_from(FromMeth, FromFrag, Type...)
- SWIG_VALUE_OUT_TYPEMAP(SWIG_arg(FromMeth), SWIG_arg(FromFrag), Type);
- SWIG_VALUE_VAROUT_TYPEMAP(SWIG_arg(FromMeth), SWIG_arg(FromFrag), Type);
- SWIG_VALUE_CONSTCODE_TYPEMAP(SWIG_arg(FromMeth), SWIG_arg(FromFrag), Type);
- SWIG_VALUE_DIRECTORIN_TYPEMAP(SWIG_arg(FromMeth), SWIG_arg(FromFrag), Type);
- SWIG_VALUE_THROWS_TYPEMAP(SWIG_arg(FromMeth), SWIG_arg(FromFrag), Type);
- SWIG_VALUE_OUTPUT_TYPEMAP(SWIG_arg(FromMeth), SWIG_arg(FromFrag), Type);
+%define %typemaps_from(FromMeth, FromFrag, Type...)
+ %value_out_typemap(%arg(FromMeth), %arg(FromFrag), Type);
+ %value_varout_typemap(%arg(FromMeth), %arg(FromFrag), Type);
+ %value_constcode_typemap(%arg(FromMeth), %arg(FromFrag), Type);
+ %value_directorin_typemap(%arg(FromMeth), %arg(FromFrag), Type);
+ %value_throws_typemap(%arg(FromMeth), %arg(FromFrag), Type);
+ %value_output_typemap(%arg(FromMeth), %arg(FromFrag), Type);
%enddef
@@ -165,22 +186,22 @@
* typemap definition for types with alval/from method
*---------------------------------------------------------------------*/
-%define %typemap_asvalfrom(CheckCode, AsValMeth, FromMeth,
+%define %typemaps_asvalfrom(CheckCode, AsValMeth, FromMeth,
AsValFrag, FromFrag, Type...)
- %typemap_asval(SWIG_arg(CheckCode), SWIG_arg(AsValMeth), SWIG_arg(AsValFrag), Type);
- %typemap_from(SWIG_arg(FromMeth), SWIG_arg(FromFrag), Type);
- SWIG_VALUE_INOUT_TYPEMAP(Type);
+ %typemaps_asval(%arg(CheckCode), %arg(AsValMeth), %arg(AsValFrag), Type);
+ %typemaps_from(%arg(FromMeth), %arg(FromFrag), Type);
+ %value_inout_typemap(Type);
%enddef
/*---------------------------------------------------------------------
* typemap definition for types with for 'normalized' asval/from methods
*---------------------------------------------------------------------*/
-%define %typemap_asvalfromn(CheckCode, Type...)
- %typemap_asvalfrom(SWIG_arg(CheckCode),
+%define %typemaps_asvalfromn(CheckCode, Type...)
+ %typemaps_asvalfrom(%arg(CheckCode),
SWIG_AsVal(Type),
SWIG_From(Type),
- SWIG_arg(SWIG_AsVal_frag(Type)),
- SWIG_arg(SWIG_From_frag(Type)),
+ %arg(SWIG_AsVal_frag(Type)),
+ %arg(SWIG_From_frag(Type)),
Type);
%enddef
diff --git a/Lib/typemaps/void.swg b/Lib/typemaps/void.swg
index a702d232b..d0fd20516 100644
--- a/Lib/typemaps/void.swg
+++ b/Lib/typemaps/void.swg
@@ -2,19 +2,23 @@
* Void * - Accepts any kind of pointer
* ------------------------------------------------------------ */
+#if !defined(VOID_Object)
+#error "VOID_Object must be defined using %define_void_object"
+#endif
+
/* in */
%typemap(in,noblock=1) void * {
- if (SWIG_ConvertPtr($input,SWIG_as_voidptrptr(&$1), 0, $disown) != SWIG_OK) {
- SWIG_arg_fail(SWIG_TypeError, "$type", $argnum);
+ if (SWIG_ConvertPtr($input,%as_voidptrptr(&$1), 0, $disown) != SWIG_OK) {
+ %argument_fail(SWIG_TypeError, "$type", $argnum);
}
}
%typemap(freearg) void * "";
%typemap(in,noblock=1) void * const& ($*ltype temp) {
- if (SWIG_ConvertPtr($input, SWIG_as_voidptrptr(&temp), 0, $disown) != SWIG_OK) {
- SWIG_arg_fail(SWIG_TypeError, "Stype", $argnum);
+ if (SWIG_ConvertPtr($input, %as_voidptrptr(&temp), 0, $disown) != SWIG_OK) {
+ %argument_fail(SWIG_TypeError, "Stype", $argnum);
}
$1 = &temp;
}
@@ -23,7 +27,7 @@
/* out */
%typemap(out,noblock=1) void {
- SWIG_set_result(SWIG_VoidObject());
+ $result = VOID_Object;
}
/* varin */
@@ -31,7 +35,7 @@
%typemap(varin,noblock=1) void * {
void *temp = 0;
if (SWIG_ConvertPtr($input, &temp, 0, SWIG_POINTER_DISOWN) != SWIG_OK) {
- SWIG_var_fail(SWIG_TypeError, "$type", "$name");
+ %variable_fail(SWIG_TypeError, "$type", "$name");
}
$1 = ($1_ltype) temp;
}
@@ -50,9 +54,9 @@
%typemap(directorout,noblock=1) void * (void *argp) {
if (SWIG_ConvertPtr($input, &argp, 0, 0) != SWIG_OK) {
- SWIG_dout_fail(SWIG_TypeError,"$type");
+ %dirout_fail(SWIG_TypeError,"$type");
}
- $result = SWIG_reinterpret_cast(argp, $ltype);
+ $result = %reinterpret_cast(argp, $ltype);
}
diff --git a/Lib/typemaps/wstring.swg b/Lib/typemaps/wstring.swg
new file mode 100644
index 000000000..ce91ac5e5
--- /dev/null
+++ b/Lib/typemaps/wstring.swg
@@ -0,0 +1,4 @@
+%include <typemaps/strings.swg>
+%typemaps_string(wchar_t, WChar, SWIG_AsWCharPtrAndSize, SWIG_FromWCharPtrAndSize, wcslen,
+ "<wchar.h>", WCHAR_MIN, WCHAR_MAX)
+