diff options
author | Chad Austin <chad@imvu.com> | 2013-03-26 12:39:57 -0700 |
---|---|---|
committer | Jukka Jylänki <jujjyl@gmail.com> | 2013-04-12 14:26:41 +0300 |
commit | dbd1a3bfe253ac1df0200427de10f60dc520cfb1 (patch) | |
tree | 56b1cbb492baaf9ce3843a31b67dd52b1e1b0fe8 /src | |
parent | 7973873abff495fab9f9193e057a6c6c52871d05 (diff) |
Allow multiple arguments to emscripten::val::new_()
Diffstat (limited to 'src')
-rwxr-xr-x | src/embind/emval.js | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/src/embind/emval.js b/src/embind/emval.js index c60c62e0..eb31777b 100755 --- a/src/embind/emval.js +++ b/src/embind/emval.js @@ -73,8 +73,22 @@ function __emval_take_value(type, v) { return __emval_register(v); } -function __emval_new(handle) { - return __emval_register(new (_emval_handle_array[handle].value)); +function __emval_new(handle, argCount, argTypes) { + var args = parseParameters( + argCount, + argTypes, + Array.prototype.slice.call(arguments, 3)); + + // implement what amounts to operator new + var constructor = _emval_handle_array[handle].value; + function dummy(){} + dummy.prototype = constructor.prototype; + var obj = new constructor; + var rv = constructor.apply(obj, args); + if (typeof rv === 'object') { + obj = rv; + } + return __emval_register(obj); } // appease jshint (technically this code uses eval) |