From 52550c26325ff3d6649fa84c83bf8d4ce9ad4fde Mon Sep 17 00:00:00 2001 From: Daniel Wirtz Date: Tue, 21 Jan 2020 22:29:18 +0100 Subject: Unify JS memory segment API (#2533) Binaryen.js now uses offset instead of byteOffset when inspecting a memory segment, matching the arguments on memory segment creation. Also adds inspection of the passive property. Previously, one would specify { offset, data, passive } on creation and get back { byteOffset, data } upon inspection. This PR unifies both to the keys on creation while also adding the respective C-API to retrieve passive status, which was missing. --- src/js/binaryen.js-post.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/js/binaryen.js-post.js') diff --git a/src/js/binaryen.js-post.js b/src/js/binaryen.js-post.js index 54f21ed07..5857c21c9 100644 --- a/src/js/binaryen.js-post.js +++ b/src/js/binaryen.js-post.js @@ -2212,7 +2212,7 @@ function wrapModule(module, self) { } self['getMemorySegmentInfoByIndex'] = function(id) { return { - 'byteOffset': Module['_BinaryenGetMemorySegmentByteOffset'](module, id), + 'offset': Module['_BinaryenGetMemorySegmentByteOffset'](module, id), 'data': (function(){ var size = Module['_BinaryenGetMemorySegmentByteLength'](module, id); var ptr = _malloc(size); @@ -2221,7 +2221,8 @@ function wrapModule(module, self) { res.set(new Uint8Array(buffer, ptr, size)); _free(ptr); return res.buffer; - })() + })(), + 'passive': Boolean(Module['_BinaryenGetMemorySegmentPassive'](module, id)) }; } self['setStart'] = function(start) { -- cgit v1.2.3