merge revisions 11877-12162 from trunk to gsoc2009-matevz
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2009-matevz@12164 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
commit
25ff4e4927
563 changed files with 22912 additions and 17189 deletions
|
|
@ -203,22 +203,28 @@ SWIG_TYPECHECK_STRING_ARRAY 1140
|
|||
|
||||
%typemap(in) wchar_t "$1 = $input;";
|
||||
%typemap(lin,numinputs=1) wchar_t "(cl::let (($out (cl:char-code $in)))\n $body)";
|
||||
%typemap(lin,numinputs=1) wchar_t* "(excl:with-native-string ($out $in
|
||||
%typemap(lin,numinputs=1) wchar_t * "(excl:with-native-string ($out $in
|
||||
:external-format #+little-endian :fat-le #-little-endian :fat)\n
|
||||
$body)"
|
||||
|
||||
%typemap(out) wchar_t "$result = $1;";
|
||||
%typemap(lout) wchar_t "(cl::setq ACL_ffresult (cl::code-char $body))";
|
||||
%typemap(lout) wchar_t* "(cl::setq ACL_ffresult (excl:native-to-string $body
|
||||
%typemap(lout) wchar_t * "(cl::setq ACL_ffresult (excl:native-to-string $body
|
||||
:external-format #+little-endian :fat-le #-little-endian :fat))";
|
||||
|
||||
%typemap(ffitype) wchar_t ":unsigned-short";
|
||||
%typemap(lisptype) wchar_t "";
|
||||
%typemap(ctype) wchar_t "wchar_t";
|
||||
%typemap(lispclass) wchar_t "cl:character";
|
||||
%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. */
|
||||
#ifdef __cplusplus
|
||||
%rename(__add__) *::operator+;
|
||||
|
|
|
|||
|
|
@ -130,6 +130,11 @@
|
|||
%typemap(lispclass) double "cl:number";
|
||||
%typemap(lispclass) char * "cl:string";
|
||||
|
||||
/* Array reference typemaps */
|
||||
%apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) }
|
||||
|
||||
/* const pointers */
|
||||
%apply SWIGTYPE * { SWIGTYPE *const }
|
||||
|
||||
%{
|
||||
|
||||
|
|
|
|||
|
|
@ -679,6 +679,16 @@ $result = C_SCHEME_UNDEFINED;
|
|||
|
||||
%apply unsigned long { size_t };
|
||||
|
||||
/* ------------------------------------------------------------
|
||||
* Various
|
||||
* ------------------------------------------------------------ */
|
||||
|
||||
/* Array reference typemaps */
|
||||
%apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) }
|
||||
|
||||
/* const pointers */
|
||||
%apply SWIGTYPE * { SWIGTYPE *const }
|
||||
|
||||
/* ------------------------------------------------------------
|
||||
* Overloaded operator support
|
||||
* ------------------------------------------------------------ */
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ namespace std {
|
|||
%typemap(typecheck) string = char *;
|
||||
%typemap(typecheck) const string & = char *;
|
||||
|
||||
%typemap(in) string (char* tempptr) {
|
||||
%typemap(in) string (char * tempptr) {
|
||||
if ($input == C_SCHEME_FALSE) {
|
||||
$1.resize(0);
|
||||
} else {
|
||||
|
|
@ -44,8 +44,7 @@ namespace std {
|
|||
}
|
||||
}
|
||||
|
||||
%typemap(in) const string& (std::string temp,
|
||||
char* tempptr) {
|
||||
%typemap(in) const string& (std::string temp, char *tempptr) {
|
||||
|
||||
if ($input == C_SCHEME_FALSE) {
|
||||
temp.resize(0);
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
%include <shared_ptr.i>
|
||||
|
||||
// Language specific macro implementing all the customisations for handling the smart pointer
|
||||
%define SWIG_SHARED_PTR_TYPEMAPS(PROXYCLASS, CONST, TYPE...)
|
||||
%define SWIG_SHARED_PTR_TYPEMAPS(CONST, TYPE...)
|
||||
|
||||
// %naturalvar is as documented for member variables
|
||||
%naturalvar TYPE;
|
||||
|
|
@ -44,10 +44,10 @@
|
|||
%{ $result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_$owner); %}
|
||||
|
||||
// plain pointer by reference
|
||||
%typemap(in) CONST TYPE *& ($*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);
|
||||
%typemap(in) TYPE *CONST& ($*1_ltype temp = 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; %}
|
||||
%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); %}
|
||||
|
||||
// shared_ptr by value
|
||||
|
|
@ -96,51 +96,51 @@
|
|||
%typemap (cstype) 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 > *& "PROXYCLASS"
|
||||
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& "$typemap(cstype, TYPE)"
|
||||
|
||||
%typemap(csin) 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 > *& "PROXYCLASS.getCPtr($csinput)"
|
||||
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& "$typemap(cstype, TYPE).getCPtr($csinput)"
|
||||
|
||||
%typemap(csout, excode=SWIGEXCODE) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > {
|
||||
IntPtr cPtr = $imcall;
|
||||
PROXYCLASS ret = (cPtr == IntPtr.Zero) ? null : new PROXYCLASS(cPtr, true);$excode
|
||||
$typemap(cstype, TYPE) ret = (cPtr == IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode
|
||||
return ret;
|
||||
}
|
||||
%typemap(csout, excode=SWIGEXCODE) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & {
|
||||
IntPtr cPtr = $imcall;
|
||||
PROXYCLASS ret = (cPtr == IntPtr.Zero) ? null : new PROXYCLASS(cPtr, true);$excode
|
||||
$typemap(cstype, TYPE) ret = (cPtr == IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode
|
||||
return ret;
|
||||
}
|
||||
%typemap(csout, excode=SWIGEXCODE) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * {
|
||||
IntPtr cPtr = $imcall;
|
||||
PROXYCLASS ret = (cPtr == IntPtr.Zero) ? null : new PROXYCLASS(cPtr, true);$excode
|
||||
$typemap(cstype, TYPE) ret = (cPtr == IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode
|
||||
return ret;
|
||||
}
|
||||
%typemap(csout, excode=SWIGEXCODE) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& {
|
||||
IntPtr cPtr = $imcall;
|
||||
PROXYCLASS ret = (cPtr == IntPtr.Zero) ? null : new PROXYCLASS(cPtr, true);$excode
|
||||
$typemap(cstype, TYPE) ret = (cPtr == IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
%typemap(csout, excode=SWIGEXCODE) CONST TYPE {
|
||||
PROXYCLASS ret = new PROXYCLASS($imcall, true);$excode
|
||||
$typemap(cstype, TYPE) ret = new $typemap(cstype, TYPE)($imcall, true);$excode
|
||||
return ret;
|
||||
}
|
||||
%typemap(csout, excode=SWIGEXCODE) CONST TYPE & {
|
||||
PROXYCLASS ret = new PROXYCLASS($imcall, true);$excode
|
||||
$typemap(cstype, TYPE) ret = new $typemap(cstype, TYPE)($imcall, true);$excode
|
||||
return ret;
|
||||
}
|
||||
%typemap(csout, excode=SWIGEXCODE) CONST TYPE * {
|
||||
IntPtr cPtr = $imcall;
|
||||
PROXYCLASS ret = (cPtr == IntPtr.Zero) ? null : new PROXYCLASS(cPtr, true);$excode
|
||||
$typemap(cstype, TYPE) ret = (cPtr == IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode
|
||||
return ret;
|
||||
}
|
||||
%typemap(csout, excode=SWIGEXCODE) CONST TYPE *& {
|
||||
%typemap(csout, excode=SWIGEXCODE) TYPE *CONST& {
|
||||
IntPtr cPtr = $imcall;
|
||||
PROXYCLASS ret = (cPtr == IntPtr.Zero) ? null : new PROXYCLASS(cPtr, true);$excode
|
||||
$typemap(cstype, TYPE) ret = (cPtr == IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
@ -159,13 +159,13 @@
|
|||
%typemap(csvarout, excode=SWIGEXCODE2) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & %{
|
||||
get {
|
||||
IntPtr cPtr = $imcall;
|
||||
PROXYCLASS ret = (cPtr == IntPtr.Zero) ? null : new PROXYCLASS(cPtr, true);$excode
|
||||
$typemap(cstype, TYPE) ret = (cPtr == IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode
|
||||
return ret;
|
||||
} %}
|
||||
%typemap(csvarout, excode=SWIGEXCODE2) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * %{
|
||||
get {
|
||||
IntPtr cPtr = $imcall;
|
||||
PROXYCLASS ret = (cPtr == IntPtr.Zero) ? null : new PROXYCLASS(cPtr, true);$excode
|
||||
$typemap(cstype, TYPE) ret = (cPtr == IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode
|
||||
return ret;
|
||||
} %}
|
||||
|
||||
|
|
@ -190,7 +190,7 @@
|
|||
private HandleRef swigCPtr;
|
||||
private bool swigCMemOwnDerived;
|
||||
|
||||
internal $csclassname(IntPtr cPtr, bool cMemoryOwn) : base($imclassname.$csclassname_SWIGSharedPtrUpcast(cPtr), true) {
|
||||
internal $csclassname(IntPtr cPtr, bool cMemoryOwn) : base($imclassname.$csclazznameSWIGSmartPtrUpcast(cPtr), true) {
|
||||
swigCMemOwnDerived = cMemoryOwn;
|
||||
swigCPtr = new HandleRef(this, cPtr);
|
||||
}
|
||||
|
|
@ -227,10 +227,6 @@
|
|||
}
|
||||
}
|
||||
|
||||
%typemap(imtype) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > swigSharedPtrUpcast "IntPtr"
|
||||
%typemap(csin) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > swigSharedPtrUpcast "PROXYCLASS.getCPtr($csinput).Handle"
|
||||
|
||||
|
||||
%template() SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >;
|
||||
%enddef
|
||||
|
||||
|
|
|
|||
|
|
@ -533,6 +533,7 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
|
|||
SWIGTYPE *,
|
||||
SWIGTYPE &,
|
||||
SWIGTYPE &&,
|
||||
SWIGTYPE *const&,
|
||||
SWIGTYPE [],
|
||||
SWIGTYPE (CLASS::*)
|
||||
""
|
||||
|
|
@ -802,24 +803,21 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
|
|||
} %}
|
||||
|
||||
/* Pointer reference typemaps */
|
||||
%typemap(ctype) SWIGTYPE *& "void *"
|
||||
%typemap(imtype, out="IntPtr") SWIGTYPE *& "HandleRef"
|
||||
%typemap(cstype) SWIGTYPE *& "$*csclassname"
|
||||
%typemap(csin) SWIGTYPE *& "$*csclassname.getCPtr($csinput)"
|
||||
%typemap(csout, excode=SWIGEXCODE) SWIGTYPE *& {
|
||||
%typemap(ctype) SWIGTYPE *const& "void *"
|
||||
%typemap(imtype, out="IntPtr") SWIGTYPE *const& "HandleRef"
|
||||
%typemap(cstype) SWIGTYPE *const& "$*csclassname"
|
||||
%typemap(csin) SWIGTYPE *const& "$*csclassname.getCPtr($csinput)"
|
||||
%typemap(csout, excode=SWIGEXCODE) SWIGTYPE *const& {
|
||||
IntPtr cPtr = $imcall;
|
||||
$*csclassname ret = (cPtr == IntPtr.Zero) ? null : new $*csclassname(cPtr, $owner);$excode
|
||||
return ret;
|
||||
}
|
||||
%typemap(in) SWIGTYPE *& ($*1_ltype temp = 0)
|
||||
%typemap(in) SWIGTYPE *const& ($*1_ltype temp = 0)
|
||||
%{ temp = ($*1_ltype)$input;
|
||||
$1 = &temp; %}
|
||||
%typemap(out) SWIGTYPE *&
|
||||
$1 = ($1_ltype)&temp; %}
|
||||
%typemap(out) SWIGTYPE *const&
|
||||
%{ $result = (void *)*$1; %}
|
||||
|
||||
/* Array reference typemaps */
|
||||
%apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) }
|
||||
|
||||
/* Marshal C/C++ pointer to IntPtr */
|
||||
%typemap(ctype) void *VOID_INT_PTR "void *"
|
||||
%typemap(imtype) void *VOID_INT_PTR "IntPtr"
|
||||
|
|
@ -861,7 +859,7 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
|
|||
%typemap(csbody_derived) SWIGTYPE %{
|
||||
private HandleRef swigCPtr;
|
||||
|
||||
internal $csclassname(IntPtr cPtr, bool cMemoryOwn) : base($imclassname.$csclassnameUpcast(cPtr), cMemoryOwn) {
|
||||
internal $csclassname(IntPtr cPtr, bool cMemoryOwn) : base($imclassname.$csclazznameSWIGUpcast(cPtr), cMemoryOwn) {
|
||||
swigCPtr = new HandleRef(this, cPtr);
|
||||
}
|
||||
|
||||
|
|
@ -973,12 +971,21 @@ using System.Runtime.InteropServices;
|
|||
%apply unsigned long { size_t };
|
||||
%apply const unsigned long & { const size_t & };
|
||||
|
||||
/* Array reference typemaps */
|
||||
%apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) }
|
||||
|
||||
/* const pointers */
|
||||
%apply SWIGTYPE * { SWIGTYPE *const }
|
||||
|
||||
/* csharp keywords */
|
||||
%include <csharpkw.swg>
|
||||
|
||||
// Default enum handling
|
||||
%include <enums.swg>
|
||||
|
||||
// For vararg handling in macros, from swigmacros.swg
|
||||
#define %arg(X...) X
|
||||
|
||||
/*
|
||||
// Alternative char * typemaps.
|
||||
%pragma(csharp) imclasscode=%{
|
||||
|
|
|
|||
|
|
@ -319,6 +319,14 @@ SWIGEXPORT void SWIGSTDCALL SWIGRegisterStringCallback_$module(SWIG_CSharpString
|
|||
%}
|
||||
#endif // SWIG_CSHARP_NO_STRING_HELPER
|
||||
|
||||
#if !defined(SWIG_CSHARP_NO_IMCLASS_STATIC_CONSTRUCTOR)
|
||||
// Ensure the class is not marked beforefieldinit
|
||||
%pragma(csharp) imclasscode=%{
|
||||
static $imclassname() {
|
||||
}
|
||||
%}
|
||||
#endif
|
||||
|
||||
%insert(runtime) %{
|
||||
/* Contract support */
|
||||
|
||||
|
|
|
|||
|
|
@ -296,14 +296,14 @@ namespace std {
|
|||
|
||||
// Legacy macros (deprecated)
|
||||
%define specialize_std_map_on_key(K,CHECK,CONVERT_FROM,CONVERT_TO)
|
||||
#warning specialize_std_map_on_key ignored - macro is deprecated and no longer necessary
|
||||
#warning "specialize_std_map_on_key ignored - macro is deprecated and no longer necessary"
|
||||
%enddef
|
||||
|
||||
%define specialize_std_map_on_value(T,CHECK,CONVERT_FROM,CONVERT_TO)
|
||||
#warning specialize_std_map_on_value ignored - macro is deprecated and no longer necessary
|
||||
#warning "specialize_std_map_on_value ignored - macro is deprecated and no longer necessary"
|
||||
%enddef
|
||||
|
||||
%define specialize_std_map_on_both(K,CHECK_K,CONVERT_K_FROM,CONVERT_K_TO, T,CHECK_T,CONVERT_T_FROM,CONVERT_T_TO)
|
||||
#warning specialize_std_map_on_both ignored - macro is deprecated and no longer necessary
|
||||
#warning "specialize_std_map_on_both ignored - macro is deprecated and no longer necessary"
|
||||
%enddef
|
||||
|
||||
|
|
|
|||
2
Lib/csharp/std_shared_ptr.i
Normal file
2
Lib/csharp/std_shared_ptr.i
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
#define SWIG_SHARED_PTR_NAMESPACE std
|
||||
%include <boost_shared_ptr.i>
|
||||
|
|
@ -25,9 +25,9 @@
|
|||
%include <std_common.i>
|
||||
|
||||
// MACRO for use within the std::vector class body
|
||||
%define SWIG_STD_VECTOR_MINIMUM_INTERNAL(CSINTERFACE, CONST_REFERENCE_TYPE, CTYPE...)
|
||||
%typemap(csinterfaces) std::vector<CTYPE > "IDisposable, System.Collections.IEnumerable\n#if !SWIG_DOTNET_1\n , System.Collections.Generic.CSINTERFACE<$typemap(cstype, CTYPE)>\n#endif\n";
|
||||
%typemap(cscode) std::vector<CTYPE > %{
|
||||
%define SWIG_STD_VECTOR_MINIMUM_INTERNAL(CSINTERFACE, CONST_REFERENCE, CTYPE...)
|
||||
%typemap(csinterfaces) std::vector< CTYPE > "IDisposable, System.Collections.IEnumerable\n#if !SWIG_DOTNET_1\n , System.Collections.Generic.CSINTERFACE<$typemap(cstype, CTYPE)>\n#endif\n";
|
||||
%typemap(cscode) std::vector< CTYPE > %{
|
||||
public $csclassname(System.Collections.ICollection c) : this() {
|
||||
if (c == null)
|
||||
throw new ArgumentNullException("c");
|
||||
|
|
@ -208,23 +208,23 @@
|
|||
public:
|
||||
typedef size_t size_type;
|
||||
typedef CTYPE value_type;
|
||||
typedef CONST_REFERENCE_TYPE const_reference;
|
||||
typedef CONST_REFERENCE const_reference;
|
||||
%rename(Clear) clear;
|
||||
void clear();
|
||||
%rename(Add) push_back;
|
||||
void push_back(const value_type& x);
|
||||
void push_back(CTYPE const& x);
|
||||
size_type size() const;
|
||||
size_type capacity() const;
|
||||
void reserve(size_type n);
|
||||
%newobject GetRange(int index, int count);
|
||||
%newobject Repeat(const value_type& value, int count);
|
||||
%newobject Repeat(CTYPE const& value, int count);
|
||||
vector();
|
||||
vector(const vector &other);
|
||||
%extend {
|
||||
vector(int capacity) throw (std::out_of_range) {
|
||||
std::vector<CTYPE >* pv = 0;
|
||||
std::vector< CTYPE >* pv = 0;
|
||||
if (capacity >= 0) {
|
||||
pv = new std::vector<CTYPE >();
|
||||
pv = new std::vector< CTYPE >();
|
||||
pv->reserve(capacity);
|
||||
} else {
|
||||
throw std::out_of_range("capacity");
|
||||
|
|
@ -243,34 +243,34 @@
|
|||
else
|
||||
throw std::out_of_range("index");
|
||||
}
|
||||
void setitem(int index, const value_type& val) throw (std::out_of_range) {
|
||||
void setitem(int index, CTYPE const& val) throw (std::out_of_range) {
|
||||
if (index>=0 && index<(int)$self->size())
|
||||
(*$self)[index] = val;
|
||||
else
|
||||
throw std::out_of_range("index");
|
||||
}
|
||||
// Takes a deep copy of the elements unlike ArrayList.AddRange
|
||||
void AddRange(const std::vector<CTYPE >& values) {
|
||||
void AddRange(const std::vector< CTYPE >& values) {
|
||||
$self->insert($self->end(), values.begin(), values.end());
|
||||
}
|
||||
// Takes a deep copy of the elements unlike ArrayList.GetRange
|
||||
std::vector<CTYPE > *GetRange(int index, int count) throw (std::out_of_range, std::invalid_argument) {
|
||||
std::vector< CTYPE > *GetRange(int index, int count) throw (std::out_of_range, std::invalid_argument) {
|
||||
if (index < 0)
|
||||
throw std::out_of_range("index");
|
||||
if (count < 0)
|
||||
throw std::out_of_range("count");
|
||||
if (index >= (int)$self->size()+1 || index+count > (int)$self->size())
|
||||
throw std::invalid_argument("invalid range");
|
||||
return new std::vector<CTYPE >($self->begin()+index, $self->begin()+index+count);
|
||||
return new std::vector< CTYPE >($self->begin()+index, $self->begin()+index+count);
|
||||
}
|
||||
void Insert(int index, const value_type& x) throw (std::out_of_range) {
|
||||
void Insert(int index, CTYPE const& x) throw (std::out_of_range) {
|
||||
if (index>=0 && index<(int)$self->size()+1)
|
||||
$self->insert($self->begin()+index, x);
|
||||
else
|
||||
throw std::out_of_range("index");
|
||||
}
|
||||
// Takes a deep copy of the elements unlike ArrayList.InsertRange
|
||||
void InsertRange(int index, const std::vector<CTYPE >& values) throw (std::out_of_range) {
|
||||
void InsertRange(int index, const std::vector< CTYPE >& values) throw (std::out_of_range) {
|
||||
if (index>=0 && index<(int)$self->size()+1)
|
||||
$self->insert($self->begin()+index, values.begin(), values.end());
|
||||
else
|
||||
|
|
@ -291,10 +291,10 @@
|
|||
throw std::invalid_argument("invalid range");
|
||||
$self->erase($self->begin()+index, $self->begin()+index+count);
|
||||
}
|
||||
static std::vector<CTYPE > *Repeat(const value_type& value, int count) throw (std::out_of_range) {
|
||||
static std::vector< CTYPE > *Repeat(CTYPE const& value, int count) throw (std::out_of_range) {
|
||||
if (count < 0)
|
||||
throw std::out_of_range("count");
|
||||
return new std::vector<CTYPE >(count, value);
|
||||
return new std::vector< CTYPE >(count, value);
|
||||
}
|
||||
void Reverse() {
|
||||
std::reverse($self->begin(), $self->end());
|
||||
|
|
@ -309,7 +309,7 @@
|
|||
std::reverse($self->begin()+index, $self->begin()+index+count);
|
||||
}
|
||||
// Takes a deep copy of the elements unlike ArrayList.SetRange
|
||||
void SetRange(int index, const std::vector<CTYPE >& values) throw (std::out_of_range) {
|
||||
void SetRange(int index, const std::vector< CTYPE >& values) throw (std::out_of_range) {
|
||||
if (index < 0)
|
||||
throw std::out_of_range("index");
|
||||
if (index+values.size() > $self->size())
|
||||
|
|
@ -319,33 +319,29 @@
|
|||
}
|
||||
%enddef
|
||||
|
||||
%define SWIG_STD_VECTOR_MINIMUM(CTYPE...)
|
||||
SWIG_STD_VECTOR_MINIMUM_INTERNAL(IEnumerable, const value_type&, CTYPE)
|
||||
%enddef
|
||||
|
||||
// Extra methods added to the collection class if operator== is defined for the class being wrapped
|
||||
// The class will then implement IList<>, which adds extra functionality
|
||||
%define SWIG_STD_VECTOR_EXTRA_OP_EQUALS_EQUALS(CTYPE...)
|
||||
%extend {
|
||||
bool Contains(const value_type& value) {
|
||||
bool Contains(CTYPE const& value) {
|
||||
return std::find($self->begin(), $self->end(), value) != $self->end();
|
||||
}
|
||||
int IndexOf(const value_type& value) {
|
||||
int IndexOf(CTYPE const& value) {
|
||||
int index = -1;
|
||||
std::vector<CTYPE >::iterator it = std::find($self->begin(), $self->end(), value);
|
||||
std::vector< CTYPE >::iterator it = std::find($self->begin(), $self->end(), value);
|
||||
if (it != $self->end())
|
||||
index = (int)(it - $self->begin());
|
||||
return index;
|
||||
}
|
||||
int LastIndexOf(const value_type& value) {
|
||||
int LastIndexOf(CTYPE const& value) {
|
||||
int index = -1;
|
||||
std::vector<CTYPE >::reverse_iterator rit = std::find($self->rbegin(), $self->rend(), value);
|
||||
std::vector< CTYPE >::reverse_iterator rit = std::find($self->rbegin(), $self->rend(), value);
|
||||
if (rit != $self->rend())
|
||||
index = (int)($self->rend() - 1 - rit);
|
||||
return index;
|
||||
}
|
||||
bool Remove(const value_type& value) {
|
||||
std::vector<CTYPE >::iterator it = std::find($self->begin(), $self->end(), value);
|
||||
bool Remove(CTYPE const& value) {
|
||||
std::vector< CTYPE >::iterator it = std::find($self->begin(), $self->end(), value);
|
||||
if (it != $self->end()) {
|
||||
$self->erase(it);
|
||||
return true;
|
||||
|
|
@ -358,8 +354,8 @@ SWIG_STD_VECTOR_MINIMUM_INTERNAL(IEnumerable, const value_type&, CTYPE)
|
|||
// Macros for std::vector class specializations/enhancements
|
||||
%define SWIG_STD_VECTOR_ENHANCED(CTYPE...)
|
||||
namespace std {
|
||||
template<> class vector<CTYPE > {
|
||||
SWIG_STD_VECTOR_MINIMUM_INTERNAL(IList, const value_type&, CTYPE)
|
||||
template<> class vector< CTYPE > {
|
||||
SWIG_STD_VECTOR_MINIMUM_INTERNAL(IList, %arg(CTYPE const&), %arg(CTYPE))
|
||||
SWIG_STD_VECTOR_EXTRA_OP_EQUALS_EQUALS(CTYPE)
|
||||
};
|
||||
}
|
||||
|
|
@ -392,18 +388,14 @@ namespace std {
|
|||
// primary (unspecialized) class template for std::vector
|
||||
// does not require operator== to be defined
|
||||
template<class T> class vector {
|
||||
SWIG_STD_VECTOR_MINIMUM(T)
|
||||
SWIG_STD_VECTOR_MINIMUM_INTERNAL(IEnumerable, T const&, T)
|
||||
};
|
||||
// specializations for pointers
|
||||
template<class T> class vector<T*> {
|
||||
SWIG_STD_VECTOR_MINIMUM_INTERNAL(IList, const value_type&, T*)
|
||||
SWIG_STD_VECTOR_EXTRA_OP_EQUALS_EQUALS(T*)
|
||||
// specialization for pointers
|
||||
template<class T> class vector<T *> {
|
||||
SWIG_STD_VECTOR_MINIMUM_INTERNAL(IList, T *const&, T *)
|
||||
SWIG_STD_VECTOR_EXTRA_OP_EQUALS_EQUALS(T *)
|
||||
};
|
||||
template<class T> class vector<const T*> {
|
||||
SWIG_STD_VECTOR_MINIMUM_INTERNAL(IList, const value_type&, const T*)
|
||||
SWIG_STD_VECTOR_EXTRA_OP_EQUALS_EQUALS(const T*)
|
||||
};
|
||||
// bool is a bit different in the C++ standard
|
||||
// bool is specialized in the C++ standard - const_reference in particular
|
||||
template<> class vector<bool> {
|
||||
SWIG_STD_VECTOR_MINIMUM_INTERNAL(IList, bool, bool)
|
||||
SWIG_STD_VECTOR_EXTRA_OP_EQUALS_EQUALS(bool)
|
||||
|
|
|
|||
135
Lib/go/cdata.i
Normal file
135
Lib/go/cdata.i
Normal file
|
|
@ -0,0 +1,135 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* cdata.i
|
||||
*
|
||||
* SWIG library file containing macros for manipulating raw C data as strings.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
%{
|
||||
typedef struct SWIGCDATA {
|
||||
char *data;
|
||||
int len;
|
||||
} SWIGCDATA;
|
||||
%}
|
||||
|
||||
%typemap(gotype) SWIGCDATA %{ []byte %}
|
||||
%typemap(out) SWIGCDATA (swigcdata argp) {
|
||||
argp = _swig_makegobyteslice($1.data, $1.len);
|
||||
$result.data = (char*)argp.data;
|
||||
$result.len = (int)argp.len;
|
||||
}
|
||||
|
||||
/* The makegobyteslice function. */
|
||||
|
||||
%insert(runtime) %{
|
||||
typedef struct {
|
||||
char *data;
|
||||
int len;
|
||||
} swigcdata;
|
||||
|
||||
%}
|
||||
|
||||
#ifndef SWIGGO_GCCGO
|
||||
%insert(runtime) %{
|
||||
extern
|
||||
#ifdef __cplusplus
|
||||
"C"
|
||||
#endif
|
||||
void _swig_gc_makegobyteslice(void *, int);
|
||||
static swigcdata _swig_makegobyteslice(const char *data, int len) {
|
||||
struct {
|
||||
const char *data;
|
||||
int len;
|
||||
swigcdata ret;
|
||||
} a;
|
||||
a.data = data;
|
||||
a.len = len;
|
||||
crosscall2(_swig_gc_makegobyteslice, &a, (int) sizeof a);
|
||||
return a.ret;
|
||||
}
|
||||
%}
|
||||
|
||||
%insert(gc_header) %{
|
||||
typedef struct {
|
||||
byte *data;
|
||||
int32 len;
|
||||
} swigcdata;
|
||||
extern void ·_swig_internal_makegobyteslice(void);
|
||||
#pragma dynexport _swig_gc_makegobyteslice _swig_gc_makegobyteslice
|
||||
void _swig_gc_makegobyteslice(void *a, int32 n) {
|
||||
cgocallback(·_swig_internal_makegobyteslice, a, n);
|
||||
}
|
||||
void ·_swig_allocategobyteslice(byte *data, int32 len, swigcdata ret) {
|
||||
ret.data = mal(len);
|
||||
mcpy(ret.data, data, len);
|
||||
ret.len = len;
|
||||
FLUSH(&ret);
|
||||
}
|
||||
%}
|
||||
|
||||
%insert(go_header) %{
|
||||
type swigcdata struct { data *byte; len int }
|
||||
func _swig_allocategobyteslice(*byte, int) swigcdata
|
||||
func _swig_internal_makegobyteslice(data *byte, len int) swigcdata {
|
||||
return _swig_allocategobyteslice(data, len)
|
||||
}
|
||||
%}
|
||||
|
||||
#else
|
||||
|
||||
%insert(runtime) %{
|
||||
static swigcdata _swig_makegobyteslice(const char *data, int len) {
|
||||
swigcdata ret;
|
||||
ret.data = (char*)__go_alloc(len);
|
||||
memcpy(ret.data, data, len);
|
||||
ret.len = (int)len;
|
||||
return ret;
|
||||
}
|
||||
|
||||
%}
|
||||
|
||||
#endif
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* %cdata(TYPE [, NAME])
|
||||
*
|
||||
* Convert raw C data to a binary string.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
%define %cdata(TYPE,NAME...)
|
||||
|
||||
%insert("header") {
|
||||
#if #NAME == ""
|
||||
static SWIGCDATA cdata_##TYPE(TYPE *ptr, int nelements) {
|
||||
#else
|
||||
static SWIGCDATA cdata_##NAME(TYPE *ptr, int nelements) {
|
||||
#endif
|
||||
SWIGCDATA d;
|
||||
d.data = (char *) ptr;
|
||||
#if #TYPE != "void"
|
||||
d.len = nelements*sizeof(TYPE);
|
||||
#else
|
||||
d.len = nelements;
|
||||
#endif
|
||||
return d;
|
||||
}
|
||||
}
|
||||
|
||||
%typemap(default) int nelements "$1 = 1;"
|
||||
|
||||
#if #NAME == ""
|
||||
SWIGCDATA cdata_##TYPE(TYPE *ptr, int nelements);
|
||||
#else
|
||||
SWIGCDATA cdata_##NAME(TYPE *ptr, int nelements);
|
||||
#endif
|
||||
%enddef
|
||||
|
||||
%typemap(default) int nelements;
|
||||
|
||||
%rename(cdata) ::cdata_void(void *ptr, int nelements);
|
||||
|
||||
%cdata(void);
|
||||
|
||||
/* Memory move function. Due to multi-argument typemaps this appears
|
||||
to be wrapped as
|
||||
void memmove(void *data, const char *s); */
|
||||
void memmove(void *data, char *indata, int inlen);
|
||||
7
Lib/go/exception.i
Normal file
7
Lib/go/exception.i
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
%typemap(throws,noblock=1) (...) {
|
||||
SWIG_exception(SWIG_RuntimeError,"unknown exception");
|
||||
}
|
||||
|
||||
%insert("runtime") %{
|
||||
#define SWIG_exception(code, msg) _swig_gopanic(msg)
|
||||
%}
|
||||
514
Lib/go/go.swg
Normal file
514
Lib/go/go.swg
Normal file
|
|
@ -0,0 +1,514 @@
|
|||
/* ------------------------------------------------------------
|
||||
* go.swg
|
||||
*
|
||||
* Go configuration module.
|
||||
* ------------------------------------------------------------ */
|
||||
|
||||
/* Basic types */
|
||||
|
||||
%typemap(gotype) bool, const bool & "bool"
|
||||
%typemap(gotype) char, const char & "byte"
|
||||
%typemap(gotype) signed char, const signed char & "int8"
|
||||
%typemap(gotype) unsigned char, const unsigned char & "byte"
|
||||
%typemap(gotype) short, const short & "int16"
|
||||
%typemap(gotype) unsigned short, const unsigned short & "uint16"
|
||||
%typemap(gotype) int, const int & "int"
|
||||
%typemap(gotype) unsigned int, const unsigned int & "uint"
|
||||
#if SWIGGO_LONG_TYPE_SIZE == 32
|
||||
%typemap(gotype) long, const long & "int32"
|
||||
%typemap(gotype) unsigned long, const unsigned long & "uint32"
|
||||
#elif SWIGGO_LONG_TYPE_SIZE == 64
|
||||
%typemap(gotype) long, const long & "int64"
|
||||
%typemap(gotype) unsigned long, const unsigned long & "uint64"
|
||||
#else
|
||||
#error "SWIGGO_LONG_TYPE_SIZE not 32 or 64"
|
||||
#endif
|
||||
%typemap(gotype) long long, const long long & "int64"
|
||||
%typemap(gotype) unsigned long long, const unsigned long long & "uint64"
|
||||
%typemap(gotype) float, const float & "float32"
|
||||
%typemap(gotype) double, const double & "float64"
|
||||
|
||||
%typemap(in) bool,
|
||||
char,
|
||||
signed char,
|
||||
unsigned char,
|
||||
short,
|
||||
unsigned short,
|
||||
int,
|
||||
unsigned int,
|
||||
long,
|
||||
unsigned long,
|
||||
long long,
|
||||
unsigned long long,
|
||||
float,
|
||||
double
|
||||
%{ $1 = ($1_ltype)$input; %}
|
||||
|
||||
%typemap(in) const bool &,
|
||||
const char &,
|
||||
const signed char &,
|
||||
const unsigned char &,
|
||||
const short &,
|
||||
const unsigned short &,
|
||||
const int &,
|
||||
const unsigned int &,
|
||||
const long &,
|
||||
const unsigned long &,
|
||||
const long long &,
|
||||
const unsigned long long &,
|
||||
const float &,
|
||||
const double &
|
||||
%{ $1 = ($1_ltype)&$input; %}
|
||||
|
||||
%typemap(out) bool,
|
||||
char,
|
||||
signed char,
|
||||
unsigned char,
|
||||
short,
|
||||
unsigned short,
|
||||
int,
|
||||
unsigned int,
|
||||
long,
|
||||
unsigned long,
|
||||
long long,
|
||||
unsigned long long,
|
||||
float,
|
||||
double
|
||||
%{ $result = $1; %}
|
||||
|
||||
%typemap(out) const bool &,
|
||||
const char &,
|
||||
const signed char &,
|
||||
const unsigned char &,
|
||||
const short &,
|
||||
const unsigned short &,
|
||||
const int &,
|
||||
const unsigned int &,
|
||||
const long &,
|
||||
const unsigned long &,
|
||||
const long long &,
|
||||
const unsigned long long &,
|
||||
const float &,
|
||||
const double &
|
||||
%{ $result = ($*1_ltype)*$1; %}
|
||||
|
||||
%typemap(out) void ""
|
||||
|
||||
%typemap(directorin) bool,
|
||||
char,
|
||||
signed char,
|
||||
unsigned char,
|
||||
short,
|
||||
unsigned short,
|
||||
int,
|
||||
unsigned int,
|
||||
long,
|
||||
unsigned long,
|
||||
long long,
|
||||
unsigned long long,
|
||||
float,
|
||||
double
|
||||
%{ $input = ($1_ltype)$1_name; %}
|
||||
|
||||
%typemap(directorin) const bool &,
|
||||
const char &,
|
||||
const signed char &,
|
||||
const unsigned char &,
|
||||
const short &,
|
||||
const unsigned short &,
|
||||
const int &,
|
||||
const unsigned int &,
|
||||
const long &,
|
||||
const unsigned long &,
|
||||
const long long &,
|
||||
const unsigned long long &,
|
||||
const float &,
|
||||
const double &
|
||||
%{ $input = ($*1_ltype)$1_name; %}
|
||||
|
||||
%typemap(directorout) bool,
|
||||
char,
|
||||
signed char,
|
||||
unsigned char,
|
||||
short,
|
||||
unsigned short,
|
||||
int,
|
||||
unsigned int,
|
||||
long,
|
||||
unsigned long,
|
||||
long long,
|
||||
unsigned long long,
|
||||
float,
|
||||
double
|
||||
%{ $result = ($1_ltype)$input; %}
|
||||
|
||||
%typemap(directorout) const bool &,
|
||||
const char &,
|
||||
const signed char &,
|
||||
const unsigned char &,
|
||||
const short &,
|
||||
const unsigned short &,
|
||||
const int &,
|
||||
const unsigned int &,
|
||||
const long &,
|
||||
const unsigned long &,
|
||||
const long long &,
|
||||
const unsigned long long &,
|
||||
const float &,
|
||||
const double &
|
||||
%{
|
||||
$result = ($1_ltype)_swig_allocate(sizeof($*1_ltype));
|
||||
*$result = *($1_ltype)$input;
|
||||
%}
|
||||
|
||||
/* The size_t type. */
|
||||
|
||||
#if SWIGGO_LONG_TYPE_SIZE == 32
|
||||
%typemap(gotype) size_t, const size_t & %{int%}
|
||||
#else
|
||||
%typemap(gotype) size_t, const size_t & %{int64%}
|
||||
#endif
|
||||
|
||||
%typemap(in) size_t
|
||||
%{ $1 = (size_t)$input; %}
|
||||
|
||||
%typemap(in) const size_t &
|
||||
%{ $1 = ($1_ltype)&$input; %}
|
||||
|
||||
%typemap(out) size_t
|
||||
%{ $result = $1; %}
|
||||
|
||||
%typemap(out) const size_t &
|
||||
%{ $result = ($*1_ltype)*$1; %}
|
||||
|
||||
%typemap(directorin) size_t
|
||||
%{ $input = (size_t)$1_name; %}
|
||||
|
||||
%typemap(directorin) const size_t &
|
||||
%{ $input = ($*1_ltype)$1_name; %}
|
||||
|
||||
%typemap(directorout) size_t
|
||||
%{ $result = ($1_ltype)$input; %}
|
||||
|
||||
%typemap(directorout) const size_t &
|
||||
%{
|
||||
$result = ($1_ltype)_swig_allocate(sizeof($*1_ltype));
|
||||
*$result = *($1_ltype)$input;
|
||||
%}
|
||||
|
||||
/* Member pointers. */
|
||||
|
||||
%typemap(gotype) SWIGTYPE (CLASS::*)
|
||||
%{$gotypename%}
|
||||
|
||||
%typemap(in) SWIGTYPE (CLASS::*)
|
||||
%{ $1 = *($&1_ltype)$input; %}
|
||||
|
||||
%typemap(out) SWIGTYPE (CLASS::*)
|
||||
%{
|
||||
$result = _swig_allocate(sizeof($1_ltype));
|
||||
*($&1_ltype)$result = $1;
|
||||
%}
|
||||
|
||||
%typemap(directorin) SWIGTYPE (CLASS::*)
|
||||
%{ $input = *($&1_ltype)$1_name; %}
|
||||
|
||||
%typemap(directorout) SWIGTYPE (CLASS::*)
|
||||
%{
|
||||
$result = _swig_allocate(sizeof($1_ltype));
|
||||
*($&1_ltype)$result = $input;
|
||||
%}
|
||||
|
||||
/* Pointers. */
|
||||
|
||||
/* We can't translate pointers using a typemap, so that is handled in
|
||||
the C++ code. */
|
||||
%typemap(gotype) SWIGTYPE *
|
||||
%{$gotypename%}
|
||||
|
||||
%typemap(in) SWIGTYPE *
|
||||
%{ $1 = *($&1_ltype)&$input; %}
|
||||
|
||||
%typemap(out) SWIGTYPE *
|
||||
%{ *($&1_ltype)&$result = $1; %}
|
||||
|
||||
%typemap(directorin) SWIGTYPE *
|
||||
%{ $input = ($1_ltype)$1_name; %}
|
||||
|
||||
%typemap(directorout) SWIGTYPE *
|
||||
%{ $result = ($1_ltype)$input; %}
|
||||
|
||||
%apply SWIGTYPE * { SWIGTYPE *const }
|
||||
|
||||
/* Pointer references. */
|
||||
|
||||
%typemap(gotype) SWIGTYPE *const&
|
||||
%{$gotypename%}
|
||||
|
||||
%typemap(in) SWIGTYPE *const& ($*1_ltype temp = 0)
|
||||
%{
|
||||
temp = *($1_ltype)&$input;
|
||||
$1 = ($1_ltype)&temp;
|
||||
%}
|
||||
|
||||
%typemap(out) SWIGTYPE *const&
|
||||
%{ *($1_ltype)&$result = *$1; %}
|
||||
|
||||
/* Function pointers are translated by the code in go.cxx into
|
||||
_swig_fnptr. Member pointers are translated to _swig_memberptr. */
|
||||
|
||||
%insert(go_header) %{
|
||||
type _swig_fnptr *byte
|
||||
type _swig_memberptr *byte
|
||||
%}
|
||||
|
||||
/* References. */
|
||||
|
||||
/* Converting a C++ reference to Go has to be handled in the C++
|
||||
code. */
|
||||
%typemap(gotype) SWIGTYPE &
|
||||
%{$gotypename%}
|
||||
|
||||
%typemap(in) SWIGTYPE &
|
||||
%{ $1 = *($&1_ltype)&$input; %}
|
||||
|
||||
%typemap(out) SWIGTYPE &
|
||||
%{ *($&1_ltype)&$result = $1; %}
|
||||
|
||||
%typemap(directorin) SWIGTYPE &
|
||||
%{ $input = ($1_ltype)&$1_name; %}
|
||||
|
||||
%typemap(directorout) SWIGTYPE &
|
||||
%{ *($&1_ltype)&$result = $input; %}
|
||||
|
||||
/* C arrays turn into Go pointers. If we know the length we can use a
|
||||
slice. */
|
||||
|
||||
%typemap(gotype) SWIGTYPE []
|
||||
%{$gotypename%}
|
||||
|
||||
%typemap(in) SWIGTYPE []
|
||||
%{ $1 = *($&1_ltype)&$input; %}
|
||||
|
||||
%typemap(out) SWIGTYPE []
|
||||
%{ *($&1_ltype)&$result = $1; %}
|
||||
|
||||
%typemap(directorin) SWIGTYPE []
|
||||
%{ $input = *($1_ltype)&$1_name; %}
|
||||
|
||||
%typemap(directorout) SWIGTYPE []
|
||||
%{ *($&1_ltype)&$result = $input; %}
|
||||
|
||||
/* Strings. */
|
||||
|
||||
%typemap(gotype)
|
||||
char *, char *&, char[ANY], char[],
|
||||
signed char *, signed char *&, signed char[ANY], signed char[],
|
||||
unsigned char *, unsigned char *&, unsigned char[ANY], unsigned char[]
|
||||
"string"
|
||||
|
||||
/* Needed to avoid confusion with the way the go module handles
|
||||
references. */
|
||||
%typemap(gotype) char&, unsigned char& "*byte"
|
||||
%typemap(gotype) signed char& "*int8"
|
||||
|
||||
%typemap(in)
|
||||
char *, char[ANY], char[],
|
||||
signed char *, signed char[ANY], signed char[],
|
||||
unsigned char *, unsigned char[ANY], unsigned char[]
|
||||
%{ $1 = ($1_ltype)$input.p; %}
|
||||
|
||||
%typemap(in) char *&, signed char *&, unsigned char *&
|
||||
%{ $1 = ($1_ltype)$input.p; %}
|
||||
|
||||
%typemap(out)
|
||||
char *, char *&, char[ANY], char[],
|
||||
signed char *, signed char *&, signed char[ANY], signed char[],
|
||||
unsigned char *, unsigned char *&, unsigned char[ANY], unsigned char[]
|
||||
%{ $result = _swig_makegostring((char*)$1, $1 ? strlen((char*)$1) : 0); %}
|
||||
|
||||
%typemap(directorin)
|
||||
char *, char *&, char[ANY], char[],
|
||||
signed char *, signed char *&, signed char[ANY], signed char[],
|
||||
unsigned char *, unsigned char *&, unsigned char[ANY], unsigned char[]
|
||||
%{
|
||||
$input = _swig_makegostring((char*)$1_name, $1_name ? strlen((char*)$1_name) : 0);
|
||||
%}
|
||||
|
||||
%typemap(directorout)
|
||||
char *, char *&, char[ANY], char[],
|
||||
signed char *, signed char *&, signed char[ANY], signed char[],
|
||||
unsigned char *, unsigned char *&, unsigned char[ANY], unsigned char[]
|
||||
%{ $result = ($1_ltype)$input.p; %}
|
||||
|
||||
/* Enums. We can't do the right thing for enums in typemap(gotype) so
|
||||
we deliberately don't define them. The right thing would be to
|
||||
capitalize the name. This is instead done in go.cxx. */
|
||||
|
||||
%typemap(gotype) enum SWIGTYPE
|
||||
%{$gotypename%}
|
||||
|
||||
%typemap(in) enum SWIGTYPE
|
||||
%{ $1 = ($1_ltype)$input; %}
|
||||
|
||||
%typemap(out) enum SWIGTYPE
|
||||
%{ $result = $1; %}
|
||||
|
||||
%typemap(directorin) enum SWIGTYPE
|
||||
%{ $input = ($1_ltype)$1_name; %}
|
||||
|
||||
%typemap(directorout) enum SWIGTYPE
|
||||
%{ $result = ($1_ltype)$input; %}
|
||||
|
||||
/* Arbitrary type. This is a type passed by value in the C/C++ code.
|
||||
We convert it to a pointer for the Go code. Note that all basic
|
||||
types are explicitly handled above. */
|
||||
|
||||
%typemap(gotype) SWIGTYPE
|
||||
%{$gotypename%}
|
||||
|
||||
%typemap(in) SWIGTYPE ($&1_type argp)
|
||||
%{
|
||||
argp = ($&1_ltype)$input;
|
||||
if (argp == NULL) {
|
||||
_swig_gopanic("Attempt to dereference null $1_type");
|
||||
}
|
||||
$1 = ($1_ltype)*argp;
|
||||
%}
|
||||
|
||||
%typemap(out) SWIGTYPE
|
||||
#ifdef __cplusplus
|
||||
%{ *($&1_ltype*)&$result = new $1_ltype($1); %}
|
||||
#else
|
||||
{
|
||||
$&1_ltype $1ptr = ($&1_ltype)malloc(sizeof($1_ltype));
|
||||
memmove($1ptr, &$1, sizeof($1_type));
|
||||
*($&1_ltype*)&$result = $1ptr;
|
||||
}
|
||||
#endif
|
||||
|
||||
%typemap(directorin) SWIGTYPE
|
||||
%{ $input = ($&1_ltype)&$1_name; %}
|
||||
|
||||
%typemap(directorout) SWIGTYPE
|
||||
%{ $result = *($&1_ltype)$input; %}
|
||||
|
||||
/* Exception handling */
|
||||
|
||||
%typemap(throws) char *
|
||||
%{ _swig_gopanic($1); %}
|
||||
|
||||
%typemap(throws) SWIGTYPE, SWIGTYPE &, SWIGTYPE *, SWIGTYPE [], SWIGTYPE [ANY]
|
||||
%{
|
||||
(void)$1;
|
||||
_swig_gopanic("C++ $1_type exception thrown");
|
||||
%}
|
||||
|
||||
/* Typecheck typemaps. The purpose of these is merely to issue a
|
||||
warning for overloaded C++ functions * that cannot be overloaded in
|
||||
Go as more than one C++ type maps to a single Go type. */
|
||||
|
||||
%typecheck(SWIG_TYPECHECK_BOOL) /* Go bool */
|
||||
bool,
|
||||
const bool &
|
||||
""
|
||||
|
||||
%typecheck(SWIG_TYPECHECK_CHAR) /* Go byte */
|
||||
char,
|
||||
const char &,
|
||||
unsigned char,
|
||||
const unsigned char &
|
||||
""
|
||||
|
||||
%typecheck(SWIG_TYPECHECK_INT8) /* Go int8 */
|
||||
signed char,
|
||||
const signed char &
|
||||
""
|
||||
|
||||
%typecheck(SWIG_TYPECHECK_INT16) /* Go int16 */
|
||||
short,
|
||||
const short &
|
||||
""
|
||||
|
||||
%typecheck(SWIG_TYPECHECK_INT16) /* Go uint16 */
|
||||
unsigned short,
|
||||
const unsigned short &
|
||||
""
|
||||
|
||||
%typecheck(SWIG_TYPECHECK_INT32) /* Go int */
|
||||
int,
|
||||
const int &
|
||||
""
|
||||
|
||||
%typecheck(SWIG_TYPECHECK_INT32) /* Go uint */
|
||||
unsigned int,
|
||||
const unsigned int &
|
||||
""
|
||||
|
||||
#if SWIGGO_LONG_TYPE_SIZE == 32
|
||||
%typecheck(SWIG_TYPECHECK_INT32) /* Go int32 */
|
||||
long,
|
||||
const long &
|
||||
""
|
||||
|
||||
%typecheck(SWIG_TYPECHECK_INT32) /* Go uint32 */
|
||||
unsigned long,
|
||||
const unsigned long &
|
||||
""
|
||||
#endif
|
||||
|
||||
%typecheck(SWIG_TYPECHECK_INT64) /* Go int64 */
|
||||
#if SWIGGO_LONG_TYPE_SIZE == 64
|
||||
long,
|
||||
const long &,
|
||||
#endif
|
||||
long long,
|
||||
const long long &
|
||||
""
|
||||
|
||||
%typecheck(SWIG_TYPECHECK_INT64) /* Go uint64 */
|
||||
#if SWIGGO_LONG_TYPE_SIZE == 64
|
||||
unsigned long,
|
||||
const unsigned long &,
|
||||
#endif
|
||||
unsigned long long,
|
||||
const unsigned long long &
|
||||
""
|
||||
|
||||
%typecheck(SWIG_TYPECHECK_FLOAT) /* Go float32 */
|
||||
float,
|
||||
const float &
|
||||
""
|
||||
|
||||
%typecheck(SWIG_TYPECHECK_DOUBLE) /* Go float64 */
|
||||
double,
|
||||
const double &
|
||||
""
|
||||
|
||||
%typecheck(SWIG_TYPECHECK_STRING) /* Go string */
|
||||
char *,
|
||||
char *&,
|
||||
char[ANY],
|
||||
char [],
|
||||
signed char *,
|
||||
signed char *&,
|
||||
signed char[ANY],
|
||||
signed char [],
|
||||
unsigned char *,
|
||||
unsigned char *&,
|
||||
unsigned char[ANY],
|
||||
unsigned char []
|
||||
""
|
||||
|
||||
%typecheck(SWIG_TYPECHECK_POINTER)
|
||||
SWIGTYPE,
|
||||
SWIGTYPE *,
|
||||
SWIGTYPE &,
|
||||
SWIGTYPE *const&,
|
||||
SWIGTYPE [],
|
||||
SWIGTYPE (CLASS::*)
|
||||
""
|
||||
/* Go keywords. */
|
||||
%include <gokw.swg>
|
||||
|
||||
%include <goruntime.swg>
|
||||
33
Lib/go/gokw.swg
Normal file
33
Lib/go/gokw.swg
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
/* Rename keywords. */
|
||||
|
||||
#define GOKW(x) %keywordwarn("'" `x` "' is a Go keyword, renaming to 'X"`x`"'",rename="X%s") `x`
|
||||
#define GOBN(x) %builtinwarn("'" `x` "' conflicts with a built-in name in Go") "::"`x`
|
||||
|
||||
GOKW(break);
|
||||
GOKW(case);
|
||||
GOKW(chan);
|
||||
GOKW(const);
|
||||
GOKW(continue);
|
||||
GOKW(default);
|
||||
GOKW(defer);
|
||||
GOKW(else);
|
||||
GOKW(fallthrough);
|
||||
GOKW(for);
|
||||
GOKW(func);
|
||||
GOKW(go);
|
||||
GOKW(goto);
|
||||
GOKW(if);
|
||||
GOKW(import);
|
||||
GOKW(interface);
|
||||
GOKW(package);
|
||||
GOKW(range);
|
||||
GOKW(return);
|
||||
GOKW(select);
|
||||
GOKW(struct);
|
||||
GOKW(switch);
|
||||
GOKW(type);
|
||||
GOKW(var);
|
||||
|
||||
GOBN(map);
|
||||
|
||||
#undef GOKW
|
||||
198
Lib/go/goruntime.swg
Normal file
198
Lib/go/goruntime.swg
Normal file
|
|
@ -0,0 +1,198 @@
|
|||
/* ------------------------------------------------------------
|
||||
* goruntime.swg
|
||||
*
|
||||
* Go runtime code for the various generated files.
|
||||
* ------------------------------------------------------------ */
|
||||
|
||||
%insert(runtime) %{
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
typedef struct { char *p; int n; } _gostring_;
|
||||
typedef struct { void* array; unsigned int len; unsigned int cap; } _goslice_;
|
||||
|
||||
%}
|
||||
|
||||
#ifndef SWIGGO_GCCGO
|
||||
/* Boilerplate for C/C++ code when using 6g/8g. This code is compiled
|
||||
with gcc. */
|
||||
%insert(runtime) %{
|
||||
|
||||
#define swiggo_size_assert_eq(x, y, name) typedef char name[(x-y)*(x-y)*-2+1];
|
||||
#define swiggo_size_assert(t, n) swiggo_size_assert_eq(sizeof(t), n, swiggo_sizeof_##t##_is_not_##n)
|
||||
|
||||
swiggo_size_assert(char, 1)
|
||||
swiggo_size_assert(short, 2)
|
||||
swiggo_size_assert(int, 4)
|
||||
typedef long long swiggo_long_long;
|
||||
swiggo_size_assert(swiggo_long_long, 8)
|
||||
swiggo_size_assert(float, 4)
|
||||
swiggo_size_assert(double, 8)
|
||||
|
||||
extern
|
||||
#ifdef __cplusplus
|
||||
"C"
|
||||
#endif
|
||||
void crosscall2(void (*fn)(void *, int), void *, int);
|
||||
|
||||
extern
|
||||
#ifdef __cplusplus
|
||||
"C"
|
||||
#endif
|
||||
void _swig_gc_allocate(void *, int);
|
||||
static void *_swig_allocate(int len) {
|
||||
struct {
|
||||
int len;
|
||||
void *ret;
|
||||
} a;
|
||||
a.len = len;
|
||||
crosscall2(_swig_gc_allocate, &a, (int) sizeof a);
|
||||
return a.ret;
|
||||
}
|
||||
|
||||
extern
|
||||
#ifdef __cplusplus
|
||||
"C"
|
||||
#endif
|
||||
void _swig_gc_makegostring(void *, int);
|
||||
static _gostring_ _swig_makegostring(const char *p, size_t l) {
|
||||
struct {
|
||||
const char *p;
|
||||
int l;
|
||||
_gostring_ ret;
|
||||
} a;
|
||||
a.p = p;
|
||||
a.l = l;
|
||||
crosscall2(_swig_gc_makegostring, &a, (int) sizeof a);
|
||||
return a.ret;
|
||||
}
|
||||
|
||||
extern
|
||||
#ifdef __cplusplus
|
||||
"C"
|
||||
#endif
|
||||
void _swig_gc_gopanic(void *, int);
|
||||
static void _swig_gopanic(const char *p) {
|
||||
struct {
|
||||
const char *p;
|
||||
int l;
|
||||
} a;
|
||||
a.p = p;
|
||||
a.l = strlen(p);
|
||||
crosscall2(_swig_gc_gopanic, &a, (int) sizeof a);
|
||||
}
|
||||
|
||||
%}
|
||||
|
||||
/* Boilerplate for C code when using 6g/8g. This code is compiled
|
||||
with 6c/8c. */
|
||||
%insert(gc_header) %{
|
||||
#include "runtime.h"
|
||||
#include "cgocall.h"
|
||||
|
||||
#pragma dynimport initcgo initcgo "libcgo.so"
|
||||
#pragma dynimport libcgo_thread_start libcgo_thread_start "libcgo.so"
|
||||
#pragma dynimport libcgo_set_scheduler libcgo_set_scheduler "libcgo.so"
|
||||
|
||||
#ifdef _64BIT
|
||||
#define SWIG_PARM_SIZE 8
|
||||
#else
|
||||
#define SWIG_PARM_SIZE 4
|
||||
#endif
|
||||
%}
|
||||
|
||||
/* 6g/8g C boilerplate that is only needed once in a program. This
|
||||
only gets added to the file if nothing is imported. */
|
||||
%insert(gc_once) %{
|
||||
|
||||
extern void ·_swig_internal_allocate(void);
|
||||
#pragma dynexport _swig_gc_allocate _swig_gc_allocate
|
||||
void _swig_gc_allocate(void *a, int32 n) {
|
||||
cgocallback(·_swig_internal_allocate, a, n);
|
||||
}
|
||||
|
||||
void ·_swig_allocatememory(int32 len, byte *ret) {
|
||||
ret = mal(len);
|
||||
FLUSH(&ret);
|
||||
}
|
||||
|
||||
extern void ·_swig_internal_makegostring(void);
|
||||
#pragma dynexport _swig_gc_makegostring _swig_gc_makegostring
|
||||
void _swig_gc_makegostring(void *a, int32 n) {
|
||||
cgocallback(·_swig_internal_makegostring, a, n);
|
||||
}
|
||||
|
||||
void ·_swig_allocatestring(byte *p, int32 l, String ret) {
|
||||
ret.str = mal(l+1);
|
||||
mcpy(ret.str, p, l);
|
||||
ret.len = l;
|
||||
FLUSH(&ret);
|
||||
}
|
||||
|
||||
extern void ·_swig_internal_gopanic(void);
|
||||
#pragma dynexport _swig_gc_gopanic _swig_gc_gopanic
|
||||
void _swig_gc_gopanic(void *a, int32 n) {
|
||||
cgocallback(·_swig_internal_gopanic, a, n);
|
||||
}
|
||||
|
||||
%}
|
||||
|
||||
/* Go code that is only needed once in a program. This is only added
|
||||
to the file if nothing is imported. */
|
||||
%insert(go_once) %{
|
||||
func _swig_allocatememory(int) *byte
|
||||
func _swig_internal_allocate(len int) *byte {
|
||||
return _swig_allocatememory(len)
|
||||
}
|
||||
|
||||
func _swig_allocatestring(*byte, int) string
|
||||
func _swig_internal_makegostring(p *byte, l int) string {
|
||||
return _swig_allocatestring(p, l)
|
||||
}
|
||||
|
||||
func _swig_internal_gopanic(p *byte, l int) {
|
||||
panic(_swig_allocatestring(p, l))
|
||||
}
|
||||
%}
|
||||
|
||||
#else
|
||||
|
||||
/* Boilerplate for C/C++ code when using gccgo. */
|
||||
%insert(runtime) %{
|
||||
#define SWIGGO_GCCGO
|
||||
|
||||
extern
|
||||
#ifdef __cplusplus
|
||||
"C"
|
||||
#endif
|
||||
void *__go_alloc (size_t);
|
||||
|
||||
static void *_swig_allocate(int len) {
|
||||
return __go_alloc(len);
|
||||
}
|
||||
|
||||
static _gostring_ _swig_makegostring(const char *p, size_t l) {
|
||||
_gostring_ ret;
|
||||
ret.p = (char*)__go_alloc(l);
|
||||
memcpy(ret.p, p, l);
|
||||
ret.n = l;
|
||||
return ret;
|
||||
}
|
||||
|
||||
extern
|
||||
#ifdef __cplusplus
|
||||
"C"
|
||||
#endif
|
||||
void __go_panic_msg(const char *);
|
||||
#define _swig_gopanic __go_panic_msg
|
||||
|
||||
%}
|
||||
|
||||
#endif
|
||||
|
||||
%insert(runtime) %{
|
||||
#define SWIG_contract_assert(expr, msg) \
|
||||
if (!(expr)) { _swig_gopanic(msg); } else
|
||||
%}
|
||||
|
||||
4
Lib/go/std_common.i
Normal file
4
Lib/go/std_common.i
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
%include <std_except.i>
|
||||
|
||||
%apply size_t { std::size_t };
|
||||
%apply const size_t& { const std::size_t& };
|
||||
1
Lib/go/std_deque.i
Normal file
1
Lib/go/std_deque.i
Normal file
|
|
@ -0,0 +1 @@
|
|||
%include <std/_std_deque.i>
|
||||
29
Lib/go/std_except.i
Normal file
29
Lib/go/std_except.i
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* std_except.i
|
||||
*
|
||||
* Typemaps used by the STL wrappers that throw exceptions.
|
||||
* These typemaps are used when methods are declared with an STL exception specification, such as
|
||||
* size_t at() const throw (std::out_of_range);
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
%{
|
||||
#include <stdexcept>
|
||||
%}
|
||||
|
||||
namespace std
|
||||
{
|
||||
%ignore exception;
|
||||
struct exception {};
|
||||
}
|
||||
|
||||
%typemap(throws) std::bad_exception %{_swig_gopanic($1.what());%}
|
||||
%typemap(throws) std::domain_error %{_swig_gopanic($1.what());%}
|
||||
%typemap(throws) std::exception %{_swig_gopanic($1.what());%}
|
||||
%typemap(throws) std::invalid_argument %{_swig_gopanic($1.what());%}
|
||||
%typemap(throws) std::length_error %{_swig_gopanic($1.what());%}
|
||||
%typemap(throws) std::logic_error %{_swig_gopanic($1.what());%}
|
||||
%typemap(throws) std::out_of_range %{_swig_gopanic($1.what());%}
|
||||
%typemap(throws) std::overflow_error %{_swig_gopanic($1.what());%}
|
||||
%typemap(throws) std::range_error %{_swig_gopanic($1.what());%}
|
||||
%typemap(throws) std::runtime_error %{_swig_gopanic($1.what());%}
|
||||
%typemap(throws) std::underflow_error %{_swig_gopanic($1.what());%}
|
||||
60
Lib/go/std_map.i
Normal file
60
Lib/go/std_map.i
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* std_map.i
|
||||
*
|
||||
* SWIG typemaps for std::map
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
%include <std_common.i>
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// std::map
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
%{
|
||||
#include <map>
|
||||
#include <algorithm>
|
||||
#include <stdexcept>
|
||||
%}
|
||||
|
||||
// exported class
|
||||
|
||||
namespace std {
|
||||
|
||||
template<class K, class T> class map {
|
||||
// add typemaps here
|
||||
public:
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef K key_type;
|
||||
typedef T mapped_type;
|
||||
map();
|
||||
map(const map<K,T> &);
|
||||
|
||||
unsigned int size() const;
|
||||
bool empty() const;
|
||||
void clear();
|
||||
%extend {
|
||||
const T& get(const K& key) throw (std::out_of_range) {
|
||||
std::map<K,T >::iterator i = self->find(key);
|
||||
if (i != self->end())
|
||||
return i->second;
|
||||
else
|
||||
throw std::out_of_range("key not found");
|
||||
}
|
||||
void set(const K& key, const T& x) {
|
||||
(*self)[key] = x;
|
||||
}
|
||||
void del(const K& key) throw (std::out_of_range) {
|
||||
std::map<K,T >::iterator i = self->find(key);
|
||||
if (i != self->end())
|
||||
self->erase(i);
|
||||
else
|
||||
throw std::out_of_range("key not found");
|
||||
}
|
||||
bool has_key(const K& key) {
|
||||
std::map<K,T >::iterator i = self->find(key);
|
||||
return i != self->end();
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
34
Lib/go/std_pair.i
Normal file
34
Lib/go/std_pair.i
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* std_pair.i
|
||||
*
|
||||
* SWIG typemaps for std::pair
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
%include <std_common.i>
|
||||
%include <exception.i>
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// std::pair
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
%{
|
||||
#include <utility>
|
||||
%}
|
||||
|
||||
namespace std {
|
||||
|
||||
template<class T, class U> struct pair {
|
||||
|
||||
pair();
|
||||
pair(T first, U second);
|
||||
pair(const pair& p);
|
||||
|
||||
template <class U1, class U2> pair(const pair<U1, U2> &p);
|
||||
|
||||
T first;
|
||||
U second;
|
||||
};
|
||||
|
||||
// add specializations here
|
||||
|
||||
}
|
||||
55
Lib/go/std_string.i
Normal file
55
Lib/go/std_string.i
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* std_string.i
|
||||
*
|
||||
* Typemaps for std::string and const std::string&
|
||||
* These are mapped to a Go string and are passed around by value.
|
||||
*
|
||||
* To use non-const std::string references use the following %apply. Note
|
||||
* that they are passed by value.
|
||||
* %apply const std::string & {std::string &};
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
%{
|
||||
#include <string>
|
||||
%}
|
||||
|
||||
namespace std {
|
||||
|
||||
%naturalvar string;
|
||||
|
||||
class string;
|
||||
|
||||
%typemap(gotype) string, const string & "string"
|
||||
|
||||
%typemap(in) string
|
||||
%{ $1.assign($input.p, $input.n); %}
|
||||
|
||||
%typemap(directorout) string
|
||||
%{ $result.assign($input.p, $input.n); %}
|
||||
|
||||
%typemap(out) string
|
||||
%{ $result = _swig_makegostring($1.data(), $1.length()); %}
|
||||
|
||||
%typemap(directorin) string
|
||||
%{ $input = _swig_makegostring($1_name.data(), $1_name.length()); %}
|
||||
|
||||
%typemap(in) const string &
|
||||
%{
|
||||
std::string $1_str($input.p, $input.n);
|
||||
$1 = &$1_str;
|
||||
%}
|
||||
|
||||
%typemap(directorout,warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const string &
|
||||
%{
|
||||
static std::string $1_str;
|
||||
$1_str.assign($input.p, $input.n);
|
||||
$result = &$1_str;
|
||||
%}
|
||||
|
||||
%typemap(out) const string &
|
||||
%{ $result = _swig_makegostring((*$1).data(), (*$1).length()); %}
|
||||
|
||||
%typemap(directorin) const string &
|
||||
%{ $input = _swig_makegostring($1_name.data(), $1_name.length()); %}
|
||||
|
||||
}
|
||||
78
Lib/go/std_vector.i
Normal file
78
Lib/go/std_vector.i
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* std_vector.i
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
%{
|
||||
#include <vector>
|
||||
#include <stdexcept>
|
||||
%}
|
||||
|
||||
namespace std {
|
||||
|
||||
template<class T> class vector {
|
||||
public:
|
||||
typedef size_t size_type;
|
||||
typedef T value_type;
|
||||
typedef const value_type& const_reference;
|
||||
vector();
|
||||
vector(size_type n);
|
||||
size_type size() const;
|
||||
size_type capacity() const;
|
||||
void reserve(size_type n);
|
||||
%rename(isEmpty) empty;
|
||||
bool empty() const;
|
||||
void clear();
|
||||
%rename(add) push_back;
|
||||
void push_back(const value_type& x);
|
||||
%extend {
|
||||
const_reference get(int i) throw (std::out_of_range) {
|
||||
int size = int(self->size());
|
||||
if (i>=0 && i<size)
|
||||
return (*self)[i];
|
||||
else
|
||||
throw std::out_of_range("vector index out of range");
|
||||
}
|
||||
void set(int i, const value_type& val) throw (std::out_of_range) {
|
||||
int size = int(self->size());
|
||||
if (i>=0 && i<size)
|
||||
(*self)[i] = val;
|
||||
else
|
||||
throw std::out_of_range("vector index out of range");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// bool specialization
|
||||
template<> class vector<bool> {
|
||||
public:
|
||||
typedef size_t size_type;
|
||||
typedef bool value_type;
|
||||
typedef bool const_reference;
|
||||
vector();
|
||||
vector(size_type n);
|
||||
size_type size() const;
|
||||
size_type capacity() const;
|
||||
void reserve(size_type n);
|
||||
%rename(isEmpty) empty;
|
||||
bool empty() const;
|
||||
void clear();
|
||||
%rename(add) push_back;
|
||||
void push_back(const value_type& x);
|
||||
%extend {
|
||||
const_reference get(int i) throw (std::out_of_range) {
|
||||
int size = int(self->size());
|
||||
if (i>=0 && i<size)
|
||||
return (*self)[i];
|
||||
else
|
||||
throw std::out_of_range("vector index out of range");
|
||||
}
|
||||
void set(int i, const value_type& val) throw (std::out_of_range) {
|
||||
int size = int(self->size());
|
||||
if (i>=0 && i<size)
|
||||
(*self)[i] = val;
|
||||
else
|
||||
throw std::out_of_range("vector index out of range");
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
9
Lib/go/stl.i
Normal file
9
Lib/go/stl.i
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* stl.i
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
%include <std_common.i>
|
||||
%include <std_string.i>
|
||||
%include <std_vector.i>
|
||||
%include <std_map.i>
|
||||
%include <std_pair.i>
|
||||
335
Lib/go/typemaps.i
Normal file
335
Lib/go/typemaps.i
Normal file
|
|
@ -0,0 +1,335 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* typemaps.i
|
||||
*
|
||||
* Pointer and reference handling typemap library
|
||||
*
|
||||
* These mappings provide support for input/output arguments and common
|
||||
* uses for C/C++ pointers and C++ references.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
/*
|
||||
INPUT typemaps
|
||||
--------------
|
||||
|
||||
These typemaps remap a C pointer or C++ reference to be an "INPUT" value which is
|
||||
passed by value instead of reference.
|
||||
|
||||
The following typemaps can be applied to turn a pointer or reference into a simple
|
||||
input value. That is, instead of passing a pointer or reference to an object,
|
||||
you would use a real value instead.
|
||||
|
||||
bool *INPUT, bool &INPUT
|
||||
signed char *INPUT, signed char &INPUT
|
||||
unsigned char *INPUT, unsigned char &INPUT
|
||||
short *INPUT, short &INPUT
|
||||
unsigned short *INPUT, unsigned short &INPUT
|
||||
int *INPUT, int &INPUT
|
||||
unsigned int *INPUT, unsigned int &INPUT
|
||||
long *INPUT, long &INPUT
|
||||
unsigned long *INPUT, unsigned long &INPUT
|
||||
long long *INPUT, long long &INPUT
|
||||
unsigned long long *INPUT, unsigned long long &INPUT
|
||||
float *INPUT, float &INPUT
|
||||
double *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);
|
||||
|
||||
In Go you could then use it like this:
|
||||
answer := modulename.Fadd(10.0, 20.0)
|
||||
|
||||
There are no char *INPUT typemaps, however you can apply the signed
|
||||
char * typemaps instead:
|
||||
%include <typemaps.i>
|
||||
%apply signed char *INPUT {char *input};
|
||||
void f(char *input);
|
||||
*/
|
||||
|
||||
%define INPUT_TYPEMAP(TYPE, GOTYPE)
|
||||
%typemap(gotype) TYPE *INPUT, TYPE &INPUT "GOTYPE"
|
||||
|
||||
%typemap(in) TYPE *INPUT
|
||||
%{ $1 = ($1_ltype)&$input; %}
|
||||
|
||||
%typemap(in) TYPE &INPUT
|
||||
%{ $1 = ($1_ltype)$input; %}
|
||||
|
||||
%typemap(freearg) TYPE *INPUT, TYPE &INPUT ""
|
||||
|
||||
%typemap(directorout) TYPE *INPUT
|
||||
%{ $result = ($1_ltype)&$input; %}
|
||||
|
||||
%typemap(directorout) TYPE &INPUT
|
||||
%{ $result = ($1_ltype)$input; %}
|
||||
|
||||
%typemap(directorin) TYPE &INPUT
|
||||
%{ $1 = ($input_ltype)&$input; %}
|
||||
|
||||
// %typemap(typecheck) TYPE *INPUT = TYPE;
|
||||
// %typemap(typecheck) TYPE &INPUT = TYPE;
|
||||
%enddef
|
||||
|
||||
INPUT_TYPEMAP(bool, bool);
|
||||
INPUT_TYPEMAP(signed char, int8);
|
||||
INPUT_TYPEMAP(char, byte);
|
||||
INPUT_TYPEMAP(unsigned char, byte);
|
||||
INPUT_TYPEMAP(short, int16);
|
||||
INPUT_TYPEMAP(unsigned short, uint16);
|
||||
INPUT_TYPEMAP(int, int);
|
||||
INPUT_TYPEMAP(unsigned int, uint);
|
||||
INPUT_TYPEMAP(long, int64);
|
||||
INPUT_TYPEMAP(unsigned long, uint64);
|
||||
INPUT_TYPEMAP(long long, int64);
|
||||
INPUT_TYPEMAP(unsigned long long, uint64);
|
||||
INPUT_TYPEMAP(float, float);
|
||||
INPUT_TYPEMAP(double, float64);
|
||||
|
||||
#undef INPUT_TYPEMAP
|
||||
|
||||
// OUTPUT typemaps. These typemaps are used for parameters that
|
||||
// are output only. An array replaces the c pointer or reference parameter.
|
||||
// The output value is returned in this array passed in.
|
||||
|
||||
/*
|
||||
OUTPUT typemaps
|
||||
---------------
|
||||
|
||||
The following typemaps can be applied to turn a pointer or reference
|
||||
into an "output" value. When calling a function, no input value would
|
||||
be given for a parameter, but an output value would be returned. This
|
||||
works by a Go slice being passed as a parameter where a c pointer or
|
||||
reference is required. As with any Go function, the array is passed
|
||||
by reference so that any modifications to the array will be picked up
|
||||
in the calling function. Note that the array passed in MUST have at
|
||||
least one element, but as the c function does not require any input,
|
||||
the value can be set to anything.
|
||||
|
||||
bool *OUTPUT, bool &OUTPUT
|
||||
signed char *OUTPUT, signed char &OUTPUT
|
||||
unsigned char *OUTPUT, unsigned char &OUTPUT
|
||||
short *OUTPUT, short &OUTPUT
|
||||
unsigned short *OUTPUT, unsigned short &OUTPUT
|
||||
int *OUTPUT, int &OUTPUT
|
||||
unsigned int *OUTPUT, unsigned int &OUTPUT
|
||||
long *OUTPUT, long &OUTPUT
|
||||
unsigned long *OUTPUT, unsigned long &OUTPUT
|
||||
long long *OUTPUT, long long &OUTPUT
|
||||
unsigned long long *OUTPUT, unsigned long long &OUTPUT
|
||||
float *OUTPUT, float &OUTPUT
|
||||
double *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 Go output of the function would be the function return value and the
|
||||
value in the single element array. In Go you would use it like this:
|
||||
|
||||
ptr := []float64{0.0}
|
||||
fraction := modulename.Modf(5.0,ptr)
|
||||
|
||||
There are no char *OUTPUT typemaps, however you can apply the signed
|
||||
char * typemaps instead:
|
||||
%include <typemaps.i>
|
||||
%apply signed char *OUTPUT {char *output};
|
||||
void f(char *output);
|
||||
*/
|
||||
|
||||
%define OUTPUT_TYPEMAP(TYPE, GOTYPE)
|
||||
%typemap(gotype) TYPE *OUTPUT, TYPE &OUTPUT %{[]GOTYPE%}
|
||||
|
||||
%typemap(in) TYPE *OUTPUT($*1_ltype temp)
|
||||
{
|
||||
if ($input.len == 0) {
|
||||
_swig_gopanic("array must contain at least 1 element");
|
||||
}
|
||||
$1 = &temp;
|
||||
}
|
||||
|
||||
%typemap(in) TYPE &OUTPUT($*1_ltype temp)
|
||||
{
|
||||
if ($input->len == 0) {
|
||||
_swig_gopanic("array must contain at least 1 element");
|
||||
}
|
||||
$1 = &temp;
|
||||
}
|
||||
|
||||
%typemap(freearg) TYPE *OUTPUT, TYPE &OUTPUT ""
|
||||
|
||||
%typemap(argout) TYPE *OUTPUT
|
||||
{
|
||||
TYPE* a = (TYPE *) $input.array;
|
||||
a[0] = temp$argnum;
|
||||
}
|
||||
|
||||
%typemap(argout) TYPE &OUTPUT
|
||||
{
|
||||
TYPE* a = (TYPE *) $input->array;
|
||||
a[0] = temp$argnum;
|
||||
}
|
||||
|
||||
%typemap(directorout,warning="Need to provide TYPE *OUTPUT directorout typemap") TYPE *OUTPUT, TYPE &OUTPUT {
|
||||
}
|
||||
|
||||
%typemap(directorin) TYPE &OUTPUT
|
||||
%{ *(($&1_ltype) $input = &$1; %}
|
||||
|
||||
%typemap(directorin,warning="Need to provide TYPE *OUTPUT directorin typemap, TYPE array length is unknown") TYPE *OUTPUT
|
||||
{
|
||||
}
|
||||
|
||||
%enddef
|
||||
|
||||
OUTPUT_TYPEMAP(bool, bool);
|
||||
OUTPUT_TYPEMAP(signed char, int8);
|
||||
OUTPUT_TYPEMAP(char, byte);
|
||||
OUTPUT_TYPEMAP(unsigned char, byte);
|
||||
OUTPUT_TYPEMAP(short, int16);
|
||||
OUTPUT_TYPEMAP(unsigned short, uint16);
|
||||
OUTPUT_TYPEMAP(int, int);
|
||||
OUTPUT_TYPEMAP(unsigned int, uint);
|
||||
OUTPUT_TYPEMAP(long, int64);
|
||||
OUTPUT_TYPEMAP(unsigned long, uint64);
|
||||
OUTPUT_TYPEMAP(long long, int64);
|
||||
OUTPUT_TYPEMAP(unsigned long long, uint64);
|
||||
OUTPUT_TYPEMAP(float, float);
|
||||
OUTPUT_TYPEMAP(double, float64);
|
||||
|
||||
#undef OUTPUT_TYPEMAP
|
||||
|
||||
/*
|
||||
INOUT typemaps
|
||||
--------------
|
||||
|
||||
Mappings for a parameter that is both an input and an output parameter
|
||||
|
||||
The following typemaps can be applied to make a function parameter both
|
||||
an input and output value. This combines the behavior of both the
|
||||
"INPUT" and "OUTPUT" typemaps described earlier. Output values are
|
||||
returned as an element in a Go slice.
|
||||
|
||||
bool *INOUT, bool &INOUT
|
||||
signed char *INOUT, signed char &INOUT
|
||||
unsigned char *INOUT, unsigned char &INOUT
|
||||
short *INOUT, short &INOUT
|
||||
unsigned short *INOUT, unsigned short &INOUT
|
||||
int *INOUT, int &INOUT
|
||||
unsigned int *INOUT, unsigned int &INOUT
|
||||
long *INOUT, long &INOUT
|
||||
unsigned long *INOUT, unsigned long &INOUT
|
||||
long long *INOUT, long long &INOUT
|
||||
unsigned long long *INOUT, unsigned long long &INOUT
|
||||
float *INOUT, float &INOUT
|
||||
double *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);
|
||||
|
||||
This works similarly to C in that the mapping directly modifies the
|
||||
input value - the input must be an array with a minimum of one element.
|
||||
The element in the array is the input and the output is the element in
|
||||
the array.
|
||||
|
||||
x := []float64{5.0}
|
||||
Neg(x);
|
||||
|
||||
The implementation of the OUTPUT and INOUT typemaps is different to
|
||||
other languages in that other languages will return the output value
|
||||
as part of the function return value. This difference is due to Go
|
||||
being a typed language.
|
||||
|
||||
There are no char *INOUT typemaps, however you can apply the signed
|
||||
char * typemaps instead:
|
||||
%include <typemaps.i>
|
||||
%apply signed char *INOUT {char *inout};
|
||||
void f(char *inout);
|
||||
*/
|
||||
|
||||
%define INOUT_TYPEMAP(TYPE, GOTYPE)
|
||||
%typemap(gotype) TYPE *INOUT, TYPE &INOUT %{[]GOTYPE%}
|
||||
|
||||
%typemap(in) TYPE *INOUT {
|
||||
if ($input.len == 0) {
|
||||
_swig_gopanic("array must contain at least 1 element");
|
||||
}
|
||||
$1 = ($1_ltype) $input.array;
|
||||
}
|
||||
|
||||
%typemap(in) TYPE &INOUT {
|
||||
if ($input->len == 0) {
|
||||
_swig_gopanic("array must contain at least 1 element");
|
||||
}
|
||||
$1 = ($1_ltype) $input->array;
|
||||
}
|
||||
|
||||
%typemap(freearg) TYPE *INOUT, TYPE &INOUT ""
|
||||
|
||||
%typemap(directorout,warning="Need to provide TYPE *INOUT directorout typemap") TYPE *INOUT, TYPE &INOUT {
|
||||
}
|
||||
|
||||
%typemap(directorin) TYPE &INOUT
|
||||
%{ *(($&1_ltype)&$input) = &$1; %}
|
||||
|
||||
%typemap(directorin,warning="Need to provide TYPE *INOUT directorin typemap, TYPE array length is unknown") TYPE *INOUT, TYPE &INOUT
|
||||
{
|
||||
}
|
||||
|
||||
%enddef
|
||||
|
||||
INOUT_TYPEMAP(bool, bool);
|
||||
INOUT_TYPEMAP(signed char, int8);
|
||||
INOUT_TYPEMAP(char, byte);
|
||||
INOUT_TYPEMAP(unsigned char, byte);
|
||||
INOUT_TYPEMAP(short, int16);
|
||||
INOUT_TYPEMAP(unsigned short, uint16);
|
||||
INOUT_TYPEMAP(int, int);
|
||||
INOUT_TYPEMAP(unsigned int, uint);
|
||||
INOUT_TYPEMAP(long, int64);
|
||||
INOUT_TYPEMAP(unsigned long, uint64);
|
||||
INOUT_TYPEMAP(long long, int64);
|
||||
INOUT_TYPEMAP(unsigned long long, uint64);
|
||||
INOUT_TYPEMAP(float, float);
|
||||
INOUT_TYPEMAP(double, float64);
|
||||
|
||||
#undef INOUT_TYPEMAP
|
||||
|
|
@ -224,7 +224,7 @@ namespace std {
|
|||
bool empty() const;
|
||||
void clear();
|
||||
%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);
|
||||
if (i != self->end())
|
||||
return i->second;
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ namespace std {
|
|||
%typemap(typecheck) string = char *;
|
||||
%typemap(typecheck) const string & = char *;
|
||||
|
||||
%typemap(in) string (char* tempptr) {
|
||||
%typemap(in) string (char * tempptr) {
|
||||
if (gh_string_p($input)) {
|
||||
tempptr = SWIG_scm2str($input);
|
||||
$1.assign(tempptr);
|
||||
|
|
@ -36,8 +36,7 @@ namespace std {
|
|||
}
|
||||
}
|
||||
|
||||
%typemap(in) const string & (std::string temp,
|
||||
char* tempptr) {
|
||||
%typemap(in) const string & (std::string temp, char *tempptr) {
|
||||
if (gh_string_p($input)) {
|
||||
tempptr = SWIG_scm2str($input);
|
||||
temp.assign(tempptr);
|
||||
|
|
@ -48,7 +47,7 @@ namespace std {
|
|||
}
|
||||
}
|
||||
|
||||
%typemap(in) string * (char* tempptr) {
|
||||
%typemap(in) string * (char *tempptr) {
|
||||
if (gh_string_p($input)) {
|
||||
tempptr = SWIG_scm2str($input);
|
||||
$1 = new std::string(tempptr);
|
||||
|
|
|
|||
|
|
@ -208,7 +208,7 @@ namespace std {
|
|||
self->pop_back();
|
||||
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());
|
||||
if (i>=0 && i<size)
|
||||
return (*self)[i];
|
||||
|
|
|
|||
|
|
@ -448,4 +448,10 @@ typedef unsigned long SCM;
|
|||
$1 = SWIG_CheckState(res);
|
||||
}
|
||||
|
||||
/* Array reference typemaps */
|
||||
%apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) }
|
||||
|
||||
/* const pointers */
|
||||
%apply SWIGTYPE * { SWIGTYPE *const }
|
||||
|
||||
/* typemaps.i ends here */
|
||||
|
|
|
|||
|
|
@ -44,52 +44,39 @@ struct SWIG_null_deleter {
|
|||
%#define SWIG_NO_NULL_DELETER_1
|
||||
}
|
||||
|
||||
// Workaround empty first macro argument bug
|
||||
#define SWIGEMPTYHACK
|
||||
// Main user macro for defining intrusive_ptr typemaps for both const and non-const pointer types
|
||||
// For plain classes, do not use for derived classes
|
||||
%define %intrusive_ptr(TYPE...)
|
||||
%feature("smartptr", noblock=1) TYPE { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > }
|
||||
SWIG_INTRUSIVE_PTR_TYPEMAPS(SWIGEMPTYHACK, TYPE)
|
||||
SWIG_INTRUSIVE_PTR_TYPEMAPS(const, TYPE)
|
||||
%enddef
|
||||
|
||||
%define %intrusive_ptr_no_wrap(TYPE...)
|
||||
%feature("smartptr", noblock=1) TYPE { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > }
|
||||
SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP(SWIGEMPTYHACK, TYPE)
|
||||
SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP(const, TYPE)
|
||||
%enddef
|
||||
|
||||
// Legacy macros
|
||||
%define SWIG_INTRUSIVE_PTR(PROXYCLASS, TYPE...)
|
||||
SWIG_INTRUSIVE_PTR_TYPEMAPS(PROXYCLASS, , TYPE)
|
||||
SWIG_INTRUSIVE_PTR_TYPEMAPS(PROXYCLASS, const, TYPE)
|
||||
#warning "SWIG_INTRUSIVE_PTR(PROXYCLASS, TYPE) is deprecated. Please use %intrusive_ptr(TYPE) instead."
|
||||
%intrusive_ptr(TYPE)
|
||||
%enddef
|
||||
|
||||
// Main user macro for defining intrusive_ptr typemaps for both const and non-const pointer types
|
||||
// For derived classes
|
||||
%define SWIG_INTRUSIVE_PTR_DERIVED(PROXYCLASS, BASECLASSTYPE, TYPE...)
|
||||
SWIG_INTRUSIVE_PTR_TYPEMAPS(PROXYCLASS, , TYPE)
|
||||
SWIG_INTRUSIVE_PTR_TYPEMAPS(PROXYCLASS, const, TYPE)
|
||||
%types(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > = SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< BASECLASSTYPE >) %{
|
||||
*newmemory = SWIG_CAST_NEW_MEMORY;
|
||||
return (void *) new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< BASECLASSTYPE >(*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *)$from);
|
||||
%}
|
||||
%extend TYPE {
|
||||
static SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< BASECLASSTYPE > SWIGSharedPtrUpcast(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > swigSharedPtrUpcast) {
|
||||
return swigSharedPtrUpcast;
|
||||
}
|
||||
}
|
||||
#warning "SWIG_INTRUSIVE_PTR_DERIVED(PROXYCLASS, BASECLASSTYPE, TYPE) is deprecated. Please use %intrusive_ptr(TYPE) instead."
|
||||
%intrusive_ptr(TYPE)
|
||||
%enddef
|
||||
|
||||
// Extra user macro for including classes in intrusive_ptr typemaps for both const and non-const pointer types
|
||||
// This caters for classes which cannot be wrapped by intrusive_ptrs but are still part of the class hierarchy
|
||||
// For plain classes, do not use for derived classes
|
||||
%define SWIG_INTRUSIVE_PTR_NO_WRAP(PROXYCLASS, TYPE...)
|
||||
SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP(PROXYCLASS, , TYPE)
|
||||
SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP(PROXYCLASS, const, TYPE)
|
||||
#warning "SWIG_INTRUSIVE_PTR_NO_WRAP(PROXYCLASS, TYPE) is deprecated. Please use %intrusive_ptr_no_wrap(TYPE) instead."
|
||||
%intrusive_ptr_no_wrap(TYPE)
|
||||
%enddef
|
||||
|
||||
// Extra user macro for including classes in intrusive_ptr typemaps for both const and non-const pointer types
|
||||
// This caters for classes which cannot be wrapped by intrusive_ptrs but are still part of the class hierarchy
|
||||
// For derived classes
|
||||
%define SWIG_INTRUSIVE_PTR_DERIVED_NO_WRAP(PROXYCLASS, BASECLASSTYPE, TYPE...)
|
||||
SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP(PROXYCLASS, , TYPE)
|
||||
SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP(PROXYCLASS, const, TYPE)
|
||||
%types(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > = SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< BASECLASSTYPE >) %{
|
||||
*newmemory = SWIG_CAST_NEW_MEMORY;
|
||||
return (void *) new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< BASECLASSTYPE >(*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *)$from);
|
||||
%}
|
||||
%extend TYPE {
|
||||
static SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< BASECLASSTYPE > SWIGSharedPtrUpcast(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > swigSharedPtrUpcast) {
|
||||
return swigSharedPtrUpcast;
|
||||
}
|
||||
}
|
||||
#warning "SWIG_INTRUSIVE_PTR_DERIVED_NO_WRAP(PROXYCLASS, BASECLASSTYPE, TYPE) is deprecated. Please use %intrusive_ptr_no_wrap(TYPE) instead."
|
||||
%intrusive_ptr_no_wrap(TYPE)
|
||||
%enddef
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
%include <intrusive_ptr.i>
|
||||
|
||||
// Language specific macro implementing all the customisations for handling the smart pointer
|
||||
%define SWIG_INTRUSIVE_PTR_TYPEMAPS(PROXYCLASS, CONST, TYPE...)
|
||||
%define SWIG_INTRUSIVE_PTR_TYPEMAPS(CONST, TYPE...)
|
||||
|
||||
// %naturalvar is as documented for member variables
|
||||
%naturalvar TYPE;
|
||||
|
|
@ -69,12 +69,12 @@
|
|||
#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
|
||||
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;
|
||||
%}
|
||||
%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)
|
||||
#if ($owner)
|
||||
if (*$1) {
|
||||
|
|
@ -207,48 +207,48 @@
|
|||
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >,
|
||||
SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > &,
|
||||
SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *,
|
||||
SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& "PROXYCLASS"
|
||||
SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& "$typemap(jstype, TYPE)"
|
||||
%typemap(javain) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >,
|
||||
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >,
|
||||
SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > &,
|
||||
SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *,
|
||||
SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& "PROXYCLASS.getCPtr($javainput)"
|
||||
SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& "$typemap(jstype, TYPE).getCPtr($javainput)"
|
||||
|
||||
%typemap(javaout) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > {
|
||||
long cPtr = $jnicall;
|
||||
return (cPtr == 0) ? null : new PROXYCLASS(cPtr, true);
|
||||
return (cPtr == 0) ? null : new $typemap(jstype, TYPE)(cPtr, true);
|
||||
}
|
||||
%typemap(javaout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > {
|
||||
long cPtr = $jnicall;
|
||||
return (cPtr == 0) ? null : new PROXYCLASS(cPtr, true);
|
||||
return (cPtr == 0) ? null : new $typemap(jstype, TYPE)(cPtr, true);
|
||||
}
|
||||
%typemap(javaout) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > & {
|
||||
long cPtr = $jnicall;
|
||||
return (cPtr == 0) ? null : new PROXYCLASS(cPtr, true);
|
||||
return (cPtr == 0) ? null : new $typemap(jstype, TYPE)(cPtr, true);
|
||||
}
|
||||
%typemap(javaout) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > * {
|
||||
long cPtr = $jnicall;
|
||||
return (cPtr == 0) ? null : new PROXYCLASS(cPtr, true);
|
||||
return (cPtr == 0) ? null : new $typemap(jstype, TYPE)(cPtr, true);
|
||||
}
|
||||
%typemap(javaout) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& {
|
||||
long cPtr = $jnicall;
|
||||
return (cPtr == 0) ? null : new PROXYCLASS(cPtr, true);
|
||||
return (cPtr == 0) ? null : new $typemap(jstype, TYPE)(cPtr, true);
|
||||
}
|
||||
|
||||
|
||||
%typemap(javaout) CONST TYPE {
|
||||
return new PROXYCLASS($jnicall, true);
|
||||
return new $typemap(jstype, TYPE)($jnicall, true);
|
||||
}
|
||||
%typemap(javaout) CONST TYPE & {
|
||||
return new PROXYCLASS($jnicall, true);
|
||||
return new $typemap(jstype, TYPE)($jnicall, true);
|
||||
}
|
||||
%typemap(javaout) CONST TYPE * {
|
||||
long cPtr = $jnicall;
|
||||
return (cPtr == 0) ? null : new PROXYCLASS(cPtr, true);
|
||||
return (cPtr == 0) ? null : new $typemap(jstype, TYPE)(cPtr, true);
|
||||
}
|
||||
%typemap(javaout) CONST TYPE *& {
|
||||
%typemap(javaout) TYPE *CONST& {
|
||||
long cPtr = $jnicall;
|
||||
return (cPtr == 0) ? null : new PROXYCLASS(cPtr, true);
|
||||
return (cPtr == 0) ? null : new $typemap(jstype, TYPE)(cPtr, true);
|
||||
}
|
||||
|
||||
// Base proxy classes
|
||||
|
|
@ -256,7 +256,7 @@
|
|||
private long swigCPtr;
|
||||
private boolean swigCMemOwnBase;
|
||||
|
||||
protected $javaclassname(long cPtr, boolean cMemoryOwn) {
|
||||
public $javaclassname(long cPtr, boolean cMemoryOwn) {
|
||||
swigCMemOwnBase = cMemoryOwn;
|
||||
swigCPtr = cPtr;
|
||||
}
|
||||
|
|
@ -271,8 +271,8 @@
|
|||
private long swigCPtr;
|
||||
private boolean swigCMemOwnDerived;
|
||||
|
||||
protected $javaclassname(long cPtr, boolean cMemoryOwn) {
|
||||
super($imclassname.$javaclassname_SWIGSharedPtrUpcast(cPtr), true);
|
||||
public $javaclassname(long cPtr, boolean cMemoryOwn) {
|
||||
super($imclassname.$javaclazznameSWIGSmartPtrUpcast(cPtr), true);
|
||||
swigCMemOwnDerived = cMemoryOwn;
|
||||
swigCPtr = cPtr;
|
||||
}
|
||||
|
|
@ -314,7 +314,7 @@
|
|||
|
||||
%include <shared_ptr.i>
|
||||
|
||||
%define SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP(PROXYCLASS, CONST, TYPE...)
|
||||
%define SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP(CONST, TYPE...)
|
||||
|
||||
%naturalvar TYPE;
|
||||
%naturalvar SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >;
|
||||
|
|
@ -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); %}
|
||||
|
||||
// plain pointer by reference
|
||||
%typemap(in) CONST TYPE *& ($*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);
|
||||
%typemap(in) TYPE *CONST& ($*1_ltype temp = 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; %}
|
||||
%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); %}
|
||||
|
||||
%typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > swigSharedPtrUpcast ($&1_type smartarg) %{
|
||||
|
|
@ -379,26 +379,26 @@
|
|||
|
||||
%typemap (jni) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > "jlong"
|
||||
%typemap (jtype) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > "long"
|
||||
%typemap (jstype) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > "PROXYCLASS"
|
||||
%typemap (javain) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > "PROXYCLASS.getCPtr($javainput)"
|
||||
%typemap (jstype) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > "$typemap(jstype, TYPE)"
|
||||
%typemap (javain) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > "$typemap(jstype, TYPE).getCPtr($javainput)"
|
||||
%typemap(javaout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > {
|
||||
long cPtr = $jnicall;
|
||||
return (cPtr == 0) ? null : new PROXYCLASS(cPtr, true);
|
||||
return (cPtr == 0) ? null : new $typemap(jstype, TYPE)(cPtr, true);
|
||||
}
|
||||
|
||||
%typemap(javaout) CONST TYPE {
|
||||
return new PROXYCLASS($jnicall, true);
|
||||
return new $typemap(jstype, TYPE)($jnicall, true);
|
||||
}
|
||||
%typemap(javaout) CONST TYPE & {
|
||||
return new PROXYCLASS($jnicall, true);
|
||||
return new $typemap(jstype, TYPE)($jnicall, true);
|
||||
}
|
||||
%typemap(javaout) CONST TYPE * {
|
||||
long cPtr = $jnicall;
|
||||
return (cPtr == 0) ? null : new PROXYCLASS(cPtr, true);
|
||||
return (cPtr == 0) ? null : new $typemap(jstype, TYPE)(cPtr, true);
|
||||
}
|
||||
%typemap(javaout) CONST TYPE *& {
|
||||
%typemap(javaout) TYPE *CONST& {
|
||||
long cPtr = $jnicall;
|
||||
return (cPtr == 0) ? null : new PROXYCLASS(cPtr, true);
|
||||
return (cPtr == 0) ? null : new $typemap(jstype, TYPE)(cPtr, true);
|
||||
}
|
||||
|
||||
// Base proxy classes
|
||||
|
|
@ -406,7 +406,7 @@
|
|||
private long swigCPtr;
|
||||
private boolean swigCMemOwnBase;
|
||||
|
||||
protected $javaclassname(long cPtr, boolean cMemoryOwn) {
|
||||
public $javaclassname(long cPtr, boolean cMemoryOwn) {
|
||||
swigCMemOwnBase = cMemoryOwn;
|
||||
swigCPtr = cPtr;
|
||||
}
|
||||
|
|
@ -421,8 +421,8 @@
|
|||
private long swigCPtr;
|
||||
private boolean swigCMemOwnDerived;
|
||||
|
||||
protected $javaclassname(long cPtr, boolean cMemoryOwn) {
|
||||
super($imclassname.$javaclassname_SWIGSharedPtrUpcast(cPtr), true);
|
||||
public $javaclassname(long cPtr, boolean cMemoryOwn) {
|
||||
super($imclassname.$javaclazznameSWIGSmartPtrUpcast(cPtr), true);
|
||||
swigCMemOwnDerived = cMemoryOwn;
|
||||
swigCPtr = cPtr;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
%include <shared_ptr.i>
|
||||
|
||||
// Language specific macro implementing all the customisations for handling the smart pointer
|
||||
%define SWIG_SHARED_PTR_TYPEMAPS(PROXYCLASS, CONST, TYPE...)
|
||||
%define SWIG_SHARED_PTR_TYPEMAPS(CONST, TYPE...)
|
||||
|
||||
// %naturalvar is as documented for member variables
|
||||
%naturalvar TYPE;
|
||||
|
|
@ -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); %}
|
||||
|
||||
// plain pointer by reference
|
||||
%typemap(in) CONST TYPE *& ($*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);
|
||||
%typemap(in) TYPE *CONST& ($*1_ltype temp = 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; %}
|
||||
%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); %}
|
||||
|
||||
// shared_ptr by value
|
||||
|
|
@ -97,44 +97,44 @@
|
|||
%typemap (jstype) 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 > *& "PROXYCLASS"
|
||||
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& "$typemap(jstype, TYPE)"
|
||||
|
||||
%typemap(javain) 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 > *& "PROXYCLASS.getCPtr($javainput)"
|
||||
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& "$typemap(jstype, TYPE).getCPtr($javainput)"
|
||||
|
||||
%typemap(javaout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > {
|
||||
long cPtr = $jnicall;
|
||||
return (cPtr == 0) ? null : new PROXYCLASS(cPtr, true);
|
||||
return (cPtr == 0) ? null : new $typemap(jstype, TYPE)(cPtr, true);
|
||||
}
|
||||
%typemap(javaout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & {
|
||||
long cPtr = $jnicall;
|
||||
return (cPtr == 0) ? null : new PROXYCLASS(cPtr, true);
|
||||
return (cPtr == 0) ? null : new $typemap(jstype, TYPE)(cPtr, true);
|
||||
}
|
||||
%typemap(javaout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * {
|
||||
long cPtr = $jnicall;
|
||||
return (cPtr == 0) ? null : new PROXYCLASS(cPtr, true);
|
||||
return (cPtr == 0) ? null : new $typemap(jstype, TYPE)(cPtr, true);
|
||||
}
|
||||
%typemap(javaout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& {
|
||||
long cPtr = $jnicall;
|
||||
return (cPtr == 0) ? null : new PROXYCLASS(cPtr, true);
|
||||
return (cPtr == 0) ? null : new $typemap(jstype, TYPE)(cPtr, true);
|
||||
}
|
||||
|
||||
|
||||
%typemap(javaout) CONST TYPE {
|
||||
return new PROXYCLASS($jnicall, true);
|
||||
return new $typemap(jstype, TYPE)($jnicall, true);
|
||||
}
|
||||
%typemap(javaout) CONST TYPE & {
|
||||
return new PROXYCLASS($jnicall, true);
|
||||
return new $typemap(jstype, TYPE)($jnicall, true);
|
||||
}
|
||||
%typemap(javaout) CONST TYPE * {
|
||||
long cPtr = $jnicall;
|
||||
return (cPtr == 0) ? null : new PROXYCLASS(cPtr, true);
|
||||
return (cPtr == 0) ? null : new $typemap(jstype, TYPE)(cPtr, true);
|
||||
}
|
||||
%typemap(javaout) CONST TYPE *& {
|
||||
%typemap(javaout) TYPE *CONST& {
|
||||
long cPtr = $jnicall;
|
||||
return (cPtr == 0) ? null : new PROXYCLASS(cPtr, true);
|
||||
return (cPtr == 0) ? null : new $typemap(jstype, TYPE)(cPtr, true);
|
||||
}
|
||||
|
||||
// Base proxy classes
|
||||
|
|
@ -142,7 +142,7 @@
|
|||
private long swigCPtr;
|
||||
private boolean swigCMemOwnBase;
|
||||
|
||||
protected $javaclassname(long cPtr, boolean cMemoryOwn) {
|
||||
public $javaclassname(long cPtr, boolean cMemoryOwn) {
|
||||
swigCMemOwnBase = cMemoryOwn;
|
||||
swigCPtr = cPtr;
|
||||
}
|
||||
|
|
@ -157,8 +157,8 @@
|
|||
private long swigCPtr;
|
||||
private boolean swigCMemOwnDerived;
|
||||
|
||||
protected $javaclassname(long cPtr, boolean cMemoryOwn) {
|
||||
super($imclassname.$javaclassname_SWIGSharedPtrUpcast(cPtr), true);
|
||||
public $javaclassname(long cPtr, boolean cMemoryOwn) {
|
||||
super($imclassname.$javaclazznameSWIGSmartPtrUpcast(cPtr), true);
|
||||
swigCMemOwnDerived = cMemoryOwn;
|
||||
swigCPtr = cPtr;
|
||||
}
|
||||
|
|
@ -189,10 +189,6 @@
|
|||
super.delete();
|
||||
}
|
||||
|
||||
// CONST version needed ???? also for C#
|
||||
%typemap(jtype, nopgcpp="1") SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > swigSharedPtrUpcast "long"
|
||||
%typemap(jtype, nopgcpp="1") SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > swigSharedPtrUpcast "long"
|
||||
|
||||
|
||||
%template() SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >;
|
||||
%enddef
|
||||
|
|
|
|||
|
|
@ -11,6 +11,49 @@
|
|||
* The jtype typemap contains the Java type used in the JNI intermediary class.
|
||||
* The jstype typemap contains the Java type used in the Java proxy classes, type wrapper classes and module class. */
|
||||
|
||||
/* Fragments */
|
||||
%fragment("SWIG_PackData", "header") {
|
||||
/* Pack binary data into a string */
|
||||
SWIGINTERN char * SWIG_PackData(char *c, void *ptr, size_t sz) {
|
||||
static const char hex[17] = "0123456789abcdef";
|
||||
register const unsigned char *u = (unsigned char *) ptr;
|
||||
register const unsigned char *eu = u + sz;
|
||||
for (; u != eu; ++u) {
|
||||
register unsigned char uu = *u;
|
||||
*(c++) = hex[(uu & 0xf0) >> 4];
|
||||
*(c++) = hex[uu & 0xf];
|
||||
}
|
||||
return c;
|
||||
}
|
||||
}
|
||||
|
||||
%fragment("SWIG_UnPackData", "header") {
|
||||
/* Unpack binary data from a string */
|
||||
SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
|
||||
register unsigned char *u = (unsigned char *) ptr;
|
||||
register const unsigned char *eu = u + sz;
|
||||
for (; u != eu; ++u) {
|
||||
register char d = *(c++);
|
||||
register unsigned char uu;
|
||||
if ((d >= '0') && (d <= '9'))
|
||||
uu = ((d - '0') << 4);
|
||||
else if ((d >= 'a') && (d <= 'f'))
|
||||
uu = ((d - ('a'-10)) << 4);
|
||||
else
|
||||
return (char *) 0;
|
||||
d = *(c++);
|
||||
if ((d >= '0') && (d <= '9'))
|
||||
uu |= (d - '0');
|
||||
else if ((d >= 'a') && (d <= 'f'))
|
||||
uu |= (d - ('a'-10));
|
||||
else
|
||||
return (char *) 0;
|
||||
*u = uu;
|
||||
}
|
||||
return c;
|
||||
}
|
||||
}
|
||||
|
||||
/* Primitive types */
|
||||
%typemap(jni) bool, const bool & "jboolean"
|
||||
%typemap(jni) char, const char & "jchar"
|
||||
|
|
@ -143,8 +186,8 @@
|
|||
%typemap(jstype) SWIGTYPE & "$javaclassname"
|
||||
|
||||
/* pointer to a class member */
|
||||
%typemap(jni) SWIGTYPE (CLASS::*) "jlong"
|
||||
%typemap(jtype) SWIGTYPE (CLASS::*) "long"
|
||||
%typemap(jni) SWIGTYPE (CLASS::*) "jstring"
|
||||
%typemap(jtype) SWIGTYPE (CLASS::*) "String"
|
||||
%typemap(jstype) SWIGTYPE (CLASS::*) "$javaclassname"
|
||||
|
||||
/* The following are the in, out, freearg, argout typemaps. These are the JNI code generating typemaps for converting from Java to C and visa versa. */
|
||||
|
|
@ -592,20 +635,39 @@
|
|||
%typemap(javadirectorout) SWIGTYPE "$&javaclassname.getCPtr($javacall)"
|
||||
|
||||
/* Generic pointers and references */
|
||||
%typemap(in) SWIGTYPE *, SWIGTYPE (CLASS::*) %{ $1 = *($&1_ltype)&$input; %}
|
||||
%typemap(in) SWIGTYPE * %{ $1 = *($&1_ltype)&$input; %}
|
||||
%typemap(in, fragment="SWIG_UnPackData") SWIGTYPE (CLASS::*) {
|
||||
const char *temp = 0;
|
||||
if ($input) {
|
||||
temp = JCALL2(GetStringUTFChars, jenv, $input, 0);
|
||||
if (!temp) return $null;
|
||||
}
|
||||
SWIG_UnpackData(temp, (void *)&$1, sizeof($1));
|
||||
}
|
||||
%typemap(in) SWIGTYPE & %{ $1 = *($&1_ltype)&$input;
|
||||
if (!$1) {
|
||||
SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "$1_type reference is null");
|
||||
return $null;
|
||||
} %}
|
||||
%typemap(out) SWIGTYPE *, SWIGTYPE (CLASS::*)
|
||||
%typemap(out) SWIGTYPE *
|
||||
%{ *($&1_ltype)&$result = $1; %}
|
||||
%typemap(out, fragment="SWIG_PackData", noblock=1) SWIGTYPE (CLASS::*) {
|
||||
char buf[128];
|
||||
char *data = SWIG_PackData(buf, (void *)&$1, sizeof($1));
|
||||
*data = '\0';
|
||||
$result = JCALL1(NewStringUTF, jenv, buf);
|
||||
}
|
||||
%typemap(out) SWIGTYPE &
|
||||
%{ *($&1_ltype)&$result = $1; %}
|
||||
|
||||
%typemap(directorout, warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) SWIGTYPE *, SWIGTYPE (CLASS::*)
|
||||
%typemap(directorout, warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) SWIGTYPE *
|
||||
%{ $result = *($&1_ltype)&$input; %}
|
||||
%typemap(directorin,descriptor="L$packagepath/$javaclassname;") SWIGTYPE *, SWIGTYPE (CLASS::*)
|
||||
%typemap(directorout, warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) SWIGTYPE (CLASS::*)
|
||||
%{ $result = *($&1_ltype)&$input; %}
|
||||
|
||||
%typemap(directorin,descriptor="L$packagepath/$javaclassname;") SWIGTYPE *
|
||||
%{ *(($&1_ltype)&$input) = ($1_ltype) $1; %}
|
||||
%typemap(directorin,descriptor="L$packagepath/$javaclassname;") SWIGTYPE (CLASS::*)
|
||||
%{ *(($&1_ltype)&$input) = ($1_ltype) $1; %}
|
||||
|
||||
%typemap(directorout, warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) SWIGTYPE &
|
||||
|
|
@ -897,6 +959,7 @@
|
|||
SWIGTYPE,
|
||||
SWIGTYPE *,
|
||||
SWIGTYPE &,
|
||||
SWIGTYPE *const&,
|
||||
SWIGTYPE [],
|
||||
SWIGTYPE (CLASS::*)
|
||||
""
|
||||
|
|
@ -966,7 +1029,8 @@
|
|||
jobjectArray
|
||||
"$javainput"
|
||||
%typemap(javain) SWIGTYPE "$&javaclassname.getCPtr($javainput)"
|
||||
%typemap(javain) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) "$javaclassname.getCPtr($javainput)"
|
||||
%typemap(javain) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [] "$javaclassname.getCPtr($javainput)"
|
||||
%typemap(javain) SWIGTYPE (CLASS::*) "$javaclassname.getCMemberPtr($javainput)"
|
||||
|
||||
/* The javaout typemap is used for converting function return types from the return type
|
||||
* used in the JNI class to the type returned by the proxy, module or type wrapper class. */
|
||||
|
|
@ -1019,29 +1083,30 @@
|
|||
%typemap(javaout) SWIGTYPE & {
|
||||
return new $javaclassname($jnicall, $owner);
|
||||
}
|
||||
%typemap(javaout) SWIGTYPE *, SWIGTYPE [], SWIGTYPE (CLASS::*) {
|
||||
%typemap(javaout) SWIGTYPE *, SWIGTYPE [] {
|
||||
long cPtr = $jnicall;
|
||||
return (cPtr == 0) ? null : new $javaclassname(cPtr, $owner);
|
||||
}
|
||||
%typemap(javaout) SWIGTYPE (CLASS::*) {
|
||||
String cMemberPtr = $jnicall;
|
||||
return (cMemberPtr == null) ? null : new $javaclassname(cMemberPtr, $owner);
|
||||
}
|
||||
|
||||
/* Pointer reference typemaps */
|
||||
%typemap(jni) SWIGTYPE *& "jlong"
|
||||
%typemap(jtype) SWIGTYPE *& "long"
|
||||
%typemap(jstype) SWIGTYPE *& "$*javaclassname"
|
||||
%typemap(javain) SWIGTYPE *& "$*javaclassname.getCPtr($javainput)"
|
||||
%typemap(javaout) SWIGTYPE *& {
|
||||
%typemap(jni) SWIGTYPE *const& "jlong"
|
||||
%typemap(jtype) SWIGTYPE *const& "long"
|
||||
%typemap(jstype) SWIGTYPE *const& "$*javaclassname"
|
||||
%typemap(javain) SWIGTYPE *const& "$*javaclassname.getCPtr($javainput)"
|
||||
%typemap(javaout) SWIGTYPE *const& {
|
||||
long cPtr = $jnicall;
|
||||
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;
|
||||
$1 = &temp; %}
|
||||
%typemap(out) SWIGTYPE *&
|
||||
$1 = ($1_ltype)&temp; %}
|
||||
%typemap(out) SWIGTYPE *const&
|
||||
%{ *($1_ltype)&$result = *$1; %}
|
||||
|
||||
/* Array reference typemaps */
|
||||
%apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) }
|
||||
|
||||
/* Typemaps used for the generation of proxy and type wrapper class code */
|
||||
%typemap(javabase) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) ""
|
||||
%typemap(javaclassmodifiers) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) "public class"
|
||||
|
|
@ -1072,7 +1137,7 @@
|
|||
private long swigCPtr;
|
||||
|
||||
PTRCTOR_VISIBILITY $javaclassname(long cPtr, boolean cMemoryOwn) {
|
||||
super($imclassname.SWIG$javaclassnameUpcast(cPtr), cMemoryOwn);
|
||||
super($imclassname.$javaclazznameSWIGUpcast(cPtr), cMemoryOwn);
|
||||
swigCPtr = cPtr;
|
||||
}
|
||||
|
||||
|
|
@ -1085,10 +1150,10 @@
|
|||
/* Set the default for SWIGTYPE: pointer constructor is protected,
|
||||
getCPtr is protected. Season to your own taste! */
|
||||
|
||||
SWIG_JAVABODY_METHODS(protected, protected, SWIGTYPE)
|
||||
SWIG_JAVABODY_METHODS(public, public, SWIGTYPE)
|
||||
|
||||
// Typewrapper classes
|
||||
%typemap(javabody) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) %{
|
||||
%typemap(javabody) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [] %{
|
||||
private long swigCPtr;
|
||||
|
||||
protected $javaclassname(long cPtr, boolean futureUse) {
|
||||
|
|
@ -1104,6 +1169,22 @@ SWIG_JAVABODY_METHODS(protected, protected, SWIGTYPE)
|
|||
}
|
||||
%}
|
||||
|
||||
%typemap(javabody) SWIGTYPE (CLASS::*) %{
|
||||
private String swigCMemberPtr;
|
||||
|
||||
protected $javaclassname(String cMemberPtr, boolean futureUse) {
|
||||
swigCMemberPtr = cMemberPtr;
|
||||
}
|
||||
|
||||
protected $javaclassname() {
|
||||
swigCMemberPtr = null;
|
||||
}
|
||||
|
||||
protected static String getCMemberPtr($javaclassname obj) {
|
||||
return obj.swigCMemberPtr;
|
||||
}
|
||||
%}
|
||||
|
||||
%typemap(javafinalize) SWIGTYPE %{
|
||||
protected void finalize() {
|
||||
delete();
|
||||
|
|
@ -1132,7 +1213,7 @@ SWIG_JAVABODY_METHODS(protected, protected, SWIGTYPE)
|
|||
*/
|
||||
|
||||
%define SWIG_PROXY_CONSTRUCTOR(OWNERSHIP, WEAKREF, TYPENAME...)
|
||||
%typemap(javaconstruct,directorconnect="\n $imclassname.$javaclassname_director_connect(this, swigCPtr, swigCMemOwn, WEAKREF);") TYPENAME {
|
||||
%typemap(javaconstruct,directorconnect="\n $imclassname.$javaclazznamedirector_connect(this, swigCPtr, swigCMemOwn, WEAKREF);") TYPENAME {
|
||||
this($imcall, OWNERSHIP);$directorconnect
|
||||
}
|
||||
%enddef
|
||||
|
|
@ -1195,7 +1276,7 @@ SWIG_PROXY_CONSTRUCTOR(true, true, SWIGTYPE)
|
|||
#define %nojavaexception %feature("except","0",throws="")
|
||||
#define %clearjavaexception %feature("except","",throws="")
|
||||
|
||||
%pragma(java) jniclassclassmodifiers="class"
|
||||
%pragma(java) jniclassclassmodifiers="public class"
|
||||
%pragma(java) moduleclassmodifiers="public class"
|
||||
|
||||
/* Some ANSI C typemaps */
|
||||
|
|
@ -1203,6 +1284,12 @@ SWIG_PROXY_CONSTRUCTOR(true, true, SWIGTYPE)
|
|||
%apply unsigned long { size_t };
|
||||
%apply const unsigned long & { const size_t & };
|
||||
|
||||
/* Array reference typemaps */
|
||||
%apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) }
|
||||
|
||||
/* const pointers */
|
||||
%apply SWIGTYPE * { SWIGTYPE *const }
|
||||
|
||||
/* java keywords */
|
||||
%include <javakw.swg>
|
||||
|
||||
|
|
|
|||
|
|
@ -58,119 +58,17 @@ namespace std {
|
|||
}
|
||||
};
|
||||
|
||||
// Legacy macros (deprecated)
|
||||
%define specialize_std_map_on_key(K,CHECK,CONVERT_FROM,CONVERT_TO)
|
||||
#warning "specialize_std_map_on_key ignored - macro is deprecated and no longer necessary"
|
||||
%enddef
|
||||
|
||||
// specializations for built-ins
|
||||
%define specialize_std_map_on_value(T,CHECK,CONVERT_FROM,CONVERT_TO)
|
||||
#warning "specialize_std_map_on_value ignored - macro is deprecated and no longer necessary"
|
||||
%enddef
|
||||
|
||||
%define specialize_std_map_on_key(K,CHECK,CONVERT_FROM,CONVERT_TO)
|
||||
|
||||
template<class T> class map<K,T> {
|
||||
// add typemaps here
|
||||
public:
|
||||
map();
|
||||
map(const map<K,T> &);
|
||||
|
||||
unsigned int size() const;
|
||||
bool empty() const;
|
||||
void clear();
|
||||
%extend {
|
||||
T& get(K key) throw (std::out_of_range) {
|
||||
std::map<K,T >::iterator i = self->find(key);
|
||||
if (i != self->end())
|
||||
return i->second;
|
||||
else
|
||||
throw std::out_of_range("key not found");
|
||||
}
|
||||
void set(K key, const T& x) {
|
||||
(*self)[key] = x;
|
||||
}
|
||||
void del(K key) throw (std::out_of_range) {
|
||||
std::map<K,T >::iterator i = self->find(key);
|
||||
if (i != self->end())
|
||||
self->erase(i);
|
||||
else
|
||||
throw std::out_of_range("key not found");
|
||||
}
|
||||
bool has_key(K key) {
|
||||
std::map<K,T >::iterator i = self->find(key);
|
||||
return i != self->end();
|
||||
}
|
||||
}
|
||||
};
|
||||
%enddef
|
||||
|
||||
%define specialize_std_map_on_value(T,CHECK,CONVERT_FROM,CONVERT_TO)
|
||||
template<class K> class map<K,T> {
|
||||
// add typemaps here
|
||||
public:
|
||||
map();
|
||||
map(const map<K,T> &);
|
||||
|
||||
unsigned int size() const;
|
||||
bool empty() const;
|
||||
void clear();
|
||||
%extend {
|
||||
T get(const K& key) throw (std::out_of_range) {
|
||||
std::map<K,T >::iterator i = self->find(key);
|
||||
if (i != self->end())
|
||||
return i->second;
|
||||
else
|
||||
throw std::out_of_range("key not found");
|
||||
}
|
||||
void set(const K& key, T x) {
|
||||
(*self)[key] = x;
|
||||
}
|
||||
void del(const K& key) throw (std::out_of_range) {
|
||||
std::map<K,T >::iterator i = self->find(key);
|
||||
if (i != self->end())
|
||||
self->erase(i);
|
||||
else
|
||||
throw std::out_of_range("key not found");
|
||||
}
|
||||
bool has_key(const K& key) {
|
||||
std::map<K,T >::iterator i = self->find(key);
|
||||
return i != self->end();
|
||||
}
|
||||
}
|
||||
};
|
||||
%enddef
|
||||
|
||||
%define specialize_std_map_on_both(K,CHECK_K,CONVERT_K_FROM,CONVERT_K_TO,
|
||||
T,CHECK_T,CONVERT_T_FROM,CONVERT_T_TO)
|
||||
template<> class map<K,T> {
|
||||
// add typemaps here
|
||||
public:
|
||||
map();
|
||||
map(const map<K,T> &);
|
||||
|
||||
unsigned int size() const;
|
||||
bool empty() const;
|
||||
void clear();
|
||||
%extend {
|
||||
T get(K key) throw (std::out_of_range) {
|
||||
std::map<K,T >::iterator i = self->find(key);
|
||||
if (i != self->end())
|
||||
return i->second;
|
||||
else
|
||||
throw std::out_of_range("key not found");
|
||||
}
|
||||
void set(K key, T x) {
|
||||
(*self)[key] = x;
|
||||
}
|
||||
void del(K key) throw (std::out_of_range) {
|
||||
std::map<K,T >::iterator i = self->find(key);
|
||||
if (i != self->end())
|
||||
self->erase(i);
|
||||
else
|
||||
throw std::out_of_range("key not found");
|
||||
}
|
||||
bool has_key(K key) {
|
||||
std::map<K,T >::iterator i = self->find(key);
|
||||
return i != self->end();
|
||||
}
|
||||
}
|
||||
};
|
||||
%enddef
|
||||
|
||||
// add specializations here
|
||||
%define specialize_std_map_on_both(K,CHECK_K,CONVERT_K_FROM,CONVERT_K_TO, T,CHECK_T,CONVERT_T_FROM,CONVERT_T_TO)
|
||||
#warning "specialize_std_map_on_both ignored - macro is deprecated and no longer necessary"
|
||||
%enddef
|
||||
|
||||
}
|
||||
|
|
|
|||
2
Lib/java/std_shared_ptr.i
Normal file
2
Lib/java/std_shared_ptr.i
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
#define SWIG_SHARED_PTR_NAMESPACE std
|
||||
%include <boost_shared_ptr.i>
|
||||
|
|
@ -40,7 +40,7 @@
|
|||
%typemap(consttab) long long, unsigned long long
|
||||
{ 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}
|
||||
|
||||
// member function pointers
|
||||
|
|
@ -176,7 +176,7 @@ use %include <std_except.i> instead
|
|||
%{lua_pushnumber(L,(lua_Number)(int)$1);SWIG_fail; %}
|
||||
|
||||
// strings are just sent as errors
|
||||
%typemap(throws) char*, const char*
|
||||
%typemap(throws) char *, const char *
|
||||
%{lua_pushstring(L,$1);SWIG_fail;%}
|
||||
|
||||
// char is changed to a string
|
||||
|
|
|
|||
|
|
@ -661,7 +661,7 @@ SWIGRUNTIME const char *SWIG_Lua_typename(lua_State *L, int tp)
|
|||
swig_lua_userdata* usr;
|
||||
if (lua_isuserdata(L,tp))
|
||||
{
|
||||
usr=(swig_lua_userdata*)lua_touserdata(L,1); /* get data */
|
||||
usr=(swig_lua_userdata*)lua_touserdata(L,tp); /* get data */
|
||||
if (usr && usr->type && usr->type->str)
|
||||
return usr->type->str;
|
||||
return "userdata (unknown type)";
|
||||
|
|
|
|||
|
|
@ -89,30 +89,39 @@ temp=($basetype)lua_tonumber(L,$input); $1=&temp;%}
|
|||
%typemap(out) const bool&
|
||||
%{ lua_pushboolean(L,(int)((*$1)!=0)); SWIG_arg++;%}
|
||||
|
||||
// strings (char* and char[])
|
||||
%typemap(in,checkfn="lua_isstring") const char*, char*
|
||||
// strings (char * and char[])
|
||||
%fragment("SWIG_lua_isnilstring", "header") {
|
||||
SWIGINTERN int SWIG_lua_isnilstring(lua_State *L, int idx) {
|
||||
int ret = lua_isstring(L, idx);
|
||||
if (!ret)
|
||||
ret = lua_isnil(L, idx);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
%typemap(in,checkfn="SWIG_lua_isnilstring",fragment="SWIG_lua_isnilstring") const char *, char *
|
||||
%{$1 = ($ltype)lua_tostring(L, $input);%}
|
||||
|
||||
%typemap(in,checkfn="lua_isstring") const char[ANY], char[ANY]
|
||||
%typemap(in,checkfn="SWIG_lua_isnilstring",fragment="SWIG_lua_isnilstring") const char[ANY], char[ANY]
|
||||
%{$1 = ($ltype)lua_tostring(L, $input);%}
|
||||
|
||||
%typemap(out) const char*, char*
|
||||
%{ lua_pushstring(L,(const char*)$1); SWIG_arg++;%}
|
||||
%typemap(out) const char *, char *
|
||||
%{ lua_pushstring(L,(const char *)$1); SWIG_arg++;%}
|
||||
|
||||
%typemap(out) const char[ANY], char[ANY]
|
||||
%{ lua_pushstring(L,(const char*)$1); SWIG_arg++;%}
|
||||
%{ lua_pushstring(L,(const char *)$1); SWIG_arg++;%}
|
||||
|
||||
// char's
|
||||
// currently treating chars as small strings, not as numbers
|
||||
// (however signed & unsigned char's are numbers...)
|
||||
%typemap(in,checkfn="lua_isstring") char
|
||||
%typemap(in,checkfn="SWIG_lua_isnilstring",fragment="SWIG_lua_isnilstring") char
|
||||
%{$1 = (lua_tostring(L, $input))[0];%}
|
||||
|
||||
%typemap(out) char
|
||||
%{ lua_pushfstring(L,"%c",$1); SWIG_arg++;%}
|
||||
|
||||
// by const ref
|
||||
%typemap(in,checkfn="lua_isstring") const char& (char temp)
|
||||
%typemap(in,checkfn="SWIG_lua_isnilstring",fragment="SWIG_lua_isnilstring") const char& (char temp)
|
||||
%{temp = (lua_tostring(L, $input))[0]; $1=&temp;%}
|
||||
|
||||
%typemap(out) const char&
|
||||
|
|
@ -167,11 +176,11 @@ temp=($basetype)lua_tonumber(L,$input); $1=&temp;%}
|
|||
// Also needed for object ptrs by const ref
|
||||
// eg A* const& ref_pointer(A* const& a);
|
||||
// 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");
|
||||
$1=&temp;%}
|
||||
$1=($1_ltype)&temp;%}
|
||||
|
||||
%typemap(out) SWIGTYPE *&
|
||||
%typemap(out) SWIGTYPE *const&
|
||||
%{SWIG_NewPointerObj(L,*$1,$*descriptor,$owner); SWIG_arg++; %}
|
||||
|
||||
|
||||
|
|
@ -288,12 +297,12 @@ parmeters match which function
|
|||
}
|
||||
|
||||
// special check for a char (string of length 1)
|
||||
%typecheck(SWIG_TYPECHECK_CHAR) char, const char& {
|
||||
$1 = lua_isstring(L,$input) && (lua_strlen(L,$input)==1);
|
||||
%typecheck(SWIG_TYPECHECK_CHAR,fragment="SWIG_lua_isnilstring") char, const char& {
|
||||
$1 = SWIG_lua_isnilstring(L,$input) && (lua_strlen(L,$input)==1);
|
||||
}
|
||||
|
||||
%typecheck(SWIG_TYPECHECK_STRING) char *, char[] {
|
||||
$1 = lua_isstring(L,$input);
|
||||
%typecheck(SWIG_TYPECHECK_STRING,fragment="SWIG_lua_isnilstring") char *, char[] {
|
||||
$1 = SWIG_lua_isnilstring(L,$input);
|
||||
}
|
||||
|
||||
%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE *, SWIGTYPE [] {
|
||||
|
|
@ -335,7 +344,7 @@ parmeters match which function
|
|||
// Also needed for object ptrs by const ref
|
||||
// eg const A* ref_pointer(A* const& a);
|
||||
// found in mixed_types.i
|
||||
%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE* const &
|
||||
%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE *const&
|
||||
{
|
||||
void *ptr;
|
||||
if (lua_isuserdata(L,$input)==0 || SWIG_ConvertPtr(L,$input, (void **) &ptr, $*descriptor, 0)) {
|
||||
|
|
@ -352,6 +361,9 @@ parmeters match which function
|
|||
// Array reference typemaps
|
||||
%apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) }
|
||||
|
||||
/* const pointers */
|
||||
%apply SWIGTYPE * { SWIGTYPE *const }
|
||||
|
||||
// size_t (which is just a unsigned long)
|
||||
%apply unsigned long { size_t };
|
||||
%apply const unsigned long & { const size_t & };
|
||||
|
|
|
|||
|
|
@ -199,10 +199,10 @@ There probably is some compiler that its not true for, so the code is left here
|
|||
%{
|
||||
#ifdef __cplusplus /* generic alloc/dealloc fns*/
|
||||
#define SWIG_ALLOC_ARRAY(TYPE,LEN) new TYPE[LEN]
|
||||
#define SWIG_FREE_ARRAY(PTR) delete[] PTR;
|
||||
#define SWIG_FREE_ARRAY(PTR) delete[] PTR
|
||||
#else
|
||||
#define SWIG_ALLOC_ARRAY(TYPE,LEN) (TYPE *)malloc(LEN*sizeof(TYPE))
|
||||
#define SWIG_FREE_ARRAY(PTR) free(PTR);
|
||||
#define SWIG_FREE_ARRAY(PTR) free(PTR)
|
||||
#endif
|
||||
/* counting the size of arrays:*/
|
||||
SWIGINTERN int SWIG_itable_size(lua_State* L, int index)
|
||||
|
|
|
|||
|
|
@ -12,11 +12,11 @@
|
|||
%{
|
||||
#include <stdlib.h>
|
||||
|
||||
wchar_t* str2wstr(const char* str, int len)
|
||||
wchar_t* str2wstr(const char *str, int len)
|
||||
{
|
||||
wchar_t* p;
|
||||
if (str==0 || len<1) return 0;
|
||||
p=(wchar*)malloc((len+1)*sizeof(wchar_t));
|
||||
p=(wchar *)malloc((len+1)*sizeof(wchar_t));
|
||||
if (p==0) return 0;
|
||||
if (mbstowcs(p, str, len)==-1)
|
||||
{
|
||||
|
|
@ -28,13 +28,13 @@ wchar_t* str2wstr(const char* str, int len)
|
|||
}
|
||||
%}
|
||||
|
||||
%typemap( in, checkfn="lua_isstring" ) wchar_t*
|
||||
%typemap(in, checkfn="SWIG_lua_isnilstring", fragment="SWIG_lua_isnilstring") wchar_t *
|
||||
%{
|
||||
$1 = str2wstr(lua_tostring( L, $input ),lua_strlen( L, $input ));
|
||||
if ($1==0) {lua_pushfstring(L,"Error in converting to wchar (arg %d)",$input);goto fail;}
|
||||
%}
|
||||
|
||||
%typemap( freearg ) wchar_t*
|
||||
%typemap(freearg) wchar_t *
|
||||
%{
|
||||
free($1);
|
||||
%}
|
||||
|
|
|
|||
|
|
@ -745,3 +745,10 @@ FROM BlaBla IMPORT Bla;
|
|||
/* Some ANSI C typemaps */
|
||||
|
||||
%apply unsigned long { size_t };
|
||||
|
||||
/* Array reference typemaps */
|
||||
%apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) }
|
||||
|
||||
/* const pointers */
|
||||
%apply SWIGTYPE * { SWIGTYPE *const }
|
||||
|
||||
|
|
|
|||
|
|
@ -247,8 +247,8 @@ namespace std {
|
|||
}
|
||||
Scheme_Object* keys() {
|
||||
Scheme_Object* result = scheme_null;
|
||||
for (std::map<K,T >::reverse_iterator i=$1.rbegin();
|
||||
i!=$1.rend(); ++i) {
|
||||
for (std::map<K,T >::reverse_iterator i=self->rbegin();
|
||||
i!=self->rend(); ++i) {
|
||||
K* key = new K(i->first);
|
||||
Scheme_Object* k = SWIG_NewPointerObj(key,$descriptor(K *), 1);
|
||||
result = scheme_make_pair(k,result);
|
||||
|
|
@ -467,8 +467,8 @@ namespace std {
|
|||
}
|
||||
Scheme_Object* keys() {
|
||||
Scheme_Object* result = scheme_null;
|
||||
for (std::map<K,T >::reverse_iterator i=$1.rbegin();
|
||||
i!=$1.rend(); ++i) {
|
||||
for (std::map<K,T >::reverse_iterator i=self->rbegin();
|
||||
i!=self->rend(); ++i) {
|
||||
Scheme_Object* k = CONVERT_TO(i->first);
|
||||
result = scheme_make_pair(k,result);
|
||||
}
|
||||
|
|
@ -679,8 +679,8 @@ namespace std {
|
|||
}
|
||||
Scheme_Object* keys() {
|
||||
Scheme_Object* result = scheme_null;
|
||||
for (std::map<K,T >::reverse_iterator i=$1.rbegin();
|
||||
i!=$1.rend(); ++i) {
|
||||
for (std::map<K,T >::reverse_iterator i=self->rbegin();
|
||||
i!=self->rend(); ++i) {
|
||||
K* key = new K(i->first);
|
||||
Scheme_Object* k = SWIG_NewPointerObj(key,$descriptor(K *), 1);
|
||||
result = scheme_make_pair(k,result);
|
||||
|
|
@ -891,8 +891,8 @@ namespace std {
|
|||
}
|
||||
Scheme_Object* keys() {
|
||||
Scheme_Object* result = scheme_null;
|
||||
for (std::map<K,T >::reverse_iterator i=$1.rbegin();
|
||||
i!=$1.rend(); ++i) {
|
||||
for (std::map<K,T >::reverse_iterator i=self->rbegin();
|
||||
i!=self->rend(); ++i) {
|
||||
Scheme_Object* k = CONVERT_K_TO(i->first);
|
||||
result = scheme_make_pair(k,result);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 }
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@
|
|||
|
||||
#include <string>
|
||||
|
||||
# define SWIG_DIRECTOR_CAST(ARG) dynamic_cast<Swig::Director *>(ARG)
|
||||
|
||||
namespace Swig {
|
||||
/* base class for director exceptions */
|
||||
class DirectorException {
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
#define OCAML_OCAMLKW_SWG_
|
||||
|
||||
/* Warnings for Ocaml keywords */
|
||||
#define OCAMLKW(x) %namewarn("314: '" #x "' is a ocaml keyword and it will properly renamed") #x
|
||||
#define OCAMLKW(x) %namewarn("314: '" #x "' is an ocaml keyword and it will be appropriately renamed") #x
|
||||
|
||||
/*
|
||||
from
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ namespace std {
|
|||
bool empty() const;
|
||||
void clear();
|
||||
%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);
|
||||
if (i != self->end())
|
||||
return i->second;
|
||||
|
|
@ -53,118 +53,17 @@ namespace std {
|
|||
}
|
||||
};
|
||||
|
||||
// Legacy macros (deprecated)
|
||||
%define specialize_std_map_on_key(K,CHECK,CONVERT_FROM,CONVERT_TO)
|
||||
#warning "specialize_std_map_on_key ignored - macro is deprecated and no longer necessary"
|
||||
%enddef
|
||||
|
||||
// specializations for built-ins
|
||||
%define specialize_std_map_on_value(T,CHECK,CONVERT_FROM,CONVERT_TO)
|
||||
#warning "specialize_std_map_on_value ignored - macro is deprecated and no longer necessary"
|
||||
%enddef
|
||||
|
||||
%define specialize_std_map_on_key(K,CHECK,CONVERT_FROM,CONVERT_TO)
|
||||
%define specialize_std_map_on_both(K,CHECK_K,CONVERT_K_FROM,CONVERT_K_TO, T,CHECK_T,CONVERT_T_FROM,CONVERT_T_TO)
|
||||
#warning "specialize_std_map_on_both ignored - macro is deprecated and no longer necessary"
|
||||
%enddef
|
||||
|
||||
template<class T> class map<K,T> {
|
||||
// add typemaps here
|
||||
public:
|
||||
map();
|
||||
map(const map<K,T> &);
|
||||
|
||||
unsigned int size() const;
|
||||
bool empty() const;
|
||||
void clear();
|
||||
%extend {
|
||||
T& get(K key) throw (std::out_of_range) {
|
||||
std::map<K,T >::iterator i = self->find(key);
|
||||
if (i != self->end())
|
||||
return i->second;
|
||||
else
|
||||
throw std::out_of_range("key not found");
|
||||
}
|
||||
void set(K key, const T& x) {
|
||||
(*self)[key] = x;
|
||||
}
|
||||
void del(K key) throw (std::out_of_range) {
|
||||
std::map<K,T >::iterator i = self->find(key);
|
||||
if (i != self->end())
|
||||
self->erase(i);
|
||||
else
|
||||
throw std::out_of_range("key not found");
|
||||
}
|
||||
bool has_key(K key) {
|
||||
std::map<K,T >::iterator i = self->find(key);
|
||||
return i != self->end();
|
||||
}
|
||||
}
|
||||
};
|
||||
%enddef
|
||||
|
||||
%define specialize_std_map_on_value(T,CHECK,CONVERT_FROM,CONVERT_TO)
|
||||
template<class K> class map<K,T> {
|
||||
// add typemaps here
|
||||
public:
|
||||
map();
|
||||
map(const map<K,T> &);
|
||||
|
||||
unsigned int size() const;
|
||||
bool empty() const;
|
||||
void clear();
|
||||
%extend {
|
||||
T get(const K& key) throw (std::out_of_range) {
|
||||
std::map<K,T >::iterator i = self->find(key);
|
||||
if (i != self->end())
|
||||
return i->second;
|
||||
else
|
||||
throw std::out_of_range("key not found");
|
||||
}
|
||||
void set(const K& key, T x) {
|
||||
(*self)[key] = x;
|
||||
}
|
||||
void del(const K& key) throw (std::out_of_range) {
|
||||
std::map<K,T >::iterator i = self->find(key);
|
||||
if (i != self->end())
|
||||
self->erase(i);
|
||||
else
|
||||
throw std::out_of_range("key not found");
|
||||
}
|
||||
bool has_key(const K& key) {
|
||||
std::map<K,T >::iterator i = self->find(key);
|
||||
return i != self->end();
|
||||
}
|
||||
}
|
||||
};
|
||||
%enddef
|
||||
|
||||
%define specialize_std_map_on_both(K,CHECK_K,CONVERT_K_FROM,CONVERT_K_TO,
|
||||
T,CHECK_T,CONVERT_T_FROM,CONVERT_T_TO)
|
||||
template<> class map<K,T> {
|
||||
// add typemaps here
|
||||
public:
|
||||
map();
|
||||
map(const map<K,T> &);
|
||||
|
||||
unsigned int size() const;
|
||||
bool empty() const;
|
||||
void clear();
|
||||
%extend {
|
||||
T get(K key) throw (std::out_of_range) {
|
||||
std::map<K,T >::iterator i = self->find(key);
|
||||
if (i != self->end())
|
||||
return i->second;
|
||||
else
|
||||
throw std::out_of_range("key not found");
|
||||
}
|
||||
void set(K key, T x) {
|
||||
(*self)[key] = x;
|
||||
}
|
||||
void del(K key) throw (std::out_of_range) {
|
||||
std::map<K,T >::iterator i = self->find(key);
|
||||
if (i != self->end())
|
||||
self->erase(i);
|
||||
else
|
||||
throw std::out_of_range("key not found");
|
||||
}
|
||||
bool has_key(K key) {
|
||||
std::map<K,T >::iterator i = self->find(key);
|
||||
return i != self->end();
|
||||
}
|
||||
}
|
||||
};
|
||||
%enddef
|
||||
|
||||
// add specializations here
|
||||
}
|
||||
|
|
|
|||
|
|
@ -314,3 +314,11 @@ SIMPLE_MAP(unsigned long long,caml_val_ulong,caml_long_val);
|
|||
%swig_enum_out(out)
|
||||
%swig_enum_out(varout)
|
||||
%swig_enum_out(directorin)
|
||||
|
||||
|
||||
/* Array reference typemaps */
|
||||
%apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) }
|
||||
|
||||
/* const pointers */
|
||||
%apply SWIGTYPE * { SWIGTYPE *const }
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
%include <shared_ptr.i>
|
||||
|
||||
// Language specific macro implementing all the customisations for handling the smart pointer
|
||||
%define SWIG_SHARED_PTR_TYPEMAPS(PROXYCLASS, CONST, TYPE...)
|
||||
%define SWIG_SHARED_PTR_TYPEMAPS(CONST, TYPE...)
|
||||
|
||||
// %naturalvar is as documented for member variables
|
||||
%naturalvar TYPE;
|
||||
|
|
@ -12,9 +12,6 @@
|
|||
//"if (debug_shared) { cout << \"deleting use_count: \" << (*smartarg1).use_count() << \" [\" << (boost::get_deleter<SWIG_null_deleter>(*smartarg1) ? std::string(\"CANNOT BE DETERMINED SAFELY\") : ( (*smartarg1).get() ? (*smartarg1)->getValue() : std::string(\"NULL PTR\") )) << \"]\" << endl << flush; }\n"
|
||||
"(void)arg1; delete smartarg1;"
|
||||
|
||||
// Feature to adapt the code generated in the swigregister functions for smart pointers
|
||||
%feature("smartptr", noblock=1) TYPE { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > }
|
||||
|
||||
// Typemap customisations...
|
||||
|
||||
// plain value
|
||||
|
|
@ -143,7 +140,7 @@
|
|||
|
||||
// plain pointer by reference
|
||||
// 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;
|
||||
res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem);
|
||||
if (!SWIG_IsOK(res)) {
|
||||
|
|
@ -158,15 +155,15 @@
|
|||
}
|
||||
$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);
|
||||
%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"
|
||||
%}
|
||||
%typemap(varout) CONST TYPE *& %{
|
||||
%typemap(varout) TYPE *CONST& %{
|
||||
#error "varout typemap not implemented"
|
||||
%}
|
||||
|
||||
|
|
@ -283,10 +280,10 @@
|
|||
// 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.
|
||||
%typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER,noblock=1)
|
||||
CONST TYPE,
|
||||
CONST TYPE &,
|
||||
CONST TYPE *,
|
||||
CONST TYPE *&,
|
||||
TYPE CONST,
|
||||
TYPE CONST &,
|
||||
TYPE CONST *,
|
||||
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 > *,
|
||||
|
|
|
|||
|
|
@ -106,6 +106,8 @@ SWIGRUNTIME void SWIG_Octave_SetModule(void *clientdata, swig_module_info *point
|
|||
typedef octave_value_list(*octave_func) (const octave_value_list &, int);
|
||||
class octave_swig_type;
|
||||
|
||||
# define SWIG_DIRECTOR_CAST(ARG) dynamic_cast<Swig::Director *>(ARG)
|
||||
|
||||
namespace Swig {
|
||||
class Director;
|
||||
|
||||
|
|
@ -1130,24 +1132,24 @@ namespace Swig {
|
|||
namespace Swig {
|
||||
class Director {
|
||||
octave_swig_type *self;
|
||||
bool disowned;
|
||||
bool swig_disowned;
|
||||
|
||||
Director(const Director &x);
|
||||
Director &operator=(const Director &rhs);
|
||||
public:
|
||||
|
||||
Director(void *vptr):self(0), disowned(false) {
|
||||
Director(void *vptr):self(0), swig_disowned(false) {
|
||||
set_rtdir(vptr, this);
|
||||
}
|
||||
|
||||
~Director() {
|
||||
swig_director_destroyed(self, this);
|
||||
if (disowned)
|
||||
if (swig_disowned)
|
||||
self->decref();
|
||||
}
|
||||
|
||||
void swig_set_self(octave_swig_type *new_self) {
|
||||
assert(!disowned);
|
||||
assert(!swig_disowned);
|
||||
self = new_self;
|
||||
}
|
||||
|
||||
|
|
@ -1156,9 +1158,9 @@ namespace Swig {
|
|||
}
|
||||
|
||||
void swig_disown() {
|
||||
if (disowned)
|
||||
if (swig_disowned)
|
||||
return;
|
||||
disowned = true;
|
||||
swig_disowned = true;
|
||||
self->incref();
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -32,6 +32,8 @@ SWIGINTERNINLINE octave_value
|
|||
}
|
||||
}
|
||||
|
||||
%ignore std::basic_string::operator +=;
|
||||
|
||||
%include <std/std_basic_string.i>
|
||||
%typemaps_asptrfromn(%checkcode(STRING), std::basic_string<char>);
|
||||
|
||||
|
|
|
|||
|
|
@ -92,10 +92,10 @@
|
|||
};
|
||||
|
||||
template<class OutIterator, class FromOper, class ValueType = typename OutIterator::value_type>
|
||||
struct OctMapIterator_T : SwigPyIteratorClosed_T<OutIterator, ValueType, FromOper>
|
||||
struct OctMapIterator_T : OctSwigIteratorClosed_T<OutIterator, ValueType, FromOper>
|
||||
{
|
||||
OctMapIterator_T(OutIterator curr, OutIterator first, OutIterator last, octave_value seq)
|
||||
: SwigPyIteratorClosed_T<OutIterator,ValueType,FromOper>(curr, first, last, seq)
|
||||
: OctSwigIteratorClosed_T<OutIterator,ValueType,FromOper>(curr, first, last, seq)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
|
@ -112,7 +112,7 @@
|
|||
};
|
||||
|
||||
template<typename OutIter>
|
||||
inline SwigPyIterator*
|
||||
inline OctSwigIterator*
|
||||
make_output_key_iterator(const OutIter& current, const OutIter& begin, const OutIter& end, octave_value seq = octave_value())
|
||||
{
|
||||
return new OctMapKeyIterator_T<OutIter>(current, begin, end, seq);
|
||||
|
|
@ -130,7 +130,7 @@
|
|||
|
||||
|
||||
template<typename OutIter>
|
||||
inline SwigPyIterator*
|
||||
inline OctSwigIterator*
|
||||
make_output_value_iterator(const OutIter& current, const OutIter& begin, const OutIter& end, octave_value seq = 0)
|
||||
{
|
||||
return new OctMapValueIterator_T<OutIter>(current, begin, end, seq);
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@
|
|||
%include <typemaps/swigtypemaps.swg>
|
||||
|
||||
/* ------------------------------------------------------------
|
||||
* Perl extra typemaps
|
||||
* Perl extra typemaps / typemap overrides
|
||||
* ------------------------------------------------------------ */
|
||||
|
||||
%typemap(varout,type="$1_descriptor") SWIGTYPE *, SWIGTYPE []
|
||||
|
|
@ -90,3 +90,6 @@
|
|||
%typemap(varout,type="$1_descriptor") SWIGTYPE (CLASS::*) {
|
||||
SWIG_MakePackedObj($result, (void *) &$1, sizeof($1_type), $1_descriptor);
|
||||
}
|
||||
|
||||
%typemap(varout) SWIGTYPE *const = SWIGTYPE *;
|
||||
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ namespace std {
|
|||
bool empty() const;
|
||||
void clear();
|
||||
%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);
|
||||
if (i != self->end())
|
||||
return i->second;
|
||||
|
|
@ -54,119 +54,17 @@ namespace std {
|
|||
}
|
||||
};
|
||||
|
||||
// Legacy macros (deprecated)
|
||||
%define specialize_std_map_on_key(K,CHECK,CONVERT_FROM,CONVERT_TO)
|
||||
#warning "specialize_std_map_on_key ignored - macro is deprecated and no longer necessary"
|
||||
%enddef
|
||||
|
||||
// specializations for built-ins
|
||||
%define specialize_std_map_on_value(T,CHECK,CONVERT_FROM,CONVERT_TO)
|
||||
#warning "specialize_std_map_on_value ignored - macro is deprecated and no longer necessary"
|
||||
%enddef
|
||||
|
||||
%define specialize_std_map_on_key(K,CHECK,CONVERT_FROM,CONVERT_TO)
|
||||
|
||||
template<class T> class map<K,T> {
|
||||
// add typemaps here
|
||||
public:
|
||||
map();
|
||||
map(const map<K,T> &);
|
||||
|
||||
unsigned int size() const;
|
||||
bool empty() const;
|
||||
void clear();
|
||||
%extend {
|
||||
T& get(K key) throw (std::out_of_range) {
|
||||
std::map<K,T >::iterator i = self->find(key);
|
||||
if (i != self->end())
|
||||
return i->second;
|
||||
else
|
||||
throw std::out_of_range("key not found");
|
||||
}
|
||||
void set(K key, const T& x) {
|
||||
(*self)[key] = x;
|
||||
}
|
||||
void del(K key) throw (std::out_of_range) {
|
||||
std::map<K,T >::iterator i = self->find(key);
|
||||
if (i != self->end())
|
||||
self->erase(i);
|
||||
else
|
||||
throw std::out_of_range("key not found");
|
||||
}
|
||||
bool has_key(K key) {
|
||||
std::map<K,T >::iterator i = self->find(key);
|
||||
return i != self->end();
|
||||
}
|
||||
}
|
||||
};
|
||||
%enddef
|
||||
|
||||
%define specialize_std_map_on_value(T,CHECK,CONVERT_FROM,CONVERT_TO)
|
||||
template<class K> class map<K,T> {
|
||||
// add typemaps here
|
||||
public:
|
||||
map();
|
||||
map(const map<K,T> &);
|
||||
|
||||
unsigned int size() const;
|
||||
bool empty() const;
|
||||
void clear();
|
||||
%extend {
|
||||
T get(const K& key) throw (std::out_of_range) {
|
||||
std::map<K,T >::iterator i = self->find(key);
|
||||
if (i != self->end())
|
||||
return i->second;
|
||||
else
|
||||
throw std::out_of_range("key not found");
|
||||
}
|
||||
void set(const K& key, T x) {
|
||||
(*self)[key] = x;
|
||||
}
|
||||
void del(const K& key) throw (std::out_of_range) {
|
||||
std::map<K,T >::iterator i = self->find(key);
|
||||
if (i != self->end())
|
||||
self->erase(i);
|
||||
else
|
||||
throw std::out_of_range("key not found");
|
||||
}
|
||||
bool has_key(const K& key) {
|
||||
std::map<K,T >::iterator i = self->find(key);
|
||||
return i != self->end();
|
||||
}
|
||||
}
|
||||
};
|
||||
%enddef
|
||||
|
||||
%define specialize_std_map_on_both(K,CHECK_K,CONVERT_K_FROM,CONVERT_K_TO,
|
||||
T,CHECK_T,CONVERT_T_FROM,CONVERT_T_TO)
|
||||
template<> class map<K,T> {
|
||||
// add typemaps here
|
||||
public:
|
||||
map();
|
||||
map(const map<K,T> &);
|
||||
|
||||
unsigned int size() const;
|
||||
bool empty() const;
|
||||
void clear();
|
||||
%extend {
|
||||
T get(K key) throw (std::out_of_range) {
|
||||
std::map<K,T >::iterator i = self->find(key);
|
||||
if (i != self->end())
|
||||
return i->second;
|
||||
else
|
||||
throw std::out_of_range("key not found");
|
||||
}
|
||||
void set(K key, T x) {
|
||||
(*self)[key] = x;
|
||||
}
|
||||
void del(K key) throw (std::out_of_range) {
|
||||
std::map<K,T >::iterator i = self->find(key);
|
||||
if (i != self->end())
|
||||
self->erase(i);
|
||||
else
|
||||
throw std::out_of_range("key not found");
|
||||
}
|
||||
bool has_key(K key) {
|
||||
std::map<K,T >::iterator i = self->find(key);
|
||||
return i != self->end();
|
||||
}
|
||||
}
|
||||
};
|
||||
%enddef
|
||||
|
||||
// add specializations here
|
||||
%define specialize_std_map_on_both(K,CHECK_K,CONVERT_K_FROM,CONVERT_K_TO, T,CHECK_T,CONVERT_T_FROM,CONVERT_T_TO)
|
||||
#warning "specialize_std_map_on_both ignored - macro is deprecated and no longer necessary"
|
||||
%enddef
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -103,19 +103,19 @@ namespace Swig {
|
|||
class Director {
|
||||
protected:
|
||||
zval *swig_self;
|
||||
typedef std::map<void*, GCItem_var> ownership_map;
|
||||
mutable ownership_map owner;
|
||||
typedef std::map<void*, GCItem_var> swig_ownership_map;
|
||||
mutable swig_ownership_map swig_owner;
|
||||
public:
|
||||
Director(zval* self) : swig_self(self) {
|
||||
}
|
||||
|
||||
~Director() {
|
||||
for (ownership_map::iterator i = owner.begin(); i != owner.end(); i++) {
|
||||
owner.erase(i);
|
||||
for (swig_ownership_map::iterator i = swig_owner.begin(); i != swig_owner.end(); i++) {
|
||||
swig_owner.erase(i);
|
||||
}
|
||||
}
|
||||
|
||||
bool is_overriden_method(char *cname, char *lc_fname) {
|
||||
bool swig_is_overridden_method(char *cname, char *lc_fname) {
|
||||
zval classname;
|
||||
zend_class_entry **ce;
|
||||
zend_function *mptr;
|
||||
|
|
@ -136,7 +136,7 @@ namespace Swig {
|
|||
void swig_acquire_ownership(Type *vptr) const
|
||||
{
|
||||
if (vptr) {
|
||||
owner[vptr] = new GCItem_T<Type>(vptr);
|
||||
swig_owner[vptr] = new GCItem_T<Type>(vptr);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -96,19 +96,19 @@
|
|||
MAKE_STD_ZVAL(z_var);
|
||||
z_var->type = IS_STRING;
|
||||
if ($1) {
|
||||
// varinit char [ANY]
|
||||
/* varinit char [ANY] */
|
||||
ZVAL_STRINGL(z_var,(char*)$1, $1_dim0, 1);
|
||||
}
|
||||
zend_hash_add(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void*)&z_var, sizeof(zval *), NULL);
|
||||
}
|
||||
|
||||
%typemap(varinit) SWIGTYPE (CLASS::*)
|
||||
%typemap(varinit, fragment="swig_php_init_member_ptr") SWIGTYPE (CLASS::*)
|
||||
{
|
||||
void * p = emalloc(sizeof($1));
|
||||
memcpy(p, &$1, sizeof($1));
|
||||
zval * resource;
|
||||
MAKE_STD_ZVAL(resource);
|
||||
ZEND_REGISTER_RESOURCE(resource, p, le_member_ptr);
|
||||
ZEND_REGISTER_RESOURCE(resource, p, swig_member_ptr);
|
||||
zend_hash_add(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void*)&resource, sizeof(zval *), NULL);
|
||||
}
|
||||
|
||||
|
|
@ -223,12 +223,12 @@
|
|||
$1 = ($1_ltype)_temp;
|
||||
}
|
||||
|
||||
%typemap(varin) SWIGTYPE (CLASS::*)
|
||||
%typemap(varin, fragment="swig_php_init_member_ptr") SWIGTYPE (CLASS::*)
|
||||
{
|
||||
zval **z_var;
|
||||
|
||||
zend_hash_find(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void**)&z_var);
|
||||
void * p = (void*)zend_fetch_resource(*z_var TSRMLS_CC, -1, SWIG_MEMBER_PTR, NULL, 1, le_member_ptr);
|
||||
void * p = (void*)zend_fetch_resource(*z_var TSRMLS_CC, -1, SWIG_MEMBER_PTR, NULL, 1, swig_member_ptr);
|
||||
memcpy(&$1, p, sizeof($1));
|
||||
}
|
||||
|
||||
|
|
@ -344,12 +344,12 @@ deliberate error cos this code looks bogus to me
|
|||
SWIG_SetPointerZval(*z_var, (void*)$1, $1_descriptor, 0);
|
||||
}
|
||||
|
||||
%typemap(varout) SWIGTYPE (CLASS::*)
|
||||
%typemap(varout, fragment="swig_php_init_member_ptr") SWIGTYPE (CLASS::*)
|
||||
{
|
||||
void * p = emalloc(sizeof($1));
|
||||
memcpy(p, &$1, sizeof($1));
|
||||
zval * resource;
|
||||
MAKE_STD_ZVAL(resource);
|
||||
ZEND_REGISTER_RESOURCE(resource, p, le_member_ptr);
|
||||
ZEND_REGISTER_RESOURCE(resource, p, swig_member_ptr);
|
||||
zend_hash_add(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void*)&resource, sizeof(zval *), NULL);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
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
|
||||
|
|
@ -339,7 +339,7 @@
|
|||
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);
|
||||
%}
|
||||
|
|
@ -351,20 +351,20 @@
|
|||
SWIG_SetPointerZval($input, (void *)&$1_name, $1_descriptor, $owner);
|
||||
%}
|
||||
|
||||
%typemap(out) SWIGTYPE (CLASS::*)
|
||||
%typemap(out, fragment="swig_php_init_member_ptr") SWIGTYPE (CLASS::*)
|
||||
{
|
||||
void * p = emalloc(sizeof($1));
|
||||
memcpy(p, &$1, sizeof($1));
|
||||
zval * resource;
|
||||
MAKE_STD_ZVAL(resource);
|
||||
ZEND_REGISTER_RESOURCE(resource, p, le_member_ptr);
|
||||
ZEND_REGISTER_RESOURCE(resource, p, swig_member_ptr);
|
||||
|
||||
SWIG_SetPointerZval(return_value, (void *)&$1, $1_descriptor, $owner);
|
||||
}
|
||||
|
||||
%typemap(in) SWIGTYPE (CLASS::*)
|
||||
%typemap(in, fragment="swig_php_init_member_ptr") SWIGTYPE (CLASS::*)
|
||||
{
|
||||
void * p = (void*)zend_fetch_resource($input TSRMLS_CC, -1, SWIG_MEMBER_PTR, NULL, 1, le_member_ptr);
|
||||
void * p = (void*)zend_fetch_resource($input TSRMLS_CC, -1, SWIG_MEMBER_PTR, NULL, 1, swig_member_ptr);
|
||||
memcpy(&$1, p, sizeof($1));
|
||||
}
|
||||
|
||||
|
|
@ -394,10 +394,6 @@
|
|||
SWIG_SetPointerZval($input, SWIG_as_voidptr(&$1_name), $&1_descriptor, 2);
|
||||
}
|
||||
|
||||
/* Array reference typemaps */
|
||||
%apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) }
|
||||
|
||||
|
||||
%typemap(out) void "";
|
||||
|
||||
%typemap(out) char [ANY]
|
||||
|
|
@ -441,10 +437,11 @@
|
|||
_v = (SWIG_ConvertPtr(*$input, (void **)&tmp, $&1_descriptor, 0) >= 0);
|
||||
}
|
||||
|
||||
%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE *,
|
||||
%typecheck(SWIG_TYPECHECK_POINTER)
|
||||
SWIGTYPE *,
|
||||
SWIGTYPE [],
|
||||
SWIGTYPE &,
|
||||
SWIGTYPE *&
|
||||
SWIGTYPE *const&
|
||||
{
|
||||
void *tmp;
|
||||
_v = (SWIG_ConvertPtr(*$input, (void**)&tmp, $1_descriptor, 0) >= 0);
|
||||
|
|
@ -464,20 +461,27 @@
|
|||
unsigned int,
|
||||
unsigned long,
|
||||
unsigned short {
|
||||
char error_msg[256];
|
||||
sprintf(error_msg, "C++ $1_type exception thrown, value: %d", $1);
|
||||
SWIG_PHP_Error(E_ERROR, error_msg);
|
||||
zend_throw_exception(NULL, const_cast<char*>("C++ $1_type exception thrown"), $1 TSRMLS_CC);
|
||||
return;
|
||||
}
|
||||
|
||||
%typemap(throws) SWIGTYPE, SWIGTYPE &, SWIGTYPE *, SWIGTYPE [], SWIGTYPE [ANY] %{
|
||||
(void)$1;
|
||||
SWIG_PHP_Error(E_ERROR, "C++ $1_type exception thrown");
|
||||
zend_throw_exception(NULL, const_cast<char*>("C++ $1_type exception thrown"), 0 TSRMLS_CC);
|
||||
return;
|
||||
%}
|
||||
|
||||
%typemap(throws) char * %{
|
||||
SWIG_PHP_Error(E_ERROR, (char *)$1);
|
||||
zend_throw_exception(NULL, const_cast<char*>($1), 0 TSRMLS_CC);
|
||||
return;
|
||||
%}
|
||||
|
||||
/* Array reference typemaps */
|
||||
%apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) }
|
||||
|
||||
/* const pointers */
|
||||
%apply SWIGTYPE * { SWIGTYPE *const }
|
||||
|
||||
|
||||
/* php keywords */
|
||||
%include <phpkw.swg>
|
||||
|
|
|
|||
|
|
@ -8,6 +8,18 @@
|
|||
%init %{
|
||||
SWIG_php_minit {
|
||||
SWIG_InitializeModule(0);
|
||||
le_member_ptr = zend_register_list_destructors_ex(member_ptr_dtor, NULL, SWIG_MEMBER_PTR, module_number);
|
||||
%}
|
||||
|
||||
%fragment("swig_php_init_member_ptr2", "header") {
|
||||
#define SWIG_MEMBER_PTR ((char*)"CLASS::*")
|
||||
|
||||
static void swig_member_ptr_dtor(zend_rsrc_list_entry *rsrc TSRMLS_DC) {
|
||||
efree(rsrc->ptr);
|
||||
}
|
||||
|
||||
static int swig_member_ptr = 0;
|
||||
}
|
||||
|
||||
%fragment("swig_php_init_member_ptr", "init", fragment="swig_php_init_member_ptr2") {
|
||||
swig_member_ptr = zend_register_list_destructors_ex(swig_member_ptr_dtor, NULL, SWIG_MEMBER_PTR, module_number);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ extern "C" {
|
|||
#endif
|
||||
#include "zend.h"
|
||||
#include "zend_API.h"
|
||||
#include "zend_exceptions.h"
|
||||
#include "php.h"
|
||||
#include "ext/standard/php_string.h"
|
||||
|
||||
|
|
@ -23,11 +24,11 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
#ifndef Z_SET_ISREF_P
|
||||
// For PHP < 5.3
|
||||
/* For PHP < 5.3 */
|
||||
# define Z_SET_ISREF_P(z) (z)->is_ref = 1
|
||||
#endif
|
||||
#ifndef Z_SET_REFCOUNT_P
|
||||
// For PHP < 5.3
|
||||
/* For PHP < 5.3 */
|
||||
# define Z_SET_REFCOUNT_P(z, rc) (z)->refcount = (rc)
|
||||
#endif
|
||||
|
||||
|
|
@ -258,12 +259,3 @@ static void SWIG_Php_SetModule(swig_module_info *pointer) {
|
|||
TSRMLS_FETCH();
|
||||
REGISTER_MAIN_LONG_CONSTANT(const_name, (long) pointer, 0);
|
||||
}
|
||||
|
||||
#define SWIG_MEMBER_PTR ((char*)"CLASS::*")
|
||||
|
||||
static void member_ptr_dtor(zend_rsrc_list_entry *rsrc TSRMLS_DC) {
|
||||
efree(rsrc->ptr);
|
||||
}
|
||||
|
||||
static int le_member_ptr;
|
||||
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ namespace std {
|
|||
unsigned int size() const;
|
||||
void clear();
|
||||
%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);
|
||||
if (i != self->end())
|
||||
return i->second;
|
||||
|
|
@ -56,125 +56,17 @@ namespace std {
|
|||
}
|
||||
};
|
||||
|
||||
// Legacy macros (deprecated)
|
||||
%define specialize_std_map_on_key(K,CHECK,CONVERT_FROM,CONVERT_TO)
|
||||
#warning "specialize_std_map_on_key ignored - macro is deprecated and no longer necessary"
|
||||
%enddef
|
||||
|
||||
// specializations for built-ins
|
||||
%define specialize_std_map_on_value(T,CHECK,CONVERT_FROM,CONVERT_TO)
|
||||
#warning "specialize_std_map_on_value ignored - macro is deprecated and no longer necessary"
|
||||
%enddef
|
||||
|
||||
%define specialize_std_map_on_key(K,CHECK,CONVERT_FROM,CONVERT_TO)
|
||||
|
||||
template<class T> class map<K,T> {
|
||||
// add typemaps here
|
||||
public:
|
||||
map();
|
||||
map(const map<K,T> &);
|
||||
|
||||
unsigned int size() const;
|
||||
void clear();
|
||||
%extend {
|
||||
T& get(K key) throw (std::out_of_range) {
|
||||
std::map<K,T >::iterator i = self->find(key);
|
||||
if (i != self->end())
|
||||
return i->second;
|
||||
else
|
||||
throw std::out_of_range("key not found");
|
||||
}
|
||||
void set(K key, const T& x) {
|
||||
(*self)[key] = x;
|
||||
}
|
||||
void del(K key) throw (std::out_of_range) {
|
||||
std::map<K,T >::iterator i = self->find(key);
|
||||
if (i != self->end())
|
||||
self->erase(i);
|
||||
else
|
||||
throw std::out_of_range("key not found");
|
||||
}
|
||||
bool has_key(K key) {
|
||||
std::map<K,T >::iterator i = self->find(key);
|
||||
return i != self->end();
|
||||
}
|
||||
bool is_empty() const {
|
||||
return self->empty();
|
||||
}
|
||||
}
|
||||
};
|
||||
%enddef
|
||||
|
||||
%define specialize_std_map_on_value(T,CHECK,CONVERT_FROM,CONVERT_TO)
|
||||
template<class K> class map<K,T> {
|
||||
// add typemaps here
|
||||
public:
|
||||
map();
|
||||
map(const map<K,T> &);
|
||||
|
||||
unsigned int size() const;
|
||||
void clear();
|
||||
%extend {
|
||||
T get(const K& key) throw (std::out_of_range) {
|
||||
std::map<K,T >::iterator i = self->find(key);
|
||||
if (i != self->end())
|
||||
return i->second;
|
||||
else
|
||||
throw std::out_of_range("key not found");
|
||||
}
|
||||
void set(const K& key, T x) {
|
||||
(*self)[key] = x;
|
||||
}
|
||||
void del(const K& key) throw (std::out_of_range) {
|
||||
std::map<K,T >::iterator i = self->find(key);
|
||||
if (i != self->end())
|
||||
self->erase(i);
|
||||
else
|
||||
throw std::out_of_range("key not found");
|
||||
}
|
||||
bool has_key(const K& key) {
|
||||
std::map<K,T >::iterator i = self->find(key);
|
||||
return i != self->end();
|
||||
}
|
||||
bool is_empty() const {
|
||||
return self->empty();
|
||||
}
|
||||
}
|
||||
};
|
||||
%enddef
|
||||
|
||||
%define specialize_std_map_on_both(K,CHECK_K,CONVERT_K_FROM,CONVERT_K_TO,
|
||||
T,CHECK_T,CONVERT_T_FROM,CONVERT_T_TO)
|
||||
template<> class map<K,T> {
|
||||
// add typemaps here
|
||||
public:
|
||||
map();
|
||||
map(const map<K,T> &);
|
||||
|
||||
unsigned int size() const;
|
||||
void clear();
|
||||
%extend {
|
||||
T get(K key) throw (std::out_of_range) {
|
||||
std::map<K,T >::iterator i = self->find(key);
|
||||
if (i != self->end())
|
||||
return i->second;
|
||||
else
|
||||
throw std::out_of_range("key not found");
|
||||
}
|
||||
void set(K key, T x) {
|
||||
(*self)[key] = x;
|
||||
}
|
||||
void del(K key) throw (std::out_of_range) {
|
||||
std::map<K,T >::iterator i = self->find(key);
|
||||
if (i != self->end())
|
||||
self->erase(i);
|
||||
else
|
||||
throw std::out_of_range("key not found");
|
||||
}
|
||||
bool has_key(K key) {
|
||||
std::map<K,T >::iterator i = self->find(key);
|
||||
return i != self->end();
|
||||
}
|
||||
bool is_empty() const {
|
||||
return self->empty();
|
||||
}
|
||||
}
|
||||
};
|
||||
%enddef
|
||||
|
||||
// add specializations here
|
||||
%define specialize_std_map_on_both(K,CHECK_K,CONVERT_K_FROM,CONVERT_K_TO, T,CHECK_T,CONVERT_T_FROM,CONVERT_T_TO)
|
||||
#warning "specialize_std_map_on_both ignored - macro is deprecated and no longer necessary"
|
||||
%enddef
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,8 +23,8 @@ namespace std {
|
|||
|
||||
class string;
|
||||
|
||||
%typemap(typecheck,precedence=SWIG_TYPECHECK_STRING) string %{
|
||||
$1 = ( Z_TYPE_PP($input) == IS_STRING ) ? 1 : 0;
|
||||
%typemap(typecheck,precedence=SWIG_TYPECHECK_STRING) string, const string& %{
|
||||
$1 = ( Z_TYPE_PP($input) == IS_STRING ) ? 1 : 0;
|
||||
%}
|
||||
|
||||
%typemap(in) string %{
|
||||
|
|
@ -37,15 +37,11 @@ namespace std {
|
|||
$result.assign(Z_STRVAL_PP($input), Z_STRLEN_PP($input));
|
||||
%}
|
||||
|
||||
%typemap(typecheck,precedence=SWIG_TYPECHECK_STRING) const string& %{
|
||||
$1 = ( Z_TYPE_PP($input) == IS_STRING ) ? 1 : 0;
|
||||
%}
|
||||
|
||||
%typemap(out) string %{
|
||||
ZVAL_STRINGL($result, const_cast<char*>($1.data()), $1.size(), 1);
|
||||
%}
|
||||
|
||||
%typemap(directorin) string %{
|
||||
%typemap(directorin) string, const string& %{
|
||||
ZVAL_STRINGL($input, const_cast<char*>($1_name.data()), $1_name.size(), 1);
|
||||
%}
|
||||
|
||||
|
|
@ -53,12 +49,9 @@ namespace std {
|
|||
ZVAL_STRINGL($result, const_cast<char*>($1->data()), $1->size(), 1);
|
||||
%}
|
||||
|
||||
%typemap(throws) string %{
|
||||
SWIG_PHP_Error(E_ERROR, (char *)$1.c_str());
|
||||
%}
|
||||
|
||||
%typemap(throws) const string& %{
|
||||
SWIG_PHP_Error(E_ERROR, (char *)$1.c_str());
|
||||
%typemap(throws) string, const string& %{
|
||||
zend_throw_exception(NULL, const_cast<char*>($1.c_str()), 0 TSRMLS_CC);
|
||||
return;
|
||||
%}
|
||||
|
||||
/* These next two handle a function which takes a non-const reference to
|
||||
|
|
@ -71,8 +64,7 @@ namespace std {
|
|||
|
||||
%typemap(directorout) string & (std::string *temp) %{
|
||||
convert_to_string_ex($input);
|
||||
temp = new std::string;
|
||||
temp->assign(Z_STRVAL_PP($input), Z_STRLEN_PP($input));
|
||||
temp = new std::string(Z_STRVAL_PP($input), Z_STRLEN_PP($input));
|
||||
swig_acquire_ownership(temp);
|
||||
$result = temp;
|
||||
%}
|
||||
|
|
|
|||
|
|
@ -264,6 +264,12 @@ extern "C" {
|
|||
}
|
||||
}
|
||||
|
||||
/* Array reference typemaps */
|
||||
%apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) }
|
||||
|
||||
/* const pointers */
|
||||
%apply SWIGTYPE * { SWIGTYPE *const }
|
||||
|
||||
/* ------------------------------------------------------------
|
||||
* Overloaded operator support
|
||||
* ------------------------------------------------------------ */
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ SWIG_AsArgcArgv(PyObject *input,
|
|||
}
|
||||
|
||||
/*
|
||||
This typemap works with either a char**, a python list or a python
|
||||
This typemap works with either a char **, a python list or a python
|
||||
tuple
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
#endif
|
||||
|
||||
// Language specific macro implementing all the customisations for handling the smart pointer
|
||||
%define SWIG_SHARED_PTR_TYPEMAPS(PROXYCLASS, CONST, TYPE...)
|
||||
%define SWIG_SHARED_PTR_TYPEMAPS(CONST, TYPE...)
|
||||
|
||||
// %naturalvar is as documented for member variables
|
||||
%naturalvar TYPE;
|
||||
|
|
@ -18,9 +18,6 @@
|
|||
//"if (debug_shared) { cout << \"deleting use_count: \" << (*smartarg1).use_count() << \" [\" << (boost::get_deleter<SWIG_null_deleter>(*smartarg1) ? std::string(\"CANNOT BE DETERMINED SAFELY\") : ( (*smartarg1).get() ? (*smartarg1)->getValue() : std::string(\"NULL PTR\") )) << \"]\" << endl << flush; }\n"
|
||||
"(void)arg1; delete smartarg1;"
|
||||
|
||||
// Feature to adapt the code generated in the swigregister functions for smart pointers
|
||||
%feature("smartptr", noblock=1) TYPE { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > }
|
||||
|
||||
// Typemap customisations...
|
||||
|
||||
// plain value
|
||||
|
|
@ -151,7 +148,7 @@
|
|||
|
||||
// plain pointer by reference
|
||||
// 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;
|
||||
res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SHARED_PTR_DISOWN | %convertptr_flags, &newmem);
|
||||
if (!SWIG_IsOK(res)) {
|
||||
|
|
@ -166,15 +163,15 @@
|
|||
}
|
||||
$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);
|
||||
%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"
|
||||
%}
|
||||
%typemap(varout) CONST TYPE *& %{
|
||||
%typemap(varout) TYPE *CONST& %{
|
||||
#error "varout typemap not implemented"
|
||||
%}
|
||||
|
||||
|
|
@ -291,10 +288,10 @@
|
|||
// 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.
|
||||
%typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER,noblock=1)
|
||||
CONST TYPE,
|
||||
CONST TYPE &,
|
||||
CONST TYPE *,
|
||||
CONST TYPE *&,
|
||||
TYPE CONST,
|
||||
TYPE CONST &,
|
||||
TYPE CONST *,
|
||||
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 > *,
|
||||
|
|
|
|||
|
|
@ -85,13 +85,13 @@ namespace Swig {
|
|||
}
|
||||
# endif /* SWIG_DIRECTOR_RTDIR */
|
||||
|
||||
# define SWIG_DIRECTOR_CAST(Arg) Swig::get_rtdir(static_cast<void*>(Arg))
|
||||
# define SWIG_DIRECTOR_RGTR(Arg1, Arg2) Swig::set_rtdir(static_cast<void*>(Arg1), Arg2)
|
||||
# define SWIG_DIRECTOR_CAST(ARG) Swig::get_rtdir(static_cast<void*>(ARG))
|
||||
# define SWIG_DIRECTOR_RGTR(ARG1, ARG2) Swig::set_rtdir(static_cast<void*>(ARG1), ARG2)
|
||||
|
||||
#else
|
||||
|
||||
# define SWIG_DIRECTOR_CAST(Arg) dynamic_cast<Swig::Director*>(Arg)
|
||||
# define SWIG_DIRECTOR_RGTR(Arg1, Arg2)
|
||||
# define SWIG_DIRECTOR_CAST(ARG) dynamic_cast<Swig::Director *>(ARG)
|
||||
# define SWIG_DIRECTOR_RGTR(ARG1, ARG2)
|
||||
|
||||
#endif /* SWIG_DIRECTOR_NORTTI */
|
||||
|
||||
|
|
@ -404,17 +404,17 @@ namespace Swig {
|
|||
}
|
||||
|
||||
/* methods to implement pseudo protected director members */
|
||||
virtual bool swig_get_inner(const char* /* name */) const {
|
||||
virtual bool swig_get_inner(const char* /* protected_method_name */) const {
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual void swig_set_inner(const char* /* name */, bool /* val */) const {
|
||||
virtual void swig_set_inner(const char* /* protected_method_name */, bool /* val */) const {
|
||||
}
|
||||
|
||||
/* ownership management */
|
||||
private:
|
||||
typedef std::map<void*, GCItem_var> ownership_map;
|
||||
mutable ownership_map owner;
|
||||
typedef std::map<void*, GCItem_var> swig_ownership_map;
|
||||
mutable swig_ownership_map swig_owner;
|
||||
#ifdef __THREAD__
|
||||
static PyThread_type_lock swig_mutex_own;
|
||||
#endif
|
||||
|
|
@ -425,7 +425,7 @@ namespace Swig {
|
|||
{
|
||||
if (vptr) {
|
||||
SWIG_GUARD(swig_mutex_own);
|
||||
owner[vptr] = new GCArray_T<Type>(vptr);
|
||||
swig_owner[vptr] = new GCArray_T<Type>(vptr);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -434,7 +434,7 @@ namespace Swig {
|
|||
{
|
||||
if (vptr) {
|
||||
SWIG_GUARD(swig_mutex_own);
|
||||
owner[vptr] = new GCItem_T<Type>(vptr);
|
||||
swig_owner[vptr] = new GCItem_T<Type>(vptr);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -442,7 +442,7 @@ namespace Swig {
|
|||
{
|
||||
if (vptr && own) {
|
||||
SWIG_GUARD(swig_mutex_own);
|
||||
owner[vptr] = new GCItem_Object(own);
|
||||
swig_owner[vptr] = new GCItem_Object(own);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -451,10 +451,10 @@ namespace Swig {
|
|||
int own = 0;
|
||||
if (vptr) {
|
||||
SWIG_GUARD(swig_mutex_own);
|
||||
ownership_map::iterator iter = owner.find(vptr);
|
||||
if (iter != owner.end()) {
|
||||
swig_ownership_map::iterator iter = swig_owner.find(vptr);
|
||||
if (iter != swig_owner.end()) {
|
||||
own = iter->second->get_own();
|
||||
owner.erase(iter);
|
||||
swig_owner.erase(iter);
|
||||
}
|
||||
}
|
||||
return own;
|
||||
|
|
|
|||
|
|
@ -3,13 +3,13 @@
|
|||
|
||||
#ifdef SWIG_DOC_DOXYGEN_STYLE
|
||||
%typemap(doc) SWIGTYPE "@param $1_name $1_type value";
|
||||
%typemap(doc) SWIGTYPE* "@param $1_name $1_type value";
|
||||
%typemap(doc) const SWIGTYPE& "@param $1_name $1_type value";
|
||||
%typemap(doc) SWIGTYPE * "@param $1_name $1_type value";
|
||||
%typemap(doc) const SWIGTYPE & "@param $1_name $1_type value";
|
||||
%typemap(doc) enum SWIGTYPE "@param $1_name enum $1_type value";
|
||||
#else
|
||||
%typemap(doc) SWIGTYPE "$1_name: $1_type value";
|
||||
%typemap(doc) SWIGTYPE* "$1_name: $1_type value";
|
||||
%typemap(doc) const SWIGTYPE& "$1_name: $1_type value";
|
||||
%typemap(doc) SWIGTYPE * "$1_name: $1_type value";
|
||||
%typemap(doc) const SWIGTYPE & "$1_name: $1_type value";
|
||||
%typemap(doc) enum SWIGTYPE "$1_name: enum $1_type value";
|
||||
|
||||
%typemap(doc) SWIGTYPE *INOUT "$1_name: $1_type input/ouput value";
|
||||
|
|
|
|||
|
|
@ -275,10 +275,10 @@ namespace swig {
|
|||
SwigPyIterator *decr(size_t n = 1)
|
||||
{
|
||||
while (n--) {
|
||||
if (base::current == begin) {
|
||||
throw stop_iteration();
|
||||
if (base::current == begin) {
|
||||
throw stop_iteration();
|
||||
} else {
|
||||
--base::current;
|
||||
--base::current;
|
||||
}
|
||||
}
|
||||
return this;
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@
|
|||
|
||||
|
||||
/* ------------------------------------------------------------
|
||||
* Python extra typemaps
|
||||
* Python extra typemaps / typemap overrides
|
||||
* ------------------------------------------------------------ */
|
||||
|
||||
/* Get the address of the 'python self' object */
|
||||
|
|
|
|||
2
Lib/python/std_shared_ptr.i
Normal file
2
Lib/python/std_shared_ptr.i
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
#define SWIG_SHARED_PTR_NAMESPACE std
|
||||
%include <boost_shared_ptr.i>
|
||||
|
|
@ -144,11 +144,11 @@ SWIG_InitializeModule(0);
|
|||
$1 = %reinterpret_cast(INTEGER($input), $1_ltype);
|
||||
}
|
||||
|
||||
%typemap(in,noblock=1,fragment="SWIG_strdup") char* {
|
||||
%typemap(in,noblock=1,fragment="SWIG_strdup") char * {
|
||||
$1 = %reinterpret_cast(SWIG_strdup(CHAR(STRING_ELT($input, 0))), $1_ltype);
|
||||
}
|
||||
|
||||
%typemap(freearg,noblock=1) char* {
|
||||
%typemap(freearg,noblock=1) char * {
|
||||
free($1);
|
||||
}
|
||||
|
||||
|
|
@ -189,7 +189,7 @@ else
|
|||
strcpy($1, "");
|
||||
%}
|
||||
|
||||
%typemap(out,noblock=1) char*
|
||||
%typemap(out,noblock=1) char *
|
||||
{ $result = $1 ? Rf_mkString(%reinterpret_cast($1,char *)) : R_NilValue; }
|
||||
|
||||
%typemap(in,noblock=1) char {
|
||||
|
|
|
|||
|
|
@ -122,7 +122,7 @@ SWIGINTERN int
|
|||
SWIG_AsCharPtrAndSize(SEXP obj, char** cptr, size_t* psize, int *alloc)
|
||||
{
|
||||
if (cptr && Rf_isString(obj)) {
|
||||
const char *cstr = CHAR(STRING_ELT(obj, 0));
|
||||
char *cstr = %const_cast(CHAR(STRING_ELT(obj, 0)), char *);
|
||||
int len = strlen(cstr);
|
||||
|
||||
if (alloc) {
|
||||
|
|
@ -130,9 +130,7 @@ SWIG_AsCharPtrAndSize(SEXP obj, char** cptr, size_t* psize, int *alloc)
|
|||
*cptr = %new_copy_array(cstr, len + 1, char);
|
||||
*alloc = SWIG_NEWOBJ;
|
||||
} else {
|
||||
*cptr = %reinterpret_cast(malloc(len + 1), char *);
|
||||
*cptr = strcpy(*cptr, cstr);
|
||||
*alloc = SWIG_OLDOBJ;
|
||||
*cptr = cstr;
|
||||
}
|
||||
} else {
|
||||
*cptr = %reinterpret_cast(malloc(len + 1), char *);
|
||||
|
|
@ -164,9 +162,20 @@ SWIG_FromCharPtrAndSize(const char* carray, size_t size)
|
|||
{
|
||||
SEXP t, c;
|
||||
if (!carray) return R_NilValue;
|
||||
/* See R internals document 1.10.
|
||||
MkCharLen was introduced in 2.7.0. Use that instead of hand
|
||||
creating vector.
|
||||
|
||||
Starting in 2.8.0 creating strings via vectors was deprecated in
|
||||
order to allow for use of CHARSXP caches. */
|
||||
|
||||
Rf_protect(t = Rf_allocVector(STRSXP, 1));
|
||||
#if R_VERSION >= R_Version(2,7,0)
|
||||
c = Rf_mkCharLen(carray, size);
|
||||
#else
|
||||
c = Rf_allocVector(CHARSXP, size);
|
||||
strncpy((char *)CHAR(c), carray, size);
|
||||
#endif
|
||||
SET_STRING_ELT(t, 0, c);
|
||||
Rf_unprotect(1);
|
||||
return t;
|
||||
|
|
|
|||
|
|
@ -29,8 +29,10 @@
|
|||
%typemap("rtype") bool, bool * "logical";
|
||||
%typemap("rtype") enum SWIGTYPE "character";
|
||||
%typemap("rtype") enum SWIGTYPE * "character";
|
||||
%typemap("rtype") enum SWIGTYPE *const "character";
|
||||
%typemap("rtype") enum SWIGTYPE & "character";
|
||||
%typemap("rtype") SWIGTYPE * "$R_class";
|
||||
%typemap("rtype") SWIGTYPE *const "$R_class";
|
||||
%typemap("rtype") SWIGTYPE & "$R_class";
|
||||
%typemap("rtype") SWIGTYPE "$&R_class";
|
||||
|
||||
|
|
@ -65,13 +67,15 @@
|
|||
%{ $input = enumToInteger($input, "$R_class"); %}
|
||||
%typemap(scoercein) enum SWIGTYPE *
|
||||
%{ $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") %}
|
||||
|
||||
%typemap(scoercein) SWIGTYPE &
|
||||
|
|
@ -115,6 +119,9 @@ string &, std::string &
|
|||
%typemap(scoerceout) enum SWIGTYPE *
|
||||
%{ $result = enumToInteger($result, "$R_class"); %}
|
||||
|
||||
%typemap(scoerceout) enum SWIGTYPE *const
|
||||
%{ $result = enumToInteger($result, "$R_class"); %}
|
||||
|
||||
|
||||
%typemap(scoerceout) SWIGTYPE
|
||||
%{ class($result) <- "$&R_class"; %}
|
||||
|
|
@ -125,6 +132,9 @@ string &, std::string &
|
|||
%typemap(scoerceout) SWIGTYPE *
|
||||
%{ class($result) <- "$R_class"; %}
|
||||
|
||||
%typemap(scoerceout) SWIGTYPE *const
|
||||
%{ class($result) <- "$R_class"; %}
|
||||
|
||||
/* Override the SWIGTYPE * above. */
|
||||
%typemap(scoerceout) char,
|
||||
char *,
|
||||
|
|
|
|||
|
|
@ -21,6 +21,8 @@
|
|||
#include <iostream>
|
||||
#include <map>
|
||||
|
||||
# define SWIG_DIRECTOR_CAST(ARG) dynamic_cast<Swig::Director *>(ARG)
|
||||
|
||||
namespace Swig {
|
||||
/* memory handler */
|
||||
struct GCItem
|
||||
|
|
@ -325,8 +327,8 @@ namespace Swig {
|
|||
|
||||
/* ownership management */
|
||||
private:
|
||||
typedef std::map<void*, GCItem_var> ownership_map;
|
||||
mutable ownership_map owner;
|
||||
typedef std::map<void*, GCItem_var> swig_ownership_map;
|
||||
mutable swig_ownership_map swig_owner;
|
||||
#ifdef __PTHREAD__
|
||||
static pthread_mutex_t swig_mutex_own;
|
||||
#endif
|
||||
|
|
@ -337,7 +339,7 @@ namespace Swig {
|
|||
{
|
||||
if (vptr) {
|
||||
SWIG_GUARD(swig_mutex_own);
|
||||
owner[vptr] = new GCArray_T<Type>(vptr);
|
||||
swig_owner[vptr] = new GCArray_T<Type>(vptr);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -346,7 +348,7 @@ namespace Swig {
|
|||
{
|
||||
if (vptr) {
|
||||
SWIG_GUARD(swig_mutex_own);
|
||||
owner[vptr] = new GCItem_T<Type>(vptr);
|
||||
swig_owner[vptr] = new GCItem_T<Type>(vptr);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -354,7 +356,7 @@ namespace Swig {
|
|||
{
|
||||
if (vptr && own) {
|
||||
SWIG_GUARD(swig_mutex_own);
|
||||
owner[vptr] = new GCItem_Object(own);
|
||||
swig_owner[vptr] = new GCItem_Object(own);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -363,10 +365,10 @@ namespace Swig {
|
|||
ruby_owntype own = 0;
|
||||
if (vptr) {
|
||||
SWIG_GUARD(swig_mutex_own);
|
||||
ownership_map::iterator iter = owner.find(vptr);
|
||||
if (iter != owner.end()) {
|
||||
swig_ownership_map::iterator iter = swig_owner.find(vptr);
|
||||
if (iter != swig_owner.end()) {
|
||||
own = iter->second->get_own();
|
||||
owner.erase(iter);
|
||||
swig_owner.erase(iter);
|
||||
}
|
||||
}
|
||||
return own;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
// This is a helper file for shared_ptr and should not be included directly.
|
||||
|
||||
// The main implementation detail in using this smart pointer of a type is to customise the code generated
|
||||
// to use a pointer to the smart pointer of the type, rather than the usual pointer to the underlying type.
|
||||
// So for some type T, shared_ptr<T> * is used rather than T *.
|
||||
|
|
@ -40,26 +42,23 @@ struct SWIG_null_deleter {
|
|||
}
|
||||
|
||||
|
||||
// Workaround empty first macro argument bug
|
||||
#define SWIGEMPTYHACK
|
||||
// Main user macro for defining shared_ptr typemaps for both const and non-const pointer types
|
||||
// For plain classes, do not use for derived classes
|
||||
%define %shared_ptr(TYPE...)
|
||||
%feature("smartptr", noblock=1) TYPE { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > }
|
||||
SWIG_SHARED_PTR_TYPEMAPS(SWIGEMPTYHACK, TYPE)
|
||||
SWIG_SHARED_PTR_TYPEMAPS(const, TYPE)
|
||||
%enddef
|
||||
|
||||
// Legacy macros
|
||||
%define SWIG_SHARED_PTR(PROXYCLASS, TYPE...)
|
||||
SWIG_SHARED_PTR_TYPEMAPS(PROXYCLASS, , TYPE)
|
||||
SWIG_SHARED_PTR_TYPEMAPS(PROXYCLASS, const, TYPE)
|
||||
#warning "SWIG_SHARED_PTR(PROXYCLASS, TYPE) is deprecated. Please use %shared_ptr(TYPE) instead."
|
||||
%shared_ptr(TYPE)
|
||||
%enddef
|
||||
|
||||
// Main user macro for defining shared_ptr typemaps for both const and non-const pointer types
|
||||
// For derived classes
|
||||
%define SWIG_SHARED_PTR_DERIVED(PROXYCLASS, BASECLASSTYPE, TYPE...)
|
||||
SWIG_SHARED_PTR_TYPEMAPS(PROXYCLASS, , TYPE)
|
||||
SWIG_SHARED_PTR_TYPEMAPS(PROXYCLASS, const, TYPE)
|
||||
%types(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > = SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< BASECLASSTYPE >) %{
|
||||
*newmemory = SWIG_CAST_NEW_MEMORY;
|
||||
return (void *) new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< BASECLASSTYPE >(*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *)$from);
|
||||
%}
|
||||
%extend TYPE {
|
||||
static SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< BASECLASSTYPE > SWIGSharedPtrUpcast(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > swigSharedPtrUpcast) {
|
||||
return swigSharedPtrUpcast;
|
||||
}
|
||||
}
|
||||
#warning "SWIG_SHARED_PTR_DERIVED(PROXYCLASS, BASECLASSTYPE, TYPE) is deprecated. Please use %shared_ptr(TYPE) instead."
|
||||
%shared_ptr(TYPE)
|
||||
%enddef
|
||||
|
||||
|
|
|
|||
|
|
@ -138,11 +138,11 @@ namespace std {
|
|||
// const pointer specialization
|
||||
// ***
|
||||
template<class _Tp, class _Alloc >
|
||||
class vector<const _Tp *, _Alloc > {
|
||||
class vector<_Tp const *, _Alloc > {
|
||||
public:
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef const _Tp * value_type;
|
||||
typedef _Tp const * value_type;
|
||||
typedef value_type* pointer;
|
||||
typedef const value_type* const_pointer;
|
||||
typedef value_type reference;
|
||||
|
|
@ -151,32 +151,32 @@ namespace std {
|
|||
|
||||
%traits_swigtype(_Tp);
|
||||
|
||||
%fragment(SWIG_Traits_frag(std::vector<const _Tp *, _Alloc >), "header",
|
||||
%fragment(SWIG_Traits_frag(std::vector<_Tp const*, _Alloc >), "header",
|
||||
fragment=SWIG_Traits_frag(_Tp),
|
||||
fragment="StdVectorTraits") {
|
||||
namespace swig {
|
||||
template <> struct traits<std::vector<const _Tp *, _Alloc > > {
|
||||
template <> struct traits<std::vector<_Tp const*, _Alloc > > {
|
||||
typedef value_category category;
|
||||
static const char* type_name() {
|
||||
return "std::vector<const " #_Tp " *," #_Alloc " >";
|
||||
return "std::vector<" #_Tp " const*," #_Alloc " >";
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
%typemap_traits_ptr(SWIG_TYPECHECK_VECTOR, std::vector<const _Tp *, _Alloc >);
|
||||
%typemap_traits_ptr(SWIG_TYPECHECK_VECTOR, std::vector<_Tp const*, _Alloc >);
|
||||
|
||||
#ifdef %swig_vector_methods_val
|
||||
// Add swig/language extra methods
|
||||
%swig_vector_methods_val(std::vector<const _Tp *, _Alloc >);
|
||||
%swig_vector_methods_val(std::vector<_Tp const*, _Alloc >);
|
||||
#endif
|
||||
|
||||
%std_vector_methods_val(vector);
|
||||
};
|
||||
|
||||
// ***
|
||||
// ***
|
||||
// bool specialization
|
||||
// ***
|
||||
|
||||
template<class _Alloc >
|
||||
class vector<bool,_Alloc > {
|
||||
|
|
|
|||
|
|
@ -156,6 +156,11 @@
|
|||
#define %nonaturalvar %feature("naturalvar","0")
|
||||
#define %clearnaturalvar %feature("naturalvar","")
|
||||
|
||||
/* nspace directives */
|
||||
#define %nspace %feature("nspace")
|
||||
#define %nonspace %feature("nspace","0")
|
||||
#define %clearnspace %feature("nspace","")
|
||||
|
||||
/* valuewrapper directives */
|
||||
#define %valuewrapper %feature("valuewrapper")
|
||||
#define %clearvaluewrapper %feature("valuewrapper","")
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@
|
|||
/*
|
||||
Flags/methods for returning states.
|
||||
|
||||
The SWIG conversion methods, as ConvertPtr, return and integer
|
||||
The SWIG conversion methods, as ConvertPtr, return an integer
|
||||
that tells if the conversion was successful or not. And if not,
|
||||
an error code can be returned (see swigerrors.swg for the codes).
|
||||
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ namespace std {
|
|||
bool empty() const;
|
||||
void clear();
|
||||
%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);
|
||||
if (i != self->end())
|
||||
return i->second;
|
||||
|
|
@ -55,119 +55,17 @@ namespace std {
|
|||
}
|
||||
};
|
||||
|
||||
// Legacy macros (deprecated)
|
||||
%define specialize_std_map_on_key(K,CHECK,CONVERT_FROM,CONVERT_TO)
|
||||
#warning "specialize_std_map_on_key ignored - macro is deprecated and no longer necessary"
|
||||
%enddef
|
||||
|
||||
// specializations for built-ins
|
||||
%define specialize_std_map_on_value(T,CHECK,CONVERT_FROM,CONVERT_TO)
|
||||
#warning "specialize_std_map_on_value ignored - macro is deprecated and no longer necessary"
|
||||
%enddef
|
||||
|
||||
%define specialize_std_map_on_key(K,CHECK,CONVERT_FROM,CONVERT_TO)
|
||||
|
||||
template<class T> class map<K,T> {
|
||||
// add typemaps here
|
||||
public:
|
||||
map();
|
||||
map(const map<K,T> &);
|
||||
|
||||
unsigned int size() const;
|
||||
bool empty() const;
|
||||
void clear();
|
||||
%extend {
|
||||
T& get(K key) throw (std::out_of_range) {
|
||||
std::map<K,T >::iterator i = self->find(key);
|
||||
if (i != self->end())
|
||||
return i->second;
|
||||
else
|
||||
throw std::out_of_range("key not found");
|
||||
}
|
||||
void set(K key, const T& x) {
|
||||
(*self)[key] = x;
|
||||
}
|
||||
void del(K key) throw (std::out_of_range) {
|
||||
std::map<K,T >::iterator i = self->find(key);
|
||||
if (i != self->end())
|
||||
self->erase(i);
|
||||
else
|
||||
throw std::out_of_range("key not found");
|
||||
}
|
||||
bool has_key(K key) {
|
||||
std::map<K,T >::iterator i = self->find(key);
|
||||
return i != self->end();
|
||||
}
|
||||
}
|
||||
};
|
||||
%enddef
|
||||
|
||||
%define specialize_std_map_on_value(T,CHECK,CONVERT_FROM,CONVERT_TO)
|
||||
template<class K> class map<K,T> {
|
||||
// add typemaps here
|
||||
public:
|
||||
map();
|
||||
map(const map<K,T> &);
|
||||
|
||||
unsigned int size() const;
|
||||
bool empty() const;
|
||||
void clear();
|
||||
%extend {
|
||||
T get(const K& key) throw (std::out_of_range) {
|
||||
std::map<K,T >::iterator i = self->find(key);
|
||||
if (i != self->end())
|
||||
return i->second;
|
||||
else
|
||||
throw std::out_of_range("key not found");
|
||||
}
|
||||
void set(const K& key, T x) {
|
||||
(*self)[key] = x;
|
||||
}
|
||||
void del(const K& key) throw (std::out_of_range) {
|
||||
std::map<K,T >::iterator i = self->find(key);
|
||||
if (i != self->end())
|
||||
self->erase(i);
|
||||
else
|
||||
throw std::out_of_range("key not found");
|
||||
}
|
||||
bool has_key(const K& key) {
|
||||
std::map<K,T >::iterator i = self->find(key);
|
||||
return i != self->end();
|
||||
}
|
||||
}
|
||||
};
|
||||
%enddef
|
||||
|
||||
%define specialize_std_map_on_both(K,CHECK_K,CONVERT_K_FROM,CONVERT_K_TO,
|
||||
T,CHECK_T,CONVERT_T_FROM,CONVERT_T_TO)
|
||||
template<> class map<K,T> {
|
||||
// add typemaps here
|
||||
public:
|
||||
map();
|
||||
map(const map<K,T> &);
|
||||
|
||||
unsigned int size() const;
|
||||
bool empty() const;
|
||||
void clear();
|
||||
%extend {
|
||||
T get(K key) throw (std::out_of_range) {
|
||||
std::map<K,T >::iterator i = self->find(key);
|
||||
if (i != self->end())
|
||||
return i->second;
|
||||
else
|
||||
throw std::out_of_range("key not found");
|
||||
}
|
||||
void set(K key, T x) {
|
||||
(*self)[key] = x;
|
||||
}
|
||||
void del(K key) throw (std::out_of_range) {
|
||||
std::map<K,T >::iterator i = self->find(key);
|
||||
if (i != self->end())
|
||||
self->erase(i);
|
||||
else
|
||||
throw std::out_of_range("key not found");
|
||||
}
|
||||
bool has_key(K key) {
|
||||
std::map<K,T >::iterator i = self->find(key);
|
||||
return i != self->end();
|
||||
}
|
||||
}
|
||||
};
|
||||
%enddef
|
||||
|
||||
// add specializations here
|
||||
%define specialize_std_map_on_both(K,CHECK_K,CONVERT_K_FROM,CONVERT_K_TO, T,CHECK_T,CONVERT_T_FROM,CONVERT_T_TO)
|
||||
#warning "specialize_std_map_on_both ignored - macro is deprecated and no longer necessary"
|
||||
%enddef
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@
|
|||
|
||||
|
||||
/* ------------------------------------------------------------
|
||||
* Tcl extra typemaps
|
||||
* Tcl extra typemaps / typemap overrides
|
||||
* ------------------------------------------------------------ */
|
||||
|
||||
#if 1
|
||||
|
|
@ -84,6 +84,7 @@
|
|||
|
||||
%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(varout) SWIGTYPE = SWIGTYPE INSTANCE;
|
||||
|
|
|
|||
|
|
@ -221,7 +221,7 @@
|
|||
#if #AccessorMethod != ""
|
||||
%attribute_custom(Class, AttributeType, AttributeName, AccessorMethod, AccessorMethod, &self_->AccessorMethod(), self_->AccessorMethod() = *val_)
|
||||
#else
|
||||
%attribute_custom(Class, AttributeType, AccessorMethod, AccessorMethod, AccessorMethod, &self_->AccessorMethod(), self_->AccessorMethod() = *val_)
|
||||
%attribute_custom(Class, AttributeType, AccessorName, AccessorName, AccessorName, &self_->AccessorName(), self_->AccessorName() = *val_)
|
||||
#endif
|
||||
%enddef
|
||||
|
||||
|
|
|
|||
|
|
@ -147,8 +147,7 @@
|
|||
*/
|
||||
|
||||
%define Name ## _mutable(TYPEMAP,EXP...)
|
||||
%typemap(in,noblock=1,fragment=#SWIG_AsCharPtrAndSize) TYPEMAP
|
||||
(int res, Char* t = 0, size_t n = 0, int alloc = 0, size_t expansion = 0) {
|
||||
%typemap(in,noblock=1,fragment=#SWIG_AsCharPtrAndSize) TYPEMAP (int res, Char *t = 0, size_t n = 0, int alloc = 0, size_t expansion = 0) {
|
||||
#if #EXP != ""
|
||||
expansion += EXP;
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,238 +1,15 @@
|
|||
/*
|
||||
Fragments:
|
||||
==========
|
||||
Fragments
|
||||
=========
|
||||
See the "Typemap fragments" section in the documentation for understanding
|
||||
fragments. Below is some info on how fragments and automatic type
|
||||
specialization is used.
|
||||
|
||||
Second to typemaps, fragments are one the most powerful and
|
||||
dangerous swig features. So, if you are starting to read about them,
|
||||
make sure you read all of this document.
|
||||
Macros that make the automatic generation of typemaps easier are provided.
|
||||
|
||||
Basics:
|
||||
=======
|
||||
Consider the following code:
|
||||
|
||||
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 discover yourself copying the same long
|
||||
conversion code in several typemaps, such as varin, directorout,
|
||||
etc. Also, you will discover that swig copes 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" specialized.
|
||||
|
||||
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") {...}
|
||||
|
||||
|
||||
Finally, you can force the inclusion of a fragment at any moment as follow:
|
||||
|
||||
%fragment("bigfragment");
|
||||
|
||||
which is very useful inside a template class, for example.
|
||||
|
||||
|
||||
Fragment type specialization
|
||||
============================
|
||||
|
||||
Fragments can be "type specialized". The syntax is as follows
|
||||
|
||||
%fragment("name","header") { a type independent fragment }
|
||||
%fragment("name" {Type}, "header") { a type 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 specialization:
|
||||
===============================================
|
||||
|
||||
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_method_float(PyObject *obj) {
|
||||
...
|
||||
}
|
||||
}
|
||||
|
||||
%fragment("incode"{long}, "header") {
|
||||
float in_method_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 fragment 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") {
|
||||
%fragment(SWIG_From_frag(bool), "header") {
|
||||
static PyObject*
|
||||
SWIG_From_dec(bool)(bool value)
|
||||
{
|
||||
|
|
@ -242,7 +19,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
%typemap(out,fragment=SWIG_From_frag(bool)) bool {
|
||||
%typemap(out, fragment=SWIG_From_frag(bool)) bool {
|
||||
$result = SWIG_From(bool)($1));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@
|
|||
|
||||
/* out */
|
||||
|
||||
%typemap(out,noblock=1,fragment=#SWIG_FromCharPtr) Char *, const Char* {
|
||||
%typemap(out,noblock=1,fragment=#SWIG_FromCharPtr) Char *, const Char * {
|
||||
%set_output(SWIG_FromCharPtr((const Char *)$1));
|
||||
}
|
||||
|
||||
|
|
@ -98,7 +98,7 @@
|
|||
|
||||
/* varout */
|
||||
|
||||
%typemap(varout,noblock=1,fragment=#SWIG_FromCharPtr) Char*, const Char* {
|
||||
%typemap(varout,noblock=1,fragment=#SWIG_FromCharPtr) Char *, const Char * {
|
||||
%set_varoutput(SWIG_FromCharPtr($1));
|
||||
}
|
||||
|
||||
|
|
@ -165,8 +165,7 @@
|
|||
|
||||
/* directorout */
|
||||
|
||||
%typemap(directorout,noblock=1,fragment=#SWIG_AsCharPtr,warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG)
|
||||
Char * (int res, Char* buf = 0, int alloc = SWIG_NEWOBJ) {
|
||||
%typemap(directorout,noblock=1,fragment=#SWIG_AsCharPtr,warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) Char * (int res, Char *buf = 0, int alloc = SWIG_NEWOBJ) {
|
||||
res = SWIG_AsCharPtr($input, &buf, &alloc);
|
||||
if (!SWIG_IsOK(res)) {
|
||||
%dirout_fail(res, "$type");
|
||||
|
|
@ -184,9 +183,7 @@
|
|||
}
|
||||
|
||||
|
||||
%typemap(directorout,noblock=1,fragment=#SWIG_AsCharPtr,warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG)
|
||||
Char * const& (int res, Char* buf = 0, int alloc = SWIG_NEWOBJ),
|
||||
Char const* const& (int res, Char* buf = 0, int alloc = SWIG_NEWOBJ) {
|
||||
%typemap(directorout,noblock=1,fragment=#SWIG_AsCharPtr,warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) Char *const& (int res, Char *buf = 0, int alloc = SWIG_NEWOBJ), Char const*const& (int res, Char *buf = 0, int alloc = SWIG_NEWOBJ) {
|
||||
res = SWIG_AsCharPtr($input, &buf, &alloc);
|
||||
if (!SWIG_IsOK(res)) {
|
||||
%dirout_fail(res, "$type");
|
||||
|
|
@ -226,8 +223,8 @@
|
|||
* Unknown size const Character array Char[ANY] handling
|
||||
* ------------------------------------------------------------ */
|
||||
|
||||
%apply Char* { Char [] };
|
||||
%apply const Char* { const Char [] };
|
||||
%apply Char * { Char [] };
|
||||
%apply const Char * { const Char [] };
|
||||
|
||||
%typemap(varin,noblock=1,warning="462:Unable to set variable of type Char []") Char []
|
||||
{
|
||||
|
|
|
|||
|
|
@ -21,15 +21,15 @@
|
|||
%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);
|
||||
if (!SWIG_IsOK(res)) {
|
||||
%argument_fail(res, "$*ltype", $symname, $argnum);
|
||||
}
|
||||
temp = %reinterpret_cast(argp, $*ltype);
|
||||
$1 = &temp;
|
||||
$1 = %reinterpret_cast(&temp, $1_ltype);
|
||||
}
|
||||
%typemap(freearg) SWIGTYPE* const& "";
|
||||
%typemap(freearg) SWIGTYPE *const& "";
|
||||
|
||||
|
||||
/* Reference */
|
||||
|
|
@ -106,7 +106,7 @@
|
|||
%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));
|
||||
}
|
||||
|
||||
|
|
@ -299,6 +299,12 @@
|
|||
$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 & {
|
||||
void *vptr = 0;
|
||||
int res = SWIG_ConvertPtr($input, &vptr, $descriptor, 0);
|
||||
|
|
@ -337,7 +343,7 @@
|
|||
|
||||
/* 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);
|
||||
}
|
||||
|
||||
|
|
@ -345,7 +351,7 @@
|
|||
$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);
|
||||
}
|
||||
|
||||
|
|
@ -407,7 +413,7 @@
|
|||
* --- 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));
|
||||
}
|
||||
|
||||
|
|
@ -547,6 +553,7 @@
|
|||
}
|
||||
#endif
|
||||
|
||||
%apply SWIGTYPE * { SWIGTYPE *const }
|
||||
|
||||
/* ------------------------------------------------------------
|
||||
* --- Special typemaps ---
|
||||
|
|
@ -602,3 +609,4 @@
|
|||
%typemap(varout,noblock=1) SWIGTYPE INSTANCE {
|
||||
%set_varoutput(SWIG_NewInstanceObj(%as_voidptr(&$1), $&1_descriptor, %newinstance_flags));
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue