From ffbf0c20ccc4e70281958f18ed117f40bdd91397 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Mon, 30 Sep 2019 20:59:44 +0200 Subject: feat: op registration in core (#3002) --- core/shared_queue.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'core/shared_queue.js') diff --git a/core/shared_queue.js b/core/shared_queue.js index 22a64a312..7eeb61255 100644 --- a/core/shared_queue.js +++ b/core/shared_queue.js @@ -58,6 +58,13 @@ SharedQueue Binary Layout Deno.core.recv(handleAsyncMsgFromRust); } + function ops() { + // op id 0 is a special value to retreive the map of registered ops. + const opsMapBytes = Deno.core.send(0, new Uint8Array([]), null); + const opsMapJson = String.fromCharCode.apply(null, opsMapBytes); + return JSON.parse(opsMapJson); + } + function assert(cond) { if (!cond) { throw Error("assert"); @@ -84,7 +91,6 @@ SharedQueue Binary Layout return shared32[INDEX_NUM_RECORDS] - shared32[INDEX_NUM_SHIFTED_OFF]; } - // TODO(ry) rename to setMeta function setMeta(index, end, opId) { shared32[INDEX_OFFSETS + 2 * index] = end; shared32[INDEX_OFFSETS + 2 * index + 1] = opId; @@ -189,7 +195,8 @@ SharedQueue Binary Layout push, reset, shift - } + }, + ops }; assert(window[GLOBAL_NAMESPACE] != null); -- cgit v1.2.3