diff options
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; + }, }); } |