diff options
author | Chad Austin <chad@imvu.com> | 2013-04-03 19:50:50 -0700 |
---|---|---|
committer | Jukka Jylänki <jujjyl@gmail.com> | 2013-04-12 14:27:19 +0300 |
commit | f508d6306ff0be4966d3f26b99a26c46f7c2c1ef (patch) | |
tree | 352dd1ce42319b225794db40ee510dc86743e36b /system | |
parent | d4bf6fbe297ea7e5720b49bfa6fc58b696540144 (diff) |
Allow value_tuple and value_struct to be registered as global constants. This involved reworking how value_struct and value_tuple are registered.
Diffstat (limited to 'system')
-rwxr-xr-x | system/include/emscripten/bind.h | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/system/include/emscripten/bind.h b/system/include/emscripten/bind.h index e767afaa..bd170dea 100755 --- a/system/include/emscripten/bind.h +++ b/system/include/emscripten/bind.h @@ -77,6 +77,8 @@ namespace emscripten { GenericFunction setter, void* setterContext); + void _embind_finalize_tuple(TYPEID tupleType); + void _embind_register_struct( TYPEID structType, const char* fieldName, @@ -93,6 +95,8 @@ namespace emscripten { GenericFunction setter, void* setterContext); + void _embind_finalize_struct(TYPEID structType); + void _embind_register_smart_ptr( TYPEID pointerType, TYPEID pointeeType, @@ -458,6 +462,15 @@ namespace emscripten { return internal::getContext(context); } }; + + class noncopyable { + protected: + noncopyable() {} + ~noncopyable() {} + private: + noncopyable(const noncopyable&) = delete; + const noncopyable& operator=(const noncopyable&) = delete; + }; } //////////////////////////////////////////////////////////////////////////////// @@ -465,7 +478,7 @@ namespace emscripten { //////////////////////////////////////////////////////////////////////////////// template<typename ClassType> - class value_tuple { + class value_tuple : public internal::noncopyable { public: value_tuple(const char* name) { using namespace internal; @@ -476,6 +489,11 @@ namespace emscripten { reinterpret_cast<GenericFunction>(&raw_destructor<ClassType>)); } + ~value_tuple() { + using namespace internal; + _embind_finalize_tuple(TypeID<ClassType>::get()); + } + template<typename InstanceType, typename ElementType> value_tuple& element(ElementType InstanceType::*field) { using namespace internal; @@ -516,7 +534,7 @@ namespace emscripten { //////////////////////////////////////////////////////////////////////////////// template<typename ClassType> - class value_struct { + class value_struct : public internal::noncopyable { public: value_struct(const char* name) { using namespace internal; @@ -527,6 +545,10 @@ namespace emscripten { reinterpret_cast<GenericFunction>(&raw_destructor<ClassType>)); } + ~value_struct() { + _embind_finalize_struct(internal::TypeID<ClassType>::get()); + } + template<typename InstanceType, typename FieldType> value_struct& field(const char* fieldName, FieldType InstanceType::*field) { using namespace internal; |