Home /Modules/gui/SLGuiBridge.sleela

SLGuiBridge.sleela

lib/gui/version-mual/SLGuiBridge.sleela · 101 line(s) · sleela

<< lib/gui/version-mual/SLGuiBridge.sleela
   SLeeLa Standard Library Definition.
   Definition: Defines SLGuiBridge — Path 3 of gui/INTEGRATION.md: the shared
     native ABI. Mirrors gui/native/sleela_gui_bridge.h: a C-compatible callback
     boundary (slgui_bridge_create/call/destroy) plus the document-change
     refresh hook (slgui_bridge_on_document_change / slgui_bridge_document_changed)
     that is the native counterpart of SleelaGui.refresh(). The attached document
     count is bounded 1..14 to match the Java listener. >>
#sleela 2.5
material;
< SLeeLa gui front-end contract — Path 3 (shared native C ABI bridge). >
< Family: gui. Native VM/OS work crosses this explicit low-overhead boundary; >
< SLeeLa models the bridge's lifecycle and refresh hook. >
class SLGuiBridge {
  < ---- 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 = 11172;
  String metaAuthor = "Kiro Agent";
  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-10-16";
  < 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; }
  int SLGUI_MIN_DOCUMENTS = 1;
  int SLGUI_MAX_DOCUMENTS = 14;
  < 1 after slgui_bridge_create succeeds >
  int created;
  < 1 while a refresh callback is installed >
  int hasRefresh;
  < attached document count (bounded 1..14) >
  int documents;
  < total refreshes delivered to the callback >
  int delivered;
  < slgui_bridge_create(context, call): a non-null call is required. >
  boolean create(boolean hasCall) {
    if (!hasCall) { created = 0; return false; }
    created = 1; hasRefresh = 0; documents = 0; delivered = 0;
    return true;
  }
  boolean isCreated() { return created == 1; }
  < slgui_bridge_call(operation, arguments): valid only on a created bridge >
  < with a non-empty operation (null arguments are treated as empty). >
  boolean call(String operation) {
    return created == 1 && operation != null;
  }
  < Attach the watched-document count; enforces the 1..14 ABI bound. >
  boolean attachDocuments(int count) {
    if (created == 0) { return false; }
    if (count < SLGUI_MIN_DOCUMENTS || count > SLGUI_MAX_DOCUMENTS) { return false; }
    documents = count;
    return true;
  }
  int documentCount() { return documents; }
  < slgui_bridge_on_document_change(refresh): install (or clear with false). >
  void onDocumentChange(boolean installRefresh) {
    hasRefresh = installRefresh ? 1 : 0;
  }
  < slgui_bridge_document_changed(id, revision): forwards one change; returns >
  < 1 when delivered, else 0 (no-op when no callback is installed). >
  int documentChanged(String documentId) {
    if (created == 0 || hasRefresh == 0 || documentId == null) { return 0; }
    delivered = delivered + 1;
    return 1;
  }
  int totalDelivered() { return delivered; }
  < slgui_bridge_destroy(bridge). >
  void destroy() { created = 0; hasRefresh = 0; documents = 0; }
}