use ReadOnlyArray where it makes sense

This commit is contained in:
Djeeberjr 2022-03-12 17:23:09 +01:00
parent 72dfcb1aa1
commit f3141a0f99
3 changed files with 9 additions and 6 deletions

View File

@ -1,5 +1,6 @@
package kernel.fs; package kernel.fs;
import haxe.ds.ReadOnlyArray;
import kernel.fs.FileHandler.WriteBinaryHandle; import kernel.fs.FileHandler.WriteBinaryHandle;
import kernel.fs.FileHandler.ReadBinaryHandle; import kernel.fs.FileHandler.ReadBinaryHandle;
import kernel.fs.FileHandler.WriteHandle; import kernel.fs.FileHandler.WriteHandle;
@ -12,7 +13,7 @@ using lua.Table;
Wrapper to interact with the filesystem. Wrapper to interact with the filesystem.
**/ **/
class FS { class FS {
public static inline function list(path: String):Array<String> { public static inline function list(path: String):ReadOnlyArray<String> {
return FileSystem.list(path).toArray(); return FileSystem.list(path).toArray();
} }
@ -84,7 +85,7 @@ class FS {
return FileSystem.open(path,BinaryAppend); return FileSystem.open(path,BinaryAppend);
} }
public static inline function find(pattern: String):Array<String> { public static inline function find(pattern: String):ReadOnlyArray<String> {
return FileSystem.find(pattern).toArray(); return FileSystem.find(pattern).toArray();
} }

View File

@ -1,5 +1,6 @@
package kernel.peripherals; package kernel.peripherals;
import haxe.ds.ReadOnlyArray;
import kernel.peripherals.Modem; import kernel.peripherals.Modem;
import kernel.peripherals.Screen; import kernel.peripherals.Screen;
@ -36,7 +37,7 @@ class Peripheral {
/** /**
Get all connected screens. Get all connected screens.
**/ **/
public function getScreens():Array<Screen> { public function getScreens():ReadOnlyArray<Screen> {
return this.screens; return this.screens;
} }
@ -52,7 +53,7 @@ class Peripheral {
/** /**
Get all connected modems. Get all connected modems.
**/ **/
public function getModems():Array<Modem> { public function getModems():ReadOnlyArray<Modem> {
return this.modes; return this.modes;
} }
@ -68,7 +69,7 @@ class Peripheral {
/** /**
Get all connected drives. Get all connected drives.
**/ **/
public function getDrives(): Array<Drive> { public function getDrives(): ReadOnlyArray<Drive> {
return this.drives; return this.drives;
} }

View File

@ -1,5 +1,6 @@
package kernel.ui; package kernel.ui;
import haxe.ds.ReadOnlyArray;
import kernel.ui.TermWriteable; import kernel.ui.TermWriteable;
import kernel.peripherals.Peripherals.Peripheral; import kernel.peripherals.Peripherals.Peripheral;
@ -73,7 +74,7 @@ class WindowManager {
return newContext; return newContext;
} }
public function getOutputs():Array<String> { public function getOutputs():ReadOnlyArray<String> {
var arr = Peripheral.instance.getScreens().map(screen -> return screen.getAddr()); var arr = Peripheral.instance.getScreens().map(screen -> return screen.getAddr());
arr.push("main"); arr.push("main");
return arr; return arr;