Home | History | Annotate | Download | only in csharp
      1 // Users can provide their own SWIG_INTRUSIVE_PTR_TYPEMAPS or SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP macros before including this file to change the
      2 // visibility of the constructor and getCPtr method if desired to public if using multiple modules.
      3 #ifndef SWIG_INTRUSIVE_PTR_TYPEMAPS
      4 #define SWIG_INTRUSIVE_PTR_TYPEMAPS(CONST, TYPE...) SWIG_INTRUSIVE_PTR_TYPEMAPS_IMPLEMENTATION(internal, internal, CONST, TYPE)
      5 #endif
      6 #ifndef SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP
      7 #define SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP(CONST, TYPE...) SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP_IMPLEMENTATION(internal, internal, CONST, TYPE)
      8 #endif
      9 
     10 %include <intrusive_ptr.i>
     11 
     12 // Language specific macro implementing all the customisations for handling the smart pointer
     13 %define SWIG_INTRUSIVE_PTR_TYPEMAPS_IMPLEMENTATION(PTRCTOR_VISIBILITY, CPTR_VISIBILITY, CONST, TYPE...)
     14 
     15 // %naturalvar is as documented for member variables
     16 %naturalvar TYPE;
     17 %naturalvar SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >;
     18 
     19 // destructor wrapper customisation
     20 %feature("unref") TYPE "(void)arg1; delete smartarg1;"
     21 
     22 // Typemap customisations...
     23 
     24 %typemap(in, canthrow=1) CONST TYPE ($&1_type argp = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) %{
     25   // plain value
     26   argp = (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0;
     27   if (!argp) {
     28     SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null $1_type", 0);
     29     return $null;
     30   }
     31   $1 = *argp;
     32 %}
     33 %typemap(out, fragment="SWIG_intrusive_deleter") CONST TYPE %{
     34   //plain value(out)
     35   $1_ltype* resultp = new $1_ltype(($1_ltype &)$1);
     36   intrusive_ptr_add_ref(resultp);
     37   *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(resultp, SWIG_intrusive_deleter< CONST TYPE >());
     38 %}
     39 
     40 %typemap(in, canthrow=1) CONST TYPE * (SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) %{
     41   // plain pointer
     42   smartarg = *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input;
     43   $1 = (TYPE *)(smartarg ? smartarg->get() : 0);
     44 %}
     45 %typemap(out, fragment="SWIG_intrusive_deleter,SWIG_null_deleter") CONST TYPE * %{
     46   //plain pointer(out)
     47   #if ($owner)
     48   if ($1) {
     49     intrusive_ptr_add_ref($1);
     50     *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1, SWIG_intrusive_deleter< CONST TYPE >());
     51   } else {
     52     *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0;
     53   }
     54   #else
     55     *(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;
     56   #endif
     57 %}
     58 
     59 %typemap(in, canthrow=1) CONST TYPE & (SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) %{
     60   // plain reference
     61   $1 = ($1_ltype)((*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0);
     62   if(!$1) {
     63     SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "$1_type reference is null", 0);
     64     return $null;
     65   }
     66 %}
     67 %typemap(out, fragment="SWIG_intrusive_deleter,SWIG_null_deleter") CONST TYPE & %{
     68   //plain reference(out)
     69   #if ($owner)
     70   if ($1) {
     71     intrusive_ptr_add_ref($1);
     72     *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1, SWIG_intrusive_deleter< CONST TYPE >());
     73   } else {
     74     *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0;
     75   }
     76   #else
     77     *(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;
     78   #endif
     79 %}
     80 
     81 %typemap(in) TYPE *CONST& ($*1_ltype temp = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) %{
     82   // plain pointer by reference
     83   temp = ($*1_ltype)((*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0);
     84   $1 = &temp;
     85 %}
     86 %typemap(out, fragment="SWIG_intrusive_deleter,SWIG_null_deleter") TYPE *CONST& %{
     87   // plain pointer by reference(out)
     88   #if ($owner)
     89   if (*$1) {
     90     intrusive_ptr_add_ref(*$1);
     91     *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1, SWIG_intrusive_deleter< CONST TYPE >());
     92   } else {
     93     *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0;
     94   }
     95   #else
     96     *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1 SWIG_NO_NULL_DELETER_0);
     97   #endif
     98 %}
     99 
    100 %typemap(in) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > (SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * smartarg) %{
    101   // intrusive_ptr by value
    102   smartarg = *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >**)&$input;
    103   if (smartarg) {
    104     $1 = SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >(smartarg->get(), true);
    105   }
    106 %}
    107 %typemap(out, fragment="SWIG_intrusive_deleter") SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > %{
    108   if ($1) {
    109     intrusive_ptr_add_ref($1.get());
    110     *(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 >());
    111   } else {
    112     *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0;
    113   }
    114 %}
    115 
    116 %typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > swigSharedPtrUpcast ($&1_type smartarg) %{
    117   // shared_ptr by value
    118   smartarg = *($&1_ltype*)&$input;
    119   if (smartarg) $1 = *smartarg;
    120 %}
    121 %typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > ANY_TYPE_SWIGSharedPtrUpcast %{
    122   *($&1_ltype*)&$result = $1 ? new $1_ltype($1) : 0;
    123 %}
    124 
    125 %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) %{
    126   // intrusive_ptr by reference
    127   if ( $input ) {
    128     smartarg = *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >**)&$input;
    129     temp = SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >(smartarg->get(), true);
    130     $1 = &temp;
    131   } else {
    132     $1 = &tempnull;
    133   }
    134 %}
    135 %typemap(memberin) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > & %{
    136   delete &($1);
    137   if ($self) {
    138     SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > * temp = new SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >(*$input);
    139     $1 = *temp;
    140   }
    141 %}
    142 %typemap(out, fragment="SWIG_intrusive_deleter") SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > & %{
    143   if (*$1) {
    144     intrusive_ptr_add_ref($1->get());
    145     *(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 >());
    146   } else {
    147     *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0;
    148   }
    149 %}
    150 
    151 %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) %{
    152   // intrusive_ptr by pointer
    153   if ( $input ) {
    154     smartarg = *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >**)&$input;
    155     temp = SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >(smartarg->get(), true);
    156     $1 = &temp;
    157   } else {
    158     $1 = &tempnull;
    159   }
    160 %}
    161 %typemap(memberin) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > * %{
    162   delete $1;
    163   if ($self) $1 = new SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >(*$input);
    164 %}
    165 %typemap(out, fragment="SWIG_intrusive_deleter") SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > * %{
    166   if ($1 && *$1) {
    167     intrusive_ptr_add_ref($1->get());
    168     *(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 >());
    169   } else {
    170     *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0;
    171   }
    172   if ($owner) delete $1;
    173 %}
    174 
    175 %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) %{
    176   // intrusive_ptr by pointer reference
    177   smartarg = *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >**)&$input;
    178   if ($input) {
    179     temp = SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >(smartarg->get(), true);
    180   }
    181   tempp = &temp;
    182   $1 = &tempp;
    183 %}
    184 %typemap(memberin) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& %{
    185   if ($self) $1 = *$input;
    186 %}
    187 %typemap(out, fragment="SWIG_intrusive_deleter") SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& %{
    188   if (*$1 && **$1) {
    189     intrusive_ptr_add_ref((*$1)->get());
    190     *(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 >());
    191   } else {
    192     *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0;
    193   }
    194 %}
    195 
    196 // various missing typemaps - If ever used (unlikely) ensure compilation error rather than runtime bug
    197 %typemap(in) CONST TYPE[], CONST TYPE[ANY], CONST TYPE (CLASS::*) %{
    198 #error "typemaps for $1_type not available"
    199 %}
    200 %typemap(out) CONST TYPE[], CONST TYPE[ANY], CONST TYPE (CLASS::*) %{
    201 #error "typemaps for $1_type not available"
    202 %}
    203 
    204 
    205 %typemap (ctype)    SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >,
    206                   SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >,
    207                   SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > &,
    208                   SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *,
    209                   SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& "void *"
    210 %typemap (imtype, out="IntPtr")  SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >,
    211                   SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >,
    212                   SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > &,
    213                   SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *,
    214                   SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& "HandleRef"
    215 %typemap (cstype) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >,
    216                   SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >,
    217                   SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > &,
    218                   SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *,
    219                   SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& "$typemap(cstype, TYPE)"
    220 %typemap(csin) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >,
    221                  SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >,
    222                  SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > &,
    223                  SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *,
    224                  SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& "$typemap(cstype, TYPE).getCPtr($csinput)"
    225 
    226 %typemap(csout, excode=SWIGEXCODE) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > {
    227     IntPtr cPtr = $imcall;
    228     $typemap(cstype, TYPE) ret = (cPtr == IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode
    229     return ret;
    230   }
    231 %typemap(csout, excode=SWIGEXCODE) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > {
    232     IntPtr cPtr = $imcall;
    233     $typemap(cstype, TYPE) ret = (cPtr == IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode
    234     return ret;
    235   }
    236 %typemap(csout, excode=SWIGEXCODE) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > & {
    237     IntPtr cPtr = $imcall;
    238     $typemap(cstype, TYPE) ret = (cPtr == IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode
    239     return ret;
    240   }
    241 %typemap(csout, excode=SWIGEXCODE) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > * {
    242     IntPtr cPtr = $imcall;
    243     $typemap(cstype, TYPE) ret = (cPtr == IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode
    244     return ret;
    245   }
    246 %typemap(csout, excode=SWIGEXCODE) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& {
    247     IntPtr cPtr = $imcall;
    248     $typemap(cstype, TYPE) ret = (cPtr == IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode
    249     return ret;
    250   }
    251 %typemap(csvarout, excode=SWIGEXCODE2) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > %{
    252     get {
    253       $typemap(cstype, TYPE) ret = new $typemap(cstype, TYPE)($imcall, true);$excode
    254       return ret;
    255     } %}
    256 %typemap(csvarout, excode=SWIGEXCODE2) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >& %{
    257     get {
    258       $typemap(cstype, TYPE) ret = new $typemap(cstype, TYPE)($imcall, true);$excode
    259       return ret;
    260     } %}
    261 %typemap(csvarout, excode=SWIGEXCODE2) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >* %{
    262     get {
    263       $typemap(cstype, TYPE) ret = new $typemap(cstype, TYPE)($imcall, true);$excode
    264       return ret;
    265     } %}
    266 
    267 
    268 %typemap(csout, excode=SWIGEXCODE) CONST TYPE {
    269     $typemap(cstype, TYPE) ret = new $typemap(cstype, TYPE)($imcall, true);$excode
    270     return ret;
    271   }
    272 %typemap(csout, excode=SWIGEXCODE) CONST TYPE & {
    273     $typemap(cstype, TYPE) ret = new $typemap(cstype, TYPE)($imcall, true);$excode
    274     return ret;
    275   }
    276 %typemap(csout, excode=SWIGEXCODE) CONST TYPE * {
    277     IntPtr cPtr = $imcall;
    278     $typemap(cstype, TYPE) ret = (cPtr == IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode
    279     return ret;
    280   }
    281 %typemap(csout, excode=SWIGEXCODE) TYPE *CONST& {
    282     IntPtr cPtr = $imcall;
    283     $typemap(cstype, TYPE) ret = (cPtr == IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode
    284     return ret;
    285   }
    286 
    287 // Base proxy classes
    288 %typemap(csbody) TYPE %{
    289   private HandleRef swigCPtr;
    290   private bool swigCMemOwnBase;
    291 
    292   PTRCTOR_VISIBILITY $csclassname(IntPtr cPtr, bool cMemoryOwn) {
    293     swigCMemOwnBase = cMemoryOwn;
    294     swigCPtr = new HandleRef(this, cPtr);
    295   }
    296 
    297   CPTR_VISIBILITY static HandleRef getCPtr($csclassname obj) {
    298     return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
    299   }
    300 %}
    301 
    302 // Derived proxy classes
    303 %typemap(csbody_derived) TYPE %{
    304   private HandleRef swigCPtr;
    305   private bool swigCMemOwnDerived;
    306 
    307   PTRCTOR_VISIBILITY $csclassname(IntPtr cPtr, bool cMemoryOwn) : base($imclassname.$csclazznameSWIGSmartPtrUpcast(cPtr), true) {
    308     swigCMemOwnDerived = cMemoryOwn;
    309     swigCPtr = new HandleRef(this, cPtr);
    310   }
    311 
    312   CPTR_VISIBILITY static HandleRef getCPtr($csclassname obj) {
    313     return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
    314   }
    315 %}
    316 
    317 %typemap(csdestruct, methodname="Dispose", methodmodifiers="public") TYPE {
    318     lock(this) {
    319       if (swigCPtr.Handle != IntPtr.Zero) {
    320         if (swigCMemOwnBase) {
    321           swigCMemOwnBase = false;
    322           $imcall;
    323         }
    324         swigCPtr = new HandleRef(null, IntPtr.Zero);
    325       }
    326       GC.SuppressFinalize(this);
    327     }
    328   }
    329 
    330 %typemap(csdestruct_derived, methodname="Dispose", methodmodifiers="public") TYPE {
    331     lock(this) {
    332       if (swigCPtr.Handle != IntPtr.Zero) {
    333         if (swigCMemOwnDerived) {
    334           swigCMemOwnDerived = false;
    335           $imcall;
    336         }
    337         swigCPtr = new HandleRef(null, IntPtr.Zero);
    338       }
    339       GC.SuppressFinalize(this);
    340       base.Dispose();
    341     }
    342   }
    343 
    344 // CONST version needed ???? also for C#
    345 %typemap(imtype, nopgcpp="1") SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > swigSharedPtrUpcast "HandleRef"
    346 %typemap(imtype, nopgcpp="1") SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > swigSharedPtrUpcast "HandleRef"
    347 
    348 
    349 %template() SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >;
    350 %template() SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >;
    351 %enddef
    352 
    353 
    354 /////////////////////////////////////////////////////////////////////
    355 
    356 
    357 %include <shared_ptr.i>
    358 
    359 %define SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP_IMPLEMENTATION(PTRCTOR_VISIBILITY, CPTR_VISIBILITY, CONST, TYPE...)
    360 
    361 %naturalvar TYPE;
    362 %naturalvar SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >;
    363 
    364 // destructor mods
    365 %feature("unref") TYPE "(void)arg1; delete smartarg1;"
    366 
    367 
    368 // plain value
    369 %typemap(in, canthrow=1) CONST TYPE ($&1_type argp = 0) %{
    370   argp = (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0;
    371   if (!argp) {
    372     SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null $1_type", 0);
    373     return $null;
    374   }
    375   $1 = *argp; %}
    376 %typemap(out) CONST TYPE
    377 %{ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(new $1_ltype(($1_ltype &)$1)); %}
    378 
    379 // plain pointer
    380 %typemap(in) CONST TYPE * (SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) %{
    381   smartarg = *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input;
    382   $1 = (TYPE *)(smartarg ? smartarg->get() : 0); %}
    383 %typemap(out, fragment="SWIG_null_deleter") CONST TYPE * %{
    384   *(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;
    385 %}
    386 
    387 // plain reference
    388 %typemap(in, canthrow=1) CONST TYPE & %{
    389   $1 = ($1_ltype)((*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0);
    390   if (!$1) {
    391     SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "$1_type reference is null", 0);
    392     return $null;
    393   } %}
    394 %typemap(out, fragment="SWIG_null_deleter") CONST TYPE &
    395 %{ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_$owner); %}
    396 
    397 // plain pointer by reference
    398 %typemap(in) TYPE *CONST& ($*1_ltype temp = 0)
    399 %{ temp = ($*1_ltype)((*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0);
    400    $1 = &temp; %}
    401 %typemap(out, fragment="SWIG_null_deleter") TYPE *CONST&
    402 %{ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1 SWIG_NO_NULL_DELETER_$owner); %}
    403 
    404 %typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > swigSharedPtrUpcast ($&1_type smartarg) %{
    405   // shared_ptr by value
    406   smartarg = *($&1_ltype*)&$input;
    407   if (smartarg) $1 = *smartarg;
    408 %}
    409 %typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > ANY_TYPE_SWIGSharedPtrUpcast %{
    410   *($&1_ltype*)&$result = $1 ? new $1_ltype($1) : 0;
    411 %}
    412 
    413 // various missing typemaps - If ever used (unlikely) ensure compilation error rather than runtime bug
    414 %typemap(in) CONST TYPE[], CONST TYPE[ANY], CONST TYPE (CLASS::*) %{
    415 #error "typemaps for $1_type not available"
    416 %}
    417 %typemap(out) CONST TYPE[], CONST TYPE[ANY], CONST TYPE (CLASS::*) %{
    418 #error "typemaps for $1_type not available"
    419 %}
    420 
    421 
    422 %typemap (ctype)    SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > "void *"
    423 %typemap (imtype)  SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > "void *"
    424 %typemap (cstype) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > "$typemap(cstype, TYPE)"
    425 %typemap (csin) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > "$typemap(cstype, TYPE).getCPtr($csinput)"
    426 %typemap(csout, excode=SWIGEXCODE) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > {
    427     IntPtr cPtr = $imcall;
    428     return (cPtr == IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);
    429   }
    430 
    431 %typemap(csout, excode=SWIGEXCODE) CONST TYPE {
    432     return new $typemap(cstype, TYPE)($imcall, true);
    433   }
    434 %typemap(csout, excode=SWIGEXCODE) CONST TYPE & {
    435     return new $typemap(cstype, TYPE)($imcall, true);
    436   }
    437 %typemap(csout, excode=SWIGEXCODE) CONST TYPE * {
    438     IntPtr cPtr = $imcall;
    439     return (cPtr == IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);
    440   }
    441 %typemap(csout, excode=SWIGEXCODE) TYPE *CONST& {
    442     IntPtr cPtr = $imcall;
    443     return (cPtr == IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);
    444   }
    445 
    446 // Base proxy classes
    447 %typemap(csbody) TYPE %{
    448   private HandleRef swigCPtr;
    449   private bool swigCMemOwnBase;
    450 
    451   PTRCTOR_VISIBILITY $csclassname(IntPtr cPtr, bool cMemoryOwn) {
    452     swigCMemOwnBase = cMemoryOwn;
    453     swigCPtr = new HandleRef(this, cPtr);
    454   }
    455 
    456   CPTR_VISIBILITY static HandleRef getCPtr($csclassname obj) {
    457     return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
    458   }
    459 %}
    460 
    461 // Derived proxy classes
    462 %typemap(csbody_derived) TYPE %{
    463   private HandleRef swigCPtr;
    464   private bool swigCMemOwnDerived;
    465 
    466   PTRCTOR_VISIBILITY $csclassname(IntPtr cPtr, bool cMemoryOwn) : base($imclassname.$csclazznameSWIGSmartPtrUpcast(cPtr), true) {
    467     swigCMemOwnDerived = cMemoryOwn;
    468     swigCPtr = new HandleRef(this, cPtr);
    469   }
    470 
    471   CPTR_VISIBILITY static HandleRef getCPtr($csclassname obj) {
    472     return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
    473   }
    474 %}
    475 
    476 %typemap(csdestruct, methodname="Dispose", methodmodifiers="public") TYPE {
    477     lock(this) {
    478       if (swigCPtr.Handle != IntPtr.Zero) {
    479         if (swigCMemOwnBase) {
    480           swigCMemOwnBase = false;
    481           $imcall;
    482         }
    483         swigCPtr = new HandleRef(null, IntPtr.Zero);
    484       }
    485       GC.SuppressFinalize(this);
    486     }
    487   }
    488 
    489 %typemap(csdestruct_derived, methodname="Dispose", methodmodifiers="public") TYPE {
    490     lock(this) {
    491       if (swigCPtr.Handle != IntPtr.Zero) {
    492         if (swigCMemOwnDerived) {
    493           swigCMemOwnDerived = false;
    494           $imcall;
    495         }
    496         swigCPtr = new HandleRef(null, IntPtr.Zero);
    497       }
    498       GC.SuppressFinalize(this);
    499       base.Dispose();
    500     }
    501   }
    502 
    503 
    504 // CONST version needed ???? also for C#
    505 %typemap(imtype, nopgcpp="1") SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > swigSharedPtrUpcast "HandleRef"
    506 %typemap(imtype, nopgcpp="1") SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > swigSharedPtrUpcast "HandleRef"
    507 
    508 
    509 %template() SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >;
    510 %enddef
    511 
    512