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