diff options
author | Chad Austin <caustin@gmail.com> | 2014-03-22 21:10:46 -0700 |
---|---|---|
committer | Chad Austin <chad@chadaustin.me> | 2014-03-28 23:56:40 -0700 |
commit | 464f4a3cace3eba27c145d347d031930b9630a51 (patch) | |
tree | e4ebd41b75ee637d5a774e62e78830dd71d6d212 /system/include | |
parent | 555cb8207b9b06f86284a88d97a74c43e20469fb (diff) |
make val::as<> compatible with asm.js
Diffstat (limited to 'system/include')
-rw-r--r-- | system/include/emscripten/bind.h | 13 | ||||
-rw-r--r-- | system/include/emscripten/val.h | 18 |
2 files changed, 14 insertions, 17 deletions
diff --git a/system/include/emscripten/bind.h b/system/include/emscripten/bind.h index 390533f3..5ed05994 100644 --- a/system/include/emscripten/bind.h +++ b/system/include/emscripten/bind.h @@ -35,18 +35,21 @@ namespace emscripten { void _embind_register_bool( TYPEID boolType, const char* name, + size_t size, bool trueValue, bool falseValue); void _embind_register_integer( TYPEID integerType, const char* name, + size_t size, long minRange, unsigned long maxRange); void _embind_register_float( TYPEID floatType, - const char* name); + const char* name, + size_t size); void _embind_register_std_string( TYPEID stringType, @@ -163,7 +166,9 @@ namespace emscripten { void _embind_register_enum( TYPEID enumType, - const char* name); + const char* name, + size_t size, + bool isSigned); void _embind_register_enum_value( TYPEID enumType, @@ -1182,7 +1187,9 @@ namespace emscripten { enum_(const char* name) { _embind_register_enum( internal::TypeID<EnumType>::get(), - name); + name, + sizeof(EnumType), + std::is_signed<typename std::underlying_type<EnumType>::type>::value); } enum_& value(const char* name, EnumType value) { diff --git a/system/include/emscripten/val.h b/system/include/emscripten/val.h index 19b1beb1..49b143c1 100644 --- a/system/include/emscripten/val.h +++ b/system/include/emscripten/val.h @@ -13,11 +13,6 @@ namespace emscripten { typedef struct _EM_VAL* EM_VAL; typedef struct _EM_DESTRUCTORS* EM_DESTRUCTORS; - // TODO: functions returning this are reinterpret_cast - // into the correct return type. this needs some thought - // for asm.js. - typedef void _POLYMORPHIC_RESULT; - void _emval_incref(EM_VAL value); void _emval_decref(EM_VAL value); @@ -40,7 +35,7 @@ namespace emscripten { EM_VAL _emval_get_module_property(const char* name); EM_VAL _emval_get_property(EM_VAL object, EM_VAL key); void _emval_set_property(EM_VAL object, EM_VAL key, EM_VAL value); - _POLYMORPHIC_RESULT _emval_as(EM_VAL value, TYPEID returnType, EM_DESTRUCTORS* runDestructors); + void _emval_as(EM_VAL value, TYPEID returnType, void* result, EM_DESTRUCTORS* destructors); EM_VAL _emval_call( EM_VAL value, @@ -297,16 +292,11 @@ namespace emscripten { typedef BindingType<T> BT; - typedef typename BT::WireType (*TypedAs)( - EM_VAL value, - TYPEID returnType, - EM_DESTRUCTORS* runDestructors); - TypedAs typedAs = reinterpret_cast<TypedAs>(&_emval_as); - + typename BT::WireType result; EM_DESTRUCTORS destructors; - typename BT::WireType wt = typedAs(handle, TypeID<T>::get(), &destructors); + _emval_as(handle, TypeID<T>::get(), &result, &destructors); DestructorsRunner dr(destructors); - return BT::fromWireType(wt); + return BT::fromWireType(result); } private: |