diff options
author | Chad Austin <caustin@gmail.com> | 2014-03-23 15:28:16 -0700 |
---|---|---|
committer | Chad Austin <chad@chadaustin.me> | 2014-03-28 23:56:41 -0700 |
commit | f9ef5a0002a3b2980d14f874514eeffa4f48dbbd (patch) | |
tree | 491a0d7b9e1f5c5b329eef2c27bf78f47b688417 | |
parent | b9abf3c50ff469a0a7c2824138210ecd6f0dd708 (diff) |
Allow passing memory_views in varargs
-rw-r--r-- | src/embind/embind.js | 3 | ||||
-rw-r--r-- | tests/embind/embind.test.js | 9 | ||||
-rw-r--r-- | tests/embind/embind_test.cpp | 6 |
3 files changed, 18 insertions, 0 deletions
diff --git a/src/embind/embind.js b/src/embind/embind.js index 660f7ad4..f8707986 100644 --- a/src/embind/embind.js +++ b/src/embind/embind.js @@ -589,6 +589,9 @@ function __embind_register_memory_view(rawType, name) { var TA = typeMapping[type]; return new TA(HEAP8.buffer, data, size); }, + 'readValueFromPointer': function(ptr) { + return this['fromWireType'](ptr); + }, }); } diff --git a/tests/embind/embind.test.js b/tests/embind/embind.test.js index b303d51c..2e74c133 100644 --- a/tests/embind/embind.test.js +++ b/tests/embind/embind.test.js @@ -1984,6 +1984,15 @@ module({ [6, -12.5, "a3", {x: 1, y: 2, z: 3, w: 4}, cm.EnumClass.TWO, [-1, -2, -3, -4]], instance.arguments); }); + + test("memory view", function() { + function factory(view) { + this.view = view; + } + + var instance = cm.construct_with_memory_view(factory); + assert.equal(10, instance.view.byteLength); + }); }); }); diff --git a/tests/embind/embind_test.cpp b/tests/embind/embind_test.cpp index 8dab6ec7..2746e114 100644 --- a/tests/embind/embind_test.cpp +++ b/tests/embind/embind_test.cpp @@ -2343,6 +2343,12 @@ val construct_with_6(val factory) { return factory.new_(a1, a2, a3, a4, a5, a6); } +val construct_with_memory_view(val factory) { + static const char data[11] = "0123456789"; + return factory.new_(memory_view(10, data)); +} + EMSCRIPTEN_BINDINGS(val_new_) { function("construct_with_6_arguments", &construct_with_6); + function("construct_with_memory_view", &construct_with_memory_view); } |