summaryrefslogtreecommitdiff
path: root/gruel/src/swig
diff options
context:
space:
mode:
authorTom Rondeau2011-03-26 18:06:56 -0400
committerTom Rondeau2011-03-26 18:06:56 -0400
commitdd97932abfd35e60e9374f202aa6c69afcfb35ca (patch)
treedca7a07ca99108bc6e35cd4bae54a28ddf371ca6 /gruel/src/swig
parente45e25d13c4f0ea8b84143c1a8e1d18dbcc427be (diff)
downloadgnuradio-dd97932abfd35e60e9374f202aa6c69afcfb35ca.tar.gz
gnuradio-dd97932abfd35e60e9374f202aa6c69afcfb35ca.tar.bz2
gnuradio-dd97932abfd35e60e9374f202aa6c69afcfb35ca.zip
gruel: using a copy of swig's intrusive_ptr.i to support the PMT wrapping.
Diffstat (limited to 'gruel/src/swig')
-rw-r--r--gruel/src/swig/Makefile.am7
-rw-r--r--gruel/src/swig/gr_intrusive_ptr.i102
-rw-r--r--gruel/src/swig/pmt_swig.i3
3 files changed, 106 insertions, 6 deletions
diff --git a/gruel/src/swig/Makefile.am b/gruel/src/swig/Makefile.am
index 294045567..3261e47c2 100644
--- a/gruel/src/swig/Makefile.am
+++ b/gruel/src/swig/Makefile.am
@@ -30,9 +30,6 @@ AM_CPPFLAGS = \
$(PYTHON_CPPFLAGS) \
$(WITH_INCLUDES)
-TOP_SWIG_IFILES = \
- pmt_swig.i
-
##############################
# SWIG interface and library
TOP_SWIG_IFILES = \
@@ -50,6 +47,6 @@ pmt_swig_la_swig_libadd = \
$(abs_top_builddir)/gruel/src/lib/pmt/libpmt.la
# additional SWIG files to be installed
-pmt_swig_swiginclude_headers =
-
+pmt_swig_swiginclude_headers = \
+ gr_intrusive_ptr.i
diff --git a/gruel/src/swig/gr_intrusive_ptr.i b/gruel/src/swig/gr_intrusive_ptr.i
new file mode 100644
index 000000000..eef5bc84d
--- /dev/null
+++ b/gruel/src/swig/gr_intrusive_ptr.i
@@ -0,0 +1,102 @@
+// This file was borrowed from the SWIG project to allow use to
+// wrap PMTs that use intrusive pointers. This is only necessary
+// to support backwards compatability with older distributions of
+// Linux that do not natively support a new enough version of SWIG.
+// We do this to prevent having to update our dependency on a new
+// SWIG. Eventually, the need for this should go away.
+
+// Allow for different namespaces for shared_ptr / intrusive_ptr - they could be boost or std or std::tr1
+// For example for std::tr1, use:
+// #define SWIG_SHARED_PTR_NAMESPACE std
+// #define SWIG_SHARED_PTR_SUBNAMESPACE tr1
+// #define SWIG_INTRUSIVE_PTR_NAMESPACE boost
+// #define SWIG_INTRUSIVE_PTR_SUBNAMESPACE
+
+#if !defined(SWIG_INTRUSIVE_PTR_NAMESPACE)
+# define SWIG_INTRUSIVE_PTR_NAMESPACE boost
+#endif
+
+#if defined(SWIG_INTRUSIVE_PTR_SUBNAMESPACE)
+# define SWIG_INTRUSIVE_PTR_QNAMESPACE SWIG_INTRUSIVE_PTR_NAMESPACE::SWIG_INTRUSIVE_PTR_SUBNAMESPACE
+#else
+# define SWIG_INTRUSIVE_PTR_QNAMESPACE SWIG_INTRUSIVE_PTR_NAMESPACE
+#endif
+
+namespace SWIG_INTRUSIVE_PTR_NAMESPACE {
+#if defined(SWIG_INTRUSIVE_PTR_SUBNAMESPACE)
+ namespace SWIG_INTRUSIVE_PTR_SUBNAMESPACE {
+#endif
+ template <class T> class intrusive_ptr {
+ };
+#if defined(SWIG_INTRUSIVE_PTR_SUBNAMESPACE)
+ }
+#endif
+}
+
+%fragment("SWIG_intrusive_deleter", "header") {
+template<class T> struct SWIG_intrusive_deleter {
+ void operator()(T *p) {
+ if (p)
+ intrusive_ptr_release(p);
+ }
+};
+}
+
+%fragment("SWIG_null_deleter", "header") {
+struct SWIG_null_deleter {
+ void operator() (void const *) const {
+ }
+};
+%#define SWIG_NO_NULL_DELETER_0 , SWIG_null_deleter()
+%#define SWIG_NO_NULL_DELETER_1
+}
+
+// Main user macro for defining intrusive_ptr typemaps for both const and non-const pointer types
+// For plain classes, do not use for derived classes
+%define SWIG_INTRUSIVE_PTR(PROXYCLASS, TYPE...)
+SWIG_INTRUSIVE_PTR_TYPEMAPS(PROXYCLASS, , TYPE)
+SWIG_INTRUSIVE_PTR_TYPEMAPS(PROXYCLASS, const, TYPE)
+%enddef
+
+// Main user macro for defining intrusive_ptr typemaps for both const and non-const pointer types
+// For derived classes
+%define SWIG_INTRUSIVE_PTR_DERIVED(PROXYCLASS, BASECLASSTYPE, TYPE...)
+SWIG_INTRUSIVE_PTR_TYPEMAPS(PROXYCLASS, , TYPE)
+SWIG_INTRUSIVE_PTR_TYPEMAPS(PROXYCLASS, const, TYPE)
+%types(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > = SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< BASECLASSTYPE >) %{
+ *newmemory = SWIG_CAST_NEW_MEMORY;
+ return (void *) new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< BASECLASSTYPE >(*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *)$from);
+ %}
+%extend TYPE {
+ static SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< BASECLASSTYPE > SWIGSharedPtrUpcast(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > swigSharedPtrUpcast) {
+ return swigSharedPtrUpcast;
+ }
+}
+%enddef
+
+// Extra user macro for including classes in intrusive_ptr typemaps for both const and non-const pointer types
+// This caters for classes which cannot be wrapped by intrusive_ptrs but are still part of the class hierarchy
+// For plain classes, do not use for derived classes
+%define SWIG_INTRUSIVE_PTR_NO_WRAP(PROXYCLASS, TYPE...)
+SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP(PROXYCLASS, , TYPE)
+SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP(PROXYCLASS, const, TYPE)
+%enddef
+
+// Extra user macro for including classes in intrusive_ptr typemaps for both const and non-const pointer types
+// This caters for classes which cannot be wrapped by intrusive_ptrs but are still part of the class hierarchy
+// For derived classes
+%define SWIG_INTRUSIVE_PTR_DERIVED_NO_WRAP(PROXYCLASS, BASECLASSTYPE, TYPE...)
+SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP(PROXYCLASS, , TYPE)
+SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP(PROXYCLASS, const, TYPE)
+%types(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > = SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< BASECLASSTYPE >) %{
+ *newmemory = SWIG_CAST_NEW_MEMORY;
+ return (void *) new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< BASECLASSTYPE >(*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *)$from);
+%}
+%extend TYPE {
+ static SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< BASECLASSTYPE > SWIGSharedPtrUpcast(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > swigSharedPtrUpcast) {
+ return swigSharedPtrUpcast;
+ }
+}
+%enddef
+
+
diff --git a/gruel/src/swig/pmt_swig.i b/gruel/src/swig/pmt_swig.i
index 6435e03cc..3b0eb45c8 100644
--- a/gruel/src/swig/pmt_swig.i
+++ b/gruel/src/swig/pmt_swig.i
@@ -38,7 +38,8 @@ using namespace pmt;
// Template intrusive_ptr for Swig to avoid dereferencing issues
class pmt_base;
-%import <intrusive_ptr.i>
+//%import <intrusive_ptr.i>
+%import <gr_intrusive_ptr.i>
%template(swig_int_ptr) boost::intrusive_ptr<pmt_base>;
typedef boost::intrusive_ptr<pmt_base> pmt_t;