Merge trunk (up to just after swig 2.0.5 release - rev 13009) to gsoc2008-cherylfoil
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2008-cherylfoil@13017 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
commit
af1c6ac3c3
1811 changed files with 94580 additions and 35569 deletions
140
Lib/csharp/arrays_csharp.i
Normal file
140
Lib/csharp/arrays_csharp.i
Normal file
|
|
@ -0,0 +1,140 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* See the LICENSE file for information on copyright, usage and redistribution
|
||||
* of SWIG, and the README file for authors - http://www.swig.org/release.html.
|
||||
*
|
||||
* 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)
|
||||
|
||||
511
Lib/csharp/boost_intrusive_ptr.i
Normal file
511
Lib/csharp/boost_intrusive_ptr.i
Normal file
|
|
@ -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 > ($&1_type argp, 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
|
||||
|
||||
|
|
@ -1,7 +1,15 @@
|
|||
// 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>
|
||||
|
||||
%define SWIG_SHARED_PTR_TYPEMAPS(PROXYCLASS, CONST, TYPE...)
|
||||
// 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 >;
|
||||
|
||||
|
|
@ -10,6 +18,7 @@
|
|||
//"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) %{
|
||||
|
|
@ -33,7 +42,7 @@
|
|||
// 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) {
|
||||
if (!$1) {
|
||||
SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "$1_type reference is null", 0);
|
||||
return $null;
|
||||
} %}
|
||||
|
|
@ -41,10 +50,10 @@
|
|||
%{ $result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_$owner); %}
|
||||
|
||||
// plain pointer by reference
|
||||
%typemap(in) CONST TYPE *& ($*1_ltype temp = 0)
|
||||
%{ temp = (((SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)$input) ? ((SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)$input)->get() : 0);
|
||||
%typemap(in) TYPE *CONST& ($*1_ltype temp = 0)
|
||||
%{ temp = (TYPE *)(((SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)$input) ? ((SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)$input)->get() : 0);
|
||||
$1 = &temp; %}
|
||||
%typemap(out, fragment="SWIG_null_deleter") CONST TYPE *&
|
||||
%typemap(out, fragment="SWIG_null_deleter") TYPE *CONST&
|
||||
%{ $result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1 SWIG_NO_NULL_DELETER_$owner); %}
|
||||
|
||||
// shared_ptr by value
|
||||
|
|
@ -93,51 +102,51 @@
|
|||
%typemap (cstype) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >,
|
||||
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > &,
|
||||
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *,
|
||||
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& "PROXYCLASS"
|
||||
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& "$typemap(cstype, TYPE)"
|
||||
|
||||
%typemap(csin) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >,
|
||||
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > &,
|
||||
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *,
|
||||
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& "PROXYCLASS.getCPtr($csinput)"
|
||||
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& "$typemap(cstype, TYPE).getCPtr($csinput)"
|
||||
|
||||
%typemap(csout, excode=SWIGEXCODE) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > {
|
||||
IntPtr cPtr = $imcall;
|
||||
PROXYCLASS ret = (cPtr == IntPtr.Zero) ? null : new PROXYCLASS(cPtr, true);$excode
|
||||
$typemap(cstype, TYPE) ret = (cPtr == IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode
|
||||
return ret;
|
||||
}
|
||||
%typemap(csout, excode=SWIGEXCODE) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & {
|
||||
IntPtr cPtr = $imcall;
|
||||
PROXYCLASS ret = (cPtr == IntPtr.Zero) ? null : new PROXYCLASS(cPtr, true);$excode
|
||||
$typemap(cstype, TYPE) ret = (cPtr == IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode
|
||||
return ret;
|
||||
}
|
||||
%typemap(csout, excode=SWIGEXCODE) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * {
|
||||
IntPtr cPtr = $imcall;
|
||||
PROXYCLASS ret = (cPtr == IntPtr.Zero) ? null : new PROXYCLASS(cPtr, true);$excode
|
||||
$typemap(cstype, TYPE) ret = (cPtr == IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode
|
||||
return ret;
|
||||
}
|
||||
%typemap(csout, excode=SWIGEXCODE) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& {
|
||||
IntPtr cPtr = $imcall;
|
||||
PROXYCLASS ret = (cPtr == IntPtr.Zero) ? null : new PROXYCLASS(cPtr, true);$excode
|
||||
$typemap(cstype, TYPE) ret = (cPtr == IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
%typemap(csout, excode=SWIGEXCODE) CONST TYPE {
|
||||
PROXYCLASS ret = new PROXYCLASS($imcall, true);$excode
|
||||
$typemap(cstype, TYPE) ret = new $typemap(cstype, TYPE)($imcall, true);$excode
|
||||
return ret;
|
||||
}
|
||||
%typemap(csout, excode=SWIGEXCODE) CONST TYPE & {
|
||||
PROXYCLASS ret = new PROXYCLASS($imcall, true);$excode
|
||||
$typemap(cstype, TYPE) ret = new $typemap(cstype, TYPE)($imcall, true);$excode
|
||||
return ret;
|
||||
}
|
||||
%typemap(csout, excode=SWIGEXCODE) CONST TYPE * {
|
||||
IntPtr cPtr = $imcall;
|
||||
PROXYCLASS ret = (cPtr == IntPtr.Zero) ? null : new PROXYCLASS(cPtr, true);$excode
|
||||
$typemap(cstype, TYPE) ret = (cPtr == IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode
|
||||
return ret;
|
||||
}
|
||||
%typemap(csout, excode=SWIGEXCODE) CONST TYPE *& {
|
||||
%typemap(csout, excode=SWIGEXCODE) TYPE *CONST& {
|
||||
IntPtr cPtr = $imcall;
|
||||
PROXYCLASS ret = (cPtr == IntPtr.Zero) ? null : new PROXYCLASS(cPtr, true);$excode
|
||||
$typemap(cstype, TYPE) ret = (cPtr == IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
@ -156,13 +165,13 @@
|
|||
%typemap(csvarout, excode=SWIGEXCODE2) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & %{
|
||||
get {
|
||||
IntPtr cPtr = $imcall;
|
||||
PROXYCLASS ret = (cPtr == IntPtr.Zero) ? null : new PROXYCLASS(cPtr, true);$excode
|
||||
$typemap(cstype, TYPE) ret = (cPtr == IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode
|
||||
return ret;
|
||||
} %}
|
||||
%typemap(csvarout, excode=SWIGEXCODE2) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * %{
|
||||
get {
|
||||
IntPtr cPtr = $imcall;
|
||||
PROXYCLASS ret = (cPtr == IntPtr.Zero) ? null : new PROXYCLASS(cPtr, true);$excode
|
||||
$typemap(cstype, TYPE) ret = (cPtr == IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode
|
||||
return ret;
|
||||
} %}
|
||||
|
||||
|
|
@ -172,12 +181,12 @@
|
|||
private HandleRef swigCPtr;
|
||||
private bool swigCMemOwnBase;
|
||||
|
||||
internal $csclassname(IntPtr cPtr, bool cMemoryOwn) {
|
||||
PTRCTOR_VISIBILITY $csclassname(IntPtr cPtr, bool cMemoryOwn) {
|
||||
swigCMemOwnBase = cMemoryOwn;
|
||||
swigCPtr = new HandleRef(this, cPtr);
|
||||
}
|
||||
|
||||
internal static HandleRef getCPtr($csclassname obj) {
|
||||
CPTR_VISIBILITY static HandleRef getCPtr($csclassname obj) {
|
||||
return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
|
||||
}
|
||||
%}
|
||||
|
|
@ -187,43 +196,43 @@
|
|||
private HandleRef swigCPtr;
|
||||
private bool swigCMemOwnDerived;
|
||||
|
||||
internal $csclassname(IntPtr cPtr, bool cMemoryOwn) : base($imclassname.$csclassname_SWIGSharedPtrUpcast(cPtr), true) {
|
||||
PTRCTOR_VISIBILITY $csclassname(IntPtr cPtr, bool cMemoryOwn) : base($imclassname.$csclazznameSWIGSmartPtrUpcast(cPtr), true) {
|
||||
swigCMemOwnDerived = cMemoryOwn;
|
||||
swigCPtr = new HandleRef(this, cPtr);
|
||||
}
|
||||
|
||||
internal static HandleRef getCPtr($csclassname obj) {
|
||||
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 && swigCMemOwnBase) {
|
||||
swigCMemOwnBase = false;
|
||||
$imcall;
|
||||
if (swigCPtr.Handle != IntPtr.Zero) {
|
||||
if (swigCMemOwnBase) {
|
||||
swigCMemOwnBase = false;
|
||||
$imcall;
|
||||
}
|
||||
swigCPtr = new HandleRef(null, IntPtr.Zero);
|
||||
}
|
||||
swigCPtr = new HandleRef(null, IntPtr.Zero);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
}
|
||||
|
||||
%typemap(csdestruct_derived, methodname="Dispose", methodmodifiers="public") TYPE {
|
||||
lock(this) {
|
||||
if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwnDerived) {
|
||||
swigCMemOwnDerived = false;
|
||||
$imcall;
|
||||
if (swigCPtr.Handle != IntPtr.Zero) {
|
||||
if (swigCMemOwnDerived) {
|
||||
swigCMemOwnDerived = false;
|
||||
$imcall;
|
||||
}
|
||||
swigCPtr = new HandleRef(null, IntPtr.Zero);
|
||||
}
|
||||
swigCPtr = new HandleRef(null, IntPtr.Zero);
|
||||
GC.SuppressFinalize(this);
|
||||
base.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
%typemap(imtype) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > swigSharedPtrUpcast "IntPtr"
|
||||
%typemap(csin) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > swigSharedPtrUpcast "PROXYCLASS.getCPtr($csinput).Handle"
|
||||
|
||||
|
||||
%template() SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >;
|
||||
%enddef
|
||||
|
||||
|
|
|
|||
|
|
@ -297,19 +297,19 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
|
|||
temp = ($*1_ltype)$input;
|
||||
$result = &temp; %}
|
||||
|
||||
%typemap(directorin) const bool & "$input = $1_name;"
|
||||
%typemap(directorin) const char & "$input = $1_name;"
|
||||
%typemap(directorin) const signed char & "$input = $1_name;"
|
||||
%typemap(directorin) const unsigned char & "$input = $1_name;"
|
||||
%typemap(directorin) const short & "$input = $1_name;"
|
||||
%typemap(directorin) const unsigned short & "$input = $1_name;"
|
||||
%typemap(directorin) const int & "$input = $1_name;"
|
||||
%typemap(directorin) const unsigned int & "$input = $1_name;"
|
||||
%typemap(directorin) const long & "$input = $1_name;"
|
||||
%typemap(directorin) const unsigned long & "$input = $1_name;"
|
||||
%typemap(directorin) const long long & "$input = $1_name;"
|
||||
%typemap(directorin) const float & "$input = $1_name;"
|
||||
%typemap(directorin) const double & "$input = $1_name;"
|
||||
%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 float & "$input = $1;"
|
||||
%typemap(directorin) const double & "$input = $1;"
|
||||
|
||||
%typemap(csdirectorin) const char & ($*1_ltype temp),
|
||||
const signed char & ($*1_ltype temp),
|
||||
|
|
@ -393,7 +393,7 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
|
|||
SWIG_UnpackData($input, (void *)&$1, sizeof($1));
|
||||
%}
|
||||
%typemap(in, canthrow=1) SWIGTYPE & %{ $1 = ($1_ltype)$input;
|
||||
if(!$1) {
|
||||
if (!$1) {
|
||||
SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "$1_type type is null", 0);
|
||||
return $null;
|
||||
} %}
|
||||
|
|
@ -522,6 +522,7 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
|
|||
SWIGTYPE,
|
||||
SWIGTYPE *,
|
||||
SWIGTYPE &,
|
||||
SWIGTYPE *const&,
|
||||
SWIGTYPE [],
|
||||
SWIGTYPE (CLASS::*)
|
||||
""
|
||||
|
|
@ -782,23 +783,33 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
|
|||
} %}
|
||||
|
||||
/* Pointer reference typemaps */
|
||||
%typemap(ctype) SWIGTYPE *& "void *"
|
||||
%typemap(imtype, out="IntPtr") SWIGTYPE *& "HandleRef"
|
||||
%typemap(cstype) SWIGTYPE *& "$*csclassname"
|
||||
%typemap(csin) SWIGTYPE *& "$*csclassname.getCPtr($csinput)"
|
||||
%typemap(csout, excode=SWIGEXCODE) SWIGTYPE *& {
|
||||
%typemap(ctype) SWIGTYPE *const& "void *"
|
||||
%typemap(imtype, out="IntPtr") SWIGTYPE *const& "HandleRef"
|
||||
%typemap(cstype) SWIGTYPE *const& "$*csclassname"
|
||||
%typemap(csin) SWIGTYPE *const& "$*csclassname.getCPtr($csinput)"
|
||||
%typemap(csout, excode=SWIGEXCODE) SWIGTYPE *const& {
|
||||
IntPtr cPtr = $imcall;
|
||||
$*csclassname ret = (cPtr == IntPtr.Zero) ? null : new $*csclassname(cPtr, $owner);$excode
|
||||
return ret;
|
||||
}
|
||||
%typemap(in) SWIGTYPE *& ($*1_ltype temp = 0)
|
||||
%typemap(in) SWIGTYPE *const& ($*1_ltype temp = 0)
|
||||
%{ temp = ($*1_ltype)$input;
|
||||
$1 = &temp; %}
|
||||
%typemap(out) SWIGTYPE *&
|
||||
$1 = ($1_ltype)&temp; %}
|
||||
%typemap(out) SWIGTYPE *const&
|
||||
%{ $result = (void *)*$1; %}
|
||||
|
||||
/* Array reference typemaps */
|
||||
%apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) }
|
||||
/* Marshal C/C++ pointer to IntPtr */
|
||||
%typemap(ctype) void *VOID_INT_PTR "void *"
|
||||
%typemap(imtype) void *VOID_INT_PTR "IntPtr"
|
||||
%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::*) ""
|
||||
|
|
@ -809,66 +820,78 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
|
|||
%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) SWIGTYPE %{
|
||||
%typemap(csbody) TYPE %{
|
||||
private HandleRef swigCPtr;
|
||||
protected bool swigCMemOwn;
|
||||
|
||||
internal $csclassname(IntPtr cPtr, bool cMemoryOwn) {
|
||||
PTRCTOR_VISIBILITY $csclassname(IntPtr cPtr, bool cMemoryOwn) {
|
||||
swigCMemOwn = cMemoryOwn;
|
||||
swigCPtr = new HandleRef(this, cPtr);
|
||||
}
|
||||
|
||||
internal static HandleRef getCPtr($csclassname obj) {
|
||||
CPTR_VISIBILITY static HandleRef getCPtr($csclassname obj) {
|
||||
return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
|
||||
}
|
||||
%}
|
||||
|
||||
// Derived proxy classes
|
||||
%typemap(csbody_derived) SWIGTYPE %{
|
||||
%typemap(csbody_derived) TYPE %{
|
||||
private HandleRef swigCPtr;
|
||||
|
||||
internal $csclassname(IntPtr cPtr, bool cMemoryOwn) : base($imclassname.$csclassnameUpcast(cPtr), cMemoryOwn) {
|
||||
PTRCTOR_VISIBILITY $csclassname(IntPtr cPtr, bool cMemoryOwn) : base($imclassname.$csclazznameSWIGUpcast(cPtr), cMemoryOwn) {
|
||||
swigCPtr = new HandleRef(this, cPtr);
|
||||
}
|
||||
|
||||
internal static HandleRef getCPtr($csclassname obj) {
|
||||
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) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [] %{
|
||||
%typemap(csbody) TYPE *, TYPE &, TYPE [] %{
|
||||
private HandleRef swigCPtr;
|
||||
|
||||
internal $csclassname(IntPtr cPtr, bool futureUse) {
|
||||
PTRCTOR_VISIBILITY $csclassname(IntPtr cPtr, bool futureUse) {
|
||||
swigCPtr = new HandleRef(this, cPtr);
|
||||
}
|
||||
|
||||
protected $csclassname() {
|
||||
DEFAULTCTOR_VISIBILITY $csclassname() {
|
||||
swigCPtr = new HandleRef(null, IntPtr.Zero);
|
||||
}
|
||||
|
||||
internal static HandleRef getCPtr($csclassname obj) {
|
||||
CPTR_VISIBILITY static HandleRef getCPtr($csclassname obj) {
|
||||
return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
|
||||
}
|
||||
%}
|
||||
|
||||
%typemap(csbody) SWIGTYPE (CLASS::*) %{
|
||||
%typemap(csbody) TYPE (CLASS::*) %{
|
||||
private string swigCMemberPtr;
|
||||
|
||||
internal $csclassname(string cMemberPtr, bool futureUse) {
|
||||
PTRCTOR_VISIBILITY $csclassname(string cMemberPtr, bool futureUse) {
|
||||
swigCMemberPtr = cMemberPtr;
|
||||
}
|
||||
|
||||
protected $csclassname() {
|
||||
DEFAULTCTOR_VISIBILITY $csclassname() {
|
||||
swigCMemberPtr = null;
|
||||
}
|
||||
|
||||
internal static string getCMemberPtr($csclassname obj) {
|
||||
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() {
|
||||
|
|
@ -882,22 +905,26 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
|
|||
|
||||
%typemap(csdestruct, methodname="Dispose", methodmodifiers="public") SWIGTYPE {
|
||||
lock(this) {
|
||||
if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) {
|
||||
swigCMemOwn = false;
|
||||
$imcall;
|
||||
if (swigCPtr.Handle != IntPtr.Zero) {
|
||||
if (swigCMemOwn) {
|
||||
swigCMemOwn = false;
|
||||
$imcall;
|
||||
}
|
||||
swigCPtr = new HandleRef(null, IntPtr.Zero);
|
||||
}
|
||||
swigCPtr = new HandleRef(null, IntPtr.Zero);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
}
|
||||
|
||||
%typemap(csdestruct_derived, methodname="Dispose", methodmodifiers="public") SWIGTYPE {
|
||||
lock(this) {
|
||||
if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) {
|
||||
swigCMemOwn = false;
|
||||
$imcall;
|
||||
if (swigCPtr.Handle != IntPtr.Zero) {
|
||||
if (swigCMemOwn) {
|
||||
swigCMemOwn = false;
|
||||
$imcall;
|
||||
}
|
||||
swigCPtr = new HandleRef(null, IntPtr.Zero);
|
||||
}
|
||||
swigCPtr = new HandleRef(null, IntPtr.Zero);
|
||||
GC.SuppressFinalize(this);
|
||||
base.Dispose();
|
||||
}
|
||||
|
|
@ -936,12 +963,21 @@ using System.Runtime.InteropServices;
|
|||
%apply unsigned long { size_t };
|
||||
%apply const unsigned long & { const size_t & };
|
||||
|
||||
/* Array reference typemaps */
|
||||
%apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) }
|
||||
|
||||
/* const pointers */
|
||||
%apply SWIGTYPE * { SWIGTYPE *const }
|
||||
|
||||
/* csharp keywords */
|
||||
%include <csharpkw.swg>
|
||||
|
||||
// Default enum handling
|
||||
%include <enums.swg>
|
||||
|
||||
// For vararg handling in macros, from swigmacros.swg
|
||||
#define %arg(X...) X
|
||||
|
||||
/*
|
||||
// Alternative char * typemaps.
|
||||
%pragma(csharp) imclasscode=%{
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ static SWIG_CSharpException_t SWIG_csharp_exceptions[] = {
|
|||
static SWIG_CSharpExceptionArgument_t SWIG_csharp_exceptions_argument[] = {
|
||||
{ SWIG_CSharpArgumentException, NULL },
|
||||
{ SWIG_CSharpArgumentNullException, NULL },
|
||||
{ SWIG_CSharpArgumentOutOfRangeException, NULL },
|
||||
{ SWIG_CSharpArgumentOutOfRangeException, NULL }
|
||||
};
|
||||
|
||||
static void SWIGUNUSED SWIG_CSharpSetPendingException(SWIG_CSharpExceptionCodes code, const char *msg) {
|
||||
|
|
@ -319,6 +319,14 @@ SWIGEXPORT void SWIGSTDCALL SWIGRegisterStringCallback_$module(SWIG_CSharpString
|
|||
%}
|
||||
#endif // SWIG_CSHARP_NO_STRING_HELPER
|
||||
|
||||
#if !defined(SWIG_CSHARP_NO_IMCLASS_STATIC_CONSTRUCTOR)
|
||||
// Ensure the class is not marked beforefieldinit
|
||||
%pragma(csharp) imclasscode=%{
|
||||
static $imclassname() {
|
||||
}
|
||||
%}
|
||||
#endif
|
||||
|
||||
%insert(runtime) %{
|
||||
/* Contract support */
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
%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_name;"
|
||||
%typemap(directorin) const enum SWIGTYPE & "$input = $1;"
|
||||
%typemap(csdirectorin) const enum SWIGTYPE & "($*csclassname)$iminput"
|
||||
%typemap(csdirectorout) const enum SWIGTYPE & "(int)$cscall"
|
||||
|
||||
|
|
@ -51,7 +51,7 @@
|
|||
%typemap(out) enum SWIGTYPE %{ $result = $1; %}
|
||||
|
||||
%typemap(directorout) enum SWIGTYPE %{ $result = ($1_ltype)$input; %}
|
||||
%typemap(directorin) enum SWIGTYPE "$input = $1;"
|
||||
%typemap(directorin) enum SWIGTYPE "$input = $1;"
|
||||
%typemap(csdirectorin) enum SWIGTYPE "($csclassname)$iminput"
|
||||
%typemap(csdirectorout) enum SWIGTYPE "(int)$cscall"
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
%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_name;"
|
||||
%typemap(directorin) const enum SWIGTYPE & "$input = $1;"
|
||||
%typemap(csdirectorin) const enum SWIGTYPE & "$iminput"
|
||||
%typemap(csdirectorout) const enum SWIGTYPE & "$cscall"
|
||||
|
||||
|
|
@ -53,7 +53,7 @@
|
|||
%typemap(out) enum SWIGTYPE %{ $result = $1; %}
|
||||
|
||||
%typemap(directorout) enum SWIGTYPE %{ $result = ($1_ltype)$input; %}
|
||||
%typemap(directorin) enum SWIGTYPE "$input = $1;"
|
||||
%typemap(directorin) enum SWIGTYPE "$input = $1;"
|
||||
%typemap(csdirectorin) enum SWIGTYPE "$iminput"
|
||||
%typemap(csdirectorout) enum SWIGTYPE "$cscall"
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
%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_name;"
|
||||
%typemap(directorin) const enum SWIGTYPE & "$input = $1;"
|
||||
%typemap(csdirectorin) const enum SWIGTYPE & "$*csclassname.swigToEnum($iminput)"
|
||||
%typemap(csdirectorout) const enum SWIGTYPE & "$cscall.swigValue"
|
||||
|
||||
|
|
@ -52,7 +52,7 @@
|
|||
%typemap(out) enum SWIGTYPE %{ $result = $1; %}
|
||||
|
||||
%typemap(directorout) enum SWIGTYPE %{ $result = ($1_ltype)$input; %}
|
||||
%typemap(directorin) enum SWIGTYPE "$input = $1;"
|
||||
%typemap(directorin) enum SWIGTYPE "$input = $1;"
|
||||
%typemap(csdirectorin) enum SWIGTYPE "$csclassname.swigToEnum($iminput)"
|
||||
%typemap(csdirectorout) enum SWIGTYPE "$cscall.swigValue"
|
||||
|
||||
|
|
|
|||
|
|
@ -1,172 +1,311 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* std_map.i
|
||||
*
|
||||
* SWIG typemaps for std::map
|
||||
* SWIG typemaps for std::map< K, T >
|
||||
*
|
||||
* 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 <std_common.i>
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// std::map
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
%{
|
||||
#include <map>
|
||||
#include <algorithm>
|
||||
#include <stdexcept>
|
||||
%}
|
||||
|
||||
// exported class
|
||||
/* K is the C++ key type, T is the C++ value type */
|
||||
%define SWIG_STD_MAP_INTERNAL(K, T)
|
||||
|
||||
namespace std {
|
||||
%typemap(csinterfaces) std::map< K, T > "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 > %{
|
||||
|
||||
template<class K, class T> class map {
|
||||
// add typemaps here
|
||||
public:
|
||||
map();
|
||||
map(const map<K,T> &);
|
||||
|
||||
unsigned int size() const;
|
||||
bool empty() const;
|
||||
void clear();
|
||||
%extend {
|
||||
T& get(const K& key) throw (std::out_of_range) {
|
||||
std::map<K,T >::iterator i = self->find(key);
|
||||
if (i != self->end())
|
||||
return i->second;
|
||||
else
|
||||
throw std::out_of_range("key not found");
|
||||
}
|
||||
void set(const K& key, const T& x) {
|
||||
(*self)[key] = x;
|
||||
}
|
||||
void del(const K& key) throw (std::out_of_range) {
|
||||
std::map<K,T >::iterator i = self->find(key);
|
||||
if (i != self->end())
|
||||
self->erase(i);
|
||||
else
|
||||
throw std::out_of_range("key not found");
|
||||
}
|
||||
bool has_key(const K& key) {
|
||||
std::map<K,T >::iterator i = self->find(key);
|
||||
return i != self->end();
|
||||
}
|
||||
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:
|
||||
map();
|
||||
map(const map< K, T > &other);
|
||||
|
||||
typedef K key_type;
|
||||
typedef T mapped_type;
|
||||
typedef size_t size_type;
|
||||
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 >::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 >::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 >::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 >::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 >::iterator *create_iterator_begin }
|
||||
%apply void *VOID_INT_PTR { std::map< K, T >::iterator *swigiterator }
|
||||
|
||||
std::map< K, T >::iterator *create_iterator_begin() {
|
||||
return new std::map< K, T >::iterator($self->begin());
|
||||
}
|
||||
|
||||
const key_type& get_next_key(std::map< K, T >::iterator *swigiterator) {
|
||||
std::map< K, T >::iterator iter = *swigiterator;
|
||||
(*swigiterator)++;
|
||||
return (*iter).first;
|
||||
}
|
||||
|
||||
void destroy_iterator(std::map< K, T >::iterator *swigiterator) {
|
||||
delete swigiterator;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// specializations for built-ins
|
||||
%enddef
|
||||
|
||||
%define specialize_std_map_on_key(K,CHECK,CONVERT_FROM,CONVERT_TO)
|
||||
|
||||
template<class T> class map<K,T> {
|
||||
// add typemaps here
|
||||
public:
|
||||
map();
|
||||
map(const map<K,T> &);
|
||||
|
||||
unsigned int size() const;
|
||||
bool empty() const;
|
||||
void clear();
|
||||
%extend {
|
||||
T& get(K key) throw (std::out_of_range) {
|
||||
std::map<K,T >::iterator i = self->find(key);
|
||||
if (i != self->end())
|
||||
return i->second;
|
||||
else
|
||||
throw std::out_of_range("key not found");
|
||||
}
|
||||
void set(K key, const T& x) {
|
||||
(*self)[key] = x;
|
||||
}
|
||||
void del(K key) throw (std::out_of_range) {
|
||||
std::map<K,T >::iterator i = self->find(key);
|
||||
if (i != self->end())
|
||||
self->erase(i);
|
||||
else
|
||||
throw std::out_of_range("key not found");
|
||||
}
|
||||
bool has_key(K key) {
|
||||
std::map<K,T >::iterator i = self->find(key);
|
||||
return i != self->end();
|
||||
}
|
||||
}
|
||||
};
|
||||
%enddef
|
||||
|
||||
%define specialize_std_map_on_value(T,CHECK,CONVERT_FROM,CONVERT_TO)
|
||||
template<class K> class map<K,T> {
|
||||
// add typemaps here
|
||||
public:
|
||||
map();
|
||||
map(const map<K,T> &);
|
||||
|
||||
unsigned int size() const;
|
||||
bool empty() const;
|
||||
void clear();
|
||||
%extend {
|
||||
T get(const K& key) throw (std::out_of_range) {
|
||||
std::map<K,T >::iterator i = self->find(key);
|
||||
if (i != self->end())
|
||||
return i->second;
|
||||
else
|
||||
throw std::out_of_range("key not found");
|
||||
}
|
||||
void set(const K& key, T x) {
|
||||
(*self)[key] = x;
|
||||
}
|
||||
void del(const K& key) throw (std::out_of_range) {
|
||||
std::map<K,T >::iterator i = self->find(key);
|
||||
if (i != self->end())
|
||||
self->erase(i);
|
||||
else
|
||||
throw std::out_of_range("key not found");
|
||||
}
|
||||
bool has_key(const K& key) {
|
||||
std::map<K,T >::iterator i = self->find(key);
|
||||
return i != self->end();
|
||||
}
|
||||
}
|
||||
};
|
||||
%enddef
|
||||
|
||||
%define specialize_std_map_on_both(K,CHECK_K,CONVERT_K_FROM,CONVERT_K_TO,
|
||||
T,CHECK_T,CONVERT_T_FROM,CONVERT_T_TO)
|
||||
template<> class map<K,T> {
|
||||
// add typemaps here
|
||||
public:
|
||||
map();
|
||||
map(const map<K,T> &);
|
||||
|
||||
unsigned int size() const;
|
||||
bool empty() const;
|
||||
void clear();
|
||||
%extend {
|
||||
T get(K key) throw (std::out_of_range) {
|
||||
std::map<K,T >::iterator i = self->find(key);
|
||||
if (i != self->end())
|
||||
return i->second;
|
||||
else
|
||||
throw std::out_of_range("key not found");
|
||||
}
|
||||
void set(K key, T x) {
|
||||
(*self)[key] = x;
|
||||
}
|
||||
void del(K key) throw (std::out_of_range) {
|
||||
std::map<K,T >::iterator i = self->find(key);
|
||||
if (i != self->end())
|
||||
self->erase(i);
|
||||
else
|
||||
throw std::out_of_range("key not found");
|
||||
}
|
||||
bool has_key(K key) {
|
||||
std::map<K,T >::iterator i = self->find(key);
|
||||
return i != self->end();
|
||||
}
|
||||
}
|
||||
};
|
||||
%enddef
|
||||
|
||||
// add specializations here
|
||||
%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 map {
|
||||
SWIG_STD_MAP_INTERNAL(K, T)
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
// 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
|
||||
|
||||
|
|
|
|||
2
Lib/csharp/std_shared_ptr.i
Normal file
2
Lib/csharp/std_shared_ptr.i
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
#define SWIG_SHARED_PTR_NAMESPACE std
|
||||
%include <boost_shared_ptr.i>
|
||||
252
Lib/csharp/std_vector.i
Executable file → Normal file
252
Lib/csharp/std_vector.i
Executable file → Normal file
|
|
@ -1,17 +1,22 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* std_vector.i
|
||||
*
|
||||
* SWIG typemaps for std::vector
|
||||
* SWIG typemaps for std::vector<T>
|
||||
* C# implementation
|
||||
* The C# wrapper is made to look and feel like a typesafe C# System.Collections.ArrayList
|
||||
* All the methods in IList are defined, but we don't derive from IList as this is a typesafe collection.
|
||||
* Warning: heavy macro usage in this file. Use swig -E to get a sane view on the real file contents!
|
||||
* 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.
|
||||
*
|
||||
* Very often the C# generated code will not compile as the C++ template type is not the same as the C#
|
||||
* proxy type, so use the SWIG_STD_VECTOR_SPECIALIZE or SWIG_STD_VECTOR_SPECIALIZE_MINIMUM macro, eg
|
||||
* 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_SPECIALIZE_MINIMUM(Klass, SomeNamespace::Klass)
|
||||
* 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.
|
||||
|
|
@ -20,14 +25,13 @@
|
|||
%include <std_common.i>
|
||||
|
||||
// MACRO for use within the std::vector class body
|
||||
// CSTYPE and CTYPE respectively correspond to the types in the cstype and ctype typemaps
|
||||
%define SWIG_STD_VECTOR_MINIMUM(CSTYPE, CTYPE...)
|
||||
%typemap(csinterfaces) std::vector<CTYPE > "IDisposable, System.Collections.IEnumerable";
|
||||
%typemap(cscode) std::vector<CTYPE > %{
|
||||
%define SWIG_STD_VECTOR_MINIMUM_INTERNAL(CSINTERFACE, CONST_REFERENCE, CTYPE...)
|
||||
%typemap(csinterfaces) std::vector< CTYPE > "IDisposable, System.Collections.IEnumerable\n#if !SWIG_DOTNET_1\n , System.Collections.Generic.CSINTERFACE<$typemap(cstype, CTYPE)>\n#endif\n";
|
||||
%typemap(cscode) std::vector< CTYPE > %{
|
||||
public $csclassname(System.Collections.ICollection c) : this() {
|
||||
if (c == null)
|
||||
throw new ArgumentNullException("c");
|
||||
foreach (CSTYPE element in c) {
|
||||
foreach ($typemap(cstype, CTYPE) element in c) {
|
||||
this.Add(element);
|
||||
}
|
||||
}
|
||||
|
|
@ -44,7 +48,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
public CSTYPE this[int index] {
|
||||
public $typemap(cstype, CTYPE) this[int index] {
|
||||
get {
|
||||
return getitem(index);
|
||||
}
|
||||
|
|
@ -76,15 +80,30 @@
|
|||
}
|
||||
}
|
||||
|
||||
public void CopyTo(System.Array array) {
|
||||
#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);
|
||||
}
|
||||
|
||||
public void CopyTo(System.Array array, int arrayIndex) {
|
||||
#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);
|
||||
}
|
||||
|
||||
public void CopyTo(int index, System.Array array, int arrayIndex, int 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)
|
||||
|
|
@ -94,14 +113,19 @@
|
|||
if (count < 0)
|
||||
throw new ArgumentOutOfRangeException("count", "Value is less than zero");
|
||||
if (array.Rank > 1)
|
||||
throw new ArgumentException("Multi dimensional array.");
|
||||
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);
|
||||
}
|
||||
|
||||
// Type-safe version of IEnumerable.GetEnumerator
|
||||
#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);
|
||||
}
|
||||
|
|
@ -115,7 +139,11 @@
|
|||
/// 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 {
|
||||
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;
|
||||
|
|
@ -129,7 +157,7 @@
|
|||
}
|
||||
|
||||
// Type-safe iterator Current
|
||||
public CSTYPE Current {
|
||||
public $typemap(cstype, CTYPE) Current {
|
||||
get {
|
||||
if (currentIndex == -1)
|
||||
throw new InvalidOperationException("Enumeration not started.");
|
||||
|
|
@ -137,7 +165,7 @@
|
|||
throw new InvalidOperationException("Enumeration finished.");
|
||||
if (currentObject == null)
|
||||
throw new InvalidOperationException("Collection modified.");
|
||||
return (CSTYPE)currentObject;
|
||||
return ($typemap(cstype, CTYPE))currentObject;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -167,28 +195,36 @@
|
|||
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 value_type& const_reference;
|
||||
typedef CONST_REFERENCE const_reference;
|
||||
%rename(Clear) clear;
|
||||
void clear();
|
||||
%rename(Add) push_back;
|
||||
void push_back(const value_type& x);
|
||||
void push_back(CTYPE const& x);
|
||||
size_type size() const;
|
||||
size_type capacity() const;
|
||||
void reserve(size_type n);
|
||||
%newobject GetRange(int index, int count);
|
||||
%newobject Repeat(const value_type& value, int count);
|
||||
%newobject Repeat(CTYPE const& value, int count);
|
||||
vector();
|
||||
vector(const vector &other);
|
||||
%extend {
|
||||
vector(int capacity) throw (std::out_of_range) {
|
||||
std::vector<CTYPE >* pv = 0;
|
||||
std::vector< CTYPE >* pv = 0;
|
||||
if (capacity >= 0) {
|
||||
pv = new std::vector<CTYPE >();
|
||||
pv = new std::vector< CTYPE >();
|
||||
pv->reserve(capacity);
|
||||
} else {
|
||||
throw std::out_of_range("capacity");
|
||||
|
|
@ -196,53 +232,53 @@
|
|||
return pv;
|
||||
}
|
||||
CTYPE getitemcopy(int index) throw (std::out_of_range) {
|
||||
if (index>=0 && index<(int)self->size())
|
||||
return (*self)[index];
|
||||
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];
|
||||
if (index>=0 && index<(int)$self->size())
|
||||
return (*$self)[index];
|
||||
else
|
||||
throw std::out_of_range("index");
|
||||
}
|
||||
void setitem(int index, const value_type& val) throw (std::out_of_range) {
|
||||
if (index>=0 && index<(int)self->size())
|
||||
(*self)[index] = val;
|
||||
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());
|
||||
void AddRange(const std::vector< CTYPE >& values) {
|
||||
$self->insert($self->end(), values.begin(), values.end());
|
||||
}
|
||||
// Takes a deep copy of the elements unlike ArrayList.GetRange
|
||||
std::vector<CTYPE > *GetRange(int index, int count) throw (std::out_of_range, std::invalid_argument) {
|
||||
std::vector< CTYPE > *GetRange(int index, int count) throw (std::out_of_range, std::invalid_argument) {
|
||||
if (index < 0)
|
||||
throw std::out_of_range("index");
|
||||
if (count < 0)
|
||||
throw std::out_of_range("count");
|
||||
if (index >= (int)self->size()+1 || index+count > (int)self->size())
|
||||
if (index >= (int)$self->size()+1 || index+count > (int)$self->size())
|
||||
throw std::invalid_argument("invalid range");
|
||||
return new std::vector<CTYPE >(self->begin()+index, self->begin()+index+count);
|
||||
return new std::vector< CTYPE >($self->begin()+index, $self->begin()+index+count);
|
||||
}
|
||||
void Insert(int index, const value_type& x) throw (std::out_of_range) {
|
||||
if (index>=0 && index<(int)self->size())
|
||||
self->insert(self->begin()+index, x);
|
||||
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())
|
||||
self->insert(self->begin()+index, values.begin(), values.end());
|
||||
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);
|
||||
if (index>=0 && index<(int)$self->size())
|
||||
$self->erase($self->begin() + index);
|
||||
else
|
||||
throw std::out_of_range("index");
|
||||
}
|
||||
|
|
@ -251,87 +287,90 @@
|
|||
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())
|
||||
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);
|
||||
$self->erase($self->begin()+index, $self->begin()+index+count);
|
||||
}
|
||||
static std::vector<CTYPE > *Repeat(const value_type& value, int count) throw (std::out_of_range) {
|
||||
static std::vector< CTYPE > *Repeat(CTYPE const& value, int count) throw (std::out_of_range) {
|
||||
if (count < 0)
|
||||
throw std::out_of_range("count");
|
||||
return new std::vector<CTYPE >(count, value);
|
||||
return new std::vector< CTYPE >(count, value);
|
||||
}
|
||||
void Reverse() {
|
||||
std::reverse(self->begin(), self->end());
|
||||
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())
|
||||
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);
|
||||
std::reverse($self->begin()+index, $self->begin()+index+count);
|
||||
}
|
||||
// Takes a deep copy of the elements unlike ArrayList.SetRange
|
||||
void SetRange(int index, const std::vector<CTYPE >& values) throw (std::out_of_range) {
|
||||
void SetRange(int index, const std::vector< CTYPE >& values) throw (std::out_of_range) {
|
||||
if (index < 0)
|
||||
throw std::out_of_range("index");
|
||||
if (index+values.size() > self->size())
|
||||
if (index+values.size() > $self->size())
|
||||
throw std::out_of_range("index");
|
||||
std::copy(values.begin(), values.end(), self->begin()+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
|
||||
// CSTYPE and CTYPE respectively correspond to the types in the cstype and ctype typemaps
|
||||
%define SWIG_STD_VECTOR_EXTRA_OP_EQUALS_EQUALS(CSTYPE, CTYPE...)
|
||||
// The class will then implement IList<>, which adds extra functionality
|
||||
%define SWIG_STD_VECTOR_EXTRA_OP_EQUALS_EQUALS(CTYPE...)
|
||||
%extend {
|
||||
bool Contains(const value_type& value) {
|
||||
return std::find(self->begin(), self->end(), value) != self->end();
|
||||
bool Contains(CTYPE const& value) {
|
||||
return std::find($self->begin(), $self->end(), value) != $self->end();
|
||||
}
|
||||
int IndexOf(const value_type& value) {
|
||||
int IndexOf(CTYPE const& value) {
|
||||
int index = -1;
|
||||
std::vector<CTYPE >::iterator it = std::find(self->begin(), self->end(), value);
|
||||
if (it != self->end())
|
||||
index = (int)(it - self->begin());
|
||||
std::vector< CTYPE >::iterator it = std::find($self->begin(), $self->end(), value);
|
||||
if (it != $self->end())
|
||||
index = (int)(it - $self->begin());
|
||||
return index;
|
||||
}
|
||||
int LastIndexOf(const value_type& value) {
|
||||
int LastIndexOf(CTYPE const& value) {
|
||||
int index = -1;
|
||||
std::vector<CTYPE >::reverse_iterator rit = std::find(self->rbegin(), self->rend(), value);
|
||||
if (rit != self->rend())
|
||||
index = (int)(self->rend() - 1 - rit);
|
||||
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;
|
||||
}
|
||||
void Remove(const value_type& value) {
|
||||
std::vector<CTYPE >::iterator it = std::find(self->begin(), self->end(), value);
|
||||
if (it != self->end())
|
||||
self->erase(it);
|
||||
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
|
||||
// CSTYPE and CTYPE respectively correspond to the types in the cstype and ctype typemaps
|
||||
%define SWIG_STD_VECTOR_SPECIALIZE(CSTYPE, CTYPE...)
|
||||
// Macros for std::vector class specializations/enhancements
|
||||
%define SWIG_STD_VECTOR_ENHANCED(CTYPE...)
|
||||
namespace std {
|
||||
template<> class vector<CTYPE > {
|
||||
SWIG_STD_VECTOR_MINIMUM(CSTYPE, CTYPE)
|
||||
SWIG_STD_VECTOR_EXTRA_OP_EQUALS_EQUALS(CSTYPE, CTYPE)
|
||||
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...)
|
||||
namespace std {
|
||||
template<> class vector<CTYPE > {
|
||||
SWIG_STD_VECTOR_MINIMUM(CSTYPE, CTYPE)
|
||||
};
|
||||
}
|
||||
#warning SWIG_STD_VECTOR_SPECIALIZE_MINIMUM macro deprecated, it is no longer required
|
||||
%enddef
|
||||
|
||||
|
||||
%{
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
|
|
@ -349,33 +388,34 @@ namespace std {
|
|||
// primary (unspecialized) class template for std::vector
|
||||
// does not require operator== to be defined
|
||||
template<class T> class vector {
|
||||
SWIG_STD_VECTOR_MINIMUM(T, T)
|
||||
SWIG_STD_VECTOR_MINIMUM_INTERNAL(IEnumerable, T const&, T)
|
||||
};
|
||||
// specializations for pointers
|
||||
template<class T> class vector<T*> {
|
||||
SWIG_STD_VECTOR_MINIMUM(T, T*)
|
||||
// specialization for pointers
|
||||
template<class T> class vector<T *> {
|
||||
SWIG_STD_VECTOR_MINIMUM_INTERNAL(IList, T *const&, T *)
|
||||
SWIG_STD_VECTOR_EXTRA_OP_EQUALS_EQUALS(T *)
|
||||
};
|
||||
template<class T> class vector<const T*> {
|
||||
SWIG_STD_VECTOR_MINIMUM(T, const 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_SPECIALIZE(bool, bool)
|
||||
SWIG_STD_VECTOR_SPECIALIZE(char, char)
|
||||
SWIG_STD_VECTOR_SPECIALIZE(sbyte, signed char)
|
||||
SWIG_STD_VECTOR_SPECIALIZE(byte, unsigned char)
|
||||
SWIG_STD_VECTOR_SPECIALIZE(short, short)
|
||||
SWIG_STD_VECTOR_SPECIALIZE(ushort, unsigned short)
|
||||
SWIG_STD_VECTOR_SPECIALIZE(int, int)
|
||||
SWIG_STD_VECTOR_SPECIALIZE(uint, unsigned int)
|
||||
SWIG_STD_VECTOR_SPECIALIZE(int, long)
|
||||
SWIG_STD_VECTOR_SPECIALIZE(uint, unsigned long)
|
||||
SWIG_STD_VECTOR_SPECIALIZE(long, long long)
|
||||
SWIG_STD_VECTOR_SPECIALIZE(ulong, unsigned long long)
|
||||
SWIG_STD_VECTOR_SPECIALIZE(float, float)
|
||||
SWIG_STD_VECTOR_SPECIALIZE(double, double)
|
||||
SWIG_STD_VECTOR_SPECIALIZE(string, std::string) // also requires a %include <std_string.i>
|
||||
|
||||
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>
|
||||
|
||||
|
|
|
|||
0
Lib/csharp/std_wstring.i
Executable file → Normal file
0
Lib/csharp/std_wstring.i
Executable file → Normal file
|
|
@ -51,29 +51,17 @@ or you can use the %apply directive :
|
|||
|
||||
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) TYPE *INPUT, TYPE &INPUT "CTYPE"
|
||||
%typemap(imtype) TYPE *INPUT, TYPE &INPUT "CSTYPE"
|
||||
%typemap(cstype) TYPE *INPUT, TYPE &INPUT "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(csdirectorin) TYPE *INPUT, TYPE &INPUT "$iminput"
|
||||
%typemap(csdirectorout) TYPE *INPUT, TYPE &INPUT "$cscall"
|
||||
|
||||
%typemap(in) TYPE *INPUT, TYPE &INPUT
|
||||
%{ $1 = ($1_ltype)&$input; %}
|
||||
|
||||
%typemap(directorout) TYPE *INPUT, TYPE &INPUT
|
||||
%{ $result = ($1_ltype)&$input; %}
|
||||
|
||||
%typemap(directorin) TYPE &INPUT
|
||||
%{ $input = (CTYPE *)$1; %}
|
||||
|
||||
%typemap(directorin) TYPE *INPUT
|
||||
%{ $input = (CTYPE *)$1; %}
|
||||
|
||||
%typemap(typecheck) TYPE *INPUT = TYPE;
|
||||
%typemap(typecheck) TYPE &INPUT = TYPE;
|
||||
%enddef
|
||||
|
|
@ -143,32 +131,17 @@ 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) TYPE *OUTPUT, TYPE &OUTPUT "CTYPE *"
|
||||
%typemap(imtype) TYPE *OUTPUT, TYPE &OUTPUT "out CSTYPE"
|
||||
%typemap(cstype) TYPE *OUTPUT, TYPE &OUTPUT "out CSTYPE"
|
||||
%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(csdirectorin) TYPE *OUTPUT, TYPE &OUTPUT "$iminput"
|
||||
%typemap(csdirectorout) TYPE *OUTPUT, TYPE &OUTPUT "$cscall"
|
||||
|
||||
|
||||
%typemap(in) TYPE *OUTPUT, TYPE &OUTPUT
|
||||
%{ $1 = ($1_ltype)$input; %}
|
||||
|
||||
%typemap(directorout,warning="Need to provide TYPE *OUTPUT directorout typemap") TYPE *OUTPUT, TYPE &OUTPUT {
|
||||
}
|
||||
|
||||
%typemap(directorin) TYPE &OUTPUT
|
||||
%{ $input = &$1; %}
|
||||
|
||||
%typemap(directorin,warning="Need to provide TYPE *OUTPUT directorin typemap, TYPE array length is unknown") TYPE *OUTPUT
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
%typecheck(SWIG_TYPECHECK_##TYPECHECKPRECEDENCE) TYPE *OUTPUT, TYPE &OUTPUT ""
|
||||
%enddef
|
||||
|
||||
|
|
@ -189,6 +162,10 @@ OUTPUT_TYPEMAP(double, double, double, DOUBLE_PTR)
|
|||
|
||||
#undef OUTPUT_TYPEMAP
|
||||
|
||||
%typemap(in) bool *OUTPUT, bool &OUTPUT
|
||||
%{ *$input = 0;
|
||||
$1 = ($1_ltype)$input; %}
|
||||
|
||||
|
||||
/*
|
||||
INOUT typemaps
|
||||
|
|
@ -246,26 +223,14 @@ of the function return value.
|
|||
*/
|
||||
|
||||
%define INOUT_TYPEMAP(TYPE, CTYPE, CSTYPE, TYPECHECKPRECEDENCE)
|
||||
%typemap(ctype) TYPE *INOUT, TYPE &INOUT "CTYPE *"
|
||||
%typemap(imtype) TYPE *INOUT, TYPE &INOUT "ref CSTYPE"
|
||||
%typemap(cstype) TYPE *INOUT, TYPE &INOUT "ref CSTYPE"
|
||||
%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(csdirectorin) TYPE *INOUT, TYPE &INOUT "$iminput"
|
||||
%typemap(csdirectorout) TYPE *INOUT, TYPE &INOUT "$cscall"
|
||||
|
||||
%typemap(in) TYPE *INOUT, TYPE &INOUT
|
||||
%{ $1 = ($1_ltype)$input; %}
|
||||
|
||||
%typemap(directorout,warning="Need to provide TYPE *INOUT directorout typemap") TYPE *INOUT, TYPE &INOUT {
|
||||
}
|
||||
|
||||
%typemap(directorin) TYPE &INOUT
|
||||
%{ $input = &$1; %}
|
||||
|
||||
%typemap(directorin,warning="Need to provide TYPE *INOUT directorin typemap, TYPE array length is unknown") TYPE *INOUT, TYPE &INOUT
|
||||
{
|
||||
}
|
||||
|
||||
%typecheck(SWIG_TYPECHECK_##TYPECHECKPRECEDENCE) TYPE *INOUT, TYPE &INOUT ""
|
||||
%enddef
|
||||
|
||||
|
|
|
|||
204
Lib/csharp/wchar.i
Executable file → Normal file
204
Lib/csharp/wchar.i
Executable file → Normal file
|
|
@ -1,102 +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 *;
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* 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 *;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue