Change typemap matching rules for the default type (SWIGTYPE) to follow template partial specialization type deduction. Fixes some containers of const pointers. SWIGTYPE*& typemps removed and replaced with SWIGTYPE *const&.

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11958 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
William S Fulton 2010-04-01 18:26:37 +00:00
parent b1c5940786
commit bdb136d611
41 changed files with 477 additions and 122 deletions

View File

@ -1,6 +1,76 @@
Version 2.0.0 (in progress) Version 2.0.0 (in progress)
============================ ============================
2010-04-01: wsfulton
Numerous subtle typemap matching rule fixes when using the default type. The typemap
matching rules are to take a type and find the best default typemap (SWIGTYPE, SWIGTYPE* etc),
then look for the next best match by reducing the chosen default type. The type reduction
now follows C++ template partial specialization matching rules.
Below are the set of changes made showing the default type reduction
along with the old reduced type and the new version of the reduced type:
SWIGTYPE const &[ANY]
new: SWIGTYPE const &[]
old: SWIGTYPE (&)[ANY]
SWIGTYPE *const [ANY]
new: SWIGTYPE const [ANY]
old: SWIGTYPE *[ANY]
SWIGTYPE const *const [ANY]
new: SWIGTYPE *const [ANY]
old: SWIGTYPE const *[ANY]
SWIGTYPE const *const &
new: SWIGTYPE *const &
old: SWIGTYPE const *&
SWIGTYPE *const *
new: SWIGTYPE const *
old: SWIGTYPE **
SWIGTYPE *const &
new: SWIGTYPE const &
old: SWIGTYPE *&
Additionally, a const SWIGTYPE lookup is used now for any constant type. Some examples, where
T is some reduced type, eg int, struct Foo:
T const
new: SWIGTYPE const
old: SWIGTYPE
T *const
new: SWIGTYPE *const
old: SWIGTYPE *
T const[]
new: SWIGTYPE const[]
old: SWIGTYPE[]
enum T const
new: enum SWIGTYPE const
old: enum SWIGTYPE
T (*const )[]
new: SWIGTYPE (*const )[]
old: SWIGTYPE (*)[]
Reminder: the typemap matching rules can now be seen for any types being wrapped by using
either the -debug-tmsearch or -debug-tmused options.
In practice this leads to some subtle matching rule changes and the majority of users
won't notice any changes, except in the prime area of motivation for this change: Improve
STL containers of const pointers and passing const pointers by reference. This is fixed
because many of the STL containers use a type 'T const&' as parameters and when T is
a const pointer, for example, 'K const*', then the full type is 'K const*const&'. This
means that the 'SWIGTYPE *const&' typemaps now match when T is either a non-const or
const pointer. Furthermore, some target languages incorrectly had 'SWIGTYPE *&' typemaps
when these should have been 'SWIGTYPE *const&'. These have been corrected (Java, C#, Lua, PHP).
*** POTENTIAL INCOMPATIBILITY ***
2010-03-13: wsfulton 2010-03-13: wsfulton
[Java] Some very old deprecated pragma warnings are now errors. [Java] Some very old deprecated pragma warnings are now errors.

View File

@ -70,6 +70,8 @@ public:
void ret6(int*& a) {} void ret6(int*& a) {}
int*& ret7() {return GlobalIntPtr;} int*& ret7() {return GlobalIntPtr;}
void ret8(int*const& a) {}
int*const& ret9() {return GlobalIntPtr;}
ReturnValuesTest() : int3(NULL) {} ReturnValuesTest() : int3(NULL) {}
private: private:
ReturnValuesTest& operator=(const ReturnValuesTest&); ReturnValuesTest& operator=(const ReturnValuesTest&);
@ -112,7 +114,7 @@ int* const globalRet2() {return &GlobalInt;}
return b; return b;
} }
B const*& cbar(B const*& b) { B *const& cbar(B *const& b) {
return b; return b;
} }
} }

View File

@ -11,8 +11,8 @@ class Klass6 {};
class Klass7 {}; class Klass7 {};
struct KlassMethods { struct KlassMethods {
static void methodA(::Klass1 v, const ::Klass2 cv, const ::Klass3 *cp, ::Klass4 *p, const ::Klass5 &cr, ::Klass6 &r, ::Klass7*& pr) {} static void methodA(::Klass1 v, const ::Klass2 cv, const ::Klass3 *cp, ::Klass4 *p, const ::Klass5 &cr, ::Klass6 &r, ::Klass7*const& pr) {}
static void methodB( Klass1 v, const Klass2 cv, const Klass3 *cp, Klass4 *p, const Klass5 &cr, Klass6 &r, Klass7*& pr) {} static void methodB( Klass1 v, const Klass2 cv, const Klass3 *cp, Klass4 *p, const Klass5 &cr, Klass6 &r, Klass7*const& pr) {}
}; };
%} %}
@ -28,8 +28,8 @@ class XYZ7 {};
} }
struct XYZMethods { struct XYZMethods {
static void methodA(::Space::XYZ1 v, const ::Space::XYZ2 cv, const ::Space::XYZ3 *cp, ::Space::XYZ4 *p, const ::Space::XYZ5 &cr, ::Space::XYZ6 &r, ::Space::XYZ7*& pr) {} static void methodA(::Space::XYZ1 v, const ::Space::XYZ2 cv, const ::Space::XYZ3 *cp, ::Space::XYZ4 *p, const ::Space::XYZ5 &cr, ::Space::XYZ6 &r, ::Space::XYZ7*const& pr) {}
static void methodB( Space::XYZ1 v, const Space::XYZ2 cv, const Space::XYZ3 *cp, Space::XYZ4 *p, const Space::XYZ5 &cr, Space::XYZ6 &r, Space::XYZ7*& pr) {} static void methodB( Space::XYZ1 v, const Space::XYZ2 cv, const Space::XYZ3 *cp, Space::XYZ4 *p, const Space::XYZ5 &cr, Space::XYZ6 &r, Space::XYZ7*const& pr) {}
}; };
%} %}

View File

@ -16,21 +16,21 @@
%typemap(jstype) Space::Classic ** " Classic " %typemap(jstype) Space::Classic ** " Classic "
%typemap(javain) Space::Classic ** "Classic.getCPtr($javainput)" %typemap(javain) Space::Classic ** "Classic.getCPtr($javainput)"
// Default typemaps for pass by value, ref, pointer and pointer reference should use pgcpp // Default typemaps for pass by value, ref, pointer and pointer const reference should use pgcpp
%inline %{ %inline %{
namespace Space { namespace Space {
struct Classic { struct Classic {
Classic() {} Classic() {}
Classic(Classic c1, Classic& c2, Classic* c3, Classic*& c4, Classic** c5) {} Classic(Classic c1, Classic& c2, Classic* c3, Classic*const& c4, Classic** c5) {}
Classic(const Classic c1, const Classic& c2, const Classic* c3, const Classic*& c4, const Classic** c5, bool b) {} Classic(const Classic c1, const Classic& c2, const Classic* c3, const Classic*const& c4, const Classic** c5, bool b) {}
void method(Classic c1, Classic& c2, Classic* c3, Classic*& c4, Classic** c5) {} void method(Classic c1, Classic& c2, Classic* c3, Classic*const& c4, Classic** c5) {}
void methodconst(const Classic c1, const Classic& c2, const Classic* c3, const Classic*& c4, const Classic** c5) {} void methodconst(const Classic c1, const Classic& c2, const Classic* c3, const Classic*const& c4, const Classic** c5) {}
}; };
void function(Classic c1, Classic& c2, Classic* c3, Classic*& c4, Classic** c5) {} void function(Classic c1, Classic& c2, Classic* c3, Classic*const& c4, Classic** c5) {}
void functionconst(const Classic c1, const Classic& c2, const Classic* c3, const Classic*& c4, const Classic** c5) {} void functionconst(const Classic c1, const Classic& c2, const Classic* c3, const Classic*const& c4, const Classic** c5) {}
} }
%} %}

View File

@ -295,7 +295,7 @@ Klass& reftest(Klass& k) {
k.append(" reftest"); k.append(" reftest");
return k; return k;
} }
Klass*& pointerreftest(Klass*& k) { Klass *const& pointerreftest(Klass *const& k) {
k->append(" pointerreftest"); k->append(" pointerreftest");
return k; return k;
} }
@ -334,7 +334,7 @@ std::string overload_rawbyptr(int i) { return "int"; }
std::string overload_rawbyptr(Klass *k) { return "rawbyptr"; } std::string overload_rawbyptr(Klass *k) { return "rawbyptr"; }
std::string overload_rawbyptrref(int i) { return "int"; } std::string overload_rawbyptrref(int i) { return "int"; }
std::string overload_rawbyptrref(Klass *&k) { return "rawbyptrref"; } std::string overload_rawbyptrref(Klass *const&k) { return "rawbyptrref"; }

View File

@ -222,7 +222,7 @@ Klass& reftest(Klass& k) {
k.append(" reftest"); k.append(" reftest");
return k; return k;
} }
Klass*& pointerreftest(Klass*& k) { Klass *const& pointerreftest(Klass *const& k) {
k->append(" pointerreftest"); k->append(" pointerreftest");
return k; return k;
} }
@ -275,7 +275,7 @@ std::string overload_rawbyptr(int i) { return "int"; }
std::string overload_rawbyptr(Klass *k) { return "rawbyptr"; } std::string overload_rawbyptr(Klass *k) { return "rawbyptr"; }
std::string overload_rawbyptrref(int i) { return "int"; } std::string overload_rawbyptrref(int i) { return "int"; }
std::string overload_rawbyptrref(Klass *&k) { return "rawbyptrref"; } std::string overload_rawbyptrref(Klass *const&k) { return "rawbyptrref"; }

View File

@ -29,10 +29,10 @@ struct Struct {
static Struct *pInstance; static Struct *pInstance;
}; };
void set(Struct *& s) { void set(Struct *const& s) {
Struct::instance = *s; Struct::instance = *s;
} }
Struct *& get() { Struct *const& get() {
return Struct::pInstance; return Struct::pInstance;
} }
%} %}

View File

@ -219,6 +219,12 @@ $body)"
%typemap(lispclass) wchar_t* "cl:string"; %typemap(lispclass) wchar_t* "cl:string";
////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////
/* Array reference typemaps */
%apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) }
/* const pointers */
%apply SWIGTYPE * { SWIGTYPE *const }
/* name conversion for overloaded operators. */ /* name conversion for overloaded operators. */
#ifdef __cplusplus #ifdef __cplusplus
%rename(__add__) *::operator+; %rename(__add__) *::operator+;

View File

@ -130,6 +130,11 @@
%typemap(lispclass) double "cl:number"; %typemap(lispclass) double "cl:number";
%typemap(lispclass) char * "cl:string"; %typemap(lispclass) char * "cl:string";
/* Array reference typemaps */
%apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) }
/* const pointers */
%apply SWIGTYPE * { SWIGTYPE *const }
%{ %{

View File

@ -679,6 +679,16 @@ $result = C_SCHEME_UNDEFINED;
%apply unsigned long { size_t }; %apply unsigned long { size_t };
/* ------------------------------------------------------------
* Various
* ------------------------------------------------------------ */
/* Array reference typemaps */
%apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) }
/* const pointers */
%apply SWIGTYPE * { SWIGTYPE *const }
/* ------------------------------------------------------------ /* ------------------------------------------------------------
* Overloaded operator support * Overloaded operator support
* ------------------------------------------------------------ */ * ------------------------------------------------------------ */

View File

@ -44,10 +44,10 @@
%{ $result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_$owner); %} %{ $result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_$owner); %}
// plain pointer by reference // plain pointer by reference
%typemap(in) CONST TYPE *& ($*1_ltype temp = 0) %typemap(in) TYPE *CONST& ($*1_ltype temp = 0)
%{ temp = (((SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)$input) ? ((SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)$input)->get() : 0); %{ temp = (TYPE *)(((SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)$input) ? ((SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)$input)->get() : 0);
$1 = &temp; %} $1 = &temp; %}
%typemap(out, fragment="SWIG_null_deleter") CONST TYPE *& %typemap(out, fragment="SWIG_null_deleter") TYPE *CONST&
%{ $result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1 SWIG_NO_NULL_DELETER_$owner); %} %{ $result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1 SWIG_NO_NULL_DELETER_$owner); %}
// shared_ptr by value // shared_ptr by value
@ -138,7 +138,7 @@
PROXYCLASS ret = (cPtr == IntPtr.Zero) ? null : new PROXYCLASS(cPtr, true);$excode PROXYCLASS ret = (cPtr == IntPtr.Zero) ? null : new PROXYCLASS(cPtr, true);$excode
return ret; return ret;
} }
%typemap(csout, excode=SWIGEXCODE) CONST TYPE *& { %typemap(csout, excode=SWIGEXCODE) TYPE *CONST& {
IntPtr cPtr = $imcall; IntPtr cPtr = $imcall;
PROXYCLASS ret = (cPtr == IntPtr.Zero) ? null : new PROXYCLASS(cPtr, true);$excode PROXYCLASS ret = (cPtr == IntPtr.Zero) ? null : new PROXYCLASS(cPtr, true);$excode
return ret; return ret;

View File

@ -522,6 +522,7 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
SWIGTYPE, SWIGTYPE,
SWIGTYPE *, SWIGTYPE *,
SWIGTYPE &, SWIGTYPE &,
SWIGTYPE *const&,
SWIGTYPE [], SWIGTYPE [],
SWIGTYPE (CLASS::*) SWIGTYPE (CLASS::*)
"" ""
@ -782,24 +783,21 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
} %} } %}
/* Pointer reference typemaps */ /* Pointer reference typemaps */
%typemap(ctype) SWIGTYPE *& "void *" %typemap(ctype) SWIGTYPE *const& "void *"
%typemap(imtype, out="IntPtr") SWIGTYPE *& "HandleRef" %typemap(imtype, out="IntPtr") SWIGTYPE *const& "HandleRef"
%typemap(cstype) SWIGTYPE *& "$*csclassname" %typemap(cstype) SWIGTYPE *const& "$*csclassname"
%typemap(csin) SWIGTYPE *& "$*csclassname.getCPtr($csinput)" %typemap(csin) SWIGTYPE *const& "$*csclassname.getCPtr($csinput)"
%typemap(csout, excode=SWIGEXCODE) SWIGTYPE *& { %typemap(csout, excode=SWIGEXCODE) SWIGTYPE *const& {
IntPtr cPtr = $imcall; IntPtr cPtr = $imcall;
$*csclassname ret = (cPtr == IntPtr.Zero) ? null : new $*csclassname(cPtr, $owner);$excode $*csclassname ret = (cPtr == IntPtr.Zero) ? null : new $*csclassname(cPtr, $owner);$excode
return ret; return ret;
} }
%typemap(in) SWIGTYPE *& ($*1_ltype temp = 0) %typemap(in) SWIGTYPE *const& ($*1_ltype temp = 0)
%{ temp = ($*1_ltype)$input; %{ temp = ($*1_ltype)$input;
$1 = &temp; %} $1 = ($1_ltype)&temp; %}
%typemap(out) SWIGTYPE *& %typemap(out) SWIGTYPE *const&
%{ $result = (void *)*$1; %} %{ $result = (void *)*$1; %}
/* Array reference typemaps */
%apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) }
/* Marshal C/C++ pointer to IntPtr */ /* Marshal C/C++ pointer to IntPtr */
%typemap(ctype) void *VOID_INT_PTR "void *" %typemap(ctype) void *VOID_INT_PTR "void *"
%typemap(imtype) void *VOID_INT_PTR "IntPtr" %typemap(imtype) void *VOID_INT_PTR "IntPtr"
@ -953,6 +951,12 @@ using System.Runtime.InteropServices;
%apply unsigned long { size_t }; %apply unsigned long { size_t };
%apply const unsigned long & { const size_t & }; %apply const unsigned long & { const size_t & };
/* Array reference typemaps */
%apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) }
/* const pointers */
%apply SWIGTYPE * { SWIGTYPE *const }
/* csharp keywords */ /* csharp keywords */
%include <csharpkw.swg> %include <csharpkw.swg>

View File

@ -224,7 +224,7 @@ namespace std {
bool empty() const; bool empty() const;
void clear(); void clear();
%extend { %extend {
T& __getitem__(const K& key) throw (std::out_of_range) { const T& __getitem__(const K& key) throw (std::out_of_range) {
std::map<K,T >::iterator i = self->find(key); std::map<K,T >::iterator i = self->find(key);
if (i != self->end()) if (i != self->end())
return i->second; return i->second;

View File

@ -208,7 +208,7 @@ namespace std {
self->pop_back(); self->pop_back();
return x; return x;
} }
T& ref(int i) throw (std::out_of_range) { const T& ref(int i) throw (std::out_of_range) {
int size = int(self->size()); int size = int(self->size());
if (i>=0 && i<size) if (i>=0 && i<size)
return (*self)[i]; return (*self)[i];

View File

@ -448,4 +448,10 @@ typedef unsigned long SCM;
$1 = SWIG_CheckState(res); $1 = SWIG_CheckState(res);
} }
/* Array reference typemaps */
%apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) }
/* const pointers */
%apply SWIGTYPE * { SWIGTYPE *const }
/* typemaps.i ends here */ /* typemaps.i ends here */

View File

@ -69,12 +69,12 @@
#endif #endif
%} %}
%typemap(in) CONST TYPE *& ($*1_ltype temp = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) %{ %typemap(in) TYPE *CONST& ($*1_ltype temp = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) %{
// plain pointer by reference // plain pointer by reference
temp = ((*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0); temp = ($*1_ltype)((*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0);
$1 = &temp; $1 = &temp;
%} %}
%typemap(out, fragment="SWIG_intrusive_deleter,SWIG_null_deleter") CONST TYPE *& %{ %typemap(out, fragment="SWIG_intrusive_deleter,SWIG_null_deleter") TYPE *CONST& %{
// plain pointer by reference(out) // plain pointer by reference(out)
#if ($owner) #if ($owner)
if (*$1) { if (*$1) {
@ -246,7 +246,7 @@
long cPtr = $jnicall; long cPtr = $jnicall;
return (cPtr == 0) ? null : new PROXYCLASS(cPtr, true); return (cPtr == 0) ? null : new PROXYCLASS(cPtr, true);
} }
%typemap(javaout) CONST TYPE *& { %typemap(javaout) TYPE *CONST& {
long cPtr = $jnicall; long cPtr = $jnicall;
return (cPtr == 0) ? null : new PROXYCLASS(cPtr, true); return (cPtr == 0) ? null : new PROXYCLASS(cPtr, true);
} }
@ -353,10 +353,10 @@
%{ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_$owner); %} %{ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_$owner); %}
// plain pointer by reference // plain pointer by reference
%typemap(in) CONST TYPE *& ($*1_ltype temp = 0) %typemap(in) TYPE *CONST& ($*1_ltype temp = 0)
%{ temp = ((*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0); %{ temp = ($*1_ltype)((*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0);
$1 = &temp; %} $1 = &temp; %}
%typemap(out, fragment="SWIG_null_deleter") CONST TYPE *& %typemap(out, fragment="SWIG_null_deleter") TYPE *CONST&
%{ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1 SWIG_NO_NULL_DELETER_$owner); %} %{ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1 SWIG_NO_NULL_DELETER_$owner); %}
%typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > swigSharedPtrUpcast ($&1_type smartarg) %{ %typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > swigSharedPtrUpcast ($&1_type smartarg) %{
@ -396,7 +396,7 @@
long cPtr = $jnicall; long cPtr = $jnicall;
return (cPtr == 0) ? null : new PROXYCLASS(cPtr, true); return (cPtr == 0) ? null : new PROXYCLASS(cPtr, true);
} }
%typemap(javaout) CONST TYPE *& { %typemap(javaout) TYPE *CONST& {
long cPtr = $jnicall; long cPtr = $jnicall;
return (cPtr == 0) ? null : new PROXYCLASS(cPtr, true); return (cPtr == 0) ? null : new PROXYCLASS(cPtr, true);
} }

View File

@ -44,10 +44,10 @@
%{ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_$owner); %} %{ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_$owner); %}
// plain pointer by reference // plain pointer by reference
%typemap(in) CONST TYPE *& ($*1_ltype temp = 0) %typemap(in) TYPE *CONST& ($*1_ltype temp = 0)
%{ temp = ((*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0); %{ temp = (TYPE *)((*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0);
$1 = &temp; %} $1 = &temp; %}
%typemap(out, fragment="SWIG_null_deleter") CONST TYPE *& %typemap(out, fragment="SWIG_null_deleter") TYPE *CONST&
%{ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1 SWIG_NO_NULL_DELETER_$owner); %} %{ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1 SWIG_NO_NULL_DELETER_$owner); %}
// shared_ptr by value // shared_ptr by value
@ -132,7 +132,7 @@
long cPtr = $jnicall; long cPtr = $jnicall;
return (cPtr == 0) ? null : new PROXYCLASS(cPtr, true); return (cPtr == 0) ? null : new PROXYCLASS(cPtr, true);
} }
%typemap(javaout) CONST TYPE *& { %typemap(javaout) TYPE *CONST& {
long cPtr = $jnicall; long cPtr = $jnicall;
return (cPtr == 0) ? null : new PROXYCLASS(cPtr, true); return (cPtr == 0) ? null : new PROXYCLASS(cPtr, true);
} }

View File

@ -897,6 +897,7 @@
SWIGTYPE, SWIGTYPE,
SWIGTYPE *, SWIGTYPE *,
SWIGTYPE &, SWIGTYPE &,
SWIGTYPE *const&,
SWIGTYPE [], SWIGTYPE [],
SWIGTYPE (CLASS::*) SWIGTYPE (CLASS::*)
"" ""
@ -1025,23 +1026,20 @@
} }
/* Pointer reference typemaps */ /* Pointer reference typemaps */
%typemap(jni) SWIGTYPE *& "jlong" %typemap(jni) SWIGTYPE *const& "jlong"
%typemap(jtype) SWIGTYPE *& "long" %typemap(jtype) SWIGTYPE *const& "long"
%typemap(jstype) SWIGTYPE *& "$*javaclassname" %typemap(jstype) SWIGTYPE *const& "$*javaclassname"
%typemap(javain) SWIGTYPE *& "$*javaclassname.getCPtr($javainput)" %typemap(javain) SWIGTYPE *const& "$*javaclassname.getCPtr($javainput)"
%typemap(javaout) SWIGTYPE *& { %typemap(javaout) SWIGTYPE *const& {
long cPtr = $jnicall; long cPtr = $jnicall;
return (cPtr == 0) ? null : new $*javaclassname(cPtr, $owner); return (cPtr == 0) ? null : new $*javaclassname(cPtr, $owner);
} }
%typemap(in) SWIGTYPE *& ($*1_ltype temp = 0) %typemap(in) SWIGTYPE *const& ($*1_ltype temp = 0)
%{ temp = *($1_ltype)&$input; %{ temp = *($1_ltype)&$input;
$1 = &temp; %} $1 = ($1_ltype)&temp; %}
%typemap(out) SWIGTYPE *& %typemap(out) SWIGTYPE *const&
%{ *($1_ltype)&$result = *$1; %} %{ *($1_ltype)&$result = *$1; %}
/* Array reference typemaps */
%apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) }
/* Typemaps used for the generation of proxy and type wrapper class code */ /* Typemaps used for the generation of proxy and type wrapper class code */
%typemap(javabase) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) "" %typemap(javabase) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) ""
%typemap(javaclassmodifiers) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) "public class" %typemap(javaclassmodifiers) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) "public class"
@ -1203,6 +1201,12 @@ SWIG_PROXY_CONSTRUCTOR(true, true, SWIGTYPE)
%apply unsigned long { size_t }; %apply unsigned long { size_t };
%apply const unsigned long & { const size_t & }; %apply const unsigned long & { const size_t & };
/* Array reference typemaps */
%apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) }
/* const pointers */
%apply SWIGTYPE * { SWIGTYPE *const }
/* java keywords */ /* java keywords */
%include <javakw.swg> %include <javakw.swg>

View File

@ -40,7 +40,7 @@
%typemap(consttab) long long, unsigned long long %typemap(consttab) long long, unsigned long long
{ SWIG_LUA_STRING, (char *) "$symname", 0, 0, (void *)"$value", 0} { SWIG_LUA_STRING, (char *) "$symname", 0, 0, (void *)"$value", 0}
%typemap(consttab) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [] %typemap(consttab) SWIGTYPE *, SWIGTYPE *const, SWIGTYPE &, SWIGTYPE []
{ SWIG_LUA_POINTER, (char *)"$symname", 0, 0, (void *)$value, &$1_descriptor} { SWIG_LUA_POINTER, (char *)"$symname", 0, 0, (void *)$value, &$1_descriptor}
// member function pointers // member function pointers

View File

@ -167,11 +167,11 @@ temp=($basetype)lua_tonumber(L,$input); $1=&temp;%}
// Also needed for object ptrs by const ref // Also needed for object ptrs by const ref
// eg A* const& ref_pointer(A* const& a); // eg A* const& ref_pointer(A* const& a);
// found in mixed_types.i // found in mixed_types.i
%typemap(in,checkfn="lua_isuserdata") SWIGTYPE *&($*ltype temp) %typemap(in,checkfn="lua_isuserdata") SWIGTYPE *const&($*ltype temp)
%{temp=($*ltype)SWIG_MustGetPtr(L,$input,$*descriptor,0,$argnum,"$symname"); %{temp=($*ltype)SWIG_MustGetPtr(L,$input,$*descriptor,0,$argnum,"$symname");
$1=&temp;%} $1=($1_ltype)&temp;%}
%typemap(out) SWIGTYPE *& %typemap(out) SWIGTYPE *const&
%{SWIG_NewPointerObj(L,*$1,$*descriptor,$owner); SWIG_arg++; %} %{SWIG_NewPointerObj(L,*$1,$*descriptor,$owner); SWIG_arg++; %}
@ -335,7 +335,7 @@ parmeters match which function
// Also needed for object ptrs by const ref // Also needed for object ptrs by const ref
// eg const A* ref_pointer(A* const& a); // eg const A* ref_pointer(A* const& a);
// found in mixed_types.i // found in mixed_types.i
%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE* const & %typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE *const&
{ {
void *ptr; void *ptr;
if (lua_isuserdata(L,$input)==0 || SWIG_ConvertPtr(L,$input, (void **) &ptr, $*descriptor, 0)) { if (lua_isuserdata(L,$input)==0 || SWIG_ConvertPtr(L,$input, (void **) &ptr, $*descriptor, 0)) {
@ -352,6 +352,9 @@ parmeters match which function
// Array reference typemaps // Array reference typemaps
%apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) } %apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) }
/* const pointers */
%apply SWIGTYPE * { SWIGTYPE *const }
// size_t (which is just a unsigned long) // size_t (which is just a unsigned long)
%apply unsigned long { size_t }; %apply unsigned long { size_t };
%apply const unsigned long & { const size_t & }; %apply const unsigned long & { const size_t & };

View File

@ -745,3 +745,10 @@ FROM BlaBla IMPORT Bla;
/* Some ANSI C typemaps */ /* Some ANSI C typemaps */
%apply unsigned long { size_t }; %apply unsigned long { size_t };
/* Array reference typemaps */
%apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) }
/* const pointers */
%apply SWIGTYPE * { SWIGTYPE *const }

View File

@ -349,3 +349,10 @@ REF_MAP(double, SCHEME_REALP, scheme_real_to_double,
} }
/* Array reference typemaps */
%apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) }
/* const pointers */
%apply SWIGTYPE * { SWIGTYPE *const }

View File

@ -29,7 +29,7 @@ namespace std {
bool empty() const; bool empty() const;
void clear(); void clear();
%extend { %extend {
T& get(const K& key) throw (std::out_of_range) { const T& get(const K& key) throw (std::out_of_range) {
std::map<K,T >::iterator i = self->find(key); std::map<K,T >::iterator i = self->find(key);
if (i != self->end()) if (i != self->end())
return i->second; return i->second;

View File

@ -314,3 +314,11 @@ SIMPLE_MAP(unsigned long long,caml_val_ulong,caml_long_val);
%swig_enum_out(out) %swig_enum_out(out)
%swig_enum_out(varout) %swig_enum_out(varout)
%swig_enum_out(directorin) %swig_enum_out(directorin)
/* Array reference typemaps */
%apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) }
/* const pointers */
%apply SWIGTYPE * { SWIGTYPE *const }

View File

@ -143,7 +143,7 @@
// plain pointer by reference // plain pointer by reference
// Note: $disown not implemented as it will lead to a memory leak of the shared_ptr instance // Note: $disown not implemented as it will lead to a memory leak of the shared_ptr instance
%typemap(in) CONST TYPE *& (void *argp = 0, int res = 0, $*1_ltype temp = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared) { %typemap(in) TYPE *CONST& (void *argp = 0, int res = 0, $*1_ltype temp = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared) {
int newmem = 0; int newmem = 0;
res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem);
if (!SWIG_IsOK(res)) { if (!SWIG_IsOK(res)) {
@ -158,15 +158,15 @@
} }
$1 = &temp; $1 = &temp;
} }
%typemap(out, fragment="SWIG_null_deleter") CONST TYPE *& { %typemap(out, fragment="SWIG_null_deleter") TYPE *CONST& {
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1 SWIG_NO_NULL_DELETER_$owner); SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1 SWIG_NO_NULL_DELETER_$owner);
%set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN));
} }
%typemap(varin) CONST TYPE *& %{ %typemap(varin) TYPE *CONST& %{
#error "varin typemap not implemented" #error "varin typemap not implemented"
%} %}
%typemap(varout) CONST TYPE *& %{ %typemap(varout) TYPE *CONST& %{
#error "varout typemap not implemented" #error "varout typemap not implemented"
%} %}
@ -283,10 +283,10 @@
// Note: SWIG_ConvertPtr with void ** parameter set to 0 instead of using SWIG_ConvertPtrAndOwn, so that the casting // Note: SWIG_ConvertPtr with void ** parameter set to 0 instead of using SWIG_ConvertPtrAndOwn, so that the casting
// function is not called thereby avoiding a possible smart pointer copy constructor call when casting up the inheritance chain. // function is not called thereby avoiding a possible smart pointer copy constructor call when casting up the inheritance chain.
%typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER,noblock=1) %typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER,noblock=1)
CONST TYPE, TYPE CONST,
CONST TYPE &, TYPE CONST &,
CONST TYPE *, TYPE CONST *,
CONST TYPE *&, TYPE *CONST&,
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >,
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > &, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > &,
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *,

View File

@ -75,7 +75,7 @@
%include <typemaps/swigtypemaps.swg> %include <typemaps/swigtypemaps.swg>
/* ------------------------------------------------------------ /* ------------------------------------------------------------
* Perl extra typemaps * Perl extra typemaps / typemap overrides
* ------------------------------------------------------------ */ * ------------------------------------------------------------ */
%typemap(varout,type="$1_descriptor") SWIGTYPE *, SWIGTYPE [] %typemap(varout,type="$1_descriptor") SWIGTYPE *, SWIGTYPE []
@ -90,3 +90,6 @@
%typemap(varout,type="$1_descriptor") SWIGTYPE (CLASS::*) { %typemap(varout,type="$1_descriptor") SWIGTYPE (CLASS::*) {
SWIG_MakePackedObj($result, (void *) &$1, sizeof($1_type), $1_descriptor); SWIG_MakePackedObj($result, (void *) &$1, sizeof($1_type), $1_descriptor);
} }
%typemap(varout) SWIGTYPE *const = SWIGTYPE *;

View File

@ -30,7 +30,7 @@ namespace std {
bool empty() const; bool empty() const;
void clear(); void clear();
%extend { %extend {
T& get(const K& key) throw (std::out_of_range) { const T& get(const K& key) throw (std::out_of_range) {
std::map<K,T >::iterator i = self->find(key); std::map<K,T >::iterator i = self->find(key);
if (i != self->end()) if (i != self->end())
return i->second; return i->second;

View File

@ -115,12 +115,12 @@
} }
} }
%typemap(in) SWIGTYPE *& ($*ltype temp) %typemap(in) SWIGTYPE *const& ($*ltype temp)
{ {
if(SWIG_ConvertPtr(*$input, (void **) &temp, $*1_descriptor, 0) < 0) { if(SWIG_ConvertPtr(*$input, (void **) &temp, $*1_descriptor, 0) < 0) {
SWIG_PHP_Error(E_ERROR, "Type error in argument $argnum of $symname. Expected $*1_descriptor"); SWIG_PHP_Error(E_ERROR, "Type error in argument $argnum of $symname. Expected $*1_descriptor");
} }
$1 = &temp; $1 = ($1_ltype)&temp;
} }
%typemap(in) SWIGTYPE *DISOWN %typemap(in) SWIGTYPE *DISOWN
@ -339,7 +339,7 @@
SWIG_SetPointerZval(return_value, (void *)$1, $1_descriptor, $owner); SWIG_SetPointerZval(return_value, (void *)$1, $1_descriptor, $owner);
%} %}
%typemap(out) SWIGTYPE *& %typemap(out) SWIGTYPE *const&
%{ %{
SWIG_SetPointerZval(return_value, (void *)*$1, $*1_descriptor, $owner); SWIG_SetPointerZval(return_value, (void *)*$1, $*1_descriptor, $owner);
%} %}
@ -394,10 +394,6 @@
SWIG_SetPointerZval($input, SWIG_as_voidptr(&$1_name), $&1_descriptor, 2); SWIG_SetPointerZval($input, SWIG_as_voidptr(&$1_name), $&1_descriptor, 2);
} }
/* Array reference typemaps */
%apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) }
%typemap(out) void ""; %typemap(out) void "";
%typemap(out) char [ANY] %typemap(out) char [ANY]
@ -441,10 +437,11 @@
_v = (SWIG_ConvertPtr(*$input, (void **)&tmp, $&1_descriptor, 0) >= 0); _v = (SWIG_ConvertPtr(*$input, (void **)&tmp, $&1_descriptor, 0) >= 0);
} }
%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE *, %typecheck(SWIG_TYPECHECK_POINTER)
SWIGTYPE *,
SWIGTYPE [], SWIGTYPE [],
SWIGTYPE &, SWIGTYPE &,
SWIGTYPE *& SWIGTYPE *const&
{ {
void *tmp; void *tmp;
_v = (SWIG_ConvertPtr(*$input, (void**)&tmp, $1_descriptor, 0) >= 0); _v = (SWIG_ConvertPtr(*$input, (void**)&tmp, $1_descriptor, 0) >= 0);
@ -478,6 +475,12 @@
SWIG_PHP_Error(E_ERROR, (char *)$1); SWIG_PHP_Error(E_ERROR, (char *)$1);
%} %}
/* Array reference typemaps */
%apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) }
/* const pointers */
%apply SWIGTYPE * { SWIGTYPE *const }
/* php keywords */ /* php keywords */
%include <phpkw.swg> %include <phpkw.swg>

View File

@ -29,7 +29,7 @@ namespace std {
unsigned int size() const; unsigned int size() const;
void clear(); void clear();
%extend { %extend {
T& get(const K& key) throw (std::out_of_range) { const T& get(const K& key) throw (std::out_of_range) {
std::map<K,T >::iterator i = self->find(key); std::map<K,T >::iterator i = self->find(key);
if (i != self->end()) if (i != self->end())
return i->second; return i->second;

View File

@ -264,6 +264,12 @@ extern "C" {
} }
} }
/* Array reference typemaps */
%apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) }
/* const pointers */
%apply SWIGTYPE * { SWIGTYPE *const }
/* ------------------------------------------------------------ /* ------------------------------------------------------------
* Overloaded operator support * Overloaded operator support
* ------------------------------------------------------------ */ * ------------------------------------------------------------ */

View File

@ -151,7 +151,7 @@
// plain pointer by reference // plain pointer by reference
// Note: $disown not implemented by default as it will lead to a memory leak of the shared_ptr instance // Note: $disown not implemented by default as it will lead to a memory leak of the shared_ptr instance
%typemap(in) CONST TYPE *& (void *argp = 0, int res = 0, $*1_ltype temp = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared) { %typemap(in) TYPE *CONST& (void *argp = 0, int res = 0, $*1_ltype temp = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared) {
int newmem = 0; int newmem = 0;
res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SHARED_PTR_DISOWN | %convertptr_flags, &newmem); res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SHARED_PTR_DISOWN | %convertptr_flags, &newmem);
if (!SWIG_IsOK(res)) { if (!SWIG_IsOK(res)) {
@ -166,15 +166,15 @@
} }
$1 = &temp; $1 = &temp;
} }
%typemap(out, fragment="SWIG_null_deleter") CONST TYPE *& { %typemap(out, fragment="SWIG_null_deleter") TYPE *CONST& {
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1 SWIG_NO_NULL_DELETER_$owner); SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1 SWIG_NO_NULL_DELETER_$owner);
%set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN));
} }
%typemap(varin) CONST TYPE *& %{ %typemap(varin) TYPE *CONST& %{
#error "varin typemap not implemented" #error "varin typemap not implemented"
%} %}
%typemap(varout) CONST TYPE *& %{ %typemap(varout) TYPE *CONST& %{
#error "varout typemap not implemented" #error "varout typemap not implemented"
%} %}
@ -291,10 +291,10 @@
// Note: SWIG_ConvertPtr with void ** parameter set to 0 instead of using SWIG_ConvertPtrAndOwn, so that the casting // Note: SWIG_ConvertPtr with void ** parameter set to 0 instead of using SWIG_ConvertPtrAndOwn, so that the casting
// function is not called thereby avoiding a possible smart pointer copy constructor call when casting up the inheritance chain. // function is not called thereby avoiding a possible smart pointer copy constructor call when casting up the inheritance chain.
%typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER,noblock=1) %typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER,noblock=1)
CONST TYPE, TYPE CONST,
CONST TYPE &, TYPE CONST &,
CONST TYPE *, TYPE CONST *,
CONST TYPE *&, TYPE *CONST&,
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >,
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > &, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > &,
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *,

View File

@ -61,7 +61,7 @@
/* ------------------------------------------------------------ /* ------------------------------------------------------------
* Python extra typemaps * Python extra typemaps / typemap overrides
* ------------------------------------------------------------ */ * ------------------------------------------------------------ */
/* Get the address of the 'python self' object */ /* Get the address of the 'python self' object */

View File

@ -29,8 +29,10 @@
%typemap("rtype") bool, bool * "logical"; %typemap("rtype") bool, bool * "logical";
%typemap("rtype") enum SWIGTYPE "character"; %typemap("rtype") enum SWIGTYPE "character";
%typemap("rtype") enum SWIGTYPE * "character"; %typemap("rtype") enum SWIGTYPE * "character";
%typemap("rtype") enum SWIGTYPE *const "character";
%typemap("rtype") enum SWIGTYPE & "character"; %typemap("rtype") enum SWIGTYPE & "character";
%typemap("rtype") SWIGTYPE * "$R_class"; %typemap("rtype") SWIGTYPE * "$R_class";
%typemap("rtype") SWIGTYPE *const "$R_class";
%typemap("rtype") SWIGTYPE & "$R_class"; %typemap("rtype") SWIGTYPE & "$R_class";
%typemap("rtype") SWIGTYPE "$&R_class"; %typemap("rtype") SWIGTYPE "$&R_class";
@ -65,13 +67,15 @@
%{ $input = enumToInteger($input, "$R_class"); %} %{ $input = enumToInteger($input, "$R_class"); %}
%typemap(scoercein) enum SWIGTYPE * %typemap(scoercein) enum SWIGTYPE *
%{ $input = enumToInteger($input, "$R_class"); %} %{ $input = enumToInteger($input, "$R_class"); %}
%typemap(scoercein) enum SWIGTYPE *const
%{ $input = enumToInteger($input, "$R_class"); %}
%typemap(scoercein) SWIGTYPE, SWIGTYPE *, SWIGTYPE & %typemap(scoercein) SWIGTYPE, SWIGTYPE *, SWIGTYPE *const, SWIGTYPE &
%{ %} %{ %}
/* /*
%typemap(scoercein) SWIGTYPE * %typemap(scoercein) SWIGTYPE *, SWIGTYPE *const
%{ $input = coerceIfNotSubclass($input, "$R_class") %} %{ $input = coerceIfNotSubclass($input, "$R_class") %}
%typemap(scoercein) SWIGTYPE & %typemap(scoercein) SWIGTYPE &
@ -115,6 +119,9 @@ string &, std::string &
%typemap(scoerceout) enum SWIGTYPE * %typemap(scoerceout) enum SWIGTYPE *
%{ $result = enumToInteger($result, "$R_class"); %} %{ $result = enumToInteger($result, "$R_class"); %}
%typemap(scoerceout) enum SWIGTYPE *const
%{ $result = enumToInteger($result, "$R_class"); %}
%typemap(scoerceout) SWIGTYPE %typemap(scoerceout) SWIGTYPE
%{ class($result) <- "$&R_class"; %} %{ class($result) <- "$&R_class"; %}
@ -125,6 +132,9 @@ string &, std::string &
%typemap(scoerceout) SWIGTYPE * %typemap(scoerceout) SWIGTYPE *
%{ class($result) <- "$R_class"; %} %{ class($result) <- "$R_class"; %}
%typemap(scoerceout) SWIGTYPE *const
%{ class($result) <- "$R_class"; %}
/* Override the SWIGTYPE * above. */ /* Override the SWIGTYPE * above. */
%typemap(scoerceout) char, %typemap(scoerceout) char,
char *, char *,

View File

@ -31,7 +31,7 @@ namespace std {
bool empty() const; bool empty() const;
void clear(); void clear();
%extend { %extend {
T& get(const K& key) throw (std::out_of_range) { const T& get(const K& key) throw (std::out_of_range) {
std::map<K,T >::iterator i = self->find(key); std::map<K,T >::iterator i = self->find(key);
if (i != self->end()) if (i != self->end())
return i->second; return i->second;

View File

@ -61,7 +61,7 @@
/* ------------------------------------------------------------ /* ------------------------------------------------------------
* Tcl extra typemaps * Tcl extra typemaps / typemap overrides
* ------------------------------------------------------------ */ * ------------------------------------------------------------ */
#if 1 #if 1
@ -84,6 +84,7 @@
%typemap(out) SWIGTYPE = SWIGTYPE INSTANCE; %typemap(out) SWIGTYPE = SWIGTYPE INSTANCE;
%typemap(out) SWIGTYPE * = SWIGTYPE *INSTANCE; %typemap(out) SWIGTYPE * = SWIGTYPE *INSTANCE;
%typemap(out) SWIGTYPE *const = SWIGTYPE *;
%typemap(out) SWIGTYPE & = SWIGTYPE &INSTANCE; %typemap(out) SWIGTYPE & = SWIGTYPE &INSTANCE;
%typemap(out) SWIGTYPE [] = SWIGTYPE INSTANCE[]; %typemap(out) SWIGTYPE [] = SWIGTYPE INSTANCE[];
%typemap(varout) SWIGTYPE = SWIGTYPE INSTANCE; %typemap(varout) SWIGTYPE = SWIGTYPE INSTANCE;

View File

@ -21,15 +21,15 @@
%typemap(freearg) SWIGTYPE [] ""; %typemap(freearg) SWIGTYPE [] "";
%typemap(in, noblock=1) SWIGTYPE* const& (void *argp = 0, int res = 0, $*ltype temp) { %typemap(in, noblock=1) SWIGTYPE *const& (void *argp = 0, int res = 0, $*1_ltype temp) {
res = SWIG_ConvertPtr($input, &argp, $*descriptor, $disown | %convertptr_flags); res = SWIG_ConvertPtr($input, &argp, $*descriptor, $disown | %convertptr_flags);
if (!SWIG_IsOK(res)) { if (!SWIG_IsOK(res)) {
%argument_fail(res, "$*ltype", $symname, $argnum); %argument_fail(res, "$*ltype", $symname, $argnum);
} }
temp = %reinterpret_cast(argp, $*ltype); temp = %reinterpret_cast(argp, $*ltype);
$1 = &temp; $1 = %reinterpret_cast(&temp, $1_ltype);
} }
%typemap(freearg) SWIGTYPE* const& ""; %typemap(freearg) SWIGTYPE *const& "";
/* Reference */ /* Reference */
@ -106,7 +106,7 @@
%set_output(SWIG_NewPointerObj(%as_voidptr($1), $descriptor, $owner | %newpointer_flags)); %set_output(SWIG_NewPointerObj(%as_voidptr($1), $descriptor, $owner | %newpointer_flags));
} }
%typemap(out, noblock=1) SWIGTYPE* const& { %typemap(out, noblock=1) SWIGTYPE *const& {
%set_output(SWIG_NewPointerObj(%as_voidptr(*$1), $*descriptor, $owner | %newpointer_flags)); %set_output(SWIG_NewPointerObj(%as_voidptr(*$1), $*descriptor, $owner | %newpointer_flags));
} }
@ -299,6 +299,12 @@
$1 = SWIG_CheckState(res); $1 = SWIG_CheckState(res);
} }
%typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER,noblock=1) SWIGTYPE *const& {
void *vptr = 0;
int res = SWIG_ConvertPtr($input, &vptr, $descriptor, 0);
$1 = SWIG_CheckState(res);
}
%typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER,noblock=1) SWIGTYPE & { %typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER,noblock=1) SWIGTYPE & {
void *vptr = 0; void *vptr = 0;
int res = SWIG_ConvertPtr($input, &vptr, $descriptor, 0); int res = SWIG_ConvertPtr($input, &vptr, $descriptor, 0);
@ -337,7 +343,7 @@
/* directorin */ /* directorin */
%typemap(directorin,noblock=1) SWIGTYPE*, SWIGTYPE* const& { %typemap(directorin,noblock=1) SWIGTYPE *, SWIGTYPE *const& {
$input = SWIG_NewPointerObj(%as_voidptr($1_name), $descriptor, %newpointer_flags); $input = SWIG_NewPointerObj(%as_voidptr($1_name), $descriptor, %newpointer_flags);
} }
@ -345,7 +351,7 @@
$input = SWIG_NewPointerObj(%as_voidptr(&$1_name), $&descriptor, %newpointer_flags); $input = SWIG_NewPointerObj(%as_voidptr(&$1_name), $&descriptor, %newpointer_flags);
} }
%typemap(directorin,noblock=1) SWIGTYPE& { %typemap(directorin,noblock=1) SWIGTYPE & {
$input = SWIG_NewPointerObj(%as_voidptr(&$1_name), $descriptor, %newpointer_flags); $input = SWIG_NewPointerObj(%as_voidptr(&$1_name), $descriptor, %newpointer_flags);
} }
@ -407,7 +413,7 @@
* --- Constants --- * --- Constants ---
* ------------------------------------------------------------ */ * ------------------------------------------------------------ */
%typemap(constcode,noblock=1) SWIGTYPE *, SWIGTYPE &, SWIGTYPE []{ %typemap(constcode,noblock=1) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [] {
%set_constant("$symname", SWIG_NewPointerObj(%as_voidptr($value),$descriptor,%newpointer_flags)); %set_constant("$symname", SWIG_NewPointerObj(%as_voidptr($value),$descriptor,%newpointer_flags));
} }
@ -547,6 +553,7 @@
} }
#endif #endif
%apply SWIGTYPE * { SWIGTYPE *const }
/* ------------------------------------------------------------ /* ------------------------------------------------------------
* --- Special typemaps --- * --- Special typemaps ---
@ -602,3 +609,4 @@
%typemap(varout,noblock=1) SWIGTYPE INSTANCE { %typemap(varout,noblock=1) SWIGTYPE INSTANCE {
%set_varoutput(SWIG_NewInstanceObj(%as_voidptr(&$1), $&1_descriptor, %newinstance_flags)); %set_varoutput(SWIG_NewInstanceObj(%as_voidptr(&$1), $&1_descriptor, %newinstance_flags));
} }

View File

@ -3014,8 +3014,6 @@ Node *Language::classLookup(SwigType *s) {
Symtab *stab = 0; Symtab *stab = 0;
SwigType *ty1 = SwigType_typedef_resolve_all(s); SwigType *ty1 = SwigType_typedef_resolve_all(s);
SwigType *ty2 = SwigType_strip_qualifiers(ty1); SwigType *ty2 = SwigType_strip_qualifiers(ty1);
Delete(ty1);
ty1 = 0;
String *base = SwigType_base(ty2); String *base = SwigType_base(ty2);
@ -3052,11 +3050,18 @@ Node *Language::classLookup(SwigType *s) {
if (n) { if (n) {
/* Found a match. Look at the prefix. We only allow /* Found a match. Look at the prefix. We only allow
the cases where where we want a proxy class for the particular type */ the cases where where we want a proxy class for the particular type */
if ((Len(prefix) == 0) || // simple type (pass by value) bool acceptable_prefix =
(Strcmp(prefix, "p.") == 0) || // pointer (Len(prefix) == 0) || // simple type (pass by value)
(Strcmp(prefix, "r.") == 0) || // reference (Strcmp(prefix, "p.") == 0) || // pointer
(Strcmp(prefix, "r.p.") == 0) || // pointer by reference (Strcmp(prefix, "r.") == 0) || // reference
SwigType_prefix_is_simple_1D_array(prefix)) { // Simple 1D array (not arrays of pointers/references) SwigType_prefix_is_simple_1D_array(prefix); // Simple 1D array (not arrays of pointers/references)
// Also accept pointer by const reference, not non-const pointer reference
if (!acceptable_prefix && (Strcmp(prefix, "r.p.") == 0)) {
Delete(prefix);
prefix = SwigType_prefix(ty1);
acceptable_prefix = (Strncmp(prefix, "r.q(const", 9) == 0);
}
if (acceptable_prefix) {
SwigType *cs = Copy(s); SwigType *cs = Copy(s);
Setattr(classtypes, cs, n); Setattr(classtypes, cs, n);
Delete(cs); Delete(cs);
@ -3064,9 +3069,10 @@ Node *Language::classLookup(SwigType *s) {
n = 0; n = 0;
} }
} }
Delete(ty2);
Delete(base);
Delete(prefix); Delete(prefix);
Delete(base);
Delete(ty2);
Delete(ty1);
} }
if (n && (GetFlag(n, "feature:ignore") || Getattr(n, "feature:onlychildren"))) { if (n && (GetFlag(n, "feature:ignore") || Getattr(n, "feature:onlychildren"))) {
n = 0; n = 0;
@ -3092,10 +3098,6 @@ Node *Language::enumLookup(SwigType *s) {
SwigType *lt = SwigType_ltype(s); SwigType *lt = SwigType_ltype(s);
SwigType *ty1 = SwigType_typedef_resolve_all(lt); SwigType *ty1 = SwigType_typedef_resolve_all(lt);
SwigType *ty2 = SwigType_strip_qualifiers(ty1); SwigType *ty2 = SwigType_strip_qualifiers(ty1);
Delete(lt);
Delete(ty1);
lt = 0;
ty1 = 0;
String *base = SwigType_base(ty2); String *base = SwigType_base(ty2);
@ -3134,9 +3136,11 @@ Node *Language::enumLookup(SwigType *s) {
n = 0; n = 0;
} }
} }
Delete(ty2);
Delete(base);
Delete(prefix); Delete(prefix);
Delete(base);
Delete(ty2);
Delete(ty1);
Delete(lt);
} }
if (n && (GetFlag(n, "feature:ignore"))) { if (n && (GetFlag(n, "feature:ignore"))) {
n = 0; n = 0;

View File

@ -492,6 +492,186 @@ SwigType *SwigType_default(SwigType *t) {
return def; return def;
} }
/* -----------------------------------------------------------------------------
* SwigType_default_create()
*
* Create the default type for this datatype. This takes a type and strips it
* down to a generic form first by resolving all typedefs.
*
* Rules:
* Pointers: p.SWIGTYPE
* References: r.SWIGTYPE
* Arrays no dimension: a().SWIGTYPE
* Arrays with dimension: a(ANY).SWIGTYPE
* Member pointer: m(CLASS).SWIGTYPE
* Function pointer: f(ANY).SWIGTYPE
* Enums: enum SWIGTYPE
* Types: SWIGTYPE
*
* Examples (also see SwigType_default_reduce):
*
* int [2][4]
* a(2).a(4).int
* a(ANY).a(ANY).SWIGTYPE
*
* struct A {};
* typedef A *Aptr;
* Aptr const &
* r.q(const).Aptr
* r.q(const).p.SWIGTYPE
*
* enum E {e1, e2};
* enum E const &
* r.q(const).enum E
* r.q(const).enum SWIGTYPE
* ----------------------------------------------------------------------------- */
SwigType *SwigType_default_create(SwigType *ty) {
SwigType *r = 0;
List *l;
Iterator it;
int numitems;
if (!SwigType_isvarargs(ty)) {
SwigType *t = SwigType_typedef_resolve_all(ty);
r = NewStringEmpty();
l = SwigType_split(t);
numitems = Len(l);
if (numitems >= 1) {
String *last_subtype = Getitem(l, numitems-1);
if (SwigType_isenum(last_subtype))
Setitem(l, numitems-1, NewString("enum SWIGTYPE"));
else
Setitem(l, numitems-1, NewString("SWIGTYPE"));
}
for (it = First(l); it.item; it = Next(it)) {
String *subtype = it.item;
if (SwigType_isarray(subtype)) {
if (Equal(subtype, "a()."))
Append(r, NewString("a()."));
else
Append(r, NewString("a(ANY)."));
} else if (SwigType_isfunction(subtype)) {
Append(r, NewString("f(ANY).SWIGTYPE"));
break;
} else if (SwigType_ismemberpointer(subtype)) {
Append(r, NewString("m(CLASS).SWIGTYPE"));
break;
} else {
Append(r, subtype);
}
}
Delete(l);
Delete(t);
}
return r;
}
/* -----------------------------------------------------------------------------
* SwigType_default_reduce()
*
* This function implements type reduction used in the typemap matching rules
* and is very close to the type reduction used in partial template specialization.
* SWIGTYPE is used as the generic type. The basic idea is to repeatedly call
* this function to reduce the type until it is reduced to nothing.
*
* The type t must have already been converted to the default type via a call to
* SwigType_default_create() before calling this function.
*
* Example reductions (matching the examples described in SwigType_default_create):
*
* a(ANY).a(ANY).SWIGTYPE
* a(ANY).a().SWIGTYPE
* a(ANY).p.SWIGTYPE
* a(ANY).SWIGTYPE
* a().SWIGTYPE
* p.SWIGTYPE
* SWIGTYPE
*
* r.q(const).p.SWIGTYPE
* r.q(const).SWIGTYPE
* r.SWIGTYPE
* SWIGTYPE
*
* r.q(const).enum SWIGTYPE
* r.enum SWIGTYPE
* r.SWIGTYPE
* SWIGTYPE
* ----------------------------------------------------------------------------- */
SwigType *SwigType_default_reduce(SwigType *t) {
SwigType *r = NewStringEmpty();
List *l;
Iterator it;
int numitems;
l = SwigType_split(t);
numitems = Len(l);
if (numitems >= 1) {
String *last_subtype = Getitem(l, numitems-1);
int is_enum = SwigType_isenum(last_subtype);
if (numitems >=2 ) {
String *subtype = Getitem(l, numitems-2); /* last but one */
if (SwigType_isarray(subtype)) {
if (is_enum) {
/* enum reduction, enum SWIGTYPE => SWIGTYPE */
Setitem(l, numitems-1, NewString("SWIGTYPE"));
} else {
/* array reduction, a(ANY). => a(). => p. */
String *reduced_subtype = 0;
if (Strcmp(subtype, "a().") == 0) {
reduced_subtype = NewString("p.");
} else if (Strcmp(subtype, "a(ANY).") == 0) {
reduced_subtype = NewString("a().");
} else {
assert(0);
}
Setitem(l, numitems-2, reduced_subtype);
}
} else if (SwigType_ismemberpointer(subtype)) {
/* member pointer reduction, m(CLASS). => p. */
Setitem(l, numitems-2, NewString("p."));
} else if (is_enum && !SwigType_isqualifier(subtype)) {
/* enum reduction, enum SWIGTYPE => SWIGTYPE */
Setitem(l, numitems-1, NewString("SWIGTYPE"));
} else {
/* simple type reduction, eg, r.p.p. => r.p. */
/* also function pointers eg, p.f(ANY). => p. */
Delitem(l, numitems-2);
}
} else {
if (is_enum) {
/* enum reduction, enum SWIGTYPE => SWIGTYPE */
Setitem(l, numitems-1, NewString("SWIGTYPE"));
} else {
/* delete the only item, we are done with reduction */
Delitem(l, 0);
}
}
} else {
assert(0);
}
for (it = First(l); it.item; it = Next(it)) {
Append(r, it.item);
}
if (Len(r) == 0) {
Delete(r);
r = 0;
}
Delete(l);
return r;
}
/* ----------------------------------------------------------------------------- /* -----------------------------------------------------------------------------
* SwigType_namestr() * SwigType_namestr()
* *

View File

@ -172,6 +172,8 @@ extern "C" {
extern void SwigType_array_setdim(SwigType *t, int n, const_String_or_char_ptr rep); extern void SwigType_array_setdim(SwigType *t, int n, const_String_or_char_ptr rep);
extern SwigType *SwigType_array_type(SwigType *t); extern SwigType *SwigType_array_type(SwigType *t);
extern String *SwigType_default(SwigType *t); extern String *SwigType_default(SwigType *t);
extern SwigType *SwigType_default_create(SwigType *ty);
extern SwigType *SwigType_default_reduce(SwigType *t);
extern void SwigType_typename_replace(SwigType *t, String *pat, String *rep); extern void SwigType_typename_replace(SwigType *t, String *pat, String *rep);
extern SwigType *SwigType_remove_global_scope_prefix(const SwigType *t); extern SwigType *SwigType_remove_global_scope_prefix(const SwigType *t);
extern SwigType *SwigType_alttype(SwigType *t, int ltmap); extern SwigType *SwigType_alttype(SwigType *t, int ltmap);

View File

@ -674,7 +674,7 @@ static Hash *typemap_search_helper(int debug_display, Hash *tm, const String *tm
if (debug_display) if (debug_display)
Printf(stdout, " Looking for: %s\n", SwigType_str(ctype, 0)); Printf(stdout, " Looking for: %s\n", SwigType_str(ctype, 0));
if (tm) { if (tm) {
result = Getattr(tm, tm_method); /* See if there is simply a type match */ result = Getattr(tm, tm_method); /* See if there is simply a type without name match */
if (result && Getattr(result, "code")) if (result && Getattr(result, "code"))
goto ret_result; goto ret_result;
if (result) if (result)
@ -779,7 +779,7 @@ static Hash *typemap_search(const_String_or_char_ptr tmap_method, SwigType *type
/* Hmmm. Well, no match seems to be found at all. See if there is some kind of default (SWIGTYPE) mapping */ /* Hmmm. Well, no match seems to be found at all. See if there is some kind of default (SWIGTYPE) mapping */
primitive = SwigType_default(type); primitive = SwigType_default_create(type);
while (primitive) { while (primitive) {
tm = get_typemap(ts, primitive); tm = get_typemap(ts, primitive);
result = typemap_search_helper(debug_display, tm, tm_method, primitive, cqualifiedname, cname, &backup); result = typemap_search_helper(debug_display, tm, tm_method, primitive, cqualifiedname, cname, &backup);
@ -787,7 +787,7 @@ static Hash *typemap_search(const_String_or_char_ptr tmap_method, SwigType *type
goto ret_result; goto ret_result;
{ {
SwigType *nprim = SwigType_default(primitive); SwigType *nprim = SwigType_default_reduce(primitive);
Delete(primitive); Delete(primitive);
primitive = nprim; primitive = nprim;
} }

View File

@ -50,6 +50,9 @@ char cvsroot_typeobj_c[] = "$Id$";
* 'q(str).' = Qualifier (such as const or volatile) (const, volatile) * 'q(str).' = Qualifier (such as const or volatile) (const, volatile)
* 'm(qual).' = Pointer to member (qual::*) * 'm(qual).' = Pointer to member (qual::*)
* *
* The complete type representation for varargs is:
* 'v(...)'
*
* The encoding follows the order that you might describe a type in words. * The encoding follows the order that you might describe a type in words.
* For example "p.a(200).int" is "A pointer to array of int's" and * For example "p.a(200).int" is "A pointer to array of int's" and
* "p.q(const).char" is "a pointer to a const char". * "p.q(const).char" is "a pointer to a const char".
@ -177,6 +180,9 @@ SwigType *SwigType_del_element(SwigType *t) {
* SwigType_pop() * SwigType_pop()
* *
* Pop one type element off the type. * Pop one type element off the type.
* Example: t in: q(const).p.Integer
* t out: p.Integer
* result: q(const).
* ----------------------------------------------------------------------------- */ * ----------------------------------------------------------------------------- */
SwigType *SwigType_pop(SwigType *t) { SwigType *SwigType_pop(SwigType *t) {