SLOperatingSystem.sleela
lib/operating-system/SLOperatingSystem.sleela · 113 line(s) · sleela
<< lib/operating-system/SLOperatingSystem.sleela
SLeeLa Standard Library Definition.
Definition: Defines SLOperatingSystem โ the capstone facade of the /lib/os
family. It is the single object a developer reaches for to talk to the host
operating system from SLeeLa source: identity (which OS, hostname, user),
the environment, the working directory, and process execution. Every method
bottoms out in an `os*` SLVM built-in that makes the GENUINE host System API
call โ Win32 on Windows, POSIX on Linux, POSIX+Apple on macOS โ so the same
SLeeLa program drives the real OS on whichever platform runs it.
This is the general, cross-OS surface. The OS-specific flavor classes
(SLWindowsOS / SLLinuxOS / SLMacOS) build on these same built-ins to expose
features idiomatic to each platform.
Family: operating-system. Native VM/OS work crosses the explicit `os*` SLVM bridge. >>
#sleela 2.5
material;
class SLOperatingSystem {
< ---- Descriptive metadata (version 1.11 nested-friendly accessors) ---- >
<< Eleven catalogued attributes with getter/setter pairs, so a GUI, loader,
or catalog can read and (where appropriate) override this record.
Values are faithful to the subject's real origin where publicly known. >>
String metaVersion = "1.0.0";
int metaId = 630;
String metaAuthor = "Max Rupplin vs. Dr. Mrs. Elisabeth Harkins";
String metaDate = "2026-10-16";
String metaCopyright = "SLeeLa project";
String metaTrademark = "none";
String metaCorporation = "none";
< metaOrigin: National | <nation> | International | Galactic >
String metaOrigin = "International";
String metaBirthDate = "2026-09-28";
< metaScienceRating: maturity/robustness on a 1..10 scale >
int metaScienceRating = 9;
< metaNationalSchedule: a real, citable instrument or "none" >
String metaNationalSchedule = "none";
String getMetaVersion() { return metaVersion; }
void setMetaVersion(String v) { metaVersion = v; }
int getMetaId() { return metaId; }
void setMetaId(int v) { metaId = v; }
String getAuthor() { return metaAuthor; }
void setAuthor(String v) { metaAuthor = v; }
String getDate() { return metaDate; }
void setDate(String v) { metaDate = v; }
String getCopyright() { return metaCopyright; }
void setCopyright(String v) { metaCopyright = v; }
String getTrademark() { return metaTrademark; }
void setTrademark(String v) { metaTrademark = v; }
String getCorporation() { return metaCorporation; }
void setCorporation(String v) { metaCorporation = v; }
String getOrigin() { return metaOrigin; }
void setOrigin(String v) { metaOrigin = v; }
String getBirthDate() { return metaBirthDate; }
void setBirthDate(String v) { metaBirthDate = v; }
int getScienceRating() { return metaScienceRating; }
void setScienceRating(int v) { metaScienceRating = v; }
String getNationalSchedule() { return metaNationalSchedule; }
void setNationalSchedule(String v) { metaNationalSchedule = v; }
< Capability ordinals (mirror SLPlatformCapability in the VM). >
static final int CAP_MEMORY = 0;
static final int CAP_FILE_IO = 1;
static final int CAP_NETWORK = 2;
static final int CAP_THREADS = 3;
static final int CAP_LIBRARY = 4;
static final int CAP_TERMINAL= 5;
static final int CAP_PATHS = 6;
static final int CAP_PROCESS = 7;
static final int CAP_IPC = 8;
static final int CAP_TIME = 9;
< human label chosen by the caller >
String name;
int opened;
void configure(String label) { name = label; opened = 0; }
void open() { opened = 1; }
void close() { opened = 0; }
boolean active() { return opened == 1; }
< ---- Identity ----------------------------------------------------------- >
< The host OS name as reported by the VM: "Windows", "Linux", or "macOS". >
String platform() { return osPlatform(); }
boolean isWindows() { return equalsString(osPlatform(), "Windows"); }
boolean isLinux() { return equalsString(osPlatform(), "Linux"); }
boolean isMac() { return equalsString(osPlatform(), "macOS"); }
String hostName() { return osHostName(); }
String userName() { return osUserName(); }
int processId() { return osProcessId(); }
< True if the host advertises a capability class (process/ipc/network/...). >
boolean supports(int capability) { return osCapability(capability) == 1; }
< ---- Environment -------------------------------------------------------- >
String getEnv(String key) { return osGetEnv(key); }
boolean setEnv(String key, String value) { return osSetEnv(key, value) == 0; }
< ---- Working directory -------------------------------------------------- >
String currentDir() { return osCurrentDir(); }
boolean changeDir(String path) { return osChangeDir(path) == 0; }
String tempDir() { return osTempDir(); }
< ---- Process execution -------------------------------------------------- >
< Run a shell command synchronously; returns its exit code (0 == success). >
int run(String command) { return osRun(command); }
< True if the command ran and exited 0. >
boolean runOk(String command) { return osRun(command) == 0; }
< String equality helper (SLeeLa compares value by ==, but keep intent clear). >
boolean equalsString(String a, String b) { return a == b; }
}