diff options
author | Alon Zakai <alonzakai@gmail.com> | 2012-03-30 20:15:32 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2012-03-30 20:15:32 -0700 |
commit | 3b7d149de6bb40c9714f9e863485d613d2135b5c (patch) | |
tree | 99ac4e281aa31092bfb71d849f9a7ffcfbd4d2b5 /src/preamble.js | |
parent | fa8b668639e9c9656a6efa0c5ff24d33e33a9f5a (diff) | |
parent | d241868b63fcd306f3ff1007b57363391b724a46 (diff) |
Merge pull request #328 from ehsan/ogre_upstream
Upstream the work I did for porting Ogre
Diffstat (limited to 'src/preamble.js')
-rw-r--r-- | src/preamble.js | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/src/preamble.js b/src/preamble.js index 33da1159..c88a4671 100644 --- a/src/preamble.js +++ b/src/preamble.js @@ -729,11 +729,14 @@ Module['Array_copy'] = Array_copy; #if USE_TYPED_ARRAYS // Copies a list of num items on the HEAP into a // JavaScript typed array. -function TypedArray_copy(ptr, num) { +function TypedArray_copy(ptr, num, offset /*optional*/) { // TODO: optimize this! - var arr = new Uint8Array(num); - for (var i = 0; i < num; ++i) { - arr[i] = {{{ makeGetValue('ptr', 'i', 'i8') }}}; + if (offset === undefined) { + offset = 0; + } + var arr = new Uint8Array(num - offset); + for (var i = offset; i < num; ++i) { + arr[i - offset] = {{{ makeGetValue('ptr', 'i', 'i8') }}}; } return arr.buffer; } @@ -762,11 +765,14 @@ Module['String_copy'] = String_copy; // This processes a JS string into a C-line array of numbers, 0-terminated. // For LLVM-originating strings, see parser.js:parseLLVMString function -function intArrayFromString(stringy, dontAddNull) { +function intArrayFromString(stringy, dontAddNull, length /* optional */) { var ret = []; var t; var i = 0; - while (i < stringy.length) { + if (length === undefined) { + length = stringy.length; + } + while (i < length) { var chr = stringy.charCodeAt(i); if (chr > 0xFF) { #if ASSERTIONS |