diff options
author | Chad Austin <chad@imvu.com> | 2014-03-31 23:42:50 -0700 |
---|---|---|
committer | Chad Austin <chad@chadaustin.me> | 2014-04-13 09:08:34 -0700 |
commit | e4cfbda44856c3b7bc4081d3828423971cbedf1d (patch) | |
tree | 6ea380591356a0e97a992766b4fb6c7e0c02dc5e /system | |
parent | 2bbdb0cd396d785a9587bc776d699283c1902ff7 (diff) |
Add a way to opt out of compiler-generated type names for smart pointers and wrapper types.
Diffstat (limited to 'system')
-rw-r--r-- | system/include/emscripten/bind.h | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/system/include/emscripten/bind.h b/system/include/emscripten/bind.h index b4c5004e..1c7daeba 100644 --- a/system/include/emscripten/bind.h +++ b/system/include/emscripten/bind.h @@ -890,7 +890,7 @@ namespace emscripten { } template<typename PointerType> - const class_& smart_ptr() const { + const class_& smart_ptr(const char* name = typeid(PointerType).name()) const { using namespace internal; typedef smart_ptr_trait<PointerType> PointerTrait; @@ -901,7 +901,7 @@ namespace emscripten { _embind_register_smart_ptr( TypeID<PointerType>::get(), TypeID<PointeeType>::get(), - typeid(PointerType).name(), + name, PointerTrait::get_sharing_policy(), reinterpret_cast<GenericFunction>(&PointerTrait::get), reinterpret_cast<GenericFunction>(&PointerTrait::construct_null), @@ -933,10 +933,16 @@ namespace emscripten { } template<typename SmartPtr, typename... Args, typename... Policies> - const class_& smart_ptr_constructor(SmartPtr (*factory)(Args...), Policies...) const { + const class_& smart_ptr_constructor(SmartPtr (*factory)(Args...), Policies&&... policies) const { + // TODO: once everyone has manually specified a name, remove this + return smart_ptr_constructor(typeid(SmartPtr).name(), factory, std::forward<Policies>(policies)...); + } + + template<typename SmartPtr, typename... Args, typename... Policies> + const class_& smart_ptr_constructor(const char* smartPtrName, SmartPtr (*factory)(Args...), Policies...) const { using namespace internal; - smart_ptr<SmartPtr>(); + smart_ptr<SmartPtr>(smartPtrName); typename WithPolicies<Policies...>::template ArgTypeList<SmartPtr, Args...> args; _embind_register_class_constructor( @@ -949,10 +955,10 @@ namespace emscripten { } template<typename WrapperType, typename PointerType = WrapperType*> - const class_& allow_subclass() const { + const class_& allow_subclass(const char* wrapperClassName = typeid(WrapperType).name()) const { using namespace internal; - auto cls = class_<WrapperType, base<ClassType>>(typeid(WrapperType).name()) + auto cls = class_<WrapperType, base<ClassType>>(wrapperClassName) ; SmartPtrIfNeeded<PointerType> _(cls); |