diff options
Diffstat (limited to 'share/swig/2.0.11/csharp')
22 files changed, 4079 insertions, 0 deletions
diff --git a/share/swig/2.0.11/csharp/arrays_csharp.i b/share/swig/2.0.11/csharp/arrays_csharp.i new file mode 100644 index 0000000..513330e --- /dev/null +++ b/share/swig/2.0.11/csharp/arrays_csharp.i @@ -0,0 +1,137 @@ +/* ----------------------------------------------------------------------------- + * 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="[In, MarshalAs(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="[Out, MarshalAs(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="[In, Out, MarshalAs(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) + + +%define CSHARP_ARRAYS_FIXED( CTYPE, CSTYPE ) + +%typemap(ctype) CTYPE FIXED[] "CTYPE*" +%typemap(imtype) CTYPE FIXED[] "IntPtr" +%typemap(cstype) CTYPE FIXED[] "CSTYPE[]" +%typemap(csin, + pre= " fixed ( CSTYPE* swig_ptrTo_$csinput = $csinput ) {", + terminator=" }") + CTYPE FIXED[] "(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) + diff --git a/share/swig/2.0.11/csharp/boost_intrusive_ptr.i b/share/swig/2.0.11/csharp/boost_intrusive_ptr.i new file mode 100644 index 0000000..09a1647 --- /dev/null +++ b/share/swig/2.0.11/csharp/boost_intrusive_ptr.i @@ -0,0 +1,511 @@ +// 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, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 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_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 & (SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) %{
+ // 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, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 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="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 > *& "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 > {
+ IntPtr cPtr = $imcall;
+ $typemap(cstype, TYPE) ret = (cPtr == IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode
+ return ret;
+ }
+%typemap(csout, excode=SWIGEXCODE) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > {
+ IntPtr cPtr = $imcall;
+ $typemap(cstype, TYPE) ret = (cPtr == IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode
+ return ret;
+ }
+%typemap(csout, excode=SWIGEXCODE) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > & {
+ IntPtr cPtr = $imcall;
+ $typemap(cstype, TYPE) ret = (cPtr == IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode
+ return ret;
+ }
+%typemap(csout, excode=SWIGEXCODE) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > * {
+ IntPtr cPtr = $imcall;
+ $typemap(cstype, TYPE) ret = (cPtr == IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode
+ return ret;
+ }
+%typemap(csout, excode=SWIGEXCODE) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& {
+ IntPtr cPtr = $imcall;
+ $typemap(cstype, TYPE) ret = (cPtr == 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 * {
+ IntPtr cPtr = $imcall;
+ $typemap(cstype, TYPE) ret = (cPtr == IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode
+ return ret;
+ }
+%typemap(csout, excode=SWIGEXCODE) TYPE *CONST& {
+ IntPtr cPtr = $imcall;
+ $typemap(cstype, TYPE) ret = (cPtr == IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode
+ return ret;
+ }
+
+// Base proxy classes
+%typemap(csbody) TYPE %{
+ private HandleRef swigCPtr;
+ private bool swigCMemOwnBase;
+
+ PTRCTOR_VISIBILITY $csclassname(IntPtr cPtr, bool cMemoryOwn) {
+ swigCMemOwnBase = cMemoryOwn;
+ swigCPtr = new HandleRef(this, cPtr);
+ }
+
+ CPTR_VISIBILITY static HandleRef getCPtr($csclassname obj) {
+ return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
+ }
+%}
+
+// Derived proxy classes
+%typemap(csbody_derived) TYPE %{
+ private HandleRef swigCPtr;
+ private bool swigCMemOwnDerived;
+
+ PTRCTOR_VISIBILITY $csclassname(IntPtr cPtr, bool cMemoryOwn) : base($imclassname.$csclazznameSWIGSmartPtrUpcast(cPtr), true) {
+ swigCMemOwnDerived = cMemoryOwn;
+ swigCPtr = new HandleRef(this, cPtr);
+ }
+
+ CPTR_VISIBILITY static HandleRef getCPtr($csclassname obj) {
+ return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
+ }
+%}
+
+%typemap(csdestruct, methodname="Dispose", methodmodifiers="public") TYPE {
+ lock(this) {
+ if (swigCPtr.Handle != IntPtr.Zero) {
+ if (swigCMemOwnBase) {
+ swigCMemOwnBase = false;
+ $imcall;
+ }
+ swigCPtr = new HandleRef(null, IntPtr.Zero);
+ }
+ GC.SuppressFinalize(this);
+ }
+ }
+
+%typemap(csdestruct_derived, methodname="Dispose", methodmodifiers="public") TYPE {
+ lock(this) {
+ if (swigCPtr.Handle != IntPtr.Zero) {
+ if (swigCMemOwnDerived) {
+ swigCMemOwnDerived = false;
+ $imcall;
+ }
+ swigCPtr = new HandleRef(null, IntPtr.Zero);
+ }
+ GC.SuppressFinalize(this);
+ base.Dispose();
+ }
+ }
+
+// CONST version needed ???? also for C#
+%typemap(imtype, nopgcpp="1") SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > swigSharedPtrUpcast "HandleRef"
+%typemap(imtype, nopgcpp="1") SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > swigSharedPtrUpcast "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_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 > {
+ IntPtr cPtr = $imcall;
+ return (cPtr == 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 * {
+ IntPtr cPtr = $imcall;
+ return (cPtr == IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);
+ }
+%typemap(csout, excode=SWIGEXCODE) TYPE *CONST& {
+ IntPtr cPtr = $imcall;
+ return (cPtr == IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);
+ }
+
+// Base proxy classes
+%typemap(csbody) TYPE %{
+ private HandleRef swigCPtr;
+ private bool swigCMemOwnBase;
+
+ PTRCTOR_VISIBILITY $csclassname(IntPtr cPtr, bool cMemoryOwn) {
+ swigCMemOwnBase = cMemoryOwn;
+ swigCPtr = new HandleRef(this, cPtr);
+ }
+
+ CPTR_VISIBILITY static HandleRef getCPtr($csclassname obj) {
+ return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
+ }
+%}
+
+// Derived proxy classes
+%typemap(csbody_derived) TYPE %{
+ private HandleRef swigCPtr;
+ private bool swigCMemOwnDerived;
+
+ PTRCTOR_VISIBILITY $csclassname(IntPtr cPtr, bool cMemoryOwn) : base($imclassname.$csclazznameSWIGSmartPtrUpcast(cPtr), true) {
+ swigCMemOwnDerived = cMemoryOwn;
+ swigCPtr = new HandleRef(this, cPtr);
+ }
+
+ CPTR_VISIBILITY static HandleRef getCPtr($csclassname obj) {
+ return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
+ }
+%}
+
+%typemap(csdestruct, methodname="Dispose", methodmodifiers="public") TYPE {
+ lock(this) {
+ if (swigCPtr.Handle != IntPtr.Zero) {
+ if (swigCMemOwnBase) {
+ swigCMemOwnBase = false;
+ $imcall;
+ }
+ swigCPtr = new HandleRef(null, IntPtr.Zero);
+ }
+ GC.SuppressFinalize(this);
+ }
+ }
+
+%typemap(csdestruct_derived, methodname="Dispose", methodmodifiers="public") TYPE {
+ lock(this) {
+ if (swigCPtr.Handle != IntPtr.Zero) {
+ if (swigCMemOwnDerived) {
+ swigCMemOwnDerived = false;
+ $imcall;
+ }
+ swigCPtr = new HandleRef(null, IntPtr.Zero);
+ }
+ GC.SuppressFinalize(this);
+ base.Dispose();
+ }
+ }
+
+
+// CONST version needed ???? also for C#
+%typemap(imtype, nopgcpp="1") SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > swigSharedPtrUpcast "HandleRef"
+%typemap(imtype, nopgcpp="1") SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > swigSharedPtrUpcast "HandleRef"
+
+
+%template() SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >;
+%enddef
+
diff --git a/share/swig/2.0.11/csharp/boost_shared_ptr.i b/share/swig/2.0.11/csharp/boost_shared_ptr.i new file mode 100644 index 0000000..5e6f664 --- /dev/null +++ b/share/swig/2.0.11/csharp/boost_shared_ptr.i @@ -0,0 +1,238 @@ +// 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_ltype &)$1)); %} + +// 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; +%} + +// 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); %} + +// 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); %} + +// 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; %} + +// 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; %} + +// 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_ltype)$1) : 0; + if ($owner) delete $1; %} + +// 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; %} + +// 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="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 > *& "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 > { + IntPtr cPtr = $imcall; + $typemap(cstype, TYPE) ret = (cPtr == IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode + return ret; + } +%typemap(csout, excode=SWIGEXCODE) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & { + IntPtr cPtr = $imcall; + $typemap(cstype, TYPE) ret = (cPtr == IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode + return ret; + } +%typemap(csout, excode=SWIGEXCODE) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * { + IntPtr cPtr = $imcall; + $typemap(cstype, TYPE) ret = (cPtr == IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode + return ret; + } +%typemap(csout, excode=SWIGEXCODE) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& { + IntPtr cPtr = $imcall; + $typemap(cstype, TYPE) ret = (cPtr == 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 * { + IntPtr cPtr = $imcall; + $typemap(cstype, TYPE) ret = (cPtr == IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode + return ret; + } +%typemap(csout, excode=SWIGEXCODE) TYPE *CONST& { + IntPtr cPtr = $imcall; + $typemap(cstype, TYPE) ret = (cPtr == 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 { + IntPtr cPtr = $imcall; + $csclassname ret = (cPtr == IntPtr.Zero) ? null : new $csclassname(cPtr, true);$excode + return ret; + } %} + +%typemap(csvarout, excode=SWIGEXCODE2) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & %{ + get { + IntPtr cPtr = $imcall; + $typemap(cstype, TYPE) ret = (cPtr == IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode + return ret; + } %} +%typemap(csvarout, excode=SWIGEXCODE2) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * %{ + get { + IntPtr cPtr = $imcall; + $typemap(cstype, TYPE) ret = (cPtr == IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode + return ret; + } %} + + +// Proxy classes (base classes, ie, not derived classes) +%typemap(csbody) TYPE %{ + private HandleRef swigCPtr; + private bool swigCMemOwnBase; + + PTRCTOR_VISIBILITY $csclassname(IntPtr cPtr, bool cMemoryOwn) { + swigCMemOwnBase = cMemoryOwn; + swigCPtr = new HandleRef(this, cPtr); + } + + CPTR_VISIBILITY static HandleRef getCPtr($csclassname obj) { + return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr; + } +%} + +// Derived proxy classes +%typemap(csbody_derived) TYPE %{ + private HandleRef swigCPtr; + private bool swigCMemOwnDerived; + + PTRCTOR_VISIBILITY $csclassname(IntPtr cPtr, bool cMemoryOwn) : base($imclassname.$csclazznameSWIGSmartPtrUpcast(cPtr), true) { + swigCMemOwnDerived = cMemoryOwn; + swigCPtr = new HandleRef(this, cPtr); + } + + CPTR_VISIBILITY static HandleRef getCPtr($csclassname obj) { + return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr; + } +%} + +%typemap(csdestruct, methodname="Dispose", methodmodifiers="public") TYPE { + lock(this) { + if (swigCPtr.Handle != IntPtr.Zero) { + if (swigCMemOwnBase) { + swigCMemOwnBase = false; + $imcall; + } + swigCPtr = new HandleRef(null, IntPtr.Zero); + } + GC.SuppressFinalize(this); + } + } + +%typemap(csdestruct_derived, methodname="Dispose", methodmodifiers="public") TYPE { + lock(this) { + if (swigCPtr.Handle != IntPtr.Zero) { + if (swigCMemOwnDerived) { + swigCMemOwnDerived = false; + $imcall; + } + swigCPtr = new HandleRef(null, IntPtr.Zero); + } + GC.SuppressFinalize(this); + base.Dispose(); + } + } + +%template() SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >; +%enddef + diff --git a/share/swig/2.0.11/csharp/csharp.swg b/share/swig/2.0.11/csharp/csharp.swg new file mode 100644 index 0000000..c0b896e --- /dev/null +++ b/share/swig/2.0.11/csharp/csharp.swg @@ -0,0 +1,1017 @@ +/* ----------------------------------------------------------------------------- + * csharp.swg + * + * C# typemaps + * ----------------------------------------------------------------------------- */ + +%include <csharphead.swg> + +/* The ctype, imtype and cstype typemaps work together and so there should be one of each. + * The ctype typemap contains the PInvoke type used in the PInvoke (C/C++) code. + * The imtype typemap contains the C# type used in the intermediary class. + * The cstype typemap contains the C# type used in the C# proxy classes, type wrapper classes and module class. */ + + +/* Fragments */ +%fragment("SWIG_PackData", "header") { +/* Pack binary data into a string */ +SWIGINTERN char * SWIG_PackData(char *c, void *ptr, size_t sz) { + static const char hex[17] = "0123456789abcdef"; + register const unsigned char *u = (unsigned char *) ptr; + register const unsigned char *eu = u + sz; + for (; u != eu; ++u) { + register unsigned char uu = *u; + *(c++) = hex[(uu & 0xf0) >> 4]; + *(c++) = hex[uu & 0xf]; + } + return c; +} +} + +%fragment("SWIG_UnPackData", "header") { +/* Unpack binary data from a string */ +SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) { + register unsigned char *u = (unsigned char *) ptr; + register const unsigned char *eu = u + sz; + for (; u != eu; ++u) { + register char d = *(c++); + register unsigned char uu; + if ((d >= '0') && (d <= '9')) + uu = ((d - '0') << 4); + else if ((d >= 'a') && (d <= 'f')) + uu = ((d - ('a'-10)) << 4); + else + return (char *) 0; + d = *(c++); + if ((d >= '0') && (d <= '9')) + uu |= (d - '0'); + else if ((d >= 'a') && (d <= 'f')) + uu |= (d - ('a'-10)); + else + return (char *) 0; + *u = uu; + } + return c; +} +} + +/* Primitive types */ +%typemap(ctype) bool, const bool & "unsigned int" +%typemap(ctype) char, const char & "char" +%typemap(ctype) signed char, const signed char & "signed char" +%typemap(ctype) unsigned char, const unsigned char & "unsigned char" +%typemap(ctype) short, const short & "short" +%typemap(ctype) unsigned short, const unsigned short & "unsigned short" +%typemap(ctype) int, const int & "int" +%typemap(ctype) unsigned int, const unsigned int & "unsigned int" +%typemap(ctype) long, const long & "long" +%typemap(ctype) unsigned long, const unsigned long & "unsigned long" +%typemap(ctype) long long, const long long & "long long" +%typemap(ctype) unsigned long long, const unsigned long long & "unsigned long long" +%typemap(ctype) float, const float & "float" +%typemap(ctype) double, const double & "double" +%typemap(ctype) void "void" + +%typemap(imtype) bool, const bool & "bool" +%typemap(imtype) char, const char & "char" +%typemap(imtype) signed char, const signed char & "sbyte" +%typemap(imtype) unsigned char, const unsigned char & "byte" +%typemap(imtype) short, const short & "short" +%typemap(imtype) unsigned short, const unsigned short & "ushort" +%typemap(imtype) int, const int & "int" +%typemap(imtype) unsigned int, const unsigned int & "uint" +%typemap(imtype) long, const long & "int" +%typemap(imtype) unsigned long, const unsigned long & "uint" +%typemap(imtype) long long, const long long & "long" +%typemap(imtype) unsigned long long, const unsigned long long & "ulong" +%typemap(imtype) float, const float & "float" +%typemap(imtype) double, const double & "double" +%typemap(imtype) void "void" + +%typemap(cstype) bool, const bool & "bool" +%typemap(cstype) char, const char & "char" +%typemap(cstype) signed char, const signed char & "sbyte" +%typemap(cstype) unsigned char, const unsigned char & "byte" +%typemap(cstype) short, const short & "short" +%typemap(cstype) unsigned short, const unsigned short & "ushort" +%typemap(cstype) int, const int & "int" +%typemap(cstype) unsigned int, const unsigned int & "uint" +%typemap(cstype) long, const long & "int" +%typemap(cstype) unsigned long, const unsigned long & "uint" +%typemap(cstype) long long, const long long & "long" +%typemap(cstype) unsigned long long, const unsigned long long & "ulong" +%typemap(cstype) float, const float & "float" +%typemap(cstype) double, const double & "double" +%typemap(cstype) void "void" + +%typemap(ctype) char *, char *&, char[ANY], char[] "char *" +%typemap(imtype) char *, char *&, char[ANY], char[] "string" +%typemap(cstype) char *, char *&, char[ANY], char[] "string" + +/* Non primitive types */ +%typemap(ctype) SWIGTYPE "void *" +%typemap(imtype, out="IntPtr") SWIGTYPE "HandleRef" +%typemap(cstype) SWIGTYPE "$&csclassname" + +%typemap(ctype) SWIGTYPE [] "void *" +%typemap(imtype, out="IntPtr") SWIGTYPE [] "HandleRef" +%typemap(cstype) SWIGTYPE [] "$csclassname" + +%typemap(ctype) SWIGTYPE * "void *" +%typemap(imtype, out="IntPtr") SWIGTYPE * "HandleRef" +%typemap(cstype) SWIGTYPE * "$csclassname" + +%typemap(ctype) SWIGTYPE & "void *" +%typemap(imtype, out="IntPtr") SWIGTYPE & "HandleRef" +%typemap(cstype) SWIGTYPE & "$csclassname" + +/* pointer to a class member */ +%typemap(ctype) SWIGTYPE (CLASS::*) "char *" +%typemap(imtype) SWIGTYPE (CLASS::*) "string" +%typemap(cstype) SWIGTYPE (CLASS::*) "$csclassname" + +/* The following are the in and out typemaps. These are the PInvoke code generating typemaps for converting from C# to C and visa versa. */ + +/* primitive types */ +%typemap(in) bool +%{ $1 = $input ? true : false; %} + +%typemap(directorout) bool +%{ $result = $input ? true : false; %} + +%typemap(csdirectorin) bool "$iminput" +%typemap(csdirectorout) bool "$cscall" + +%typemap(in) 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(directorout) 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(directorin) bool "$input = $1;" +%typemap(directorin) char "$input = $1;" +%typemap(directorin) signed char "$input = $1;" +%typemap(directorin) unsigned char "$input = $1;" +%typemap(directorin) short "$input = $1;" +%typemap(directorin) unsigned short "$input = $1;" +%typemap(directorin) int "$input = $1;" +%typemap(directorin) unsigned int "$input = $1;" +%typemap(directorin) long "$input = $1;" +%typemap(directorin) unsigned long "$input = $1;" +%typemap(directorin) long long "$input = $1;" +%typemap(directorin) unsigned long long "$input = $1;" +%typemap(directorin) float "$input = $1;" +%typemap(directorin) double "$input = $1;" + +%typemap(csdirectorin) char, + signed char, + unsigned char, + short, + unsigned short, + int, + unsigned int, + long, + unsigned long, + long long, + unsigned long long, + float, + double + "$iminput" + +%typemap(csdirectorout) char, + signed char, + unsigned char, + short, + unsigned short, + int, + unsigned int, + long, + unsigned long, + long long, + unsigned long long, + float, + double + "$cscall" + +%typemap(out) bool %{ $result = $1; %} +%typemap(out) char %{ $result = $1; %} +%typemap(out) signed char %{ $result = $1; %} +%typemap(out) unsigned char %{ $result = $1; %} +%typemap(out) short %{ $result = $1; %} +%typemap(out) unsigned short %{ $result = $1; %} +%typemap(out) int %{ $result = $1; %} +%typemap(out) unsigned int %{ $result = $1; %} +%typemap(out) long %{ $result = $1; %} +%typemap(out) unsigned long %{ $result = (unsigned long)$1; %} +%typemap(out) long long %{ $result = $1; %} +%typemap(out) unsigned long long %{ $result = $1; %} +%typemap(out) float %{ $result = $1; %} +%typemap(out) double %{ $result = $1; %} + +/* char * - treat as String */ +%typemap(in) char * %{ $1 = ($1_ltype)$input; %} +%typemap(out) char * %{ $result = SWIG_csharp_string_callback((const char *)$1); %} +%typemap(directorout, warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) char * %{ $result = ($1_ltype)$input; %} +%typemap(directorin) char * %{ $input = SWIG_csharp_string_callback((const char *)$1); %} +%typemap(csdirectorin) char * "$iminput" +%typemap(csdirectorout) char * "$cscall" + +/* char *& - treat as String */ +%typemap(in) char *& ($*1_ltype temp = 0) %{ + temp = ($*1_ltype)$input; + $1 = &temp; +%} +%typemap(out) char *& %{ if ($1) $result = SWIG_csharp_string_callback((const char *)*$1); %} + +%typemap(out, null="") void "" +%typemap(csdirectorin) void "$iminput" +%typemap(csdirectorout) void "$cscall" +%typemap(directorin) void "" + +/* primitive types by const reference */ +%typemap(in) const bool & ($*1_ltype temp) +%{ temp = $input ? true : false; + $1 = &temp; %} + +%typemap(directorout,warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const bool & +%{ static $*1_ltype temp; + temp = $input ? true : false; + $result = &temp; %} + +%typemap(csdirectorin) const bool & "$iminput" +%typemap(csdirectorout) const bool & "$cscall" + +%typemap(in) const char & ($*1_ltype temp), + const signed char & ($*1_ltype temp), + const unsigned char & ($*1_ltype temp), + const short & ($*1_ltype temp), + const unsigned short & ($*1_ltype temp), + const int & ($*1_ltype temp), + const unsigned int & ($*1_ltype temp), + const long & ($*1_ltype temp), + const unsigned long & ($*1_ltype temp), + const long long & ($*1_ltype temp), + const unsigned long long & ($*1_ltype temp), + const float & ($*1_ltype temp), + const double & ($*1_ltype temp) +%{ temp = ($*1_ltype)$input; + $1 = &temp; %} + +%typemap(directorout,warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) 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 & +%{ static $*1_ltype temp; + temp = ($*1_ltype)$input; + $result = &temp; %} + +%typemap(directorin) const bool & "$input = $1;" +%typemap(directorin) const char & "$input = $1;" +%typemap(directorin) const signed char & "$input = $1;" +%typemap(directorin) const unsigned char & "$input = $1;" +%typemap(directorin) const short & "$input = $1;" +%typemap(directorin) const unsigned short & "$input = $1;" +%typemap(directorin) const int & "$input = $1;" +%typemap(directorin) const unsigned int & "$input = $1;" +%typemap(directorin) const long & "$input = $1;" +%typemap(directorin) const unsigned long & "$input = $1;" +%typemap(directorin) const long long & "$input = $1;" +%typemap(directorin) const unsigned long long & "$input = $1;" +%typemap(directorin) const float & "$input = $1;" +%typemap(directorin) const double & "$input = $1;" + +%typemap(csdirectorin) const char & ($*1_ltype temp), + const signed char & ($*1_ltype temp), + const unsigned char & ($*1_ltype temp), + const short & ($*1_ltype temp), + const unsigned short & ($*1_ltype temp), + const int & ($*1_ltype temp), + const unsigned int & ($*1_ltype temp), + const long & ($*1_ltype temp), + const unsigned long & ($*1_ltype temp), + const long long & ($*1_ltype temp), + const unsigned long long & ($*1_ltype temp), + const float & ($*1_ltype temp), + const double & ($*1_ltype temp) + "$iminput" + +%typemap(csdirectorout) const char & ($*1_ltype temp), + const signed char & ($*1_ltype temp), + const unsigned char & ($*1_ltype temp), + const short & ($*1_ltype temp), + const unsigned short & ($*1_ltype temp), + const int & ($*1_ltype temp), + const unsigned int & ($*1_ltype temp), + const long & ($*1_ltype temp), + const unsigned long & ($*1_ltype temp), + const long long & ($*1_ltype temp), + const unsigned long long & ($*1_ltype temp), + const float & ($*1_ltype temp), + const double & ($*1_ltype temp) + "$cscall" + + +%typemap(out) const bool & %{ $result = *$1; %} +%typemap(out) const char & %{ $result = *$1; %} +%typemap(out) const signed char & %{ $result = *$1; %} +%typemap(out) const unsigned char & %{ $result = *$1; %} +%typemap(out) const short & %{ $result = *$1; %} +%typemap(out) const unsigned short & %{ $result = *$1; %} +%typemap(out) const int & %{ $result = *$1; %} +%typemap(out) const unsigned int & %{ $result = *$1; %} +%typemap(out) const long & %{ $result = *$1; %} +%typemap(out) const unsigned long & %{ $result = (unsigned long)*$1; %} +%typemap(out) const long long & %{ $result = *$1; %} +%typemap(out) const unsigned long long & %{ $result = *$1; %} +%typemap(out) const float & %{ $result = *$1; %} +%typemap(out) const double & %{ $result = *$1; %} + +/* Default handling. Object passed by value. Convert to a pointer */ +%typemap(in, canthrow=1) SWIGTYPE ($&1_type argp) +%{ argp = ($&1_ltype)$input; + if (!argp) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null $1_type", 0); + return $null; + } + $1 = *argp; %} + +%typemap(directorout) SWIGTYPE +%{ if (!$input) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Unexpected null return for type $1_type", 0); + return $null; + } + $result = *($&1_ltype)$input; %} + +%typemap(out) SWIGTYPE +#ifdef __cplusplus +%{ $result = new $1_ltype((const $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 *)&$1; %} +%typemap(csdirectorin) SWIGTYPE "new $&csclassname($iminput, false)" +%typemap(csdirectorout) SWIGTYPE "$&csclassname.getCPtr($cscall).Handle" + +/* Generic pointers and references */ +%typemap(in) SWIGTYPE * %{ $1 = ($1_ltype)$input; %} +%typemap(in, fragment="SWIG_UnPackData") SWIGTYPE (CLASS::*) %{ + SWIG_UnpackData($input, (void *)&$1, sizeof($1)); +%} +%typemap(in, canthrow=1) SWIGTYPE & %{ $1 = ($1_ltype)$input; + if (!$1) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "$1_type type is null", 0); + return $null; + } %} +%typemap(out) SWIGTYPE * %{ $result = (void *)$1; %} +%typemap(out, fragment="SWIG_PackData") SWIGTYPE (CLASS::*) %{ + char buf[128]; + char *data = SWIG_PackData(buf, (void *)&$1, sizeof($1)); + *data = '\0'; + $result = SWIG_csharp_string_callback(buf); +%} +%typemap(out) SWIGTYPE & %{ $result = (void *)$1; %} + +%typemap(directorout, warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) SWIGTYPE * +%{ $result = ($1_ltype)$input; %} +%typemap(directorout, warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) SWIGTYPE (CLASS::*) +%{ $result = ($1_ltype)$input; %} + +%typemap(directorin) SWIGTYPE * +%{ $input = (void *) $1; %} +%typemap(directorin) SWIGTYPE (CLASS::*) +%{ $input = (void *) $1; %} + +%typemap(directorout, warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) SWIGTYPE & +%{ if (!$input) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Unexpected null return for type $1_type", 0); + return $null; + } + $result = ($1_ltype)$input; %} +%typemap(directorin) SWIGTYPE & +%{ $input = ($1_ltype) &$1; %} + +%typemap(csdirectorin) SWIGTYPE *, SWIGTYPE (CLASS::*) "($iminput == IntPtr.Zero) ? null : new $csclassname($iminput, false)" +%typemap(csdirectorin) SWIGTYPE & "new $csclassname($iminput, false)" +%typemap(csdirectorout) SWIGTYPE *, SWIGTYPE (CLASS::*), SWIGTYPE & "$csclassname.getCPtr($cscall).Handle" + +/* Default array handling */ +%typemap(in) SWIGTYPE [] %{ $1 = ($1_ltype)$input; %} +%typemap(out) SWIGTYPE [] %{ $result = $1; %} + +/* char arrays - treat as String */ +%typemap(in) char[ANY], char[] %{ $1 = ($1_ltype)$input; %} +%typemap(out) char[ANY], char[] %{ $result = SWIG_csharp_string_callback((const char *)$1); %} + +%typemap(directorout) char[ANY], char[] %{ $result = ($1_ltype)$input; %} +%typemap(directorin) char[ANY], char[] %{ $input = SWIG_csharp_string_callback((const char *)$1); %} + +%typemap(csdirectorin) char[ANY], char[] "$iminput" +%typemap(csdirectorout) char[ANY], char[] "$cscall" + + +/* Typecheck typemaps - The purpose of these is merely to issue a warning for overloaded C++ functions + * that cannot be overloaded in C# as more than one C++ type maps to a single C# type */ + +%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 & + "" + +%typecheck(SWIG_TYPECHECK_STRING) + char *, + char *&, + char[ANY], + char[] + "" + +%typecheck(SWIG_TYPECHECK_POINTER) + SWIGTYPE, + SWIGTYPE *, + SWIGTYPE &, + SWIGTYPE *const&, + SWIGTYPE [], + SWIGTYPE (CLASS::*) + "" + +/* Exception handling */ + +%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_CSharpSetPendingException(SWIG_CSharpApplicationException, error_msg); + return $null; %} + +%typemap(throws, canthrow=1) SWIGTYPE, SWIGTYPE &, SWIGTYPE *, SWIGTYPE [ANY] +%{ (void)$1; + SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, "C++ $1_type exception thrown"); + return $null; %} + +%typemap(throws, canthrow=1) char * +%{ SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, $1); + return $null; %} + + +/* Typemaps for code generation in proxy classes and C# type wrapper classes */ + +/* The csin typemap is used for converting function parameter types from the type + * used in the proxy, module or type wrapper class to the type used in the PInvoke class. */ +%typemap(csin) bool, const bool &, + char, const char &, + signed char, const signed char &, + unsigned char, const unsigned char &, + short, const short &, + unsigned short, const unsigned short &, + int, const int &, + unsigned int, const unsigned int &, + long, const long &, + unsigned long, const unsigned long &, + long long, const long long &, + unsigned long long, const unsigned long long &, + float, const float &, + double, const double & + "$csinput" +%typemap(csin) char *, char *&, char[ANY], char[] "$csinput" +%typemap(csin) SWIGTYPE "$&csclassname.getCPtr($csinput)" +%typemap(csin) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [] "$csclassname.getCPtr($csinput)" +%typemap(csin) SWIGTYPE (CLASS::*) "$csclassname.getCMemberPtr($csinput)" + +/* The csout typemap is used for converting function return types from the return type + * used in the PInvoke class to the type returned by the proxy, module or type wrapper class. + * The $excode special variable is replaced by the excode typemap attribute code if the + * method can throw any exceptions from unmanaged code, otherwise replaced by nothing. */ + +// Macro used by the $excode special variable +%define SWIGEXCODE "\n if ($imclassname.SWIGPendingException.Pending) throw $imclassname.SWIGPendingException.Retrieve();" %enddef +%define SWIGEXCODE2 "\n if ($imclassname.SWIGPendingException.Pending) throw $imclassname.SWIGPendingException.Retrieve();" %enddef + +%typemap(csout, excode=SWIGEXCODE) bool, const bool & { + bool ret = $imcall;$excode + return ret; + } +%typemap(csout, excode=SWIGEXCODE) char, const char & { + char ret = $imcall;$excode + return ret; + } +%typemap(csout, excode=SWIGEXCODE) signed char, const signed char & { + sbyte ret = $imcall;$excode + return ret; + } +%typemap(csout, excode=SWIGEXCODE) unsigned char, const unsigned char & { + byte ret = $imcall;$excode + return ret; + } +%typemap(csout, excode=SWIGEXCODE) short, const short & { + short ret = $imcall;$excode + return ret; + } +%typemap(csout, excode=SWIGEXCODE) unsigned short, const unsigned short & { + ushort ret = $imcall;$excode + return ret; + } +%typemap(csout, excode=SWIGEXCODE) int, const int & { + int ret = $imcall;$excode + return ret; + } +%typemap(csout, excode=SWIGEXCODE) unsigned int, const unsigned int & { + uint ret = $imcall;$excode + return ret; + } +%typemap(csout, excode=SWIGEXCODE) long, const long & { + int ret = $imcall;$excode + return ret; + } +%typemap(csout, excode=SWIGEXCODE) unsigned long, const unsigned long & { + uint ret = $imcall;$excode + return ret; + } +%typemap(csout, excode=SWIGEXCODE) long long, const long long & { + long ret = $imcall;$excode + return ret; + } +%typemap(csout, excode=SWIGEXCODE) unsigned long long, const unsigned long long & { + ulong ret = $imcall;$excode + return ret; + } +%typemap(csout, excode=SWIGEXCODE) float, const float & { + float ret = $imcall;$excode + return ret; + } +%typemap(csout, excode=SWIGEXCODE) double, const double & { + double ret = $imcall;$excode + return ret; + } +%typemap(csout, excode=SWIGEXCODE) char *, char *&, char[ANY], char[] { + string ret = $imcall;$excode + return ret; + } +%typemap(csout, excode=SWIGEXCODE) void { + $imcall;$excode + } +%typemap(csout, excode=SWIGEXCODE) SWIGTYPE { + $&csclassname ret = new $&csclassname($imcall, true);$excode + return ret; + } +%typemap(csout, excode=SWIGEXCODE) SWIGTYPE & { + $csclassname ret = new $csclassname($imcall, $owner);$excode + return ret; + } +%typemap(csout, excode=SWIGEXCODE) SWIGTYPE *, SWIGTYPE [] { + IntPtr cPtr = $imcall; + $csclassname ret = (cPtr == IntPtr.Zero) ? null : new $csclassname(cPtr, $owner);$excode + return ret; + } +%typemap(csout, excode=SWIGEXCODE) SWIGTYPE (CLASS::*) { + string cMemberPtr = $imcall; + $csclassname ret = (cMemberPtr == null) ? null : new $csclassname(cMemberPtr, $owner);$excode + return ret; + } + + +/* Properties */ +%typemap(csvarin, excode=SWIGEXCODE2) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) %{ + set { + $imcall;$excode + } %} + +%typemap(csvarin, excode=SWIGEXCODE2) char *, char *&, char[ANY], char[] %{ + set { + $imcall;$excode + } %} + +%typemap(csvarout, excode=SWIGEXCODE2) bool, const bool & %{ + get { + bool ret = $imcall;$excode + return ret; + } %} +%typemap(csvarout, excode=SWIGEXCODE2) char, const char & %{ + get { + char ret = $imcall;$excode + return ret; + } %} +%typemap(csvarout, excode=SWIGEXCODE2) signed char, const signed char & %{ + get { + sbyte ret = $imcall;$excode + return ret; + } %} +%typemap(csvarout, excode=SWIGEXCODE2) unsigned char, const unsigned char & %{ + get { + byte ret = $imcall;$excode + return ret; + } %} +%typemap(csvarout, excode=SWIGEXCODE2) short, const short & %{ + get { + short ret = $imcall;$excode + return ret; + } %} +%typemap(csvarout, excode=SWIGEXCODE2) unsigned short, const unsigned short & %{ + get { + ushort ret = $imcall;$excode + return ret; + } %} +%typemap(csvarout, excode=SWIGEXCODE2) int, const int & %{ + get { + int ret = $imcall;$excode + return ret; + } %} +%typemap(csvarout, excode=SWIGEXCODE2) unsigned int, const unsigned int & %{ + get { + uint ret = $imcall;$excode + return ret; + } %} +%typemap(csvarout, excode=SWIGEXCODE2) long, const long & %{ + get { + int ret = $imcall;$excode + return ret; + } %} +%typemap(csvarout, excode=SWIGEXCODE2) unsigned long, const unsigned long & %{ + get { + uint ret = $imcall;$excode + return ret; + } %} +%typemap(csvarout, excode=SWIGEXCODE2) long long, const long long & %{ + get { + long ret = $imcall;$excode + return ret; + } %} +%typemap(csvarout, excode=SWIGEXCODE2) unsigned long long, const unsigned long long & %{ + get { + ulong ret = $imcall;$excode + return ret; + } %} +%typemap(csvarout, excode=SWIGEXCODE2) float, const float & %{ + get { + float ret = $imcall;$excode + return ret; + } %} +%typemap(csvarout, excode=SWIGEXCODE2) double, const double & %{ + get { + double ret = $imcall;$excode + return ret; + } %} + + +%typemap(csvarout, excode=SWIGEXCODE2) char *, char *&, char[ANY], char[] %{ + get { + string ret = $imcall;$excode + return ret; + } %} +%typemap(csvarout, excode=SWIGEXCODE2) void %{ + get { + $imcall;$excode + } %} +%typemap(csvarout, excode=SWIGEXCODE2) SWIGTYPE %{ + get { + $&csclassname ret = new $&csclassname($imcall, true);$excode + return ret; + } %} +%typemap(csvarout, excode=SWIGEXCODE2) SWIGTYPE & %{ + get { + $csclassname ret = new $csclassname($imcall, $owner);$excode + return ret; + } %} +%typemap(csvarout, excode=SWIGEXCODE2) SWIGTYPE *, SWIGTYPE [] %{ + get { + IntPtr cPtr = $imcall; + $csclassname ret = (cPtr == IntPtr.Zero) ? null : new $csclassname(cPtr, $owner);$excode + return ret; + } %} + +%typemap(csvarout, excode=SWIGEXCODE2) SWIGTYPE (CLASS::*) %{ + get { + string cMemberPtr = $imcall; + $csclassname ret = (cMemberPtr == null) ? null : new $csclassname(cMemberPtr, $owner);$excode + return ret; + } %} + +/* Pointer reference typemaps */ +%typemap(ctype) SWIGTYPE *const& "void *" +%typemap(imtype, out="IntPtr") SWIGTYPE *const& "HandleRef" +%typemap(cstype) SWIGTYPE *const& "$*csclassname" +%typemap(csin) SWIGTYPE *const& "$*csclassname.getCPtr($csinput)" +%typemap(csout, excode=SWIGEXCODE) SWIGTYPE *const& { + IntPtr cPtr = $imcall; + $*csclassname ret = (cPtr == IntPtr.Zero) ? null : new $*csclassname(cPtr, $owner);$excode + return ret; + } +%typemap(in) SWIGTYPE *const& ($*1_ltype temp = 0) +%{ temp = ($*1_ltype)$input; + $1 = ($1_ltype)&temp; %} +%typemap(out) SWIGTYPE *const& +%{ $result = (void *)*$1; %} + +/* Marshal C/C++ pointer to IntPtr */ +%typemap(ctype) void *VOID_INT_PTR "void *" +%typemap(imtype) void *VOID_INT_PTR "IntPtr" +%typemap(cstype) void *VOID_INT_PTR "IntPtr" +%typemap(in) void *VOID_INT_PTR %{ $1 = ($1_ltype)$input; %} +%typemap(out) void *VOID_INT_PTR %{ $result = (void *)$1; %} +%typemap(csin) void *VOID_INT_PTR "$csinput" +%typemap(csout, excode=SWIGEXCODE) void *VOID_INT_PTR { + IntPtr ret = $imcall;$excode + return ret; + } + + +/* Typemaps used for the generation of proxy and type wrapper class code */ +%typemap(csbase) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) "" +%typemap(csclassmodifiers) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) "public class" +%typemap(cscode) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) "" +%typemap(csimports) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) "\nusing System;\nusing System.Runtime.InteropServices;\n" +%typemap(csinterfaces) SWIGTYPE "IDisposable" +%typemap(csinterfaces) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) "" +%typemap(csinterfaces_derived) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) "" + + +// csbody typemaps... these are in macros so that the visibility of the methods can be easily changed by users. + +%define SWIG_CSBODY_PROXY(PTRCTOR_VISIBILITY, CPTR_VISIBILITY, TYPE...) +// Proxy classes (base classes, ie, not derived classes) +%typemap(csbody) TYPE %{ + private HandleRef swigCPtr; + protected bool swigCMemOwn; + + PTRCTOR_VISIBILITY $csclassname(IntPtr cPtr, bool cMemoryOwn) { + swigCMemOwn = cMemoryOwn; + swigCPtr = new HandleRef(this, cPtr); + } + + CPTR_VISIBILITY static HandleRef getCPtr($csclassname obj) { + return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr; + } +%} + +// Derived proxy classes +%typemap(csbody_derived) TYPE %{ + private HandleRef swigCPtr; + + PTRCTOR_VISIBILITY $csclassname(IntPtr cPtr, bool cMemoryOwn) : base($imclassname.$csclazznameSWIGUpcast(cPtr), cMemoryOwn) { + swigCPtr = new HandleRef(this, cPtr); + } + + CPTR_VISIBILITY static HandleRef getCPtr($csclassname obj) { + return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr; + } +%} +%enddef + +%define SWIG_CSBODY_TYPEWRAPPER(PTRCTOR_VISIBILITY, DEFAULTCTOR_VISIBILITY, CPTR_VISIBILITY, TYPE...) +// Typewrapper classes +%typemap(csbody) TYPE *, TYPE &, TYPE [] %{ + private HandleRef swigCPtr; + + PTRCTOR_VISIBILITY $csclassname(IntPtr cPtr, bool futureUse) { + swigCPtr = new HandleRef(this, cPtr); + } + + DEFAULTCTOR_VISIBILITY $csclassname() { + swigCPtr = new HandleRef(null, IntPtr.Zero); + } + + CPTR_VISIBILITY static HandleRef getCPtr($csclassname obj) { + return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr; + } +%} + +%typemap(csbody) TYPE (CLASS::*) %{ + private string swigCMemberPtr; + + PTRCTOR_VISIBILITY $csclassname(string cMemberPtr, bool futureUse) { + swigCMemberPtr = cMemberPtr; + } + + DEFAULTCTOR_VISIBILITY $csclassname() { + swigCMemberPtr = null; + } + + CPTR_VISIBILITY static string getCMemberPtr($csclassname obj) { + return obj.swigCMemberPtr; + } +%} +%enddef + +/* Set the default csbody typemaps to use internal visibility. + Use the macros to change to public if using multiple modules. */ +SWIG_CSBODY_PROXY(internal, internal, SWIGTYPE) +SWIG_CSBODY_TYPEWRAPPER(internal, protected, internal, SWIGTYPE) + +%typemap(csfinalize) SWIGTYPE %{ + ~$csclassname() { + Dispose(); + } +%} + +%typemap(csconstruct, excode=SWIGEXCODE,directorconnect="\n SwigDirectorConnect();") SWIGTYPE %{: this($imcall, true) {$excode$directorconnect + } +%} + +%typemap(csdestruct, methodname="Dispose", methodmodifiers="public") SWIGTYPE { + lock(this) { + if (swigCPtr.Handle != IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + $imcall; + } + swigCPtr = new HandleRef(null, IntPtr.Zero); + } + GC.SuppressFinalize(this); + } + } + +%typemap(csdestruct_derived, methodname="Dispose", methodmodifiers="public") SWIGTYPE { + lock(this) { + if (swigCPtr.Handle != IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + $imcall; + } + swigCPtr = new HandleRef(null, IntPtr.Zero); + } + GC.SuppressFinalize(this); + base.Dispose(); + } + } + +%typemap(directordisconnect, methodname="swigDirectorDisconnect") SWIGTYPE %{ + protected void $methodname() { + swigCMemOwn = false; + $imcall; + } +%} + +/* C# specific directives */ +#define %csconst(flag) %feature("cs:const","flag") +#define %csconstvalue(value) %feature("cs:constvalue",value) +#define %csenum(wrapapproach) %feature("cs:enum","wrapapproach") +#define %csmethodmodifiers %feature("cs:methodmodifiers") +#define %csnothrowexception %feature("except") +#define %csattributes %feature("cs:attributes") + +%pragma(csharp) imclassclassmodifiers="class" +%pragma(csharp) moduleclassmodifiers="public class" + +%pragma(csharp) moduleimports=%{ +using System; +using System.Runtime.InteropServices; +%} + +%pragma(csharp) imclassimports=%{ +using System; +using System.Runtime.InteropServices; +%} + +/* Some ANSI C typemaps */ + +%apply unsigned long { size_t }; +%apply const unsigned long & { const size_t & }; + +/* Array reference typemaps */ +%apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) } + +/* const pointers */ +%apply SWIGTYPE * { SWIGTYPE *const } + +/* csharp keywords */ +%include <csharpkw.swg> + +// Default enum handling +%include <enums.swg> + +// For vararg handling in macros, from swigmacros.swg +#define %arg(X...) X + +/* +// Alternative char * typemaps. +%pragma(csharp) imclasscode=%{ + public class SWIGStringMarshal : IDisposable { + public readonly HandleRef swigCPtr; + public SWIGStringMarshal(string str) { + swigCPtr = new HandleRef(this, System.Runtime.InteropServices.Marshal.StringToHGlobalAnsi(str)); + } + public virtual void Dispose() { + System.Runtime.InteropServices.Marshal.FreeHGlobal(swigCPtr.Handle); + GC.SuppressFinalize(this); + } + } +%} + +%typemap(imtype, out="IntPtr") char *, char[ANY], char[] "HandleRef" +%typemap(out) char *, char[ANY], char[] %{ $result = $1; %} +%typemap(csin) char *, char[ANY], char[] "new $imclassname.SWIGStringMarshal($csinput).swigCPtr" +%typemap(csout, excode=SWIGEXCODE) char *, char[ANY], char[] { + string ret = System.Runtime.InteropServices.Marshal.PtrToStringAnsi($imcall);$excode + return ret; + } +%typemap(csvarin, excode=SWIGEXCODE2) char *, char[ANY], char[] %{ + set { + $imcall;$excode + } %} +%typemap(csvarout, excode=SWIGEXCODE2) char *, char[ANY], char[] %{ + get { + string ret = System.Runtime.InteropServices.Marshal.PtrToStringAnsi($imcall);$excode + return ret; + } %} +*/ + diff --git a/share/swig/2.0.11/csharp/csharphead.swg b/share/swig/2.0.11/csharp/csharphead.swg new file mode 100644 index 0000000..a1c56a4 --- /dev/null +++ b/share/swig/2.0.11/csharp/csharphead.swg @@ -0,0 +1,334 @@ +/* ----------------------------------------------------------------------------- + * 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); + + [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); + + [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 System.ApplicationException(message, SWIGPendingException.Retrieve())); + } + static void SetPendingArithmeticException(string message) { + SWIGPendingException.Set(new System.ArithmeticException(message, SWIGPendingException.Retrieve())); + } + static void SetPendingDivideByZeroException(string message) { + SWIGPendingException.Set(new System.DivideByZeroException(message, SWIGPendingException.Retrieve())); + } + static void SetPendingIndexOutOfRangeException(string message) { + SWIGPendingException.Set(new System.IndexOutOfRangeException(message, SWIGPendingException.Retrieve())); + } + static void SetPendingInvalidCastException(string message) { + SWIGPendingException.Set(new System.InvalidCastException(message, SWIGPendingException.Retrieve())); + } + static void SetPendingInvalidOperationException(string message) { + SWIGPendingException.Set(new System.InvalidOperationException(message, SWIGPendingException.Retrieve())); + } + static void SetPendingIOException(string message) { + SWIGPendingException.Set(new System.IO.IOException(message, SWIGPendingException.Retrieve())); + } + static void SetPendingNullReferenceException(string message) { + SWIGPendingException.Set(new System.NullReferenceException(message, SWIGPendingException.Retrieve())); + } + static void SetPendingOutOfMemoryException(string message) { + SWIGPendingException.Set(new System.OutOfMemoryException(message, SWIGPendingException.Retrieve())); + } + static void SetPendingOverflowException(string message) { + SWIGPendingException.Set(new System.OverflowException(message, SWIGPendingException.Retrieve())); + } + static void SetPendingSystemException(string message) { + SWIGPendingException.Set(new System.SystemException(message, SWIGPendingException.Retrieve())); + } + + static void SetPendingArgumentException(string message, string paramName) { + SWIGPendingException.Set(new System.ArgumentException(message, paramName, SWIGPendingException.Retrieve())); + } + static void SetPendingArgumentNullException(string message, string paramName) { + Exception e = SWIGPendingException.Retrieve(); + if (e != null) message = message + " Inner Exception: " + e.Message; + SWIGPendingException.Set(new System.ArgumentNullException(paramName, message)); + } + static void SetPendingArgumentOutOfRangeException(string message, string paramName) { + Exception e = SWIGPendingException.Retrieve(); + if (e != null) message = message + " Inner Exception: " + e.Message; + SWIGPendingException.Set(new 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 { + [ThreadStatic] + private static Exception pendingException = null; + private static int numExceptionsPending = 0; + + public static bool Pending { + get { + bool pending = false; + if (numExceptionsPending > 0) + if (pendingException != null) + pending = true; + return pending; + } + } + + public static void Set(Exception e) { + if (pendingException != null) + throw new ApplicationException("FATAL: An earlier pending exception from unmanaged code was missed and thus not thrown (" + pendingException.ToString() + ")", e); + pendingException = e; + lock(typeof($imclassname)) { + numExceptionsPending++; + } + } + + public static Exception Retrieve() { + Exception e = null; + if (numExceptionsPending > 0) { + if (pendingException != null) { + e = pendingException; + pendingException = null; + lock(typeof($imclassname)) { + numExceptionsPending--; + } + } + } + return e; + } + } +%} +#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); + + [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) if (!(expr)) {SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentOutOfRangeException, msg, ""); return nullreturn; } else +%} diff --git a/share/swig/2.0.11/csharp/csharpkw.swg b/share/swig/2.0.11/csharp/csharpkw.swg new file mode 100644 index 0000000..9a6d979 --- /dev/null +++ b/share/swig/2.0.11/csharp/csharpkw.swg @@ -0,0 +1,94 @@ +#ifndef CSHARP_CSHARPKW_SWG_ +#define CSHARP_CSHARPKW_SWG_ + +/* Warnings for C# keywords */ +#define CSHARPKW(x) %keywordwarn("'" `x` "' is a C# keyword, renaming to '_" `x` "'",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); + + +#undef CSHARPKW + +#endif //CSHARP_CSHARPKW_SWG_ diff --git a/share/swig/2.0.11/csharp/director.swg b/share/swig/2.0.11/csharp/director.swg new file mode 100644 index 0000000..7768d8c --- /dev/null +++ b/share/swig/2.0.11/csharp/director.swg @@ -0,0 +1,47 @@ +/* ----------------------------------------------------------------------------- + * director.swg + * + * This file contains support for director classes so that C# proxy + * methods can be called from C++. + * ----------------------------------------------------------------------------- */ + +#ifdef __cplusplus + +#if defined(DEBUG_DIRECTOR_OWNED) +#include <iostream> +#endif +#include <string> + +namespace Swig { + /* Director base class - not currently used in C# directors */ + class Director { + }; + + /* Base class for director exceptions */ + class DirectorException { + protected: + std::string swig_msg; + + public: + DirectorException(const char* msg) : swig_msg(msg) { + } + DirectorException(const std::string &msg) : swig_msg(msg) { + } + const std::string& what() const { + return swig_msg; + } + virtual ~DirectorException() { + } + }; + + /* Pure virtual method exception */ + class DirectorPureVirtualException : public Swig::DirectorException { + public: + DirectorPureVirtualException(const char* msg) : DirectorException(std::string("Attempt to invoke pure virtual method ") + msg) { + } + }; +} + +#endif /* __cplusplus */ + + diff --git a/share/swig/2.0.11/csharp/enums.swg b/share/swig/2.0.11/csharp/enums.swg new file mode 100644 index 0000000..70e483f --- /dev/null +++ b/share/swig/2.0.11/csharp/enums.swg @@ -0,0 +1,86 @@ +/* ----------------------------------------------------------------------------- + * 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 = *$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 = $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 = $1; %} + +%typemap(directorout) enum SWIGTYPE %{ $result = ($1_ltype)$input; %} +%typemap(directorin) enum SWIGTYPE "$input = $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); + diff --git a/share/swig/2.0.11/csharp/enumsimple.swg b/share/swig/2.0.11/csharp/enumsimple.swg new file mode 100644 index 0000000..a193e75 --- /dev/null +++ b/share/swig/2.0.11/csharp/enumsimple.swg @@ -0,0 +1,88 @@ +/* ----------------------------------------------------------------------------- + * 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 = *$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 = $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 = $1; %} + +%typemap(directorout) enum SWIGTYPE %{ $result = ($1_ltype)$input; %} +%typemap(directorin) enum SWIGTYPE "$input = $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); + diff --git a/share/swig/2.0.11/csharp/enumtypesafe.swg b/share/swig/2.0.11/csharp/enumtypesafe.swg new file mode 100644 index 0000000..ed483f0 --- /dev/null +++ b/share/swig/2.0.11/csharp/enumtypesafe.swg @@ -0,0 +1,130 @@ +/* ----------------------------------------------------------------------------- + * 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 = *$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 = $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 = $1; %} + +%typemap(directorout) enum SWIGTYPE %{ $result = ($1_ltype)$input; %} +%typemap(directorin) enum SWIGTYPE "$input = $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 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); + diff --git a/share/swig/2.0.11/csharp/std_common.i b/share/swig/2.0.11/csharp/std_common.i new file mode 100644 index 0000000..cee11e8 --- /dev/null +++ b/share/swig/2.0.11/csharp/std_common.i @@ -0,0 +1,5 @@ +%include <std_except.i> + +%apply size_t { std::size_t }; +%apply const size_t& { const std::size_t& }; + diff --git a/share/swig/2.0.11/csharp/std_deque.i b/share/swig/2.0.11/csharp/std_deque.i new file mode 100644 index 0000000..cb98f6c --- /dev/null +++ b/share/swig/2.0.11/csharp/std_deque.i @@ -0,0 +1 @@ +%include <std/_std_deque.i> diff --git a/share/swig/2.0.11/csharp/std_except.i b/share/swig/2.0.11/csharp/std_except.i new file mode 100644 index 0000000..27eb84b --- /dev/null +++ b/share/swig/2.0.11/csharp/std_except.i @@ -0,0 +1,30 @@ +/* ----------------------------------------------------------------------------- + * std_except.i + * + * Typemaps used by the STL wrappers that throw exceptions. These typemaps are + * used when methods are declared with an STL exception specification, such as + * size_t at() const throw (std::out_of_range); + * ----------------------------------------------------------------------------- */ + +%{ +#include <stdexcept> +%} + +namespace std +{ + %ignore exception; + struct exception {}; +} + +%typemap(throws, 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;" + diff --git a/share/swig/2.0.11/csharp/std_map.i b/share/swig/2.0.11/csharp/std_map.i new file mode 100644 index 0000000..acd1906 --- /dev/null +++ b/share/swig/2.0.11/csharp/std_map.i @@ -0,0 +1,312 @@ +/* ----------------------------------------------------------------------------- + * 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) For .NET 1 compatibility, define SWIG_DOTNET_1 when compiling the C# code. In this case + * the C# wrapper has only basic functionality. + * 2) 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 > "IDisposable \n#if !SWIG_DOTNET_1\n , System.Collections.Generic.IDictionary<$typemap(cstype, K), $typemap(cstype, T)>\n#endif\n"; +%typemap(cscode) std::map<K, T, C > %{ + + 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; + } + } + +#if !SWIG_DOTNET_1 + + public System.Collections.Generic.ICollection<$typemap(cstype, K)> Keys { + get { + System.Collections.Generic.ICollection<$typemap(cstype, K)> keys = new System.Collections.Generic.List<$typemap(cstype, K)>(); + int size = this.Count; + if (size > 0) { + IntPtr iter = create_iterator_begin(); + for (int i = 0; i < size; i++) { + keys.Add(get_next_key(iter)); + } + destroy_iterator(iter); + } + return keys; + } + } + + public System.Collections.Generic.ICollection<$typemap(cstype, T)> Values { + get { + System.Collections.Generic.ICollection<$typemap(cstype, T)> vals = new System.Collections.Generic.List<$typemap(cstype, T)>(); + foreach (System.Collections.Generic.KeyValuePair<$typemap(cstype, K), $typemap(cstype, T)> pair in this) { + vals.Add(pair.Value); + } + return vals; + } + } + + public void Add(System.Collections.Generic.KeyValuePair<$typemap(cstype, K), $typemap(cstype, T)> item) { + Add(item.Key, item.Value); + } + + public bool Remove(System.Collections.Generic.KeyValuePair<$typemap(cstype, K), $typemap(cstype, T)> item) { + if (Contains(item)) { + return Remove(item.Key); + } else { + return false; + } + } + + public bool Contains(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(System.Collections.Generic.KeyValuePair<$typemap(cstype, K), $typemap(cstype, T)>[] array) { + CopyTo(array, 0); + } + + public void CopyTo(System.Collections.Generic.KeyValuePair<$typemap(cstype, K), $typemap(cstype, T)>[] array, int arrayIndex) { + if (array == null) + throw new ArgumentNullException("array"); + if (arrayIndex < 0) + throw new ArgumentOutOfRangeException("arrayIndex", "Value is less than zero"); + if (array.Rank > 1) + throw new ArgumentException("Multi dimensional array.", "array"); + if (arrayIndex+this.Count > array.Length) + throw new ArgumentException("Number of elements to copy is too large."); + + System.Collections.Generic.IList<$typemap(cstype, K)> keyList = new 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 System.Collections.Generic.KeyValuePair<$typemap(cstype, K), $typemap(cstype, T)>(currentKey, this[currentKey]), arrayIndex+i); + } + } + + System.Collections.Generic.IEnumerator<System.Collections.Generic.KeyValuePair<$typemap(cstype, K), $typemap(cstype, T)>> System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<$typemap(cstype, K), $typemap(cstype, T)>>.GetEnumerator() { + return new $csclassnameEnumerator(this); + } + + System.Collections.IEnumerator 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 : System.Collections.IEnumerator, + System.Collections.Generic.IEnumerator<System.Collections.Generic.KeyValuePair<$typemap(cstype, K), $typemap(cstype, T)>> + { + private $csclassname collectionRef; + private 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 System.Collections.Generic.List<$typemap(cstype, K)>(collection.Keys); + currentIndex = -1; + currentObject = null; + currentSize = collectionRef.Count; + } + + // Type-safe iterator Current + public System.Collections.Generic.KeyValuePair<$typemap(cstype, K), $typemap(cstype, T)> Current { + get { + if (currentIndex == -1) + throw new InvalidOperationException("Enumeration not started."); + if (currentIndex > currentSize - 1) + throw new InvalidOperationException("Enumeration finished."); + if (currentObject == null) + throw new InvalidOperationException("Collection modified."); + return (System.Collections.Generic.KeyValuePair<$typemap(cstype, K), $typemap(cstype, T)>)currentObject; + } + } + + // Type-unsafe IEnumerator.Current + object 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 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 InvalidOperationException("Collection modified."); + } + } + + public void Dispose() { + currentIndex = -1; + currentObject = null; + } + } +#endif + +%} + + public: + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef K key_type; + typedef T mapped_type; + + map(); + map(const map< K, T, C > &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& val) 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, val)); + } + + 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 + diff --git a/share/swig/2.0.11/csharp/std_pair.i b/share/swig/2.0.11/csharp/std_pair.i new file mode 100644 index 0000000..0712ad7 --- /dev/null +++ b/share/swig/2.0.11/csharp/std_pair.i @@ -0,0 +1,34 @@ +/* ----------------------------------------------------------------------------- + * std_pair.i + * + * SWIG typemaps for std::pair + * ----------------------------------------------------------------------------- */ + +%include <std_common.i> +%include <exception.i> + +// ------------------------------------------------------------------------ +// std::pair +// ------------------------------------------------------------------------ + +%{ +#include <utility> +%} + +namespace std { + + template<class T, class U> struct pair { + + pair(); + pair(T t, U u); + pair(const pair& p); + + template <class U1, class U2> pair(const pair<U1, U2> &p); + + T first; + U second; + }; + + // add specializations here + +} diff --git a/share/swig/2.0.11/csharp/std_shared_ptr.i b/share/swig/2.0.11/csharp/std_shared_ptr.i new file mode 100644 index 0000000..df87367 --- /dev/null +++ b/share/swig/2.0.11/csharp/std_shared_ptr.i @@ -0,0 +1,2 @@ +#define SWIG_SHARED_PTR_NAMESPACE std +%include <boost_shared_ptr.i> diff --git a/share/swig/2.0.11/csharp/std_string.i b/share/swig/2.0.11/csharp/std_string.i new file mode 100644 index 0000000..5f8fa44 --- /dev/null +++ b/share/swig/2.0.11/csharp/std_string.i @@ -0,0 +1,111 @@ +/* ----------------------------------------------------------------------------- + * 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 "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 = SWIG_csharp_string_callback($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 & "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 = SWIG_csharp_string_callback($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; %} + +} + diff --git a/share/swig/2.0.11/csharp/std_vector.i b/share/swig/2.0.11/csharp/std_vector.i new file mode 100644 index 0000000..5a21ad3 --- /dev/null +++ b/share/swig/2.0.11/csharp/std_vector.i @@ -0,0 +1,421 @@ +/* ----------------------------------------------------------------------------- + * 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. + * For .NET 1 compatibility, define SWIG_DOTNET_1 when compiling the C# code; then the C# wrapper is + * made to look and feel like a typesafe C# System.Collections.ArrayList. + * + * 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>; + * + * 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(CSINTERFACE, CONST_REFERENCE, CTYPE...) +%typemap(csinterfaces) std::vector< CTYPE > "IDisposable, System.Collections.IEnumerable\n#if !SWIG_DOTNET_1\n , System.Collections.Generic.CSINTERFACE<$typemap(cstype, CTYPE)>\n#endif\n"; +%typemap(cscode) std::vector< CTYPE > %{ + public $csclassname(System.Collections.ICollection c) : this() { + if (c == null) + throw new ArgumentNullException("c"); + 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 < size()) + throw new ArgumentOutOfRangeException("Capacity"); + reserve((uint)value); + } + } + + public int Count { + get { + return (int)size(); + } + } + + public bool IsSynchronized { + get { + return false; + } + } + +#if SWIG_DOTNET_1 + public void CopyTo(System.Array array) +#else + public void CopyTo($typemap(cstype, CTYPE)[] array) +#endif + { + CopyTo(0, array, 0, this.Count); + } + +#if SWIG_DOTNET_1 + public void CopyTo(System.Array array, int arrayIndex) +#else + public void CopyTo($typemap(cstype, CTYPE)[] array, int arrayIndex) +#endif + { + CopyTo(0, array, arrayIndex, this.Count); + } + +#if SWIG_DOTNET_1 + public void CopyTo(int index, System.Array array, int arrayIndex, int count) +#else + public void CopyTo(int index, $typemap(cstype, CTYPE)[] array, int arrayIndex, int count) +#endif + { + if (array == null) + throw new ArgumentNullException("array"); + if (index < 0) + throw new ArgumentOutOfRangeException("index", "Value is less than zero"); + if (arrayIndex < 0) + throw new ArgumentOutOfRangeException("arrayIndex", "Value is less than zero"); + if (count < 0) + throw new ArgumentOutOfRangeException("count", "Value is less than zero"); + if (array.Rank > 1) + throw new ArgumentException("Multi dimensional array.", "array"); + if (index+count > this.Count || arrayIndex+count > array.Length) + throw new ArgumentException("Number of elements to copy is too large."); + for (int i=0; i<count; i++) + array.SetValue(getitemcopy(index+i), arrayIndex+i); + } + +#if !SWIG_DOTNET_1 + System.Collections.Generic.IEnumerator<$typemap(cstype, CTYPE)> System.Collections.Generic.IEnumerable<$typemap(cstype, CTYPE)>.GetEnumerator() { + return new $csclassnameEnumerator(this); + } +#endif + + System.Collections.IEnumerator 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 : System.Collections.IEnumerator +#if !SWIG_DOTNET_1 + , System.Collections.Generic.IEnumerator<$typemap(cstype, CTYPE)> +#endif + { + 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 InvalidOperationException("Enumeration not started."); + if (currentIndex > currentSize - 1) + throw new InvalidOperationException("Enumeration finished."); + if (currentObject == null) + throw new InvalidOperationException("Collection modified."); + return ($typemap(cstype, CTYPE))currentObject; + } + } + + // Type-unsafe IEnumerator.Current + object 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 InvalidOperationException("Collection modified."); + } + } + +#if !SWIG_DOTNET_1 + public void Dispose() { + currentIndex = -1; + currentObject = null; + } +#endif + } +%} + + public: + typedef size_t size_type; + typedef CTYPE value_type; + 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, %arg(CTYPE const&), %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, T const&, T) + }; + // specialization for pointers + template<class T> class vector<T *> { + SWIG_STD_VECTOR_MINIMUM_INTERNAL(IList, T *const&, T *) + SWIG_STD_VECTOR_EXTRA_OP_EQUALS_EQUALS(T *) + }; + // 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> + diff --git a/share/swig/2.0.11/csharp/std_wstring.i b/share/swig/2.0.11/csharp/std_wstring.i new file mode 100644 index 0000000..9142d36 --- /dev/null +++ b/share/swig/2.0.11/csharp/std_wstring.i @@ -0,0 +1,114 @@ +/* ----------------------------------------------------------------------------- + * std_wstring.i + * + * Typemaps for std::wstring and const std::wstring& + * These are mapped to a C# String and are passed around by value. + * + * 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> +%} + +namespace std { + +%naturalvar wstring; + +class wstring; + +// wstring +%typemap(ctype, out="void *") wstring "wchar_t *" +%typemap(imtype, inattributes="[MarshalAs(UnmanagedType.LPWStr)]") wstring "string" +%typemap(cstype) wstring "string" +%typemap(csdirectorin) wstring "$iminput" +%typemap(csdirectorout) wstring "$cscall" + +%typemap(in, canthrow=1) wstring +%{ if (!$input) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "null wstring", 0); + return $null; + } + $1.assign($input); %} +%typemap(out) wstring %{ $result = SWIG_csharp_wstring_callback($1.c_str()); %} + +%typemap(directorout, canthrow=1) wstring +%{ if (!$input) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "null wstring", 0); + return $null; + } + $result.assign($input); %} + +%typemap(directorin) wstring %{ $input = SWIG_csharp_wstring_callback($1.c_str()); %} + +%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 +%{ std::string message($1.begin(), $1.end()); + SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, message.c_str()); + return $null; %} + +// const wstring & +%typemap(ctype, out="void *") const wstring & "wchar_t *" +%typemap(imtype, inattributes="[MarshalAs(UnmanagedType.LPWStr)]") const wstring & "string" +%typemap(cstype) const wstring & "string" + +%typemap(csdirectorin) const wstring & "$iminput" +%typemap(csdirectorout) const wstring & "$cscall" + +%typemap(in, canthrow=1) const wstring & +%{ if (!$input) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "null wstring", 0); + return $null; + } + std::wstring $1_str($input); + $1 = &$1_str; %} +%typemap(out) const wstring & %{ $result = SWIG_csharp_wstring_callback($1->c_str()); %} + +%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 = $input; + $result = &$1_str; %} + +%typemap(directorin) const wstring & %{ $input = SWIG_csharp_wstring_callback($1.c_str()); %} + +%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 & +%{ std::string message($1.begin(), $1.end()); + SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, message.c_str()); + return $null; %} + +} + diff --git a/share/swig/2.0.11/csharp/stl.i b/share/swig/2.0.11/csharp/stl.i new file mode 100644 index 0000000..9d2e91e --- /dev/null +++ b/share/swig/2.0.11/csharp/stl.i @@ -0,0 +1,12 @@ +/* ----------------------------------------------------------------------------- + * stl.i + * + * Initial STL definition. extended as needed in each language + * ----------------------------------------------------------------------------- */ + +%include <std_common.i> +%include <std_string.i> +%include <std_vector.i> +%include <std_map.i> +%include <std_pair.i> + diff --git a/share/swig/2.0.11/csharp/typemaps.i b/share/swig/2.0.11/csharp/typemaps.i new file mode 100644 index 0000000..79f5596 --- /dev/null +++ b/share/swig/2.0.11/csharp/typemaps.i @@ -0,0 +1,253 @@ +/* ----------------------------------------------------------------------------- + * 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="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="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="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 + diff --git a/share/swig/2.0.11/csharp/wchar.i b/share/swig/2.0.11/csharp/wchar.i new file mode 100644 index 0000000..1d95edd --- /dev/null +++ b/share/swig/2.0.11/csharp/wchar.i @@ -0,0 +1,102 @@ +/* ----------------------------------------------------------------------------- + * wchar.i + * + * Typemaps for the wchar_t type + * These are mapped to a C# String and are passed around by value. + * + * 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_ +%insert(runtime) %{ +/* Callback for returning strings to C# without leaking memory */ +typedef void * (SWIGSTDCALL* SWIG_CSharpWStringHelperCallback)(const wchar_t *); +static SWIG_CSharpWStringHelperCallback SWIG_csharp_wstring_callback = NULL; +%} + +%pragma(csharp) imclasscode=%{ + protected class SWIGWStringHelper { + + public delegate string SWIGWStringDelegate(IntPtr message); + static SWIGWStringDelegate wstringDelegate = new SWIGWStringDelegate(CreateWString); + + [DllImport("$dllimport", EntryPoint="SWIGRegisterWStringCallback_$module")] + public static extern void SWIGRegisterWStringCallback_$module(SWIGWStringDelegate wstringDelegate); + + static string CreateWString([MarshalAs(UnmanagedType.LPWStr)]IntPtr cString) { + return System.Runtime.InteropServices.Marshal.PtrToStringUni(cString); + } + + static SWIGWStringHelper() { + SWIGRegisterWStringCallback_$module(wstringDelegate); + } + } + + static protected SWIGWStringHelper swigWStringHelper = new SWIGWStringHelper(); +%} + +%insert(runtime) %{ +#ifdef __cplusplus +extern "C" +#endif +SWIGEXPORT void SWIGSTDCALL SWIGRegisterWStringCallback_$module(SWIG_CSharpWStringHelperCallback callback) { + SWIG_csharp_wstring_callback = callback; +} +%} +#endif // SWIG_CSHARP_WSTRING_HELPER_ +#endif // SWIG_CSHARP_NO_WSTRING_HELPER + + +// wchar_t +%typemap(ctype) wchar_t "wchar_t" +%typemap(imtype) wchar_t "char" +%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 * +%typemap(ctype) wchar_t * "wchar_t *" +%typemap(imtype, inattributes="[MarshalAs(UnmanagedType.LPWStr)]", out="IntPtr" ) wchar_t * "string" +%typemap(cstype) wchar_t * "string" + +%typemap(csin) wchar_t * "$csinput" +%typemap(csout, excode=SWIGEXCODE) wchar_t * { + string ret = System.Runtime.InteropServices.Marshal.PtrToStringUni($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) wchar_t * %{ $1 = ($1_ltype)$input; %} +%typemap(out) wchar_t * %{ $result = (wchar_t *)$1; %} + +%typemap(typecheck) wchar_t * = char *; + |