shared_ptr.i 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. // This is a helper file for shared_ptr and should not be included directly.
  2. // The main implementation detail in using this smart pointer of a type is to customise the code generated
  3. // to use a pointer to the smart pointer of the type, rather than the usual pointer to the underlying type.
  4. // So for some type T, shared_ptr<T> * is used rather than T *.
  5. // shared_ptr namespaces could be boost or std or std::tr1
  6. // For example for std::tr1, use:
  7. // #define SWIG_SHARED_PTR_NAMESPACE std
  8. // #define SWIG_SHARED_PTR_SUBNAMESPACE tr1
  9. #if !defined(SWIG_SHARED_PTR_NAMESPACE)
  10. # define SWIG_SHARED_PTR_NAMESPACE boost
  11. #endif
  12. #if defined(SWIG_SHARED_PTR_SUBNAMESPACE)
  13. # define SWIG_SHARED_PTR_QNAMESPACE SWIG_SHARED_PTR_NAMESPACE::SWIG_SHARED_PTR_SUBNAMESPACE
  14. #else
  15. # define SWIG_SHARED_PTR_QNAMESPACE SWIG_SHARED_PTR_NAMESPACE
  16. #endif
  17. namespace SWIG_SHARED_PTR_NAMESPACE {
  18. #if defined(SWIG_SHARED_PTR_SUBNAMESPACE)
  19. namespace SWIG_SHARED_PTR_SUBNAMESPACE {
  20. #endif
  21. template <class T> class shared_ptr {
  22. };
  23. #if defined(SWIG_SHARED_PTR_SUBNAMESPACE)
  24. }
  25. #endif
  26. }
  27. %fragment("SWIG_null_deleter", "header") {
  28. struct SWIG_null_deleter {
  29. void operator() (void const *) const {
  30. }
  31. };
  32. %#define SWIG_NO_NULL_DELETER_0 , SWIG_null_deleter()
  33. %#define SWIG_NO_NULL_DELETER_1
  34. %#define SWIG_NO_NULL_DELETER_SWIG_POINTER_NEW
  35. %#define SWIG_NO_NULL_DELETER_SWIG_POINTER_OWN
  36. }
  37. // Workaround empty first macro argument bug
  38. #define SWIGEMPTYHACK
  39. // Main user macro for defining shared_ptr typemaps for both const and non-const pointer types
  40. %define %shared_ptr(TYPE...)
  41. %feature("smartptr", noblock=1) TYPE { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > }
  42. SWIG_SHARED_PTR_TYPEMAPS(SWIGEMPTYHACK, TYPE)
  43. SWIG_SHARED_PTR_TYPEMAPS(const, TYPE)
  44. %enddef
  45. // Legacy macros
  46. %define SWIG_SHARED_PTR(PROXYCLASS, TYPE...)
  47. #warning "SWIG_SHARED_PTR(PROXYCLASS, TYPE) is deprecated. Please use %shared_ptr(TYPE) instead."
  48. %shared_ptr(TYPE)
  49. %enddef
  50. %define SWIG_SHARED_PTR_DERIVED(PROXYCLASS, BASECLASSTYPE, TYPE...)
  51. #warning "SWIG_SHARED_PTR_DERIVED(PROXYCLASS, BASECLASSTYPE, TYPE) is deprecated. Please use %shared_ptr(TYPE) instead."
  52. %shared_ptr(TYPE)
  53. %enddef