Initial project import
This commit is contained in:
commit
d189bb22f4
19 files changed
+361
No files matched your search
@@ -0,0 +1,60 @@
|
||||
// Public Agila application contract and host-safe sandbox.
|
||||
// This file does not implement Agila OS services or private ABIs.
|
||||
module agila
|
||||
|
||||
pub struct AgilaError {
|
||||
pub:
|
||||
code int
|
||||
message string
|
||||
}
|
||||
|
||||
pub fn (err AgilaError) msg() string {
|
||||
return err.message
|
||||
}
|
||||
|
||||
pub enum Capability {
|
||||
ui
|
||||
audio
|
||||
storage
|
||||
networking
|
||||
graphics
|
||||
}
|
||||
|
||||
pub struct App {
|
||||
pub:
|
||||
id string
|
||||
name string
|
||||
mut:
|
||||
started bool
|
||||
}
|
||||
|
||||
pub fn new_app(id string, name string) !App {
|
||||
if id.len == 0 || name.len == 0 {
|
||||
return AgilaError{code: 1, message: 'Application id and name are required'}
|
||||
}
|
||||
return App{id: id, name: name}
|
||||
}
|
||||
|
||||
pub fn (mut app App) start() ! {
|
||||
if app.started {
|
||||
return AgilaError{code: 2, message: 'Application is already started'}
|
||||
}
|
||||
app.started = true
|
||||
println('[Agila SDK sandbox] started ${app.name}')
|
||||
}
|
||||
|
||||
pub fn (mut app App) stop() {
|
||||
app.started = false
|
||||
println('[Agila SDK sandbox] stopped ${app.name}')
|
||||
}
|
||||
|
||||
pub fn (app &App) request(cap Capability) ! {
|
||||
if !app.started {
|
||||
return AgilaError{code: 3, message: 'Start the application before requesting capabilities'}
|
||||
}
|
||||
println('[Agila SDK sandbox] requested capability: ${cap}')
|
||||
}
|
||||
|
||||
pub fn log(text string) {
|
||||
println('[Agila app] ${text}')
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
// Application-facing graphics contracts only. No AGX implementation is included.
|
||||
module agila
|
||||
|
||||
pub struct Vec2 { pub: x f32; y f32 }
|
||||
pub struct Vec3 { pub: x f32; y f32; z f32 }
|
||||
|
||||
pub struct MeshDescriptor {
|
||||
pub:
|
||||
vertex_count int
|
||||
index_count int
|
||||
}
|
||||
|
||||
pub struct TextureDescriptor {
|
||||
pub:
|
||||
width int
|
||||
height int
|
||||
format string
|
||||
}
|
||||
|
||||
pub fn validate_mesh(desc MeshDescriptor) ! {
|
||||
if desc.vertex_count <= 0 || desc.index_count <= 0 {
|
||||
return AgilaError{code: 20, message: 'Mesh counts must be positive'}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn submit_mesh(desc MeshDescriptor) ! {
|
||||
validate_mesh(desc)!
|
||||
println('[Agila SDK sandbox graphics] submitted mesh ${desc.vertex_count}/${desc.index_count}')
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
// Safe application-level UI model. Rendering is provided by the proprietary Agila runtime.
|
||||
module agila
|
||||
|
||||
pub struct Color {
|
||||
pub:
|
||||
r u8
|
||||
g u8
|
||||
b u8
|
||||
a u8 = 255
|
||||
}
|
||||
|
||||
pub fn rgb(hex u32) Color {
|
||||
return Color{
|
||||
r: u8((hex >> 16) & 0xff)
|
||||
g: u8((hex >> 8) & 0xff)
|
||||
b: u8(hex & 0xff)
|
||||
}
|
||||
}
|
||||
|
||||
pub struct Theme {
|
||||
pub:
|
||||
background Color
|
||||
surface Color
|
||||
text Color
|
||||
accent Color
|
||||
}
|
||||
|
||||
pub fn default_theme() Theme {
|
||||
return Theme{
|
||||
background: rgb(0x08080e)
|
||||
surface: rgb(0x171827)
|
||||
text: rgb(0xf5f1ff)
|
||||
accent: rgb(0xc084fc)
|
||||
}
|
||||
}
|
||||
|
||||
pub interface Widget {
|
||||
describe() string
|
||||
}
|
||||
|
||||
pub struct Text {
|
||||
pub:
|
||||
value string
|
||||
}
|
||||
|
||||
pub fn (t Text) describe() string { return 'Text(${t.value})' }
|
||||
|
||||
pub struct Button {
|
||||
pub:
|
||||
label string
|
||||
}
|
||||
|
||||
pub fn (b Button) describe() string { return 'Button(${b.label})' }
|
||||
|
||||
pub struct Column {
|
||||
pub:
|
||||
children []Widget
|
||||
}
|
||||
|
||||
pub fn (c Column) describe() string { return 'Column(${c.children.len} children)' }
|
||||
|
||||
pub fn preview(widget Widget) {
|
||||
println('[Agila SDK sandbox UI] ${widget.describe()}')
|
||||
}
|
||||
Reference in new issue
Block a user