|
| 1 | + |
| 2 | +@:coreApi |
| 3 | +class Sys { |
| 4 | + /** |
| 5 | + SHARED |
| 6 | + Internally calls Builtins.print. |
| 7 | + **/ |
| 8 | + public static inline function print(v:Dynamic):Void |
| 9 | + sf.library.Builtins.print(v); |
| 10 | + |
| 11 | + /** |
| 12 | + SHARED |
| 13 | + Internally calls Builtins.print with a newline after |
| 14 | + **/ |
| 15 | + public static inline function println(v:Dynamic):Void |
| 16 | + sf.library.Builtins.print('$v\n'); |
| 17 | + |
| 18 | + /** |
| 19 | + Simply returns "SF" since Starfall has no concept of OS. |
| 20 | + There's no reason to use this |
| 21 | + **/ |
| 22 | + public static inline function systemName():String |
| 23 | + return "SF"; |
| 24 | + |
| 25 | + /** |
| 26 | + Returns an empty array, this isn't supported. |
| 27 | + **/ |
| 28 | + public static inline function args():Array<String> |
| 29 | + return []; |
| 30 | + |
| 31 | + // Can't just get an env variable from an SF chip. |
| 32 | + public static inline function getEnv(s:String):String |
| 33 | + return ""; |
| 34 | + |
| 35 | + public static inline function putEnv(s:String, v:String):Void {} |
| 36 | + |
| 37 | + public static function environment():Map<String, String> { |
| 38 | + return new Map<String,String>(); |
| 39 | + } |
| 40 | + |
| 41 | + /** |
| 42 | + Always returns false as setting the time isn't supported. |
| 43 | + **/ |
| 44 | + public inline static function setTimeLocale(loc:String):Bool |
| 45 | + return false; |
| 46 | + |
| 47 | + /** |
| 48 | + SHARED |
| 49 | + Returns the same thing as doing debugGetInfo(1,"S").short_src. |
| 50 | + **/ |
| 51 | + public inline static function getCwd():String { |
| 52 | + return untyped { |
| 53 | + sf.library.Builtins.debugGetInfo(1, "S").short_src; |
| 54 | + } |
| 55 | + } |
| 56 | + |
| 57 | + /** |
| 58 | + Does nothing. |
| 59 | + **/ |
| 60 | + public static inline function setCwd(s:String):Void {} |
| 61 | + |
| 62 | + /** |
| 63 | + SHARED |
| 64 | + Does nothing. Returns Access denied error code. |
| 65 | + https://www.tutorialspoint.com/batch_script/batch_script_return_code.htm |
| 66 | + **/ |
| 67 | + public static inline function command(cmd:String, ?args:Array<String>):Int { |
| 68 | + return 5; |
| 69 | + } |
| 70 | + |
| 71 | + /** |
| 72 | + SHARED |
| 73 | + Just errors the chip with the message 'exit' at stack level 0. |
| 74 | + **/ |
| 75 | + public static inline function exit(code:Int):Void { |
| 76 | + sf.library.Builtins.error("exit", 0); |
| 77 | + } |
| 78 | + |
| 79 | + /** |
| 80 | + SHARED |
| 81 | + Returns the same thing as using Timer.systime() |
| 82 | + **/ |
| 83 | + public static inline function time():Float |
| 84 | + return sf.library.Timer.systime(); |
| 85 | + |
| 86 | + /** |
| 87 | + SHARED |
| 88 | + Returns the same result as calling quotaTotalUsed() |
| 89 | + **/ |
| 90 | + public static inline function cpuTime():Float { |
| 91 | + return sf.library.Builtins.quotaTotalUsed(); |
| 92 | + } |
| 93 | + |
| 94 | + /** |
| 95 | + SHARED |
| 96 | + Returns the same result as getCwd, which just returns the debugGetInfo short_src of stack level 1. |
| 97 | + **/ |
| 98 | + public static inline function executablePath():String { |
| 99 | + return getCwd(); |
| 100 | + } |
| 101 | + |
| 102 | + /** |
| 103 | + SHARED |
| 104 | + Does the same thing as Sys.executablePath(). |
| 105 | + **/ |
| 106 | + public static inline function programPath():String { |
| 107 | + return executablePath(); |
| 108 | + } |
| 109 | + |
| 110 | + /** |
| 111 | + Don't use this. There is no std interface for starfall. |
| 112 | + **/ |
| 113 | + public static function getChar(echo: Bool):Int { |
| 114 | + return throw "No stdin in SF"; |
| 115 | + } |
| 116 | + |
| 117 | + /** |
| 118 | + SHARED |
| 119 | + Just calls Coroutine.yield. |
| 120 | + Starfall doesn't run in a coroutine by default so make sure you're in a coroutine. |
| 121 | + **/ |
| 122 | + public static function sleep(seconds: Float):Void { |
| 123 | + sf.library.Coroutine.yield(); |
| 124 | + } |
| 125 | + |
| 126 | + /** |
| 127 | + Don't use this. There is no std interface for starfall. |
| 128 | + **/ |
| 129 | + public static inline function stdin():haxe.io.Input { |
| 130 | + return throw "No stdio in SF"; |
| 131 | + } |
| 132 | + |
| 133 | + /** |
| 134 | + Don't use this. There is no std interface for starfall. |
| 135 | + **/ |
| 136 | + public static inline function stdout():haxe.io.Output { |
| 137 | + return throw "No stdio in SF"; |
| 138 | + } |
| 139 | + |
| 140 | + /** |
| 141 | + Don't use this. There is no std interface for starfall. |
| 142 | + **/ |
| 143 | + public static inline function stderr():haxe.io.Output { |
| 144 | + return throw "No stdio in SF"; |
| 145 | + } |
| 146 | +} |
0 commit comments