PageRenderTime 35ms CodeModel.GetById 12ms app.highlight 10ms RepoModel.GetById 1ms app.codeStats 1ms

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

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