diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-05-03 13:40:01 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-05-03 13:40:01 -0700 |
commit | 1e3e0e5cf1ab9866faadbce1b1861d9fd79a80fb (patch) | |
tree | 7219f013034ead2e3926bc83e75ab3191d80db5e /system | |
parent | 6c531cbf21e4b332f963b977434dc897e914ca7b (diff) | |
parent | 8237fb35bcfb721eefb9c1608856b36a6adb852e (diff) |
Merge pull request #1126 from imvu/more_embind_updates
More embind updates
Diffstat (limited to 'system')
-rwxr-xr-x | system/include/emscripten/bind.h | 101 | ||||
-rw-r--r-- | system/include/emscripten/val.h | 1 |
2 files changed, 18 insertions, 84 deletions
diff --git a/system/include/emscripten/bind.h b/system/include/emscripten/bind.h index 4d2f4ac8..7aa2a55e 100755 --- a/system/include/emscripten/bind.h +++ b/system/include/emscripten/bind.h @@ -224,6 +224,10 @@ namespace emscripten { struct allow_raw_pointer : public allow_raw_pointers { }; + //////////////////////////////////////////////////////////////////////////////// + // select_overload and select_const + //////////////////////////////////////////////////////////////////////////////// + template<typename Signature> typename std::add_pointer<Signature>::type select_overload(typename std::add_pointer<Signature>::type fn) { return fn; @@ -241,6 +245,15 @@ namespace emscripten { return fn; } + template<typename ClassType, typename ReturnType, typename... Args> + auto select_const(ReturnType (ClassType::*method)(Args...) const) -> decltype(method) { + return method; + } + + //////////////////////////////////////////////////////////////////////////////// + // Invoker + //////////////////////////////////////////////////////////////////////////////// + namespace internal { template<typename ReturnType, typename... Args> struct Invoker { @@ -1220,90 +1233,10 @@ namespace emscripten { TypeID<const ConstantType&>::get(), asGenericValue(BindingType<const ConstantType&>::toWireType(v))); } - - namespace internal { - template<typename T> - class optional { - public: - optional() - : initialized(false) - {} - - ~optional() { - if (initialized) { - get()->~T(); - } - } - - optional(const optional& rhs) - : initialized(false) - { - *this = rhs; - } - - T& operator*() { - assert(initialized); - return *get(); - } - - const T& operator*() const { - assert(initialized); - return *get(); - } - - explicit operator bool() const { - return initialized; - } - - optional& operator=(const T& v) { - if (initialized) { - get()->~T(); - } - new(get()) T(v); - initialized = true; - return *this; - } - - optional& operator=(const optional& o) { - if (initialized) { - get()->~T(); - } - if (o.initialized) { - new(get()) T(*o); - } - initialized = o.initialized; - return *this; - } - - private: - T* get() { - return reinterpret_cast<T*>(&data); - } - - T const* get() const { - return reinterpret_cast<T const*>(&data); - } - - bool initialized; - typename std::aligned_storage<sizeof(T)>::type data; - }; - } -} - -namespace emscripten { - namespace internal { - class BindingsDefinition { - public: - template<typename Function> - BindingsDefinition(Function fn) { - fn(); - } - }; - } } #define EMSCRIPTEN_BINDINGS(name) \ - static struct BindingInitializer_##name { \ - BindingInitializer_##name(); \ - } BindingInitializer_##name##_instance; \ - BindingInitializer_##name::BindingInitializer_##name() + static struct EmscriptenBindingInitializer_##name { \ + EmscriptenBindingInitializer_##name(); \ + } EmscriptenBindingInitializer_##name##_instance; \ + EmscriptenBindingInitializer_##name::EmscriptenBindingInitializer_##name() diff --git a/system/include/emscripten/val.h b/system/include/emscripten/val.h index 09cad80e..edd070e3 100644 --- a/system/include/emscripten/val.h +++ b/system/include/emscripten/val.h @@ -10,6 +10,7 @@ namespace emscripten { extern "C" { void _emval_register_symbol(const char*); + typedef struct _EM_SIG* EM_SIG; typedef struct _EM_VAL* EM_VAL; void _emval_incref(EM_VAL value); |