PageRenderTime 49ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/trunk/Examples/test-suite/li_boost_intrusive_ptr.i

#
Swig | 498 lines | 426 code | 72 blank | 0 comment | 0 complexity | 7207449c730c14a972f766e4867e8bbe MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1. // This tests intrusive_ptr is working okay. It also checks that there are no memory leaks in the
  2. // class that intrusive_ptr is pointing via a counting mechanism in the constructors and destructor of Klass.
  3. // In order to test that there are no leaks of the intrusive_ptr class itself (as it is created on the heap)
  4. // the runtime tests can be run for a long time to monitor memory leaks using memory monitor tools
  5. // like 'top'. There is a wrapper for intrusive_ptr in intrusive_ptr_wrapper.h which enables one to
  6. // count the instances of intrusive_ptr. Uncomment the INTRUSIVE_PTR_WRAPPER macro to turn this on.
  7. //
  8. // Also note the debug_shared flag which can be set from the target language.
  9. %module li_boost_intrusive_ptr
  10. %warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK);
  11. %warnfilter(SWIGWARN_LANG_SMARTPTR_MISSING) KlassDerived;
  12. %warnfilter(SWIGWARN_LANG_SMARTPTR_MISSING) KlassDerivedDerived;
  13. %inline %{
  14. #include "boost/shared_ptr.hpp"
  15. #include "boost/intrusive_ptr.hpp"
  16. #include <boost/detail/atomic_count.hpp>
  17. // Uncomment macro below to turn on intrusive_ptr memory leak checking as described above
  18. //#define INTRUSIVE_PTR_WRAPPER
  19. #ifdef INTRUSIVE_PTR_WRAPPER
  20. # include "intrusive_ptr_wrapper.h"
  21. # include "shared_ptr_wrapper.h"
  22. #endif
  23. %}
  24. %{
  25. #ifndef INTRUSIVE_PTR_WRAPPER
  26. # define SwigBoost boost
  27. #endif
  28. %}
  29. %include "std_string.i"
  30. #ifndef INTRUSIVE_PTR_WRAPPER
  31. # define SWIG_INTRUSIVE_PTR_NAMESPACE SwigBoost
  32. # define SWIG_SHARED_PTR_NAMESPACE SwigBoost
  33. #endif
  34. #if defined(SWIGJAVA) || defined(SWIGCSHARP)
  35. #define INTRUSIVE_PTR_WRAPPERS_IMPLEMENTED
  36. #endif
  37. #if defined(INTRUSIVE_PTR_WRAPPERS_IMPLEMENTED)
  38. %include <boost_intrusive_ptr.i>
  39. %intrusive_ptr(Space::Klass)
  40. %intrusive_ptr_no_wrap(Space::KlassWithoutRefCount)
  41. %intrusive_ptr(Space::KlassDerived)
  42. %intrusive_ptr(Space::KlassDerivedDerived)
  43. //For the use_count shared_ptr functions
  44. #if defined(SWIGJAVA)
  45. %typemap(in) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::Klass > & ($*1_ltype tempnull) %{
  46. $1 = $input ? *($&1_ltype)&$input : &tempnull;
  47. %}
  48. %typemap (jni) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::Klass > & "jlong"
  49. %typemap (jtype) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::Klass > & "long"
  50. %typemap (jstype) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::Klass > & "Klass"
  51. %typemap(javain) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::Klass > & "Klass.getCPtr($javainput)"
  52. %typemap(in) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::KlassDerived > & ($*1_ltype tempnull) %{
  53. $1 = $input ? *($&1_ltype)&$input : &tempnull;
  54. %}
  55. %typemap (jni) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::KlassDerived > & "jlong"
  56. %typemap (jtype) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::KlassDerived > & "long"
  57. %typemap (jstype) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::KlassDerived > & "KlassDerived"
  58. %typemap(javain) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::KlassDerived > & "KlassDerived.getCPtr($javainput)"
  59. %typemap(in) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::KlassDerivedDerived > & ($*1_ltype tempnull) %{
  60. $1 = $input ? *($&1_ltype)&$input : &tempnull;
  61. %}
  62. %typemap (jni) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::KlassDerivedDerived > & "jlong"
  63. %typemap (jtype) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::KlassDerivedDerived > & "long"
  64. %typemap (jstype) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::KlassDerivedDerived > & "KlassDerivedDerived"
  65. %typemap(javain) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::KlassDerivedDerived > & "KlassDerivedDerived.getCPtr($javainput)"
  66. #elif defined(SWIGCSHARP)
  67. // TODO!
  68. #endif
  69. #endif
  70. // TODO:
  71. // const intrusive_ptr
  72. // std::vector
  73. // Add in generic %extend for the Upcast function for derived classes
  74. // Remove proxy upcast method - implement %feature("shadow") ??? which replaces the proxy method
  75. %exception {
  76. if (debug_shared) {
  77. cout << "++++++" << endl << flush;
  78. cout << "calling $name" << endl << flush;
  79. }
  80. $action
  81. if (debug_shared) {
  82. cout << "------" << endl << flush;
  83. }
  84. }
  85. %ignore IgnoredRefCountingBase;
  86. %ignore *::operator=;
  87. %ignore intrusive_ptr_add_ref;
  88. %ignore intrusive_ptr_release;
  89. %newobject pointerownertest();
  90. %newobject smartpointerpointerownertest();
  91. %inline %{
  92. #include <iostream>
  93. using namespace std;
  94. static bool debug_shared = false;
  95. namespace Space {
  96. struct Klass {
  97. Klass() : value("EMPTY"), count(0) { if (debug_shared) cout << "Klass() [" << value << "]" << endl << flush; increment(); }
  98. Klass(const std::string &val) : value(val), count(0) { if (debug_shared) cout << "Klass(string) [" << value << "]" << endl << flush; increment(); }
  99. virtual ~Klass() { if (debug_shared) cout << "~Klass() [" << value << "]" << endl << flush; decrement(); }
  100. virtual std::string getValue() const { return value; }
  101. void append(const std::string &s) { value += s; }
  102. Klass(const Klass &other) : value(other.value), count(0) { if (debug_shared) cout << "Klass(const Klass&) [" << value << "]" << endl << flush; increment(); }
  103. Klass &operator=(const Klass &other) { value = other.value; return *this; }
  104. void addref(void) const { ++count; }
  105. void release(void) const { if (--count == 0) delete this; }
  106. int use_count(void) const { return count; }
  107. static long getTotal_count() { return total_count; }
  108. private:
  109. static void increment() { ++total_count; if (debug_shared) cout << " ++xxxxx Klass::increment tot: " << total_count << endl;}
  110. static void decrement() { --total_count; if (debug_shared) cout << " --xxxxx Klass::decrement tot: " << total_count << endl;}
  111. static boost::detail::atomic_count total_count;
  112. std::string value;
  113. int array[1024];
  114. mutable boost::detail::atomic_count count;
  115. };
  116. struct KlassWithoutRefCount {
  117. KlassWithoutRefCount() : value("EMPTY") { if (debug_shared) cout << "KlassWithoutRefCount() [" << value << "]" << endl << flush; increment(); }
  118. KlassWithoutRefCount(const std::string &val) : value(val) { if (debug_shared) cout << "KlassWithoutRefCount(string) [" << value << "]" << endl << flush; increment(); }
  119. virtual ~KlassWithoutRefCount() { if (debug_shared) cout << "~KlassWithoutRefCount() [" << value << "]" << endl << flush; decrement(); }
  120. virtual std::string getValue() const { return value; }
  121. void append(const std::string &s) { value += s; }
  122. KlassWithoutRefCount(const KlassWithoutRefCount &other) : value(other.value) { if (debug_shared) cout << "KlassWithoutRefCount(const KlassWithoutRefCount&) [" << value << "]" << endl << flush; increment(); }
  123. std::string getSpecialValueFromUnwrappableClass() { return "this class cannot be wrapped by intrusive_ptrs but we can still use it"; }
  124. KlassWithoutRefCount &operator=(const KlassWithoutRefCount &other) { value = other.value; return *this; }
  125. static long getTotal_count() { return total_count; }
  126. private:
  127. static void increment() { ++total_count; if (debug_shared) cout << " ++xxxxx KlassWithoutRefCount::increment tot: " << total_count << endl;}
  128. static void decrement() { --total_count; if (debug_shared) cout << " --xxxxx KlassWithoutRefCount::decrement tot: " << total_count << endl;}
  129. static boost::detail::atomic_count total_count;
  130. std::string value;
  131. int array[1024];
  132. };
  133. struct IgnoredRefCountingBase {
  134. IgnoredRefCountingBase() : count(0) { if (debug_shared) cout << "IgnoredRefCountingBase()" << endl << flush; increment(); }
  135. IgnoredRefCountingBase(const IgnoredRefCountingBase &other) : count(0) { if (debug_shared) cout << "IgnoredRefCountingBase(const IgnoredRefCountingBase&)" << endl << flush; increment(); }
  136. IgnoredRefCountingBase &operator=(const IgnoredRefCountingBase& other) {
  137. return *this;
  138. }
  139. virtual ~IgnoredRefCountingBase() { if (debug_shared) cout << "~IgnoredRefCountingBase()" << endl << flush; decrement(); }
  140. void addref(void) const { ++count; }
  141. void release(void) const { if (--count == 0) delete this; }
  142. int use_count(void) const { return count; }
  143. static long getTotal_count() { return total_count; }
  144. private:
  145. static void increment() { ++total_count; if (debug_shared) cout << " ++xxxxx IgnoredRefCountingBase::increment tot: " << total_count << endl;}
  146. static void decrement() { --total_count; if (debug_shared) cout << " --xxxxx IgnoredRefCountingBase::decrement tot: " << total_count << endl;}
  147. static boost::detail::atomic_count total_count;
  148. double d;
  149. double e;
  150. mutable boost::detail::atomic_count count;
  151. };
  152. long getTotal_IgnoredRefCountingBase_count() {
  153. return IgnoredRefCountingBase::getTotal_count();
  154. }
  155. // For most compilers, this use of multiple inheritance results in different derived and base class
  156. // pointer values ... for some more challenging tests :)
  157. struct KlassDerived : IgnoredRefCountingBase, KlassWithoutRefCount {
  158. KlassDerived() : KlassWithoutRefCount() { if (debug_shared) cout << "KlassDerived()" << endl << flush; increment(); }
  159. KlassDerived(const std::string &val) : KlassWithoutRefCount(val) { if (debug_shared) cout << "KlassDerived(string) [" << val << "]" << endl << flush; increment(); }
  160. KlassDerived(const KlassDerived &other) : KlassWithoutRefCount(other) { if (debug_shared) cout << "KlassDerived(const KlassDerived&))" << endl << flush; increment(); }
  161. virtual ~KlassDerived() { if (debug_shared) cout << "~KlassDerived()" << endl << flush; decrement(); }
  162. virtual std::string getValue() const { return KlassWithoutRefCount::getValue() + "-Derived"; }
  163. int use_count(void) const { return IgnoredRefCountingBase::use_count(); }
  164. static long getTotal_count() { return total_count; }
  165. private:
  166. static void increment() { ++total_count; if (debug_shared) cout << " ++xxxxx KlassDerived::increment tot: " << total_count << endl;}
  167. static void decrement() { --total_count; if (debug_shared) cout << " --xxxxx KlassDerived::decrement tot: " << total_count << endl;}
  168. static boost::detail::atomic_count total_count;
  169. };
  170. struct KlassDerivedDerived : KlassDerived {
  171. KlassDerivedDerived() : KlassDerived() { if (debug_shared) cout << "KlassDerivedDerived()" << endl << flush; increment(); }
  172. KlassDerivedDerived(const std::string &val) : KlassDerived(val) { if (debug_shared) cout << "KlassDerivedDerived(string) [" << val << "]" << endl << flush; increment(); }
  173. KlassDerivedDerived(const KlassDerived &other) : KlassDerived(other) { if (debug_shared) cout << "KlassDerivedDerived(const KlassDerivedDerived&))" << endl << flush; increment(); }
  174. virtual ~KlassDerivedDerived() { if (debug_shared) cout << "~KlassDerivedDerived()" << endl << flush; decrement(); }
  175. virtual std::string getValue() const { return KlassWithoutRefCount::getValue() + "-DerivedDerived"; }
  176. static long getTotal_count() { return total_count; }
  177. private:
  178. static void increment() { ++total_count; if (debug_shared) cout << " ++xxxxx KlassDerivedDerived::increment tot: " << total_count << endl;}
  179. static void decrement() { --total_count; if (debug_shared) cout << " --xxxxx KlassDerivedDerived::decrement tot: " << total_count << endl;}
  180. static boost::detail::atomic_count total_count;
  181. };
  182. KlassDerived* derivedpointertest(KlassDerived* kd) {
  183. if (kd)
  184. kd->append(" derivedpointertest");
  185. return kd;
  186. }
  187. KlassDerived derivedvaluetest(KlassDerived kd) {
  188. kd.append(" derivedvaluetest");
  189. return kd;
  190. }
  191. KlassDerived& derivedreftest(KlassDerived& kd) {
  192. kd.append(" derivedreftest");
  193. return kd;
  194. }
  195. SwigBoost::intrusive_ptr<KlassDerived> derivedsmartptrtest(SwigBoost::intrusive_ptr<KlassDerived> kd) {
  196. if (kd)
  197. kd->append(" derivedsmartptrtest");
  198. return kd;
  199. }
  200. SwigBoost::intrusive_ptr<KlassDerived>* derivedsmartptrpointertest(SwigBoost::intrusive_ptr<KlassDerived>* kd) {
  201. if (kd && *kd)
  202. (*kd)->append(" derivedsmartptrpointertest");
  203. return kd;
  204. }
  205. SwigBoost::intrusive_ptr<KlassDerived>* derivedsmartptrreftest(SwigBoost::intrusive_ptr<KlassDerived>* kd) {
  206. if (kd && *kd)
  207. (*kd)->append(" derivedsmartptrreftest");
  208. return kd;
  209. }
  210. SwigBoost::intrusive_ptr<KlassDerived>*& derivedsmartptrpointerreftest(SwigBoost::intrusive_ptr<KlassDerived>*& kd) {
  211. if (kd && *kd)
  212. (*kd)->append(" derivedsmartptrpointerreftest");
  213. return kd;
  214. }
  215. SwigBoost::intrusive_ptr<Klass> factorycreate() {
  216. return SwigBoost::intrusive_ptr<Klass>(new Klass("factorycreate"));
  217. }
  218. // smart pointer
  219. SwigBoost::intrusive_ptr<Klass> smartpointertest(SwigBoost::intrusive_ptr<Klass> k) {
  220. if (k)
  221. k->append(" smartpointertest");
  222. return SwigBoost::intrusive_ptr<Klass>(k);
  223. }
  224. SwigBoost::intrusive_ptr<Klass>* smartpointerpointertest(SwigBoost::intrusive_ptr<Klass>* k) {
  225. if (k && *k)
  226. (*k)->append(" smartpointerpointertest");
  227. return k;
  228. }
  229. SwigBoost::intrusive_ptr<Klass>& smartpointerreftest(SwigBoost::intrusive_ptr<Klass>& k) {
  230. if (k)
  231. k->append(" smartpointerreftest");
  232. return k;
  233. }
  234. SwigBoost::intrusive_ptr<Klass>*& smartpointerpointerreftest(SwigBoost::intrusive_ptr<Klass>*& k) {
  235. if (k && *k)
  236. (*k)->append(" smartpointerpointerreftest");
  237. return k;
  238. }
  239. // const
  240. SwigBoost::intrusive_ptr<const Klass> constsmartpointertest(SwigBoost::intrusive_ptr<const Klass> k) {
  241. return SwigBoost::intrusive_ptr<const Klass>(k);
  242. }
  243. SwigBoost::intrusive_ptr<const Klass>* constsmartpointerpointertest(SwigBoost::intrusive_ptr<const Klass>* k) {
  244. return k;
  245. }
  246. SwigBoost::intrusive_ptr<const Klass>& constsmartpointerreftest(SwigBoost::intrusive_ptr<const Klass>& k) {
  247. return k;
  248. }
  249. // plain pointer
  250. Klass valuetest(Klass k) {
  251. k.append(" valuetest");
  252. return k;
  253. }
  254. Klass *pointertest(Klass *k) {
  255. if (k)
  256. k->append(" pointertest");
  257. return k;
  258. }
  259. Klass& reftest(Klass& k) {
  260. k.append(" reftest");
  261. return k;
  262. }
  263. Klass *const& pointerreftest(Klass *const& k) {
  264. k->append(" pointerreftest");
  265. return k;
  266. }
  267. // null
  268. std::string nullsmartpointerpointertest(SwigBoost::intrusive_ptr<Klass>* k) {
  269. if (k && *k)
  270. return "not null";
  271. else if (!k)
  272. return "null smartpointer pointer";
  273. else if (!*k)
  274. return "null pointer";
  275. else
  276. return "also not null";
  277. }
  278. // $owner
  279. Klass *pointerownertest() {
  280. return new Klass("pointerownertest");
  281. }
  282. SwigBoost::intrusive_ptr<Klass>* smartpointerpointerownertest() {
  283. return new SwigBoost::intrusive_ptr<Klass>(new Klass("smartpointerpointerownertest"));
  284. }
  285. const SwigBoost::intrusive_ptr<Klass>& ref_1() {
  286. static SwigBoost::intrusive_ptr<Klass> sptr;
  287. return sptr;
  288. }
  289. // overloading tests
  290. std::string overload_rawbyval(int i) { return "int"; }
  291. std::string overload_rawbyval(Klass k) { return "rawbyval"; }
  292. std::string overload_rawbyref(int i) { return "int"; }
  293. std::string overload_rawbyref(Klass &k) { return "rawbyref"; }
  294. std::string overload_rawbyptr(int i) { return "int"; }
  295. std::string overload_rawbyptr(Klass *k) { return "rawbyptr"; }
  296. std::string overload_rawbyptrref(int i) { return "int"; }
  297. std::string overload_rawbyptrref(Klass *const&k) { return "rawbyptrref"; }
  298. std::string overload_smartbyval(int i) { return "int"; }
  299. std::string overload_smartbyval(SwigBoost::intrusive_ptr<Klass> k) { return "smartbyval"; }
  300. std::string overload_smartbyref(int i) { return "int"; }
  301. std::string overload_smartbyref(SwigBoost::intrusive_ptr<Klass> &k) { return "smartbyref"; }
  302. std::string overload_smartbyptr(int i) { return "int"; }
  303. std::string overload_smartbyptr(SwigBoost::intrusive_ptr<Klass> *k) { return "smartbyptr"; }
  304. std::string overload_smartbyptrref(int i) { return "int"; }
  305. std::string overload_smartbyptrref(SwigBoost::intrusive_ptr<Klass> *&k) { return "smartbyptrref"; }
  306. } // namespace Space
  307. %}
  308. %{
  309. boost::detail::atomic_count Space::Klass::total_count(0);
  310. boost::detail::atomic_count Space::KlassWithoutRefCount::total_count(0);
  311. boost::detail::atomic_count Space::IgnoredRefCountingBase::total_count(0);
  312. boost::detail::atomic_count Space::KlassDerived::total_count(0);
  313. boost::detail::atomic_count Space::KlassDerivedDerived::total_count(0);
  314. %}
  315. // Member variables
  316. %inline %{
  317. struct MemberVariables {
  318. MemberVariables() : SmartMemberPointer(new SwigBoost::intrusive_ptr<Space::Klass>()), SmartMemberReference(*(new SwigBoost::intrusive_ptr<Space::Klass>())), MemberPointer(0), MemberReference(MemberValue) {}
  319. virtual ~MemberVariables() {
  320. delete SmartMemberPointer;
  321. delete &SmartMemberReference;
  322. }
  323. SwigBoost::intrusive_ptr<Space::Klass> SmartMemberValue;
  324. SwigBoost::intrusive_ptr<Space::Klass> * SmartMemberPointer;
  325. SwigBoost::intrusive_ptr<Space::Klass> & SmartMemberReference;
  326. Space::Klass MemberValue;
  327. Space::Klass * MemberPointer;
  328. Space::Klass & MemberReference;
  329. };
  330. // Global variables
  331. SwigBoost::intrusive_ptr<Space::Klass> GlobalSmartValue;
  332. Space::Klass GlobalValue;
  333. Space::Klass * GlobalPointer = 0;
  334. Space::Klass & GlobalReference = GlobalValue;
  335. %}
  336. #if defined(INTRUSIVE_PTR_WRAPPERS_IMPLEMENTED)
  337. // Note: %template after the intrusive_ptr typemaps
  338. %intrusive_ptr(Base<int, double>)
  339. %intrusive_ptr(Pair<int, double>)
  340. #endif
  341. // Templates
  342. %inline %{
  343. template <class T1, class T2> struct Base {
  344. Space::Klass klassBase;
  345. T1 baseVal1;
  346. T2 baseVal2;
  347. Base(T1 t1, T2 t2) : baseVal1(t1*2), baseVal2(t2*2) {}
  348. virtual std::string getValue() const { return "Base<>"; };
  349. mutable int count;
  350. void addref(void) const { count++; }
  351. void release(void) const { if (--count == 0) delete this; }
  352. int use_count(void) const { return count; }
  353. };
  354. %}
  355. %template(BaseIntDouble) Base<int, double>;
  356. %inline %{
  357. template <class T1, class T2> struct Pair : Base<T1, T2> {
  358. Space::Klass klassPair;
  359. T1 val1;
  360. T2 val2;
  361. Pair(T1 t1, T2 t2) : Base<T1, T2>(t1, t2), val1(t1), val2(t2) {}
  362. virtual std::string getValue() const { return "Pair<>"; };
  363. };
  364. Pair<int, double> pair_id2(Pair<int, double> p) { return p; }
  365. SwigBoost::intrusive_ptr< Pair<int, double> > pair_id1(SwigBoost::intrusive_ptr< Pair<int, double> > p) { return p; }
  366. template<typename T> void intrusive_ptr_add_ref(const T* r) { r->addref(); }
  367. template<typename T> void intrusive_ptr_release(const T* r) { r->release(); }
  368. long use_count(const SwigBoost::shared_ptr<Space::Klass>& sptr) {
  369. return sptr.use_count();
  370. }
  371. long use_count(const SwigBoost::shared_ptr<Space::KlassDerived>& sptr) {
  372. return sptr.use_count();
  373. }
  374. long use_count(const SwigBoost::shared_ptr<Space::KlassDerivedDerived>& sptr) {
  375. return sptr.use_count();
  376. }
  377. %}
  378. %template(PairIntDouble) Pair<int, double>;
  379. // For counting the instances of intrusive_ptr (all of which are created on the heap)
  380. // intrusive_ptr_wrapper_count() gives overall count
  381. %inline %{
  382. namespace SwigBoost {
  383. const int NOT_COUNTING = -123456;
  384. int intrusive_ptr_wrapper_count() {
  385. #ifdef INTRUSIVE_PTR_WRAPPER
  386. return SwigBoost::IntrusivePtrWrapper::getTotalCount();
  387. #else
  388. return NOT_COUNTING;
  389. #endif
  390. }
  391. #ifdef INTRUSIVE_PTR_WRAPPER
  392. template<> std::string show_message(boost::intrusive_ptr<Space::Klass >*t) {
  393. if (!t)
  394. return "null intrusive_ptr!!!";
  395. if (*t)
  396. return "Klass: " + (*t)->getValue();
  397. else
  398. return "Klass: NULL";
  399. }
  400. template<> std::string show_message(boost::intrusive_ptr<const Space::Klass >*t) {
  401. if (!t)
  402. return "null intrusive_ptr!!!";
  403. if (*t)
  404. return "Klass: " + (*t)->getValue();
  405. else
  406. return "Klass: NULL";
  407. }
  408. template<> std::string show_message(boost::intrusive_ptr<Space::KlassDerived >*t) {
  409. if (!t)
  410. return "null intrusive_ptr!!!";
  411. if (*t)
  412. return "KlassDerived: " + (*t)->getValue();
  413. else
  414. return "KlassDerived: NULL";
  415. }
  416. template<> std::string show_message(boost::intrusive_ptr<const Space::KlassDerived >*t) {
  417. if (!t)
  418. return "null intrusive_ptr!!!";
  419. if (*t)
  420. return "KlassDerived: " + (*t)->getValue();
  421. else
  422. return "KlassDerived: NULL";
  423. }
  424. #endif
  425. }
  426. %}