1 // Allow for different namespaces for shared_ptr / intrusive_ptr - they could be boost or std or std::tr1 2 // For example for std::tr1, use: 3 // #define SWIG_SHARED_PTR_NAMESPACE std 4 // #define SWIG_SHARED_PTR_SUBNAMESPACE tr1 5 // #define SWIG_INTRUSIVE_PTR_NAMESPACE boost 6 // #define SWIG_INTRUSIVE_PTR_SUBNAMESPACE 7 8 #if !defined(SWIG_INTRUSIVE_PTR_NAMESPACE) 9 # define SWIG_INTRUSIVE_PTR_NAMESPACE boost 10 #endif 11 12 #if defined(SWIG_INTRUSIVE_PTR_SUBNAMESPACE) 13 # define SWIG_INTRUSIVE_PTR_QNAMESPACE SWIG_INTRUSIVE_PTR_NAMESPACE::SWIG_INTRUSIVE_PTR_SUBNAMESPACE 14 #else 15 # define SWIG_INTRUSIVE_PTR_QNAMESPACE SWIG_INTRUSIVE_PTR_NAMESPACE 16 #endif 17 18 namespace SWIG_INTRUSIVE_PTR_NAMESPACE { 19 #if defined(SWIG_INTRUSIVE_PTR_SUBNAMESPACE) 20 namespace SWIG_INTRUSIVE_PTR_SUBNAMESPACE { 21 #endif 22 template <class T> class intrusive_ptr { 23 }; 24 #if defined(SWIG_INTRUSIVE_PTR_SUBNAMESPACE) 25 } 26 #endif 27 } 28 29 %fragment("SWIG_intrusive_deleter", "header") { 30 template<class T> struct SWIG_intrusive_deleter { 31 void operator()(T *p) { 32 if (p) 33 intrusive_ptr_release(p); 34 } 35 }; 36 } 37 38 %fragment("SWIG_null_deleter", "header") { 39 struct SWIG_null_deleter { 40 void operator() (void const *) const { 41 } 42 }; 43 %#define SWIG_NO_NULL_DELETER_0 , SWIG_null_deleter() 44 %#define SWIG_NO_NULL_DELETER_1 45 } 46 47 // Workaround empty first macro argument bug 48 #define SWIGEMPTYHACK 49 // Main user macro for defining intrusive_ptr typemaps for both const and non-const pointer types 50 %define %intrusive_ptr(TYPE...) 51 %feature("smartptr", noblock=1) TYPE { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > } 52 SWIG_INTRUSIVE_PTR_TYPEMAPS(SWIGEMPTYHACK, TYPE) 53 SWIG_INTRUSIVE_PTR_TYPEMAPS(const, TYPE) 54 %enddef 55 56 %define %intrusive_ptr_no_wrap(TYPE...) 57 %feature("smartptr", noblock=1) TYPE { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > } 58 SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP(SWIGEMPTYHACK, TYPE) 59 SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP(const, TYPE) 60 %enddef 61 62 // Legacy macros 63 %define SWIG_INTRUSIVE_PTR(PROXYCLASS, TYPE...) 64 #warning "SWIG_INTRUSIVE_PTR(PROXYCLASS, TYPE) is deprecated. Please use %intrusive_ptr(TYPE) instead." 65 %intrusive_ptr(TYPE) 66 %enddef 67 68 %define SWIG_INTRUSIVE_PTR_DERIVED(PROXYCLASS, BASECLASSTYPE, TYPE...) 69 #warning "SWIG_INTRUSIVE_PTR_DERIVED(PROXYCLASS, BASECLASSTYPE, TYPE) is deprecated. Please use %intrusive_ptr(TYPE) instead." 70 %intrusive_ptr(TYPE) 71 %enddef 72 73 %define SWIG_INTRUSIVE_PTR_NO_WRAP(PROXYCLASS, TYPE...) 74 #warning "SWIG_INTRUSIVE_PTR_NO_WRAP(PROXYCLASS, TYPE) is deprecated. Please use %intrusive_ptr_no_wrap(TYPE) instead." 75 %intrusive_ptr_no_wrap(TYPE) 76 %enddef 77 78 %define SWIG_INTRUSIVE_PTR_DERIVED_NO_WRAP(PROXYCLASS, BASECLASSTYPE, TYPE...) 79 #warning "SWIG_INTRUSIVE_PTR_DERIVED_NO_WRAP(PROXYCLASS, BASECLASSTYPE, TYPE) is deprecated. Please use %intrusive_ptr_no_wrap(TYPE) instead." 80 %intrusive_ptr_no_wrap(TYPE) 81 %enddef 82 83