fix crash if function returns stack object like Vec4
This commit is contained in:
parent
749af5630c
commit
b8b18f4783
Binary file not shown.
|
|
@ -1,179 +0,0 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* arrays_csharp.i
|
||||
*
|
||||
* This file contains a two approaches to marshaling arrays. The first uses
|
||||
* default p/invoke marshaling and the second uses pinning of the arrays.
|
||||
*
|
||||
* Default marshaling approach
|
||||
* ----------------------------
|
||||
* Array typemaps using default p/invoke marshaling. The data is copied to a separately
|
||||
* allocated buffer when passing over the managed-native boundary.
|
||||
*
|
||||
* There are separate typemaps for in, out and inout arrays to enable avoiding
|
||||
* unnecessary copying.
|
||||
*
|
||||
* Example usage:
|
||||
*
|
||||
* %include "arrays_csharp.i"
|
||||
* %apply int INPUT[] { int* sourceArray }
|
||||
* %apply int OUTPUT[] { int* targetArray }
|
||||
* void myArrayCopy( int* sourceArray, int* targetArray, int nitems );
|
||||
*
|
||||
* %apply int INOUT[] { int* array1, int *array2 }
|
||||
* void myArraySwap( int* array1, int* array2, int nitems );
|
||||
*
|
||||
* If handling large arrays you should consider using the pinning array typemaps
|
||||
* described next.
|
||||
*
|
||||
* Pinning approach
|
||||
* ----------------
|
||||
* Array typemaps using pinning. These typemaps pin the managed array given
|
||||
* as parameter and pass a pointer to it to the c/c++ side. This is very
|
||||
* efficient as no copying is done (unlike in the default array marshaling),
|
||||
* but it makes garbage collection more difficult. When considering using
|
||||
* these typemaps, think carefully whether you have callbacks that may cause
|
||||
* the control to re-enter the managed side from within the call (and produce
|
||||
* garbage for the gc) or whether other threads may produce enough garbage to
|
||||
* trigger gc while the call is being executed. In those cases it may be
|
||||
* wiser to use the default marshaling typemaps.
|
||||
*
|
||||
* Please note that when using fixed arrays, you have to mark your corresponding
|
||||
* module class method unsafe using
|
||||
* %csmethodmodifiers "public unsafe"
|
||||
* (the visibility of the method is up to you).
|
||||
*
|
||||
* Example usage:
|
||||
*
|
||||
* %include "arrays_csharp.i"
|
||||
* %apply int FIXED[] { int* sourceArray, int *targetArray }
|
||||
* %csmethodmodifiers myArrayCopy "public unsafe";
|
||||
* void myArrayCopy( int *sourceArray, int* targetArray, int nitems );
|
||||
*
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
%define CSHARP_ARRAYS( CTYPE, CSTYPE )
|
||||
|
||||
// input only arrays
|
||||
|
||||
%typemap(ctype) CTYPE INPUT[] "CTYPE*"
|
||||
%typemap(cstype) CTYPE INPUT[] "CSTYPE[]"
|
||||
%typemap(imtype, inattributes="[global::System.Runtime.InteropServices.In, global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.LPArray)]") CTYPE INPUT[] "CSTYPE[]"
|
||||
%typemap(csin) CTYPE INPUT[] "$csinput"
|
||||
|
||||
%typemap(in) CTYPE INPUT[] "$1 = $input;"
|
||||
%typemap(freearg) CTYPE INPUT[] ""
|
||||
%typemap(argout) CTYPE INPUT[] ""
|
||||
|
||||
// output only arrays
|
||||
|
||||
%typemap(ctype) CTYPE OUTPUT[] "CTYPE*"
|
||||
%typemap(cstype) CTYPE OUTPUT[] "CSTYPE[]"
|
||||
%typemap(imtype, inattributes="[global::System.Runtime.InteropServices.Out, global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.LPArray)]") CTYPE OUTPUT[] "CSTYPE[]"
|
||||
%typemap(csin) CTYPE OUTPUT[] "$csinput"
|
||||
|
||||
%typemap(in) CTYPE OUTPUT[] "$1 = $input;"
|
||||
%typemap(freearg) CTYPE OUTPUT[] ""
|
||||
%typemap(argout) CTYPE OUTPUT[] ""
|
||||
|
||||
// inout arrays
|
||||
|
||||
%typemap(ctype) CTYPE INOUT[] "CTYPE*"
|
||||
%typemap(cstype) CTYPE INOUT[] "CSTYPE[]"
|
||||
%typemap(imtype, inattributes="[global::System.Runtime.InteropServices.In, global::System.Runtime.InteropServices.Out, global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.LPArray)]") CTYPE INOUT[] "CSTYPE[]"
|
||||
%typemap(csin) CTYPE INOUT[] "$csinput"
|
||||
|
||||
%typemap(in) CTYPE INOUT[] "$1 = $input;"
|
||||
%typemap(freearg) CTYPE INOUT[] ""
|
||||
%typemap(argout) CTYPE INOUT[] ""
|
||||
|
||||
%enddef // CSHARP_ARRAYS
|
||||
|
||||
CSHARP_ARRAYS(signed char, sbyte)
|
||||
CSHARP_ARRAYS(unsigned char, byte)
|
||||
CSHARP_ARRAYS(short, short)
|
||||
CSHARP_ARRAYS(unsigned short, ushort)
|
||||
CSHARP_ARRAYS(int, int)
|
||||
CSHARP_ARRAYS(unsigned int, uint)
|
||||
// FIXME - on Unix 64 bit, long is 8 bytes but is 4 bytes on Windows 64 bit.
|
||||
// How can this be handled sensibly?
|
||||
// See e.g. http://www.xml.com/ldd/chapter/book/ch10.html
|
||||
CSHARP_ARRAYS(long, int)
|
||||
CSHARP_ARRAYS(unsigned long, uint)
|
||||
CSHARP_ARRAYS(long long, long)
|
||||
CSHARP_ARRAYS(unsigned long long, ulong)
|
||||
CSHARP_ARRAYS(float, float)
|
||||
CSHARP_ARRAYS(double, double)
|
||||
|
||||
// By default C# will marshal bools as 4 bytes
|
||||
// UnmanagedType.I1 will change this to 1 byte
|
||||
// FIXME - When running on mono ArraySubType appears to be ignored and bools will be marshalled as 4-byte
|
||||
// https://github.com/mono/mono/issues/15592
|
||||
|
||||
// input only arrays
|
||||
%typemap(ctype) bool INPUT[] "bool*"
|
||||
%typemap(cstype) bool INPUT[] "bool[]"
|
||||
%typemap(imtype, inattributes="[global::System.Runtime.InteropServices.In, global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.LPArray,ArraySubType=System.Runtime.InteropServices.UnmanagedType.I1)]") bool INPUT[] "bool[]"
|
||||
%typemap(csin) bool INPUT[] "$csinput"
|
||||
|
||||
%typemap(in) bool INPUT[] %{
|
||||
$1 = $input;
|
||||
%}
|
||||
%typemap(freearg) bool INPUT[] ""
|
||||
%typemap(argout) bool INPUT[] ""
|
||||
|
||||
// output only arrays
|
||||
%typemap(ctype) bool OUTPUT[] "bool*"
|
||||
%typemap(cstype) bool OUTPUT[] "bool[]"
|
||||
%typemap(imtype, inattributes="[global::System.Runtime.InteropServices.Out, global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.LPArray,ArraySubType=System.Runtime.InteropServices.UnmanagedType.I1)]") bool OUTPUT[] "bool[]"
|
||||
%typemap(csin) bool OUTPUT[] "$csinput"
|
||||
|
||||
%typemap(in) bool OUTPUT[] %{
|
||||
$1 = $input;
|
||||
%}
|
||||
%typemap(freearg) bool OUTPUT[] ""
|
||||
%typemap(argout) bool OUTPUT[] ""
|
||||
|
||||
// inout arrays
|
||||
%typemap(ctype) bool INOUT[] "bool*"
|
||||
%typemap(cstype) bool INOUT[] "bool[]"
|
||||
%typemap(imtype, inattributes="[global::System.Runtime.InteropServices.In, global::System.Runtime.InteropServices.Out, global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.LPArray,ArraySubType=System.Runtime.InteropServices.UnmanagedType.I1)]") bool INOUT[] "bool[]"
|
||||
%typemap(csin) bool INOUT[] "$csinput"
|
||||
|
||||
%typemap(in) bool INOUT[] %{
|
||||
$1 = $input;
|
||||
%}
|
||||
%typemap(freearg) bool INOUT[] ""
|
||||
%typemap(argout) bool INOUT[] ""
|
||||
|
||||
|
||||
%define CSHARP_ARRAYS_FIXED( CTYPE, CSTYPE )
|
||||
|
||||
%typemap(ctype) CTYPE FIXED[] "CTYPE*"
|
||||
%typemap(imtype) CTYPE FIXED[] "global::System.IntPtr"
|
||||
%typemap(cstype) CTYPE FIXED[] "CSTYPE[]"
|
||||
%typemap(csin,
|
||||
pre= " fixed ( CSTYPE* swig_ptrTo_$csinput = $csinput ) {",
|
||||
terminator=" }")
|
||||
CTYPE FIXED[] "(global::System.IntPtr)swig_ptrTo_$csinput"
|
||||
|
||||
%typemap(in) CTYPE FIXED[] "$1 = $input;"
|
||||
%typemap(freearg) CTYPE FIXED[] ""
|
||||
%typemap(argout) CTYPE FIXED[] ""
|
||||
|
||||
|
||||
%enddef // CSHARP_ARRAYS_FIXED
|
||||
|
||||
CSHARP_ARRAYS_FIXED(signed char, sbyte)
|
||||
CSHARP_ARRAYS_FIXED(unsigned char, byte)
|
||||
CSHARP_ARRAYS_FIXED(short, short)
|
||||
CSHARP_ARRAYS_FIXED(unsigned short, ushort)
|
||||
CSHARP_ARRAYS_FIXED(int, int)
|
||||
CSHARP_ARRAYS_FIXED(unsigned int, uint)
|
||||
CSHARP_ARRAYS_FIXED(long, int)
|
||||
CSHARP_ARRAYS_FIXED(unsigned long, uint)
|
||||
CSHARP_ARRAYS_FIXED(long long, long)
|
||||
CSHARP_ARRAYS_FIXED(unsigned long long, ulong)
|
||||
CSHARP_ARRAYS_FIXED(float, float)
|
||||
CSHARP_ARRAYS_FIXED(double, double)
|
||||
CSHARP_ARRAYS_FIXED(bool, bool)
|
||||
|
||||
|
|
@ -1,517 +0,0 @@
|
|||
// Users can provide their own SWIG_INTRUSIVE_PTR_TYPEMAPS or SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP macros before including this file to change the
|
||||
// visibility of the constructor and getCPtr method if desired to public if using multiple modules.
|
||||
#ifndef SWIG_INTRUSIVE_PTR_TYPEMAPS
|
||||
#define SWIG_INTRUSIVE_PTR_TYPEMAPS(CONST, TYPE...) SWIG_INTRUSIVE_PTR_TYPEMAPS_IMPLEMENTATION(internal, internal, CONST, TYPE)
|
||||
#endif
|
||||
#ifndef SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP
|
||||
#define SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP(CONST, TYPE...) SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP_IMPLEMENTATION(internal, internal, CONST, TYPE)
|
||||
#endif
|
||||
|
||||
%include <intrusive_ptr.i>
|
||||
|
||||
// Language specific macro implementing all the customisations for handling the smart pointer
|
||||
%define SWIG_INTRUSIVE_PTR_TYPEMAPS_IMPLEMENTATION(PTRCTOR_VISIBILITY, CPTR_VISIBILITY, CONST, TYPE...)
|
||||
|
||||
// %naturalvar is as documented for member variables
|
||||
%naturalvar TYPE;
|
||||
%naturalvar SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >;
|
||||
|
||||
// destructor wrapper customisation
|
||||
%feature("unref") TYPE "(void)arg1; delete smartarg1;"
|
||||
|
||||
// Typemap customisations...
|
||||
|
||||
%typemap(in, canthrow=1) CONST TYPE ($&1_type argp = 0) %{
|
||||
// plain value
|
||||
argp = (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0;
|
||||
if (!argp) {
|
||||
SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null $1_type", 0);
|
||||
return $null;
|
||||
}
|
||||
$1 = *argp;
|
||||
%}
|
||||
%typemap(out, fragment="SWIG_intrusive_deleter") CONST TYPE %{
|
||||
//plain value(out)
|
||||
$1_ltype* resultp = new $1_ltype($1);
|
||||
intrusive_ptr_add_ref(resultp);
|
||||
*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(resultp, SWIG_intrusive_deleter< CONST TYPE >());
|
||||
%}
|
||||
|
||||
%typemap(in, canthrow=1) CONST TYPE * (SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) %{
|
||||
// plain pointer
|
||||
smartarg = *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input;
|
||||
$1 = (TYPE *)(smartarg ? smartarg->get() : 0);
|
||||
%}
|
||||
%typemap(out, fragment="SWIG_intrusive_deleter,SWIG_null_deleter") CONST TYPE * %{
|
||||
//plain pointer(out)
|
||||
#if ($owner)
|
||||
if ($1) {
|
||||
intrusive_ptr_add_ref($1);
|
||||
*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1, SWIG_intrusive_deleter< CONST TYPE >());
|
||||
} else {
|
||||
*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0;
|
||||
}
|
||||
#else
|
||||
*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_0) : 0;
|
||||
#endif
|
||||
%}
|
||||
|
||||
%typemap(in, canthrow=1) CONST TYPE & %{
|
||||
// plain reference
|
||||
$1 = ($1_ltype)((*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0);
|
||||
if(!$1) {
|
||||
SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "$1_type reference is null", 0);
|
||||
return $null;
|
||||
}
|
||||
%}
|
||||
%typemap(out, fragment="SWIG_intrusive_deleter,SWIG_null_deleter") CONST TYPE & %{
|
||||
//plain reference(out)
|
||||
#if ($owner)
|
||||
if ($1) {
|
||||
intrusive_ptr_add_ref($1);
|
||||
*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1, SWIG_intrusive_deleter< CONST TYPE >());
|
||||
} else {
|
||||
*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0;
|
||||
}
|
||||
#else
|
||||
*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_0) : 0;
|
||||
#endif
|
||||
%}
|
||||
|
||||
%typemap(in) TYPE *CONST& ($*1_ltype temp = 0) %{
|
||||
// plain pointer by reference
|
||||
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") TYPE *CONST& %{
|
||||
// plain pointer by reference(out)
|
||||
#if ($owner)
|
||||
if (*$1) {
|
||||
intrusive_ptr_add_ref(*$1);
|
||||
*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1, SWIG_intrusive_deleter< CONST TYPE >());
|
||||
} else {
|
||||
*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0;
|
||||
}
|
||||
#else
|
||||
*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1 SWIG_NO_NULL_DELETER_0);
|
||||
#endif
|
||||
%}
|
||||
|
||||
%typemap(in) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > (SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * smartarg) %{
|
||||
// intrusive_ptr by value
|
||||
smartarg = *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >**)&$input;
|
||||
if (smartarg) {
|
||||
$1 = SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >(smartarg->get(), true);
|
||||
}
|
||||
%}
|
||||
%typemap(out, fragment="SWIG_intrusive_deleter") SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > %{
|
||||
if ($1) {
|
||||
intrusive_ptr_add_ref($1.get());
|
||||
*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1.get(), SWIG_intrusive_deleter< CONST TYPE >());
|
||||
} else {
|
||||
*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0;
|
||||
}
|
||||
%}
|
||||
|
||||
%typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > swigSharedPtrUpcast ($&1_type smartarg) %{
|
||||
// shared_ptr by value
|
||||
smartarg = *($&1_ltype*)&$input;
|
||||
if (smartarg) $1 = *smartarg;
|
||||
%}
|
||||
%typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > ANY_TYPE_SWIGSharedPtrUpcast %{
|
||||
*($&1_ltype*)&$result = $1 ? new $1_ltype($1) : 0;
|
||||
%}
|
||||
|
||||
%typemap(in) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > & ($*1_ltype tempnull, $*1_ltype temp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * smartarg) %{
|
||||
// intrusive_ptr by reference
|
||||
if ( $input ) {
|
||||
smartarg = *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >**)&$input;
|
||||
temp = SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >(smartarg->get(), true);
|
||||
$1 = &temp;
|
||||
} else {
|
||||
$1 = &tempnull;
|
||||
}
|
||||
%}
|
||||
%typemap(memberin) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > & %{
|
||||
delete &($1);
|
||||
if ($self) {
|
||||
SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > * temp = new SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >(*$input);
|
||||
$1 = *temp;
|
||||
}
|
||||
%}
|
||||
%typemap(out, fragment="SWIG_intrusive_deleter") SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > & %{
|
||||
if (*$1) {
|
||||
intrusive_ptr_add_ref($1->get());
|
||||
*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1->get(), SWIG_intrusive_deleter< CONST TYPE >());
|
||||
} else {
|
||||
*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0;
|
||||
}
|
||||
%}
|
||||
|
||||
%typemap(in) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > * ($*1_ltype tempnull, $*1_ltype temp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * smartarg) %{
|
||||
// intrusive_ptr by pointer
|
||||
if ( $input ) {
|
||||
smartarg = *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >**)&$input;
|
||||
temp = SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >(smartarg->get(), true);
|
||||
$1 = &temp;
|
||||
} else {
|
||||
$1 = &tempnull;
|
||||
}
|
||||
%}
|
||||
%typemap(memberin) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > * %{
|
||||
delete $1;
|
||||
if ($self) $1 = new SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >(*$input);
|
||||
%}
|
||||
%typemap(out, fragment="SWIG_intrusive_deleter") SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > * %{
|
||||
if ($1 && *$1) {
|
||||
intrusive_ptr_add_ref($1->get());
|
||||
*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1->get(), SWIG_intrusive_deleter< CONST TYPE >());
|
||||
} else {
|
||||
*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0;
|
||||
}
|
||||
if ($owner) delete $1;
|
||||
%}
|
||||
|
||||
%typemap(in) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& (SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > temp, $*1_ltype tempp = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * smartarg) %{
|
||||
// intrusive_ptr by pointer reference
|
||||
smartarg = *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >**)&$input;
|
||||
if ($input) {
|
||||
temp = SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >(smartarg->get(), true);
|
||||
}
|
||||
tempp = &temp;
|
||||
$1 = &tempp;
|
||||
%}
|
||||
%typemap(memberin) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& %{
|
||||
if ($self) $1 = *$input;
|
||||
%}
|
||||
%typemap(out, fragment="SWIG_intrusive_deleter") SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& %{
|
||||
if (*$1 && **$1) {
|
||||
intrusive_ptr_add_ref((*$1)->get());
|
||||
*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >((*$1)->get(), SWIG_intrusive_deleter< CONST TYPE >());
|
||||
} else {
|
||||
*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0;
|
||||
}
|
||||
%}
|
||||
|
||||
// various missing typemaps - If ever used (unlikely) ensure compilation error rather than runtime bug
|
||||
%typemap(in) CONST TYPE[], CONST TYPE[ANY], CONST TYPE (CLASS::*) %{
|
||||
#error "typemaps for $1_type not available"
|
||||
%}
|
||||
%typemap(out) CONST TYPE[], CONST TYPE[ANY], CONST TYPE (CLASS::*) %{
|
||||
#error "typemaps for $1_type not available"
|
||||
%}
|
||||
|
||||
|
||||
%typemap (ctype) 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 > *& "void *"
|
||||
%typemap (imtype, out="global::System.IntPtr") 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 > *& "global::System.Runtime.InteropServices.HandleRef"
|
||||
%typemap (cstype) 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 > *& "$typemap(cstype, TYPE)"
|
||||
%typemap(csin) 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 > *& "$typemap(cstype, TYPE).getCPtr($csinput)"
|
||||
|
||||
%typemap(csout, excode=SWIGEXCODE) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > {
|
||||
global::System.IntPtr cPtr = $imcall;
|
||||
$typemap(cstype, TYPE) ret = (cPtr == global::System.IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode
|
||||
return ret;
|
||||
}
|
||||
%typemap(csout, excode=SWIGEXCODE) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > {
|
||||
global::System.IntPtr cPtr = $imcall;
|
||||
$typemap(cstype, TYPE) ret = (cPtr == global::System.IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode
|
||||
return ret;
|
||||
}
|
||||
%typemap(csout, excode=SWIGEXCODE) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > & {
|
||||
global::System.IntPtr cPtr = $imcall;
|
||||
$typemap(cstype, TYPE) ret = (cPtr == global::System.IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode
|
||||
return ret;
|
||||
}
|
||||
%typemap(csout, excode=SWIGEXCODE) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > * {
|
||||
global::System.IntPtr cPtr = $imcall;
|
||||
$typemap(cstype, TYPE) ret = (cPtr == global::System.IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode
|
||||
return ret;
|
||||
}
|
||||
%typemap(csout, excode=SWIGEXCODE) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& {
|
||||
global::System.IntPtr cPtr = $imcall;
|
||||
$typemap(cstype, TYPE) ret = (cPtr == global::System.IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode
|
||||
return ret;
|
||||
}
|
||||
%typemap(csvarout, excode=SWIGEXCODE2) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > %{
|
||||
get {
|
||||
$typemap(cstype, TYPE) ret = new $typemap(cstype, TYPE)($imcall, true);$excode
|
||||
return ret;
|
||||
} %}
|
||||
%typemap(csvarout, excode=SWIGEXCODE2) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >& %{
|
||||
get {
|
||||
$typemap(cstype, TYPE) ret = new $typemap(cstype, TYPE)($imcall, true);$excode
|
||||
return ret;
|
||||
} %}
|
||||
%typemap(csvarout, excode=SWIGEXCODE2) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >* %{
|
||||
get {
|
||||
$typemap(cstype, TYPE) ret = new $typemap(cstype, TYPE)($imcall, true);$excode
|
||||
return ret;
|
||||
} %}
|
||||
|
||||
|
||||
%typemap(csout, excode=SWIGEXCODE) CONST TYPE {
|
||||
$typemap(cstype, TYPE) ret = new $typemap(cstype, TYPE)($imcall, true);$excode
|
||||
return ret;
|
||||
}
|
||||
%typemap(csout, excode=SWIGEXCODE) CONST TYPE & {
|
||||
$typemap(cstype, TYPE) ret = new $typemap(cstype, TYPE)($imcall, true);$excode
|
||||
return ret;
|
||||
}
|
||||
%typemap(csout, excode=SWIGEXCODE) CONST TYPE * {
|
||||
global::System.IntPtr cPtr = $imcall;
|
||||
$typemap(cstype, TYPE) ret = (cPtr == global::System.IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode
|
||||
return ret;
|
||||
}
|
||||
%typemap(csout, excode=SWIGEXCODE) TYPE *CONST& {
|
||||
global::System.IntPtr cPtr = $imcall;
|
||||
$typemap(cstype, TYPE) ret = (cPtr == global::System.IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode
|
||||
return ret;
|
||||
}
|
||||
|
||||
// Base proxy classes
|
||||
%typemap(csbody) TYPE %{
|
||||
private global::System.Runtime.InteropServices.HandleRef swigCPtr;
|
||||
private bool swigCMemOwnBase;
|
||||
|
||||
PTRCTOR_VISIBILITY $csclassname(global::System.IntPtr cPtr, bool cMemoryOwn) {
|
||||
swigCMemOwnBase = cMemoryOwn;
|
||||
swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
|
||||
}
|
||||
|
||||
CPTR_VISIBILITY static global::System.Runtime.InteropServices.HandleRef getCPtr($csclassname obj) {
|
||||
return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
|
||||
}
|
||||
%}
|
||||
|
||||
// Derived proxy classes
|
||||
%typemap(csbody_derived) TYPE %{
|
||||
private global::System.Runtime.InteropServices.HandleRef swigCPtr;
|
||||
private bool swigCMemOwnDerived;
|
||||
|
||||
PTRCTOR_VISIBILITY $csclassname(global::System.IntPtr cPtr, bool cMemoryOwn) : base($imclassname.$csclazznameSWIGSmartPtrUpcast(cPtr), true) {
|
||||
swigCMemOwnDerived = cMemoryOwn;
|
||||
swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
|
||||
}
|
||||
|
||||
CPTR_VISIBILITY static global::System.Runtime.InteropServices.HandleRef getCPtr($csclassname obj) {
|
||||
return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
|
||||
}
|
||||
%}
|
||||
|
||||
%typemap(csdisposing, methodname="Dispose", methodmodifiers="protected", parameters="bool disposing") TYPE {
|
||||
lock(this) {
|
||||
if (swigCPtr.Handle != global::System.IntPtr.Zero) {
|
||||
if (swigCMemOwnBase) {
|
||||
swigCMemOwnBase = false;
|
||||
$imcall;
|
||||
}
|
||||
swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
%typemap(csdisposing_derived, methodname="Dispose", methodmodifiers="protected", parameters="bool disposing") TYPE {
|
||||
lock(this) {
|
||||
if (swigCPtr.Handle != global::System.IntPtr.Zero) {
|
||||
if (swigCMemOwnDerived) {
|
||||
swigCMemOwnDerived = false;
|
||||
$imcall;
|
||||
}
|
||||
swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
}
|
||||
|
||||
// CONST version needed ???? also for C#
|
||||
%typemap(imtype, nopgcpp="1") SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > swigSharedPtrUpcast "global::System.Runtime.InteropServices.HandleRef"
|
||||
%typemap(imtype, nopgcpp="1") SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > swigSharedPtrUpcast "global::System.Runtime.InteropServices.HandleRef"
|
||||
|
||||
|
||||
%template() SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >;
|
||||
%template() SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >;
|
||||
%enddef
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
%include <shared_ptr.i>
|
||||
|
||||
%define SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP_IMPLEMENTATION(PTRCTOR_VISIBILITY, CPTR_VISIBILITY, CONST, TYPE...)
|
||||
|
||||
%naturalvar TYPE;
|
||||
%naturalvar SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >;
|
||||
|
||||
// destructor mods
|
||||
%feature("unref") TYPE "(void)arg1; delete smartarg1;"
|
||||
|
||||
|
||||
// plain value
|
||||
%typemap(in, canthrow=1) CONST TYPE ($&1_type argp = 0) %{
|
||||
argp = (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0;
|
||||
if (!argp) {
|
||||
SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null $1_type", 0);
|
||||
return $null;
|
||||
}
|
||||
$1 = *argp; %}
|
||||
%typemap(out) CONST TYPE
|
||||
%{ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(new $1_ltype($1)); %}
|
||||
|
||||
// plain pointer
|
||||
%typemap(in) CONST TYPE * (SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) %{
|
||||
smartarg = *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input;
|
||||
$1 = (TYPE *)(smartarg ? smartarg->get() : 0); %}
|
||||
%typemap(out, fragment="SWIG_null_deleter") CONST TYPE * %{
|
||||
*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_$owner) : 0;
|
||||
%}
|
||||
|
||||
// plain reference
|
||||
%typemap(in, canthrow=1) CONST TYPE & %{
|
||||
$1 = ($1_ltype)((*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0);
|
||||
if (!$1) {
|
||||
SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "$1_type reference is null", 0);
|
||||
return $null;
|
||||
} %}
|
||||
%typemap(out, fragment="SWIG_null_deleter") CONST TYPE &
|
||||
%{ *(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) 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") 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) %{
|
||||
// shared_ptr by value
|
||||
smartarg = *($&1_ltype*)&$input;
|
||||
if (smartarg) $1 = *smartarg;
|
||||
%}
|
||||
%typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > ANY_TYPE_SWIGSharedPtrUpcast %{
|
||||
*($&1_ltype*)&$result = $1 ? new $1_ltype($1) : 0;
|
||||
%}
|
||||
|
||||
// various missing typemaps - If ever used (unlikely) ensure compilation error rather than runtime bug
|
||||
%typemap(in) CONST TYPE[], CONST TYPE[ANY], CONST TYPE (CLASS::*) %{
|
||||
#error "typemaps for $1_type not available"
|
||||
%}
|
||||
%typemap(out) CONST TYPE[], CONST TYPE[ANY], CONST TYPE (CLASS::*) %{
|
||||
#error "typemaps for $1_type not available"
|
||||
%}
|
||||
|
||||
|
||||
%typemap (ctype) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > "void *"
|
||||
%typemap (imtype) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > "void *"
|
||||
%typemap (cstype) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > "$typemap(cstype, TYPE)"
|
||||
%typemap (csin) 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 > {
|
||||
global::System.IntPtr cPtr = $imcall;
|
||||
return (cPtr == global::System.IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);
|
||||
}
|
||||
|
||||
%typemap(csout, excode=SWIGEXCODE) CONST TYPE {
|
||||
return new $typemap(cstype, TYPE)($imcall, true);
|
||||
}
|
||||
%typemap(csout, excode=SWIGEXCODE) CONST TYPE & {
|
||||
return new $typemap(cstype, TYPE)($imcall, true);
|
||||
}
|
||||
%typemap(csout, excode=SWIGEXCODE) CONST TYPE * {
|
||||
global::System.IntPtr cPtr = $imcall;
|
||||
return (cPtr == global::System.IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);
|
||||
}
|
||||
%typemap(csout, excode=SWIGEXCODE) TYPE *CONST& {
|
||||
global::System.IntPtr cPtr = $imcall;
|
||||
return (cPtr == global::System.IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);
|
||||
}
|
||||
|
||||
// Base proxy classes
|
||||
%typemap(csbody) TYPE %{
|
||||
private global::System.Runtime.InteropServices.HandleRef swigCPtr;
|
||||
private bool swigCMemOwnBase;
|
||||
|
||||
PTRCTOR_VISIBILITY $csclassname(global::System.IntPtr cPtr, bool cMemoryOwn) {
|
||||
swigCMemOwnBase = cMemoryOwn;
|
||||
swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
|
||||
}
|
||||
|
||||
CPTR_VISIBILITY static global::System.Runtime.InteropServices.HandleRef getCPtr($csclassname obj) {
|
||||
return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
|
||||
}
|
||||
%}
|
||||
|
||||
// Derived proxy classes
|
||||
%typemap(csbody_derived) TYPE %{
|
||||
private global::System.Runtime.InteropServices.HandleRef swigCPtr;
|
||||
private bool swigCMemOwnDerived;
|
||||
|
||||
PTRCTOR_VISIBILITY $csclassname(global::System.IntPtr cPtr, bool cMemoryOwn) : base($imclassname.$csclazznameSWIGSmartPtrUpcast(cPtr), true) {
|
||||
swigCMemOwnDerived = cMemoryOwn;
|
||||
swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
|
||||
}
|
||||
|
||||
CPTR_VISIBILITY static global::System.Runtime.InteropServices.HandleRef getCPtr($csclassname obj) {
|
||||
return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
|
||||
}
|
||||
%}
|
||||
|
||||
%typemap(csdisposing, methodname="Dispose", methodmodifiers="protected", parameters="bool disposing") TYPE {
|
||||
lock(this) {
|
||||
if (swigCPtr.Handle != global::System.IntPtr.Zero) {
|
||||
if (swigCMemOwnBase) {
|
||||
swigCMemOwnBase = false;
|
||||
$imcall;
|
||||
}
|
||||
swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
%typemap(csdisposing_derived, methodname="Dispose", methodmodifiers="protected", parameters="bool disposing") TYPE {
|
||||
lock(this) {
|
||||
if (swigCPtr.Handle != global::System.IntPtr.Zero) {
|
||||
if (swigCMemOwnDerived) {
|
||||
swigCMemOwnDerived = false;
|
||||
$imcall;
|
||||
}
|
||||
swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// CONST version needed ???? also for C#
|
||||
%typemap(imtype, nopgcpp="1") SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > swigSharedPtrUpcast "global::System.Runtime.InteropServices.HandleRef"
|
||||
%typemap(imtype, nopgcpp="1") SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > swigSharedPtrUpcast "global::System.Runtime.InteropServices.HandleRef"
|
||||
|
||||
// Typecheck typemaps
|
||||
%typemap(typecheck, precedence=SWIG_TYPECHECK_POINTER, equivalent="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 > *,
|
||||
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *&
|
||||
""
|
||||
|
||||
%template() SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >;
|
||||
%enddef
|
||||
|
|
@ -1,323 +0,0 @@
|
|||
// Users can provide their own SWIG_SHARED_PTR_TYPEMAPS macro before including this file to change the
|
||||
// visibility of the constructor and getCPtr method if desired to public if using multiple modules.
|
||||
#ifndef SWIG_SHARED_PTR_TYPEMAPS
|
||||
#define SWIG_SHARED_PTR_TYPEMAPS(CONST, TYPE...) SWIG_SHARED_PTR_TYPEMAPS_IMPLEMENTATION(internal, internal, CONST, TYPE)
|
||||
#endif
|
||||
|
||||
%include <shared_ptr.i>
|
||||
|
||||
// Language specific macro implementing all the customisations for handling the smart pointer
|
||||
%define SWIG_SHARED_PTR_TYPEMAPS_IMPLEMENTATION(PTRCTOR_VISIBILITY, CPTR_VISIBILITY, CONST, TYPE...)
|
||||
|
||||
// %naturalvar is as documented for member variables
|
||||
%naturalvar TYPE;
|
||||
%naturalvar SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >;
|
||||
|
||||
// destructor mods
|
||||
%feature("unref") TYPE
|
||||
//"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;"
|
||||
|
||||
// Typemap customisations...
|
||||
|
||||
// plain value
|
||||
%typemap(in, canthrow=1) CONST TYPE ($&1_type argp = 0) %{
|
||||
argp = ((SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)$input) ? ((SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)$input)->get() : 0;
|
||||
if (!argp) {
|
||||
SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null $1_type", 0);
|
||||
return $null;
|
||||
}
|
||||
$1 = *argp; %}
|
||||
%typemap(out) CONST TYPE
|
||||
%{ $result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(new $1_ltype($1)); %}
|
||||
|
||||
%typemap(directorin) CONST TYPE
|
||||
%{ $input = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > (new $1_ltype(SWIG_STD_MOVE($1))); %}
|
||||
|
||||
%typemap(directorout) CONST TYPE
|
||||
%{ if (!$input) {
|
||||
SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null $1_type", 0);
|
||||
return $null;
|
||||
}
|
||||
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = (SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)$input;
|
||||
$result = *smartarg->get();
|
||||
%}
|
||||
|
||||
// plain pointer
|
||||
%typemap(in, canthrow=1) CONST TYPE * (SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) %{
|
||||
smartarg = (SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)$input;
|
||||
$1 = (TYPE *)(smartarg ? smartarg->get() : 0); %}
|
||||
%typemap(out, fragment="SWIG_null_deleter") CONST TYPE * %{
|
||||
$result = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_$owner) : 0;
|
||||
%}
|
||||
|
||||
%typemap(directorin) CONST TYPE *
|
||||
%{ $input = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_0) : 0; %}
|
||||
|
||||
%typemap(directorout) CONST TYPE * %{
|
||||
#error "typemaps for $1_type not available"
|
||||
%}
|
||||
|
||||
// plain reference
|
||||
%typemap(in, canthrow=1) CONST TYPE & %{
|
||||
$1 = ($1_ltype)(((SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)$input) ? ((SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)$input)->get() : 0);
|
||||
if (!$1) {
|
||||
SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "$1_type reference is null", 0);
|
||||
return $null;
|
||||
} %}
|
||||
%typemap(out, fragment="SWIG_null_deleter") CONST TYPE &
|
||||
%{ $result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_$owner); %}
|
||||
|
||||
%typemap(directorin) CONST TYPE &
|
||||
%{ $input = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > (&$1 SWIG_NO_NULL_DELETER_0); %}
|
||||
|
||||
%typemap(directorout) CONST TYPE & %{
|
||||
#error "typemaps for $1_type not available"
|
||||
%}
|
||||
|
||||
// plain pointer by reference
|
||||
%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") TYPE *CONST&
|
||||
%{ $result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1 SWIG_NO_NULL_DELETER_$owner); %}
|
||||
|
||||
%typemap(directorin) TYPE *CONST&
|
||||
%{ $input = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_0) : 0; %}
|
||||
|
||||
%typemap(directorout) TYPE *CONST& %{
|
||||
#error "typemaps for $1_type not available"
|
||||
%}
|
||||
|
||||
// shared_ptr by value
|
||||
%typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >
|
||||
%{ if ($input) $1 = *($&1_ltype)$input; %}
|
||||
%typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >
|
||||
%{ $result = $1 ? new $1_ltype($1) : 0; %}
|
||||
|
||||
%typemap(directorin) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >
|
||||
%{ $input = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1) : 0; %}
|
||||
|
||||
%typemap(directorout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >
|
||||
%{ if ($input) {
|
||||
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = (SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)$input;
|
||||
$result = *smartarg;
|
||||
}
|
||||
%}
|
||||
|
||||
// shared_ptr by reference
|
||||
%typemap(in, canthrow=1) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & ($*1_ltype tempnull)
|
||||
%{ $1 = $input ? ($1_ltype)$input : &tempnull; %}
|
||||
%typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > &
|
||||
%{ $result = *$1 ? new $*1_ltype(*$1) : 0; %}
|
||||
|
||||
%typemap(directorin) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > &
|
||||
%{ $input = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1) : 0; %}
|
||||
|
||||
%typemap(directorout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & %{
|
||||
#error "typemaps for $1_type not available"
|
||||
%}
|
||||
|
||||
// shared_ptr by pointer
|
||||
%typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * ($*1_ltype tempnull)
|
||||
%{ $1 = $input ? ($1_ltype)$input : &tempnull; %}
|
||||
%typemap(out, fragment="SWIG_null_deleter") SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *
|
||||
%{ $result = ($1 && *$1) ? new $*1_ltype(*$1) : 0;
|
||||
if ($owner) delete $1; %}
|
||||
|
||||
%typemap(directorin) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *
|
||||
%{ $input = ($1 && *$1) ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1) : 0; %}
|
||||
|
||||
%typemap(directorout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * %{
|
||||
#error "typemaps for $1_type not available"
|
||||
%}
|
||||
|
||||
// shared_ptr by pointer reference
|
||||
%typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& (SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempnull, $*1_ltype temp = 0)
|
||||
%{ temp = $input ? *($1_ltype)&$input : &tempnull;
|
||||
$1 = &temp; %}
|
||||
%typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *&
|
||||
%{ *($1_ltype)&$result = (*$1 && **$1) ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(**$1) : 0; %}
|
||||
|
||||
%typemap(directorin) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *&
|
||||
%{ $input = ($1 && *$1) ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1) : 0; %}
|
||||
|
||||
%typemap(directorout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& %{
|
||||
#error "typemaps for $1_type not available"
|
||||
%}
|
||||
|
||||
// various missing typemaps - If ever used (unlikely) ensure compilation error rather than runtime bug
|
||||
%typemap(in) CONST TYPE[], CONST TYPE[ANY], CONST TYPE (CLASS::*) %{
|
||||
#error "typemaps for $1_type not available"
|
||||
%}
|
||||
%typemap(out) CONST TYPE[], CONST TYPE[ANY], CONST TYPE (CLASS::*) %{
|
||||
#error "typemaps for $1_type not available"
|
||||
%}
|
||||
|
||||
|
||||
%typemap (ctype) 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 > *& "void *"
|
||||
%typemap (imtype, out="global::System.IntPtr") 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 > *& "global::System.Runtime.InteropServices.HandleRef"
|
||||
%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 > *& "$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 > *& "$typemap(cstype, TYPE).getCPtr($csinput)"
|
||||
|
||||
%typemap(csout, excode=SWIGEXCODE) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > {
|
||||
global::System.IntPtr cPtr = $imcall;
|
||||
$typemap(cstype, TYPE) ret = (cPtr == global::System.IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode
|
||||
return ret;
|
||||
}
|
||||
%typemap(csout, excode=SWIGEXCODE) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & {
|
||||
global::System.IntPtr cPtr = $imcall;
|
||||
$typemap(cstype, TYPE) ret = (cPtr == global::System.IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode
|
||||
return ret;
|
||||
}
|
||||
%typemap(csout, excode=SWIGEXCODE) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * {
|
||||
global::System.IntPtr cPtr = $imcall;
|
||||
$typemap(cstype, TYPE) ret = (cPtr == global::System.IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode
|
||||
return ret;
|
||||
}
|
||||
%typemap(csout, excode=SWIGEXCODE) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& {
|
||||
global::System.IntPtr cPtr = $imcall;
|
||||
$typemap(cstype, TYPE) ret = (cPtr == global::System.IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
%typemap(csout, excode=SWIGEXCODE) CONST TYPE {
|
||||
$typemap(cstype, TYPE) ret = new $typemap(cstype, TYPE)($imcall, true);$excode
|
||||
return ret;
|
||||
}
|
||||
%typemap(csout, excode=SWIGEXCODE) CONST TYPE & {
|
||||
$typemap(cstype, TYPE) ret = new $typemap(cstype, TYPE)($imcall, true);$excode
|
||||
return ret;
|
||||
}
|
||||
%typemap(csout, excode=SWIGEXCODE) CONST TYPE * {
|
||||
global::System.IntPtr cPtr = $imcall;
|
||||
$typemap(cstype, TYPE) ret = (cPtr == global::System.IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode
|
||||
return ret;
|
||||
}
|
||||
%typemap(csout, excode=SWIGEXCODE) TYPE *CONST& {
|
||||
global::System.IntPtr cPtr = $imcall;
|
||||
$typemap(cstype, TYPE) ret = (cPtr == global::System.IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode
|
||||
return ret;
|
||||
}
|
||||
|
||||
%typemap(csvarout, excode=SWIGEXCODE2) CONST TYPE & %{
|
||||
get {
|
||||
$csclassname ret = new $csclassname($imcall, true);$excode
|
||||
return ret;
|
||||
} %}
|
||||
%typemap(csvarout, excode=SWIGEXCODE2) CONST TYPE * %{
|
||||
get {
|
||||
global::System.IntPtr cPtr = $imcall;
|
||||
$csclassname ret = (cPtr == global::System.IntPtr.Zero) ? null : new $csclassname(cPtr, true);$excode
|
||||
return ret;
|
||||
} %}
|
||||
|
||||
%typemap(csvarout, excode=SWIGEXCODE2) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & %{
|
||||
get {
|
||||
global::System.IntPtr cPtr = $imcall;
|
||||
$typemap(cstype, TYPE) ret = (cPtr == global::System.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 {
|
||||
global::System.IntPtr cPtr = $imcall;
|
||||
$typemap(cstype, TYPE) ret = (cPtr == global::System.IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode
|
||||
return ret;
|
||||
} %}
|
||||
|
||||
%typemap(csdirectorout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > "$typemap(cstype, TYPE).getCPtr($cscall).Handle"
|
||||
|
||||
%typemap(csdirectorin) CONST TYPE,
|
||||
CONST TYPE *,
|
||||
CONST TYPE &,
|
||||
TYPE *CONST& "($iminput == global::System.IntPtr.Zero) ? null : new $typemap(cstype, TYPE)($iminput, true)"
|
||||
|
||||
%typemap(csdirectorin) 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 > *& "($iminput == global::System.IntPtr.Zero) ? null : new $typemap(cstype, TYPE)($iminput, true)"
|
||||
|
||||
|
||||
// Proxy classes (base classes, ie, not derived classes)
|
||||
%typemap(csbody) TYPE %{
|
||||
private global::System.Runtime.InteropServices.HandleRef swigCPtr;
|
||||
private bool swigCMemOwnBase;
|
||||
|
||||
PTRCTOR_VISIBILITY $csclassname(global::System.IntPtr cPtr, bool cMemoryOwn) {
|
||||
swigCMemOwnBase = cMemoryOwn;
|
||||
swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
|
||||
}
|
||||
|
||||
CPTR_VISIBILITY static global::System.Runtime.InteropServices.HandleRef getCPtr($csclassname obj) {
|
||||
return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
|
||||
}
|
||||
%}
|
||||
|
||||
// Derived proxy classes
|
||||
%typemap(csbody_derived) TYPE %{
|
||||
private global::System.Runtime.InteropServices.HandleRef swigCPtr;
|
||||
private bool swigCMemOwnDerived;
|
||||
|
||||
PTRCTOR_VISIBILITY $csclassname(global::System.IntPtr cPtr, bool cMemoryOwn) : base($imclassname.$csclazznameSWIGSmartPtrUpcast(cPtr), true) {
|
||||
swigCMemOwnDerived = cMemoryOwn;
|
||||
swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
|
||||
}
|
||||
|
||||
CPTR_VISIBILITY static global::System.Runtime.InteropServices.HandleRef getCPtr($csclassname obj) {
|
||||
return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
|
||||
}
|
||||
%}
|
||||
|
||||
%typemap(csdisposing, methodname="Dispose", methodmodifiers="protected", parameters="bool disposing") TYPE {
|
||||
lock(this) {
|
||||
if (swigCPtr.Handle != global::System.IntPtr.Zero) {
|
||||
if (swigCMemOwnBase) {
|
||||
swigCMemOwnBase = false;
|
||||
$imcall;
|
||||
}
|
||||
swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
%typemap(csdisposing_derived, methodname="Dispose", methodmodifiers="protected", parameters="bool disposing") TYPE {
|
||||
lock(this) {
|
||||
if (swigCPtr.Handle != global::System.IntPtr.Zero) {
|
||||
if (swigCMemOwnDerived) {
|
||||
swigCMemOwnDerived = false;
|
||||
$imcall;
|
||||
}
|
||||
swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
}
|
||||
|
||||
// Typecheck typemaps
|
||||
%typemap(typecheck, precedence=SWIG_TYPECHECK_POINTER, equivalent="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 > *,
|
||||
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *&
|
||||
""
|
||||
|
||||
%template() SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >;
|
||||
%enddef
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
#ifdef __cplusplus
|
||||
%include <std_complex.i>
|
||||
#else
|
||||
#error C# module only supports complex in C++ mode.
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -1,339 +0,0 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* csharphead.swg
|
||||
*
|
||||
* Support code for exceptions if the SWIG_CSHARP_NO_EXCEPTION_HELPER is not defined
|
||||
* Support code for strings if the SWIG_CSHARP_NO_STRING_HELPER is not defined
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
%insert(runtime) %{
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
%}
|
||||
|
||||
#if !defined(SWIG_CSHARP_NO_EXCEPTION_HELPER)
|
||||
%insert(runtime) %{
|
||||
/* Support for throwing C# exceptions from C/C++. There are two types:
|
||||
* Exceptions that take a message and ArgumentExceptions that take a message and a parameter name. */
|
||||
typedef enum {
|
||||
SWIG_CSharpApplicationException,
|
||||
SWIG_CSharpArithmeticException,
|
||||
SWIG_CSharpDivideByZeroException,
|
||||
SWIG_CSharpIndexOutOfRangeException,
|
||||
SWIG_CSharpInvalidCastException,
|
||||
SWIG_CSharpInvalidOperationException,
|
||||
SWIG_CSharpIOException,
|
||||
SWIG_CSharpNullReferenceException,
|
||||
SWIG_CSharpOutOfMemoryException,
|
||||
SWIG_CSharpOverflowException,
|
||||
SWIG_CSharpSystemException
|
||||
} SWIG_CSharpExceptionCodes;
|
||||
|
||||
typedef enum {
|
||||
SWIG_CSharpArgumentException,
|
||||
SWIG_CSharpArgumentNullException,
|
||||
SWIG_CSharpArgumentOutOfRangeException
|
||||
} SWIG_CSharpExceptionArgumentCodes;
|
||||
|
||||
typedef void (SWIGSTDCALL* SWIG_CSharpExceptionCallback_t)(const char *);
|
||||
typedef void (SWIGSTDCALL* SWIG_CSharpExceptionArgumentCallback_t)(const char *, const char *);
|
||||
|
||||
typedef struct {
|
||||
SWIG_CSharpExceptionCodes code;
|
||||
SWIG_CSharpExceptionCallback_t callback;
|
||||
} SWIG_CSharpException_t;
|
||||
|
||||
typedef struct {
|
||||
SWIG_CSharpExceptionArgumentCodes code;
|
||||
SWIG_CSharpExceptionArgumentCallback_t callback;
|
||||
} SWIG_CSharpExceptionArgument_t;
|
||||
|
||||
static SWIG_CSharpException_t SWIG_csharp_exceptions[] = {
|
||||
{ SWIG_CSharpApplicationException, NULL },
|
||||
{ SWIG_CSharpArithmeticException, NULL },
|
||||
{ SWIG_CSharpDivideByZeroException, NULL },
|
||||
{ SWIG_CSharpIndexOutOfRangeException, NULL },
|
||||
{ SWIG_CSharpInvalidCastException, NULL },
|
||||
{ SWIG_CSharpInvalidOperationException, NULL },
|
||||
{ SWIG_CSharpIOException, NULL },
|
||||
{ SWIG_CSharpNullReferenceException, NULL },
|
||||
{ SWIG_CSharpOutOfMemoryException, NULL },
|
||||
{ SWIG_CSharpOverflowException, NULL },
|
||||
{ SWIG_CSharpSystemException, NULL }
|
||||
};
|
||||
|
||||
static SWIG_CSharpExceptionArgument_t SWIG_csharp_exceptions_argument[] = {
|
||||
{ SWIG_CSharpArgumentException, NULL },
|
||||
{ SWIG_CSharpArgumentNullException, NULL },
|
||||
{ SWIG_CSharpArgumentOutOfRangeException, NULL }
|
||||
};
|
||||
|
||||
static void SWIGUNUSED SWIG_CSharpSetPendingException(SWIG_CSharpExceptionCodes code, const char *msg) {
|
||||
SWIG_CSharpExceptionCallback_t callback = SWIG_csharp_exceptions[SWIG_CSharpApplicationException].callback;
|
||||
if ((size_t)code < sizeof(SWIG_csharp_exceptions)/sizeof(SWIG_CSharpException_t)) {
|
||||
callback = SWIG_csharp_exceptions[code].callback;
|
||||
}
|
||||
callback(msg);
|
||||
}
|
||||
|
||||
static void SWIGUNUSED SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpExceptionArgumentCodes code, const char *msg, const char *param_name) {
|
||||
SWIG_CSharpExceptionArgumentCallback_t callback = SWIG_csharp_exceptions_argument[SWIG_CSharpArgumentException].callback;
|
||||
if ((size_t)code < sizeof(SWIG_csharp_exceptions_argument)/sizeof(SWIG_CSharpExceptionArgument_t)) {
|
||||
callback = SWIG_csharp_exceptions_argument[code].callback;
|
||||
}
|
||||
callback(msg, param_name);
|
||||
}
|
||||
%}
|
||||
|
||||
%insert(runtime) %{
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
#endif
|
||||
SWIGEXPORT void SWIGSTDCALL SWIGRegisterExceptionCallbacks_$module(
|
||||
SWIG_CSharpExceptionCallback_t applicationCallback,
|
||||
SWIG_CSharpExceptionCallback_t arithmeticCallback,
|
||||
SWIG_CSharpExceptionCallback_t divideByZeroCallback,
|
||||
SWIG_CSharpExceptionCallback_t indexOutOfRangeCallback,
|
||||
SWIG_CSharpExceptionCallback_t invalidCastCallback,
|
||||
SWIG_CSharpExceptionCallback_t invalidOperationCallback,
|
||||
SWIG_CSharpExceptionCallback_t ioCallback,
|
||||
SWIG_CSharpExceptionCallback_t nullReferenceCallback,
|
||||
SWIG_CSharpExceptionCallback_t outOfMemoryCallback,
|
||||
SWIG_CSharpExceptionCallback_t overflowCallback,
|
||||
SWIG_CSharpExceptionCallback_t systemCallback) {
|
||||
SWIG_csharp_exceptions[SWIG_CSharpApplicationException].callback = applicationCallback;
|
||||
SWIG_csharp_exceptions[SWIG_CSharpArithmeticException].callback = arithmeticCallback;
|
||||
SWIG_csharp_exceptions[SWIG_CSharpDivideByZeroException].callback = divideByZeroCallback;
|
||||
SWIG_csharp_exceptions[SWIG_CSharpIndexOutOfRangeException].callback = indexOutOfRangeCallback;
|
||||
SWIG_csharp_exceptions[SWIG_CSharpInvalidCastException].callback = invalidCastCallback;
|
||||
SWIG_csharp_exceptions[SWIG_CSharpInvalidOperationException].callback = invalidOperationCallback;
|
||||
SWIG_csharp_exceptions[SWIG_CSharpIOException].callback = ioCallback;
|
||||
SWIG_csharp_exceptions[SWIG_CSharpNullReferenceException].callback = nullReferenceCallback;
|
||||
SWIG_csharp_exceptions[SWIG_CSharpOutOfMemoryException].callback = outOfMemoryCallback;
|
||||
SWIG_csharp_exceptions[SWIG_CSharpOverflowException].callback = overflowCallback;
|
||||
SWIG_csharp_exceptions[SWIG_CSharpSystemException].callback = systemCallback;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
#endif
|
||||
SWIGEXPORT void SWIGSTDCALL SWIGRegisterExceptionArgumentCallbacks_$module(
|
||||
SWIG_CSharpExceptionArgumentCallback_t argumentCallback,
|
||||
SWIG_CSharpExceptionArgumentCallback_t argumentNullCallback,
|
||||
SWIG_CSharpExceptionArgumentCallback_t argumentOutOfRangeCallback) {
|
||||
SWIG_csharp_exceptions_argument[SWIG_CSharpArgumentException].callback = argumentCallback;
|
||||
SWIG_csharp_exceptions_argument[SWIG_CSharpArgumentNullException].callback = argumentNullCallback;
|
||||
SWIG_csharp_exceptions_argument[SWIG_CSharpArgumentOutOfRangeException].callback = argumentOutOfRangeCallback;
|
||||
}
|
||||
%}
|
||||
|
||||
%pragma(csharp) imclasscode=%{
|
||||
protected class SWIGExceptionHelper {
|
||||
|
||||
public delegate void ExceptionDelegate(string message);
|
||||
public delegate void ExceptionArgumentDelegate(string message, string paramName);
|
||||
|
||||
static ExceptionDelegate applicationDelegate = new ExceptionDelegate(SetPendingApplicationException);
|
||||
static ExceptionDelegate arithmeticDelegate = new ExceptionDelegate(SetPendingArithmeticException);
|
||||
static ExceptionDelegate divideByZeroDelegate = new ExceptionDelegate(SetPendingDivideByZeroException);
|
||||
static ExceptionDelegate indexOutOfRangeDelegate = new ExceptionDelegate(SetPendingIndexOutOfRangeException);
|
||||
static ExceptionDelegate invalidCastDelegate = new ExceptionDelegate(SetPendingInvalidCastException);
|
||||
static ExceptionDelegate invalidOperationDelegate = new ExceptionDelegate(SetPendingInvalidOperationException);
|
||||
static ExceptionDelegate ioDelegate = new ExceptionDelegate(SetPendingIOException);
|
||||
static ExceptionDelegate nullReferenceDelegate = new ExceptionDelegate(SetPendingNullReferenceException);
|
||||
static ExceptionDelegate outOfMemoryDelegate = new ExceptionDelegate(SetPendingOutOfMemoryException);
|
||||
static ExceptionDelegate overflowDelegate = new ExceptionDelegate(SetPendingOverflowException);
|
||||
static ExceptionDelegate systemDelegate = new ExceptionDelegate(SetPendingSystemException);
|
||||
|
||||
static ExceptionArgumentDelegate argumentDelegate = new ExceptionArgumentDelegate(SetPendingArgumentException);
|
||||
static ExceptionArgumentDelegate argumentNullDelegate = new ExceptionArgumentDelegate(SetPendingArgumentNullException);
|
||||
static ExceptionArgumentDelegate argumentOutOfRangeDelegate = new ExceptionArgumentDelegate(SetPendingArgumentOutOfRangeException);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("$dllimport", EntryPoint="SWIGRegisterExceptionCallbacks_$module")]
|
||||
public static extern void SWIGRegisterExceptionCallbacks_$module(
|
||||
ExceptionDelegate applicationDelegate,
|
||||
ExceptionDelegate arithmeticDelegate,
|
||||
ExceptionDelegate divideByZeroDelegate,
|
||||
ExceptionDelegate indexOutOfRangeDelegate,
|
||||
ExceptionDelegate invalidCastDelegate,
|
||||
ExceptionDelegate invalidOperationDelegate,
|
||||
ExceptionDelegate ioDelegate,
|
||||
ExceptionDelegate nullReferenceDelegate,
|
||||
ExceptionDelegate outOfMemoryDelegate,
|
||||
ExceptionDelegate overflowDelegate,
|
||||
ExceptionDelegate systemExceptionDelegate);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("$dllimport", EntryPoint="SWIGRegisterExceptionArgumentCallbacks_$module")]
|
||||
public static extern void SWIGRegisterExceptionCallbacksArgument_$module(
|
||||
ExceptionArgumentDelegate argumentDelegate,
|
||||
ExceptionArgumentDelegate argumentNullDelegate,
|
||||
ExceptionArgumentDelegate argumentOutOfRangeDelegate);
|
||||
|
||||
static void SetPendingApplicationException(string message) {
|
||||
SWIGPendingException.Set(new global::System.ApplicationException(message, SWIGPendingException.Retrieve()));
|
||||
}
|
||||
static void SetPendingArithmeticException(string message) {
|
||||
SWIGPendingException.Set(new global::System.ArithmeticException(message, SWIGPendingException.Retrieve()));
|
||||
}
|
||||
static void SetPendingDivideByZeroException(string message) {
|
||||
SWIGPendingException.Set(new global::System.DivideByZeroException(message, SWIGPendingException.Retrieve()));
|
||||
}
|
||||
static void SetPendingIndexOutOfRangeException(string message) {
|
||||
SWIGPendingException.Set(new global::System.IndexOutOfRangeException(message, SWIGPendingException.Retrieve()));
|
||||
}
|
||||
static void SetPendingInvalidCastException(string message) {
|
||||
SWIGPendingException.Set(new global::System.InvalidCastException(message, SWIGPendingException.Retrieve()));
|
||||
}
|
||||
static void SetPendingInvalidOperationException(string message) {
|
||||
SWIGPendingException.Set(new global::System.InvalidOperationException(message, SWIGPendingException.Retrieve()));
|
||||
}
|
||||
static void SetPendingIOException(string message) {
|
||||
SWIGPendingException.Set(new global::System.IO.IOException(message, SWIGPendingException.Retrieve()));
|
||||
}
|
||||
static void SetPendingNullReferenceException(string message) {
|
||||
SWIGPendingException.Set(new global::System.NullReferenceException(message, SWIGPendingException.Retrieve()));
|
||||
}
|
||||
static void SetPendingOutOfMemoryException(string message) {
|
||||
SWIGPendingException.Set(new global::System.OutOfMemoryException(message, SWIGPendingException.Retrieve()));
|
||||
}
|
||||
static void SetPendingOverflowException(string message) {
|
||||
SWIGPendingException.Set(new global::System.OverflowException(message, SWIGPendingException.Retrieve()));
|
||||
}
|
||||
static void SetPendingSystemException(string message) {
|
||||
SWIGPendingException.Set(new global::System.SystemException(message, SWIGPendingException.Retrieve()));
|
||||
}
|
||||
|
||||
static void SetPendingArgumentException(string message, string paramName) {
|
||||
SWIGPendingException.Set(new global::System.ArgumentException(message, paramName, SWIGPendingException.Retrieve()));
|
||||
}
|
||||
static void SetPendingArgumentNullException(string message, string paramName) {
|
||||
global::System.Exception e = SWIGPendingException.Retrieve();
|
||||
if (e != null) message = message + " Inner Exception: " + e.Message;
|
||||
SWIGPendingException.Set(new global::System.ArgumentNullException(paramName, message));
|
||||
}
|
||||
static void SetPendingArgumentOutOfRangeException(string message, string paramName) {
|
||||
global::System.Exception e = SWIGPendingException.Retrieve();
|
||||
if (e != null) message = message + " Inner Exception: " + e.Message;
|
||||
SWIGPendingException.Set(new global::System.ArgumentOutOfRangeException(paramName, message));
|
||||
}
|
||||
|
||||
static SWIGExceptionHelper() {
|
||||
SWIGRegisterExceptionCallbacks_$module(
|
||||
applicationDelegate,
|
||||
arithmeticDelegate,
|
||||
divideByZeroDelegate,
|
||||
indexOutOfRangeDelegate,
|
||||
invalidCastDelegate,
|
||||
invalidOperationDelegate,
|
||||
ioDelegate,
|
||||
nullReferenceDelegate,
|
||||
outOfMemoryDelegate,
|
||||
overflowDelegate,
|
||||
systemDelegate);
|
||||
|
||||
SWIGRegisterExceptionCallbacksArgument_$module(
|
||||
argumentDelegate,
|
||||
argumentNullDelegate,
|
||||
argumentOutOfRangeDelegate);
|
||||
}
|
||||
}
|
||||
|
||||
protected static SWIGExceptionHelper swigExceptionHelper = new SWIGExceptionHelper();
|
||||
|
||||
public class SWIGPendingException {
|
||||
[global::System.ThreadStatic]
|
||||
private static global::System.Exception pendingException = null;
|
||||
private static int numExceptionsPending = 0;
|
||||
private static global::System.Object exceptionsLock = null;
|
||||
|
||||
public static bool Pending {
|
||||
get {
|
||||
bool pending = false;
|
||||
if (numExceptionsPending > 0)
|
||||
if (pendingException != null)
|
||||
pending = true;
|
||||
return pending;
|
||||
}
|
||||
}
|
||||
|
||||
public static void Set(global::System.Exception e) {
|
||||
if (pendingException != null)
|
||||
throw new global::System.ApplicationException("FATAL: An earlier pending exception from unmanaged code was missed and thus not thrown (" + pendingException.ToString() + ")", e);
|
||||
pendingException = e;
|
||||
lock(exceptionsLock) {
|
||||
numExceptionsPending++;
|
||||
}
|
||||
}
|
||||
|
||||
public static global::System.Exception Retrieve() {
|
||||
global::System.Exception e = null;
|
||||
if (numExceptionsPending > 0) {
|
||||
if (pendingException != null) {
|
||||
e = pendingException;
|
||||
pendingException = null;
|
||||
lock(exceptionsLock) {
|
||||
numExceptionsPending--;
|
||||
}
|
||||
}
|
||||
}
|
||||
return e;
|
||||
}
|
||||
|
||||
static SWIGPendingException() {
|
||||
exceptionsLock = new global::System.Object();
|
||||
}
|
||||
}
|
||||
%}
|
||||
#endif // SWIG_CSHARP_NO_EXCEPTION_HELPER
|
||||
|
||||
#if !defined(SWIG_CSHARP_NO_STRING_HELPER)
|
||||
%insert(runtime) %{
|
||||
/* Callback for returning strings to C# without leaking memory */
|
||||
typedef char * (SWIGSTDCALL* SWIG_CSharpStringHelperCallback)(const char *);
|
||||
static SWIG_CSharpStringHelperCallback SWIG_csharp_string_callback = NULL;
|
||||
%}
|
||||
|
||||
%pragma(csharp) imclasscode=%{
|
||||
protected class SWIGStringHelper {
|
||||
|
||||
public delegate string SWIGStringDelegate(string message);
|
||||
static SWIGStringDelegate stringDelegate = new SWIGStringDelegate(CreateString);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("$dllimport", EntryPoint="SWIGRegisterStringCallback_$module")]
|
||||
public static extern void SWIGRegisterStringCallback_$module(SWIGStringDelegate stringDelegate);
|
||||
|
||||
static string CreateString(string cString) {
|
||||
return cString;
|
||||
}
|
||||
|
||||
static SWIGStringHelper() {
|
||||
SWIGRegisterStringCallback_$module(stringDelegate);
|
||||
}
|
||||
}
|
||||
|
||||
static protected SWIGStringHelper swigStringHelper = new SWIGStringHelper();
|
||||
%}
|
||||
|
||||
%insert(runtime) %{
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
#endif
|
||||
SWIGEXPORT void SWIGSTDCALL SWIGRegisterStringCallback_$module(SWIG_CSharpStringHelperCallback callback) {
|
||||
SWIG_csharp_string_callback = callback;
|
||||
}
|
||||
%}
|
||||
#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 */
|
||||
|
||||
#define SWIG_contract_assert(nullreturn, expr, msg) do { if (!(expr)) {SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentOutOfRangeException, msg, ""); return nullreturn; } } while (0)
|
||||
%}
|
||||
|
|
@ -1,97 +0,0 @@
|
|||
#ifndef CSHARP_CSHARPKW_SWG_
|
||||
#define CSHARP_CSHARPKW_SWG_
|
||||
|
||||
/* Warnings for C# keywords */
|
||||
#define CSHARPKW(x) %keywordwarn("'" `x` "' is a C# keyword",rename="%s_") `x`
|
||||
|
||||
#define CSHARPCLASSKW(x) %keywordwarn("'" `x` "' is a special method name used in the C# wrapper classes",%$isclass,rename="%s_") `x`
|
||||
|
||||
/*
|
||||
from
|
||||
http://www.jaggersoft.com/csharp_grammar.html#1.7%20Keywords
|
||||
|
||||
*/
|
||||
|
||||
CSHARPKW(abstract);
|
||||
CSHARPKW(as);
|
||||
CSHARPKW(base);
|
||||
CSHARPKW(bool);
|
||||
CSHARPKW(break);
|
||||
CSHARPKW(byte);
|
||||
CSHARPKW(case);
|
||||
CSHARPKW(catch);
|
||||
CSHARPKW(char);
|
||||
CSHARPKW(checked);
|
||||
CSHARPKW(class);
|
||||
CSHARPKW(const);
|
||||
CSHARPKW(continue);
|
||||
CSHARPKW(decimal);
|
||||
CSHARPKW(default);
|
||||
CSHARPKW(delegate);
|
||||
CSHARPKW(do);
|
||||
CSHARPKW(double);
|
||||
CSHARPKW(else);
|
||||
CSHARPKW(enum);
|
||||
CSHARPKW(event);
|
||||
CSHARPKW(explicit);
|
||||
CSHARPKW(extern);
|
||||
CSHARPKW(false);
|
||||
CSHARPKW(finally);
|
||||
CSHARPKW(fixed);
|
||||
CSHARPKW(float);
|
||||
CSHARPKW(for);
|
||||
CSHARPKW(foreach);
|
||||
CSHARPKW(goto);
|
||||
CSHARPKW(if);
|
||||
CSHARPKW(implicit);
|
||||
CSHARPKW(in);
|
||||
CSHARPKW(int);
|
||||
CSHARPKW(interface);
|
||||
CSHARPKW(internal);
|
||||
CSHARPKW(is);
|
||||
CSHARPKW(lock);
|
||||
CSHARPKW(long);
|
||||
CSHARPKW(namespace);
|
||||
CSHARPKW(new);
|
||||
CSHARPKW(null);
|
||||
CSHARPKW(object);
|
||||
CSHARPKW(operator);
|
||||
CSHARPKW(out);
|
||||
CSHARPKW(override);
|
||||
CSHARPKW(params);
|
||||
CSHARPKW(private);
|
||||
CSHARPKW(protected);
|
||||
CSHARPKW(public);
|
||||
CSHARPKW(readonly);
|
||||
CSHARPKW(ref);
|
||||
CSHARPKW(return);
|
||||
CSHARPKW(sbyte);
|
||||
CSHARPKW(sealed);
|
||||
CSHARPKW(short);
|
||||
CSHARPKW(sizeof);
|
||||
CSHARPKW(stackalloc);
|
||||
CSHARPKW(static);
|
||||
CSHARPKW(struct);
|
||||
CSHARPKW(string);
|
||||
CSHARPKW(switch);
|
||||
CSHARPKW(this);
|
||||
CSHARPKW(throw);
|
||||
CSHARPKW(true);
|
||||
CSHARPKW(try);
|
||||
CSHARPKW(typeof);
|
||||
CSHARPKW(uint);
|
||||
CSHARPKW(ulong);
|
||||
CSHARPKW(unchecked);
|
||||
CSHARPKW(unsafe);
|
||||
CSHARPKW(ushort);
|
||||
CSHARPKW(using);
|
||||
CSHARPKW(virtual);
|
||||
CSHARPKW(void);
|
||||
CSHARPKW(volatile);
|
||||
CSHARPKW(while);
|
||||
|
||||
CSHARPCLASSKW(delete);
|
||||
|
||||
#undef CSHARPKW
|
||||
|
||||
#endif //CSHARP_CSHARPKW_SWG_
|
||||
|
|
@ -1,50 +0,0 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* director.swg
|
||||
*
|
||||
* This file contains support for director classes so that C# proxy
|
||||
* methods can be called from C++.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
#if defined(DEBUG_DIRECTOR_OWNED)
|
||||
#include <iostream>
|
||||
#endif
|
||||
#include <string>
|
||||
#include <exception>
|
||||
|
||||
namespace Swig {
|
||||
/* Director base class - not currently used in C# directors */
|
||||
class Director {
|
||||
};
|
||||
|
||||
/* Base class for director exceptions */
|
||||
class DirectorException : public std::exception {
|
||||
protected:
|
||||
std::string swig_msg;
|
||||
|
||||
public:
|
||||
DirectorException(const char *msg) : swig_msg(msg) {
|
||||
}
|
||||
|
||||
DirectorException(const std::string &msg) : swig_msg(msg) {
|
||||
}
|
||||
|
||||
virtual ~DirectorException() throw() {
|
||||
}
|
||||
|
||||
const char *what() const throw() {
|
||||
return swig_msg.c_str();
|
||||
}
|
||||
};
|
||||
|
||||
/* Pure virtual method exception */
|
||||
class DirectorPureVirtualException : public DirectorException {
|
||||
public:
|
||||
DirectorPureVirtualException(const char *msg) : DirectorException(std::string("Attempt to invoke pure virtual method ") + msg) {
|
||||
}
|
||||
|
||||
static void raise(const char *msg) {
|
||||
throw DirectorPureVirtualException(msg);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -1,86 +0,0 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* enums.swg
|
||||
*
|
||||
* Include this file in order for C/C++ enums to be wrapped by proper C# enums.
|
||||
* Note that the PINVOKE layer handles the enum as an int.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
// const enum SWIGTYPE & typemaps
|
||||
%typemap(ctype) const enum SWIGTYPE & "int"
|
||||
%typemap(imtype) const enum SWIGTYPE & "int"
|
||||
%typemap(cstype) const enum SWIGTYPE & "$*csclassname"
|
||||
|
||||
%typemap(in) const enum SWIGTYPE & ($*1_ltype temp)
|
||||
%{ temp = ($*1_ltype)$input;
|
||||
$1 = &temp; %}
|
||||
%typemap(out) const enum SWIGTYPE & %{ $result = (int)*$1; %}
|
||||
|
||||
%typemap(directorout,warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const enum SWIGTYPE &
|
||||
%{ static $*1_ltype temp = ($*1_ltype)$input;
|
||||
$result = &temp; %}
|
||||
%typemap(directorin) const enum SWIGTYPE & "$input = (int)$1;"
|
||||
%typemap(csdirectorin) const enum SWIGTYPE & "($*csclassname)$iminput"
|
||||
%typemap(csdirectorout) const enum SWIGTYPE & "(int)$cscall"
|
||||
|
||||
%typecheck(SWIG_TYPECHECK_POINTER) const enum SWIGTYPE & ""
|
||||
|
||||
%typemap(throws, canthrow=1) const enum SWIGTYPE &
|
||||
%{ (void)$1;
|
||||
SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, "C++ $1_type exception thrown");
|
||||
return $null; %}
|
||||
|
||||
%typemap(csin) const enum SWIGTYPE & "(int)$csinput"
|
||||
%typemap(csout, excode=SWIGEXCODE) const enum SWIGTYPE & {
|
||||
$*csclassname ret = ($*csclassname)$imcall;$excode
|
||||
return ret;
|
||||
}
|
||||
|
||||
%typemap(csvarout, excode=SWIGEXCODE2) const enum SWIGTYPE & %{
|
||||
get {
|
||||
$*csclassname ret = ($*csclassname)$imcall;$excode
|
||||
return ret;
|
||||
} %}
|
||||
|
||||
|
||||
// enum SWIGTYPE typemaps
|
||||
%typemap(ctype) enum SWIGTYPE "int"
|
||||
%typemap(imtype) enum SWIGTYPE "int"
|
||||
%typemap(cstype) enum SWIGTYPE "$csclassname"
|
||||
|
||||
%typemap(in) enum SWIGTYPE %{ $1 = ($1_ltype)$input; %}
|
||||
%typemap(out) enum SWIGTYPE %{ $result = (int)$1; %}
|
||||
|
||||
%typemap(directorout) enum SWIGTYPE %{ $result = ($1_ltype)$input; %}
|
||||
%typemap(directorin) enum SWIGTYPE "$input = (int)$1;"
|
||||
%typemap(csdirectorin) enum SWIGTYPE "($csclassname)$iminput"
|
||||
%typemap(csdirectorout) enum SWIGTYPE "(int)$cscall"
|
||||
|
||||
%typecheck(SWIG_TYPECHECK_POINTER) enum SWIGTYPE ""
|
||||
|
||||
%typemap(throws, canthrow=1) enum SWIGTYPE
|
||||
%{ (void)$1;
|
||||
SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, "C++ $1_type exception thrown");
|
||||
return $null; %}
|
||||
|
||||
%typemap(csin) enum SWIGTYPE "(int)$csinput"
|
||||
%typemap(csout, excode=SWIGEXCODE) enum SWIGTYPE {
|
||||
$csclassname ret = ($csclassname)$imcall;$excode
|
||||
return ret;
|
||||
}
|
||||
|
||||
%typemap(csvarout, excode=SWIGEXCODE2) enum SWIGTYPE %{
|
||||
get {
|
||||
$csclassname ret = ($csclassname)$imcall;$excode
|
||||
return ret;
|
||||
} %}
|
||||
|
||||
%typemap(csbase) enum SWIGTYPE ""
|
||||
%typemap(csclassmodifiers) enum SWIGTYPE "public enum"
|
||||
%typemap(cscode) enum SWIGTYPE ""
|
||||
%typemap(csimports) enum SWIGTYPE ""
|
||||
%typemap(csinterfaces) enum SWIGTYPE ""
|
||||
|
||||
%typemap(csbody) enum SWIGTYPE ""
|
||||
|
||||
%csenum(proper);
|
||||
|
||||
|
|
@ -1,88 +0,0 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* enumsimple.swg
|
||||
*
|
||||
* This file provides backwards compatible enum wrapping. SWIG versions 1.3.21
|
||||
* and earlier wrapped global enums with constant integers in the module
|
||||
* class. Enums declared within a C++ class were wrapped by constant integers
|
||||
* in the C# proxy class.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
// const enum SWIGTYPE & typemaps
|
||||
%typemap(ctype) const enum SWIGTYPE & "int"
|
||||
%typemap(imtype) const enum SWIGTYPE & "int"
|
||||
%typemap(cstype) const enum SWIGTYPE & "int"
|
||||
|
||||
%typemap(in) const enum SWIGTYPE & ($*1_ltype temp)
|
||||
%{ temp = ($*1_ltype)$input;
|
||||
$1 = &temp; %}
|
||||
%typemap(out) const enum SWIGTYPE & %{ $result = (int)*$1; %}
|
||||
|
||||
%typemap(directorout,warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const enum SWIGTYPE &
|
||||
%{ static $*1_ltype temp = ($*1_ltype)$input;
|
||||
$result = &temp; %}
|
||||
%typemap(directorin) const enum SWIGTYPE & "$input = (int)$1;"
|
||||
%typemap(csdirectorin) const enum SWIGTYPE & "$iminput"
|
||||
%typemap(csdirectorout) const enum SWIGTYPE & "$cscall"
|
||||
|
||||
%typecheck(SWIG_TYPECHECK_INT32) const enum SWIGTYPE & ""
|
||||
|
||||
%typemap(throws, canthrow=1) const enum SWIGTYPE &
|
||||
%{ (void)$1;
|
||||
SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, "C++ $1_type exception thrown");
|
||||
return $null; %}
|
||||
|
||||
%typemap(csin) const enum SWIGTYPE & "$csinput"
|
||||
%typemap(csout, excode=SWIGEXCODE) const enum SWIGTYPE & {
|
||||
int ret = $imcall;$excode
|
||||
return ret;
|
||||
}
|
||||
|
||||
%typemap(csvarout, excode=SWIGEXCODE2) const enum SWIGTYPE & %{
|
||||
get {
|
||||
int ret = $imcall;$excode
|
||||
return ret;
|
||||
} %}
|
||||
|
||||
|
||||
// enum SWIGTYPE typemaps
|
||||
%typemap(ctype) enum SWIGTYPE "int"
|
||||
%typemap(imtype) enum SWIGTYPE "int"
|
||||
%typemap(cstype) enum SWIGTYPE "int"
|
||||
|
||||
%typemap(in) enum SWIGTYPE %{ $1 = ($1_ltype)$input; %}
|
||||
%typemap(out) enum SWIGTYPE %{ $result = (int)$1; %}
|
||||
|
||||
%typemap(directorout) enum SWIGTYPE %{ $result = ($1_ltype)$input; %}
|
||||
%typemap(directorin) enum SWIGTYPE "$input = (int)$1;"
|
||||
%typemap(csdirectorin) enum SWIGTYPE "$iminput"
|
||||
%typemap(csdirectorout) enum SWIGTYPE "$cscall"
|
||||
|
||||
%typecheck(SWIG_TYPECHECK_INT32) enum SWIGTYPE ""
|
||||
|
||||
%typemap(throws, canthrow=1) enum SWIGTYPE
|
||||
%{ (void)$1;
|
||||
SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, "C++ $1_type exception thrown");
|
||||
return $null; %}
|
||||
|
||||
%typemap(csin) enum SWIGTYPE "$csinput"
|
||||
%typemap(csout, excode=SWIGEXCODE) enum SWIGTYPE {
|
||||
int ret = $imcall;$excode
|
||||
return ret;
|
||||
}
|
||||
|
||||
%typemap(csvarout, excode=SWIGEXCODE2) enum SWIGTYPE %{
|
||||
get {
|
||||
int ret = $imcall;$excode
|
||||
return ret;
|
||||
} %}
|
||||
|
||||
%typemap(csbase) enum SWIGTYPE ""
|
||||
%typemap(csclassmodifiers) enum SWIGTYPE ""
|
||||
%typemap(cscode) enum SWIGTYPE ""
|
||||
%typemap(csimports) enum SWIGTYPE ""
|
||||
%typemap(csinterfaces) enum SWIGTYPE ""
|
||||
|
||||
%typemap(csbody) enum SWIGTYPE ""
|
||||
|
||||
%csenum(simple);
|
||||
|
||||
|
|
@ -1,130 +0,0 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* enumtypesafe.swg
|
||||
*
|
||||
* Include this file in order for C/C++ enums to be wrapped by the so called
|
||||
* typesafe enum pattern. Each enum has an equivalent C# class named after the
|
||||
* enum and each enum item is a static instance of this class.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
// const enum SWIGTYPE & typemaps
|
||||
%typemap(ctype) const enum SWIGTYPE & "int"
|
||||
%typemap(imtype) const enum SWIGTYPE & "int"
|
||||
%typemap(cstype) const enum SWIGTYPE & "$*csclassname"
|
||||
|
||||
%typemap(in) const enum SWIGTYPE & ($*1_ltype temp)
|
||||
%{ temp = ($*1_ltype)$input;
|
||||
$1 = &temp; %}
|
||||
%typemap(out) const enum SWIGTYPE & %{ $result = (int)*$1; %}
|
||||
|
||||
%typemap(directorout,warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const enum SWIGTYPE &
|
||||
%{ static $*1_ltype temp = ($*1_ltype)$input;
|
||||
$result = &temp; %}
|
||||
%typemap(directorin) const enum SWIGTYPE & "$input = (int)$1;"
|
||||
%typemap(csdirectorin) const enum SWIGTYPE & "$*csclassname.swigToEnum($iminput)"
|
||||
%typemap(csdirectorout) const enum SWIGTYPE & "$cscall.swigValue"
|
||||
|
||||
%typecheck(SWIG_TYPECHECK_POINTER) const enum SWIGTYPE & ""
|
||||
|
||||
%typemap(throws, canthrow=1) const enum SWIGTYPE &
|
||||
%{ (void)$1;
|
||||
SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, "C++ $1_type exception thrown");
|
||||
return $null; %}
|
||||
|
||||
%typemap(csin) const enum SWIGTYPE & "$csinput.swigValue"
|
||||
%typemap(csout, excode=SWIGEXCODE) const enum SWIGTYPE & {
|
||||
$*csclassname ret = $*csclassname.swigToEnum($imcall);$excode
|
||||
return ret;
|
||||
}
|
||||
|
||||
%typemap(csvarout, excode=SWIGEXCODE2) const enum SWIGTYPE & %{
|
||||
get {
|
||||
$*csclassname ret = $*csclassname.swigToEnum($imcall);$excode
|
||||
return ret;
|
||||
} %}
|
||||
|
||||
|
||||
// enum SWIGTYPE typemaps
|
||||
%typemap(ctype) enum SWIGTYPE "int"
|
||||
%typemap(imtype) enum SWIGTYPE "int"
|
||||
%typemap(cstype) enum SWIGTYPE "$csclassname"
|
||||
|
||||
%typemap(in) enum SWIGTYPE %{ $1 = ($1_ltype)$input; %}
|
||||
%typemap(out) enum SWIGTYPE %{ $result = (int)$1; %}
|
||||
|
||||
%typemap(directorout) enum SWIGTYPE %{ $result = ($1_ltype)$input; %}
|
||||
%typemap(directorin) enum SWIGTYPE "$input = (int)$1;"
|
||||
%typemap(csdirectorin) enum SWIGTYPE "$csclassname.swigToEnum($iminput)"
|
||||
%typemap(csdirectorout) enum SWIGTYPE "$cscall.swigValue"
|
||||
|
||||
%typecheck(SWIG_TYPECHECK_POINTER) enum SWIGTYPE ""
|
||||
|
||||
%typemap(throws, canthrow=1) enum SWIGTYPE
|
||||
%{ (void)$1;
|
||||
SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, "C++ $1_type exception thrown");
|
||||
return $null; %}
|
||||
|
||||
%typemap(csin) enum SWIGTYPE "$csinput.swigValue"
|
||||
%typemap(csout, excode=SWIGEXCODE) enum SWIGTYPE {
|
||||
$csclassname ret = $csclassname.swigToEnum($imcall);$excode
|
||||
return ret;
|
||||
}
|
||||
|
||||
%typemap(csvarout, excode=SWIGEXCODE2) enum SWIGTYPE %{
|
||||
get {
|
||||
$csclassname ret = $csclassname.swigToEnum($imcall);$excode
|
||||
return ret;
|
||||
} %}
|
||||
|
||||
%typemap(csbase) enum SWIGTYPE ""
|
||||
%typemap(csclassmodifiers) enum SWIGTYPE "public sealed class"
|
||||
%typemap(cscode) enum SWIGTYPE ""
|
||||
%typemap(csimports) enum SWIGTYPE ""
|
||||
%typemap(csinterfaces) enum SWIGTYPE ""
|
||||
|
||||
/*
|
||||
* The swigToEnum method is used to find the C# enum from a C++ enum integer value. The default one here takes
|
||||
* advantage of the fact that most enums do not have initial values specified, so the lookup is fast. If initial
|
||||
* values are specified then a lengthy linear search through all possible enums might occur. Specific typemaps could be
|
||||
* written to possibly optimise this lookup by taking advantage of characteristics peculiar to the targeted enum.
|
||||
* The special variable, $enumvalues, is replaced with a comma separated list of all the enum values.
|
||||
*/
|
||||
%typemap(csbody) enum SWIGTYPE %{
|
||||
public readonly int swigValue;
|
||||
|
||||
public static $csclassname swigToEnum(int swigValue) {
|
||||
if (swigValue < swigValues.Length && swigValue >= 0 && swigValues[swigValue].swigValue == swigValue)
|
||||
return swigValues[swigValue];
|
||||
for (int i = 0; i < swigValues.Length; i++)
|
||||
if (swigValues[i].swigValue == swigValue)
|
||||
return swigValues[i];
|
||||
throw new global::System.ArgumentOutOfRangeException("No enum $csclassname with value " + swigValue);
|
||||
}
|
||||
|
||||
public override string ToString() {
|
||||
return swigName;
|
||||
}
|
||||
|
||||
private $csclassname(string swigName) {
|
||||
this.swigName = swigName;
|
||||
this.swigValue = swigNext++;
|
||||
}
|
||||
|
||||
private $csclassname(string swigName, int swigValue) {
|
||||
this.swigName = swigName;
|
||||
this.swigValue = swigValue;
|
||||
swigNext = swigValue+1;
|
||||
}
|
||||
|
||||
private $csclassname(string swigName, $csclassname swigEnum) {
|
||||
this.swigName = swigName;
|
||||
this.swigValue = swigEnum.swigValue;
|
||||
swigNext = this.swigValue+1;
|
||||
}
|
||||
|
||||
private static $csclassname[] swigValues = { $enumvalues };
|
||||
private static int swigNext = 0;
|
||||
private readonly string swigName;
|
||||
%}
|
||||
|
||||
%csenum(typesafe);
|
||||
|
||||
|
|
@ -1,227 +0,0 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* std_array.i
|
||||
*
|
||||
* SWIG typemaps for std::array<T, N>
|
||||
* C# implementation
|
||||
* The C# wrapper is made to look and feel like a C# System.Collections.Generic.IReadOnlyList<> collection.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
%{
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <stdexcept>
|
||||
%}
|
||||
|
||||
%include <std_common.i>
|
||||
|
||||
|
||||
%define SWIG_STD_ARRAY_INTERNAL(T, N)
|
||||
%typemap(csinterfaces) std::array< T, N > "global::System.IDisposable, global::System.Collections.IEnumerable\n , global::System.Collections.Generic.IEnumerable<$typemap(cstype, T)>\n"
|
||||
%proxycode %{
|
||||
public $csclassname(global::System.Collections.ICollection c) : this() {
|
||||
if (c == null)
|
||||
throw new global::System.ArgumentNullException("c");
|
||||
int end = global::System.Math.Min(this.Count, c.Count);
|
||||
int i = 0;
|
||||
foreach ($typemap(cstype, T) elem in c) {
|
||||
if (i >= end)
|
||||
break;
|
||||
this[i++] = elem;
|
||||
}
|
||||
}
|
||||
|
||||
public int Count {
|
||||
get {
|
||||
return (int)size();
|
||||
}
|
||||
}
|
||||
|
||||
public $typemap(cstype, T) this[int index] {
|
||||
get {
|
||||
return getitem(index);
|
||||
}
|
||||
set {
|
||||
setitem(index, value);
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsEmpty {
|
||||
get {
|
||||
return empty();
|
||||
}
|
||||
}
|
||||
|
||||
public void CopyTo($typemap(cstype, T)[] array)
|
||||
{
|
||||
CopyTo(0, array, 0, this.Count);
|
||||
}
|
||||
|
||||
public void CopyTo($typemap(cstype, T)[] array, int arrayIndex)
|
||||
{
|
||||
CopyTo(0, array, arrayIndex, this.Count);
|
||||
}
|
||||
|
||||
public void CopyTo(int index, $typemap(cstype, T)[] array, int arrayIndex, int count)
|
||||
{
|
||||
if (array == null)
|
||||
throw new global::System.ArgumentNullException("array");
|
||||
if (index < 0)
|
||||
throw new global::System.ArgumentOutOfRangeException("index", "Value is less than zero");
|
||||
if (arrayIndex < 0)
|
||||
throw new global::System.ArgumentOutOfRangeException("arrayIndex", "Value is less than zero");
|
||||
if (count < 0)
|
||||
throw new global::System.ArgumentOutOfRangeException("count", "Value is less than zero");
|
||||
if (array.Rank > 1)
|
||||
throw new global::System.ArgumentException("Multi dimensional array.", "array");
|
||||
if (index+count > this.Count || arrayIndex+count > array.Length)
|
||||
throw new global::System.ArgumentException("Number of elements to copy is too large.");
|
||||
for (int i=0; i<count; i++)
|
||||
array.SetValue(getitemcopy(index+i), arrayIndex+i);
|
||||
}
|
||||
|
||||
global::System.Collections.Generic.IEnumerator<$typemap(cstype, T)> global::System.Collections.Generic.IEnumerable<$typemap(cstype, T)>.GetEnumerator() {
|
||||
return new $csclassnameEnumerator(this);
|
||||
}
|
||||
|
||||
global::System.Collections.IEnumerator global::System.Collections.IEnumerable.GetEnumerator() {
|
||||
return new $csclassnameEnumerator(this);
|
||||
}
|
||||
|
||||
public $csclassnameEnumerator GetEnumerator() {
|
||||
return new $csclassnameEnumerator(this);
|
||||
}
|
||||
|
||||
// Type-safe enumerator
|
||||
/// Note that the IEnumerator documentation requires an InvalidOperationException to be thrown
|
||||
/// whenever the collection is modified. This has been done for changes in the size of the
|
||||
/// collection but not when one of the elements of the collection is modified as it is a bit
|
||||
/// tricky to detect unmanaged code that modifies the collection under our feet.
|
||||
public sealed class $csclassnameEnumerator : global::System.Collections.IEnumerator
|
||||
, global::System.Collections.Generic.IEnumerator<$typemap(cstype, T)>
|
||||
{
|
||||
private $csclassname collectionRef;
|
||||
private int currentIndex;
|
||||
private object currentObject;
|
||||
private int currentSize;
|
||||
|
||||
public $csclassnameEnumerator($csclassname collection) {
|
||||
collectionRef = collection;
|
||||
currentIndex = -1;
|
||||
currentObject = null;
|
||||
currentSize = collectionRef.Count;
|
||||
}
|
||||
|
||||
// Type-safe iterator Current
|
||||
public $typemap(cstype, T) Current {
|
||||
get {
|
||||
if (currentIndex == -1)
|
||||
throw new global::System.InvalidOperationException("Enumeration not started.");
|
||||
if (currentIndex > currentSize - 1)
|
||||
throw new global::System.InvalidOperationException("Enumeration finished.");
|
||||
if (currentObject == null)
|
||||
throw new global::System.InvalidOperationException("Collection modified.");
|
||||
return ($typemap(cstype, T))currentObject;
|
||||
}
|
||||
}
|
||||
|
||||
// Type-unsafe IEnumerator.Current
|
||||
object global::System.Collections.IEnumerator.Current {
|
||||
get {
|
||||
return Current;
|
||||
}
|
||||
}
|
||||
|
||||
public bool MoveNext() {
|
||||
int size = collectionRef.Count;
|
||||
bool moveOkay = (currentIndex+1 < size) && (size == currentSize);
|
||||
if (moveOkay) {
|
||||
currentIndex++;
|
||||
currentObject = collectionRef[currentIndex];
|
||||
} else {
|
||||
currentObject = null;
|
||||
}
|
||||
return moveOkay;
|
||||
}
|
||||
|
||||
public void Reset() {
|
||||
currentIndex = -1;
|
||||
currentObject = null;
|
||||
if (collectionRef.Count != currentSize) {
|
||||
throw new global::System.InvalidOperationException("Collection modified.");
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose() {
|
||||
currentIndex = -1;
|
||||
currentObject = null;
|
||||
}
|
||||
}
|
||||
%}
|
||||
|
||||
public:
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef T value_type;
|
||||
typedef value_type* pointer;
|
||||
typedef const value_type* const_pointer;
|
||||
typedef value_type& reference;
|
||||
typedef const value_type& const_reference;
|
||||
|
||||
array();
|
||||
array(const array &other);
|
||||
|
||||
size_type size() const;
|
||||
bool empty() const;
|
||||
|
||||
%rename(Fill) fill;
|
||||
void fill(const value_type& value);
|
||||
|
||||
%rename(Swap) swap;
|
||||
void swap(array& other);
|
||||
|
||||
%extend {
|
||||
T getitemcopy(int index) throw (std::out_of_range) {
|
||||
if (index>=0 && index<(int)$self->size())
|
||||
return (*$self)[index];
|
||||
else
|
||||
throw std::out_of_range("index");
|
||||
}
|
||||
const_reference getitem(int index) throw (std::out_of_range) {
|
||||
if (index>=0 && index<(int)$self->size())
|
||||
return (*$self)[index];
|
||||
else
|
||||
throw std::out_of_range("index");
|
||||
}
|
||||
void setitem(int index, const_reference val) throw (std::out_of_range) {
|
||||
if (index>=0 && index<(int)$self->size())
|
||||
(*$self)[index] = val;
|
||||
else
|
||||
throw std::out_of_range("index");
|
||||
}
|
||||
void Reverse() {
|
||||
std::reverse($self->begin(), $self->end());
|
||||
}
|
||||
void Reverse(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");
|
||||
std::reverse($self->begin()+index, $self->begin()+index+count);
|
||||
}
|
||||
}
|
||||
%enddef
|
||||
|
||||
|
||||
%csmethodmodifiers std::array::empty "private"
|
||||
%csmethodmodifiers std::array::getitemcopy "private"
|
||||
%csmethodmodifiers std::array::getitem "private"
|
||||
%csmethodmodifiers std::array::setitem "private"
|
||||
%csmethodmodifiers std::array::size "private"
|
||||
|
||||
namespace std {
|
||||
template<class T, size_t N> class array {
|
||||
SWIG_STD_ARRAY_INTERNAL(T, N)
|
||||
};
|
||||
}
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* std_auto_ptr.i
|
||||
*
|
||||
* SWIG library file for handling std::auto_ptr.
|
||||
* Memory ownership is passed from the std::auto_ptr C++ layer to the proxy
|
||||
* class when returning a std::auto_ptr from a function.
|
||||
* Memory ownership is passed from the proxy class to the std::auto_ptr in the
|
||||
* C++ layer when passed as a parameter to a wrapped function.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
%define %auto_ptr(TYPE)
|
||||
%typemap (ctype) std::auto_ptr< TYPE > "void *"
|
||||
%typemap (imtype, out="System.IntPtr") std::auto_ptr< TYPE > "global::System.Runtime.InteropServices.HandleRef"
|
||||
%typemap (cstype) std::auto_ptr< TYPE > "$typemap(cstype, TYPE)"
|
||||
|
||||
%typemap(in) std::auto_ptr< TYPE >
|
||||
%{ $1.reset((TYPE *)$input); %}
|
||||
|
||||
%typemap(csin) std::auto_ptr< TYPE > "$typemap(cstype, TYPE).swigRelease($csinput)"
|
||||
|
||||
%typemap (out) std::auto_ptr< TYPE > %{
|
||||
$result = (void *)$1.release();
|
||||
%}
|
||||
|
||||
%typemap(csout, excode=SWIGEXCODE) std::auto_ptr< TYPE > {
|
||||
System.IntPtr cPtr = $imcall;
|
||||
$typemap(cstype, TYPE) ret = (cPtr == System.IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode
|
||||
return ret;
|
||||
}
|
||||
|
||||
%typemap(typecheck, precedence=SWIG_TYPECHECK_POINTER, equivalent="TYPE *") std::auto_ptr< TYPE > ""
|
||||
|
||||
%template() std::auto_ptr< TYPE >;
|
||||
%enddef
|
||||
|
||||
namespace std {
|
||||
template <class T> class auto_ptr {};
|
||||
}
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
%include <std_except.i>
|
||||
|
||||
%apply size_t { std::size_t };
|
||||
%apply const size_t& { const std::size_t& };
|
||||
|
||||
|
|
@ -1,95 +0,0 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* std_complex.i
|
||||
*
|
||||
* Typemaps for handling std::complex<float> and std::complex<double> as a .NET
|
||||
* System.Numerics.Complex type. Requires .NET 4 minimum.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
%{
|
||||
#include <complex>
|
||||
%}
|
||||
|
||||
%fragment("SwigSystemNumericsComplex", "header") {
|
||||
extern "C" {
|
||||
// Identical to the layout of System.Numerics.Complex, but does assume that it is
|
||||
// LayoutKind.Sequential on the managed side
|
||||
struct SwigSystemNumericsComplex {
|
||||
double real;
|
||||
double imag;
|
||||
};
|
||||
}
|
||||
|
||||
SWIGINTERN SwigSystemNumericsComplex SwigCreateSystemNumericsComplex(double real, double imag) {
|
||||
SwigSystemNumericsComplex cpx;
|
||||
cpx.real = real;
|
||||
cpx.imag = imag;
|
||||
return cpx;
|
||||
}
|
||||
}
|
||||
|
||||
namespace std {
|
||||
|
||||
%naturalvar complex;
|
||||
|
||||
template<typename T>
|
||||
class complex
|
||||
{
|
||||
public:
|
||||
complex(T re = T(), T im = T());
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
%define SWIG_COMPLEX_TYPEMAPS(T)
|
||||
%typemap(ctype, fragment="SwigSystemNumericsComplex") std::complex<T>, const std::complex<T> & "SwigSystemNumericsComplex"
|
||||
%typemap(imtype) std::complex<T>, const std::complex<T> & "System.Numerics.Complex"
|
||||
%typemap(cstype) std::complex<T>, const std::complex<T> & "System.Numerics.Complex"
|
||||
|
||||
%typemap(in) std::complex<T>
|
||||
%{$1 = std::complex< double >($input.real, $input.imag);%}
|
||||
|
||||
%typemap(in) const std::complex<T> &($*1_ltype temp)
|
||||
%{temp = std::complex< T >((T)$input.real, (T)$input.imag);
|
||||
$1 = &temp;%}
|
||||
|
||||
%typemap(out, null="SwigCreateSystemNumericsComplex(0.0, 0.0)") std::complex<T>
|
||||
%{$result = SwigCreateSystemNumericsComplex($1.real(), $1.imag());%}
|
||||
|
||||
%typemap(out, null="SwigCreateSystemNumericsComplex(0.0, 0.0)") const std::complex<T> &
|
||||
%{$result = SwigCreateSystemNumericsComplex($1->real(), $1->imag());%}
|
||||
|
||||
%typemap(cstype) std::complex<T>, const std::complex<T> & "System.Numerics.Complex"
|
||||
|
||||
%typemap(csin) std::complex<T>, const std::complex<T> & "$csinput"
|
||||
|
||||
%typemap(csout, excode=SWIGEXCODE) std::complex<T>, const std::complex<T> & {
|
||||
System.Numerics.Complex ret = $imcall;$excode
|
||||
return ret;
|
||||
}
|
||||
|
||||
%typemap(csvarin, excode=SWIGEXCODE2) const std::complex<T> & %{
|
||||
set {
|
||||
$imcall;$excode
|
||||
}
|
||||
%}
|
||||
|
||||
%typemap(csvarout, excode=SWIGEXCODE2) const std::complex<T> & %{
|
||||
get {
|
||||
System.Numerics.Complex ret = $imcall;$excode
|
||||
return ret;
|
||||
}
|
||||
%}
|
||||
|
||||
%template() std::complex<T>;
|
||||
%enddef
|
||||
|
||||
// By default, typemaps for both std::complex<double> and std::complex<float>
|
||||
// are defined, but one of them can be disabled by predefining the
|
||||
// corresponding symbol before including this file.
|
||||
#ifndef SWIG_NO_STD_COMPLEX_DOUBLE
|
||||
SWIG_COMPLEX_TYPEMAPS(double)
|
||||
#endif
|
||||
|
||||
#ifndef SWIG_NO_STD_COMPLEX_FLOAT
|
||||
SWIG_COMPLEX_TYPEMAPS(float)
|
||||
#endif
|
||||
|
|
@ -1 +0,0 @@
|
|||
%include <std/_std_deque.i>
|
||||
|
|
@ -1,32 +0,0 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* 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 <typeinfo>
|
||||
#include <stdexcept>
|
||||
%}
|
||||
|
||||
namespace std
|
||||
{
|
||||
%ignore exception;
|
||||
struct exception {};
|
||||
}
|
||||
|
||||
%typemap(throws, canthrow=1) std::bad_cast "SWIG_CSharpSetPendingException(SWIG_CSharpInvalidCastException, $1.what());\n return $null;"
|
||||
%typemap(throws, canthrow=1) std::bad_exception "SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, $1.what());\n return $null;"
|
||||
%typemap(throws, canthrow=1) std::domain_error "SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, $1.what());\n return $null;"
|
||||
%typemap(throws, canthrow=1) std::exception "SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, $1.what());\n return $null;"
|
||||
%typemap(throws, canthrow=1) std::invalid_argument "SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentException, $1.what(), \"\");\n return $null;"
|
||||
%typemap(throws, canthrow=1) std::length_error "SWIG_CSharpSetPendingException(SWIG_CSharpIndexOutOfRangeException, $1.what());\n return $null;"
|
||||
%typemap(throws, canthrow=1) std::logic_error "SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, $1.what());\n return $null;"
|
||||
%typemap(throws, canthrow=1) std::out_of_range "SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentOutOfRangeException, 0, $1.what());\n return $null;"
|
||||
%typemap(throws, canthrow=1) std::overflow_error "SWIG_CSharpSetPendingException(SWIG_CSharpOverflowException, $1.what());\n return $null;"
|
||||
%typemap(throws, canthrow=1) std::range_error "SWIG_CSharpSetPendingException(SWIG_CSharpIndexOutOfRangeException, $1.what());\n return $null;"
|
||||
%typemap(throws, canthrow=1) std::runtime_error "SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, $1.what());\n return $null;"
|
||||
%typemap(throws, canthrow=1) std::underflow_error "SWIG_CSharpSetPendingException(SWIG_CSharpOverflowException, $1.what());\n return $null;"
|
||||
|
||||
|
|
@ -1,519 +0,0 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* std_list.i
|
||||
*
|
||||
* SWIG typemaps for std::list<T>
|
||||
* C# implementation
|
||||
* The C# wrapper is made to look and feel like a C# System.Collections.Generic.LinkedList<> collection.
|
||||
*
|
||||
* Note that IEnumerable<> is implemented in the proxy class which is useful for using LINQ with
|
||||
* C++ std::list wrappers. The ICollection<> interface is also implemented to provide enhanced functionality
|
||||
* whenever we are confident that the required C++ operator== is available. This is the case for when
|
||||
* T is a primitive type or a pointer. If T does define an operator==, then use the SWIG_STD_LIST_ENHANCED
|
||||
* macro to obtain this enhanced functionality, for example:
|
||||
*
|
||||
* SWIG_STD_LIST_ENHANCED(SomeNamespace::Klass)
|
||||
* %template(ListKlass) std::list<SomeNamespace::Klass>;
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
%include <std_common.i>
|
||||
|
||||
// MACRO for use within the std::list class body
|
||||
%define SWIG_STD_LIST_MINIMUM_INTERNAL(CSINTERFACE, CTYPE...)
|
||||
%typemap(csinterfaces) std::list< CTYPE > "global::System.IDisposable, global::System.Collections.IEnumerable, global::System.Collections.Generic.CSINTERFACE<$typemap(cstype, CTYPE)>\n"
|
||||
|
||||
%apply void *VOID_INT_PTR { std::list< CTYPE >::iterator * };
|
||||
|
||||
%proxycode %{
|
||||
public $csclassname(global::System.Collections.IEnumerable c) : this() {
|
||||
if (c == null)
|
||||
throw new global::System.ArgumentNullException("c");
|
||||
foreach ($typemap(cstype, CTYPE) element in c) {
|
||||
this.AddLast(element);
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsReadOnly {
|
||||
get {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public int Count {
|
||||
get {
|
||||
return (int)size();
|
||||
}
|
||||
}
|
||||
|
||||
public $csclassnameNode First {
|
||||
get {
|
||||
if (Count == 0)
|
||||
return null;
|
||||
return new $csclassnameNode(getFirstIter(), this);
|
||||
}
|
||||
}
|
||||
|
||||
public $csclassnameNode Last {
|
||||
get {
|
||||
if (Count == 0)
|
||||
return null;
|
||||
return new $csclassnameNode(getLastIter(), this);
|
||||
}
|
||||
}
|
||||
|
||||
public $csclassnameNode AddFirst($typemap(cstype, CTYPE) value) {
|
||||
push_front(value);
|
||||
return new $csclassnameNode(getFirstIter(), this);
|
||||
}
|
||||
|
||||
public void AddFirst($csclassnameNode newNode) {
|
||||
ValidateNewNode(newNode);
|
||||
if (!newNode.inlist) {
|
||||
push_front(newNode.csharpvalue);
|
||||
newNode.iter = getFirstIter();
|
||||
newNode.inlist = true;
|
||||
} else {
|
||||
throw new global::System.InvalidOperationException("The " + newNode.GetType().Name + " node already belongs to a " + this.GetType().Name);
|
||||
}
|
||||
}
|
||||
|
||||
public $csclassnameNode AddLast($typemap(cstype, CTYPE) value) {
|
||||
push_back(value);
|
||||
return new $csclassnameNode(getLastIter(), this);
|
||||
}
|
||||
|
||||
public void AddLast($csclassnameNode newNode) {
|
||||
ValidateNewNode(newNode);
|
||||
if (!newNode.inlist) {
|
||||
push_back(newNode.csharpvalue);
|
||||
newNode.iter = getLastIter();
|
||||
newNode.inlist = true;
|
||||
} else {
|
||||
throw new global::System.InvalidOperationException("The " + newNode.GetType().Name + " node already belongs to a " + this.GetType().Name);
|
||||
}
|
||||
}
|
||||
|
||||
public $csclassnameNode AddBefore($csclassnameNode node, $typemap(cstype, CTYPE) value) {
|
||||
return new $csclassnameNode(insertNode(node.iter, value), this);
|
||||
}
|
||||
|
||||
public void AddBefore($csclassnameNode node, $csclassnameNode newNode) {
|
||||
ValidateNode(node);
|
||||
ValidateNewNode(newNode);
|
||||
if (!newNode.inlist) {
|
||||
newNode.iter = insertNode(node.iter, newNode.csharpvalue);
|
||||
newNode.inlist = true;
|
||||
} else {
|
||||
throw new global::System.InvalidOperationException("The " + newNode.GetType().Name + " node already belongs to a " + this.GetType().Name);
|
||||
}
|
||||
}
|
||||
|
||||
public $csclassnameNode AddAfter($csclassnameNode node, $typemap(cstype, CTYPE) value) {
|
||||
node = node.Next;
|
||||
return new $csclassnameNode(insertNode(node.iter, value), this);
|
||||
}
|
||||
|
||||
public void AddAfter($csclassnameNode node, $csclassnameNode newNode) {
|
||||
ValidateNode(node);
|
||||
ValidateNewNode(newNode);
|
||||
if (!newNode.inlist) {
|
||||
if (node == this.Last)
|
||||
AddLast(newNode);
|
||||
else
|
||||
{
|
||||
node = node.Next;
|
||||
newNode.iter = insertNode(node.iter, newNode.csharpvalue);
|
||||
newNode.inlist = true;
|
||||
}
|
||||
} else {
|
||||
throw new global::System.InvalidOperationException("The " + newNode.GetType().Name + " node already belongs to a " + this.GetType().Name);
|
||||
}
|
||||
}
|
||||
|
||||
public void Add($typemap(cstype, CTYPE) value) {
|
||||
AddLast(value);
|
||||
}
|
||||
|
||||
public void Remove($csclassnameNode node) {
|
||||
ValidateNode(node);
|
||||
eraseIter(node.iter);
|
||||
}
|
||||
|
||||
public void CopyTo($typemap(cstype, CTYPE)[] array, int index) {
|
||||
if (array == null)
|
||||
throw new global::System.ArgumentNullException("array");
|
||||
if (index < 0 || index > array.Length)
|
||||
throw new global::System.ArgumentOutOfRangeException("index", "Value is less than zero");
|
||||
if (array.Rank > 1)
|
||||
throw new global::System.ArgumentException("Multi dimensional array.", "array");
|
||||
$csclassnameNode node = this.First;
|
||||
if (node != null) {
|
||||
do {
|
||||
array[index++] = node.Value;
|
||||
node = node.Next;
|
||||
} while (node != null);
|
||||
}
|
||||
}
|
||||
|
||||
internal void ValidateNode($csclassnameNode node) {
|
||||
if (node == null) {
|
||||
throw new System.ArgumentNullException("node");
|
||||
}
|
||||
if (!node.inlist || node.list != this) {
|
||||
throw new System.InvalidOperationException("node");
|
||||
}
|
||||
}
|
||||
|
||||
internal void ValidateNewNode($csclassnameNode node) {
|
||||
if (node == null) {
|
||||
throw new System.ArgumentNullException("node");
|
||||
}
|
||||
}
|
||||
|
||||
global::System.Collections.Generic.IEnumerator<$typemap(cstype, CTYPE)> global::System.Collections.Generic.IEnumerable<$typemap(cstype, CTYPE)>.GetEnumerator() {
|
||||
return new $csclassnameEnumerator(this);
|
||||
}
|
||||
|
||||
global::System.Collections.IEnumerator global::System.Collections.IEnumerable.GetEnumerator() {
|
||||
return new $csclassnameEnumerator(this);
|
||||
}
|
||||
|
||||
public $csclassnameEnumerator GetEnumerator() {
|
||||
return new $csclassnameEnumerator(this);
|
||||
}
|
||||
|
||||
public sealed class $csclassnameEnumerator : global::System.Collections.IEnumerator,
|
||||
global::System.Collections.Generic.IEnumerator<$typemap(cstype, CTYPE)>
|
||||
{
|
||||
private $csclassname collectionRef;
|
||||
private $csclassnameNode currentNode;
|
||||
private int currentIndex;
|
||||
private object currentObject;
|
||||
private int currentSize;
|
||||
|
||||
public $csclassnameEnumerator($csclassname collection) {
|
||||
collectionRef = collection;
|
||||
currentNode = collection.First;
|
||||
currentIndex = 0;
|
||||
currentObject = null;
|
||||
currentSize = collectionRef.Count;
|
||||
}
|
||||
|
||||
// Type-safe iterator Current
|
||||
public $typemap(cstype, CTYPE) Current {
|
||||
get {
|
||||
if (currentIndex == -1)
|
||||
throw new global::System.InvalidOperationException("Enumeration not started.");
|
||||
if (currentIndex > currentSize)
|
||||
throw new global::System.InvalidOperationException("Enumeration finished.");
|
||||
if (currentObject == null)
|
||||
throw new global::System.InvalidOperationException("Collection modified.");
|
||||
return ($typemap(cstype, CTYPE))currentObject;
|
||||
}
|
||||
}
|
||||
|
||||
// Type-unsafe IEnumerator.Current
|
||||
object global::System.Collections.IEnumerator.Current {
|
||||
get {
|
||||
return Current;
|
||||
}
|
||||
}
|
||||
|
||||
public bool MoveNext() {
|
||||
if (currentNode == null) {
|
||||
currentIndex = collectionRef.Count + 1;
|
||||
return false;
|
||||
}
|
||||
++currentIndex;
|
||||
currentObject = currentNode.Value;
|
||||
currentNode = currentNode.Next;
|
||||
return true;
|
||||
}
|
||||
|
||||
public void Reset() {
|
||||
currentIndex = -1;
|
||||
currentObject = null;
|
||||
if (collectionRef.Count != currentSize) {
|
||||
throw new global::System.InvalidOperationException("Collection modified.");
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose() {
|
||||
currentIndex = -1;
|
||||
currentObject = null;
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class $csclassnameNode {
|
||||
internal $csclassname list;
|
||||
internal System.IntPtr iter;
|
||||
internal $typemap(cstype, CTYPE) csharpvalue;
|
||||
internal bool inlist;
|
||||
|
||||
public $csclassnameNode($typemap(cstype, CTYPE) value) {
|
||||
csharpvalue = value;
|
||||
inlist = false;
|
||||
}
|
||||
|
||||
internal $csclassnameNode(System.IntPtr iter, $csclassname list) {
|
||||
this.list = list;
|
||||
this.iter = iter;
|
||||
inlist = true;
|
||||
}
|
||||
|
||||
public $csclassname List {
|
||||
get {
|
||||
return this.list;
|
||||
}
|
||||
}
|
||||
|
||||
public $csclassnameNode Next {
|
||||
get {
|
||||
if (list.getNextIter(iter) == System.IntPtr.Zero)
|
||||
return null;
|
||||
return new $csclassnameNode(list.getNextIter(iter), list);
|
||||
}
|
||||
}
|
||||
|
||||
public $csclassnameNode Previous {
|
||||
get {
|
||||
if (list.getPrevIter(iter) == System.IntPtr.Zero)
|
||||
return null;
|
||||
return new $csclassnameNode(list.getPrevIter(iter), list);
|
||||
}
|
||||
}
|
||||
|
||||
public $typemap(cstype, CTYPE) Value {
|
||||
get {
|
||||
return list.getItem(this.iter);
|
||||
}
|
||||
set {
|
||||
list.setItem(this.iter, value);
|
||||
}
|
||||
}
|
||||
|
||||
public static bool operator==($csclassnameNode node1, $csclassnameNode node2) {
|
||||
if (object.ReferenceEquals(node1, null) && object.ReferenceEquals(node2, null))
|
||||
return true;
|
||||
if (object.ReferenceEquals(node1, null) || object.ReferenceEquals(node2, null))
|
||||
return false;
|
||||
return node1.Equals(node2);
|
||||
}
|
||||
|
||||
public static bool operator!=($csclassnameNode node1, $csclassnameNode node2) {
|
||||
if (node1 == null && node2 == null)
|
||||
return false;
|
||||
if (node1 == null || node2 == null)
|
||||
return true;
|
||||
return !node1.Equals(node2);
|
||||
}
|
||||
|
||||
public bool Equals($csclassnameNode node) {
|
||||
if (node == null)
|
||||
return false;
|
||||
if (!node.inlist || !this.inlist)
|
||||
return object.ReferenceEquals(this, node);
|
||||
return list.equals(this.iter, node.iter);
|
||||
}
|
||||
|
||||
public override bool Equals(object node) {
|
||||
return Equals(($csclassnameNode)node);
|
||||
}
|
||||
|
||||
public override int GetHashCode() {
|
||||
int hash = 13;
|
||||
if (inlist) {
|
||||
hash = (hash * 7) + this.list.GetHashCode();
|
||||
hash = (hash * 7) + this.Value.GetHashCode();
|
||||
hash = (hash * 7) + this.list.getNextIter(this.iter).GetHashCode();
|
||||
hash = (hash * 7) + this.list.getPrevIter(this.iter).GetHashCode();
|
||||
} else {
|
||||
hash = (hash * 7) + this.csharpvalue.GetHashCode();
|
||||
}
|
||||
return hash;
|
||||
}
|
||||
|
||||
public void Dispose() {
|
||||
list.deleteIter(this.iter);
|
||||
}
|
||||
}
|
||||
%}
|
||||
|
||||
public:
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef CTYPE value_type;
|
||||
typedef value_type* pointer;
|
||||
typedef const value_type* const_pointer;
|
||||
typedef value_type& reference;
|
||||
typedef const value_type& const_reference;
|
||||
|
||||
class iterator;
|
||||
|
||||
void push_front(CTYPE const& x);
|
||||
void push_back(CTYPE const& x);
|
||||
%rename(RemoveFirst) pop_front;
|
||||
void pop_front();
|
||||
%rename(RemoveLast) pop_back;
|
||||
void pop_back();
|
||||
size_type size() const;
|
||||
%rename(Clear) clear;
|
||||
void clear();
|
||||
%extend {
|
||||
const_reference getItem(iterator *iter) {
|
||||
return **iter;
|
||||
}
|
||||
|
||||
void setItem(iterator *iter, CTYPE const& val) {
|
||||
*(*iter) = val;
|
||||
}
|
||||
|
||||
iterator *getFirstIter() {
|
||||
if ($self->size() == 0)
|
||||
return NULL;
|
||||
return new std::list< CTYPE >::iterator($self->begin());
|
||||
}
|
||||
|
||||
iterator *getLastIter() {
|
||||
if ($self->size() == 0)
|
||||
return NULL;
|
||||
return new std::list< CTYPE >::iterator(--$self->end());
|
||||
}
|
||||
|
||||
iterator *getNextIter(iterator *iter) {
|
||||
std::list< CTYPE >::iterator it = *iter;
|
||||
if (std::distance(it, --$self->end()) != 0) {
|
||||
std::list< CTYPE >::iterator* itnext = new std::list< CTYPE >::iterator(++it);
|
||||
return itnext;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
iterator *getPrevIter(iterator *iter) {
|
||||
std::list< CTYPE >::iterator it = *iter;
|
||||
if (std::distance($self->begin(), it) != 0) {
|
||||
std::list< CTYPE >::iterator* itprev = new std::list< CTYPE >::iterator(--it);
|
||||
return itprev;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
iterator *insertNode(iterator *iter, CTYPE const& value) {
|
||||
std::list< CTYPE >::iterator it = $self->insert(*iter, value);
|
||||
return new std::list< CTYPE >::iterator(it);
|
||||
}
|
||||
|
||||
void eraseIter(iterator *iter) {
|
||||
std::list< CTYPE >::iterator it = *iter;
|
||||
$self->erase(it);
|
||||
}
|
||||
|
||||
void deleteIter(iterator *iter) {
|
||||
delete iter;
|
||||
}
|
||||
|
||||
bool equals(iterator *iter1, iterator *iter2) {
|
||||
if (iter1 == NULL && iter2 == NULL)
|
||||
return true;
|
||||
std::list< CTYPE >::iterator it1 = *iter1;
|
||||
std::list< CTYPE >::iterator it2 = *iter2;
|
||||
return it1 == it2;
|
||||
}
|
||||
}
|
||||
%enddef
|
||||
|
||||
// Extra methods added to the collection class if operator== is defined for the class being wrapped
|
||||
// The class will then implement ICollection<>, which adds extra functionality
|
||||
%define SWIG_STD_LIST_EXTRA_OP_EQUALS_EQUALS(CTYPE...)
|
||||
%extend {
|
||||
bool Contains(CTYPE const& value) {
|
||||
return std::find($self->begin(), $self->end(), value) != $self->end();
|
||||
}
|
||||
|
||||
bool Remove(CTYPE const& value) {
|
||||
std::list< CTYPE >::iterator it = std::find($self->begin(), $self->end(), value);
|
||||
if (it != $self->end()) {
|
||||
$self->erase(it);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
iterator *find(CTYPE const& value) {
|
||||
if (std::find($self->begin(), $self->end(), value) != $self->end()) {
|
||||
return new std::list< CTYPE >::iterator(std::find($self->begin(), $self->end(), value));
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
%proxycode %{
|
||||
public $csclassnameNode Find($typemap(cstype, CTYPE) value) {
|
||||
System.IntPtr tmp = find(value);
|
||||
if (tmp != System.IntPtr.Zero) {
|
||||
return new $csclassnameNode(tmp, this);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
%}
|
||||
%enddef
|
||||
|
||||
// Macros for std::list class specializations/enhancements
|
||||
%define SWIG_STD_LIST_ENHANCED(CTYPE...)
|
||||
namespace std {
|
||||
template<> class list< CTYPE > {
|
||||
SWIG_STD_LIST_MINIMUM_INTERNAL(ICollection, %arg(CTYPE));
|
||||
SWIG_STD_LIST_EXTRA_OP_EQUALS_EQUALS(CTYPE)
|
||||
};
|
||||
}
|
||||
%enddef
|
||||
|
||||
|
||||
%{
|
||||
#include <list>
|
||||
#include <algorithm>
|
||||
#include <stdexcept>
|
||||
%}
|
||||
|
||||
%csmethodmodifiers std::list::size "private"
|
||||
%csmethodmodifiers std::list::getItem "private"
|
||||
%csmethodmodifiers std::list::setItem "private"
|
||||
%csmethodmodifiers std::list::push_front "private"
|
||||
%csmethodmodifiers std::list::push_back "private"
|
||||
%csmethodmodifiers std::list::getFirstIter "private"
|
||||
%csmethodmodifiers std::list::getNextIter "private"
|
||||
%csmethodmodifiers std::list::getPrevIter "private"
|
||||
%csmethodmodifiers std::list::getLastIter "private"
|
||||
%csmethodmodifiers std::list::find "private"
|
||||
%csmethodmodifiers std::list::deleteIter "private"
|
||||
|
||||
namespace std {
|
||||
// primary (unspecialized) class template for std::list
|
||||
// does not require operator== to be defined
|
||||
template<class T>
|
||||
class list {
|
||||
SWIG_STD_LIST_MINIMUM_INTERNAL(IEnumerable, T)
|
||||
};
|
||||
// specialization for pointers
|
||||
template<class T>
|
||||
class list<T *> {
|
||||
SWIG_STD_LIST_MINIMUM_INTERNAL(ICollection, T *)
|
||||
SWIG_STD_LIST_EXTRA_OP_EQUALS_EQUALS(T *)
|
||||
};
|
||||
}
|
||||
|
||||
// template specializations for std::list
|
||||
// these provide extra collections methods as operator== is defined
|
||||
SWIG_STD_LIST_ENHANCED(char)
|
||||
SWIG_STD_LIST_ENHANCED(signed char)
|
||||
SWIG_STD_LIST_ENHANCED(unsigned char)
|
||||
SWIG_STD_LIST_ENHANCED(short)
|
||||
SWIG_STD_LIST_ENHANCED(unsigned short)
|
||||
SWIG_STD_LIST_ENHANCED(int)
|
||||
SWIG_STD_LIST_ENHANCED(unsigned int)
|
||||
SWIG_STD_LIST_ENHANCED(long)
|
||||
SWIG_STD_LIST_ENHANCED(unsigned long)
|
||||
SWIG_STD_LIST_ENHANCED(long long)
|
||||
SWIG_STD_LIST_ENHANCED(unsigned long long)
|
||||
SWIG_STD_LIST_ENHANCED(float)
|
||||
SWIG_STD_LIST_ENHANCED(double)
|
||||
SWIG_STD_LIST_ENHANCED(std::string) // also requires a %include <std_string.i>
|
||||
SWIG_STD_LIST_ENHANCED(std::wstring) // also requires a %include <std_wstring.i>
|
||||
|
|
@ -1,312 +0,0 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* std_map.i
|
||||
*
|
||||
* SWIG typemaps for std::map< K, T, C >
|
||||
*
|
||||
* The C# wrapper is made to look and feel like a C# System.Collections.Generic.IDictionary<>.
|
||||
*
|
||||
* Using this wrapper is fairly simple. For example, to create a map from integers to doubles use:
|
||||
*
|
||||
* %include <std_map.i>
|
||||
* %template(MapIntDouble) std::map<int, double>
|
||||
*
|
||||
* Notes:
|
||||
* 1) IEnumerable<> is implemented in the proxy class which is useful for using LINQ with
|
||||
* C++ std::map wrappers.
|
||||
*
|
||||
* Warning: heavy macro usage in this file. Use swig -E to get a sane view on the real file contents!
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
%{
|
||||
#include <map>
|
||||
#include <algorithm>
|
||||
#include <stdexcept>
|
||||
%}
|
||||
|
||||
/* K is the C++ key type, T is the C++ value type */
|
||||
%define SWIG_STD_MAP_INTERNAL(K, T, C)
|
||||
|
||||
%typemap(csinterfaces) std::map< K, T, C > "global::System.IDisposable \n , global::System.Collections.Generic.IDictionary<$typemap(cstype, K), $typemap(cstype, T)>\n"
|
||||
%proxycode %{
|
||||
|
||||
public $typemap(cstype, T) this[$typemap(cstype, K) key] {
|
||||
get {
|
||||
return getitem(key);
|
||||
}
|
||||
|
||||
set {
|
||||
setitem(key, value);
|
||||
}
|
||||
}
|
||||
|
||||
public bool TryGetValue($typemap(cstype, K) key, out $typemap(cstype, T) value) {
|
||||
if (this.ContainsKey(key)) {
|
||||
value = this[key];
|
||||
return true;
|
||||
}
|
||||
value = default($typemap(cstype, T));
|
||||
return false;
|
||||
}
|
||||
|
||||
public int Count {
|
||||
get {
|
||||
return (int)size();
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsReadOnly {
|
||||
get {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public global::System.Collections.Generic.ICollection<$typemap(cstype, K)> Keys {
|
||||
get {
|
||||
global::System.Collections.Generic.ICollection<$typemap(cstype, K)> keys = new global::System.Collections.Generic.List<$typemap(cstype, K)>();
|
||||
int size = this.Count;
|
||||
if (size > 0) {
|
||||
global::System.IntPtr iter = create_iterator_begin();
|
||||
for (int i = 0; i < size; i++) {
|
||||
keys.Add(get_next_key(iter));
|
||||
}
|
||||
destroy_iterator(iter);
|
||||
}
|
||||
return keys;
|
||||
}
|
||||
}
|
||||
|
||||
public global::System.Collections.Generic.ICollection<$typemap(cstype, T)> Values {
|
||||
get {
|
||||
global::System.Collections.Generic.ICollection<$typemap(cstype, T)> vals = new global::System.Collections.Generic.List<$typemap(cstype, T)>();
|
||||
foreach (global::System.Collections.Generic.KeyValuePair<$typemap(cstype, K), $typemap(cstype, T)> pair in this) {
|
||||
vals.Add(pair.Value);
|
||||
}
|
||||
return vals;
|
||||
}
|
||||
}
|
||||
|
||||
public void Add(global::System.Collections.Generic.KeyValuePair<$typemap(cstype, K), $typemap(cstype, T)> item) {
|
||||
Add(item.Key, item.Value);
|
||||
}
|
||||
|
||||
public bool Remove(global::System.Collections.Generic.KeyValuePair<$typemap(cstype, K), $typemap(cstype, T)> item) {
|
||||
if (Contains(item)) {
|
||||
return Remove(item.Key);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public bool Contains(global::System.Collections.Generic.KeyValuePair<$typemap(cstype, K), $typemap(cstype, T)> item) {
|
||||
if (this[item.Key] == item.Value) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void CopyTo(global::System.Collections.Generic.KeyValuePair<$typemap(cstype, K), $typemap(cstype, T)>[] array) {
|
||||
CopyTo(array, 0);
|
||||
}
|
||||
|
||||
public void CopyTo(global::System.Collections.Generic.KeyValuePair<$typemap(cstype, K), $typemap(cstype, T)>[] array, int arrayIndex) {
|
||||
if (array == null)
|
||||
throw new global::System.ArgumentNullException("array");
|
||||
if (arrayIndex < 0)
|
||||
throw new global::System.ArgumentOutOfRangeException("arrayIndex", "Value is less than zero");
|
||||
if (array.Rank > 1)
|
||||
throw new global::System.ArgumentException("Multi dimensional array.", "array");
|
||||
if (arrayIndex+this.Count > array.Length)
|
||||
throw new global::System.ArgumentException("Number of elements to copy is too large.");
|
||||
|
||||
global::System.Collections.Generic.IList<$typemap(cstype, K)> keyList = new global::System.Collections.Generic.List<$typemap(cstype, K)>(this.Keys);
|
||||
for (int i = 0; i < keyList.Count; i++) {
|
||||
$typemap(cstype, K) currentKey = keyList[i];
|
||||
array.SetValue(new global::System.Collections.Generic.KeyValuePair<$typemap(cstype, K), $typemap(cstype, T)>(currentKey, this[currentKey]), arrayIndex+i);
|
||||
}
|
||||
}
|
||||
|
||||
global::System.Collections.Generic.IEnumerator<global::System.Collections.Generic.KeyValuePair<$typemap(cstype, K), $typemap(cstype, T)>> global::System.Collections.Generic.IEnumerable<global::System.Collections.Generic.KeyValuePair<$typemap(cstype, K), $typemap(cstype, T)>>.GetEnumerator() {
|
||||
return new $csclassnameEnumerator(this);
|
||||
}
|
||||
|
||||
global::System.Collections.IEnumerator global::System.Collections.IEnumerable.GetEnumerator() {
|
||||
return new $csclassnameEnumerator(this);
|
||||
}
|
||||
|
||||
public $csclassnameEnumerator GetEnumerator() {
|
||||
return new $csclassnameEnumerator(this);
|
||||
}
|
||||
|
||||
// Type-safe enumerator
|
||||
/// Note that the IEnumerator documentation requires an InvalidOperationException to be thrown
|
||||
/// whenever the collection is modified. This has been done for changes in the size of the
|
||||
/// collection but not when one of the elements of the collection is modified as it is a bit
|
||||
/// tricky to detect unmanaged code that modifies the collection under our feet.
|
||||
public sealed class $csclassnameEnumerator : global::System.Collections.IEnumerator,
|
||||
global::System.Collections.Generic.IEnumerator<global::System.Collections.Generic.KeyValuePair<$typemap(cstype, K), $typemap(cstype, T)>>
|
||||
{
|
||||
private $csclassname collectionRef;
|
||||
private global::System.Collections.Generic.IList<$typemap(cstype, K)> keyCollection;
|
||||
private int currentIndex;
|
||||
private object currentObject;
|
||||
private int currentSize;
|
||||
|
||||
public $csclassnameEnumerator($csclassname collection) {
|
||||
collectionRef = collection;
|
||||
keyCollection = new global::System.Collections.Generic.List<$typemap(cstype, K)>(collection.Keys);
|
||||
currentIndex = -1;
|
||||
currentObject = null;
|
||||
currentSize = collectionRef.Count;
|
||||
}
|
||||
|
||||
// Type-safe iterator Current
|
||||
public global::System.Collections.Generic.KeyValuePair<$typemap(cstype, K), $typemap(cstype, T)> Current {
|
||||
get {
|
||||
if (currentIndex == -1)
|
||||
throw new global::System.InvalidOperationException("Enumeration not started.");
|
||||
if (currentIndex > currentSize - 1)
|
||||
throw new global::System.InvalidOperationException("Enumeration finished.");
|
||||
if (currentObject == null)
|
||||
throw new global::System.InvalidOperationException("Collection modified.");
|
||||
return (global::System.Collections.Generic.KeyValuePair<$typemap(cstype, K), $typemap(cstype, T)>)currentObject;
|
||||
}
|
||||
}
|
||||
|
||||
// Type-unsafe IEnumerator.Current
|
||||
object global::System.Collections.IEnumerator.Current {
|
||||
get {
|
||||
return Current;
|
||||
}
|
||||
}
|
||||
|
||||
public bool MoveNext() {
|
||||
int size = collectionRef.Count;
|
||||
bool moveOkay = (currentIndex+1 < size) && (size == currentSize);
|
||||
if (moveOkay) {
|
||||
currentIndex++;
|
||||
$typemap(cstype, K) currentKey = keyCollection[currentIndex];
|
||||
currentObject = new global::System.Collections.Generic.KeyValuePair<$typemap(cstype, K), $typemap(cstype, T)>(currentKey, collectionRef[currentKey]);
|
||||
} else {
|
||||
currentObject = null;
|
||||
}
|
||||
return moveOkay;
|
||||
}
|
||||
|
||||
public void Reset() {
|
||||
currentIndex = -1;
|
||||
currentObject = null;
|
||||
if (collectionRef.Count != currentSize) {
|
||||
throw new global::System.InvalidOperationException("Collection modified.");
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose() {
|
||||
currentIndex = -1;
|
||||
currentObject = null;
|
||||
}
|
||||
}
|
||||
|
||||
%}
|
||||
|
||||
public:
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef K key_type;
|
||||
typedef T mapped_type;
|
||||
typedef std::pair< const K, T > value_type;
|
||||
typedef value_type* pointer;
|
||||
typedef const value_type* const_pointer;
|
||||
typedef value_type& reference;
|
||||
typedef const value_type& const_reference;
|
||||
|
||||
map();
|
||||
map(const map& other);
|
||||
size_type size() const;
|
||||
bool empty() const;
|
||||
%rename(Clear) clear;
|
||||
void clear();
|
||||
%extend {
|
||||
const mapped_type& getitem(const key_type& key) throw (std::out_of_range) {
|
||||
std::map< K, T, C >::iterator iter = $self->find(key);
|
||||
if (iter != $self->end())
|
||||
return iter->second;
|
||||
else
|
||||
throw std::out_of_range("key not found");
|
||||
}
|
||||
|
||||
void setitem(const key_type& key, const mapped_type& x) {
|
||||
(*$self)[key] = x;
|
||||
}
|
||||
|
||||
bool ContainsKey(const key_type& key) {
|
||||
std::map< K, T, C >::iterator iter = $self->find(key);
|
||||
return iter != $self->end();
|
||||
}
|
||||
|
||||
void Add(const key_type& key, const mapped_type& value) throw (std::out_of_range) {
|
||||
std::map< K, T, C >::iterator iter = $self->find(key);
|
||||
if (iter != $self->end())
|
||||
throw std::out_of_range("key already exists");
|
||||
$self->insert(std::pair< K, T >(key, value));
|
||||
}
|
||||
|
||||
bool Remove(const key_type& key) {
|
||||
std::map< K, T, C >::iterator iter = $self->find(key);
|
||||
if (iter != $self->end()) {
|
||||
$self->erase(iter);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// create_iterator_begin(), get_next_key() and destroy_iterator work together to provide a collection of keys to C#
|
||||
%apply void *VOID_INT_PTR { std::map< K, T, C >::iterator *create_iterator_begin }
|
||||
%apply void *VOID_INT_PTR { std::map< K, T, C >::iterator *swigiterator }
|
||||
|
||||
std::map< K, T, C >::iterator *create_iterator_begin() {
|
||||
return new std::map< K, T, C >::iterator($self->begin());
|
||||
}
|
||||
|
||||
const key_type& get_next_key(std::map< K, T, C >::iterator *swigiterator) {
|
||||
std::map< K, T, C >::iterator iter = *swigiterator;
|
||||
(*swigiterator)++;
|
||||
return (*iter).first;
|
||||
}
|
||||
|
||||
void destroy_iterator(std::map< K, T, C >::iterator *swigiterator) {
|
||||
delete swigiterator;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
%enddef
|
||||
|
||||
%csmethodmodifiers std::map::size "private"
|
||||
%csmethodmodifiers std::map::getitem "private"
|
||||
%csmethodmodifiers std::map::setitem "private"
|
||||
%csmethodmodifiers std::map::create_iterator_begin "private"
|
||||
%csmethodmodifiers std::map::get_next_key "private"
|
||||
%csmethodmodifiers std::map::destroy_iterator "private"
|
||||
|
||||
// Default implementation
|
||||
namespace std {
|
||||
template<class K, class T, class C = std::less<K> > class map {
|
||||
SWIG_STD_MAP_INTERNAL(K, T, C)
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
// 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
|
||||
|
||||
%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_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
|
||||
|
||||
|
|
@ -1,36 +0,0 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* 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 {
|
||||
typedef T first_type;
|
||||
typedef U second_type;
|
||||
|
||||
pair();
|
||||
pair(T first, U second);
|
||||
pair(const pair& other);
|
||||
|
||||
template <class U1, class U2> pair(const pair<U1, U2> &other);
|
||||
|
||||
T first;
|
||||
U second;
|
||||
};
|
||||
|
||||
// add specializations here
|
||||
|
||||
}
|
||||
|
|
@ -1,311 +0,0 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* std_set.i
|
||||
*
|
||||
* SWIG typemaps for std::set<T>.
|
||||
*
|
||||
* Note that ISet<> used here requires .NET 4 or later.
|
||||
*
|
||||
* The C# wrapper implements ISet<> interface and shares performance
|
||||
* characteristics of C# System.Collections.Generic.SortedSet<> class, but
|
||||
* doesn't provide quite all of its methods.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
%{
|
||||
#include <set>
|
||||
#include <algorithm>
|
||||
#include <stdexcept>
|
||||
%}
|
||||
|
||||
%csmethodmodifiers std::set::size "private"
|
||||
%csmethodmodifiers std::set::getitem "private"
|
||||
%csmethodmodifiers std::set::create_iterator_begin "private"
|
||||
%csmethodmodifiers std::set::get_next "private"
|
||||
%csmethodmodifiers std::set::destroy_iterator "private"
|
||||
|
||||
namespace std {
|
||||
|
||||
// TODO: Add support for comparator and allocator template parameters.
|
||||
template <class T>
|
||||
class set {
|
||||
|
||||
%typemap(csinterfaces) std::set<T> "global::System.IDisposable, global::System.Collections.Generic.ISet<$typemap(cstype, T)>\n"
|
||||
%proxycode %{
|
||||
void global::System.Collections.Generic.ICollection<$typemap(cstype, T)>.Add($typemap(cstype, T) item) {
|
||||
((global::System.Collections.Generic.ISet<$typemap(cstype, T)>)this).Add(item);
|
||||
}
|
||||
|
||||
public bool TryGetValue($typemap(cstype, T) equalValue, out $typemap(cstype, T) actualValue) {
|
||||
try {
|
||||
actualValue = getitem(equalValue);
|
||||
return true;
|
||||
} catch {
|
||||
actualValue = default($typemap(cstype, T));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public int Count {
|
||||
get {
|
||||
return (int)size();
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsReadOnly {
|
||||
get {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void CopyTo($typemap(cstype, T)[] array) {
|
||||
CopyTo(array, 0);
|
||||
}
|
||||
|
||||
public void CopyTo($typemap(cstype, T)[] array, int arrayIndex) {
|
||||
if (array == null)
|
||||
throw new global::System.ArgumentNullException("array");
|
||||
if (arrayIndex < 0)
|
||||
throw new global::System.ArgumentOutOfRangeException("arrayIndex", "Value is less than zero");
|
||||
if (array.Rank > 1)
|
||||
throw new global::System.ArgumentException("Multi dimensional array.", "array");
|
||||
if (arrayIndex+this.Count > array.Length)
|
||||
throw new global::System.ArgumentException("Number of elements to copy is too large.");
|
||||
|
||||
foreach ($typemap(cstype, T) item in this) {
|
||||
array.SetValue(item, arrayIndex++);
|
||||
}
|
||||
}
|
||||
|
||||
public void ExceptWith(global::System.Collections.Generic.IEnumerable<$typemap(cstype, T)> other) {
|
||||
foreach ($typemap(cstype, T) item in other) {
|
||||
Remove(item);
|
||||
}
|
||||
}
|
||||
|
||||
public void IntersectWith(global::System.Collections.Generic.IEnumerable<$typemap(cstype, T)> other) {
|
||||
$csclassname old = new $csclassname(this);
|
||||
|
||||
Clear();
|
||||
foreach ($typemap(cstype, T) item in other) {
|
||||
if (old.Contains(item))
|
||||
Add(item);
|
||||
}
|
||||
}
|
||||
|
||||
private static int count_enum(global::System.Collections.Generic.IEnumerable<$typemap(cstype, T)> other) {
|
||||
int count = 0;
|
||||
foreach ($typemap(cstype, T) item in other) {
|
||||
count++;
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
public bool IsProperSubsetOf(global::System.Collections.Generic.IEnumerable<$typemap(cstype, T)> other) {
|
||||
return IsSubsetOf(other) && Count < count_enum(other);
|
||||
}
|
||||
|
||||
public bool IsProperSupersetOf(global::System.Collections.Generic.IEnumerable<$typemap(cstype, T)> other) {
|
||||
return IsSupersetOf(other) && Count > count_enum(other);
|
||||
}
|
||||
|
||||
public bool IsSubsetOf(global::System.Collections.Generic.IEnumerable<$typemap(cstype, T)> other) {
|
||||
int countContained = 0;
|
||||
|
||||
foreach ($typemap(cstype, T) item in other) {
|
||||
if (Contains(item))
|
||||
countContained++;
|
||||
}
|
||||
|
||||
return countContained == Count;
|
||||
}
|
||||
|
||||
public bool IsSupersetOf(global::System.Collections.Generic.IEnumerable<$typemap(cstype, T)> other) {
|
||||
foreach ($typemap(cstype, T) item in other) {
|
||||
if (!Contains(item))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Overlaps(global::System.Collections.Generic.IEnumerable<$typemap(cstype, T)> other) {
|
||||
foreach ($typemap(cstype, T) item in other) {
|
||||
if (Contains(item))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool SetEquals(global::System.Collections.Generic.IEnumerable<$typemap(cstype, T)> other) {
|
||||
return IsSupersetOf(other) && Count == count_enum(other);
|
||||
}
|
||||
|
||||
public void SymmetricExceptWith(global::System.Collections.Generic.IEnumerable<$typemap(cstype, T)> other) {
|
||||
foreach ($typemap(cstype, T) item in other) {
|
||||
if (!Remove(item))
|
||||
Add(item);
|
||||
}
|
||||
}
|
||||
|
||||
public void UnionWith(global::System.Collections.Generic.IEnumerable<$typemap(cstype, T)> other) {
|
||||
foreach ($typemap(cstype, T) item in other) {
|
||||
Add(item);
|
||||
}
|
||||
}
|
||||
|
||||
private global::System.Collections.Generic.ICollection<$typemap(cstype, T)> Items {
|
||||
get {
|
||||
global::System.Collections.Generic.ICollection<$typemap(cstype, T)> items = new global::System.Collections.Generic.List<$typemap(cstype, T)>();
|
||||
int size = this.Count;
|
||||
if (size > 0) {
|
||||
global::System.IntPtr iter = create_iterator_begin();
|
||||
for (int i = 0; i < size; i++) {
|
||||
items.Add(get_next(iter));
|
||||
}
|
||||
destroy_iterator(iter);
|
||||
}
|
||||
return items;
|
||||
}
|
||||
}
|
||||
|
||||
global::System.Collections.Generic.IEnumerator<$typemap(cstype, T)> global::System.Collections.Generic.IEnumerable<$typemap(cstype, T)>.GetEnumerator() {
|
||||
return new $csclassnameEnumerator(this);
|
||||
}
|
||||
|
||||
global::System.Collections.IEnumerator global::System.Collections.IEnumerable.GetEnumerator() {
|
||||
return new $csclassnameEnumerator(this);
|
||||
}
|
||||
|
||||
public $csclassnameEnumerator GetEnumerator() {
|
||||
return new $csclassnameEnumerator(this);
|
||||
}
|
||||
|
||||
// Type-safe enumerator
|
||||
/// Note that the IEnumerator documentation requires an InvalidOperationException to be thrown
|
||||
/// whenever the collection is modified. This has been done for changes in the size of the
|
||||
/// collection but not when one of the elements of the collection is modified as it is a bit
|
||||
/// tricky to detect unmanaged code that modifies the collection under our feet.
|
||||
public sealed class $csclassnameEnumerator : global::System.Collections.IEnumerator,
|
||||
global::System.Collections.Generic.IEnumerator<$typemap(cstype, T)>
|
||||
{
|
||||
private $csclassname collectionRef;
|
||||
private global::System.Collections.Generic.IList<$typemap(cstype, T)> ItemsCollection;
|
||||
private int currentIndex;
|
||||
private object currentObject;
|
||||
private int currentSize;
|
||||
|
||||
public $csclassnameEnumerator($csclassname collection) {
|
||||
collectionRef = collection;
|
||||
ItemsCollection = new global::System.Collections.Generic.List<$typemap(cstype, T)>(collection.Items);
|
||||
currentIndex = -1;
|
||||
currentObject = null;
|
||||
currentSize = collectionRef.Count;
|
||||
}
|
||||
|
||||
// Type-safe iterator Current
|
||||
public $typemap(cstype, T) Current {
|
||||
get {
|
||||
if (currentIndex == -1)
|
||||
throw new global::System.InvalidOperationException("Enumeration not started.");
|
||||
if (currentIndex > currentSize - 1)
|
||||
throw new global::System.InvalidOperationException("Enumeration finished.");
|
||||
if (currentObject == null)
|
||||
throw new global::System.InvalidOperationException("Collection modified.");
|
||||
return ($typemap(cstype, T))currentObject;
|
||||
}
|
||||
}
|
||||
|
||||
// Type-unsafe IEnumerator.Current
|
||||
object global::System.Collections.IEnumerator.Current {
|
||||
get {
|
||||
return Current;
|
||||
}
|
||||
}
|
||||
|
||||
public bool MoveNext() {
|
||||
int size = collectionRef.Count;
|
||||
bool moveOkay = (currentIndex+1 < size) && (size == currentSize);
|
||||
if (moveOkay) {
|
||||
currentIndex++;
|
||||
currentObject = ItemsCollection[currentIndex];
|
||||
} else {
|
||||
currentObject = null;
|
||||
}
|
||||
return moveOkay;
|
||||
}
|
||||
|
||||
public void Reset() {
|
||||
currentIndex = -1;
|
||||
currentObject = null;
|
||||
if (collectionRef.Count != currentSize) {
|
||||
throw new global::System.InvalidOperationException("Collection modified.");
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose() {
|
||||
currentIndex = -1;
|
||||
currentObject = null;
|
||||
}
|
||||
}
|
||||
|
||||
%}
|
||||
|
||||
public:
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef T key_type;
|
||||
typedef T value_type;
|
||||
typedef value_type* pointer;
|
||||
typedef const value_type* const_pointer;
|
||||
typedef value_type& reference;
|
||||
typedef const value_type& const_reference;
|
||||
|
||||
set();
|
||||
set(const set& other);
|
||||
size_type size() const;
|
||||
bool empty() const;
|
||||
%rename(Clear) clear;
|
||||
void clear();
|
||||
%extend {
|
||||
bool Add(const value_type& item) {
|
||||
return $self->insert(item).second;
|
||||
}
|
||||
|
||||
bool Contains(const value_type& item) {
|
||||
return $self->count(item) != 0;
|
||||
}
|
||||
|
||||
bool Remove(const value_type& item) {
|
||||
return $self->erase(item) != 0;
|
||||
}
|
||||
|
||||
const value_type& getitem(const value_type& item) throw (std::out_of_range) {
|
||||
std::set<T>::iterator iter = $self->find(item);
|
||||
if (iter == $self->end())
|
||||
throw std::out_of_range("item not found");
|
||||
|
||||
return *iter;
|
||||
}
|
||||
|
||||
// create_iterator_begin(), get_next() and destroy_iterator work together to provide a collection of items to C#
|
||||
%apply void *VOID_INT_PTR { std::set<T>::iterator *create_iterator_begin }
|
||||
%apply void *VOID_INT_PTR { std::set<T>::iterator *swigiterator }
|
||||
|
||||
std::set<T>::iterator *create_iterator_begin() {
|
||||
return new std::set<T>::iterator($self->begin());
|
||||
}
|
||||
|
||||
const key_type& get_next(std::set<T>::iterator *swigiterator) {
|
||||
std::set<T>::iterator iter = *swigiterator;
|
||||
(*swigiterator)++;
|
||||
return *iter;
|
||||
}
|
||||
|
||||
void destroy_iterator(std::set<T>::iterator *swigiterator) {
|
||||
delete swigiterator;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
#define SWIG_SHARED_PTR_NAMESPACE std
|
||||
%include <boost_shared_ptr.i>
|
||||
|
|
@ -1,111 +0,0 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* std_string.i
|
||||
*
|
||||
* Typemaps for std::string and const std::string&
|
||||
* These are mapped to a C# 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;
|
||||
|
||||
// string
|
||||
%typemap(ctype) string "const char *"
|
||||
%typemap(imtype) string "string"
|
||||
%typemap(cstype) string "string"
|
||||
|
||||
%typemap(csdirectorin) string "$iminput"
|
||||
%typemap(csdirectorout) string "$cscall"
|
||||
|
||||
%typemap(in, canthrow=1) string
|
||||
%{ if (!$input) {
|
||||
SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "null string", 0);
|
||||
return $null;
|
||||
}
|
||||
$1.assign($input); %}
|
||||
%typemap(out) string %{ $result = SWIG_csharp_string_callback($1.c_str()); %}
|
||||
|
||||
%typemap(directorout, canthrow=1) string
|
||||
%{ if (!$input) {
|
||||
SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "null string", 0);
|
||||
return $null;
|
||||
}
|
||||
$result.assign($input); %}
|
||||
|
||||
%typemap(directorin) string %{ $input = $1.c_str(); %}
|
||||
|
||||
%typemap(csin) string "$csinput"
|
||||
%typemap(csout, excode=SWIGEXCODE) string {
|
||||
string ret = $imcall;$excode
|
||||
return ret;
|
||||
}
|
||||
|
||||
%typemap(typecheck) string = char *;
|
||||
|
||||
%typemap(throws, canthrow=1) string
|
||||
%{ SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, $1.c_str());
|
||||
return $null; %}
|
||||
|
||||
// const string &
|
||||
%typemap(ctype) const string & "const char *"
|
||||
%typemap(imtype) const string & "string"
|
||||
%typemap(cstype) const string & "string"
|
||||
|
||||
%typemap(csdirectorin) const string & "$iminput"
|
||||
%typemap(csdirectorout) const string & "$cscall"
|
||||
|
||||
%typemap(in, canthrow=1) const string &
|
||||
%{ if (!$input) {
|
||||
SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "null string", 0);
|
||||
return $null;
|
||||
}
|
||||
$*1_ltype $1_str($input);
|
||||
$1 = &$1_str; %}
|
||||
%typemap(out) const string & %{ $result = SWIG_csharp_string_callback($1->c_str()); %}
|
||||
|
||||
%typemap(csin) const string & "$csinput"
|
||||
%typemap(csout, excode=SWIGEXCODE) const string & {
|
||||
string ret = $imcall;$excode
|
||||
return ret;
|
||||
}
|
||||
|
||||
%typemap(directorout, canthrow=1, warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const string &
|
||||
%{ if (!$input) {
|
||||
SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "null string", 0);
|
||||
return $null;
|
||||
}
|
||||
/* possible thread/reentrant code problem */
|
||||
static $*1_ltype $1_str;
|
||||
$1_str = $input;
|
||||
$result = &$1_str; %}
|
||||
|
||||
%typemap(directorin) const string & %{ $input = $1.c_str(); %}
|
||||
|
||||
%typemap(csvarin, excode=SWIGEXCODE2) const string & %{
|
||||
set {
|
||||
$imcall;$excode
|
||||
} %}
|
||||
%typemap(csvarout, excode=SWIGEXCODE2) const string & %{
|
||||
get {
|
||||
string ret = $imcall;$excode
|
||||
return ret;
|
||||
} %}
|
||||
|
||||
%typemap(typecheck) const string & = char *;
|
||||
|
||||
%typemap(throws, canthrow=1) const string &
|
||||
%{ SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, $1.c_str());
|
||||
return $null; %}
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* std_unique_ptr.i
|
||||
*
|
||||
* SWIG library file for handling std::unique_ptr.
|
||||
* Memory ownership is passed from the std::unique_ptr C++ layer to the proxy
|
||||
* class when returning a std::unique_ptr from a function.
|
||||
* Memory ownership is passed from the proxy class to the std::unique_ptr in the
|
||||
* C++ layer when passed as a parameter to a wrapped function.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
%define %unique_ptr(TYPE)
|
||||
%typemap (ctype) std::unique_ptr< TYPE > "void *"
|
||||
%typemap (imtype, out="System.IntPtr") std::unique_ptr< TYPE > "global::System.Runtime.InteropServices.HandleRef"
|
||||
%typemap (cstype) std::unique_ptr< TYPE > "$typemap(cstype, TYPE)"
|
||||
|
||||
%typemap(in) std::unique_ptr< TYPE >
|
||||
%{ $1.reset((TYPE *)$input); %}
|
||||
|
||||
%typemap(csin) std::unique_ptr< TYPE > "$typemap(cstype, TYPE).swigRelease($csinput)"
|
||||
|
||||
%typemap (out) std::unique_ptr< TYPE > %{
|
||||
$result = (void *)$1.release();
|
||||
%}
|
||||
|
||||
%typemap(csout, excode=SWIGEXCODE) std::unique_ptr< TYPE > {
|
||||
System.IntPtr cPtr = $imcall;
|
||||
$typemap(cstype, TYPE) ret = (cPtr == System.IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode
|
||||
return ret;
|
||||
}
|
||||
|
||||
%typemap(typecheck, precedence=SWIG_TYPECHECK_POINTER, equivalent="TYPE *") std::unique_ptr< TYPE > ""
|
||||
|
||||
%template() std::unique_ptr< TYPE >;
|
||||
%enddef
|
||||
|
||||
namespace std {
|
||||
template <class T> class unique_ptr {};
|
||||
}
|
||||
|
|
@ -1,418 +0,0 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* std_vector.i
|
||||
*
|
||||
* SWIG typemaps for std::vector<T>
|
||||
* C# implementation
|
||||
* The C# wrapper is made to look and feel like a C# System.Collections.Generic.List<> collection.
|
||||
*
|
||||
* Note that IEnumerable<> is implemented in the proxy class which is useful for using LINQ with
|
||||
* C++ std::vector wrappers. The IList<> interface is also implemented to provide enhanced functionality
|
||||
* whenever we are confident that the required C++ operator== is available. This is the case for when
|
||||
* T is a primitive type or a pointer. If T does define an operator==, then use the SWIG_STD_VECTOR_ENHANCED
|
||||
* macro to obtain this enhanced functionality, for example:
|
||||
*
|
||||
* SWIG_STD_VECTOR_ENHANCED(SomeNamespace::Klass)
|
||||
* %template(VectKlass) std::vector<SomeNamespace::Klass>;
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
%include <std_common.i>
|
||||
|
||||
// MACRO for use within the std::vector class body
|
||||
%define SWIG_STD_VECTOR_MINIMUM_INTERNAL(CSINTERFACE, CONST_REFERENCE, CTYPE...)
|
||||
%typemap(csinterfaces) std::vector< CTYPE > "global::System.IDisposable, global::System.Collections.IEnumerable, global::System.Collections.Generic.CSINTERFACE<$typemap(cstype, CTYPE)>\n"
|
||||
%proxycode %{
|
||||
public $csclassname(global::System.Collections.IEnumerable c) : this() {
|
||||
if (c == null)
|
||||
throw new global::System.ArgumentNullException("c");
|
||||
foreach ($typemap(cstype, CTYPE) element in c) {
|
||||
this.Add(element);
|
||||
}
|
||||
}
|
||||
|
||||
public $csclassname(global::System.Collections.Generic.IEnumerable<$typemap(cstype, CTYPE)> c) : this() {
|
||||
if (c == null)
|
||||
throw new global::System.ArgumentNullException("c");
|
||||
foreach ($typemap(cstype, CTYPE) element in c) {
|
||||
this.Add(element);
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsFixedSize {
|
||||
get {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsReadOnly {
|
||||
get {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public $typemap(cstype, CTYPE) this[int index] {
|
||||
get {
|
||||
return getitem(index);
|
||||
}
|
||||
set {
|
||||
setitem(index, value);
|
||||
}
|
||||
}
|
||||
|
||||
public int Capacity {
|
||||
get {
|
||||
return (int)capacity();
|
||||
}
|
||||
set {
|
||||
if (value < 0 || ($typemap(cstype, size_t))value < size())
|
||||
throw new global::System.ArgumentOutOfRangeException("Capacity");
|
||||
reserve(($typemap(cstype, size_t))value);
|
||||
}
|
||||
}
|
||||
|
||||
public int Count {
|
||||
get {
|
||||
return (int)size();
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsSynchronized {
|
||||
get {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void CopyTo($typemap(cstype, CTYPE)[] array)
|
||||
{
|
||||
CopyTo(0, array, 0, this.Count);
|
||||
}
|
||||
|
||||
public void CopyTo($typemap(cstype, CTYPE)[] array, int arrayIndex)
|
||||
{
|
||||
CopyTo(0, array, arrayIndex, this.Count);
|
||||
}
|
||||
|
||||
public void CopyTo(int index, $typemap(cstype, CTYPE)[] array, int arrayIndex, int count)
|
||||
{
|
||||
if (array == null)
|
||||
throw new global::System.ArgumentNullException("array");
|
||||
if (index < 0)
|
||||
throw new global::System.ArgumentOutOfRangeException("index", "Value is less than zero");
|
||||
if (arrayIndex < 0)
|
||||
throw new global::System.ArgumentOutOfRangeException("arrayIndex", "Value is less than zero");
|
||||
if (count < 0)
|
||||
throw new global::System.ArgumentOutOfRangeException("count", "Value is less than zero");
|
||||
if (array.Rank > 1)
|
||||
throw new global::System.ArgumentException("Multi dimensional array.", "array");
|
||||
if (index+count > this.Count || arrayIndex+count > array.Length)
|
||||
throw new global::System.ArgumentException("Number of elements to copy is too large.");
|
||||
for (int i=0; i<count; i++)
|
||||
array.SetValue(getitemcopy(index+i), arrayIndex+i);
|
||||
}
|
||||
|
||||
public $typemap(cstype, CTYPE)[] ToArray() {
|
||||
$typemap(cstype, CTYPE)[] array = new $typemap(cstype, CTYPE)[this.Count];
|
||||
this.CopyTo(array);
|
||||
return array;
|
||||
}
|
||||
|
||||
global::System.Collections.Generic.IEnumerator<$typemap(cstype, CTYPE)> global::System.Collections.Generic.IEnumerable<$typemap(cstype, CTYPE)>.GetEnumerator() {
|
||||
return new $csclassnameEnumerator(this);
|
||||
}
|
||||
|
||||
global::System.Collections.IEnumerator global::System.Collections.IEnumerable.GetEnumerator() {
|
||||
return new $csclassnameEnumerator(this);
|
||||
}
|
||||
|
||||
public $csclassnameEnumerator GetEnumerator() {
|
||||
return new $csclassnameEnumerator(this);
|
||||
}
|
||||
|
||||
// Type-safe enumerator
|
||||
/// Note that the IEnumerator documentation requires an InvalidOperationException to be thrown
|
||||
/// whenever the collection is modified. This has been done for changes in the size of the
|
||||
/// collection but not when one of the elements of the collection is modified as it is a bit
|
||||
/// tricky to detect unmanaged code that modifies the collection under our feet.
|
||||
public sealed class $csclassnameEnumerator : global::System.Collections.IEnumerator
|
||||
, global::System.Collections.Generic.IEnumerator<$typemap(cstype, CTYPE)>
|
||||
{
|
||||
private $csclassname collectionRef;
|
||||
private int currentIndex;
|
||||
private object currentObject;
|
||||
private int currentSize;
|
||||
|
||||
public $csclassnameEnumerator($csclassname collection) {
|
||||
collectionRef = collection;
|
||||
currentIndex = -1;
|
||||
currentObject = null;
|
||||
currentSize = collectionRef.Count;
|
||||
}
|
||||
|
||||
// Type-safe iterator Current
|
||||
public $typemap(cstype, CTYPE) Current {
|
||||
get {
|
||||
if (currentIndex == -1)
|
||||
throw new global::System.InvalidOperationException("Enumeration not started.");
|
||||
if (currentIndex > currentSize - 1)
|
||||
throw new global::System.InvalidOperationException("Enumeration finished.");
|
||||
if (currentObject == null)
|
||||
throw new global::System.InvalidOperationException("Collection modified.");
|
||||
return ($typemap(cstype, CTYPE))currentObject;
|
||||
}
|
||||
}
|
||||
|
||||
// Type-unsafe IEnumerator.Current
|
||||
object global::System.Collections.IEnumerator.Current {
|
||||
get {
|
||||
return Current;
|
||||
}
|
||||
}
|
||||
|
||||
public bool MoveNext() {
|
||||
int size = collectionRef.Count;
|
||||
bool moveOkay = (currentIndex+1 < size) && (size == currentSize);
|
||||
if (moveOkay) {
|
||||
currentIndex++;
|
||||
currentObject = collectionRef[currentIndex];
|
||||
} else {
|
||||
currentObject = null;
|
||||
}
|
||||
return moveOkay;
|
||||
}
|
||||
|
||||
public void Reset() {
|
||||
currentIndex = -1;
|
||||
currentObject = null;
|
||||
if (collectionRef.Count != currentSize) {
|
||||
throw new global::System.InvalidOperationException("Collection modified.");
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose() {
|
||||
currentIndex = -1;
|
||||
currentObject = null;
|
||||
}
|
||||
}
|
||||
%}
|
||||
|
||||
public:
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef CTYPE value_type;
|
||||
typedef value_type* pointer;
|
||||
typedef const value_type* const_pointer;
|
||||
typedef value_type& reference;
|
||||
typedef CONST_REFERENCE const_reference;
|
||||
|
||||
%rename(Clear) clear;
|
||||
void clear();
|
||||
%rename(Add) push_back;
|
||||
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(CTYPE const& value, int count);
|
||||
|
||||
vector();
|
||||
vector(const vector &other);
|
||||
|
||||
%extend {
|
||||
vector(int capacity) throw (std::out_of_range) {
|
||||
std::vector< CTYPE >* pv = 0;
|
||||
if (capacity >= 0) {
|
||||
pv = new std::vector< CTYPE >();
|
||||
pv->reserve(capacity);
|
||||
} else {
|
||||
throw std::out_of_range("capacity");
|
||||
}
|
||||
return pv;
|
||||
}
|
||||
CTYPE getitemcopy(int index) throw (std::out_of_range) {
|
||||
if (index>=0 && index<(int)$self->size())
|
||||
return (*$self)[index];
|
||||
else
|
||||
throw std::out_of_range("index");
|
||||
}
|
||||
CONST_REFERENCE getitem(int index) throw (std::out_of_range) {
|
||||
if (index>=0 && index<(int)$self->size())
|
||||
return (*$self)[index];
|
||||
else
|
||||
throw std::out_of_range("index");
|
||||
}
|
||||
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) {
|
||||
$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) {
|
||||
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);
|
||||
}
|
||||
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) {
|
||||
if (index>=0 && index<(int)$self->size()+1)
|
||||
$self->insert($self->begin()+index, values.begin(), values.end());
|
||||
else
|
||||
throw std::out_of_range("index");
|
||||
}
|
||||
void RemoveAt(int index) throw (std::out_of_range) {
|
||||
if (index>=0 && index<(int)$self->size())
|
||||
$self->erase($self->begin() + index);
|
||||
else
|
||||
throw std::out_of_range("index");
|
||||
}
|
||||
void RemoveRange(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");
|
||||
$self->erase($self->begin()+index, $self->begin()+index+count);
|
||||
}
|
||||
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);
|
||||
}
|
||||
void Reverse() {
|
||||
std::reverse($self->begin(), $self->end());
|
||||
}
|
||||
void Reverse(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");
|
||||
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) {
|
||||
if (index < 0)
|
||||
throw std::out_of_range("index");
|
||||
if (index+values.size() > $self->size())
|
||||
throw std::out_of_range("index");
|
||||
std::copy(values.begin(), values.end(), $self->begin()+index);
|
||||
}
|
||||
}
|
||||
%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(CTYPE const& value) {
|
||||
return std::find($self->begin(), $self->end(), value) != $self->end();
|
||||
}
|
||||
int IndexOf(CTYPE const& value) {
|
||||
int index = -1;
|
||||
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(CTYPE const& value) {
|
||||
int index = -1;
|
||||
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(CTYPE const& value) {
|
||||
std::vector< CTYPE >::iterator it = std::find($self->begin(), $self->end(), value);
|
||||
if (it != $self->end()) {
|
||||
$self->erase(it);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
%enddef
|
||||
|
||||
// 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&, %arg(CTYPE))
|
||||
SWIG_STD_VECTOR_EXTRA_OP_EQUALS_EQUALS(CTYPE)
|
||||
};
|
||||
}
|
||||
%enddef
|
||||
|
||||
// Legacy macros
|
||||
%define SWIG_STD_VECTOR_SPECIALIZE(CSTYPE, CTYPE...)
|
||||
#warning SWIG_STD_VECTOR_SPECIALIZE macro deprecated, please see csharp/std_vector.i and switch to SWIG_STD_VECTOR_ENHANCED
|
||||
SWIG_STD_VECTOR_ENHANCED(CTYPE)
|
||||
%enddef
|
||||
|
||||
%define SWIG_STD_VECTOR_SPECIALIZE_MINIMUM(CSTYPE, CTYPE...)
|
||||
#warning SWIG_STD_VECTOR_SPECIALIZE_MINIMUM macro deprecated, it is no longer required
|
||||
%enddef
|
||||
|
||||
%{
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
#include <stdexcept>
|
||||
%}
|
||||
|
||||
%csmethodmodifiers std::vector::getitemcopy "private"
|
||||
%csmethodmodifiers std::vector::getitem "private"
|
||||
%csmethodmodifiers std::vector::setitem "private"
|
||||
%csmethodmodifiers std::vector::size "private"
|
||||
%csmethodmodifiers std::vector::capacity "private"
|
||||
%csmethodmodifiers std::vector::reserve "private"
|
||||
|
||||
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_INTERNAL(IEnumerable, const value_type&, T)
|
||||
};
|
||||
// specialization 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 *)
|
||||
};
|
||||
// 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)
|
||||
};
|
||||
}
|
||||
|
||||
// template specializations for std::vector
|
||||
// these provide extra collections methods as operator== is defined
|
||||
SWIG_STD_VECTOR_ENHANCED(char)
|
||||
SWIG_STD_VECTOR_ENHANCED(signed char)
|
||||
SWIG_STD_VECTOR_ENHANCED(unsigned char)
|
||||
SWIG_STD_VECTOR_ENHANCED(short)
|
||||
SWIG_STD_VECTOR_ENHANCED(unsigned short)
|
||||
SWIG_STD_VECTOR_ENHANCED(int)
|
||||
SWIG_STD_VECTOR_ENHANCED(unsigned int)
|
||||
SWIG_STD_VECTOR_ENHANCED(long)
|
||||
SWIG_STD_VECTOR_ENHANCED(unsigned long)
|
||||
SWIG_STD_VECTOR_ENHANCED(long long)
|
||||
SWIG_STD_VECTOR_ENHANCED(unsigned long long)
|
||||
SWIG_STD_VECTOR_ENHANCED(float)
|
||||
SWIG_STD_VECTOR_ENHANCED(double)
|
||||
SWIG_STD_VECTOR_ENHANCED(std::string) // also requires a %include <std_string.i>
|
||||
SWIG_STD_VECTOR_ENHANCED(std::wstring) // also requires a %include <std_wstring.i>
|
||||
|
||||
|
|
@ -1,146 +0,0 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* std_wstring.i
|
||||
*
|
||||
* Typemaps for std::wstring and const std::wstring&
|
||||
* std::wstring is mapped to a C# Unicode string (UTF16) and is passed around by value.
|
||||
* std::wstring support includes wchar_t as a 2 byte type (Windows) and a 4 byte type
|
||||
* (most Unix systems).
|
||||
*
|
||||
* To use non-const std::wstring references use the following %apply. Note
|
||||
* that they are passed by value.
|
||||
* %apply const std::wstring & {std::wstring &};
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
%include <wchar.i>
|
||||
|
||||
%{
|
||||
#include <string>
|
||||
%}
|
||||
|
||||
%fragment("Swig_csharp_UTF16ToWString", "header") %{
|
||||
/* For converting from .NET UTF16 (2 byte unicode) strings. wchar_t is 2 bytes on Windows, 4 bytes on Linux. */
|
||||
static std::wstring Swig_csharp_UTF16ToWString(const unsigned short *str) {
|
||||
if (sizeof(wchar_t) == 2) {
|
||||
return std::wstring((wchar_t *)str);
|
||||
} else {
|
||||
const unsigned short *pBegin(str);
|
||||
const unsigned short *ptr(pBegin);
|
||||
|
||||
while (*ptr != 0)
|
||||
++ptr;
|
||||
|
||||
std::wstring result;
|
||||
result.reserve(ptr - pBegin);
|
||||
while(pBegin != ptr)
|
||||
result.push_back(*pBegin++);
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
%}
|
||||
|
||||
namespace std {
|
||||
|
||||
%naturalvar wstring;
|
||||
|
||||
class wstring;
|
||||
|
||||
// wstring
|
||||
%typemap(ctype, out="void *") wstring "unsigned short *"
|
||||
%typemap(imtype,
|
||||
inattributes="[global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.LPWStr)]",
|
||||
outattributes="[return: global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.LPWStr)]",
|
||||
directorinattributes="[global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.LPWStr)]",
|
||||
directoroutattributes="[return: global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.LPWStr)]"
|
||||
) wstring "string"
|
||||
%typemap(cstype) wstring "string"
|
||||
%typemap(csdirectorin) wstring "$iminput"
|
||||
%typemap(csdirectorout) wstring "$cscall"
|
||||
|
||||
%typemap(in, canthrow=1, fragment="Swig_csharp_UTF16ToWString") wstring
|
||||
%{ if (!$input) {
|
||||
SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "null wstring", 0);
|
||||
return $null;
|
||||
}
|
||||
$1 = Swig_csharp_UTF16ToWString($input); %}
|
||||
%typemap(out) wstring %{ $result = SWIG_csharp_wstring_with_length_callback($1.c_str(), (int)$1.size()); %}
|
||||
|
||||
%typemap(directorout, canthrow=1) wstring
|
||||
%{ if (!$input) {
|
||||
SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "null wstring", 0);
|
||||
return $null;
|
||||
}
|
||||
$result = Swig_csharp_UTF16ToWString($input); %}
|
||||
|
||||
%typemap(directorin) wstring %{ $input = SWIG_csharp_wstring_with_length_callback($1.c_str(), (int)$1.size()); %}
|
||||
|
||||
%typemap(csin) wstring "$csinput"
|
||||
%typemap(csout, excode=SWIGEXCODE) wstring {
|
||||
string ret = $imcall;$excode
|
||||
return ret;
|
||||
}
|
||||
|
||||
%typemap(typecheck) wstring = wchar_t *;
|
||||
|
||||
%typemap(throws, canthrow=1) wstring
|
||||
%{ SWIG_csharp_ApplicationException_callback($1.c_str(), (int)$1.size());
|
||||
return $null; %}
|
||||
|
||||
// const wstring &
|
||||
%typemap(ctype, out="void *") const wstring & "unsigned short *"
|
||||
%typemap(imtype,
|
||||
inattributes="[global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.LPWStr)]",
|
||||
outattributes="[return: global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.LPWStr)]",
|
||||
directorinattributes="[global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.LPWStr)]",
|
||||
directoroutattributes="[return: global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.LPWStr)]"
|
||||
) const wstring & "string"
|
||||
%typemap(cstype) const wstring & "string"
|
||||
|
||||
%typemap(csdirectorin) const wstring & "$iminput"
|
||||
%typemap(csdirectorout) const wstring & "$cscall"
|
||||
|
||||
%typemap(in, canthrow=1, fragment="Swig_csharp_UTF16ToWString") const wstring &
|
||||
%{ if (!$input) {
|
||||
SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "null wstring", 0);
|
||||
return $null;
|
||||
}
|
||||
std::wstring $1_str(Swig_csharp_UTF16ToWString($input));
|
||||
$1 = &$1_str; %}
|
||||
%typemap(out) const wstring & %{ $result = SWIG_csharp_wstring_with_length_callback($1->c_str(), (int)$1->size()); %}
|
||||
|
||||
%typemap(csin) const wstring & "$csinput"
|
||||
%typemap(csout, excode=SWIGEXCODE) const wstring & {
|
||||
string ret = $imcall;$excode
|
||||
return ret;
|
||||
}
|
||||
|
||||
%typemap(directorout, canthrow=1, warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const wstring &
|
||||
%{ if (!$input) {
|
||||
SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "null wstring", 0);
|
||||
return $null;
|
||||
}
|
||||
/* possible thread/reentrant code problem */
|
||||
static std::wstring $1_str;
|
||||
$1_str = Swig_csharp_UTF16ToWString($input);
|
||||
$result = &$1_str; %}
|
||||
|
||||
%typemap(directorin) const wstring & %{ $input = SWIG_csharp_wstring_with_length_callback($1.c_str(), (int)$1.size()); %}
|
||||
|
||||
%typemap(csvarin, excode=SWIGEXCODE2) const wstring & %{
|
||||
set {
|
||||
$imcall;$excode
|
||||
} %}
|
||||
%typemap(csvarout, excode=SWIGEXCODE2) const wstring & %{
|
||||
get {
|
||||
string ret = $imcall;$excode
|
||||
return ret;
|
||||
} %}
|
||||
|
||||
%typemap(typecheck) const wstring & = wchar_t *;
|
||||
|
||||
%typemap(throws, canthrow=1) const wstring &
|
||||
%{ SWIG_csharp_ApplicationException_callback($1.c_str(), (int)$1.size());
|
||||
return $null; %}
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* stl.i
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
%include <std_common.i>
|
||||
%include <std_string.i>
|
||||
%include <std_vector.i>
|
||||
%include <std_map.i>
|
||||
%include <std_pair.i>
|
||||
|
||||
|
|
@ -1,63 +0,0 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* swiginterface.i
|
||||
*
|
||||
* SWIG interface feature and typemaps implementation providing:
|
||||
* %interface
|
||||
* %interface_impl
|
||||
* %interface_custom
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
%define INTERFACE_TYPEMAPS(CTYPE...)
|
||||
%typemap(cstype) CTYPE "$&csinterfacename"
|
||||
%typemap(cstype) CTYPE *, CTYPE [], CTYPE & "$csinterfacename"
|
||||
%typemap(cstype) CTYPE *const& "$*csinterfacename"
|
||||
%typemap(csin) CTYPE, CTYPE & "$csinput.GetInterfaceCPtr()"
|
||||
%typemap(csin) CTYPE *, CTYPE *const&, CTYPE [] "$csinput == null ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : $csinput.GetInterfaceCPtr()"
|
||||
%typemap(csout, excode=SWIGEXCODE) CTYPE {
|
||||
$&csclassname ret = new $&csclassname($imcall, true);$excode
|
||||
return ($&csinterfacename)ret;
|
||||
}
|
||||
%typemap(csout, excode=SWIGEXCODE) CTYPE & {
|
||||
$csclassname ret = new $csclassname($imcall, $owner);$excode
|
||||
return ($csinterfacename)ret;
|
||||
}
|
||||
%typemap(csout, excode=SWIGEXCODE) CTYPE *, CTYPE [] {
|
||||
global::System.IntPtr cPtr = $imcall;
|
||||
$csclassname ret = (cPtr == global::System.IntPtr.Zero) ? null : new $csclassname(cPtr, $owner);$excode
|
||||
return ($csinterfacename)ret;
|
||||
}
|
||||
%typemap(csout, excode=SWIGEXCODE) CTYPE *const& {
|
||||
global::System.IntPtr cPtr = $imcall;
|
||||
$*csclassname ret = (cPtr == global::System.IntPtr.Zero) ? null : new $*csclassname(cPtr, $owner);$excode
|
||||
return ($*csinterfacename)ret;
|
||||
}
|
||||
%typemap(csdirectorin) CTYPE "($&csinterfacename)new $&csclassname($iminput, true)"
|
||||
%typemap(csdirectorin) CTYPE & "($csinterfacename)new $csclassname($iminput, false)"
|
||||
%typemap(csdirectorin) CTYPE *, CTYPE [] "($iminput == global::System.IntPtr.Zero) ? null : ($csinterfacename)new $csclassname($iminput, false)"
|
||||
%typemap(csdirectorin) CTYPE *const& "($iminput == global::System.IntPtr.Zero) ? null : ($*csinterfacename)new $*csclassname($iminput, false)"
|
||||
%typemap(csdirectorout) CTYPE, CTYPE *, CTYPE *const&, CTYPE [], CTYPE & "$cscall.GetInterfaceCPtr()"
|
||||
%typemap(csinterfacecode, declaration=" [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]\n global::System.Runtime.InteropServices.HandleRef GetInterfaceCPtr();\n", cptrmethod="$interfacename_GetInterfaceCPtr") CTYPE %{
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
global::System.Runtime.InteropServices.HandleRef $interfacename.GetInterfaceCPtr() {
|
||||
return new global::System.Runtime.InteropServices.HandleRef(this, $imclassname.$csclazzname$interfacename_GetInterfaceCPtr(swigCPtr.Handle));
|
||||
}
|
||||
%}
|
||||
%enddef
|
||||
|
||||
%define %interface(CTYPE...)
|
||||
%feature("interface", name="%sSwigInterface") CTYPE;
|
||||
INTERFACE_TYPEMAPS(CTYPE)
|
||||
%enddef
|
||||
|
||||
%define %interface_impl(CTYPE...)
|
||||
%rename("%sSwigImpl") CTYPE;
|
||||
%feature("interface", name="%(rstrip:[SwigImpl])s") CTYPE;
|
||||
INTERFACE_TYPEMAPS(CTYPE)
|
||||
%enddef
|
||||
|
||||
%define %interface_custom(PROXY, INTERFACE, CTYPE...)
|
||||
%rename(PROXY) CTYPE;
|
||||
%feature("interface", name=INTERFACE) CTYPE;
|
||||
INTERFACE_TYPEMAPS(CTYPE)
|
||||
%enddef
|
||||
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* swigmove.i
|
||||
*
|
||||
* Input typemaps library for implementing full move semantics when passing
|
||||
* parameters by value.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
%typemap(in, canthrow=1, fragment="<memory>") SWIGTYPE MOVE ($&1_type argp)
|
||||
%{ argp = ($&1_ltype)$input;
|
||||
if (!argp) {
|
||||
SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null $1_type", 0);
|
||||
return $null;
|
||||
}
|
||||
SwigValueWrapper< $1_ltype >::reset($1, argp); %}
|
||||
|
||||
%typemap(csin) SWIGTYPE MOVE "$&csclassname.swigRelease($csinput)"
|
||||
|
|
@ -1,34 +0,0 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* swigtype_inout.i
|
||||
*
|
||||
* Pointer pointer and pointer reference handling typemap library for non-primitive types
|
||||
*
|
||||
* These mappings provide support for input/output arguments and common
|
||||
* uses for C/C++ pointer references and pointer to pointers.
|
||||
*
|
||||
* These are named typemaps (OUTPUT) and can be used like any named typemap.
|
||||
* Alternatively they can be made the default by using %apply:
|
||||
* %apply SWIGTYPE *& OUTPUT { SWIGTYPE *& }
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
/*
|
||||
* OUTPUT typemaps. Example usage wrapping:
|
||||
*
|
||||
* void f(XXX *& x) { x = new XXX(111); }
|
||||
*
|
||||
* would be:
|
||||
*
|
||||
* XXX x = null;
|
||||
* f(out x);
|
||||
* // use x
|
||||
* x.Dispose(); // manually clear memory or otherwise leave out and leave it to the garbage collector
|
||||
*/
|
||||
%typemap(ctype) SWIGTYPE *& OUTPUT "void **"
|
||||
%typemap(imtype, out="global::System.IntPtr") SWIGTYPE *& OUTPUT "out global::System.IntPtr"
|
||||
%typemap(cstype) SWIGTYPE *& OUTPUT "out $*csclassname"
|
||||
%typemap(csin,
|
||||
pre=" global::System.IntPtr cPtr_$csinput = global::System.IntPtr.Zero;",
|
||||
post=" $csinput = (cPtr_$csinput == global::System.IntPtr.Zero) ? null : new $*csclassname(cPtr_$csinput, true);",
|
||||
cshin="out $csinput") SWIGTYPE *& OUTPUT "out cPtr_$csinput"
|
||||
%typemap(in) SWIGTYPE *& OUTPUT %{ $1 = ($1_ltype)$input; %}
|
||||
%typemap(freearg) SWIGTYPE *& OUTPUT ""
|
||||
|
|
@ -1,253 +0,0 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* 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 are used for pointer/reference parameters that are input only
|
||||
and are mapped to a C# input parameter.
|
||||
|
||||
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 C# you could then use it like this:
|
||||
double answer = modulename.fadd(10.0, 20.0);
|
||||
*/
|
||||
|
||||
%define INPUT_TYPEMAP(TYPE, CTYPE, CSTYPE)
|
||||
%typemap(ctype, out="void *") TYPE *INPUT, TYPE &INPUT "CTYPE"
|
||||
%typemap(imtype, out="global::System.IntPtr") TYPE *INPUT, TYPE &INPUT "CSTYPE"
|
||||
%typemap(cstype, out="$csclassname") TYPE *INPUT, TYPE &INPUT "CSTYPE"
|
||||
%typemap(csin) TYPE *INPUT, TYPE &INPUT "$csinput"
|
||||
|
||||
%typemap(in) TYPE *INPUT, TYPE &INPUT
|
||||
%{ $1 = ($1_ltype)&$input; %}
|
||||
|
||||
%typemap(typecheck) TYPE *INPUT = TYPE;
|
||||
%typemap(typecheck) TYPE &INPUT = TYPE;
|
||||
%enddef
|
||||
|
||||
INPUT_TYPEMAP(bool, unsigned int, bool)
|
||||
//INPUT_TYPEMAP(char, char, char)
|
||||
INPUT_TYPEMAP(signed char, signed char, sbyte)
|
||||
INPUT_TYPEMAP(unsigned char, unsigned char, byte)
|
||||
INPUT_TYPEMAP(short, short, short)
|
||||
INPUT_TYPEMAP(unsigned short, unsigned short, ushort)
|
||||
INPUT_TYPEMAP(int, int, int)
|
||||
INPUT_TYPEMAP(unsigned int, unsigned int, uint)
|
||||
INPUT_TYPEMAP(long, long, int)
|
||||
INPUT_TYPEMAP(unsigned long, unsigned long, uint)
|
||||
INPUT_TYPEMAP(long long, long long, long)
|
||||
INPUT_TYPEMAP(unsigned long long, unsigned long long, ulong)
|
||||
INPUT_TYPEMAP(float, float, float)
|
||||
INPUT_TYPEMAP(double, double, double)
|
||||
|
||||
#undef INPUT_TYPEMAP
|
||||
|
||||
/*
|
||||
OUTPUT typemaps
|
||||
---------------
|
||||
|
||||
These typemaps are used for pointer/reference parameters that are output only and
|
||||
are mapped to a C# output parameter.
|
||||
|
||||
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. In C#, the 'out' keyword is
|
||||
used when passing the parameter to a function that takes an output parameter.
|
||||
|
||||
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 C# output of the function would be the function return value and the
|
||||
value returned in the second output parameter. In C# you would use it like this:
|
||||
|
||||
double dptr;
|
||||
double fraction = modulename.modf(5, out dptr);
|
||||
*/
|
||||
|
||||
%define OUTPUT_TYPEMAP(TYPE, CTYPE, CSTYPE, TYPECHECKPRECEDENCE)
|
||||
%typemap(ctype, out="void *") TYPE *OUTPUT, TYPE &OUTPUT "CTYPE *"
|
||||
%typemap(imtype, out="global::System.IntPtr") TYPE *OUTPUT, TYPE &OUTPUT "out CSTYPE"
|
||||
%typemap(cstype, out="$csclassname") TYPE *OUTPUT, TYPE &OUTPUT "out CSTYPE"
|
||||
%typemap(csin) TYPE *OUTPUT, TYPE &OUTPUT "out $csinput"
|
||||
|
||||
%typemap(in) TYPE *OUTPUT, TYPE &OUTPUT
|
||||
%{ $1 = ($1_ltype)$input; %}
|
||||
|
||||
%typecheck(SWIG_TYPECHECK_##TYPECHECKPRECEDENCE) TYPE *OUTPUT, TYPE &OUTPUT ""
|
||||
%enddef
|
||||
|
||||
OUTPUT_TYPEMAP(bool, unsigned int, bool, BOOL_PTR)
|
||||
//OUTPUT_TYPEMAP(char, char, char, CHAR_PTR)
|
||||
OUTPUT_TYPEMAP(signed char, signed char, sbyte, INT8_PTR)
|
||||
OUTPUT_TYPEMAP(unsigned char, unsigned char, byte, UINT8_PTR)
|
||||
OUTPUT_TYPEMAP(short, short, short, INT16_PTR)
|
||||
OUTPUT_TYPEMAP(unsigned short, unsigned short, ushort, UINT16_PTR)
|
||||
OUTPUT_TYPEMAP(int, int, int, INT32_PTR)
|
||||
OUTPUT_TYPEMAP(unsigned int, unsigned int, uint, UINT32_PTR)
|
||||
OUTPUT_TYPEMAP(long, long, int, INT32_PTR)
|
||||
OUTPUT_TYPEMAP(unsigned long, unsigned long, uint, UINT32_PTR)
|
||||
OUTPUT_TYPEMAP(long long, long long, long, INT64_PTR)
|
||||
OUTPUT_TYPEMAP(unsigned long long, unsigned long long, ulong, UINT64_PTR)
|
||||
OUTPUT_TYPEMAP(float, float, float, FLOAT_PTR)
|
||||
OUTPUT_TYPEMAP(double, double, double, DOUBLE_PTR)
|
||||
|
||||
#undef OUTPUT_TYPEMAP
|
||||
|
||||
%typemap(in) bool *OUTPUT, bool &OUTPUT
|
||||
%{ *$input = 0;
|
||||
$1 = ($1_ltype)$input; %}
|
||||
|
||||
|
||||
/*
|
||||
INOUT typemaps
|
||||
--------------
|
||||
|
||||
These typemaps are for pointer/reference parameters that are both input and
|
||||
output and are mapped to a C# reference parameter.
|
||||
|
||||
The following typemaps can be applied to turn a pointer or reference into a
|
||||
reference parameters, that is the parameter is both an input and an output.
|
||||
In C#, the 'ref' keyword is used for reference parameters.
|
||||
|
||||
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);
|
||||
|
||||
The C# output of the function would be the new value returned by the
|
||||
reference parameter. In C# you would use it like this:
|
||||
|
||||
|
||||
double x = 5.0;
|
||||
neg(ref x);
|
||||
|
||||
The implementation of the OUTPUT and INOUT typemaps is different to the scripting
|
||||
languages in that the scripting languages will return the output value as part
|
||||
of the function return value.
|
||||
|
||||
*/
|
||||
|
||||
%define INOUT_TYPEMAP(TYPE, CTYPE, CSTYPE, TYPECHECKPRECEDENCE)
|
||||
%typemap(ctype, out="void *") TYPE *INOUT, TYPE &INOUT "CTYPE *"
|
||||
%typemap(imtype, out="global::System.IntPtr") TYPE *INOUT, TYPE &INOUT "ref CSTYPE"
|
||||
%typemap(cstype, out="$csclassname") TYPE *INOUT, TYPE &INOUT "ref CSTYPE"
|
||||
%typemap(csin) TYPE *INOUT, TYPE &INOUT "ref $csinput"
|
||||
|
||||
%typemap(in) TYPE *INOUT, TYPE &INOUT
|
||||
%{ $1 = ($1_ltype)$input; %}
|
||||
|
||||
%typecheck(SWIG_TYPECHECK_##TYPECHECKPRECEDENCE) TYPE *INOUT, TYPE &INOUT ""
|
||||
%enddef
|
||||
|
||||
INOUT_TYPEMAP(bool, unsigned int, bool, BOOL_PTR)
|
||||
//INOUT_TYPEMAP(char, char, char, CHAR_PTR)
|
||||
INOUT_TYPEMAP(signed char, signed char, sbyte, INT8_PTR)
|
||||
INOUT_TYPEMAP(unsigned char, unsigned char, byte, UINT8_PTR)
|
||||
INOUT_TYPEMAP(short, short, short, INT16_PTR)
|
||||
INOUT_TYPEMAP(unsigned short, unsigned short, ushort, UINT16_PTR)
|
||||
INOUT_TYPEMAP(int, int, int, INT32_PTR)
|
||||
INOUT_TYPEMAP(unsigned int, unsigned int, uint, UINT32_PTR)
|
||||
INOUT_TYPEMAP(long, long, int, INT32_PTR)
|
||||
INOUT_TYPEMAP(unsigned long, unsigned long, uint, UINT32_PTR)
|
||||
INOUT_TYPEMAP(long long, long long, long, INT64_PTR)
|
||||
INOUT_TYPEMAP(unsigned long long, unsigned long long, ulong, UINT64_PTR)
|
||||
INOUT_TYPEMAP(float, float, float, FLOAT_PTR)
|
||||
INOUT_TYPEMAP(double, double, double, DOUBLE_PTR)
|
||||
|
||||
#undef INOUT_TYPEMAP
|
||||
|
||||
|
|
@ -1,335 +0,0 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* wchar.i
|
||||
*
|
||||
* Typemaps for the wchar_t type
|
||||
* wchar_t * is mapped to a C# Unicode string (UTF16) and is passed around by value.
|
||||
* wchar_t * support includes wchar_t as a 2 byte type (Windows) and a 4 byte type
|
||||
* (most Unix systems).
|
||||
*
|
||||
* Support code for wide strings can be turned off by defining SWIG_CSHARP_NO_WSTRING_HELPER
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
#if !defined(SWIG_CSHARP_NO_WSTRING_HELPER)
|
||||
#if !defined(SWIG_CSHARP_WSTRING_HELPER_)
|
||||
#define SWIG_CSHARP_WSTRING_HELPER_
|
||||
|
||||
%fragment("<wchar.h>"); // TODO: %fragment("<wchar.h", "runtime");
|
||||
|
||||
%insert(runtime) %{
|
||||
/* Callback for returning strings to C# without leaking memory */
|
||||
typedef void * (SWIGSTDCALL* SWIG_CSharpWStringHelperCallback)(const wchar_t *, int length);
|
||||
static SWIG_CSharpWStringHelperCallback SWIG_csharp_wstring_with_length_callback = NULL;
|
||||
%}
|
||||
|
||||
%insert(header) %{
|
||||
static void * SWIG_csharp_wstring_callback(const wchar_t *s) {
|
||||
return SWIG_csharp_wstring_with_length_callback(s, (int)wcslen(s));
|
||||
}
|
||||
%}
|
||||
|
||||
|
||||
%pragma(csharp) imclasscode=%{
|
||||
protected class SWIGWStringHelper {
|
||||
|
||||
[return: global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.LPWStr)]
|
||||
public delegate string SWIGWStringDelegate(global::System.IntPtr message, int length);
|
||||
static SWIGWStringDelegate wstringUTF16Delegate = new SWIGWStringDelegate(CreateWStringFromUTF16);
|
||||
static SWIGWStringDelegate wstringUTF32Delegate = new SWIGWStringDelegate(CreateWStringFromUTF32);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("$dllimport", EntryPoint="SWIGRegisterWStringCallback_$module")]
|
||||
public static extern void SWIGRegisterWStringCallback_$module(SWIGWStringDelegate wstringUTF16Delegate, SWIGWStringDelegate wstringUTF32Delegate);
|
||||
|
||||
public static string CreateWStringFromUTF16([global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.LPWStr)]global::System.IntPtr cString, int length) {
|
||||
return global::System.Runtime.InteropServices.Marshal.PtrToStringUni(cString, length);
|
||||
}
|
||||
|
||||
public static string CreateWStringFromUTF32([global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.LPWStr)]global::System.IntPtr cString, int length) {
|
||||
if (length == 0)
|
||||
return string.Empty;
|
||||
|
||||
byte[] buffer = new byte[length * 4];
|
||||
global::System.Runtime.InteropServices.Marshal.Copy(cString, buffer, 0, buffer.Length);
|
||||
return global::System.Text.Encoding.UTF32.GetString(buffer);
|
||||
}
|
||||
|
||||
static SWIGWStringHelper() {
|
||||
SWIGRegisterWStringCallback_$module(wstringUTF16Delegate, wstringUTF32Delegate);
|
||||
}
|
||||
}
|
||||
|
||||
static protected SWIGWStringHelper swigWStringHelper = new SWIGWStringHelper();
|
||||
%}
|
||||
|
||||
%insert(runtime) %{
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
#endif
|
||||
SWIGEXPORT void SWIGSTDCALL SWIGRegisterWStringCallback_$module(SWIG_CSharpWStringHelperCallback callback_utf16, SWIG_CSharpWStringHelperCallback callback_utf32) {
|
||||
SWIG_csharp_wstring_with_length_callback = sizeof(wchar_t) == 2 ? callback_utf16 : callback_utf32;
|
||||
}
|
||||
%}
|
||||
#endif // SWIG_CSHARP_WSTRING_HELPER_
|
||||
#endif // SWIG_CSHARP_NO_WSTRING_HELPER
|
||||
|
||||
#if !defined(SWIG_CSHARP_NO_WSTRING_EXCEPTION_HELPER)
|
||||
#if !defined(SWIG_CSHARP_WSTRING_EXCEPTION_HELPER_)
|
||||
#define SWIG_CSHARP_WSTRING_EXCEPTION_HELPER_
|
||||
|
||||
%insert(runtime) %{
|
||||
/* Callback for returning strings to C# without leaking memory */
|
||||
typedef void (SWIGSTDCALL* SWIG_CSharpWStringExceptionHelperCallback)(const wchar_t *, int length);
|
||||
static SWIG_CSharpWStringExceptionHelperCallback SWIG_csharp_ApplicationException_callback = NULL;
|
||||
%}
|
||||
|
||||
%pragma(csharp) imclasscode=%{
|
||||
protected class SWIGWStringExceptionHelper {
|
||||
|
||||
[return: global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.LPWStr)]
|
||||
public delegate void SWIGWStringExceptionDelegate(global::System.IntPtr message, int length);
|
||||
static SWIGWStringExceptionDelegate applicationExceptionUTF16Delegate = new SWIGWStringExceptionDelegate(SetPendingApplicationExceptionUTF16);
|
||||
static SWIGWStringExceptionDelegate applicationExceptionUTF32Delegate = new SWIGWStringExceptionDelegate(SetPendingApplicationExceptionUTF32);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("$dllimport", EntryPoint="SWIGRegisterWStringExceptionCallback_$module")]
|
||||
public static extern void SWIGRegisterWStringExceptionCallback_$module(SWIGWStringExceptionDelegate applicationExceptionUTF16Delegate, SWIGWStringExceptionDelegate applicationExceptionUTF32Delegate);
|
||||
|
||||
static string CreateWStringFromUTF16([global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.LPWStr)]global::System.IntPtr cString, int length) {
|
||||
return global::System.Runtime.InteropServices.Marshal.PtrToStringUni(cString, length);
|
||||
}
|
||||
|
||||
public static string CreateWStringFromUTF32([global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.LPWStr)]global::System.IntPtr cString, int length) {
|
||||
if (length == 0)
|
||||
return string.Empty;
|
||||
|
||||
byte[] buffer = new byte[length * 4];
|
||||
return global::System.Text.Encoding.UTF32.GetString(buffer);
|
||||
}
|
||||
|
||||
static void SetPendingApplicationExceptionUTF16([global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.LPWStr)]global::System.IntPtr cString, int length) {
|
||||
string message = SWIGWStringHelper.CreateWStringFromUTF16(cString, length);
|
||||
SWIGPendingException.Set(new global::System.ApplicationException(message, SWIGPendingException.Retrieve()));
|
||||
}
|
||||
|
||||
static void SetPendingApplicationExceptionUTF32([global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.LPWStr)]global::System.IntPtr cString, int length) {
|
||||
string message = SWIGWStringHelper.CreateWStringFromUTF32(cString, length);
|
||||
SWIGPendingException.Set(new global::System.ApplicationException(message, SWIGPendingException.Retrieve()));
|
||||
}
|
||||
|
||||
static SWIGWStringExceptionHelper() {
|
||||
SWIGRegisterWStringExceptionCallback_$module(applicationExceptionUTF16Delegate, applicationExceptionUTF32Delegate);
|
||||
}
|
||||
}
|
||||
|
||||
static protected SWIGWStringExceptionHelper swigWStringExceptionHelper = new SWIGWStringExceptionHelper();
|
||||
%}
|
||||
|
||||
%insert(runtime) %{
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
#endif
|
||||
SWIGEXPORT void SWIGSTDCALL SWIGRegisterWStringExceptionCallback_$module(SWIG_CSharpWStringExceptionHelperCallback callback_utf16, SWIG_CSharpWStringExceptionHelperCallback callback_utf32) {
|
||||
SWIG_csharp_ApplicationException_callback = sizeof(wchar_t) == 2 ? callback_utf16 : callback_utf32;
|
||||
}
|
||||
%}
|
||||
|
||||
#endif // SWIG_CSHARP_WSTRING_EXCEPTION_HELPER_
|
||||
#endif // SWIG_CSHARP_NO_WSTRING_EXCEPTION_HELPER
|
||||
|
||||
|
||||
// wchar_t
|
||||
%typemap(ctype) wchar_t "wchar_t"
|
||||
%typemap(imtype) wchar_t "char" // Requires adding CharSet=CharSet.Unicode to the DllImport to correctly marshal Unicode characters
|
||||
%typemap(cstype) wchar_t "char"
|
||||
|
||||
%typemap(csin) wchar_t "$csinput"
|
||||
%typemap(csout, excode=SWIGEXCODE) wchar_t {
|
||||
char ret = $imcall;$excode
|
||||
return ret;
|
||||
}
|
||||
%typemap(csvarin, excode=SWIGEXCODE2) wchar_t %{
|
||||
set {
|
||||
$imcall;$excode
|
||||
} %}
|
||||
%typemap(csvarout, excode=SWIGEXCODE2) wchar_t %{
|
||||
get {
|
||||
char ret = $imcall;$excode
|
||||
return ret;
|
||||
} %}
|
||||
|
||||
%typemap(in) wchar_t %{ $1 = ($1_ltype)$input; %}
|
||||
%typemap(out) wchar_t %{ $result = (wchar_t)$1; %}
|
||||
|
||||
%typemap(typecheck) wchar_t = char;
|
||||
|
||||
// wchar_t *
|
||||
|
||||
%fragment("Swig_csharp_UTF16ToWCharPtr", "header") %{
|
||||
/* For converting from .NET UTF16 (2 byte unicode) strings. wchar_t is 2 bytes on Windows, 4 bytes on Linux. */
|
||||
static wchar_t * Swig_csharp_UTF16ToWCharPtr(const unsigned short *str) {
|
||||
if (sizeof(wchar_t) == 2) {
|
||||
return (wchar_t *)str;
|
||||
} else {
|
||||
wchar_t *result = 0;
|
||||
|
||||
if (str) {
|
||||
const unsigned short *pBegin(str);
|
||||
const unsigned short *pEnd(pBegin);
|
||||
wchar_t *ptr = 0;
|
||||
|
||||
while (*pEnd != 0)
|
||||
++pEnd;
|
||||
|
||||
#ifdef __cplusplus
|
||||
result = ptr = new wchar_t[pEnd - pBegin + 1];
|
||||
#else
|
||||
result = ptr = (wchar_t *)malloc(sizeof(wchar_t) * (pEnd - pBegin + 1));
|
||||
#endif
|
||||
while(pBegin != pEnd)
|
||||
*ptr++ = *pBegin++;
|
||||
*ptr++ = 0;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
%}
|
||||
|
||||
%fragment("Swig_csharp_UTF16ToWCharPtrFree", "header") %{
|
||||
static void Swig_csharp_UTF16ToWCharPtrFree(wchar_t *str) {
|
||||
if (sizeof(wchar_t) != 2) {
|
||||
#ifdef __cplusplus
|
||||
delete [] str;
|
||||
#else
|
||||
free(str);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
%}
|
||||
|
||||
%typemap(ctype, out="void *") wchar_t * "unsigned short *"
|
||||
%typemap(imtype,
|
||||
inattributes="[global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.LPWStr)]",
|
||||
outattributes="[return: global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.LPWStr)]",
|
||||
directorinattributes="[global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.LPWStr)]",
|
||||
directoroutattributes="[return: global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.LPWStr)]"
|
||||
) wchar_t * "string"
|
||||
%typemap(cstype) wchar_t * "string"
|
||||
%typemap(csdirectorin) wchar_t * "$iminput"
|
||||
%typemap(csdirectorout) wchar_t * "$cscall"
|
||||
|
||||
%typemap(csin) wchar_t * "$csinput"
|
||||
%typemap(csout, excode=SWIGEXCODE) wchar_t * {
|
||||
string ret = $imcall;$excode
|
||||
return ret;
|
||||
}
|
||||
%typemap(csvarin, excode=SWIGEXCODE2) wchar_t * %{
|
||||
set {
|
||||
$imcall;$excode
|
||||
} %}
|
||||
%typemap(csvarout, excode=SWIGEXCODE2) wchar_t * %{
|
||||
get {
|
||||
string ret = $imcall;$excode
|
||||
return ret;
|
||||
} %}
|
||||
|
||||
%typemap(in, fragment="Swig_csharp_UTF16ToWCharPtr") wchar_t *
|
||||
%{ $1 = Swig_csharp_UTF16ToWCharPtr($input); %}
|
||||
|
||||
%typemap(out) wchar_t * %{ $result = $1 ? SWIG_csharp_wstring_callback($1) : 0; %}
|
||||
|
||||
%typemap(freearg, fragment="Swig_csharp_UTF16ToWCharPtrFree") wchar_t *
|
||||
%{ Swig_csharp_UTF16ToWCharPtrFree($1); %}
|
||||
|
||||
%typemap(directorout, warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) wchar_t *
|
||||
%{ $result = Swig_csharp_UTF16ToWCharPtr($input); %}
|
||||
|
||||
%typemap(directorin) wchar_t * %{ $input = SWIG_csharp_wstring_with_length_callback($1, (int)wcslen($1)); %}
|
||||
|
||||
%typemap(typecheck) wchar_t * = char *;
|
||||
|
||||
%typemap(throws, canthrow=1, fragment="<wchar.h>") wchar_t *
|
||||
%{ SWIG_csharp_ApplicationException_callback($1, (int)wcslen($1));
|
||||
return $null; %}
|
||||
|
||||
|
||||
/* Default typemap for handling wchar_t * members (based on char * in swig.swg) */
|
||||
|
||||
#ifdef __cplusplus
|
||||
%typemap(memberin,fragment="<wchar.h>") wchar_t * {
|
||||
delete [] $1;
|
||||
if ($input && sizeof(wchar_t) == 2) {
|
||||
$1 = ($1_type) (new wchar_t[wcslen((const wchar_t *)$input)+1]);
|
||||
wcscpy((wchar_t *)$1, (const wchar_t *)$input);
|
||||
} else {
|
||||
$1 = $input;
|
||||
$input = 0;
|
||||
}
|
||||
}
|
||||
%typemap(memberin,warning=SWIGWARN_TYPEMAP_WCHARLEAK_MSG,fragment="<wchar.h>") const wchar_t * {
|
||||
if ($input && sizeof(wchar_t) == 2) {
|
||||
$1 = ($1_type) (new wchar_t[wcslen((const wchar_t *)$input)+1]);
|
||||
wcscpy((wchar_t *)$1, (const wchar_t *)$input);
|
||||
} else {
|
||||
$1 = $input;
|
||||
$input = 0;
|
||||
}
|
||||
}
|
||||
%typemap(globalin,fragment="<wchar.h>") wchar_t * {
|
||||
delete [] $1;
|
||||
if ($input && sizeof(wchar_t) == 2) {
|
||||
$1 = ($1_type) (new wchar_t[wcslen((const wchar_t *)$input)+1]);
|
||||
wcscpy((wchar_t *)$1, (const wchar_t *)$input);
|
||||
} else {
|
||||
$1 = $input;
|
||||
$input = 0;
|
||||
}
|
||||
}
|
||||
%typemap(globalin,warning=SWIGWARN_TYPEMAP_WCHARLEAK_MSG,fragment="<wchar.h>") const wchar_t * {
|
||||
if ($input && sizeof(wchar_t) == 2) {
|
||||
$1 = ($1_type) (new wchar_t[wcslen((const wchar_t *)$input)+1]);
|
||||
wcscpy((wchar_t *)$1, (const wchar_t *)$input);
|
||||
} else {
|
||||
$1 = $input;
|
||||
$input = 0;
|
||||
}
|
||||
}
|
||||
#else
|
||||
%typemap(memberin,fragment="<wchar.h>") wchar_t * {
|
||||
free($1);
|
||||
if ($input && sizeof(wchar_t) == 2) {
|
||||
$1 = ($1_type) malloc(wcslen((const wchar_t *)$input)+1);
|
||||
wcscpy((wchar_t *)$1, (const wchar_t *)$input);
|
||||
} else {
|
||||
$1 = $input;
|
||||
$input = 0;
|
||||
}
|
||||
}
|
||||
%typemap(memberin,warning=SWIGWARN_TYPEMAP_WCHARLEAK_MSG,fragment="<wchar.h>") const wchar_t * {
|
||||
if ($input && sizeof(wchar_t) == 2) {
|
||||
$1 = ($1_type) malloc(wcslen((const wchar_t *)$input)+1);
|
||||
wcscpy((wchar_t *)$1, (const wchar_t *)$input);
|
||||
} else {
|
||||
$1 = $input;
|
||||
$input = 0;
|
||||
}
|
||||
}
|
||||
%typemap(globalin,fragment="<wchar.h>") wchar_t * {
|
||||
free($1);
|
||||
if ($input && sizeof(wchar_t) == 2) {
|
||||
$1 = ($1_type) malloc(wcslen((const wchar_t *)$input)+1);
|
||||
wcscpy((wchar_t *)$1, (const wchar_t *)$input);
|
||||
} else {
|
||||
$1 = $input;
|
||||
$input = 0;
|
||||
}
|
||||
}
|
||||
%typemap(globalin,warning=SWIGWARN_TYPEMAP_WCHARLEAK_MSG,fragment="<wchar.h>") const wchar_t * {
|
||||
if ($input && sizeof(wchar_t) == 2) {
|
||||
$1 = ($1_type) malloc(wcslen((const wchar_t *)$input)+1);
|
||||
wcscpy((wchar_t *)$1, (const wchar_t *)$input);
|
||||
} else {
|
||||
$1 = $input;
|
||||
$input = 0;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -1,293 +0,0 @@
|
|||
%include <shared_ptr.i>
|
||||
|
||||
// Language specific macro implementing all the customisations for handling the smart pointer
|
||||
%define SWIG_SHARED_PTR_TYPEMAPS(CONST, TYPE...)
|
||||
|
||||
// %naturalvar is as documented for member variables
|
||||
%naturalvar TYPE;
|
||||
%naturalvar SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >;
|
||||
|
||||
// destructor mods
|
||||
%feature("unref") TYPE
|
||||
//"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;"
|
||||
|
||||
// Typemap customisations...
|
||||
|
||||
// plain value
|
||||
%typemap(in, canthrow=1) CONST TYPE ($&1_type argp = 0) %{
|
||||
argp = ((SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)$input) ? ((SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)$input)->get() : 0;
|
||||
if (!argp) {
|
||||
SWIG_DSetPendingException(SWIG_DIllegalArgumentException, "Attempt to dereference null $1_type");
|
||||
return $null;
|
||||
}
|
||||
$1 = *argp; %}
|
||||
%typemap(out) CONST TYPE
|
||||
%{ $result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(new $1_ltype($1)); %}
|
||||
|
||||
%typemap(directorin) CONST TYPE
|
||||
%{ $input = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > (new $1_ltype(SWIG_STD_MOVE($1))); %}
|
||||
|
||||
%typemap(directorout) CONST TYPE
|
||||
%{ if (!$input) {
|
||||
SWIG_DSetPendingException(SWIG_DIllegalArgumentException, "Attempt to dereference null $1_type");
|
||||
return $null;
|
||||
}
|
||||
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = (SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)$input;
|
||||
$result = *smartarg->get();
|
||||
%}
|
||||
|
||||
// plain pointer
|
||||
%typemap(in, canthrow=1) CONST TYPE * (SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) %{
|
||||
smartarg = (SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)$input;
|
||||
$1 = (TYPE *)(smartarg ? smartarg->get() : 0); %}
|
||||
%typemap(out, fragment="SWIG_null_deleter") CONST TYPE * %{
|
||||
$result = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_$owner) : 0;
|
||||
%}
|
||||
|
||||
%typemap(directorin) CONST TYPE *
|
||||
%{ $input = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_0) : 0; %}
|
||||
|
||||
%typemap(directorout) CONST TYPE * %{
|
||||
#error "typemaps for $1_type not available"
|
||||
%}
|
||||
|
||||
// plain reference
|
||||
%typemap(in, canthrow=1) CONST TYPE & %{
|
||||
$1 = ($1_ltype)(((SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)$input) ? ((SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)$input)->get() : 0);
|
||||
if (!$1) {
|
||||
SWIG_DSetPendingException(SWIG_DIllegalArgumentException, "$1_type reference is null");
|
||||
return $null;
|
||||
} %}
|
||||
%typemap(out, fragment="SWIG_null_deleter") CONST TYPE &
|
||||
%{ $result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_$owner); %}
|
||||
|
||||
%typemap(directorin) CONST TYPE &
|
||||
%{ $input = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > (&$1 SWIG_NO_NULL_DELETER_0); %}
|
||||
|
||||
%typemap(directorout) CONST TYPE & %{
|
||||
#error "typemaps for $1_type not available"
|
||||
%}
|
||||
|
||||
// plain pointer by reference
|
||||
%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") TYPE *CONST&
|
||||
%{ $result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1 SWIG_NO_NULL_DELETER_$owner); %}
|
||||
|
||||
%typemap(directorin) TYPE *CONST&
|
||||
%{ $input = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_0) : 0; %}
|
||||
|
||||
%typemap(directorout) TYPE *CONST& %{
|
||||
#error "typemaps for $1_type not available"
|
||||
%}
|
||||
|
||||
// shared_ptr by value
|
||||
%typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >
|
||||
%{ if ($input) $1 = *($&1_ltype)$input; %}
|
||||
%typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >
|
||||
%{ $result = $1 ? new $1_ltype($1) : 0; %}
|
||||
|
||||
%typemap(directorin) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >
|
||||
%{ $input = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1) : 0; %}
|
||||
|
||||
%typemap(directorout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >
|
||||
%{ if ($input) {
|
||||
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = (SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)$input;
|
||||
$result = *smartarg;
|
||||
}
|
||||
%}
|
||||
|
||||
// shared_ptr by reference
|
||||
%typemap(in, canthrow=1) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & ($*1_ltype tempnull)
|
||||
%{ $1 = $input ? ($1_ltype)$input : &tempnull; %}
|
||||
%typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > &
|
||||
%{ $result = *$1 ? new $*1_ltype(*$1) : 0; %}
|
||||
|
||||
%typemap(directorin) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > &
|
||||
%{ $input = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1) : 0; %}
|
||||
|
||||
%typemap(directorout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & %{
|
||||
#error "typemaps for $1_type not available"
|
||||
%}
|
||||
|
||||
// shared_ptr by pointer
|
||||
%typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * ($*1_ltype tempnull)
|
||||
%{ $1 = $input ? ($1_ltype)$input : &tempnull; %}
|
||||
%typemap(out, fragment="SWIG_null_deleter") SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *
|
||||
%{ $result = ($1 && *$1) ? new $*1_ltype(*$1) : 0;
|
||||
if ($owner) delete $1; %}
|
||||
|
||||
%typemap(directorin) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *
|
||||
%{ $input = ($1 && *$1) ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1) : 0; %}
|
||||
|
||||
%typemap(directorout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * %{
|
||||
#error "typemaps for $1_type not available"
|
||||
%}
|
||||
|
||||
// shared_ptr by pointer reference
|
||||
%typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& (SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempnull, $*1_ltype temp = 0)
|
||||
%{ temp = $input ? *($1_ltype)&$input : &tempnull;
|
||||
$1 = &temp; %}
|
||||
%typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *&
|
||||
%{ *($1_ltype)&$result = (*$1 && **$1) ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(**$1) : 0; %}
|
||||
|
||||
%typemap(directorin) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *&
|
||||
%{ $input = ($1 && *$1) ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1) : 0; %}
|
||||
|
||||
%typemap(directorout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& %{
|
||||
#error "typemaps for $1_type not available"
|
||||
%}
|
||||
|
||||
// various missing typemaps - If ever used (unlikely) ensure compilation error rather than runtime bug
|
||||
%typemap(in) CONST TYPE[], CONST TYPE[ANY], CONST TYPE (CLASS::*) %{
|
||||
#error "typemaps for $1_type not available"
|
||||
%}
|
||||
%typemap(out) CONST TYPE[], CONST TYPE[ANY], CONST TYPE (CLASS::*) %{
|
||||
#error "typemaps for $1_type not available"
|
||||
%}
|
||||
|
||||
|
||||
%typemap (ctype) 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 > *& "void *"
|
||||
%typemap (imtype) 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 > *& "void*"
|
||||
%typemap (dtype) 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 > *& "$typemap(dtype, TYPE)"
|
||||
|
||||
%typemap(din) 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 > *& "$typemap(dtype, TYPE).swigGetCPtr($dinput)"
|
||||
|
||||
%typemap(ddirectorout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > "$typemap(dtype, TYPE).swigGetCPtr($dcall)"
|
||||
|
||||
%typemap(ddirectorin) CONST TYPE,
|
||||
CONST TYPE *,
|
||||
CONST TYPE &,
|
||||
TYPE *CONST& "($winput is null) ? null : new $typemap(dtype, TYPE)($winput, true)"
|
||||
|
||||
%typemap(ddirectorin) 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 > *& "($winput is null) ? null : new $typemap(dtype, TYPE)($winput, true)"
|
||||
|
||||
|
||||
%typemap(dout, excode=SWIGEXCODE) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > {
|
||||
void* cPtr = $imcall;
|
||||
auto ret = (cPtr is null) ? null : new $typemap(dtype, TYPE)(cPtr, true);$excode
|
||||
return ret;
|
||||
}
|
||||
%typemap(dout, excode=SWIGEXCODE) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & {
|
||||
void* cPtr = $imcall;
|
||||
auto ret = (cPtr is null) ? null : new $typemap(dtype, TYPE)(cPtr, true);$excode
|
||||
return ret;
|
||||
}
|
||||
%typemap(dout, excode=SWIGEXCODE) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * {
|
||||
void* cPtr = $imcall;
|
||||
auto ret = (cPtr is null) ? null : new $typemap(dtype, TYPE)(cPtr, true);$excode
|
||||
return ret;
|
||||
}
|
||||
%typemap(dout, excode=SWIGEXCODE) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& {
|
||||
void* cPtr = $imcall;
|
||||
auto ret = (cPtr is null) ? null : new $typemap(dtype, TYPE)(cPtr, true);$excode
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
%typemap(dout, excode=SWIGEXCODE) CONST TYPE {
|
||||
auto ret = new $typemap(dtype, TYPE)($imcall, true);$excode
|
||||
return ret;
|
||||
}
|
||||
%typemap(dout, excode=SWIGEXCODE) CONST TYPE & {
|
||||
auto ret = new $typemap(dtype, TYPE)($imcall, true);$excode
|
||||
return ret;
|
||||
}
|
||||
%typemap(dout, excode=SWIGEXCODE) CONST TYPE * {
|
||||
void* cPtr = $imcall;
|
||||
auto ret = (cPtr is null) ? null : new $typemap(dtype, TYPE)(cPtr, true);$excode
|
||||
return ret;
|
||||
}
|
||||
%typemap(dout, excode=SWIGEXCODE) TYPE *CONST& {
|
||||
void* cPtr = $imcall;
|
||||
auto ret = (cPtr is null) ? null : new $typemap(dtype, TYPE)(cPtr, true);$excode
|
||||
return ret;
|
||||
}
|
||||
|
||||
// Proxy classes (base classes, ie, not derived classes)
|
||||
%typemap(dbody) SWIGTYPE %{
|
||||
private void* swigCPtr;
|
||||
private bool swigCMemOwn;
|
||||
|
||||
public this(void* cObject, bool ownCObject) {
|
||||
swigCPtr = cObject;
|
||||
swigCMemOwn = ownCObject;
|
||||
}
|
||||
|
||||
public static void* swigGetCPtr(typeof(this) obj) {
|
||||
return (obj is null) ? null : obj.swigCPtr;
|
||||
}
|
||||
%}
|
||||
|
||||
// Derived proxy classes
|
||||
%typemap(dbody_derived) SWIGTYPE %{
|
||||
private void* swigCPtr;
|
||||
private bool swigCMemOwn;
|
||||
|
||||
public this(void* cObject, bool ownCObject) {
|
||||
super($imdmodule.$dclazznameSmartPtrUpcast(cObject), ownCObject);
|
||||
swigCPtr = cObject;
|
||||
swigCMemOwn = ownCObject;
|
||||
}
|
||||
|
||||
public static void* swigGetCPtr(typeof(this) obj) {
|
||||
return (obj is null) ? null : obj.swigCPtr;
|
||||
}
|
||||
%}
|
||||
|
||||
%typemap(ddispose, methodname="dispose", methodmodifiers="public") TYPE {
|
||||
synchronized(this) {
|
||||
if (swigCPtr !is null) {
|
||||
if (swigCMemOwn) {
|
||||
swigCMemOwn = false;
|
||||
$imcall;
|
||||
}
|
||||
swigCPtr = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
%typemap(ddispose_derived, methodname="dispose", methodmodifiers="public") TYPE {
|
||||
synchronized(this) {
|
||||
if (swigCPtr !is null) {
|
||||
if (swigCMemOwn) {
|
||||
swigCMemOwn = false;
|
||||
$imcall;
|
||||
}
|
||||
swigCPtr = null;
|
||||
super.dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Typecheck typemaps
|
||||
%typemap(typecheck, precedence=SWIG_TYPECHECK_POINTER, equivalent="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 > *,
|
||||
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *&
|
||||
""
|
||||
|
||||
%template() SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >;
|
||||
%enddef
|
||||
|
|
@ -1,111 +0,0 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* carrays.i
|
||||
*
|
||||
* D-specific version of ../carrays.i.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* %array_functions(TYPE,NAME)
|
||||
*
|
||||
* Generates functions for creating and accessing elements of a C array
|
||||
* (as pointers). Creates the following functions:
|
||||
*
|
||||
* TYPE *new_NAME(int nelements)
|
||||
* void delete_NAME(TYPE *);
|
||||
* TYPE NAME_getitem(TYPE *, int index);
|
||||
* void NAME_setitem(TYPE *, int index, TYPE value);
|
||||
*
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
%define %array_functions(TYPE,NAME)
|
||||
%{
|
||||
static TYPE *new_##NAME(int nelements) { %}
|
||||
#ifdef __cplusplus
|
||||
%{ return new TYPE[nelements](); %}
|
||||
#else
|
||||
%{ return (TYPE *) calloc(nelements,sizeof(TYPE)); %}
|
||||
#endif
|
||||
%{}
|
||||
|
||||
static void delete_##NAME(TYPE *ary) { %}
|
||||
#ifdef __cplusplus
|
||||
%{ delete [] ary; %}
|
||||
#else
|
||||
%{ free(ary); %}
|
||||
#endif
|
||||
%{}
|
||||
|
||||
static TYPE NAME##_getitem(TYPE *ary, int index) {
|
||||
return ary[index];
|
||||
}
|
||||
static void NAME##_setitem(TYPE *ary, int index, TYPE value) {
|
||||
ary[index] = value;
|
||||
}
|
||||
%}
|
||||
|
||||
TYPE *new_##NAME(int nelements);
|
||||
void delete_##NAME(TYPE *ary);
|
||||
TYPE NAME##_getitem(TYPE *ary, int index);
|
||||
void NAME##_setitem(TYPE *ary, int index, TYPE value);
|
||||
|
||||
%enddef
|
||||
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* %array_class(TYPE,NAME)
|
||||
*
|
||||
* Generates a class wrapper around a C array. The class has the following
|
||||
* interface:
|
||||
*
|
||||
* struct NAME {
|
||||
* NAME(int nelements);
|
||||
* ~NAME();
|
||||
* TYPE getitem(int index);
|
||||
* void setitem(int index, TYPE value);
|
||||
* TYPE * ptr();
|
||||
* static NAME *frompointer(TYPE *t);
|
||||
* }
|
||||
*
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
%define %array_class(TYPE,NAME)
|
||||
%{
|
||||
typedef TYPE NAME;
|
||||
%}
|
||||
|
||||
typedef struct {} NAME;
|
||||
|
||||
%extend NAME {
|
||||
#ifdef __cplusplus
|
||||
NAME(int nelements) {
|
||||
return new TYPE[nelements]();
|
||||
}
|
||||
~NAME() {
|
||||
delete [] self;
|
||||
}
|
||||
#else
|
||||
NAME(int nelements) {
|
||||
return (TYPE *) calloc(nelements,sizeof(TYPE));
|
||||
}
|
||||
~NAME() {
|
||||
free(self);
|
||||
}
|
||||
#endif
|
||||
|
||||
TYPE getitem(int index) {
|
||||
return self[index];
|
||||
}
|
||||
void setitem(int index, TYPE value) {
|
||||
self[index] = value;
|
||||
}
|
||||
TYPE * ptr() {
|
||||
return self;
|
||||
}
|
||||
static NAME *frompointer(TYPE *t) {
|
||||
return (NAME *) t;
|
||||
}
|
||||
};
|
||||
|
||||
%types(NAME = TYPE);
|
||||
|
||||
%enddef
|
||||
|
|
@ -1,171 +0,0 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* cpointer.i
|
||||
*
|
||||
* D-specific version of ../cpointer.i.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* %pointer_class(type,name)
|
||||
*
|
||||
* Places a simple proxy around a simple type like 'int', 'float', or whatever.
|
||||
* The proxy provides this interface:
|
||||
*
|
||||
* class type {
|
||||
* public:
|
||||
* type();
|
||||
* ~type();
|
||||
* type value();
|
||||
* void assign(type value);
|
||||
* };
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* %pointer_class(int, intp);
|
||||
*
|
||||
* int add(int *x, int *y) { return *x + *y; }
|
||||
*
|
||||
* In python (with proxies)
|
||||
*
|
||||
* >>> a = intp()
|
||||
* >>> a.assign(10)
|
||||
* >>> a.value()
|
||||
* 10
|
||||
* >>> b = intp()
|
||||
* >>> b.assign(20)
|
||||
* >>> print add(a,b)
|
||||
* 30
|
||||
*
|
||||
* As a general rule, this macro should not be used on class/structures that
|
||||
* are already defined in the interface.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
|
||||
%define %pointer_class(TYPE, NAME)
|
||||
%{
|
||||
typedef TYPE NAME;
|
||||
%}
|
||||
|
||||
typedef struct {
|
||||
} NAME;
|
||||
|
||||
%extend NAME {
|
||||
#ifdef __cplusplus
|
||||
NAME() {
|
||||
return new TYPE();
|
||||
}
|
||||
~NAME() {
|
||||
delete self;
|
||||
}
|
||||
#else
|
||||
NAME() {
|
||||
return (TYPE *) calloc(1,sizeof(TYPE));
|
||||
}
|
||||
~NAME() {
|
||||
free(self);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
%extend NAME {
|
||||
|
||||
void assign(TYPE value) {
|
||||
*self = value;
|
||||
}
|
||||
TYPE value() {
|
||||
return *self;
|
||||
}
|
||||
TYPE * ptr() {
|
||||
return self;
|
||||
}
|
||||
static NAME * frompointer(TYPE *t) {
|
||||
return (NAME *) t;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
%types(NAME = TYPE);
|
||||
|
||||
%enddef
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* %pointer_functions(type,name)
|
||||
*
|
||||
* Create functions for allocating/deallocating pointers. This can be used
|
||||
* if you don't want to create a proxy class or if the pointer is complex.
|
||||
*
|
||||
* %pointer_functions(int, intp)
|
||||
*
|
||||
* int add(int *x, int *y) { return *x + *y; }
|
||||
*
|
||||
* In python (with proxies)
|
||||
*
|
||||
* >>> a = copy_intp(10)
|
||||
* >>> intp_value(a)
|
||||
* 10
|
||||
* >>> b = new_intp()
|
||||
* >>> intp_assign(b,20)
|
||||
* >>> print add(a,b)
|
||||
* 30
|
||||
* >>> delete_intp(a)
|
||||
* >>> delete_intp(b)
|
||||
*
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
%define %pointer_functions(TYPE,NAME)
|
||||
%{
|
||||
static TYPE *new_##NAME() { %}
|
||||
#ifdef __cplusplus
|
||||
%{ return new TYPE(); %}
|
||||
#else
|
||||
%{ return (TYPE *) calloc(1,sizeof(TYPE)); %}
|
||||
#endif
|
||||
%{}
|
||||
|
||||
static TYPE *copy_##NAME(TYPE value) { %}
|
||||
#ifdef __cplusplus
|
||||
%{ return new TYPE(value); %}
|
||||
#else
|
||||
%{ TYPE *self = (TYPE *) calloc(1,sizeof(TYPE));
|
||||
*self = value;
|
||||
return self; %}
|
||||
#endif
|
||||
%{}
|
||||
|
||||
static void delete_##NAME(TYPE *self) { %}
|
||||
#ifdef __cplusplus
|
||||
%{ delete self; %}
|
||||
#else
|
||||
%{ free(self); %}
|
||||
#endif
|
||||
%{}
|
||||
|
||||
static void NAME ##_assign(TYPE *self, TYPE value) {
|
||||
*self = value;
|
||||
}
|
||||
|
||||
static TYPE NAME ##_value(TYPE *self) {
|
||||
return *self;
|
||||
}
|
||||
%}
|
||||
|
||||
TYPE *new_##NAME();
|
||||
TYPE *copy_##NAME(TYPE value);
|
||||
void delete_##NAME(TYPE *self);
|
||||
void NAME##_assign(TYPE *self, TYPE value);
|
||||
TYPE NAME##_value(TYPE *self);
|
||||
|
||||
%enddef
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* %pointer_cast(type1,type2,name)
|
||||
*
|
||||
* Generates a pointer casting function.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
%define %pointer_cast(TYPE1,TYPE2,NAME)
|
||||
%inline %{
|
||||
TYPE2 NAME(TYPE1 x) {
|
||||
return (TYPE2) x;
|
||||
}
|
||||
%}
|
||||
%enddef
|
||||
|
|
@ -1,46 +0,0 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* d.swg
|
||||
*
|
||||
* Main library file for the D language module. See the D chapter in the SWIG
|
||||
* manual for explanation on the typemaps, pragmas, etc. used.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
// Typemaps for exception handling.
|
||||
%include <dexception.swg>
|
||||
|
||||
// Typemaps for primitive types.
|
||||
%include <dprimitives.swg>
|
||||
|
||||
// Typemaps for non-primitive types (C/C++ classes and structs).
|
||||
%include <dswigtype.swg>
|
||||
|
||||
// Typemaps for enumeration types.
|
||||
%include <denums.swg>
|
||||
|
||||
// Typemaps for member function pointers.
|
||||
%include <dmemberfunctionpointers.swg>
|
||||
|
||||
// Typemaps for wrapping pointers to/arrays of C chars as D strings.
|
||||
%include <dstrings.swg>
|
||||
|
||||
// Typemaps for handling void function return types and empty parameter lists.
|
||||
%include <dvoid.swg>
|
||||
|
||||
// Typemaps containing D code used when generating D proxy classes.
|
||||
%include <dclassgen.swg>
|
||||
|
||||
// Mapping of C++ operator overloading methods to D.
|
||||
%include <doperators.swg>
|
||||
|
||||
// Helper code string and exception handling.
|
||||
%include <dhead.swg>
|
||||
|
||||
// Wrapper loader code for dynamically linking the C wrapper library from the D
|
||||
// wrapper module.
|
||||
%include <wrapperloader.swg>
|
||||
|
||||
// List of all reserved D keywords.
|
||||
%include <dkw.swg>
|
||||
|
||||
// D-specific directives.
|
||||
%include <ddirectives.swg>
|
||||
|
|
@ -1,172 +0,0 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* dclassgen.swg
|
||||
*
|
||||
* Typemaps containing D code used when generating D proxy classes.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
%typemap(dbase) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) ""
|
||||
%typemap(dclassmodifiers) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) "class"
|
||||
%typemap(dcode) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) ""
|
||||
%typemap(dimports) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) ""
|
||||
%typemap(dinterfaces) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) ""
|
||||
%typemap(dinterfaces_derived) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) ""
|
||||
|
||||
// See <denums.swg>.
|
||||
%typemap(dclassmodifiers) enum SWIGTYPE "enum"
|
||||
%typemap(dcode) enum SWIGTYPE ""
|
||||
|
||||
|
||||
/*
|
||||
* Proxy classes.
|
||||
*/
|
||||
|
||||
%typemap(dconstructor, excode=SWIGEXCODE,directorconnect="\n swigDirectorConnect();") SWIGTYPE {
|
||||
this($imcall, true);$excode$directorconnect
|
||||
}
|
||||
|
||||
%typemap(ddestructor) SWIGTYPE %{
|
||||
~this() {
|
||||
dispose();
|
||||
}
|
||||
%}
|
||||
|
||||
// We do not use »override« attribute for generated dispose() methods to stay
|
||||
// somewhat compatible to Phobos and older Tango versions where Object.dispose()
|
||||
// does not exist.
|
||||
%typemap(ddispose, methodname="dispose", methodmodifiers="public", parameters="") SWIGTYPE {
|
||||
synchronized(this) {
|
||||
if (swigCPtr !is null) {
|
||||
if (swigCMemOwn) {
|
||||
swigCMemOwn = false;
|
||||
$imcall;
|
||||
}
|
||||
swigCPtr = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
%typemap(ddispose_derived, methodname="dispose", methodmodifiers="public", parameters="") SWIGTYPE {
|
||||
synchronized(this) {
|
||||
if (swigCPtr !is null) {
|
||||
if (swigCMemOwn) {
|
||||
swigCMemOwn = false;
|
||||
$imcall;
|
||||
}
|
||||
swigCPtr = null;
|
||||
super.dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Unfortunately, the »package« visibility attribute does not work in D when the
|
||||
// module in question is in the root package (happens if no -package is specified
|
||||
// at the SWIG command line), so we are stuck with public visibility for
|
||||
// swigGetCPtr().
|
||||
%typemap(dbody) SWIGTYPE %{
|
||||
private void* swigCPtr;
|
||||
protected bool swigCMemOwn;
|
||||
|
||||
public this(void* cObject, bool ownCObject) {
|
||||
swigCPtr = cObject;
|
||||
swigCMemOwn = ownCObject;
|
||||
}
|
||||
|
||||
public static void* swigGetCPtr(typeof(this) obj) {
|
||||
return (obj is null) ? null : obj.swigCPtr;
|
||||
}
|
||||
|
||||
public static void* swigRelease(typeof(this) obj) {
|
||||
if (obj !is null) {
|
||||
if (!obj.swigCMemOwn)
|
||||
throw new Exception("Cannot release ownership as memory is not owned");
|
||||
void* ptr = obj.swigCPtr;
|
||||
obj.swigCMemOwn = false;
|
||||
obj.dispose();
|
||||
return ptr;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
mixin $imdmodule.SwigOperatorDefinitions;
|
||||
%}
|
||||
|
||||
|
||||
%typemap(dbody_derived) SWIGTYPE %{
|
||||
private void* swigCPtr;
|
||||
|
||||
public this(void* cObject, bool ownCObject) {
|
||||
super($imdmodule.$dclazznameUpcast(cObject), ownCObject);
|
||||
swigCPtr = cObject;
|
||||
}
|
||||
|
||||
public static void* swigGetCPtr(typeof(this) obj) {
|
||||
return (obj is null) ? null : obj.swigCPtr;
|
||||
}
|
||||
|
||||
public static void* swigRelease(typeof(this) obj) {
|
||||
if (obj !is null) {
|
||||
if (!obj.swigCMemOwn)
|
||||
throw new Exception("Cannot release ownership as memory is not owned");
|
||||
void* ptr = obj.swigCPtr;
|
||||
obj.swigCMemOwn = false;
|
||||
obj.dispose();
|
||||
return ptr;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
mixin $imdmodule.SwigOperatorDefinitions;
|
||||
%}
|
||||
|
||||
|
||||
/*
|
||||
* Type wrapper classes.
|
||||
*/
|
||||
|
||||
%typemap(dbody) SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [] %{
|
||||
private void* swigCPtr;
|
||||
|
||||
public this(void* cObject, bool futureUse) {
|
||||
swigCPtr = cObject;
|
||||
}
|
||||
|
||||
protected this() {
|
||||
swigCPtr = null;
|
||||
}
|
||||
|
||||
public static void* swigGetCPtr(typeof(this) obj) {
|
||||
return (obj is null) ? null : obj.swigCPtr;
|
||||
}
|
||||
|
||||
public static void* swigRelease(typeof(this) obj) {
|
||||
return (obj is null) ? null : obj.swigCPtr;
|
||||
}
|
||||
|
||||
mixin $imdmodule.SwigOperatorDefinitions;
|
||||
%}
|
||||
|
||||
|
||||
/*
|
||||
* Member function pointer wrapper classes (see <dmemberfunctionpointers.swg>).
|
||||
*/
|
||||
|
||||
%typemap(dbody) SWIGTYPE (CLASS::*) %{
|
||||
private char* swigCPtr;
|
||||
|
||||
public this(char* cMemberPtr, bool futureUse) {
|
||||
swigCPtr = cMemberPtr;
|
||||
}
|
||||
|
||||
protected this() {
|
||||
swigCPtr = null;
|
||||
}
|
||||
|
||||
package static char* swigGetCMemberPtr(typeof(this) obj) {
|
||||
return (obj is null) ? null : obj.swigCPtr;
|
||||
}
|
||||
|
||||
mixin $imdmodule.SwigOperatorDefinitions;
|
||||
%}
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* ddirectives.swg
|
||||
*
|
||||
* D-specifiv directives.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
#define %dmanifestconst %feature("d:manifestconst")
|
||||
#define %dconstvalue(value) %feature("d:constvalue",value)
|
||||
#define %dmethodmodifiers %feature("d:methodmodifiers")
|
||||
#define %dnothrowexception %feature("except")
|
||||
#define %proxycode %insert("proxycode")
|
||||
|
|
@ -1,60 +0,0 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* denums.swg
|
||||
*
|
||||
* Typemaps for enumerations.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
|
||||
/*
|
||||
* Typemaps for enumeration types.
|
||||
*/
|
||||
|
||||
%typemap(ctype) enum SWIGTYPE "int"
|
||||
%typemap(imtype) enum SWIGTYPE "int"
|
||||
%typemap(dtype, cprimitive="1") enum SWIGTYPE "$dclassname"
|
||||
|
||||
%typecheck(SWIG_TYPECHECK_POINTER) enum SWIGTYPE ""
|
||||
|
||||
%typemap(in) enum SWIGTYPE %{ $1 = ($1_ltype)$input; %}
|
||||
%typemap(out) enum SWIGTYPE %{ $result = (int)$1; %}
|
||||
|
||||
%typemap(directorout) enum SWIGTYPE %{ $result = ($1_ltype)$input; %}
|
||||
%typemap(directorin) enum SWIGTYPE "$input = (int)$1;"
|
||||
%typemap(ddirectorin) enum SWIGTYPE "cast($dclassname)$winput"
|
||||
%typemap(ddirectorout) enum SWIGTYPE "cast(int)$dcall"
|
||||
|
||||
%typemap(din) enum SWIGTYPE "cast(int)$dinput"
|
||||
%typemap(dout, excode=SWIGEXCODE) enum SWIGTYPE {
|
||||
$dclassname ret = cast($dclassname)$imcall;$excode
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Typemaps for (const) references to enumeration types.
|
||||
*/
|
||||
|
||||
%typemap(ctype) const enum SWIGTYPE & "int"
|
||||
%typemap(imtype) const enum SWIGTYPE & "int"
|
||||
%typemap(dtype) const enum SWIGTYPE & "$*dclassname"
|
||||
|
||||
%typecheck(SWIG_TYPECHECK_POINTER) const enum SWIGTYPE & ""
|
||||
|
||||
%typemap(in) const enum SWIGTYPE & ($*1_ltype temp)
|
||||
%{ temp = ($*1_ltype)$input;
|
||||
$1 = &temp; %}
|
||||
%typemap(out) const enum SWIGTYPE & %{ $result = (int)*$1; %}
|
||||
|
||||
%typemap(directorin) const enum SWIGTYPE & "$input = (int)$1;"
|
||||
%typemap(directorout,warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const enum SWIGTYPE &
|
||||
%{ static $*1_ltype temp = ($*1_ltype)$input;
|
||||
$result = &temp; %}
|
||||
|
||||
%typemap(ddirectorin) const enum SWIGTYPE & "cast($*dclassname)$winput"
|
||||
%typemap(ddirectorout) const enum SWIGTYPE & "cast(int)$dcall"
|
||||
|
||||
%typemap(din) const enum SWIGTYPE & "cast(int)$dinput"
|
||||
%typemap(dout, excode=SWIGEXCODE) const enum SWIGTYPE & {
|
||||
$*dclassname ret = cast($*dclassname)$imcall;$excode
|
||||
return ret;
|
||||
}
|
||||
|
|
@ -1,30 +0,0 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* dexception.swg
|
||||
*
|
||||
* Typemaps used for propagating C++ exceptions to D.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
// Code which is inserted into the dout typemaps and class constructors via
|
||||
// excode if exceptions can be thrown.
|
||||
%define SWIGEXCODE "\n if ($imdmodule.SwigPendingException.isPending) throw $imdmodule.SwigPendingException.retrieve();" %enddef
|
||||
|
||||
%typemap(throws, canthrow=1) int,
|
||||
long,
|
||||
short,
|
||||
unsigned int,
|
||||
unsigned long,
|
||||
unsigned short
|
||||
%{ char error_msg[256];
|
||||
sprintf(error_msg, "C++ $1_type exception thrown, value: %d", $1);
|
||||
SWIG_DSetPendingException(SWIG_DException, error_msg);
|
||||
return $null; %}
|
||||
|
||||
%typemap(throws, canthrow=1) SWIGTYPE, SWIGTYPE &, SWIGTYPE *, SWIGTYPE [ANY],
|
||||
enum SWIGTYPE, const enum SWIGTYPE &
|
||||
%{ (void)$1;
|
||||
SWIG_DSetPendingException(SWIG_DException, "C++ $1_type exception thrown");
|
||||
return $null; %}
|
||||
|
||||
%typemap(throws, canthrow=1) char *
|
||||
%{ SWIG_DSetPendingException(SWIG_DException, $1);
|
||||
return $null; %}
|
||||
|
|
@ -1,298 +0,0 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* dhead.swg
|
||||
*
|
||||
* Support code for exceptions if the SWIG_D_NO_EXCEPTION_HELPER is not defined
|
||||
* Support code for strings if the SWIG_D_NO_STRING_HELPER is not defined
|
||||
*
|
||||
* Support code for function pointers. ----------------------------------------------------------------------------- */
|
||||
|
||||
%insert(runtime) %{
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
/* Contract support. */
|
||||
#define SWIG_contract_assert(nullreturn, expr, msg) do { if (!(expr)) {SWIG_DSetPendingException(SWIG_DException, msg); return nullreturn; } } while (0)
|
||||
%}
|
||||
|
||||
|
||||
/*
|
||||
* Exception support code.
|
||||
*/
|
||||
|
||||
#if !defined(SWIG_D_NO_EXCEPTION_HELPER)
|
||||
%insert(runtime) %{
|
||||
// Support for throwing D exceptions from C/C++.
|
||||
typedef enum {
|
||||
SWIG_DException = 0,
|
||||
SWIG_DIllegalArgumentException,
|
||||
SWIG_DIllegalElementException,
|
||||
SWIG_DIOException,
|
||||
SWIG_DNoSuchElementException
|
||||
} SWIG_DExceptionCodes;
|
||||
|
||||
typedef void (* SWIG_DExceptionCallback_t)(const char *);
|
||||
|
||||
typedef struct {
|
||||
SWIG_DExceptionCodes code;
|
||||
SWIG_DExceptionCallback_t callback;
|
||||
} SWIG_DException_t;
|
||||
|
||||
static SWIG_DException_t SWIG_d_exceptions[] = {
|
||||
{ SWIG_DException, NULL },
|
||||
{ SWIG_DIllegalArgumentException, NULL },
|
||||
{ SWIG_DIllegalElementException, NULL },
|
||||
{ SWIG_DIOException, NULL },
|
||||
{ SWIG_DNoSuchElementException, NULL }
|
||||
};
|
||||
|
||||
static void SWIGUNUSED SWIG_DSetPendingException(SWIG_DExceptionCodes code, const char *msg) {
|
||||
if ((size_t)code < sizeof(SWIG_d_exceptions)/sizeof(SWIG_DException_t)) {
|
||||
SWIG_d_exceptions[code].callback(msg);
|
||||
} else {
|
||||
SWIG_d_exceptions[SWIG_DException].callback(msg);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
#endif
|
||||
SWIGEXPORT void SWIGRegisterExceptionCallbacks_$module(
|
||||
SWIG_DExceptionCallback_t exceptionCallback,
|
||||
SWIG_DExceptionCallback_t illegalArgumentCallback,
|
||||
SWIG_DExceptionCallback_t illegalElementCallback,
|
||||
SWIG_DExceptionCallback_t ioCallback,
|
||||
SWIG_DExceptionCallback_t noSuchElementCallback) {
|
||||
SWIG_d_exceptions[SWIG_DException].callback = exceptionCallback;
|
||||
SWIG_d_exceptions[SWIG_DIllegalArgumentException].callback = illegalArgumentCallback;
|
||||
SWIG_d_exceptions[SWIG_DIllegalElementException].callback = illegalElementCallback;
|
||||
SWIG_d_exceptions[SWIG_DIOException].callback = ioCallback;
|
||||
SWIG_d_exceptions[SWIG_DNoSuchElementException].callback = noSuchElementCallback;
|
||||
}
|
||||
%}
|
||||
|
||||
#if (SWIG_D_VERSION == 1)
|
||||
%pragma(d) imdmoduleimports=%{
|
||||
// Exception throwing support currently requires Tango, but there is no reason
|
||||
// why it could not support Phobos.
|
||||
static import tango.core.Exception;
|
||||
static import tango.core.Thread;
|
||||
static import tango.stdc.stringz;
|
||||
%}
|
||||
|
||||
%pragma(d) imdmodulecode=%{
|
||||
private class SwigExceptionHelper {
|
||||
static this() {
|
||||
swigRegisterExceptionCallbacks$module(
|
||||
&setException,
|
||||
&setIllegalArgumentException,
|
||||
&setIllegalElementException,
|
||||
&setIOException,
|
||||
&setNoSuchElementException);
|
||||
}
|
||||
|
||||
static void setException(char* message) {
|
||||
auto exception = new object.Exception(tango.stdc.stringz.fromStringz(message).dup);
|
||||
SwigPendingException.set(exception);
|
||||
}
|
||||
|
||||
static void setIllegalArgumentException(char* message) {
|
||||
auto exception = new tango.core.Exception.IllegalArgumentException(tango.stdc.stringz.fromStringz(message).dup);
|
||||
SwigPendingException.set(exception);
|
||||
}
|
||||
|
||||
static void setIllegalElementException(char* message) {
|
||||
auto exception = new tango.core.Exception.IllegalElementException(tango.stdc.stringz.fromStringz(message).dup);
|
||||
SwigPendingException.set(exception);
|
||||
}
|
||||
|
||||
static void setIOException(char* message) {
|
||||
auto exception = new tango.core.Exception.IOException(tango.stdc.stringz.fromStringz(message).dup);
|
||||
SwigPendingException.set(exception);
|
||||
}
|
||||
|
||||
static void setNoSuchElementException(char* message) {
|
||||
auto exception = new tango.core.Exception.NoSuchElementException(tango.stdc.stringz.fromStringz(message).dup);
|
||||
SwigPendingException.set(exception);
|
||||
}
|
||||
}
|
||||
|
||||
package class SwigPendingException {
|
||||
public:
|
||||
static this() {
|
||||
m_sPendingException = new ThreadLocalData(null);
|
||||
}
|
||||
|
||||
static bool isPending() {
|
||||
return m_sPendingException.val !is null;
|
||||
}
|
||||
|
||||
static void set(object.Exception e) {
|
||||
auto pending = m_sPendingException.val;
|
||||
if (pending !is null) {
|
||||
e.next = pending;
|
||||
throw new object.Exception("FATAL: An earlier pending exception from C/C++ " ~
|
||||
"code was missed and thus not thrown (" ~ pending.classinfo.name ~ ": " ~
|
||||
pending.msg ~ ")!", e);
|
||||
}
|
||||
m_sPendingException.val = e;
|
||||
}
|
||||
|
||||
static object.Exception retrieve() {
|
||||
auto e = m_sPendingException.val;
|
||||
m_sPendingException.val = null;
|
||||
return e;
|
||||
}
|
||||
|
||||
private:
|
||||
// The reference to the pending exception (if any) is stored thread-local.
|
||||
alias tango.core.Thread.ThreadLocal!(object.Exception) ThreadLocalData;
|
||||
static ThreadLocalData m_sPendingException;
|
||||
}
|
||||
alias void function(char* message) SwigExceptionCallback;
|
||||
%}
|
||||
#else
|
||||
%pragma(d) imdmoduleimports=%{
|
||||
static import std.conv;
|
||||
%}
|
||||
|
||||
%pragma(d) imdmodulecode=%{
|
||||
private class SwigExceptionHelper {
|
||||
static this() {
|
||||
// The D1/Tango version maps C++ exceptions to multiple exception types.
|
||||
swigRegisterExceptionCallbacks$module(
|
||||
&setException,
|
||||
&setException,
|
||||
&setException,
|
||||
&setException,
|
||||
&setException
|
||||
);
|
||||
}
|
||||
|
||||
static void setException(const char* message) {
|
||||
auto exception = new object.Exception(std.conv.to!string(message));
|
||||
SwigPendingException.set(exception);
|
||||
}
|
||||
}
|
||||
|
||||
package struct SwigPendingException {
|
||||
public:
|
||||
static this() {
|
||||
m_sPendingException = null;
|
||||
}
|
||||
|
||||
static bool isPending() {
|
||||
return m_sPendingException !is null;
|
||||
}
|
||||
|
||||
static void set(object.Exception e) {
|
||||
if (m_sPendingException !is null) {
|
||||
e.next = m_sPendingException;
|
||||
throw new object.Exception("FATAL: An earlier pending exception from C/C++ code " ~
|
||||
"was missed and thus not thrown (" ~ m_sPendingException.classinfo.name ~
|
||||
": " ~ m_sPendingException.msg ~ ")!", e);
|
||||
}
|
||||
|
||||
m_sPendingException = e;
|
||||
}
|
||||
|
||||
static object.Exception retrieve() {
|
||||
auto e = m_sPendingException;
|
||||
m_sPendingException = null;
|
||||
return e;
|
||||
}
|
||||
|
||||
private:
|
||||
// The reference to the pending exception (if any) is stored thread-local.
|
||||
static object.Exception m_sPendingException;
|
||||
}
|
||||
alias void function(const char* message) SwigExceptionCallback;
|
||||
%}
|
||||
#endif
|
||||
// Callback registering function in wrapperloader.swg.
|
||||
#endif // SWIG_D_NO_EXCEPTION_HELPER
|
||||
|
||||
|
||||
/*
|
||||
* String support code.
|
||||
*/
|
||||
|
||||
#if !defined(SWIG_D_NO_STRING_HELPER)
|
||||
%insert(runtime) %{
|
||||
// Callback for returning strings to D without leaking memory.
|
||||
typedef char * (* SWIG_DStringHelperCallback)(const char *);
|
||||
static SWIG_DStringHelperCallback SWIG_d_string_callback = NULL;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
#endif
|
||||
SWIGEXPORT void SWIGRegisterStringCallback_$module(SWIG_DStringHelperCallback callback) {
|
||||
SWIG_d_string_callback = callback;
|
||||
}
|
||||
%}
|
||||
|
||||
#if (SWIG_D_VERSION == 1)
|
||||
%pragma(d) imdmoduleimports = "static import tango.stdc.stringz;";
|
||||
|
||||
%pragma(d) imdmodulecode = %{
|
||||
private class SwigStringHelper {
|
||||
static this() {
|
||||
swigRegisterStringCallback$module(&createString);
|
||||
}
|
||||
|
||||
static char* createString(char* cString) {
|
||||
// We are effectively dup'ing the string here.
|
||||
return tango.stdc.stringz.toStringz(tango.stdc.stringz.fromStringz(cString));
|
||||
}
|
||||
}
|
||||
alias char* function(char* cString) SwigStringCallback;
|
||||
%}
|
||||
#else
|
||||
%pragma(d) imdmoduleimports = %{
|
||||
static import std.conv;
|
||||
static import std.string;
|
||||
%}
|
||||
|
||||
%pragma(d) imdmodulecode = %{
|
||||
private class SwigStringHelper {
|
||||
static this() {
|
||||
swigRegisterStringCallback$module(&createString);
|
||||
}
|
||||
|
||||
static const(char)* createString(const(char*) cString) {
|
||||
// We are effectively dup'ing the string here.
|
||||
// TODO: Is this also correct for D2/Phobos?
|
||||
return std.string.toStringz(std.conv.to!string(cString));
|
||||
}
|
||||
}
|
||||
alias const(char)* function(const(char*) cString) SwigStringCallback;
|
||||
%}
|
||||
#endif
|
||||
// Callback registering function in wrapperloader.swg.
|
||||
#endif // SWIG_D_NO_STRING_HELPER
|
||||
|
||||
|
||||
/*
|
||||
* Function pointer support code.
|
||||
*/
|
||||
#if (SWIG_D_VERSION == 1)
|
||||
%pragma(d) imdmodulecode = %{
|
||||
template SwigExternC(T) {
|
||||
static if (is(typeof(*(T.init)) R == return)) {
|
||||
static if (is(typeof(*(T.init)) P == function)) {
|
||||
alias extern(C) R function(P) SwigExternC;
|
||||
}
|
||||
}
|
||||
}
|
||||
%}
|
||||
#else
|
||||
%pragma(d) imdmodulecode = %{
|
||||
template SwigExternC(T) if (is(typeof(*(T.init)) P == function)) {
|
||||
static if (is(typeof(*(T.init)) R == return)) {
|
||||
static if (is(typeof(*(T.init)) P == function)) {
|
||||
alias extern(C) R function(P) SwigExternC;
|
||||
}
|
||||
}
|
||||
}
|
||||
%}
|
||||
#endif
|
||||
|
|
@ -1,49 +0,0 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* director.swg
|
||||
*
|
||||
* This file contains support for director classes so that D proxy
|
||||
* methods can be called from C++.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
#if defined(DEBUG_DIRECTOR_OWNED)
|
||||
#include <iostream>
|
||||
#endif
|
||||
#include <string>
|
||||
#include <exception>
|
||||
|
||||
namespace Swig {
|
||||
|
||||
// Director base class – not used in D directors.
|
||||
class Director {
|
||||
};
|
||||
|
||||
// Base class for director exceptions.
|
||||
class DirectorException : public std::exception {
|
||||
protected:
|
||||
std::string swig_msg;
|
||||
|
||||
public:
|
||||
DirectorException(const std::string &msg) : swig_msg(msg) {
|
||||
}
|
||||
|
||||
virtual ~DirectorException() throw() {
|
||||
}
|
||||
|
||||
const char *what() const throw() {
|
||||
return swig_msg.c_str();
|
||||
}
|
||||
};
|
||||
|
||||
// Exception which is thrown when attempting to call a pure virtual method
|
||||
// from D code through the director layer.
|
||||
class DirectorPureVirtualException : public DirectorException {
|
||||
public:
|
||||
DirectorPureVirtualException(const char *msg) : DirectorException(std::string("Attempted to invoke pure virtual method ") + msg) {
|
||||
}
|
||||
|
||||
static void raise(const char *msg) {
|
||||
throw DirectorPureVirtualException(msg);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -1,128 +0,0 @@
|
|||
#ifndef D_DKW_SWG_
|
||||
#define D_DKW_SWG_
|
||||
|
||||
/* Warnings for D keywords */
|
||||
#define DKEYWORD(x) %keywordwarn("'" `x` "' is a D keyword",rename="_%s") `x`
|
||||
|
||||
// Source: http://www.digitalmars.com/d/{1.0,2.0}/lex.html and
|
||||
DKEYWORD(Error);
|
||||
DKEYWORD(Exception);
|
||||
DKEYWORD(Object);
|
||||
DKEYWORD(__FILE__);
|
||||
DKEYWORD(__LINE__);
|
||||
DKEYWORD(__gshared);
|
||||
DKEYWORD(__thread);
|
||||
DKEYWORD(__traits);
|
||||
DKEYWORD(abstract);
|
||||
DKEYWORD(alias);
|
||||
DKEYWORD(align);
|
||||
DKEYWORD(asm);
|
||||
DKEYWORD(assert);
|
||||
DKEYWORD(auto);
|
||||
DKEYWORD(body);
|
||||
DKEYWORD(bool);
|
||||
DKEYWORD(break);
|
||||
DKEYWORD(byte);
|
||||
DKEYWORD(case);
|
||||
DKEYWORD(cast);
|
||||
DKEYWORD(catch);
|
||||
DKEYWORD(cdouble);
|
||||
DKEYWORD(cent);
|
||||
DKEYWORD(cfloat);
|
||||
DKEYWORD(char);
|
||||
DKEYWORD(class);
|
||||
DKEYWORD(const);
|
||||
DKEYWORD(continue);
|
||||
DKEYWORD(creal);
|
||||
DKEYWORD(dchar);
|
||||
DKEYWORD(debug);
|
||||
DKEYWORD(default);
|
||||
DKEYWORD(delegate);
|
||||
DKEYWORD(delete);
|
||||
DKEYWORD(deprecated);
|
||||
DKEYWORD(do);
|
||||
DKEYWORD(double);
|
||||
DKEYWORD(dstring);
|
||||
DKEYWORD(else);
|
||||
DKEYWORD(enum);
|
||||
DKEYWORD(export);
|
||||
DKEYWORD(extern);
|
||||
DKEYWORD(false);
|
||||
DKEYWORD(final);
|
||||
DKEYWORD(finally);
|
||||
DKEYWORD(float);
|
||||
DKEYWORD(for);
|
||||
DKEYWORD(foreach);
|
||||
DKEYWORD(foreach_reverse);
|
||||
DKEYWORD(function);
|
||||
DKEYWORD(goto);
|
||||
DKEYWORD(idouble);
|
||||
DKEYWORD(if);
|
||||
DKEYWORD(ifloat);
|
||||
DKEYWORD(immutable);
|
||||
DKEYWORD(import);
|
||||
DKEYWORD(in);
|
||||
DKEYWORD(inout);
|
||||
DKEYWORD(int);
|
||||
DKEYWORD(interface);
|
||||
DKEYWORD(invariant);
|
||||
DKEYWORD(ireal);
|
||||
DKEYWORD(is);
|
||||
DKEYWORD(lazy);
|
||||
DKEYWORD(long);
|
||||
DKEYWORD(macro);
|
||||
DKEYWORD(mixin);
|
||||
DKEYWORD(module);
|
||||
DKEYWORD(new);
|
||||
DKEYWORD(nothrow);
|
||||
DKEYWORD(null);
|
||||
DKEYWORD(out);
|
||||
DKEYWORD(override);
|
||||
DKEYWORD(package);
|
||||
DKEYWORD(pragma);
|
||||
DKEYWORD(private);
|
||||
DKEYWORD(protected);
|
||||
DKEYWORD(public);
|
||||
DKEYWORD(pure);
|
||||
DKEYWORD(real);
|
||||
DKEYWORD(ref);
|
||||
DKEYWORD(return);
|
||||
DKEYWORD(scope);
|
||||
DKEYWORD(shared);
|
||||
DKEYWORD(short);
|
||||
DKEYWORD(static);
|
||||
DKEYWORD(string);
|
||||
DKEYWORD(struct);
|
||||
DKEYWORD(super);
|
||||
DKEYWORD(switch);
|
||||
DKEYWORD(synchronized);
|
||||
DKEYWORD(template);
|
||||
DKEYWORD(this);
|
||||
DKEYWORD(throw);
|
||||
DKEYWORD(true);
|
||||
DKEYWORD(try);
|
||||
DKEYWORD(typedef);
|
||||
DKEYWORD(typeid);
|
||||
DKEYWORD(typeof);
|
||||
DKEYWORD(ubyte);
|
||||
DKEYWORD(ucent);
|
||||
DKEYWORD(uint);
|
||||
DKEYWORD(ulong);
|
||||
DKEYWORD(union);
|
||||
DKEYWORD(unittest);
|
||||
DKEYWORD(ushort);
|
||||
DKEYWORD(version);
|
||||
DKEYWORD(void);
|
||||
DKEYWORD(volatile);
|
||||
DKEYWORD(wchar);
|
||||
DKEYWORD(while);
|
||||
DKEYWORD(with);
|
||||
DKEYWORD(wstring);
|
||||
|
||||
// Not really a keyword, but dispose() methods are generated in proxy classes
|
||||
// and it's a special method name for D1/Tango.
|
||||
DKEYWORD(dispose);
|
||||
|
||||
#undef DKEYWORD
|
||||
|
||||
#endif //D_DKW_SWG_
|
||||
|
|
@ -1,94 +0,0 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* dmemberfunctionpointers.swg
|
||||
*
|
||||
* Typemaps for member function pointers.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
|
||||
%typemap(ctype) SWIGTYPE (CLASS::*) "char *"
|
||||
%typemap(imtype) SWIGTYPE (CLASS::*) "char*"
|
||||
%typemap(dtype) SWIGTYPE (CLASS::*) "$dclassname"
|
||||
|
||||
%typecheck(SWIG_TYPECHECK_POINTER)
|
||||
SWIGTYPE (CLASS::*)
|
||||
""
|
||||
|
||||
|
||||
/*
|
||||
* Conversion generation typemaps.
|
||||
*/
|
||||
|
||||
%typemap(in, fragment="SWIG_UnPackData") SWIGTYPE (CLASS::*) %{
|
||||
SWIG_UnpackData($input, (void *)&$1, sizeof($1));
|
||||
%}
|
||||
%typemap(out, fragment="SWIG_PackData") SWIGTYPE (CLASS::*) %{
|
||||
char buf[128];
|
||||
char *data = SWIG_PackData(buf, (void *)&$1, sizeof($1));
|
||||
*data = '\0';
|
||||
$result = SWIG_d_string_callback(buf);
|
||||
%}
|
||||
|
||||
%typemap(directorin) SWIGTYPE (CLASS::*) "$input = (void *) $1;"
|
||||
%typemap(directorout, warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) SWIGTYPE (CLASS::*)
|
||||
"$result = ($1_ltype)$input;"
|
||||
|
||||
%typemap(ddirectorin) SWIGTYPE (CLASS::*)
|
||||
"($winput is null) ? null : new $dclassname($winput, false)"
|
||||
%typemap(ddirectorout) SWIGTYPE (CLASS::*) "$dclassname.swigGetCPtr($dcall)"
|
||||
|
||||
%typemap(din) SWIGTYPE (CLASS::*) "$dclassname.swigGetCMemberPtr($dinput)"
|
||||
%typemap(dout, excode=SWIGEXCODE) SWIGTYPE (CLASS::*) {
|
||||
char* cMemberPtr = $imcall;
|
||||
$dclassname ret = (cMemberPtr is null) ? null : new $dclassname(cMemberPtr, $owner);$excode
|
||||
return ret;
|
||||
}
|
||||
|
||||
%apply SWIGTYPE (CLASS::*) { SWIGTYPE (CLASS::*const) }
|
||||
%apply SWIGTYPE & { SWIGTYPE (CLASS::*const&) }
|
||||
|
||||
/*
|
||||
* Helper functions to pack/unpack arbitrary binary data (member function
|
||||
* pointers in this case) into a string.
|
||||
*/
|
||||
|
||||
%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";
|
||||
const unsigned char *u = (unsigned char *) ptr;
|
||||
const unsigned char *eu = u + sz;
|
||||
for (; u != eu; ++u) {
|
||||
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) {
|
||||
unsigned char *u = (unsigned char *) ptr;
|
||||
const unsigned char *eu = u + sz;
|
||||
for (; u != eu; ++u) {
|
||||
char d = *(c++);
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,259 +0,0 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* doperators.swg
|
||||
*
|
||||
* Mapping of C++ operator overloading methods to D.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
#if (SWIG_D_VERSION == 1)
|
||||
|
||||
%pragma(d) imdmodulecode=%{
|
||||
template SwigOperatorDefinitions() {
|
||||
public override int opEquals(Object o) {
|
||||
if (auto rhs = cast(typeof(this))o) {
|
||||
if (swigCPtr == rhs.swigCPtr) return 1;
|
||||
static if (is(typeof(swigOpEquals(rhs)))) {
|
||||
return swigOpEquals(rhs) ? 1 : 0;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return super.opEquals(o);
|
||||
}
|
||||
%}
|
||||
// opEquals is emitted in pure C mode as well to define two proxy classes
|
||||
// pointing to the same struct as equal.
|
||||
|
||||
#ifdef __cplusplus
|
||||
%rename(opPos) *::operator+();
|
||||
%rename(opPos) *::operator+() const;
|
||||
%rename(opNeg) *::operator-();
|
||||
%rename(opNeg) *::operator-() const;
|
||||
%rename(opCom) *::operator~();
|
||||
%rename(opCom) *::operator~() const;
|
||||
|
||||
%rename(opAdd) *::operator+;
|
||||
%rename(opAddAssign) *::operator+=;
|
||||
%rename(opSub) *::operator-;
|
||||
%rename(opSubAssign) *::operator-=;
|
||||
%rename(opMul) *::operator*;
|
||||
%rename(opMulAssign) *::operator*=;
|
||||
%rename(opDiv) *::operator/;
|
||||
%rename(opDivAssign) *::operator/=;
|
||||
%rename(opMod) *::operator%;
|
||||
%rename(opModAssign) *::operator%=;
|
||||
%rename(opAnd) *::operator&;
|
||||
%rename(opAndAssign) *::operator&=;
|
||||
%rename(opOr) *::operator|;
|
||||
%rename(opOrAssign) *::operator|=;
|
||||
%rename(opXor) *::operator^;
|
||||
%rename(opXorAssign) *::operator^=;
|
||||
%rename(opShl) *::operator<<;
|
||||
%rename(opShlAssign) *::operator<<=;
|
||||
%rename(opShr) *::operator>>;
|
||||
%rename(opShrAssign) *::operator>>=;
|
||||
|
||||
%rename(opIndex) *::operator[](unsigned) const;
|
||||
// opIndexAssign is not currently generated, it needs more extensive support
|
||||
// mechanisms.
|
||||
|
||||
%rename(opCall) *::operator();
|
||||
|
||||
// !a is not overridable in D1.
|
||||
%ignoreoperator(LNOT) operator!;
|
||||
|
||||
// opCmp is used in D.
|
||||
%rename(swigOpEquals) *::operator==;
|
||||
%rename(swigOpLt) *::operator<;
|
||||
%rename(swigOpLtEquals) *::operator<=;
|
||||
%rename(swigOpGt) *::operator>;
|
||||
%rename(swigOpGtEquals) *::operator>=;
|
||||
|
||||
// a != b is rewritten as !a.opEquals(b) in D.
|
||||
%ignoreoperator(NOTEQUAL) operator!=;
|
||||
|
||||
// The logic operators are not overridable in D.
|
||||
%ignoreoperator(LAND) operator&&;
|
||||
%ignoreoperator(LOR) operator||;
|
||||
|
||||
// ++/--a is rewritten as a +/-= 1 in D1,so ignore the prefix operators.
|
||||
%ignoreoperator(PLUSPLUS) *::operator++();
|
||||
%ignoreoperator(MINUSMINUS) *::operator--();
|
||||
%rename(swigOpInc) *::operator++(int);
|
||||
%rename(swigOpDec) *::operator--(int);
|
||||
|
||||
// The C++ assignment operator does not translate well to D where the proxy
|
||||
// classes have reference semantics.
|
||||
%ignoreoperator(EQ) operator=;
|
||||
|
||||
%pragma(d) imdmodulecode=%{
|
||||
public override int opCmp(Object o) {
|
||||
static if (is(typeof(swigOpLt(typeof(this).init) &&
|
||||
swigOpEquals(typeof(this).init)))) {
|
||||
if (auto rhs = cast(typeof(this))o) {
|
||||
if (swigOpLt(rhs)) {
|
||||
return -1;
|
||||
} else if (swigOpEquals(rhs)) {
|
||||
return 0;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return super.opCmp(o);
|
||||
}
|
||||
|
||||
public typeof(this) opPostInc(T = int)(T unused = 0) {
|
||||
static assert(
|
||||
is(typeof(swigOpInc(int.init))),
|
||||
"opPostInc called on " ~ typeof(this).stringof ~ ", but no postfix " ~
|
||||
"increment operator exists in the corresponding C++ class."
|
||||
);
|
||||
return swigOpInc(int.init);
|
||||
}
|
||||
|
||||
public typeof(this) opPostDec(T = int)(T unused = 0) {
|
||||
static assert(
|
||||
is(typeof(swigOpDec(int.init))),
|
||||
"opPostInc called on " ~ typeof(this).stringof ~ ", but no postfix " ~
|
||||
"decrement operator exists in the corresponding C++ class."
|
||||
);
|
||||
return swigOpDec(int.init);
|
||||
}
|
||||
%}
|
||||
#endif
|
||||
|
||||
%pragma(d) imdmodulecode=%{
|
||||
}
|
||||
%}
|
||||
|
||||
#else
|
||||
%pragma(d) imdmodulecode=%{
|
||||
mixin template SwigOperatorDefinitions() {
|
||||
public override bool opEquals(Object o) {
|
||||
if (auto rhs = cast(typeof(this))o) {
|
||||
if (swigCPtr == rhs.swigCPtr) return true;
|
||||
static if (is(typeof(swigOpEquals(rhs)))) {
|
||||
return swigOpEquals(rhs);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return super.opEquals(o);
|
||||
}
|
||||
%}
|
||||
// opEquals is emitted in pure C mode as well to define two proxy classes
|
||||
// pointing to the same struct as equal.
|
||||
|
||||
#ifdef __cplusplus
|
||||
%rename(swigOpPos) *::operator+();
|
||||
%rename(swigOpPos) *::operator+() const;
|
||||
%rename(swigOpNeg) *::operator-();
|
||||
%rename(swigOpNeg) *::operator-() const;
|
||||
%rename(swigOpCom) *::operator~();
|
||||
%rename(swigOpCom) *::operator~() const;
|
||||
%rename(swigOpInc) *::operator++();
|
||||
%rename(swigOpDec) *::operator--();
|
||||
%ignoreoperator(PLUSPLUS) *::operator++(int);
|
||||
%ignoreoperator(MINUSMINUS) *::operator--(int);
|
||||
// The postfix increment/decrement operators are ignored because they are
|
||||
// rewritten to (auto t = e, ++e, t) in D2. The unary * operator (used for
|
||||
// pointer dereferencing in C/C++) isn't mapped to opUnary("*") by default,
|
||||
// despite this would be possible in D2 – the difference in member access
|
||||
// semantics would only lead to confusion in most cases.
|
||||
|
||||
%rename(swigOpAdd) *::operator+;
|
||||
%rename(swigOpSub) *::operator-;
|
||||
%rename(swigOpMul) *::operator*;
|
||||
%rename(swigOpDiv) *::operator/;
|
||||
%rename(swigOpMod) *::operator%;
|
||||
%rename(swigOpAnd) *::operator&;
|
||||
%rename(swigOpOr) *::operator|;
|
||||
%rename(swigOpXor) *::operator^;
|
||||
%rename(swigOpShl) *::operator<<;
|
||||
%rename(swigOpShr) *::operator>>;
|
||||
|
||||
%rename(swigOpAddAssign) *::operator+=;
|
||||
%rename(swigOpSubAssign) *::operator-=;
|
||||
%rename(swigOpMulAssign) *::operator*=;
|
||||
%rename(swigOpDivAssign) *::operator/=;
|
||||
%rename(swigOpModAssign) *::operator%=;
|
||||
%rename(swigOpAndAssign) *::operator&=;
|
||||
%rename(swigOpOrAssign) *::operator|=;
|
||||
%rename(swigOpXorAssign) *::operator^=;
|
||||
%rename(swigOpShlAssign) *::operator<<=;
|
||||
%rename(swigOpShrAssign) *::operator>>=;
|
||||
|
||||
%rename(opIndex) *::operator[];
|
||||
// opIndexAssign is not currently generated, it needs more extensive support
|
||||
// mechanisms.
|
||||
|
||||
%rename(opCall) *::operator();
|
||||
|
||||
%rename(swigOpEquals) *::operator==;
|
||||
%rename(swigOpLt) *::operator<;
|
||||
%rename(swigOpLtEquals) *::operator<=;
|
||||
%rename(swigOpGt) *::operator>;
|
||||
%rename(swigOpGtEquals) *::operator>=;
|
||||
|
||||
// a != b is rewritten as !a.opEquals(b) in D.
|
||||
%ignoreoperator(NOTEQUAL) operator!=;
|
||||
|
||||
// The logic operators are not overridable in D.
|
||||
%ignoreoperator(LAND) operator&&;
|
||||
%ignoreoperator(LOR) operator||;
|
||||
|
||||
// The C++ assignment operator does not translate well to D where the proxy
|
||||
// classes have reference semantics.
|
||||
%ignoreoperator(EQ) operator=;
|
||||
|
||||
%pragma(d) imdmodulecode=%{
|
||||
public override int opCmp(Object o) {
|
||||
static if (__traits(compiles, swigOpLt(typeof(this).init) &&
|
||||
swigOpEquals(typeof(this).init))) {
|
||||
if (auto rhs = cast(typeof(this))o) {
|
||||
if (swigOpLt(rhs)) {
|
||||
return -1;
|
||||
} else if (swigOpEquals(rhs)) {
|
||||
return 0;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return super.opCmp(o);
|
||||
}
|
||||
|
||||
private template swigOpBinary(string operator, string name) {
|
||||
enum swigOpBinary = `public void opOpAssign(string op, T)(T rhs) if (op == "` ~ operator ~
|
||||
`" && __traits(compiles, swigOp` ~ name ~ `Assign(rhs))) { swigOp` ~ name ~ `Assign(rhs);}` ~
|
||||
`public auto opBinary(string op, T)(T rhs) if (op == "` ~ operator ~
|
||||
`" && __traits(compiles, swigOp` ~ name ~ `(rhs))) { return swigOp` ~ name ~ `(rhs);}`;
|
||||
}
|
||||
mixin(swigOpBinary!("+", "Add"));
|
||||
mixin(swigOpBinary!("-", "Sub"));
|
||||
mixin(swigOpBinary!("*", "Mul"));
|
||||
mixin(swigOpBinary!("/", "Div"));
|
||||
mixin(swigOpBinary!("%", "Mod"));
|
||||
mixin(swigOpBinary!("&", "And"));
|
||||
mixin(swigOpBinary!("|", "Or"));
|
||||
mixin(swigOpBinary!("^", "Xor"));
|
||||
mixin(swigOpBinary!("<<", "Shl"));
|
||||
mixin(swigOpBinary!(">>", "Shr"));
|
||||
|
||||
private template swigOpUnary(string operator, string name) {
|
||||
enum swigOpUnary = `public auto opUnary(string op)() if (op == "` ~ operator ~
|
||||
`" && __traits(compiles, swigOp` ~ name ~ `())) { return swigOp` ~ name ~ `();}`;
|
||||
}
|
||||
mixin(swigOpUnary!("+", "Pos"));
|
||||
mixin(swigOpUnary!("-", "Neg"));
|
||||
mixin(swigOpUnary!("~", "Com"));
|
||||
mixin(swigOpUnary!("++", "Inc"));
|
||||
mixin(swigOpUnary!("--", "Dec"));
|
||||
%}
|
||||
#endif
|
||||
|
||||
%pragma(d) imdmodulecode=%{
|
||||
}
|
||||
%}
|
||||
|
||||
#endif
|
||||
|
|
@ -1,171 +0,0 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* dprimitves.swg
|
||||
*
|
||||
* Typemaps for primitive types.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
// C long/ulong width depends on the target arch, use stdlib aliases for them.
|
||||
#if (SWIG_D_VERSION == 1)
|
||||
%pragma(d) imdmoduleimports = "static import tango.stdc.config;"
|
||||
%pragma(d) globalproxyimports = "static import tango.stdc.config;"
|
||||
#define SWIG_LONG_DTYPE tango.stdc.config.c_long
|
||||
#define SWIG_ULONG_DTYPE tango.stdc.config.c_ulong
|
||||
#else
|
||||
%pragma(d) imdmoduleimports = "static import core.stdc.config;"
|
||||
%pragma(d) globalproxyimports = "static import core.stdc.config;"
|
||||
#define SWIG_LONG_DTYPE core.stdc.config.c_long
|
||||
#define SWIG_ULONG_DTYPE core.stdc.config.c_ulong
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The SWIG_D_PRIMITIVE macro is used to define the typemaps for the primitive
|
||||
* types, because are more or less the same for all of them. The few special
|
||||
* cases are handled below.
|
||||
*/
|
||||
%define SWIG_D_PRIMITIVE(TYPE, DTYPE)
|
||||
%typemap(ctype) TYPE, const TYPE & "TYPE"
|
||||
%typemap(imtype) TYPE, const TYPE & "DTYPE"
|
||||
%typemap(dtype, cprimitive="1") TYPE, const TYPE & "DTYPE"
|
||||
|
||||
%typemap(in) TYPE "$1 = ($1_ltype)$input;"
|
||||
%typemap(out) TYPE "$result = $1;"
|
||||
%typemap(directorin) TYPE "$input = $1;"
|
||||
%typemap(directorout) TYPE "$result = ($1_ltype)$input;"
|
||||
%typemap(ddirectorin) TYPE "$winput"
|
||||
%typemap(ddirectorout) TYPE "$dcall"
|
||||
|
||||
%typemap(in) const TYPE & ($*1_ltype temp)
|
||||
%{ temp = ($*1_ltype)$input;
|
||||
$1 = &temp; %}
|
||||
%typemap(out) const TYPE & "$result = *$1;"
|
||||
%typemap(directorin) const TYPE & "$input = $1;"
|
||||
%typemap(directorout,warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const TYPE &
|
||||
%{ static $*1_ltype temp;
|
||||
temp = ($*1_ltype)$input;
|
||||
$result = &temp; %}
|
||||
%typemap(ddirectorin) const TYPE & "$winput"
|
||||
%typemap(ddirectorout) const TYPE & "$dcall"
|
||||
|
||||
%typemap(din) TYPE, const TYPE & "$dinput"
|
||||
%typemap(dout, excode=SWIGEXCODE) TYPE, const TYPE & {
|
||||
auto ret = $imcall;$excode
|
||||
return ret;
|
||||
}
|
||||
%enddef
|
||||
|
||||
|
||||
SWIG_D_PRIMITIVE(bool, bool)
|
||||
SWIG_D_PRIMITIVE(char, char)
|
||||
SWIG_D_PRIMITIVE(signed char, byte)
|
||||
SWIG_D_PRIMITIVE(unsigned char, ubyte)
|
||||
SWIG_D_PRIMITIVE(short, short)
|
||||
SWIG_D_PRIMITIVE(unsigned short, ushort)
|
||||
SWIG_D_PRIMITIVE(int, int)
|
||||
SWIG_D_PRIMITIVE(unsigned int, uint)
|
||||
SWIG_D_PRIMITIVE(long, SWIG_LONG_DTYPE)
|
||||
SWIG_D_PRIMITIVE(unsigned long, SWIG_ULONG_DTYPE)
|
||||
SWIG_D_PRIMITIVE(size_t, size_t)
|
||||
SWIG_D_PRIMITIVE(long long, long)
|
||||
SWIG_D_PRIMITIVE(unsigned long long, ulong)
|
||||
SWIG_D_PRIMITIVE(float, float)
|
||||
SWIG_D_PRIMITIVE(double, double)
|
||||
|
||||
|
||||
// The C++ boolean type needs some special casing since it is not part of the
|
||||
// C standard and is thus represented as unsigned int in the C wrapper layer.
|
||||
%typemap(ctype) bool, const bool & "unsigned int"
|
||||
%typemap(imtype) bool, const bool & "uint"
|
||||
|
||||
%typemap(in) bool "$1 = $input ? true : false;"
|
||||
%typemap(in) const bool & ($*1_ltype temp)
|
||||
%{ temp = $input ? true : false;
|
||||
$1 = &temp; %}
|
||||
|
||||
%typemap(directorout) bool
|
||||
"$result = $input ? true : false;"
|
||||
%typemap(directorout,warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const bool &
|
||||
%{ static $*1_ltype temp;
|
||||
temp = $input ? true : false;
|
||||
$result = &temp; %}
|
||||
|
||||
%typemap(ddirectorin) bool "($winput ? true : false)"
|
||||
|
||||
%typemap(dout, excode=SWIGEXCODE) bool, const bool & {
|
||||
bool ret = $imcall ? true : false;$excode
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
// Judging from the history of the C# module, the explicit casts are needed for
|
||||
// certain versions of VC++.
|
||||
%typemap(out) unsigned long "$result = (unsigned long)$1;"
|
||||
%typemap(out) const unsigned long & "$result = (unsigned long)*$1;"
|
||||
|
||||
|
||||
/*
|
||||
* Typecheck typemaps.
|
||||
*/
|
||||
|
||||
%typecheck(SWIG_TYPECHECK_BOOL)
|
||||
bool,
|
||||
const bool &
|
||||
""
|
||||
|
||||
%typecheck(SWIG_TYPECHECK_CHAR)
|
||||
char,
|
||||
const char &
|
||||
""
|
||||
|
||||
%typecheck(SWIG_TYPECHECK_INT8)
|
||||
signed char,
|
||||
const signed char &
|
||||
""
|
||||
|
||||
%typecheck(SWIG_TYPECHECK_UINT8)
|
||||
unsigned char,
|
||||
const unsigned char &
|
||||
""
|
||||
|
||||
%typecheck(SWIG_TYPECHECK_INT16)
|
||||
short,
|
||||
const short &
|
||||
""
|
||||
|
||||
%typecheck(SWIG_TYPECHECK_UINT16)
|
||||
unsigned short,
|
||||
const unsigned short &
|
||||
""
|
||||
|
||||
%typecheck(SWIG_TYPECHECK_INT32)
|
||||
int,
|
||||
long,
|
||||
const int &,
|
||||
const long &
|
||||
""
|
||||
|
||||
%typecheck(SWIG_TYPECHECK_UINT32)
|
||||
unsigned int,
|
||||
unsigned long,
|
||||
const unsigned int &,
|
||||
const unsigned long &
|
||||
""
|
||||
|
||||
%typecheck(SWIG_TYPECHECK_INT64)
|
||||
long long,
|
||||
const long long &
|
||||
""
|
||||
|
||||
%typecheck(SWIG_TYPECHECK_UINT64)
|
||||
unsigned long long,
|
||||
const unsigned long long &
|
||||
""
|
||||
|
||||
%typecheck(SWIG_TYPECHECK_FLOAT)
|
||||
float,
|
||||
const float &
|
||||
""
|
||||
|
||||
%typecheck(SWIG_TYPECHECK_DOUBLE)
|
||||
double,
|
||||
const double &
|
||||
""
|
||||
|
|
@ -1,80 +0,0 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* dstrings.swg
|
||||
*
|
||||
* Typemaps for wrapping pointers to/arrays of C chars as D strings.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
%define SWIGD_STRING_TYPEMAPS(DW_STRING_TYPE, DP_STRING_TYPE, FROM_STRINGZ, TO_STRINGZ)
|
||||
%typemap(ctype) char *, char *&, char[ANY], char[] "char *"
|
||||
%typemap(imtype) char *, char *&, char[ANY], char[] #DW_STRING_TYPE
|
||||
%typemap(dtype) char *, char *&, char[ANY], char[] #DP_STRING_TYPE
|
||||
|
||||
|
||||
/*
|
||||
* char* typemaps.
|
||||
*/
|
||||
|
||||
%typemap(in) char * %{ $1 = ($1_ltype)$input; %}
|
||||
%typemap(out) char * %{ $result = SWIG_d_string_callback((const char *)$1); %}
|
||||
%typemap(directorout, warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) char * %{ $result = ($1_ltype)$input; %}
|
||||
%typemap(directorin) char * %{ $input = SWIG_d_string_callback((const char *)$1); %}
|
||||
%typemap(ddirectorin) char * "FROM_STRINGZ($winput)"
|
||||
%typemap(ddirectorout) char * "TO_STRINGZ($dcall)"
|
||||
|
||||
|
||||
/*
|
||||
* char*& typemaps.
|
||||
*/
|
||||
|
||||
%typemap(in) char *& ($*1_ltype temp = 0) %{
|
||||
temp = ($*1_ltype)$input;
|
||||
$1 = &temp;
|
||||
%}
|
||||
%typemap(out) char *& %{ if ($1) $result = SWIG_d_string_callback((const char *)*$1); %}
|
||||
|
||||
|
||||
/*
|
||||
* char array typemaps.
|
||||
*/
|
||||
|
||||
%typemap(in) char[ANY], char[] %{ $1 = ($1_ltype)$input; %}
|
||||
%typemap(out) char[ANY], char[] %{ $result = SWIG_d_string_callback((const char *)$1); %}
|
||||
|
||||
%typemap(directorout) char[ANY], char[] %{ $result = ($1_ltype)$input; %}
|
||||
%typemap(directorin) char[ANY], char[] %{ $input = SWIG_d_string_callback((const char *)$1); %}
|
||||
|
||||
%typemap(ddirectorin) char[ANY], char[] "$winput"
|
||||
%typemap(ddirectorout) char[ANY], char[] "$dcall"
|
||||
|
||||
|
||||
%typemap(din) char *, char *&, char[ANY], char[] "($dinput ? TO_STRINGZ($dinput) : null)"
|
||||
%typemap(dout, excode=SWIGEXCODE) char *, char *&, char[ANY], char[] {
|
||||
DP_STRING_TYPE ret = FROM_STRINGZ ## ($imcall);$excode
|
||||
return ret;
|
||||
}
|
||||
|
||||
%typecheck(SWIG_TYPECHECK_STRING)
|
||||
char *,
|
||||
char *&,
|
||||
char[ANY],
|
||||
char[]
|
||||
""
|
||||
%enddef
|
||||
|
||||
|
||||
// We need to have the \0-terminated string conversion functions available in
|
||||
// the D proxy modules.
|
||||
#if (SWIG_D_VERSION == 1)
|
||||
// Could be easily extended to support Phobos as well.
|
||||
SWIGD_STRING_TYPEMAPS(char*, char[], tango.stdc.stringz.fromStringz, tango.stdc.stringz.toStringz)
|
||||
|
||||
%pragma(d) globalproxyimports = "static import tango.stdc.stringz;";
|
||||
#else
|
||||
SWIGD_STRING_TYPEMAPS(const(char)*, string, std.conv.to!string, std.string.toStringz)
|
||||
|
||||
%pragma(d) globalproxyimports = %{
|
||||
static import std.conv;
|
||||
static import std.string;
|
||||
%}
|
||||
#endif
|
||||
#undef SWIGD_STRING_TYPEMAPS
|
||||
|
|
@ -1,241 +0,0 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* dswigtype.swg
|
||||
*
|
||||
* Typemaps for non-primitive types (C/C++ classes and structs).
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
%typemap(ctype) SWIGTYPE "void *"
|
||||
%typemap(imtype) SWIGTYPE "void*"
|
||||
%typemap(dtype) SWIGTYPE "$&dclassname"
|
||||
|
||||
%typemap(ctype) SWIGTYPE [] "void *"
|
||||
%typemap(imtype) SWIGTYPE [] "void*"
|
||||
%typemap(dtype) SWIGTYPE [] "$dclassname"
|
||||
|
||||
%typemap(ctype) SWIGTYPE * "void *"
|
||||
%typemap(imtype) SWIGTYPE * "void*"
|
||||
%typemap(dtype, nativepointer="$dtype") SWIGTYPE * "$dclassname"
|
||||
|
||||
%typemap(ctype) SWIGTYPE & "void *"
|
||||
%typemap(imtype) SWIGTYPE & "void*"
|
||||
%typemap(dtype, nativepointer="$dtype") SWIGTYPE & "$dclassname"
|
||||
|
||||
%typemap(ctype) SWIGTYPE && "void *"
|
||||
%typemap(imtype) SWIGTYPE && "void*"
|
||||
%typemap(dtype, nativepointer="$dtype") SWIGTYPE && "$dclassname"
|
||||
|
||||
%typemap(ctype) SWIGTYPE *const& "void *"
|
||||
%typemap(imtype) SWIGTYPE *const& "void*"
|
||||
%typemap(dtype) SWIGTYPE *const& "$*dclassname"
|
||||
|
||||
%typecheck(SWIG_TYPECHECK_POINTER)
|
||||
SWIGTYPE,
|
||||
SWIGTYPE *,
|
||||
SWIGTYPE &,
|
||||
SWIGTYPE &&,
|
||||
SWIGTYPE [],
|
||||
SWIGTYPE *const&
|
||||
""
|
||||
|
||||
|
||||
/*
|
||||
* By-value conversion typemaps (parameter is converted to a pointer).
|
||||
*/
|
||||
|
||||
%typemap(in, canthrow=1) SWIGTYPE ($&1_type argp)
|
||||
%{ argp = ($&1_ltype)$input;
|
||||
if (!argp) {
|
||||
SWIG_DSetPendingException(SWIG_DIllegalArgumentException, "Attempt to dereference null $1_type");
|
||||
return $null;
|
||||
}
|
||||
$1 = *argp; %}
|
||||
|
||||
%typemap(out) SWIGTYPE
|
||||
#ifdef __cplusplus
|
||||
%{ $result = new $1_ltype($1); %}
|
||||
#else
|
||||
{
|
||||
$&1_ltype $1ptr = ($&1_ltype) malloc(sizeof($1_ltype));
|
||||
memmove($1ptr, &$1, sizeof($1_type));
|
||||
$result = $1ptr;
|
||||
}
|
||||
#endif
|
||||
|
||||
%typemap(directorin) SWIGTYPE
|
||||
"$input = (void *)new $1_ltype(SWIG_STD_MOVE($1));"
|
||||
%typemap(directorout) SWIGTYPE
|
||||
%{ if (!$input) {
|
||||
SWIG_DSetPendingException(SWIG_DIllegalArgumentException, "Unexpected null return for type $1_type");
|
||||
return $null;
|
||||
}
|
||||
$result = *($&1_ltype)$input; %}
|
||||
|
||||
%typemap(ddirectorin) SWIGTYPE "new $&dclassname($winput, true)"
|
||||
%typemap(ddirectorout) SWIGTYPE "$&dclassname.swigGetCPtr($dcall)"
|
||||
|
||||
%typemap(din) SWIGTYPE "$&dclassname.swigGetCPtr($dinput)"
|
||||
%typemap(dout, excode=SWIGEXCODE) SWIGTYPE {
|
||||
$&dclassname ret = new $&dclassname($imcall, true);$excode
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Pointer conversion typemaps.
|
||||
*/
|
||||
|
||||
%typemap(in) SWIGTYPE * "$1 = ($1_ltype)$input;"
|
||||
%typemap(out) SWIGTYPE * "$result = (void *)$1;"
|
||||
|
||||
%typemap(directorin) SWIGTYPE *
|
||||
"$input = (void *) $1;"
|
||||
%typemap(directorout, warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) SWIGTYPE *
|
||||
"$result = ($1_ltype)$input;"
|
||||
|
||||
%typemap(ddirectorin,
|
||||
nativepointer="cast($dtype)$winput"
|
||||
) SWIGTYPE * "($winput is null) ? null : new $dclassname($winput, false)"
|
||||
|
||||
%typemap(ddirectorout,
|
||||
nativepointer="cast(void*)$dcall"
|
||||
) SWIGTYPE * "$dclassname.swigGetCPtr($dcall)"
|
||||
|
||||
%typemap(din,
|
||||
nativepointer="cast(void*)$dinput"
|
||||
) SWIGTYPE * "$dclassname.swigGetCPtr($dinput)"
|
||||
|
||||
%typemap(dout, excode=SWIGEXCODE,
|
||||
nativepointer="{\n auto ret = cast($dtype)$imcall;$excode\n return ret;\n}"
|
||||
) SWIGTYPE * {
|
||||
void* cPtr = $imcall;
|
||||
$dclassname ret = (cPtr is null) ? null : new $dclassname(cPtr, $owner);$excode
|
||||
return ret;
|
||||
}
|
||||
|
||||
// Use the same typemaps for const pointers.
|
||||
%apply SWIGTYPE * { SWIGTYPE *const }
|
||||
|
||||
|
||||
/*
|
||||
* Reference conversion typemaps.
|
||||
*/
|
||||
|
||||
%typemap(in, canthrow=1) SWIGTYPE & %{ $1 = ($1_ltype)$input;
|
||||
if (!$1) {
|
||||
SWIG_DSetPendingException(SWIG_DIllegalArgumentException, "$1_type is null");
|
||||
return $null;
|
||||
} %}
|
||||
%typemap(out) SWIGTYPE & "$result = (void *)$1;"
|
||||
|
||||
%typemap(directorin) SWIGTYPE &
|
||||
"$input = ($1_ltype) &$1;"
|
||||
%typemap(directorout, warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) SWIGTYPE &
|
||||
%{ if (!$input) {
|
||||
SWIG_DSetPendingException(SWIG_DIllegalArgumentException, "Unexpected null return for type $1_type");
|
||||
return $null;
|
||||
}
|
||||
$result = ($1_ltype)$input; %}
|
||||
|
||||
%typemap(ddirectorin,
|
||||
nativepointer="cast($dtype)$winput"
|
||||
) SWIGTYPE & "new $dclassname($winput, false)"
|
||||
%typemap(ddirectorout,
|
||||
nativepointer="cast(void*)$dcall"
|
||||
) SWIGTYPE & "$dclassname.swigGetCPtr($dcall)"
|
||||
|
||||
%typemap(din,
|
||||
nativepointer="cast(void*)$dinput"
|
||||
) SWIGTYPE & "$dclassname.swigGetCPtr($dinput)"
|
||||
%typemap(dout, excode=SWIGEXCODE,
|
||||
nativepointer="{\n auto ret = cast($dtype)$imcall;$excode\n return ret;\n}") SWIGTYPE & {
|
||||
$dclassname ret = new $dclassname($imcall, $owner);$excode
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Rvalue reference conversion typemaps.
|
||||
*/
|
||||
|
||||
%typemap(in, canthrow=1, fragment="<memory>") SWIGTYPE && (std::unique_ptr<$*1_ltype> rvrdeleter) %{ $1 = ($1_ltype)$input;
|
||||
if (!$1) {
|
||||
SWIG_DSetPendingException(SWIG_DIllegalArgumentException, "$1_type is null");
|
||||
return $null;
|
||||
}
|
||||
rvrdeleter.reset($1); %}
|
||||
%typemap(out) SWIGTYPE && "$result = (void *)$1;"
|
||||
|
||||
%typemap(directorin) SWIGTYPE &&
|
||||
"$input = ($1_ltype) &$1;"
|
||||
%typemap(directorout, warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) SWIGTYPE &&
|
||||
%{ if (!$input) {
|
||||
SWIG_DSetPendingException(SWIG_DIllegalArgumentException, "Unexpected null return for type $1_type");
|
||||
return $null;
|
||||
}
|
||||
$result = ($1_ltype)$input; %}
|
||||
|
||||
%typemap(ddirectorin,
|
||||
nativepointer="cast($dtype)$winput"
|
||||
) SWIGTYPE && "new $dclassname($winput, false)"
|
||||
%typemap(ddirectorout,
|
||||
nativepointer="cast(void*)$dcall"
|
||||
) SWIGTYPE && "$dclassname.swigGetCPtr($dcall)"
|
||||
|
||||
%typemap(din,
|
||||
nativepointer="cast(void*)$dinput"
|
||||
) SWIGTYPE && "$dclassname.swigRelease($dinput)"
|
||||
%typemap(dout, excode=SWIGEXCODE,
|
||||
nativepointer="{\n auto ret = cast($dtype)$imcall;$excode\n return ret;\n}") SWIGTYPE && {
|
||||
$dclassname ret = new $dclassname($imcall, $owner);$excode
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Array conversion typemaps.
|
||||
*/
|
||||
|
||||
%typemap(in) SWIGTYPE [] %{ $1 = ($1_ltype)$input; %}
|
||||
%typemap(out) SWIGTYPE [] %{ $result = $1; %}
|
||||
|
||||
%typemap(din) SWIGTYPE [] "$dclassname.swigGetCPtr($dinput)"
|
||||
%typemap(dout, excode=SWIGEXCODE) SWIGTYPE [] {
|
||||
void* cPtr = $imcall;
|
||||
$dclassname ret = (cPtr is null) ? null : new $dclassname(cPtr, $owner);$excode
|
||||
return ret;
|
||||
}
|
||||
|
||||
// Treat references to arrays like references to a single element.
|
||||
%apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) }
|
||||
%apply SWIGTYPE && { SWIGTYPE ((&&)[ANY]) }
|
||||
|
||||
|
||||
/*
|
||||
* Pointer reference conversion typemaps.
|
||||
*/
|
||||
|
||||
%typemap(in) SWIGTYPE *const& ($*1_ltype temp = 0)
|
||||
%{ temp = ($*1_ltype)$input;
|
||||
$1 = ($1_ltype)&temp; %}
|
||||
%typemap(out) SWIGTYPE *const&
|
||||
%{ $result = (void *)*$1; %}
|
||||
|
||||
%typemap(din) SWIGTYPE *const& "$*dclassname.swigGetCPtr($dinput)"
|
||||
%typemap(dout, excode=SWIGEXCODE) SWIGTYPE *const& {
|
||||
void* cPtr = $imcall;
|
||||
$*dclassname ret = (cPtr is null) ? null : new $*dclassname(cPtr, $owner);$excode
|
||||
return ret;
|
||||
}
|
||||
%typemap(directorin) SWIGTYPE *const&
|
||||
"$input = (void *) $1;"
|
||||
%typemap(directorout, warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) SWIGTYPE *const&
|
||||
%{ static $*1_ltype swig_temp;
|
||||
swig_temp = ($*1_ltype)$input;
|
||||
$result = &swig_temp; %}
|
||||
%typemap(ddirectorin,
|
||||
nativepointer="cast($dtype)$winput"
|
||||
) SWIGTYPE *const& "($winput is null) ? null : new $*dclassname($winput, false)"
|
||||
%typemap(ddirectorout,
|
||||
nativepointer="cast(void*)$dcall"
|
||||
) SWIGTYPE *const& "$*dclassname.swigGetCPtr($dcall)"
|
||||
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* dvoid.swg
|
||||
*
|
||||
* Typemaps for handling void function return types and empty parameter lists.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
%typemap(ctype) void "void"
|
||||
%typemap(imtype) void "void"
|
||||
%typemap(dtype, cprimitive="1") void "void"
|
||||
|
||||
%typemap(out, null="") void ""
|
||||
%typemap(ddirectorin) void "$winput"
|
||||
%typemap(ddirectorout) void "$dcall"
|
||||
%typemap(directorin) void ""
|
||||
|
||||
%typemap(dout, excode=SWIGEXCODE) void {
|
||||
$imcall;$excode
|
||||
}
|
||||
|
|
@ -1,42 +0,0 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* std_auto_ptr.i
|
||||
*
|
||||
* SWIG library file for handling std::auto_ptr.
|
||||
* Memory ownership is passed from the std::auto_ptr C++ layer to the proxy
|
||||
* class when returning a std::auto_ptr from a function.
|
||||
* Memory ownership is passed from the proxy class to the std::auto_ptr in the
|
||||
* C++ layer when passed as a parameter to a wrapped function.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
%define %auto_ptr(TYPE)
|
||||
%typemap (ctype) std::auto_ptr< TYPE > "void *"
|
||||
%typemap (imtype) std::auto_ptr< TYPE > "void*"
|
||||
%typemap (dtype) std::auto_ptr< TYPE > "$typemap(dtype, TYPE)"
|
||||
|
||||
%typemap(in) std::auto_ptr< TYPE >
|
||||
%{ $1.reset((TYPE *)$input); %}
|
||||
|
||||
%typemap(din,
|
||||
nativepointer="cast(void*)$dinput"
|
||||
) std::auto_ptr< TYPE > "$typemap(dtype, TYPE).swigRelease($dinput)"
|
||||
|
||||
%typemap (out) std::auto_ptr< TYPE > %{
|
||||
$result = (void *)$1.release();
|
||||
%}
|
||||
|
||||
%typemap(dout, excode=SWIGEXCODE,
|
||||
nativepointer="{\n auto ret = cast($dtype)$imcall;$excode\n return ret;\n}"
|
||||
) std::auto_ptr< TYPE > {
|
||||
void* cPtr = $imcall;
|
||||
$typemap(dtype, TYPE) ret = (cPtr is null) ? null : new $typemap(dtype, TYPE)(cPtr, true);$excode
|
||||
return ret;
|
||||
}
|
||||
|
||||
%typemap(typecheck, precedence=SWIG_TYPECHECK_POINTER, equivalent="TYPE *") std::auto_ptr< TYPE > ""
|
||||
|
||||
%template() std::auto_ptr< TYPE >;
|
||||
%enddef
|
||||
|
||||
namespace std {
|
||||
template <class T> class auto_ptr {};
|
||||
}
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
%include <std_except.i>
|
||||
|
||||
%apply size_t { std::size_t };
|
||||
%apply const size_t& { const std::size_t& };
|
||||
|
||||
|
|
@ -1 +0,0 @@
|
|||
%include <std/_std_deque.i>
|
||||
|
|
@ -1,32 +0,0 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* 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 <typeinfo>
|
||||
#include <stdexcept>
|
||||
%}
|
||||
|
||||
namespace std
|
||||
{
|
||||
%ignore exception;
|
||||
struct exception {};
|
||||
}
|
||||
|
||||
%typemap(throws, canthrow=1) std::bad_cast "SWIG_DSetPendingException(SWIG_DException, $1.what());\n return $null;"
|
||||
%typemap(throws, canthrow=1) std::bad_exception "SWIG_DSetPendingException(SWIG_DException, $1.what());\n return $null;"
|
||||
%typemap(throws, canthrow=1) std::domain_error "SWIG_DSetPendingException(SWIG_DException, $1.what());\n return $null;"
|
||||
%typemap(throws, canthrow=1) std::exception "SWIG_DSetPendingException(SWIG_DException, $1.what());\n return $null;"
|
||||
%typemap(throws, canthrow=1) std::invalid_argument "SWIG_DSetPendingException(SWIG_DIllegalArgumentException, $1.what());\n return $null;"
|
||||
%typemap(throws, canthrow=1) std::length_error "SWIG_DSetPendingException(SWIG_DNoSuchElementException, $1.what());\n return $null;"
|
||||
%typemap(throws, canthrow=1) std::logic_error "SWIG_DSetPendingException(SWIG_DException, $1.what());\n return $null;"
|
||||
%typemap(throws, canthrow=1) std::out_of_range "SWIG_DSetPendingException(SWIG_DNoSuchElementException, $1.what());\n return $null;"
|
||||
%typemap(throws, canthrow=1) std::overflow_error "SWIG_DSetPendingException(SWIG_DException, $1.what());\n return $null;"
|
||||
%typemap(throws, canthrow=1) std::range_error "SWIG_DSetPendingException(SWIG_DException, $1.what());\n return $null;"
|
||||
%typemap(throws, canthrow=1) std::runtime_error "SWIG_DSetPendingException(SWIG_DException, $1.what());\n return $null;"
|
||||
%typemap(throws, canthrow=1) std::underflow_error "SWIG_DSetPendingException(SWIG_DException, $1.what());\n return $null;"
|
||||
|
||||
|
|
@ -1,62 +0,0 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* std_map.i
|
||||
*
|
||||
* SWIG typemaps for std::map
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
%include <std_common.i>
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// std::map
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
%{
|
||||
#include <map>
|
||||
#include <algorithm>
|
||||
#include <stdexcept>
|
||||
%}
|
||||
|
||||
namespace std {
|
||||
template<class K, class T, class C = std::less<K> > class map {
|
||||
public:
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef K key_type;
|
||||
typedef T mapped_type;
|
||||
typedef std::pair< const K, T > value_type;
|
||||
typedef value_type* pointer;
|
||||
typedef const value_type* const_pointer;
|
||||
typedef value_type& reference;
|
||||
typedef const value_type& const_reference;
|
||||
|
||||
map();
|
||||
map(const map& other);
|
||||
|
||||
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, C >::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, C >::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, C >::iterator i = self->find(key);
|
||||
return i != self->end();
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
@ -1,36 +0,0 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* 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 {
|
||||
typedef T first_type;
|
||||
typedef U second_type;
|
||||
|
||||
pair();
|
||||
pair(T first, U second);
|
||||
pair(const pair& other);
|
||||
|
||||
template <class U1, class U2> pair(const pair<U1, U2> &other);
|
||||
|
||||
T first;
|
||||
U second;
|
||||
};
|
||||
|
||||
// add specializations here
|
||||
|
||||
}
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
#define SWIG_SHARED_PTR_NAMESPACE std
|
||||
%include <boost_shared_ptr.i>
|
||||
|
|
@ -1,98 +0,0 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* std_string.i
|
||||
*
|
||||
* Typemaps for std::string and const std::string&
|
||||
* These are mapped to a D char[] 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;
|
||||
|
||||
%define SWIGD_STD_STRING_TYPEMAPS(DW_STRING_TYPE, DP_STRING_TYPE, FROM_STRINGZ, TO_STRINGZ)
|
||||
// string
|
||||
%typemap(ctype) string, const string & "char *"
|
||||
%typemap(imtype) string, const string & #DW_STRING_TYPE
|
||||
%typemap(dtype) string, const string & #DP_STRING_TYPE
|
||||
|
||||
%typemap(in, canthrow=1) string, const string &
|
||||
%{ if (!$input) {
|
||||
SWIG_DSetPendingException(SWIG_DIllegalArgumentException, "null string");
|
||||
return $null;
|
||||
}
|
||||
$1.assign($input); %}
|
||||
%typemap(in, canthrow=1) const string &
|
||||
%{ if (!$input) {
|
||||
SWIG_DSetPendingException(SWIG_DIllegalArgumentException, "null string");
|
||||
return $null;
|
||||
}
|
||||
$*1_ltype $1_str($input);
|
||||
$1 = &$1_str; %}
|
||||
|
||||
%typemap(out) string %{ $result = SWIG_d_string_callback($1.c_str()); %}
|
||||
%typemap(out) const string & %{ $result = SWIG_d_string_callback($1->c_str()); %}
|
||||
|
||||
%typemap(din) string, const string & "($dinput ? TO_STRINGZ($dinput) : null)"
|
||||
%typemap(dout, excode=SWIGEXCODE) string, const string & {
|
||||
DP_STRING_TYPE ret = FROM_STRINGZ($imcall);$excode
|
||||
return ret;
|
||||
}
|
||||
|
||||
%typemap(directorin) string, const string & %{ $input = SWIG_d_string_callback($1.c_str()); %}
|
||||
|
||||
%typemap(directorout, canthrow=1) string
|
||||
%{ if (!$input) {
|
||||
SWIG_DSetPendingException(SWIG_DIllegalArgumentException, "null string");
|
||||
return $null;
|
||||
}
|
||||
$result.assign($input); %}
|
||||
|
||||
%typemap(directorout, canthrow=1, warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const string &
|
||||
%{ if (!$input) {
|
||||
SWIG_DSetPendingException(SWIG_DIllegalArgumentException, "null string");
|
||||
return $null;
|
||||
}
|
||||
/* possible thread/reentrant code problem */
|
||||
static $*1_ltype $1_str;
|
||||
$1_str = $input;
|
||||
$result = &$1_str; %}
|
||||
|
||||
%typemap(ddirectorin) string, const string & "FROM_STRINGZ($winput)"
|
||||
%typemap(ddirectorout) string, const string & "TO_STRINGZ($dcall)"
|
||||
|
||||
%typemap(throws, canthrow=1) string, const string &
|
||||
%{ SWIG_DSetPendingException(SWIG_DException, $1.c_str());
|
||||
return $null; %}
|
||||
|
||||
%typemap(typecheck) string, const string & = char *;
|
||||
%enddef
|
||||
|
||||
// We need to have the \0-terminated string conversion functions available in
|
||||
// the D proxy modules.
|
||||
#if (SWIG_D_VERSION == 1)
|
||||
// Could be easily extended to support Phobos as well.
|
||||
SWIGD_STD_STRING_TYPEMAPS(char*, char[], tango.stdc.stringz.fromStringz, tango.stdc.stringz.toStringz)
|
||||
|
||||
%pragma(d) globalproxyimports = "static import tango.stdc.stringz;";
|
||||
#else
|
||||
SWIGD_STD_STRING_TYPEMAPS(const(char)*, string, std.conv.to!string, std.string.toStringz)
|
||||
|
||||
%pragma(d) globalproxyimports = %{
|
||||
static import std.conv;
|
||||
static import std.string;
|
||||
%}
|
||||
#endif
|
||||
|
||||
#undef SWIGD_STD_STRING_TYPEMAPS
|
||||
|
||||
} // namespace std
|
||||
|
|
@ -1,42 +0,0 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* std_unique_ptr.i
|
||||
*
|
||||
* SWIG library file for handling std::unique_ptr.
|
||||
* Memory ownership is passed from the std::unique_ptr C++ layer to the proxy
|
||||
* class when returning a std::unique_ptr from a function.
|
||||
* Memory ownership is passed from the proxy class to the std::unique_ptr in the
|
||||
* C++ layer when passed as a parameter to a wrapped function.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
%define %unique_ptr(TYPE)
|
||||
%typemap (ctype) std::unique_ptr< TYPE > "void *"
|
||||
%typemap (imtype) std::unique_ptr< TYPE > "void*"
|
||||
%typemap (dtype) std::unique_ptr< TYPE > "$typemap(dtype, TYPE)"
|
||||
|
||||
%typemap(in) std::unique_ptr< TYPE >
|
||||
%{ $1.reset((TYPE *)$input); %}
|
||||
|
||||
%typemap(din,
|
||||
nativepointer="cast(void*)$dinput"
|
||||
) std::unique_ptr< TYPE > "$typemap(dtype, TYPE).swigRelease($dinput)"
|
||||
|
||||
%typemap (out) std::unique_ptr< TYPE > %{
|
||||
$result = (void *)$1.release();
|
||||
%}
|
||||
|
||||
%typemap(dout, excode=SWIGEXCODE,
|
||||
nativepointer="{\n auto ret = cast($dtype)$imcall;$excode\n return ret;\n}"
|
||||
) std::unique_ptr< TYPE > {
|
||||
void* cPtr = $imcall;
|
||||
$typemap(dtype, TYPE) ret = (cPtr is null) ? null : new $typemap(dtype, TYPE)(cPtr, true);$excode
|
||||
return ret;
|
||||
}
|
||||
|
||||
%typemap(typecheck, precedence=SWIG_TYPECHECK_POINTER, equivalent="TYPE *") std::unique_ptr< TYPE > ""
|
||||
|
||||
%template() std::unique_ptr< TYPE >;
|
||||
%enddef
|
||||
|
||||
namespace std {
|
||||
template <class T> class unique_ptr {};
|
||||
}
|
||||
|
|
@ -1,605 +0,0 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* std_vector.i
|
||||
*
|
||||
* SWIG typemaps for std::vector<T>, D implementation.
|
||||
*
|
||||
* The D wrapper is made to loosely resemble a tango.util.container.more.Vector
|
||||
* and to provide built-in array-like access.
|
||||
*
|
||||
* If T does define an operator==, then use the SWIG_STD_VECTOR_ENHANCED
|
||||
* macro to obtain enhanced functionality (none yet), for example:
|
||||
*
|
||||
* SWIG_STD_VECTOR_ENHANCED(SomeNamespace::Klass)
|
||||
* %template(VectKlass) std::vector<SomeNamespace::Klass>;
|
||||
*
|
||||
* Warning: heavy macro usage in this file. Use swig -E to get a sane view on
|
||||
* the real file contents!
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
// Warning: Use the typemaps here in the expectation that the macros they are in will change name.
|
||||
|
||||
%include <std_common.i>
|
||||
|
||||
// MACRO for use within the std::vector class body
|
||||
%define SWIG_STD_VECTOR_MINIMUM_INTERNAL(CONST_REFERENCE, CTYPE...)
|
||||
#if (SWIG_D_VERSION == 1)
|
||||
%typemap(dimports) std::vector< CTYPE > "static import tango.core.Exception;"
|
||||
%proxycode %{
|
||||
public this($typemap(dtype, CTYPE)[] values) {
|
||||
this();
|
||||
append(values);
|
||||
}
|
||||
|
||||
alias push_back add;
|
||||
alias push_back push;
|
||||
alias push_back opCatAssign;
|
||||
alias size length;
|
||||
alias opSlice slice;
|
||||
|
||||
public $typemap(dtype, CTYPE) opIndexAssign($typemap(dtype, CTYPE) value, size_t index) {
|
||||
if (index >= size()) {
|
||||
throw new tango.core.Exception.NoSuchElementException("Tried to assign to element out of vector bounds.");
|
||||
}
|
||||
setElement(index, value);
|
||||
return value;
|
||||
}
|
||||
|
||||
public $typemap(dtype, CTYPE) opIndex(size_t index) {
|
||||
if (index >= size()) {
|
||||
throw new tango.core.Exception.NoSuchElementException("Tried to read from element out of vector bounds.");
|
||||
}
|
||||
return getElement(index);
|
||||
}
|
||||
|
||||
public void append($typemap(dtype, CTYPE)[] value...) {
|
||||
foreach (v; value) {
|
||||
add(v);
|
||||
}
|
||||
}
|
||||
|
||||
public $typemap(dtype, CTYPE)[] opSlice() {
|
||||
$typemap(dtype, CTYPE)[] array = new $typemap(dtype, CTYPE)[size()];
|
||||
foreach (i, ref value; array) {
|
||||
value = getElement(i);
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
public int opApply(int delegate(ref $typemap(dtype, CTYPE) value) dg) {
|
||||
int result;
|
||||
|
||||
size_t currentSize = size();
|
||||
for (size_t i = 0; i < currentSize; ++i) {
|
||||
auto value = getElement(i);
|
||||
result = dg(value);
|
||||
setElement(i, value);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public int opApply(int delegate(ref size_t index, ref $typemap(dtype, CTYPE) value) dg) {
|
||||
int result;
|
||||
|
||||
size_t currentSize = size();
|
||||
for (size_t i = 0; i < currentSize; ++i) {
|
||||
auto value = getElement(i);
|
||||
|
||||
// Workaround for http://d.puremagic.com/issues/show_bug.cgi?id=2443.
|
||||
auto index = i;
|
||||
|
||||
result = dg(index, value);
|
||||
setElement(i, value);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public void capacity(size_t value) {
|
||||
if (value < size()) {
|
||||
throw new tango.core.Exception.IllegalArgumentException("Tried to make the capacity of a vector smaller than its size.");
|
||||
}
|
||||
|
||||
reserve(value);
|
||||
}
|
||||
%}
|
||||
|
||||
public:
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef CTYPE value_type;
|
||||
typedef value_type* pointer;
|
||||
typedef const value_type* const_pointer;
|
||||
typedef value_type& reference;
|
||||
typedef CONST_REFERENCE const_reference;
|
||||
|
||||
void clear();
|
||||
void push_back(CTYPE const& x);
|
||||
size_type size() const;
|
||||
size_type capacity() const;
|
||||
void reserve(size_type n) throw (std::length_error);
|
||||
|
||||
vector();
|
||||
vector(const vector &other);
|
||||
|
||||
%extend {
|
||||
vector(size_type capacity) throw (std::length_error) {
|
||||
std::vector< CTYPE >* pv = 0;
|
||||
pv = new std::vector< CTYPE >();
|
||||
|
||||
// Might throw std::length_error.
|
||||
pv->reserve(capacity);
|
||||
|
||||
return pv;
|
||||
}
|
||||
|
||||
size_type unused() const {
|
||||
return $self->capacity() - $self->size();
|
||||
}
|
||||
|
||||
const_reference remove() throw (std::out_of_range) {
|
||||
if ($self->empty()) {
|
||||
throw std::out_of_range("Tried to remove last element from empty vector.");
|
||||
}
|
||||
|
||||
std::vector< CTYPE >::const_reference value = $self->back();
|
||||
$self->pop_back();
|
||||
return value;
|
||||
}
|
||||
|
||||
const_reference remove(size_type index) throw (std::out_of_range) {
|
||||
if (index >= $self->size()) {
|
||||
throw std::out_of_range("Tried to remove element with invalid index.");
|
||||
}
|
||||
|
||||
std::vector< CTYPE >::iterator it = $self->begin() + index;
|
||||
std::vector< CTYPE >::const_reference value = *it;
|
||||
$self->erase(it);
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
// Wrappers for setting/getting items with the possibly thrown exception
|
||||
// specified (important for SWIG wrapper generation).
|
||||
%extend {
|
||||
const_reference getElement(size_type index) throw (std::out_of_range) {
|
||||
if ((index < 0) || ($self->size() <= index)) {
|
||||
throw std::out_of_range("Tried to get value of element with invalid index.");
|
||||
}
|
||||
return (*$self)[index];
|
||||
}
|
||||
}
|
||||
|
||||
// Use CTYPE const& instead of const_reference to work around SWIG code
|
||||
// generation issue when using const pointers as vector elements (like
|
||||
// std::vector< const int* >).
|
||||
%extend {
|
||||
void setElement(size_type index, CTYPE const& val) throw (std::out_of_range) {
|
||||
if ((index < 0) || ($self->size() <= index)) {
|
||||
throw std::out_of_range("Tried to set value of element with invalid index.");
|
||||
}
|
||||
(*$self)[index] = val;
|
||||
}
|
||||
}
|
||||
|
||||
%dmethodmodifiers std::vector::getElement "private"
|
||||
%dmethodmodifiers std::vector::setElement "private"
|
||||
%dmethodmodifiers std::vector::reserve "private"
|
||||
|
||||
#else
|
||||
|
||||
%typemap(dimports) std::vector< CTYPE > %{
|
||||
static import std.algorithm;
|
||||
static import std.exception;
|
||||
static import std.range;
|
||||
static import std.traits;
|
||||
%}
|
||||
%proxycode %{
|
||||
alias size_t KeyType;
|
||||
alias $typemap(dtype, CTYPE) ValueType;
|
||||
|
||||
this(ValueType[] values...) {
|
||||
this();
|
||||
reserve(values.length);
|
||||
foreach (e; values) {
|
||||
this ~= e;
|
||||
}
|
||||
}
|
||||
|
||||
struct Range {
|
||||
private $typemap(dtype, std::vector< CTYPE >) _outer;
|
||||
private size_t _a, _b;
|
||||
|
||||
this($typemap(dtype, std::vector< CTYPE >) data, size_t a, size_t b) {
|
||||
_outer = data;
|
||||
_a = a;
|
||||
_b = b;
|
||||
}
|
||||
|
||||
@property bool empty() const {
|
||||
assert((cast($typemap(dtype, std::vector< CTYPE >))_outer).length >= _b);
|
||||
return _a >= _b;
|
||||
}
|
||||
|
||||
@property Range save() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@property ValueType front() {
|
||||
std.exception.enforce(!empty);
|
||||
return _outer[_a];
|
||||
}
|
||||
|
||||
@property void front(ValueType value) {
|
||||
std.exception.enforce(!empty);
|
||||
_outer[_a] = std.algorithm.move(value);
|
||||
}
|
||||
|
||||
void popFront() {
|
||||
std.exception.enforce(!empty);
|
||||
++_a;
|
||||
}
|
||||
|
||||
void opIndexAssign(ValueType value, size_t i) {
|
||||
i += _a;
|
||||
std.exception.enforce(i < _b && _b <= _outer.length);
|
||||
_outer[i] = value;
|
||||
}
|
||||
|
||||
void opIndexOpAssign(string op)(ValueType value, size_t i) {
|
||||
std.exception.enforce(_outer && _a + i < _b && _b <= _outer.length);
|
||||
auto element = _outer[i];
|
||||
mixin("element "~op~"= value;");
|
||||
_outer[i] = element;
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: dup?
|
||||
|
||||
Range opSlice() {
|
||||
return Range(this, 0, length);
|
||||
}
|
||||
|
||||
Range opSlice(size_t a, size_t b) {
|
||||
std.exception.enforce(a <= b && b <= length);
|
||||
return Range(this, a, b);
|
||||
}
|
||||
|
||||
size_t opDollar() const {
|
||||
return length;
|
||||
}
|
||||
|
||||
@property ValueType front() {
|
||||
std.exception.enforce(!empty);
|
||||
return getElement(0);
|
||||
}
|
||||
|
||||
@property void front(ValueType value) {
|
||||
std.exception.enforce(!empty);
|
||||
setElement(0, value);
|
||||
}
|
||||
|
||||
@property ValueType back() {
|
||||
std.exception.enforce(!empty);
|
||||
return getElement(length - 1);
|
||||
}
|
||||
|
||||
@property void back(ValueType value) {
|
||||
std.exception.enforce(!empty);
|
||||
setElement(length - 1, value);
|
||||
}
|
||||
|
||||
ValueType opIndex(size_t i) {
|
||||
return getElement(i);
|
||||
}
|
||||
|
||||
void opIndexAssign(ValueType value, size_t i) {
|
||||
setElement(i, value);
|
||||
}
|
||||
|
||||
void opIndexOpAssign(string op)(ValueType value, size_t i) {
|
||||
auto element = this[i];
|
||||
mixin("element "~op~"= value;");
|
||||
this[i] = element;
|
||||
}
|
||||
|
||||
ValueType[] opBinary(string op, Stuff)(Stuff stuff) if (op == "~") {
|
||||
ValueType[] result;
|
||||
result ~= this[];
|
||||
assert(result.length == length);
|
||||
result ~= stuff[];
|
||||
return result;
|
||||
}
|
||||
|
||||
void opOpAssign(string op, Stuff)(Stuff stuff) if (op == "~") {
|
||||
static if (is(typeof(insertBack(stuff)))) {
|
||||
insertBack(stuff);
|
||||
} else if (is(typeof(insertBack(stuff[])))) {
|
||||
insertBack(stuff[]);
|
||||
} else {
|
||||
static assert(false, "Cannot append " ~ Stuff.stringof ~ " to " ~ typeof(this).stringof);
|
||||
}
|
||||
}
|
||||
|
||||
alias size length;
|
||||
|
||||
alias remove removeAny;
|
||||
alias removeAny stableRemoveAny;
|
||||
|
||||
size_t insertBack(Stuff)(Stuff stuff)
|
||||
if (std.traits.isImplicitlyConvertible!(Stuff, ValueType)){
|
||||
push_back(stuff);
|
||||
return 1;
|
||||
}
|
||||
size_t insertBack(Stuff)(Stuff stuff)
|
||||
if (std.range.isInputRange!Stuff &&
|
||||
std.traits.isImplicitlyConvertible!(std.range.ElementType!Stuff, ValueType)) {
|
||||
size_t itemCount;
|
||||
foreach(item; stuff) {
|
||||
insertBack(item);
|
||||
++itemCount;
|
||||
}
|
||||
return itemCount;
|
||||
}
|
||||
alias insertBack insert;
|
||||
|
||||
alias pop_back removeBack;
|
||||
alias pop_back stableRemoveBack;
|
||||
|
||||
size_t insertBefore(Stuff)(Range r, Stuff stuff)
|
||||
if (std.traits.isImplicitlyConvertible!(Stuff, ValueType)) {
|
||||
std.exception.enforce(r._outer.swigCPtr == swigCPtr && r._a < length);
|
||||
insertAt(r._a, stuff);
|
||||
return 1;
|
||||
}
|
||||
|
||||
size_t insertBefore(Stuff)(Range r, Stuff stuff)
|
||||
if (std.range.isInputRange!Stuff && std.traits.isImplicitlyConvertible!(ElementType!Stuff, ValueType)) {
|
||||
std.exception.enforce(r._outer.swigCPtr == swigCPtr && r._a <= length);
|
||||
|
||||
size_t insertCount;
|
||||
foreach(i, item; stuff) {
|
||||
insertAt(r._a + i, item);
|
||||
++insertCount;
|
||||
}
|
||||
|
||||
return insertCount;
|
||||
}
|
||||
|
||||
size_t insertAfter(Stuff)(Range r, Stuff stuff) {
|
||||
// TODO: optimize
|
||||
immutable offset = r._a + r.length;
|
||||
std.exception.enforce(offset <= length);
|
||||
auto result = insertBack(stuff);
|
||||
std.algorithm.bringToFront(this[offset .. length - result],
|
||||
this[length - result .. length]);
|
||||
return result;
|
||||
}
|
||||
|
||||
size_t replace(Stuff)(Range r, Stuff stuff)
|
||||
if (std.range.isInputRange!Stuff &&
|
||||
std.traits.isImplicitlyConvertible!(ElementType!Stuff, ValueType)) {
|
||||
immutable offset = r._a;
|
||||
std.exception.enforce(offset <= length);
|
||||
size_t result;
|
||||
for (; !stuff.empty; stuff.popFront()) {
|
||||
if (r.empty) {
|
||||
// append the rest
|
||||
return result + insertBack(stuff);
|
||||
}
|
||||
r.front = stuff.front;
|
||||
r.popFront();
|
||||
++result;
|
||||
}
|
||||
// Remove remaining stuff in r
|
||||
remove(r);
|
||||
return result;
|
||||
}
|
||||
|
||||
size_t replace(Stuff)(Range r, Stuff stuff)
|
||||
if (std.traits.isImplicitlyConvertible!(Stuff, ValueType))
|
||||
{
|
||||
if (r.empty)
|
||||
{
|
||||
insertBefore(r, stuff);
|
||||
}
|
||||
else
|
||||
{
|
||||
r.front = stuff;
|
||||
r.popFront();
|
||||
remove(r);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
Range linearRemove(Range r) {
|
||||
std.exception.enforce(r._a <= r._b && r._b <= length);
|
||||
immutable tailLength = length - r._b;
|
||||
linearRemove(r._a, r._b);
|
||||
return this[length - tailLength .. length];
|
||||
}
|
||||
alias remove stableLinearRemove;
|
||||
|
||||
int opApply(int delegate(ref $typemap(dtype, CTYPE) value) dg) {
|
||||
int result;
|
||||
|
||||
size_t currentSize = size();
|
||||
for (size_t i = 0; i < currentSize; ++i) {
|
||||
auto value = getElement(i);
|
||||
result = dg(value);
|
||||
setElement(i, value);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
int opApply(int delegate(ref size_t index, ref $typemap(dtype, CTYPE) value) dg) {
|
||||
int result;
|
||||
|
||||
size_t currentSize = size();
|
||||
for (size_t i = 0; i < currentSize; ++i) {
|
||||
auto value = getElement(i);
|
||||
|
||||
// Workaround for http://d.puremagic.com/issues/show_bug.cgi?id=2443.
|
||||
auto index = i;
|
||||
|
||||
result = dg(index, value);
|
||||
setElement(i, value);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
%}
|
||||
|
||||
public:
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef CTYPE value_type;
|
||||
typedef value_type* pointer;
|
||||
typedef const value_type* const_pointer;
|
||||
typedef value_type& reference;
|
||||
typedef CONST_REFERENCE const_reference;
|
||||
|
||||
bool empty() const;
|
||||
void clear();
|
||||
void push_back(CTYPE const& x);
|
||||
void pop_back();
|
||||
size_type size() const;
|
||||
size_type capacity() const;
|
||||
void reserve(size_type n) throw (std::length_error);
|
||||
|
||||
vector();
|
||||
vector(const vector &other);
|
||||
|
||||
%extend {
|
||||
vector(size_type capacity) throw (std::length_error) {
|
||||
std::vector< CTYPE >* pv = 0;
|
||||
pv = new std::vector< CTYPE >();
|
||||
|
||||
// Might throw std::length_error.
|
||||
pv->reserve(capacity);
|
||||
|
||||
return pv;
|
||||
}
|
||||
|
||||
const_reference remove() throw (std::out_of_range) {
|
||||
if ($self->empty()) {
|
||||
throw std::out_of_range("Tried to remove last element from empty vector.");
|
||||
}
|
||||
|
||||
std::vector< CTYPE >::const_reference value = $self->back();
|
||||
$self->pop_back();
|
||||
return value;
|
||||
}
|
||||
|
||||
const_reference remove(size_type index) throw (std::out_of_range) {
|
||||
if (index >= $self->size()) {
|
||||
throw std::out_of_range("Tried to remove element with invalid index.");
|
||||
}
|
||||
|
||||
std::vector< CTYPE >::iterator it = $self->begin() + index;
|
||||
std::vector< CTYPE >::const_reference value = *it;
|
||||
$self->erase(it);
|
||||
return value;
|
||||
}
|
||||
|
||||
void removeBack(size_type how_many) throw (std::out_of_range) {
|
||||
std::vector< CTYPE >::iterator end = $self->end();
|
||||
std::vector< CTYPE >::iterator start = end - how_many;
|
||||
$self->erase(start, end);
|
||||
}
|
||||
|
||||
void linearRemove(size_type start_index, size_type end_index) throw (std::out_of_range) {
|
||||
std::vector< CTYPE >::iterator start = $self->begin() + start_index;
|
||||
std::vector< CTYPE >::iterator end = $self->begin() + end_index;
|
||||
$self->erase(start, end);
|
||||
}
|
||||
|
||||
void insertAt(size_type index, CTYPE const& x) throw (std::out_of_range) {
|
||||
std::vector< CTYPE >::iterator it = $self->begin() + index;
|
||||
$self->insert(it, x);
|
||||
}
|
||||
}
|
||||
|
||||
// Wrappers for setting/getting items with the possibly thrown exception
|
||||
// specified (important for SWIG wrapper generation).
|
||||
%extend {
|
||||
const_reference getElement(size_type index) throw (std::out_of_range) {
|
||||
if ((index < 0) || ($self->size() <= index)) {
|
||||
throw std::out_of_range("Tried to get value of element with invalid index.");
|
||||
}
|
||||
return (*$self)[index];
|
||||
}
|
||||
}
|
||||
// Use CTYPE const& instead of const_reference to work around SWIG code
|
||||
// generation issue when using const pointers as vector elements (like
|
||||
// std::vector< const int* >).
|
||||
%extend {
|
||||
void setElement(size_type index, CTYPE const& val) throw (std::out_of_range) {
|
||||
if ((index < 0) || ($self->size() <= index)) {
|
||||
throw std::out_of_range("Tried to set value of element with invalid index.");
|
||||
}
|
||||
(*$self)[index] = val;
|
||||
}
|
||||
}
|
||||
|
||||
%dmethodmodifiers std::vector::getElement "private"
|
||||
%dmethodmodifiers std::vector::setElement "private"
|
||||
#endif
|
||||
%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 {
|
||||
}
|
||||
%enddef
|
||||
|
||||
// For vararg handling in macros, from swigmacros.swg
|
||||
#define %arg(X...) X
|
||||
|
||||
// Macros for std::vector class specializations/enhancements
|
||||
%define SWIG_STD_VECTOR_ENHANCED(CTYPE...)
|
||||
namespace std {
|
||||
template<> class vector<CTYPE > {
|
||||
SWIG_STD_VECTOR_MINIMUM_INTERNAL(const value_type&, %arg(CTYPE))
|
||||
SWIG_STD_VECTOR_EXTRA_OP_EQUALS_EQUALS(CTYPE)
|
||||
};
|
||||
}
|
||||
%enddef
|
||||
|
||||
%{
|
||||
#include <vector>
|
||||
#include <stdexcept>
|
||||
%}
|
||||
|
||||
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_INTERNAL(const value_type&, T)
|
||||
};
|
||||
// specializations for pointers
|
||||
template<class T> class vector<T *> {
|
||||
SWIG_STD_VECTOR_MINIMUM_INTERNAL(const value_type&, T *)
|
||||
SWIG_STD_VECTOR_EXTRA_OP_EQUALS_EQUALS(T *)
|
||||
};
|
||||
// bool is a bit different in the C++ standard - const_reference in particular
|
||||
template<> class vector<bool> {
|
||||
SWIG_STD_VECTOR_MINIMUM_INTERNAL(bool, bool)
|
||||
SWIG_STD_VECTOR_EXTRA_OP_EQUALS_EQUALS(bool)
|
||||
};
|
||||
}
|
||||
|
||||
// template specializations for std::vector
|
||||
// these provide extra collections methods as operator== is defined
|
||||
SWIG_STD_VECTOR_ENHANCED(char)
|
||||
SWIG_STD_VECTOR_ENHANCED(signed char)
|
||||
SWIG_STD_VECTOR_ENHANCED(unsigned char)
|
||||
SWIG_STD_VECTOR_ENHANCED(short)
|
||||
SWIG_STD_VECTOR_ENHANCED(unsigned short)
|
||||
SWIG_STD_VECTOR_ENHANCED(int)
|
||||
SWIG_STD_VECTOR_ENHANCED(unsigned int)
|
||||
SWIG_STD_VECTOR_ENHANCED(long)
|
||||
SWIG_STD_VECTOR_ENHANCED(unsigned long)
|
||||
SWIG_STD_VECTOR_ENHANCED(long long)
|
||||
SWIG_STD_VECTOR_ENHANCED(unsigned long long)
|
||||
SWIG_STD_VECTOR_ENHANCED(float)
|
||||
SWIG_STD_VECTOR_ENHANCED(double)
|
||||
SWIG_STD_VECTOR_ENHANCED(std::string) // also requires a %include <std_string.i>
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* stl.i
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
%include <std_common.i>
|
||||
%include <std_string.i>
|
||||
%include <std_vector.i>
|
||||
%include <std_map.i>
|
||||
%include <std_pair.i>
|
||||
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* swigmove.i
|
||||
*
|
||||
* Input typemaps library for implementing full move semantics when passing
|
||||
* parameters by value.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
%typemap(in, canthrow=1) SWIGTYPE MOVE ($&1_type argp)
|
||||
%{ argp = ($&1_ltype)$input;
|
||||
if (!argp) {
|
||||
SWIG_DSetPendingException(SWIG_DIllegalArgumentException, "Attempt to dereference null $1_type");
|
||||
return $null;
|
||||
}
|
||||
SwigValueWrapper< $1_ltype >::reset($1, argp); %}
|
||||
|
||||
%typemap(din) SWIGTYPE MOVE "$dclassname.swigRelease($dinput)"
|
||||
|
|
@ -1,261 +0,0 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* 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 are used for pointer/reference parameters that are input only
|
||||
and are mapped to a D input parameter.
|
||||
|
||||
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 D you could then use it like this:
|
||||
double answer = fadd(10.0, 20.0);
|
||||
*/
|
||||
|
||||
%define INPUT_TYPEMAP(TYPE, CTYPE, DTYPE)
|
||||
%typemap(ctype, out="void *") TYPE *INPUT, TYPE &INPUT "CTYPE"
|
||||
%typemap(imtype, out="void*") TYPE *INPUT, TYPE &INPUT "DTYPE"
|
||||
%typemap(dtype, out="DTYPE*") TYPE *INPUT, TYPE &INPUT "DTYPE"
|
||||
%typemap(din) TYPE *INPUT, TYPE &INPUT "$dinput"
|
||||
|
||||
%typemap(in) TYPE *INPUT, TYPE &INPUT
|
||||
%{ $1 = ($1_ltype)&$input; %}
|
||||
|
||||
%typemap(typecheck) TYPE *INPUT = TYPE;
|
||||
%typemap(typecheck) TYPE &INPUT = TYPE;
|
||||
%enddef
|
||||
|
||||
INPUT_TYPEMAP(bool, unsigned int, bool)
|
||||
//INPUT_TYPEMAP(char, char, char) // Why was this commented out?
|
||||
INPUT_TYPEMAP(signed char, signed char, byte)
|
||||
INPUT_TYPEMAP(unsigned char, unsigned char, ubyte)
|
||||
INPUT_TYPEMAP(short, short, short)
|
||||
INPUT_TYPEMAP(unsigned short, unsigned short, ushort)
|
||||
INPUT_TYPEMAP(int, int, int)
|
||||
INPUT_TYPEMAP(unsigned int, unsigned int, uint)
|
||||
INPUT_TYPEMAP(long, long, SWIG_LONG_DTYPE)
|
||||
INPUT_TYPEMAP(unsigned long, unsigned long, SWIG_ULONG_DTYPE)
|
||||
INPUT_TYPEMAP(long long, long long, long)
|
||||
INPUT_TYPEMAP(unsigned long long, unsigned long long, ulong)
|
||||
INPUT_TYPEMAP(float, float, float)
|
||||
INPUT_TYPEMAP(double, double, double)
|
||||
|
||||
INPUT_TYPEMAP(enum SWIGTYPE, unsigned int, int)
|
||||
%typemap(dtype) enum SWIGTYPE *INPUT, enum SWIGTYPE &INPUT "$*dclassname"
|
||||
|
||||
#undef INPUT_TYPEMAP
|
||||
|
||||
|
||||
/*
|
||||
OUTPUT typemaps
|
||||
---------------
|
||||
|
||||
These typemaps are used for pointer/reference parameters that are output only and
|
||||
are mapped to a D output parameter.
|
||||
|
||||
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. In D, the 'out' keyword is
|
||||
used when passing the parameter to a function that takes an output parameter.
|
||||
|
||||
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 D output of the function would be the function return value and the
|
||||
value returned in the second output parameter. In D you would use it like this:
|
||||
|
||||
double dptr;
|
||||
double fraction = modf(5, dptr);
|
||||
*/
|
||||
|
||||
%define OUTPUT_TYPEMAP(TYPE, CTYPE, DTYPE, TYPECHECKPRECEDENCE)
|
||||
%typemap(ctype, out="void *") TYPE *OUTPUT, TYPE &OUTPUT "CTYPE *"
|
||||
%typemap(imtype, out="void*") TYPE *OUTPUT, TYPE &OUTPUT "out DTYPE"
|
||||
%typemap(dtype, out="DTYPE*") TYPE *OUTPUT, TYPE &OUTPUT "out DTYPE"
|
||||
%typemap(din) TYPE *OUTPUT, TYPE &OUTPUT "$dinput"
|
||||
|
||||
%typemap(in) TYPE *OUTPUT, TYPE &OUTPUT
|
||||
%{ $1 = ($1_ltype)$input; %}
|
||||
|
||||
%typecheck(SWIG_TYPECHECK_##TYPECHECKPRECEDENCE) TYPE *OUTPUT, TYPE &OUTPUT ""
|
||||
%enddef
|
||||
|
||||
OUTPUT_TYPEMAP(bool, unsigned int, bool, BOOL_PTR)
|
||||
//OUTPUT_TYPEMAP(char, char, char, CHAR_PTR) // Why was this commented out?
|
||||
OUTPUT_TYPEMAP(signed char, signed char, byte, INT8_PTR)
|
||||
OUTPUT_TYPEMAP(unsigned char, unsigned char, ubyte, UINT8_PTR)
|
||||
OUTPUT_TYPEMAP(short, short, short, INT16_PTR)
|
||||
OUTPUT_TYPEMAP(unsigned short, unsigned short, ushort, UINT16_PTR)
|
||||
OUTPUT_TYPEMAP(int, int, int, INT32_PTR)
|
||||
OUTPUT_TYPEMAP(unsigned int, unsigned int, uint, UINT32_PTR)
|
||||
OUTPUT_TYPEMAP(long, long, SWIG_LONG_DTYPE,INT32_PTR)
|
||||
OUTPUT_TYPEMAP(unsigned long, unsigned long, SWIG_ULONG_DTYPE,UINT32_PTR)
|
||||
OUTPUT_TYPEMAP(long long, long long, long, INT64_PTR)
|
||||
OUTPUT_TYPEMAP(unsigned long long, unsigned long long, ulong, UINT64_PTR)
|
||||
OUTPUT_TYPEMAP(float, float, float, FLOAT_PTR)
|
||||
OUTPUT_TYPEMAP(double, double, double, DOUBLE_PTR)
|
||||
|
||||
OUTPUT_TYPEMAP(enum SWIGTYPE, unsigned int, int, INT32_PTR)
|
||||
%typemap(dtype) enum SWIGTYPE *OUTPUT, enum SWIGTYPE &OUTPUT "out $*dclassname"
|
||||
|
||||
#undef OUTPUT_TYPEMAP
|
||||
|
||||
%typemap(in) bool *OUTPUT, bool &OUTPUT
|
||||
%{ *$input = 0;
|
||||
$1 = ($1_ltype)$input; %}
|
||||
|
||||
|
||||
/*
|
||||
INOUT typemaps
|
||||
--------------
|
||||
|
||||
These typemaps are for pointer/reference parameters that are both input and
|
||||
output and are mapped to a D reference parameter.
|
||||
|
||||
The following typemaps can be applied to turn a pointer or reference into a
|
||||
reference parameters, that is the parameter is both an input and an output.
|
||||
In D, the 'ref' keyword is used for reference parameters.
|
||||
|
||||
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);
|
||||
|
||||
The D output of the function would be the new value returned by the
|
||||
reference parameter. In D you would use it like this:
|
||||
|
||||
|
||||
double x = 5.0;
|
||||
neg(x);
|
||||
|
||||
The implementation of the OUTPUT and INOUT typemaps is different to the scripting
|
||||
languages in that the scripting languages will return the output value as part
|
||||
of the function return value.
|
||||
*/
|
||||
|
||||
%define INOUT_TYPEMAP(TYPE, CTYPE, DTYPE, TYPECHECKPRECEDENCE)
|
||||
%typemap(ctype, out="void *") TYPE *INOUT, TYPE &INOUT "CTYPE *"
|
||||
%typemap(imtype, out="void*") TYPE *INOUT, TYPE &INOUT "ref DTYPE"
|
||||
%typemap(dtype, out="DTYPE*") TYPE *INOUT, TYPE &INOUT "ref DTYPE"
|
||||
%typemap(din) TYPE *INOUT, TYPE &INOUT "$dinput"
|
||||
|
||||
%typemap(in) TYPE *INOUT, TYPE &INOUT
|
||||
%{ $1 = ($1_ltype)$input; %}
|
||||
|
||||
%typecheck(SWIG_TYPECHECK_##TYPECHECKPRECEDENCE) TYPE *INOUT, TYPE &INOUT ""
|
||||
%enddef
|
||||
|
||||
INOUT_TYPEMAP(bool, unsigned int, bool, BOOL_PTR)
|
||||
//INOUT_TYPEMAP(char, char, char, CHAR_PTR)
|
||||
INOUT_TYPEMAP(signed char, signed char, byte, INT8_PTR)
|
||||
INOUT_TYPEMAP(unsigned char, unsigned char, ubyte, UINT8_PTR)
|
||||
INOUT_TYPEMAP(short, short, short, INT16_PTR)
|
||||
INOUT_TYPEMAP(unsigned short, unsigned short, ushort, UINT16_PTR)
|
||||
INOUT_TYPEMAP(int, int, int, INT32_PTR)
|
||||
INOUT_TYPEMAP(unsigned int, unsigned int, uint, UINT32_PTR)
|
||||
INOUT_TYPEMAP(long, long, SWIG_LONG_DTYPE,INT32_PTR)
|
||||
INOUT_TYPEMAP(unsigned long, unsigned long, SWIG_ULONG_DTYPE,UINT32_PTR)
|
||||
INOUT_TYPEMAP(long long, long long, long, INT64_PTR)
|
||||
INOUT_TYPEMAP(unsigned long long, unsigned long long, ulong, UINT64_PTR)
|
||||
INOUT_TYPEMAP(float, float, float, FLOAT_PTR)
|
||||
INOUT_TYPEMAP(double, double, double, DOUBLE_PTR)
|
||||
|
||||
INOUT_TYPEMAP(enum SWIGTYPE, unsigned int, int, INT32_PTR)
|
||||
%typemap(dtype) enum SWIGTYPE *INOUT, enum SWIGTYPE &INOUT "ref $*dclassname"
|
||||
|
||||
#undef INOUT_TYPEMAP
|
||||
|
|
@ -1,309 +0,0 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* wrapperloader.swg
|
||||
*
|
||||
* Support code for dynamically linking the C wrapper library from the D
|
||||
* wrapper module.
|
||||
*
|
||||
* The loading code was adapted from the Derelict project and is used with
|
||||
* permission from Michael Parker, the original author.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
%pragma(d) wrapperloadercode = %{
|
||||
private {
|
||||
version(linux) {
|
||||
version = Nix;
|
||||
} else version(darwin) {
|
||||
version = Nix;
|
||||
} else version(OSX) {
|
||||
version = Nix;
|
||||
} else version(FreeBSD) {
|
||||
version = Nix;
|
||||
version = freebsd;
|
||||
} else version(freebsd) {
|
||||
version = Nix;
|
||||
} else version(Unix) {
|
||||
version = Nix;
|
||||
} else version(Posix) {
|
||||
version = Nix;
|
||||
}
|
||||
|
||||
version(Tango) {
|
||||
static import tango.stdc.string;
|
||||
static import tango.stdc.stringz;
|
||||
|
||||
version (PhobosCompatibility) {
|
||||
} else {
|
||||
alias char[] string;
|
||||
alias wchar[] wstring;
|
||||
alias dchar[] dstring;
|
||||
}
|
||||
} else {
|
||||
version(D_Version2) {
|
||||
static import std.conv;
|
||||
} else {
|
||||
static import std.c.string;
|
||||
}
|
||||
static import std.string;
|
||||
}
|
||||
|
||||
version(D_Version2) {
|
||||
mixin("alias const(char)* CCPTR;");
|
||||
} else {
|
||||
alias char* CCPTR;
|
||||
}
|
||||
|
||||
CCPTR swigToCString(string str) {
|
||||
version(Tango) {
|
||||
return tango.stdc.stringz.toStringz(str);
|
||||
} else {
|
||||
return std.string.toStringz(str);
|
||||
}
|
||||
}
|
||||
|
||||
string swigToDString(CCPTR cstr) {
|
||||
version(Tango) {
|
||||
return tango.stdc.stringz.fromStringz(cstr);
|
||||
} else {
|
||||
version(D_Version2) {
|
||||
mixin("return std.conv.to!string(cstr);");
|
||||
} else {
|
||||
return std.c.string.toString(cstr);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class SwigSwigSharedLibLoadException : Exception {
|
||||
this(in string[] libNames, in string[] reasons) {
|
||||
string msg = "Failed to load one or more shared libraries:";
|
||||
foreach(i, n; libNames) {
|
||||
msg ~= "\n\t" ~ n ~ " - ";
|
||||
if(i < reasons.length)
|
||||
msg ~= reasons[i];
|
||||
else
|
||||
msg ~= "Unknown";
|
||||
}
|
||||
super(msg);
|
||||
}
|
||||
}
|
||||
|
||||
class SwigSymbolLoadException : Exception {
|
||||
this(string SwigSharedLibName, string symbolName) {
|
||||
super("Failed to load symbol " ~ symbolName ~ " from shared library " ~ SwigSharedLibName);
|
||||
_symbolName = symbolName;
|
||||
}
|
||||
|
||||
string symbolName() {
|
||||
return _symbolName;
|
||||
}
|
||||
|
||||
private:
|
||||
string _symbolName;
|
||||
}
|
||||
|
||||
private {
|
||||
version(Nix) {
|
||||
version(freebsd) {
|
||||
// the dl* functions are in libc on FreeBSD
|
||||
}
|
||||
else {
|
||||
pragma(lib, "dl");
|
||||
}
|
||||
|
||||
version(Tango) {
|
||||
import tango.sys.Common;
|
||||
} else version(linux) {
|
||||
import core.sys.posix.dlfcn;
|
||||
} else {
|
||||
extern(C) {
|
||||
const RTLD_NOW = 2;
|
||||
|
||||
void *dlopen(CCPTR file, int mode);
|
||||
int dlclose(void* handle);
|
||||
void *dlsym(void* handle, CCPTR name);
|
||||
CCPTR dlerror();
|
||||
}
|
||||
}
|
||||
|
||||
alias void* SwigSharedLibHandle;
|
||||
|
||||
SwigSharedLibHandle swigLoadSharedLib(string libName) {
|
||||
return dlopen(swigToCString(libName), RTLD_NOW);
|
||||
}
|
||||
|
||||
void swigUnloadSharedLib(SwigSharedLibHandle hlib) {
|
||||
dlclose(hlib);
|
||||
}
|
||||
|
||||
void* swigGetSymbol(SwigSharedLibHandle hlib, string symbolName) {
|
||||
return dlsym(hlib, swigToCString(symbolName));
|
||||
}
|
||||
|
||||
string swigGetErrorStr() {
|
||||
CCPTR err = dlerror();
|
||||
if (err is null) {
|
||||
return "Unknown Error";
|
||||
}
|
||||
return swigToDString(err);
|
||||
}
|
||||
} else version(Windows) {
|
||||
alias ushort WORD;
|
||||
alias uint DWORD;
|
||||
alias CCPTR LPCSTR;
|
||||
alias void* HMODULE;
|
||||
alias void* HLOCAL;
|
||||
alias int function() FARPROC;
|
||||
struct VA_LIST {}
|
||||
|
||||
extern (Windows) {
|
||||
HMODULE LoadLibraryA(LPCSTR);
|
||||
FARPROC GetProcAddress(HMODULE, LPCSTR);
|
||||
void FreeLibrary(HMODULE);
|
||||
DWORD GetLastError();
|
||||
DWORD FormatMessageA(DWORD, in void*, DWORD, DWORD, LPCSTR, DWORD, VA_LIST*);
|
||||
HLOCAL LocalFree(HLOCAL);
|
||||
}
|
||||
|
||||
DWORD MAKELANGID(WORD p, WORD s) {
|
||||
return (((cast(WORD)s) << 10) | cast(WORD)p);
|
||||
}
|
||||
|
||||
enum {
|
||||
LANG_NEUTRAL = 0,
|
||||
SUBLANG_DEFAULT = 1,
|
||||
FORMAT_MESSAGE_ALLOCATE_BUFFER = 256,
|
||||
FORMAT_MESSAGE_IGNORE_INSERTS = 512,
|
||||
FORMAT_MESSAGE_FROM_SYSTEM = 4096
|
||||
}
|
||||
|
||||
alias HMODULE SwigSharedLibHandle;
|
||||
|
||||
SwigSharedLibHandle swigLoadSharedLib(string libName) {
|
||||
return LoadLibraryA(swigToCString(libName));
|
||||
}
|
||||
|
||||
void swigUnloadSharedLib(SwigSharedLibHandle hlib) {
|
||||
FreeLibrary(hlib);
|
||||
}
|
||||
|
||||
void* swigGetSymbol(SwigSharedLibHandle hlib, string symbolName) {
|
||||
return GetProcAddress(hlib, swigToCString(symbolName));
|
||||
}
|
||||
|
||||
string swigGetErrorStr() {
|
||||
DWORD errcode = GetLastError();
|
||||
|
||||
LPCSTR msgBuf;
|
||||
DWORD i = FormatMessageA(
|
||||
FORMAT_MESSAGE_ALLOCATE_BUFFER |
|
||||
FORMAT_MESSAGE_FROM_SYSTEM |
|
||||
FORMAT_MESSAGE_IGNORE_INSERTS,
|
||||
null,
|
||||
errcode,
|
||||
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
||||
cast(LPCSTR)&msgBuf,
|
||||
0,
|
||||
null);
|
||||
|
||||
string text = swigToDString(msgBuf);
|
||||
LocalFree(cast(HLOCAL)msgBuf);
|
||||
|
||||
if (i >= 2) {
|
||||
i -= 2;
|
||||
}
|
||||
return text[0 .. i];
|
||||
}
|
||||
} else {
|
||||
static assert(0, "Operating system not supported by the wrapper loading code.");
|
||||
}
|
||||
|
||||
final class SwigSharedLib {
|
||||
void load(string[] names) {
|
||||
if (_hlib !is null) return;
|
||||
|
||||
string[] failedLibs;
|
||||
string[] reasons;
|
||||
|
||||
foreach(n; names) {
|
||||
_hlib = swigLoadSharedLib(n);
|
||||
if (_hlib is null) {
|
||||
failedLibs ~= n;
|
||||
reasons ~= swigGetErrorStr();
|
||||
continue;
|
||||
}
|
||||
_name = n;
|
||||
break;
|
||||
}
|
||||
|
||||
if (_hlib is null) {
|
||||
throw new SwigSwigSharedLibLoadException(failedLibs, reasons);
|
||||
}
|
||||
}
|
||||
|
||||
void* loadSymbol(string symbolName, bool doThrow = true) {
|
||||
void* sym = swigGetSymbol(_hlib, symbolName);
|
||||
if(doThrow && (sym is null)) {
|
||||
throw new SwigSymbolLoadException(_name, symbolName);
|
||||
}
|
||||
return sym;
|
||||
}
|
||||
|
||||
void unload() {
|
||||
if(_hlib !is null) {
|
||||
swigUnloadSharedLib(_hlib);
|
||||
_hlib = null;
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
string _name;
|
||||
SwigSharedLibHandle _hlib;
|
||||
}
|
||||
}
|
||||
|
||||
static this() {
|
||||
string[] possibleFileNames;
|
||||
version (Posix) {
|
||||
version (OSX) {
|
||||
possibleFileNames ~= ["lib$wraplibrary.dylib", "lib$wraplibrary.bundle"];
|
||||
}
|
||||
possibleFileNames ~= ["lib$wraplibrary.so"];
|
||||
} else version (Windows) {
|
||||
possibleFileNames ~= ["$wraplibrary.dll", "lib$wraplibrary.so"];
|
||||
} else {
|
||||
static assert(false, "Operating system not supported by the wrapper loading code.");
|
||||
}
|
||||
|
||||
auto library = new SwigSharedLib;
|
||||
library.load(possibleFileNames);
|
||||
|
||||
string bindCode(string functionPointer, string symbol) {
|
||||
return functionPointer ~ " = cast(typeof(" ~ functionPointer ~
|
||||
"))library.loadSymbol(`" ~ symbol ~ "`);";
|
||||
}
|
||||
|
||||
//#if !defined(SWIG_D_NO_EXCEPTION_HELPER)
|
||||
mixin(bindCode("swigRegisterExceptionCallbacks$module", "SWIGRegisterExceptionCallbacks_$module"));
|
||||
//#endif // SWIG_D_NO_EXCEPTION_HELPER
|
||||
//#if !defined(SWIG_D_NO_STRING_HELPER)
|
||||
mixin(bindCode("swigRegisterStringCallback$module", "SWIGRegisterStringCallback_$module"));
|
||||
//#endif // SWIG_D_NO_STRING_HELPER
|
||||
$wrapperloaderbindcode
|
||||
}
|
||||
|
||||
//#if !defined(SWIG_D_NO_EXCEPTION_HELPER)
|
||||
extern(C) void function(
|
||||
SwigExceptionCallback exceptionCallback,
|
||||
SwigExceptionCallback illegalArgumentCallback,
|
||||
SwigExceptionCallback illegalElementCallback,
|
||||
SwigExceptionCallback ioCallback,
|
||||
SwigExceptionCallback noSuchElementCallback) swigRegisterExceptionCallbacks$module;
|
||||
//#endif // SWIG_D_NO_EXCEPTION_HELPER
|
||||
|
||||
//#if !defined(SWIG_D_NO_STRING_HELPER)
|
||||
extern(C) void function(SwigStringCallback callback) swigRegisterStringCallback$module;
|
||||
//#endif // SWIG_D_NO_STRING_HELPER
|
||||
%}
|
||||
|
||||
%pragma(d) wrapperloaderbindcommand = %{
|
||||
mixin(bindCode("$function", "$symbol"));%}
|
||||
|
|
@ -1,97 +0,0 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* cdata.i
|
||||
*
|
||||
* SWIG library file containing macros for manipulating raw C data as strings.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
%{
|
||||
typedef struct SWIGCDATA {
|
||||
char *data;
|
||||
intgo len;
|
||||
} SWIGCDATA;
|
||||
%}
|
||||
|
||||
%fragment("cdata", "header") %{
|
||||
struct swigcdata {
|
||||
intgo size;
|
||||
void *data;
|
||||
};
|
||||
%}
|
||||
|
||||
%typemap(gotype) SWIGCDATA "[]byte"
|
||||
|
||||
%typemap(imtype) SWIGCDATA "uint64"
|
||||
|
||||
%typemap(out, fragment="cdata") SWIGCDATA(struct swigcdata *swig_out) %{
|
||||
swig_out = (struct swigcdata *)malloc(sizeof(*swig_out));
|
||||
if (swig_out) {
|
||||
swig_out->size = $1.len;
|
||||
swig_out->data = malloc(swig_out->size);
|
||||
if (swig_out->data) {
|
||||
memcpy(swig_out->data, $1.data, swig_out->size);
|
||||
}
|
||||
}
|
||||
$result = *(long long *)(void **)&swig_out;
|
||||
%}
|
||||
|
||||
%typemap(goout) SWIGCDATA %{
|
||||
{
|
||||
type swigcdata struct { size int; data uintptr }
|
||||
p := (*swigcdata)(unsafe.Pointer(uintptr($1)))
|
||||
if p == nil || p.data == 0 {
|
||||
$result = nil
|
||||
} else {
|
||||
b := make([]byte, p.size)
|
||||
a := (*[0x7fffffff]byte)(unsafe.Pointer(p.data))[:p.size]
|
||||
copy(b, a)
|
||||
Swig_free(p.data)
|
||||
Swig_free(uintptr(unsafe.Pointer(p)))
|
||||
$result = b
|
||||
}
|
||||
}
|
||||
%}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* %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);
|
||||
|
|
@ -1,80 +0,0 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* director.swg
|
||||
*
|
||||
* This file contains support for director classes so that Go proxy
|
||||
* methods can be called from C++.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
#include <exception>
|
||||
#include <map>
|
||||
|
||||
namespace Swig {
|
||||
|
||||
class DirectorException : public std::exception {
|
||||
};
|
||||
}
|
||||
|
||||
/* Handle memory management for directors. */
|
||||
|
||||
namespace {
|
||||
struct GCItem {
|
||||
virtual ~GCItem() {}
|
||||
};
|
||||
|
||||
struct GCItem_var {
|
||||
GCItem_var(GCItem *item = 0) : _item(item) {
|
||||
}
|
||||
|
||||
GCItem_var& operator=(GCItem *item) {
|
||||
GCItem *tmp = _item;
|
||||
_item = item;
|
||||
delete tmp;
|
||||
return *this;
|
||||
}
|
||||
|
||||
~GCItem_var() {
|
||||
delete _item;
|
||||
}
|
||||
|
||||
GCItem* operator->() {
|
||||
return _item;
|
||||
}
|
||||
|
||||
private:
|
||||
GCItem *_item;
|
||||
};
|
||||
|
||||
template <typename Type>
|
||||
struct GCItem_T : GCItem {
|
||||
GCItem_T(Type *ptr) : _ptr(ptr) {
|
||||
}
|
||||
|
||||
virtual ~GCItem_T() {
|
||||
delete _ptr;
|
||||
}
|
||||
|
||||
private:
|
||||
Type *_ptr;
|
||||
};
|
||||
}
|
||||
|
||||
class Swig_memory {
|
||||
public:
|
||||
template <typename Type>
|
||||
void swig_acquire_pointer(Type* vptr) {
|
||||
if (vptr) {
|
||||
swig_owner[vptr] = new GCItem_T<Type>(vptr);
|
||||
}
|
||||
}
|
||||
private:
|
||||
typedef std::map<void *, GCItem_var> swig_ownership_map;
|
||||
swig_ownership_map swig_owner;
|
||||
};
|
||||
|
||||
template <typename Type>
|
||||
static void swig_acquire_pointer(Swig_memory** pmem, Type* ptr) {
|
||||
if (!pmem) {
|
||||
*pmem = new Swig_memory;
|
||||
}
|
||||
(*pmem)->swig_acquire_pointer(ptr);
|
||||
}
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
%typemap(throws,noblock=1) (...) {
|
||||
SWIG_exception(SWIG_RuntimeError,"unknown exception");
|
||||
}
|
||||
|
||||
%insert("runtime") %{
|
||||
#define SWIG_exception(code, msg) _swig_gopanic(msg)
|
||||
%}
|
||||
|
|
@ -1,744 +0,0 @@
|
|||
/* ------------------------------------------------------------
|
||||
* go.swg
|
||||
*
|
||||
* Go configuration module.
|
||||
* ------------------------------------------------------------ */
|
||||
|
||||
%include <gostring.swg>
|
||||
|
||||
/* Code insertion directives */
|
||||
#define %go_import(...) %insert(go_imports) %{__VA_ARGS__%}
|
||||
|
||||
/* 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"
|
||||
%typemap(gotype) long, const long & "int64"
|
||||
%typemap(gotype) unsigned long, const unsigned long & "uint64"
|
||||
%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 long &,
|
||||
const unsigned long long &,
|
||||
const float &,
|
||||
const double &
|
||||
%{ $1 = ($1_ltype)&$input; %}
|
||||
|
||||
%typemap(in) const long & ($*1_ltype temp),
|
||||
const unsigned long & ($*1_ltype temp)
|
||||
%{ temp = ($*1_ltype)$input;
|
||||
$1 = ($1_ltype)&temp; %}
|
||||
|
||||
%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(goout) bool,
|
||||
char,
|
||||
signed char,
|
||||
unsigned char,
|
||||
short,
|
||||
unsigned short,
|
||||
int,
|
||||
unsigned int,
|
||||
long,
|
||||
unsigned long,
|
||||
long long,
|
||||
unsigned long long,
|
||||
float,
|
||||
double
|
||||
""
|
||||
|
||||
%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(goout) 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 &
|
||||
""
|
||||
|
||||
%typemap(out) void ""
|
||||
|
||||
%typemap(goout) 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; %}
|
||||
|
||||
%typemap(godirectorin) bool,
|
||||
char,
|
||||
signed char,
|
||||
unsigned char,
|
||||
short,
|
||||
unsigned short,
|
||||
int,
|
||||
unsigned int,
|
||||
long,
|
||||
unsigned long,
|
||||
long long,
|
||||
unsigned long long,
|
||||
float,
|
||||
double
|
||||
""
|
||||
|
||||
%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; %}
|
||||
|
||||
%typemap(godirectorin) 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 &
|
||||
""
|
||||
|
||||
%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,warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) 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 = new $*1_ltype($input);
|
||||
swig_acquire_pointer(&swig_mem, $result);
|
||||
%}
|
||||
|
||||
/* The size_t type. */
|
||||
|
||||
%typemap(gotype) size_t, const size_t & %{int64%}
|
||||
|
||||
%typemap(in) size_t
|
||||
%{ $1 = (size_t)$input; %}
|
||||
|
||||
%typemap(in) const size_t &
|
||||
%{ $1 = ($1_ltype)&$input; %}
|
||||
|
||||
%typemap(out) size_t
|
||||
%{ $result = $1; %}
|
||||
|
||||
%typemap(goout) size_t ""
|
||||
|
||||
%typemap(out) const size_t &
|
||||
%{ $result = ($*1_ltype)*$1; %}
|
||||
|
||||
%typemap(goout) const size_t & ""
|
||||
|
||||
%typemap(directorin) size_t
|
||||
%{ $input = (size_t)$1; %}
|
||||
|
||||
%typemap(godirectorin) size_t ""
|
||||
|
||||
%typemap(directorin) const size_t &
|
||||
%{ $input = ($*1_ltype)$1; %}
|
||||
|
||||
%typemap(godirectorin) const size_t & ""
|
||||
|
||||
%typemap(directorout) size_t
|
||||
%{ $result = ($1_ltype)$input; %}
|
||||
|
||||
%typemap(directorout,warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) const size_t &
|
||||
%{
|
||||
$result = new $*1_ltype($input);
|
||||
swig_acquire_pointer(&swig_mem, $result);
|
||||
%}
|
||||
|
||||
/* Member pointers. */
|
||||
|
||||
%typemap(gotype) SWIGTYPE (CLASS::*)
|
||||
%{$gotypename%}
|
||||
|
||||
%typemap(in) SWIGTYPE (CLASS::*)
|
||||
%{ $1 = *($&1_ltype)$input; %}
|
||||
|
||||
%typemap(out) SWIGTYPE (CLASS::*)
|
||||
%{
|
||||
struct swig_out_type { intgo size; void* val; } *swig_out;
|
||||
swig_out = (struct swig_out_type*)malloc(sizeof(*swig_out));
|
||||
if (swig_out) {
|
||||
swig_out->size = sizeof($1_ltype);
|
||||
swig_out->val = malloc(swig_out->size);
|
||||
if (swig_out->val) {
|
||||
*($&1_ltype)(swig_out->val) = $1;
|
||||
}
|
||||
}
|
||||
$result = swig_out;
|
||||
%}
|
||||
|
||||
%typemap(goout) SWIGTYPE (CLASS::*)
|
||||
%{
|
||||
{
|
||||
type swig_out_type struct { size int; val uintptr }
|
||||
p := (*swig_out_type)(unsafe.Pointer($1))
|
||||
if p == nil || p.val == 0 {
|
||||
$result = nil
|
||||
} else {
|
||||
m := make([]byte, p.size)
|
||||
a := (*[1024]byte)(unsafe.Pointer(p.val))[:p.size]
|
||||
copy(m, a)
|
||||
Swig_free(p.val)
|
||||
Swig_free(uintptr(unsafe.Pointer(p)))
|
||||
$result = &m[0]
|
||||
}
|
||||
}
|
||||
%}
|
||||
|
||||
%typemap(directorin) SWIGTYPE (CLASS::*)
|
||||
%{ $input = *($&1_ltype)$1; %}
|
||||
|
||||
%typemap(godirectorin) SWIGTYPE (CLASS::*) ""
|
||||
|
||||
%typemap(directorout) SWIGTYPE (CLASS::*)
|
||||
%{
|
||||
$result = new $1_ltype($input);
|
||||
swig_acquire_pointer(&swig_mem, $result);
|
||||
%}
|
||||
|
||||
/* 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_ltype)$1; %}
|
||||
|
||||
%typemap(goout) SWIGTYPE * ""
|
||||
|
||||
%typemap(directorin) SWIGTYPE *
|
||||
%{ *($&1_ltype)&$input = ($1_ltype)$1; %}
|
||||
|
||||
%typemap(godirectorin) SWIGTYPE * ""
|
||||
|
||||
%typemap(directorout) SWIGTYPE *
|
||||
%{ $result = *($&1_ltype)&$input; %}
|
||||
|
||||
/* 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; %}
|
||||
|
||||
%typemap(goout) SWIGTYPE *const& ""
|
||||
|
||||
/* 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(goout) SWIGTYPE & ""
|
||||
|
||||
%typemap(directorin) SWIGTYPE &
|
||||
%{ $input = ($1_ltype)&$1; %}
|
||||
|
||||
%typemap(godirectorin) SWIGTYPE & ""
|
||||
|
||||
%typemap(directorout) SWIGTYPE &
|
||||
%{ *($&1_ltype)&$result = $input; %}
|
||||
|
||||
%typemap(directorout, warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) SWIGTYPE *const&
|
||||
%{ static $*1_ltype swig_temp;
|
||||
swig_temp = *($1_ltype)&$input;
|
||||
$result = &swig_temp; %}
|
||||
|
||||
%typemap(gotype) SWIGTYPE &&
|
||||
%{$gotypename%}
|
||||
|
||||
%typemap(in, fragment="<memory>") SWIGTYPE && (std::unique_ptr<$*1_ltype> rvrdeleter)
|
||||
%{ $1 = *($&1_ltype)&$input;
|
||||
rvrdeleter.reset($1); %}
|
||||
|
||||
%typemap(out) SWIGTYPE &&
|
||||
%{ *($&1_ltype)&$result = $1; %}
|
||||
|
||||
%typemap(goout) SWIGTYPE && ""
|
||||
|
||||
%typemap(directorin) SWIGTYPE &&
|
||||
%{ $input = ($1_ltype)&$1_name; %}
|
||||
|
||||
%typemap(godirectorin) SWIGTYPE && ""
|
||||
|
||||
%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(goout) SWIGTYPE [] ""
|
||||
|
||||
%typemap(directorin) SWIGTYPE []
|
||||
%{ $input = *($1_ltype)&$1; %}
|
||||
|
||||
%typemap(godirectorin) SWIGTYPE [] ""
|
||||
|
||||
%typemap(directorout) SWIGTYPE []
|
||||
%{ *($&1_ltype)&$result = $input; %}
|
||||
|
||||
/* Strings. */
|
||||
|
||||
%typemap(gotype)
|
||||
char *, char *&, char[ANY], 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[]
|
||||
%{
|
||||
$1 = ($1_ltype)malloc($input.n + 1);
|
||||
memcpy($1, $input.p, $input.n);
|
||||
$1[$input.n] = '\0';
|
||||
%}
|
||||
|
||||
%typemap(in) char *& (char *temp)
|
||||
%{
|
||||
temp = (char *)malloc($input.n + 1);
|
||||
memcpy(temp, $input.p, $input.n);
|
||||
temp[$input.n] = '\0';
|
||||
$1 = ($1_ltype)&temp;
|
||||
%}
|
||||
|
||||
%typemap(freearg)
|
||||
char *, char[ANY], char[]
|
||||
%{ free($1); %}
|
||||
|
||||
%typemap(freearg) char *&
|
||||
%{ free(temp$argnum); %}
|
||||
|
||||
%typemap(out,fragment="AllocateString")
|
||||
char *, char *&, char[ANY], char[]
|
||||
%{ $result = Swig_AllocateString((char*)$1, $1 ? strlen((char*)$1) : 0); %}
|
||||
|
||||
%typemap(goout,fragment="CopyString")
|
||||
char *, char *&, char[ANY], char[]
|
||||
%{ $result = swigCopyString($1) %}
|
||||
|
||||
%typemap(directorin,fragment="AllocateString")
|
||||
char *, char *&, char[ANY], char[]
|
||||
%{
|
||||
$input = Swig_AllocateString((char*)$1, $1 ? strlen((char*)$1) : 0);
|
||||
%}
|
||||
|
||||
%typemap(godirectorin,fragment="CopyString")
|
||||
char *, char *&, char[ANY], char[]
|
||||
%{
|
||||
$result = swigCopyString($input)
|
||||
%}
|
||||
|
||||
%typemap(godirectorout)
|
||||
char *, char *&, char[ANY], char[]
|
||||
%{
|
||||
{
|
||||
p := Swig_malloc(len($input) + 1)
|
||||
s := (*[1<<30]byte)(unsafe.Pointer(p))[:len($input) + 1]
|
||||
copy(s, $input)
|
||||
s[len($input)] = 0
|
||||
$result = *(*string)(unsafe.Pointer(&s))
|
||||
}
|
||||
%}
|
||||
|
||||
%typemap(directorout, warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG)
|
||||
char *, char *&, char[ANY], char[]
|
||||
%{ $result = ($1_ltype)$input.p; %}
|
||||
|
||||
/* String & length */
|
||||
|
||||
%typemap(gotype) (char *STRING, size_t LENGTH) "string"
|
||||
|
||||
%typemap(in) (char *STRING, size_t LENGTH)
|
||||
%{
|
||||
$1 = ($1_ltype)$input.p;
|
||||
$2 = ($2_ltype)$input.n;
|
||||
%}
|
||||
|
||||
%typemap(out,fragment="AllocateString") (char *STRING, size_t LENGTH)
|
||||
%{ $result = Swig_AllocateString((char*)$1, (size_t)$2); %}
|
||||
|
||||
%typemap(goout,fragment="CopyString") (char *STRING, size_t LENGTH)
|
||||
%{ $result = swigCopyString($1) %}
|
||||
|
||||
%typemap(directorin,fragment="AllocateString") (char *STRING, size_t LENGTH)
|
||||
%{ $input = Swig_AllocateString((char*)$1, $2); %}
|
||||
|
||||
%typemap(godirectorin,fragment="CopyString") (char *STRING, size_t LENGTH)
|
||||
%{ $result = swigCopyString($input) %}
|
||||
|
||||
%typemap(directorout) (char *STRING, size_t LENGTH)
|
||||
%{
|
||||
$1 = ($1_ltype)$input.p;
|
||||
$2 = ($2_ltype)$input.n;
|
||||
%}
|
||||
|
||||
/* The int & type needs to convert to intgo. */
|
||||
|
||||
%typemap(gotype) int & "*int"
|
||||
|
||||
%typemap(in) int & (int e)
|
||||
%{
|
||||
e = (int)*$input;
|
||||
$1 = &e;
|
||||
%}
|
||||
|
||||
%typemap(out) int &
|
||||
%{ $result = new intgo(*$1); %}
|
||||
|
||||
%typemap(argout) int &
|
||||
%{ *$input = (intgo)e$argnum; %}
|
||||
|
||||
%typemap(goout) int & ""
|
||||
|
||||
%typemap(directorin) int & (intgo e)
|
||||
%{
|
||||
e = (intgo)$1;
|
||||
$input = &e;
|
||||
%}
|
||||
|
||||
%typemap(godirectorin) int & ""
|
||||
|
||||
%typemap(directorout) int &
|
||||
%{
|
||||
$*1_ltype f = ($*1_ltype)*$input;
|
||||
$result = ($1_ltype)&f;
|
||||
%}
|
||||
|
||||
%typemap(directorargout) int &
|
||||
%{ $1 = (int)*$input; %}
|
||||
|
||||
%typemap(argout) const int & ""
|
||||
%typemap(directorargout) const int & ""
|
||||
|
||||
/* 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 = (intgo)$1; %}
|
||||
|
||||
%typemap(goout) enum SWIGTYPE ""
|
||||
|
||||
%typemap(directorin) enum SWIGTYPE
|
||||
%{ $input = (intgo)$1; %}
|
||||
|
||||
%typemap(godirectorin) enum SWIGTYPE ""
|
||||
|
||||
%typemap(directorout) enum SWIGTYPE
|
||||
%{ $result = ($1_ltype)$input; %}
|
||||
|
||||
%typemap(directorin) enum SWIGTYPE & (intgo e)
|
||||
%{
|
||||
e = (intgo)$1;
|
||||
$input = ($1_ltype)&e;
|
||||
%}
|
||||
|
||||
%typemap(godirectorin) enum SWIGTYPE & ""
|
||||
|
||||
%typemap(directorout) enum SWIGTYPE &
|
||||
%{ $result = $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(goout) SWIGTYPE ""
|
||||
|
||||
%typemap(directorin) SWIGTYPE
|
||||
%{ $input = new $1_ltype(SWIG_STD_MOVE($1)); %}
|
||||
|
||||
%typemap(godirectorin) SWIGTYPE ""
|
||||
|
||||
%typemap(directorout) SWIGTYPE
|
||||
%{ $result = *($&1_ltype)$input; %}
|
||||
|
||||
/* Exception handling */
|
||||
|
||||
%typemap(throws) char *
|
||||
%{ _swig_gopanic($1); %}
|
||||
|
||||
%typemap(throws) SWIGTYPE, 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 &
|
||||
""
|
||||
|
||||
%typecheck(SWIG_TYPECHECK_INT64) /* Go int64 */
|
||||
long,
|
||||
const long &,
|
||||
long long,
|
||||
const long long &
|
||||
""
|
||||
|
||||
%typecheck(SWIG_TYPECHECK_INT64) /* Go uint64 */
|
||||
unsigned long,
|
||||
const unsigned long &,
|
||||
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 &&,
|
||||
SWIGTYPE *const&,
|
||||
SWIGTYPE [],
|
||||
SWIGTYPE (CLASS::*)
|
||||
""
|
||||
|
||||
%apply SWIGTYPE * { SWIGTYPE *const }
|
||||
%apply SWIGTYPE (CLASS::*) { SWIGTYPE (CLASS::*const) }
|
||||
%apply SWIGTYPE & { SWIGTYPE (CLASS::*const&) }
|
||||
|
||||
/* Go keywords. */
|
||||
%include <gokw.swg>
|
||||
|
||||
%include <goruntime.swg>
|
||||
|
|
@ -1,33 +0,0 @@
|
|||
/* Rename keywords. */
|
||||
|
||||
#define GOKW(x) %keywordwarn("'" `x` "' is a Go keyword",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
|
||||
|
|
@ -1,217 +0,0 @@
|
|||
/* ------------------------------------------------------------
|
||||
* goruntime.swg
|
||||
*
|
||||
* Go runtime code for the various generated files.
|
||||
* ------------------------------------------------------------ */
|
||||
|
||||
%inline %{
|
||||
static void Swig_free(void* p) {
|
||||
free(p);
|
||||
}
|
||||
|
||||
static void* Swig_malloc(int c) {
|
||||
return malloc(c);
|
||||
}
|
||||
%}
|
||||
|
||||
%insert(runtime) %{
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
%}
|
||||
|
||||
%insert(cgo_comment_typedefs) %{
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
%}
|
||||
|
||||
#if SWIGGO_INTGO_SIZE == 32
|
||||
%insert(runtime) %{
|
||||
typedef int intgo;
|
||||
typedef unsigned int uintgo;
|
||||
%}
|
||||
%insert(cgo_comment_typedefs) %{
|
||||
typedef int intgo;
|
||||
typedef unsigned int uintgo;
|
||||
%}
|
||||
#elif SWIGGO_INTGO_SIZE == 64
|
||||
%insert(runtime) %{
|
||||
typedef long long intgo;
|
||||
typedef unsigned long long uintgo;
|
||||
%}
|
||||
%insert(cgo_comment_typedefs) %{
|
||||
typedef long long intgo;
|
||||
typedef unsigned long long uintgo;
|
||||
%}
|
||||
#else
|
||||
%insert(runtime) %{
|
||||
typedef ptrdiff_t intgo;
|
||||
typedef size_t uintgo;
|
||||
%}
|
||||
%insert(cgo_comment_typedefs) %{
|
||||
typedef ptrdiff_t intgo;
|
||||
typedef size_t uintgo;
|
||||
%}
|
||||
#endif
|
||||
|
||||
#ifndef SWIGGO_GCCGO
|
||||
// Set the host compiler struct attribute that will be
|
||||
// used to match gc's struct layout. For example, on 386 Windows,
|
||||
// gcc wants to 8-align int64s, but gc does not.
|
||||
// Use __gcc_struct__ to work around http://gcc.gnu.org/PR52991 on x86,
|
||||
// and https://golang.org/issue/5603.
|
||||
// See: https://github.com/golang/go/blob/fcbf04f9b93b4cd8addd05c2ed784118eb50a46c/src/cmd/cgo/out.go#L663
|
||||
%insert(runtime) %{
|
||||
# if !defined(__clang__) && (defined(__i386__) || defined(__x86_64__))
|
||||
# define SWIGSTRUCTPACKED __attribute__((__packed__, __gcc_struct__))
|
||||
# else
|
||||
# define SWIGSTRUCTPACKED __attribute__((__packed__))
|
||||
# endif
|
||||
%}
|
||||
#else
|
||||
# define SWIGSTRUCTPACKED
|
||||
#endif
|
||||
|
||||
%insert(runtime) %{
|
||||
|
||||
typedef struct { char *p; intgo n; } _gostring_;
|
||||
typedef struct { void* array; intgo len; intgo cap; } _goslice_;
|
||||
|
||||
%}
|
||||
|
||||
%insert(cgo_comment_typedefs) %{
|
||||
|
||||
typedef struct { char *p; intgo n; } _gostring_;
|
||||
typedef struct { void* array; intgo len; intgo cap; } _goslice_;
|
||||
|
||||
%}
|
||||
|
||||
#ifdef SWIGGO_GCCGO
|
||||
|
||||
/* Boilerplate for C/C++ code when using gccgo. */
|
||||
%insert(runtime) %{
|
||||
#define SWIGGO_GCCGO
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
extern void *_cgo_allocate(size_t);
|
||||
extern void _cgo_panic(const char *);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#define _swig_goallocate _cgo_allocate
|
||||
#define _swig_gopanic _cgo_panic
|
||||
%}
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef SWIGGO_GCCGO
|
||||
|
||||
%go_import("unsafe", _ "runtime/cgo")
|
||||
|
||||
#else
|
||||
|
||||
%go_import("syscall", "unsafe")
|
||||
|
||||
%insert(go_header) %{
|
||||
|
||||
type _ syscall.Sockaddr
|
||||
|
||||
%}
|
||||
|
||||
#endif
|
||||
|
||||
%insert(go_header) %{
|
||||
|
||||
type _ unsafe.Pointer
|
||||
|
||||
%}
|
||||
|
||||
/* Swig_always_false is used to conditionally assign parameters to
|
||||
Swig_escape_val so that the compiler thinks that they escape. We
|
||||
only assign them if Swig_always_false is true, which it never is.
|
||||
We export the variable so that the compiler doesn't realize that it
|
||||
is never set. */
|
||||
%insert(go_header) %{
|
||||
var Swig_escape_always_false bool
|
||||
var Swig_escape_val interface{}
|
||||
%}
|
||||
|
||||
/* 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
|
||||
%}
|
||||
|
||||
/* Convert a Go interface value into a C++ pointer. */
|
||||
|
||||
%insert(go_header) %{
|
||||
func getSwigcptr(v interface { Swigcptr() uintptr }) uintptr {
|
||||
if v == nil {
|
||||
return 0
|
||||
}
|
||||
return v.Swigcptr()
|
||||
}
|
||||
%}
|
||||
|
||||
/* For directors we need C++ to track a Go pointer. Since we can't
|
||||
pass a Go pointer into C++, we use a map to track the pointers on
|
||||
the Go side. */
|
||||
|
||||
%go_import("sync")
|
||||
|
||||
%insert(go_header) %{
|
||||
type _ sync.Mutex
|
||||
%}
|
||||
|
||||
%insert(go_director) %{
|
||||
|
||||
var swigDirectorTrack struct {
|
||||
sync.Mutex
|
||||
m map[int]interface{}
|
||||
c int
|
||||
}
|
||||
|
||||
func swigDirectorAdd(v interface{}) int {
|
||||
swigDirectorTrack.Lock()
|
||||
defer swigDirectorTrack.Unlock()
|
||||
if swigDirectorTrack.m == nil {
|
||||
swigDirectorTrack.m = make(map[int]interface{})
|
||||
}
|
||||
swigDirectorTrack.c++
|
||||
ret := swigDirectorTrack.c
|
||||
swigDirectorTrack.m[ret] = v
|
||||
return ret
|
||||
}
|
||||
|
||||
func swigDirectorLookup(c int) interface{} {
|
||||
swigDirectorTrack.Lock()
|
||||
defer swigDirectorTrack.Unlock()
|
||||
ret := swigDirectorTrack.m[c]
|
||||
if ret == nil {
|
||||
panic("C++ director pointer not found (possible use-after-free)")
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
func swigDirectorDelete(c int) {
|
||||
swigDirectorTrack.Lock()
|
||||
defer swigDirectorTrack.Unlock()
|
||||
if swigDirectorTrack.m[c] == nil {
|
||||
if c > swigDirectorTrack.c {
|
||||
panic("C++ director pointer invalid (possible memory corruption")
|
||||
} else {
|
||||
panic("C++ director pointer not found (possible use-after-free)")
|
||||
}
|
||||
}
|
||||
delete(swigDirectorTrack.m, c)
|
||||
}
|
||||
|
||||
%}
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
/* ------------------------------------------------------------
|
||||
* gostring.swg
|
||||
*
|
||||
* Support for returning strings from C to Go.
|
||||
* ------------------------------------------------------------ */
|
||||
|
||||
// C/C++ code to convert a memory buffer into a Go string allocated in
|
||||
// C/C++ memory.
|
||||
%fragment("AllocateString", "runtime") %{
|
||||
static _gostring_ Swig_AllocateString(const char *p, size_t l) {
|
||||
_gostring_ ret;
|
||||
ret.p = (char*)malloc(l);
|
||||
memcpy(ret.p, p, l);
|
||||
ret.n = l;
|
||||
return ret;
|
||||
}
|
||||
%}
|
||||
|
||||
// Go code to convert a string allocated in C++ memory to one
|
||||
// allocated in Go memory.
|
||||
%fragment("CopyString", "go_runtime") %{
|
||||
type swig_gostring struct { p uintptr; n int }
|
||||
func swigCopyString(s string) string {
|
||||
p := *(*swig_gostring)(unsafe.Pointer(&s))
|
||||
r := string((*[0x7fffffff]byte)(unsafe.Pointer(p.p))[:p.n])
|
||||
Swig_free(p.p)
|
||||
return r
|
||||
}
|
||||
%}
|
||||
|
|
@ -1,43 +0,0 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* std_array.i
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
%include <std_common.i>
|
||||
|
||||
namespace std {
|
||||
|
||||
template<class T, size_t N> class array {
|
||||
public:
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef T value_type;
|
||||
typedef value_type* pointer;
|
||||
typedef const value_type* const_pointer;
|
||||
typedef value_type& reference;
|
||||
typedef const value_type& const_reference;
|
||||
|
||||
array();
|
||||
array(const array& other);
|
||||
|
||||
size_type size() const;
|
||||
%rename(isEmpty) empty;
|
||||
bool empty() const;
|
||||
void fill(const T& u);
|
||||
%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("array 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("array index out of range");
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
%include <std_except.i>
|
||||
|
||||
%apply size_t { std::size_t };
|
||||
%apply const size_t& { const std::size_t& };
|
||||
|
|
@ -1 +0,0 @@
|
|||
%include <std/_std_deque.i>
|
||||
|
|
@ -1,31 +0,0 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* 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 <typeinfo>
|
||||
#include <stdexcept>
|
||||
%}
|
||||
|
||||
namespace std
|
||||
{
|
||||
%ignore exception;
|
||||
struct exception {};
|
||||
}
|
||||
|
||||
%typemap(throws) std::bad_cast %{_swig_gopanic($1.what());%}
|
||||
%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());%}
|
||||
|
|
@ -1,41 +0,0 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* std_list.i
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
%{
|
||||
#include <list>
|
||||
#include <stdexcept>
|
||||
%}
|
||||
|
||||
namespace std {
|
||||
|
||||
template<class T>
|
||||
class list {
|
||||
public:
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef T value_type;
|
||||
typedef value_type* pointer;
|
||||
typedef const value_type* const_pointer;
|
||||
typedef value_type& reference;
|
||||
typedef const value_type& const_reference;
|
||||
|
||||
list();
|
||||
list(const list& other);
|
||||
|
||||
size_type size() const;
|
||||
bool empty() const;
|
||||
%rename(isEmpty) empty;
|
||||
void clear();
|
||||
void push_front(const value_type& x);
|
||||
void pop_front();
|
||||
void push_back(const value_type& x);
|
||||
void pop_back();
|
||||
void remove(value_type x);
|
||||
void reverse();
|
||||
void unique();
|
||||
void sort();
|
||||
void merge(list& x);
|
||||
};
|
||||
|
||||
}
|
||||
|
|
@ -1,66 +0,0 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* 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 C = std::less<K> > class map {
|
||||
// add typemaps here
|
||||
public:
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef K key_type;
|
||||
typedef T mapped_type;
|
||||
typedef std::pair< const K, T > value_type;
|
||||
typedef value_type* pointer;
|
||||
typedef const value_type* const_pointer;
|
||||
typedef value_type& reference;
|
||||
typedef const value_type& const_reference;
|
||||
|
||||
map();
|
||||
map(const map& other);
|
||||
|
||||
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, C >::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, C >::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, C >::iterator i = self->find(key);
|
||||
return i != self->end();
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
@ -1,36 +0,0 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* 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 {
|
||||
typedef T first_type;
|
||||
typedef U second_type;
|
||||
|
||||
pair();
|
||||
pair(T first, U second);
|
||||
pair(const pair& other);
|
||||
|
||||
template <class U1, class U2> pair(const pair<U1, U2> &other);
|
||||
|
||||
T first;
|
||||
U second;
|
||||
};
|
||||
|
||||
// add specializations here
|
||||
|
||||
}
|
||||
|
|
@ -1,162 +0,0 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* 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(godirectorout) string
|
||||
%{
|
||||
{
|
||||
p := Swig_malloc(len($input))
|
||||
s := (*[1<<30]byte)(unsafe.Pointer(p))[:len($input)]
|
||||
copy(s, $input)
|
||||
$result = *(*string)(unsafe.Pointer(&s))
|
||||
}
|
||||
%}
|
||||
|
||||
%typemap(directorout) string
|
||||
%{
|
||||
$result.assign($input.p, $input.n);
|
||||
free($input.p);
|
||||
%}
|
||||
|
||||
%typemap(out,fragment="AllocateString") string
|
||||
%{ $result = Swig_AllocateString($1.data(), $1.length()); %}
|
||||
|
||||
%typemap(goout,fragment="CopyString") string
|
||||
%{ $result = swigCopyString($1) %}
|
||||
|
||||
%typemap(directorin,fragment="AllocateString") string
|
||||
%{ $input = Swig_AllocateString($1.data(), $1.length()); %}
|
||||
|
||||
%typemap(godirectorin,fragment="CopyString") string
|
||||
%{ $result = swigCopyString($input) %}
|
||||
|
||||
%typemap(throws) string
|
||||
%{ _swig_gopanic($1.c_str()); %}
|
||||
|
||||
%typemap(in) const string &
|
||||
%{
|
||||
$*1_ltype $1_str($input.p, $input.n);
|
||||
$1 = &$1_str;
|
||||
%}
|
||||
|
||||
%typemap(godirectorout) const string &
|
||||
%{
|
||||
{
|
||||
p := Swig_malloc(len($input))
|
||||
s := (*[1<<30]byte)(unsafe.Pointer(p))[:len($input)]
|
||||
copy(s, $input)
|
||||
$result = *(*string)(unsafe.Pointer(&s))
|
||||
}
|
||||
%}
|
||||
|
||||
%typemap(directorout,warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const string &
|
||||
%{
|
||||
static $*1_ltype $1_str;
|
||||
$1_str.assign($input.p, $input.n);
|
||||
free($input.p);
|
||||
$result = &$1_str;
|
||||
%}
|
||||
|
||||
%typemap(out,fragment="AllocateString") const string &
|
||||
%{ $result = Swig_AllocateString((*$1).data(), (*$1).length()); %}
|
||||
|
||||
%typemap(goout,fragment="CopyString") const string &
|
||||
%{ $result = swigCopyString($1) %}
|
||||
|
||||
%typemap(directorin,fragment="AllocateString") const string &
|
||||
%{ $input = Swig_AllocateString($1.data(), $1.length()); %}
|
||||
|
||||
%typemap(godirectorin,fragment="CopyString") const string &
|
||||
%{ $result = swigCopyString($input) %}
|
||||
|
||||
%typemap(throws) const string &
|
||||
%{ _swig_gopanic($1.c_str()); %}
|
||||
|
||||
|
||||
%typemap(gotype) string * "*string"
|
||||
|
||||
%typemap(in) string * (string temp)
|
||||
%{
|
||||
if ($input) {
|
||||
temp.assign($input->p, $input->n);
|
||||
$1 = &temp;
|
||||
} else
|
||||
$1 = 0;
|
||||
%}
|
||||
|
||||
%typemap(godirectorout) string *
|
||||
%{
|
||||
if $input != nil {
|
||||
p := Swig_malloc(len(*$input))
|
||||
s := (*[1<<30]byte)(unsafe.Pointer(p))[:len(*$input)]
|
||||
copy(s, *$input)
|
||||
$result = (*string)(unsafe.Pointer(&s))
|
||||
} else {
|
||||
$result = nil
|
||||
}
|
||||
%}
|
||||
|
||||
%typemap(directorout) string * (string temp)
|
||||
%{
|
||||
temp.assign($input->p, $input->n);
|
||||
$result = &temp;
|
||||
free($input.p);
|
||||
%}
|
||||
|
||||
%typemap(out,fragment="AllocateString") string * (_gostring_ temp)
|
||||
%{
|
||||
temp = Swig_AllocateString($1->data(), $1->length());
|
||||
$result = &temp;
|
||||
%}
|
||||
|
||||
%typemap(goout,fragment="CopyString") string *
|
||||
%{ *$result = swigCopyString(*$1) %}
|
||||
|
||||
%typemap(directorin,fragment="AllocateString") string * (_gostring_ temp)
|
||||
%{
|
||||
if ($1) {
|
||||
temp = Swig_AllocateString($1->data(), $1->length());
|
||||
$input = &temp;
|
||||
} else
|
||||
$input = 0;
|
||||
%}
|
||||
|
||||
%typemap(godirectorin,fragment="CopyString") string *
|
||||
%{ *$result = swigCopyString(*$input); %}
|
||||
|
||||
%typemap(argout,fragment="AllocateString") string *
|
||||
%{
|
||||
if ($1)
|
||||
*$input = Swig_AllocateString($1->data(), $1->length());
|
||||
%}
|
||||
|
||||
%typemap(goargout,fragment="CopyString") string *
|
||||
%{
|
||||
if $input != nil {
|
||||
*$1 = swigCopyString(*$input)
|
||||
}
|
||||
%}
|
||||
|
||||
}
|
||||
|
|
@ -1,92 +0,0 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* std_vector.i
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
%{
|
||||
#include <vector>
|
||||
#include <stdexcept>
|
||||
%}
|
||||
|
||||
namespace std {
|
||||
|
||||
template<class T> class vector {
|
||||
public:
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef T value_type;
|
||||
typedef value_type* pointer;
|
||||
typedef const value_type* const_pointer;
|
||||
typedef value_type& reference;
|
||||
typedef const value_type& const_reference;
|
||||
|
||||
vector();
|
||||
vector(size_type n);
|
||||
vector(const vector& other);
|
||||
|
||||
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 ptrdiff_t difference_type;
|
||||
typedef bool value_type;
|
||||
typedef value_type* pointer;
|
||||
typedef const value_type* const_pointer;
|
||||
typedef value_type& reference;
|
||||
typedef bool const_reference;
|
||||
|
||||
vector();
|
||||
vector(size_type n);
|
||||
vector(const vector& other);
|
||||
|
||||
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 {
|
||||
bool 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");
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* stl.i
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
%include <std_common.i>
|
||||
%include <std_string.i>
|
||||
%include <std_vector.i>
|
||||
%include <std_map.i>
|
||||
%include <std_pair.i>
|
||||
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* swigmove.i
|
||||
*
|
||||
* Input typemaps library for implementing full move semantics when passing
|
||||
* parameters by value.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
%typemap(in) SWIGTYPE MOVE ($&1_type argp)
|
||||
%{
|
||||
argp = ($&1_ltype)$input;
|
||||
if (argp == NULL) {
|
||||
_swig_gopanic("Attempt to dereference null $1_type");
|
||||
}
|
||||
SwigValueWrapper< $1_ltype >::reset($1, argp);
|
||||
%}
|
||||
|
|
@ -1,298 +0,0 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* 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, TYPE &INPUT
|
||||
%{ $1 = ($1_ltype)&$input; %}
|
||||
|
||||
%typemap(out) TYPE *INPUT, TYPE &INPUT ""
|
||||
|
||||
%typemap(goout) TYPE *INPUT, TYPE &INPUT ""
|
||||
|
||||
%typemap(freearg) TYPE *INPUT, TYPE &INPUT ""
|
||||
|
||||
%typemap(argout) TYPE *INPUT, TYPE &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, float32);
|
||||
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), TYPE &OUTPUT($*1_ltype temp)
|
||||
{
|
||||
if ($input.len == 0) {
|
||||
_swig_gopanic("array must contain at least 1 element");
|
||||
}
|
||||
$1 = &temp;
|
||||
}
|
||||
|
||||
%typemap(out) TYPE *OUTPUT, TYPE &OUTPUT ""
|
||||
|
||||
%typemap(goout) TYPE *INPUT, TYPE &INPUT ""
|
||||
|
||||
%typemap(freearg) TYPE *OUTPUT, TYPE &OUTPUT ""
|
||||
|
||||
%typemap(argout) TYPE *OUTPUT, TYPE &OUTPUT
|
||||
{
|
||||
TYPE* a = (TYPE *) $input.array;
|
||||
a[0] = temp$argnum;
|
||||
}
|
||||
|
||||
%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, float32);
|
||||
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, TYPE &INOUT {
|
||||
if ($input.len == 0) {
|
||||
_swig_gopanic("array must contain at least 1 element");
|
||||
}
|
||||
$1 = ($1_ltype) $input.array;
|
||||
}
|
||||
|
||||
%typemap(out) TYPE *INOUT, TYPE &INOUT ""
|
||||
|
||||
%typemap(goout) TYPE *INOUT, TYPE &INOUT ""
|
||||
|
||||
%typemap(freearg) TYPE *INOUT, TYPE &INOUT ""
|
||||
|
||||
%typemap(argout) 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, float32);
|
||||
INOUT_TYPEMAP(double, float64);
|
||||
|
||||
#undef INOUT_TYPEMAP
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
|
||||
co:
|
||||
co RCS/*.i* RCS/*.swg*
|
||||
|
|
@ -1,70 +0,0 @@
|
|||
;;;************************************************************************
|
||||
;;;*common.scm
|
||||
;;;*
|
||||
;;;* This file contains generic SWIG GOOPS classes for generated
|
||||
;;;* GOOPS file support
|
||||
;;;************************************************************************
|
||||
|
||||
(define-module (Swig swigrun))
|
||||
|
||||
(define-module (Swig common)
|
||||
#:use-module (oop goops)
|
||||
#:use-module (Swig swigrun))
|
||||
|
||||
(define-class <swig-metaclass> (<class>)
|
||||
(new-function #:init-value #f))
|
||||
|
||||
(define-method (initialize (class <swig-metaclass>) initargs)
|
||||
(slot-set! class 'new-function (get-keyword #:new-function initargs #f))
|
||||
(next-method))
|
||||
|
||||
(define-class <swig> ()
|
||||
(swig-smob #:init-value #f)
|
||||
#:metaclass <swig-metaclass>
|
||||
)
|
||||
|
||||
(define-method (initialize (obj <swig>) initargs)
|
||||
(next-method)
|
||||
(slot-set! obj 'swig-smob
|
||||
(let ((arg (get-keyword #:init-smob initargs #f)))
|
||||
(if arg
|
||||
arg
|
||||
(let ((ret (apply (slot-ref (class-of obj) 'new-function) (get-keyword #:args initargs '()))))
|
||||
;; if the class is registered with runtime environment,
|
||||
;; new-Function will return a <swig> goops class. In that case, extract the smob
|
||||
;; from that goops class and set it as the current smob.
|
||||
(if (slot-exists? ret 'swig-smob)
|
||||
(slot-ref ret 'swig-smob)
|
||||
ret))))))
|
||||
|
||||
(define (display-address o file)
|
||||
(display (number->string (object-address o) 16) file))
|
||||
|
||||
(define (display-pointer-address o file)
|
||||
;; Don't fail if the function SWIG-PointerAddress is not present.
|
||||
(let ((address (false-if-exception (SWIG-PointerAddress o))))
|
||||
(if address
|
||||
(begin
|
||||
(display " @ " file)
|
||||
(display (number->string address 16) file)))))
|
||||
|
||||
(define-method (write (o <swig>) file)
|
||||
;; We display _two_ addresses to show the object's identity:
|
||||
;; * first the address of the GOOPS proxy object,
|
||||
;; * second the pointer address.
|
||||
;; The reason is that proxy objects are created and discarded on the
|
||||
;; fly, so different proxy objects for the same C object will appear.
|
||||
(let ((class (class-of o)))
|
||||
(if (slot-bound? class 'name)
|
||||
(begin
|
||||
(display "#<" file)
|
||||
(display (class-name class) file)
|
||||
(display #\space file)
|
||||
(display-address o file)
|
||||
(display-pointer-address o file)
|
||||
(display ">" file))
|
||||
(next-method))))
|
||||
|
||||
(export <swig-metaclass> <swig>)
|
||||
|
||||
;;; common.scm ends here
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* cplusplus.i
|
||||
*
|
||||
* SWIG typemaps for C++
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
%typemap(guile,out) string, std::string {
|
||||
$result = SWIG_str02scm(const_cast<char*>($1.c_str()));
|
||||
}
|
||||
%typemap(guile,in) string, std::string {
|
||||
$1 = SWIG_scm2str($input);
|
||||
}
|
||||
|
||||
%typemap(guile,out) complex, complex<double>, std::complex<double> {
|
||||
$result = scm_make_rectangular( scm_from_double ($1.real ()),
|
||||
scm_from_double ($1.imag ()) );
|
||||
}
|
||||
%typemap(guile,in) complex, complex<double>, std::complex<double> {
|
||||
$1 = std::complex<double>( scm_to_double (scm_real_part ($input)),
|
||||
scm_to_double (scm_imag_part ($input)) );
|
||||
}
|
||||
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
# see top-level Makefile.in
|
||||
common.scm
|
||||
|
|
@ -1,33 +0,0 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* guile.i
|
||||
*
|
||||
* SWIG Configuration File for Guile.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
/* Macro for inserting Scheme code into the stub */
|
||||
#define %scheme %insert("scheme")
|
||||
#define %goops %insert("goops")
|
||||
|
||||
/* Return-styles */
|
||||
%pragma(guile) return_nothing_doc = "Returns unspecified."
|
||||
%pragma(guile) return_one_doc = "Returns $values."
|
||||
|
||||
%define %values_as_list
|
||||
%pragma(guile) beforereturn = ""
|
||||
%pragma(guile) return_multi_doc = "Returns a list of $num_values values: $values."
|
||||
%enddef
|
||||
%values_as_list /* the default style */
|
||||
|
||||
%define %values_as_vector
|
||||
%pragma(guile) beforereturn = "GUILE_MAYBE_VECTOR"
|
||||
%pragma(guile) return_multi_doc = "Returns a vector of $num_values values: $values."
|
||||
%enddef
|
||||
|
||||
%define %multiple_values
|
||||
%pragma(guile) beforereturn = "GUILE_MAYBE_VALUES"
|
||||
%pragma(guile) return_multi_doc = "Returns $num_values values: $values."
|
||||
%enddef
|
||||
|
||||
#define GUILE_APPEND_RESULT SWIG_APPEND_VALUE
|
||||
|
||||
%include <typemaps.i>
|
||||
|
|
@ -1,46 +0,0 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* guile_scm.swg
|
||||
*
|
||||
* This SWIG interface file is processed if the Guile module is run
|
||||
* with SCM_ flavor.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
#define SWIGGUILE_SCM
|
||||
|
||||
%runtime "swigrun.swg" // Common C API type-checking code
|
||||
%runtime "swigerrors.swg" // SWIG errors
|
||||
|
||||
%runtime "guile_scm_run.swg"
|
||||
%include <guile.i>
|
||||
|
||||
%runtime %{
|
||||
|
||||
#define GUILE_MAYBE_VALUES \
|
||||
if (gswig_list_p) gswig_result = scm_values(gswig_result);
|
||||
|
||||
#define GUILE_MAYBE_VECTOR \
|
||||
if (gswig_list_p) gswig_result = scm_vector(gswig_result);
|
||||
|
||||
#define SWIG_APPEND_VALUE(object) \
|
||||
if (gswig_result == SCM_UNSPECIFIED) \
|
||||
gswig_result = object; \
|
||||
else { \
|
||||
if (!gswig_list_p) { \
|
||||
gswig_list_p = 1; \
|
||||
gswig_result = scm_list_n(gswig_result, object, SCM_UNDEFINED); \
|
||||
} \
|
||||
else \
|
||||
gswig_result = scm_append(scm_list_n(gswig_result, scm_list_n(object, SCM_UNDEFINED), SCM_UNDEFINED)); \
|
||||
}
|
||||
|
||||
%}
|
||||
|
||||
%insert(init) "swiginit.swg"
|
||||
|
||||
%init %{
|
||||
SWIG_GUILE_INIT_STATIC void
|
||||
SWIG_init(void)
|
||||
{
|
||||
SWIG_InitializeModule(0);
|
||||
SWIG_PropagateClientData();
|
||||
%}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue