diff options
author | Chad Austin <chad@imvu.com> | 2013-01-22 18:02:56 -0800 |
---|---|---|
committer | Jukka Jylänki <jujjyl@gmail.com> | 2013-04-12 14:23:30 +0300 |
commit | 50e05c30bfcdf3b1c8aea0be0b631233e24f694c (patch) | |
tree | c8e58b07f47875a12a45c8b690dbb6d04cee8394 | |
parent | bacb23ed1a80740b34e3a265a29be1d86dd72ff0 (diff) |
Introduce val::new_ for constructor invocation
-rwxr-xr-x | src/embind/emval.js | 4 | ||||
-rw-r--r-- | system/include/emscripten/val.h | 6 |
2 files changed, 10 insertions, 0 deletions
diff --git a/src/embind/emval.js b/src/embind/emval.js index 56c307bf..39f23a61 100755 --- a/src/embind/emval.js +++ b/src/embind/emval.js @@ -67,6 +67,10 @@ function __emval_take_value(type, v) { return __emval_register(v); } +function __emval_new(handle) { + return __emval_register(new (_emval_handle_array[handle].value)) +} + var global = (function(){return Function;})()('return this')(); function __emval_get_global(name) { diff --git a/system/include/emscripten/val.h b/system/include/emscripten/val.h index 3d0a3e60..22a7776a 100644 --- a/system/include/emscripten/val.h +++ b/system/include/emscripten/val.h @@ -19,6 +19,8 @@ namespace emscripten { EM_VAL _emval_new_cstring(const char*); void _emval_take_value(TYPEID type/*, ...*/); + EM_VAL _emval_new(EM_VAL value); + EM_VAL _emval_get_global(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); @@ -102,6 +104,10 @@ namespace emscripten { bool hasOwnProperty(const char* key) const { return val::global("Object")["prototype"]["hasOwnProperty"].call("call", *this, val(key)).as<bool>(); } + + val new_() const { + return val(internal::_emval_new(handle)); + } template<typename T> val operator[](const T& key) const { |