aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChad Austin <chad@imvu.com>2013-03-11 18:42:13 -0700
committerJukka Jylänki <jujjyl@gmail.com>2013-04-12 14:25:46 +0300
commitde9a8d6fecd4f699b2f80d908c8c597dcc8f04bc (patch)
tree7b3727032d9ebd8576cd1e79bfea13ab6e9d9ade
parent495c40ce186d5b852f3bc3430058a24a94c72dba (diff)
make smart_ptr a method of class_ instead of a global
-rwxr-xr-xsystem/include/emscripten/bind.h34
1 files changed, 18 insertions, 16 deletions
diff --git a/system/include/emscripten/bind.h b/system/include/emscripten/bind.h
index 4b9968dc..e3593196 100755
--- a/system/include/emscripten/bind.h
+++ b/system/include/emscripten/bind.h
@@ -557,20 +557,6 @@ namespace emscripten {
}
}
- template<typename PointerType>
- void smart_ptr(const char* name) {
- using namespace internal;
- typedef typename smart_ptr_trait<PointerType>::element_type PointeeType;
-
- _embind_register_smart_ptr(
- TypeID<PointerType>::get(),
- TypeID<PointeeType>::get(),
- name,
- reinterpret_cast<GenericFunction>(&raw_smart_pointer_constructor<PointerType>),
- reinterpret_cast<GenericFunction>(&raw_destructor<PointerType>),
- reinterpret_cast<GenericFunction>(&get_pointee<PointerType>));
- };
-
////////////////////////////////////////////////////////////////////////////////
// CLASSES
////////////////////////////////////////////////////////////////////////////////
@@ -700,6 +686,23 @@ namespace emscripten {
reinterpret_cast<GenericFunction>(&raw_destructor<ClassType>));
}
+ template<typename PointerType>
+ class_& smart_ptr() {
+ using namespace internal;
+ typedef typename smart_ptr_trait<PointerType>::element_type PointeeType;
+
+ // TODO: assert that PointeeType is identical to ClassType
+
+ _embind_register_smart_ptr(
+ TypeID<PointerType>::get(),
+ TypeID<PointeeType>::get(),
+ "SmartPtr", // TODO: generate unique name
+ reinterpret_cast<GenericFunction>(&raw_smart_pointer_constructor<PointerType>),
+ reinterpret_cast<GenericFunction>(&raw_destructor<PointerType>),
+ reinterpret_cast<GenericFunction>(&get_pointee<PointerType>));
+ return *this;
+ };
+
template<typename... ConstructorArgs, typename... Policies>
class_& constructor(Policies... policies) {
return constructor(
@@ -725,8 +728,7 @@ namespace emscripten {
class_& smart_ptr_constructor(SmartPtr (*factory)(Args...), Policies...) {
using namespace internal;
- // TODO: generate unique name
- smart_ptr<SmartPtr>("SmartPtr");
+ smart_ptr<SmartPtr>();
typename WithPolicies<Policies...>::template ArgTypeList<SmartPtr, Args...> args;
_embind_register_class_constructor(