diff options
-rw-r--r-- | system/include/emscripten/bind.h | 10 | ||||
-rw-r--r-- | tests/embind/embind_test.cpp | 5 |
2 files changed, 14 insertions, 1 deletions
diff --git a/system/include/emscripten/bind.h b/system/include/emscripten/bind.h index b9da5304..2562a301 100644 --- a/system/include/emscripten/bind.h +++ b/system/include/emscripten/bind.h @@ -689,6 +689,10 @@ namespace emscripten { static void* share(void* v) { return 0; // no sharing } + + static PointerType* operator_new() { + return new PointerType; + } }; // specialize if you have a different pointer type @@ -720,6 +724,10 @@ namespace emscripten { val_deleter(val::take_ownership(v))); } + static PointerType* operator_new() { + return new PointerType; + } + private: class val_deleter { public: @@ -880,7 +888,7 @@ namespace emscripten { typeid(PointerType).name(), PointerTrait::get_sharing_policy(), reinterpret_cast<GenericFunction>(&PointerTrait::get), - reinterpret_cast<GenericFunction>(&operator_new<PointerType>), + reinterpret_cast<GenericFunction>(&PointerTrait::operator_new), reinterpret_cast<GenericFunction>(&PointerTrait::share), reinterpret_cast<GenericFunction>(&raw_destructor<PointerType>)); return *this; diff --git a/tests/embind/embind_test.cpp b/tests/embind/embind_test.cpp index 1d871924..401b2734 100644 --- a/tests/embind/embind_test.cpp +++ b/tests/embind/embind_test.cpp @@ -1283,6 +1283,7 @@ std::shared_ptr<HeldBySmartPtr> takesHeldBySmartPtrSharedPtr(std::shared_ptr<Hel namespace emscripten { template<typename T> struct smart_ptr_trait<CustomSmartPtr<T>> { + typedef CustomSmartPtr<T> pointer_type; typedef T element_type; static sharing_policy get_sharing_policy() { @@ -1297,6 +1298,10 @@ namespace emscripten { ++ptr->refcount; // implement an adopt API? return CustomSmartPtr<T>(ptr); } + + static pointer_type* operator_new() { + return new pointer_type(); + } }; } |