diff options
author | Bill Welden <bwelden@imvu.com> | 2013-04-09 12:49:32 -0700 |
---|---|---|
committer | Jukka Jylänki <jujjyl@gmail.com> | 2013-04-18 20:08:07 +0300 |
commit | de80f9c04100e57f74f62352981548cd3e322579 (patch) | |
tree | 053f2ba0088ab44c4d90602acdb72010605a9885 | |
parent | bdeab9a67107aaacc97bc043b8a753e0c58d7e7d (diff) |
Support for intrusive pointers. This dependency on Northstar must be removed before pusing embind to GitHub.
-rwxr-xr-x | src/embind/embind.js | 2 | ||||
-rwxr-xr-x | system/include/emscripten/bind.h | 19 |
2 files changed, 20 insertions, 1 deletions
diff --git a/src/embind/embind.js b/src/embind/embind.js index b8bd5fcf..42250601 100755 --- a/src/embind/embind.js +++ b/src/embind/embind.js @@ -672,7 +672,7 @@ RegisteredPointer.prototype.toWireType = function(destructors, handle) { break; case 1: // INTRUSIVE - throwBindingError('INTRUSIVE sharing policy not yet supported'); + ptr = handle.$$.smartPtr; break; case 2: // BY_EMVAL diff --git a/system/include/emscripten/bind.h b/system/include/emscripten/bind.h index 73a8d4da..3901ce50 100755 --- a/system/include/emscripten/bind.h +++ b/system/include/emscripten/bind.h @@ -9,6 +9,7 @@ #include <type_traits> #include <emscripten/val.h> #include <emscripten/wire.h> +#include "northstar/Pointer.h" namespace emscripten { enum class sharing_policy { @@ -705,6 +706,24 @@ namespace emscripten { }; }; + template<typename PointeeType> + struct smart_ptr_trait<northstar::IntrusivePointer<PointeeType>> { + typedef northstar::IntrusivePointer<PointeeType> PointerType; + typedef typename PointerType::element_type element_type; + + static element_type* get(const PointerType& ptr) { + return ptr.get(); + } + + static northstar::IntrusivePointer<PointeeType>* share(PointeeType* p, internal::EM_VAL v) { + return new northstar::IntrusivePointer<PointeeType>(p); + } + + static sharing_policy get_sharing_policy() { + return sharing_policy::INTRUSIVE; + } + }; + //////////////////////////////////////////////////////////////////////////////// // CLASSES //////////////////////////////////////////////////////////////////////////////// |