From f3141a0f9994d9fefb6aa31cb29d6a03d87593e3 Mon Sep 17 00:00:00 2001 From: Djeeberjr Date: Sat, 12 Mar 2022 17:23:09 +0100 Subject: [PATCH] use ReadOnlyArray where it makes sense --- src/kernel/fs/FS.hx | 5 +++-- src/kernel/peripherals/Peripherals.hx | 7 ++++--- src/kernel/ui/WindowManager.hx | 3 ++- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/kernel/fs/FS.hx b/src/kernel/fs/FS.hx index 770af27..2c0b935 100644 --- a/src/kernel/fs/FS.hx +++ b/src/kernel/fs/FS.hx @@ -1,5 +1,6 @@ package kernel.fs; +import haxe.ds.ReadOnlyArray; import kernel.fs.FileHandler.WriteBinaryHandle; import kernel.fs.FileHandler.ReadBinaryHandle; import kernel.fs.FileHandler.WriteHandle; @@ -12,7 +13,7 @@ using lua.Table; Wrapper to interact with the filesystem. **/ class FS { - public static inline function list(path: String):Array { + public static inline function list(path: String):ReadOnlyArray { return FileSystem.list(path).toArray(); } @@ -84,7 +85,7 @@ class FS { return FileSystem.open(path,BinaryAppend); } - public static inline function find(pattern: String):Array { + public static inline function find(pattern: String):ReadOnlyArray { return FileSystem.find(pattern).toArray(); } diff --git a/src/kernel/peripherals/Peripherals.hx b/src/kernel/peripherals/Peripherals.hx index 885dfc2..074abe3 100644 --- a/src/kernel/peripherals/Peripherals.hx +++ b/src/kernel/peripherals/Peripherals.hx @@ -1,5 +1,6 @@ package kernel.peripherals; +import haxe.ds.ReadOnlyArray; import kernel.peripherals.Modem; import kernel.peripherals.Screen; @@ -36,7 +37,7 @@ class Peripheral { /** Get all connected screens. **/ - public function getScreens():Array { + public function getScreens():ReadOnlyArray { return this.screens; } @@ -52,7 +53,7 @@ class Peripheral { /** Get all connected modems. **/ - public function getModems():Array { + public function getModems():ReadOnlyArray { return this.modes; } @@ -68,7 +69,7 @@ class Peripheral { /** Get all connected drives. **/ - public function getDrives(): Array { + public function getDrives(): ReadOnlyArray { return this.drives; } diff --git a/src/kernel/ui/WindowManager.hx b/src/kernel/ui/WindowManager.hx index ee17284..ea5fb2d 100644 --- a/src/kernel/ui/WindowManager.hx +++ b/src/kernel/ui/WindowManager.hx @@ -1,5 +1,6 @@ package kernel.ui; +import haxe.ds.ReadOnlyArray; import kernel.ui.TermWriteable; import kernel.peripherals.Peripherals.Peripheral; @@ -73,7 +74,7 @@ class WindowManager { return newContext; } - public function getOutputs():Array { + public function getOutputs():ReadOnlyArray { var arr = Peripheral.instance.getScreens().map(screen -> return screen.getAddr()); arr.push("main"); return arr;