From 13fe7fbab148de7d8dec50014b3808374aaf95f8 Mon Sep 17 00:00:00 2001 From: Djeeberjr Date: Sun, 4 Jun 2023 21:47:26 +0200 Subject: [PATCH] added Perf bin --- src/bin/Perf.hx | 38 +++++++++++++++++++++++++++++++++ src/kernel/DCEHack.hx | 1 + src/kernel/binstore/BinStore.hx | 4 +++- 3 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 src/bin/Perf.hx diff --git a/src/bin/Perf.hx b/src/bin/Perf.hx new file mode 100644 index 0000000..60192cb --- /dev/null +++ b/src/bin/Perf.hx @@ -0,0 +1,38 @@ +package bin; + +import kernel.peripherals.Peripherals.Peripheral; +import lib.CLIAppBase; + +class Perf extends CLIAppBase { + public function new() { + registerSyncSubcommand("inspect",(args)->{ + if (args.length < 1) return false; + + var result = Peripheral.instance.inspect(args[0]); + + if (result == null){ + handle.writeLine("No peripheral found on side "+args[0]); + return true; + } + + handle.writeLine("Types:"); + for (type in result.types){ + handle.writeLine(" "+type); + } + + handle.writeLine("Methods:"); + for (method in result.methods){ + handle.writeLine(" "+method); + } + + return true; + },""); + + registerSyncSubcommand("list",(args)->{ + for (addr in Peripheral.instance.getAllAddresses()){ + handle.writeLine('$addr => ${Peripheral.instance.getTypes(addr).join(", ")}'); + } + return true; + }); + } +} diff --git a/src/kernel/DCEHack.hx b/src/kernel/DCEHack.hx index 6d1b25a..d24c0b9 100644 --- a/src/kernel/DCEHack.hx +++ b/src/kernel/DCEHack.hx @@ -18,6 +18,7 @@ class DCEHack { new bin.HelloWorldService(), new bin.srsc.SiteRessourceController(), new bin.srsc.CLI(), + new bin.Perf(), ]; } } diff --git a/src/kernel/binstore/BinStore.hx b/src/kernel/binstore/BinStore.hx index a3810b3..c83b760 100644 --- a/src/kernel/binstore/BinStore.hx +++ b/src/kernel/binstore/BinStore.hx @@ -1,5 +1,6 @@ package kernel.binstore; +import bin.Perf; import bin.srsc.CLI; import bin.srsc.SiteRessourceController; import bin.HelloWorldService; @@ -31,7 +32,8 @@ class BinStore { {c: Service, name: "Service", aliases: ["service","srv"]}, {c: HelloWorldService, name: "HelloWorldService", aliases: ["hello-service"] }, {c: SiteRessourceController, name: "SiteRessourceController", aliases: ["srsc"]}, - {c: CLI, name: "SRSC CLI", aliases: ["srsc-cli"]} + {c: CLI, name: "SRSC CLI", aliases: ["srsc-cli"]}, + {c: Perf, name: "Perf", aliases: ["perf"]} ]; @:allow(kernel.Init)