Gui text argument
GTK window program70 lines of .st236 lines of generated Cbuilds as C and Rust
o3/2
On this page
The .st files#
intent.st
structop {
type_app {
exec = {
lang = "C"
}
}
lib_provider {
core = {
source = "StructOp/core"
version = "@latest"
}
Gui = {
source = "StructOp/gui"
version = "@latest"
}
}
}main.st
# Text with ${} given to a function inside a callback list (a button's on_click), nested once: the same in both
# targets, and freed when the statement in the callback ends (language 8.4.1.3).
ability "value" "i" {
type = Int
initial = 4
}
data "value" "i" {
of = ability.value.i
}
ability "function" "len" {
params = [{ name = "t", type = String }]
returns = Int
body = [ability.return.L]
}
ability "return" "L" {
value = length(t)
}
ability "function" "show" {
params = [{ name = "t", type = String }, { name = "n", type = Int }]
body = [ability.print.S]
}
ability "print" "S" {
message = "${t}/${n}"
}
ability "app" "Gui" {
body = [ability.window.Main, ability.click.Go]
exit_after = 300
}
ability "window" "Main" {
children = [ability.button.Go]
}
ability "button" "Go" {
label = "Go"
on_click = [ability.call.Show]
}
ability "call" "Show" {
function = ability.function.show
args = ["o${len(\"in${data.value.i.current}\")}", len("z${data.value.i.current}")]
}
ability "click" "Go" {
widget = ability.button.Go
}Input, plan and generated C#
structop plan
structop plan
# program.app will be created
+ program.app (.structop/build/app)
+ ability.value.i
+ ability.function.len
+ ability.return.L
+ ability.function.show
+ ability.print.S
+ ability.app.Gui
+ ability.window.Main
+ ability.button.Go
+ ability.call.Show
+ ability.click.Go
Plan: 1 to add, 0 to change, 0 to destroy.Generated main.c
To inspect this generated file, select C in intent.st, initialize the project and export its source.
Export locally
structop init
structop apply -source -no-runGenerated main.rs (the same .st built as Rust)
To inspect this generated file, select Rust in intent.st, initialize the project and export its source.
Export locally
structop init
structop apply -source -no-runTry it
cd gui-text-argument # a folder holding the .st files above
structop init
structop plan
structop apply