diff options
author | Chad Austin <chad@imvu.com> | 2013-04-11 00:07:53 -0700 |
---|---|---|
committer | Jukka Jylänki <jujjyl@gmail.com> | 2013-04-18 20:08:10 +0300 |
commit | 53c228a260b7a5e90e430860e130ed6006bd328a (patch) | |
tree | 40e66b84f3a2a5eac234f67bf390d8f34d735028 /src/embind | |
parent | 6a4574cfe44b75f8cfaa916a08b402f99baf6cc7 (diff) |
Allow passing JavaScript strings to std::wstring
Diffstat (limited to 'src/embind')
-rwxr-xr-x | src/embind/embind.js | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/embind/embind.js b/src/embind/embind.js index 576a519e..f66b0495 100755 --- a/src/embind/embind.js +++ b/src/embind/embind.js @@ -366,6 +366,18 @@ function __embind_register_std_wstring(rawType, charSize, name) { _free(value); return a.join(''); }, + toWireType: function(destructors, value) { + // assumes 4-byte alignment + var length = value.length; + var ptr = _malloc(4 + length * charSize); + HEAPU32[ptr >> 2] = length; + var start = (ptr + 4) >> shift; + for (var i = 0; i < length; ++i) { + HEAP[start + i] = value.charCodeAt(i); + } + destructors.push(_free, ptr); + return ptr; + }, }); } |