From eafca2f18235bf0f5161763e9cf671c4c521a696 Mon Sep 17 00:00:00 2001 From: Jordan Eldredge Date: Thu, 19 Sep 2019 07:15:25 -0700 Subject: [PATCH] Implement list (#924) * Add eslint support for Maki any * Implement all of List --- eslint-local-rules.js | 4 ++ .../__snapshots__/objects.test.js.snap | 6 --- modern/src/runtime/List.ts | 38 +++++++++---------- 3 files changed, 23 insertions(+), 25 deletions(-) diff --git a/eslint-local-rules.js b/eslint-local-rules.js index 4b5ba2fc..8825f2ff 100644 --- a/eslint-local-rules.js +++ b/eslint-local-rules.js @@ -41,6 +41,10 @@ const TYPE_MAP = { typeScriptName: "TSNumberKeyword", stringRepresentation: "number", }, + any: { + typeScriptName: "TSAnyKeyword", + stringRepresentation: "any", + }, }; module.exports = { diff --git a/modern/src/maki-interpreter/__snapshots__/objects.test.js.snap b/modern/src/maki-interpreter/__snapshots__/objects.test.js.snap index 445986fd..0a960d0c 100644 --- a/modern/src/maki-interpreter/__snapshots__/objects.test.js.snap +++ b/modern/src/maki-interpreter/__snapshots__/objects.test.js.snap @@ -192,12 +192,6 @@ Layout.beforeredock Layout.redock Layout.istransparencysafe Layout.islayoutanimationsafe -List.additem -List.removeitem -List.enumitem -List.finditem -List.getnumitems -List.removeall Layer.setregion Layer.setregionfrommap Layer.fx_oninit diff --git a/modern/src/runtime/List.ts b/modern/src/runtime/List.ts index a7d95588..c938c11a 100644 --- a/modern/src/runtime/List.ts +++ b/modern/src/runtime/List.ts @@ -1,7 +1,13 @@ import MakiObject from "./MakiObject"; -import { unimplementedWarning } from "../utils"; class List extends MakiObject { + _list: Array; + + constructor(node, parent, annotations, store) { + super(node, parent, annotations, store); + this._list = []; + } + /** * getclassname() * @@ -12,34 +18,28 @@ class List extends MakiObject { return "List"; } - additem(_object) { - unimplementedWarning("additem"); - return; + additem(object: any): void { + this._list.push(object); } - removeitem(pos: number) { - unimplementedWarning("removeitem"); - return; + removeitem(pos: number): void { + this._list.splice(pos, 1); } - enumitem(pos: number) { - unimplementedWarning("enumitem"); - return; + enumitem(pos: number): any { + return this._list[pos]; } - finditem(_object) { - unimplementedWarning("finditem"); - return; + finditem(obj: any): number { + return this._list.indexOf(obj); } - getnumitems() { - unimplementedWarning("getnumitems"); - return; + getnumitems(): number { + return this._list.length; } - removeall() { - unimplementedWarning("removeall"); - return; + removeall(): void { + this._list = []; } }