SLVmPlatform.sleela
lib/vm/src/sleela/SLVmPlatform.sleela · 128 line(s) · sleela
<< lib/vm/src/sleela/SLVmPlatform.sleela
SLeeLa Standard Library Definition.
Definition: Defines SLVmPlatform — the OOD equivalent of the native
platform-parity readout (virtual-machine/vm-version/008/vm_platform.{h,c},
v008). It names the host (Win32/POSIX/Apple) and, per capability, reports
parity: supported by the OS AND permitted by config. A capability a user
permits but the OS does not support raises a typed UNAVAILABLE result once.
The native side reads sleela_platform; this class holds the detected
platform + the per-capability OS-support bits fed to it.
Mirrors: enum VmPlatform, vm_platform_supports/parity/audit/report.
Family: vm. Composes SLVmConfig, SLVmCapability, SLVmResult, SLVmReport. >>
#sleela 2.5
material;
class SLVmPlatform {
< ---- 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 = 11287;
String metaAuthor = "unknown";
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 = "unknown";
< 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; }
static final int UNKNOWN = 0;
static final int LINUX = 1;
static final int WINDOWS = 2;
static final int MACOS = 3;
int platform;
String osVersion;
String arch;
< OS support bits per capability, numbered 0..9 (1=supported). Default all 1. >
int supMemory; int supFileIo; int supNetwork; int supThreads; int supDynlib;
int supTerminal; int supPaths; int supProcess; int supIpc; int supTime;
void init(int detected, String version, String architecture) {
platform = detected; osVersion = version; arch = architecture;
supMemory=1; supFileIo=1; supNetwork=1; supThreads=1; supDynlib=1;
supTerminal=1; supPaths=1; supProcess=1; supIpc=1; supTime=1;
}
< Caller may mark a capability unsupported on this OS (e.g. ipc/dynlib variance). >
void setSupport(int cap, boolean supported) {
int v = supported ? 1 : 0;
if (cap == 1) { supMemory = v; }
else if (cap == 2) { supFileIo = v; }
else if (cap == 4) { supNetwork = v; }
else if (cap == 8) { supThreads = v; }
else if (cap == 16) { supDynlib = v; }
else if (cap == 32) { supTerminal = v; }
else if (cap == 64) { supPaths = v; }
else if (cap == 128) { supProcess = v; }
else if (cap == 256) { supIpc = v; }
else if (cap == 512) { supTime = v; }
}
boolean supports(int cap) {
if (cap == 1) { return supMemory == 1; }
if (cap == 2) { return supFileIo == 1; }
if (cap == 4) { return supNetwork == 1; }
if (cap == 8) { return supThreads == 1; }
if (cap == 16) { return supDynlib == 1; }
if (cap == 32) { return supTerminal == 1; }
if (cap == 64) { return supPaths == 1; }
if (cap == 128) { return supProcess == 1; }
if (cap == 256) { return supIpc == 1; }
if (cap == 512) { return supTime == 1; }
return false;
}
< 1 if (OS supports) AND (config permits); warns once if permitted-but-not-supported. >
boolean parity(int cap, SLVmCapability caps, SLVmResult res, SLVmReport rep) {
boolean os = supports(cap);
boolean permitted = (caps == null) ? true : caps.allowed(cap);
if (permitted && !os) {
if (res != null) {
< 4 = 4 (literal: a sibling class static cannot be read through an instance) >
res.fail(4, "platform",
"capability '" + (caps==null?"?":caps.capName(cap)) + "' permitted but not supported on " + platformName());
res.report(rep);
}
return false;
}
return permitted && os;
}
String platformName() {
if (platform == LINUX) { return "linux"; }
if (platform == WINDOWS) { return "windows"; }
if (platform == MACOS) { return "macos"; }
return "unknown";
}
}