diff options
Diffstat (limited to 'Examples/test-suite/li_boost_intrusive_ptr.i')
-rw-r--r-- | Examples/test-suite/li_boost_intrusive_ptr.i | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/Examples/test-suite/li_boost_intrusive_ptr.i b/Examples/test-suite/li_boost_intrusive_ptr.i index 4916d0285..c3b211208 100644 --- a/Examples/test-suite/li_boost_intrusive_ptr.i +++ b/Examples/test-suite/li_boost_intrusive_ptr.i @@ -6,6 +6,9 @@ // count the instances of intrusive_ptr. Uncomment the INTRUSIVE_PTR_WRAPPER macro to turn this on. // // Also note the debug_shared flag which can be set from the target language. +// +// Usage of intrusive_ptr_add_ref and intrusive_ptr_release based on boost testing: +// http://www.boost.org/doc/libs/1_36_0/libs/smart_ptr/test/intrusive_ptr_test.cpp %module li_boost_intrusive_ptr @@ -13,10 +16,10 @@ %warnfilter(SWIGWARN_LANG_SMARTPTR_MISSING) KlassDerived; %warnfilter(SWIGWARN_LANG_SMARTPTR_MISSING) KlassDerivedDerived; -%{ -template<typename T> void intrusive_ptr_add_ref(const T* r) { r->addref(); } -template<typename T> void intrusive_ptr_release(const T* r) { r->release(); } +%ignore intrusive_ptr_add_ref; +%ignore intrusive_ptr_release; +%{ #include <boost/shared_ptr.hpp> #include <boost/intrusive_ptr.hpp> #include <boost/detail/atomic_count.hpp> @@ -132,6 +135,8 @@ struct Klass { void release(void) const { if (--count == 0) delete this; } int use_count(void) const { return count; } static long getTotal_count() { return total_count; } + friend void intrusive_ptr_add_ref(const Klass* r) { r->addref(); } + friend void intrusive_ptr_release(const Klass* r) { r->release(); } private: static void increment() { ++total_count; if (debug_shared) cout << " ++xxxxx Klass::increment tot: " << total_count << endl;} @@ -177,6 +182,8 @@ struct IgnoredRefCountingBase { void addref(void) const { ++count; } void release(void) const { if (--count == 0) delete this; } int use_count(void) const { return count; } + inline friend void intrusive_ptr_add_ref(const IgnoredRefCountingBase* r) { r->addref(); } + inline friend void intrusive_ptr_release(const IgnoredRefCountingBase* r) { r->release(); } static long getTotal_count() { return total_count; } private: @@ -414,6 +421,8 @@ template <class T1, class T2> struct Base { void addref(void) const { count++; } void release(void) const { if (--count == 0) delete this; } int use_count(void) const { return count; } + inline friend void intrusive_ptr_add_ref(const Base<T1, T2>* r) { r->addref(); } + inline friend void intrusive_ptr_release(const Base<T1, T2>* r) { r->release(); } }; %} |