diff --git a/src/bin/Terminal.hx b/src/bin/Terminal.hx index 1691e3b..16cfc98 100644 --- a/src/bin/Terminal.hx +++ b/src/bin/Terminal.hx @@ -200,7 +200,7 @@ class Terminal implements Process { } private function getProgByName(name:String):Process { - var bin = BinStore.instance.getBinByAlias(name); + var bin = BinStore.getBinByAlias(name); if (bin == null) { return null; } diff --git a/src/kernel/Init.hx b/src/kernel/Init.hx index 824eaf6..daf654a 100644 --- a/src/kernel/Init.hx +++ b/src/kernel/Init.hx @@ -30,8 +30,6 @@ class Init { WindowManager.init(); MainTerm.instance = new MainTerm(); - BinStore.instance = new BinStore(); - if (Turtle.isTurtle()){ Turtle.instance = new Turtle(); } diff --git a/src/kernel/binstore/BinStore.hx b/src/kernel/binstore/BinStore.hx index 48ee95a..6d1fd83 100644 --- a/src/kernel/binstore/BinStore.hx +++ b/src/kernel/binstore/BinStore.hx @@ -22,9 +22,7 @@ import bin.Disk; import haxe.ds.ReadOnlyArray; class BinStore { - public static var instance: BinStore; - - private final store:ReadOnlyArray = [ + private static final store:ReadOnlyArray = [ {c: Disk, name: "Disk", aliases: ["disk"]}, {c: GPS, name: "GPS", aliases: ["gps"]}, {c: HelloWorld, name: "HelloWorld", aliases: ["hello"]}, @@ -46,12 +44,7 @@ class BinStore { {c: PFClient, name: "PFClient", aliases: ["pfclient"]} ]; - @:allow(kernel.Init) - private function new() { - - } - - public function getBinByName(name:String):Null { + public static function getBinByName(name:String):Null { for (bin in store) { if (bin.name == name) { return bin; @@ -60,7 +53,7 @@ class BinStore { return null; } - public function getBinByAlias(alias:String):Null { + public static function getBinByAlias(alias:String):Null { for (bin in store) { for (a in bin.aliases) { if (a == alias) { @@ -71,7 +64,7 @@ class BinStore { return null; } - public function getNameByAlias(alias: String): String { + public static function getNameByAlias(alias: String): String { var bin = getBinByAlias(alias); if (bin == null) { return null; diff --git a/src/kernel/service/Service.hx b/src/kernel/service/Service.hx index 7262367..1a9f00a 100644 --- a/src/kernel/service/Service.hx +++ b/src/kernel/service/Service.hx @@ -21,7 +21,7 @@ class Service { } public function start() { - var bin = BinStore.instance.getBinByAlias(this.binName); + var bin = BinStore.getBinByAlias(this.binName); if (bin == null){ throw new Error('Bin ${this.binName} not found'); diff --git a/src/kernel/service/ServiceManager.hx b/src/kernel/service/ServiceManager.hx index 002b7b4..c14d2bd 100644 --- a/src/kernel/service/ServiceManager.hx +++ b/src/kernel/service/ServiceManager.hx @@ -67,7 +67,7 @@ class ServiceManager { } public function register(name: String, binName: String,args: Array): Outcome { - if (BinStore.instance.getBinByAlias(binName) == null){ + if (BinStore.getBinByAlias(binName) == null){ return Failure("bin not found"); } diff --git a/src/lib/HomeContext.hx b/src/lib/HomeContext.hx index d04bfe8..7148a60 100644 --- a/src/lib/HomeContext.hx +++ b/src/lib/HomeContext.hx @@ -105,7 +105,7 @@ class HomeContext { } private function spawnPs(binName: String) { - var bin = BinStore.instance.getBinByAlias(binName); + var bin = BinStore.getBinByAlias(binName); if (bin == null) { Log.error('Could not find bin: ${binName}'); @@ -159,7 +159,7 @@ class HomeContext { for (i in 0...listedApps.length) { children.push(new TextElement( - 'Add ${BinStore.instance.getNameByAlias(listedApps[i])}', + 'Add ${BinStore.getNameByAlias(listedApps[i])}', {uiEvents: {onClick: this.spawnPs.bind(listedApps[i])}} )); }