Revert json ops (#2814)

* Revert "port more ops to JSON (#2809)"

This reverts commit 137f33733d.

* Revert "port ops to JSON: compiler, errors, fetch, files (#2804)"

This reverts commit 79f82cf10e.

* Revert "Port rest of os ops to JSON (#2802)"

This reverts commit 5b2baa5c99.
This commit is contained in:
Ryan Dahl 2019-08-24 13:20:48 -07:00 committed by GitHub
parent bdc0a13261
commit 2235dd795d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
45 changed files with 1968 additions and 1045 deletions

View file

@ -1,6 +1,6 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
import * as dispatch from "./dispatch";
import { sendSync } from "./dispatch_json";
import { assert } from "./util";
import { sendSync, msg, flatbuffers } from "./dispatch_flatbuffers";
export interface ResourceMap {
[rid: number]: string;
@ -10,10 +10,20 @@ export interface ResourceMap {
* representation.
*/
export function resources(): ResourceMap {
const res = sendSync(dispatch.OP_RESOURCES) as Array<[number, string]>;
const builder = flatbuffers.createBuilder();
const inner = msg.Resource.createResource(builder, 0, 0);
const baseRes = sendSync(builder, msg.Any.Resources, inner);
assert(baseRes !== null);
assert(msg.Any.ResourcesRes === baseRes!.innerType());
const res = new msg.ResourcesRes();
assert(baseRes!.inner(res) !== null);
const resources: ResourceMap = {};
for (const resourceTuple of res) {
resources[resourceTuple[0]] = resourceTuple[1];
for (let i = 0; i < res.resourcesLength(); i++) {
const item = res.resources(i)!;
resources[item.rid()!] = item.repr()!;
}
return resources;
}