init {
screenTemplates := {
"screen1":{
"widgets": {
"btn1": {"type": "button", "text": "hello", "visible": true, "x": 10, "y": 10, "width": 100, "height": 40}
},
"layout": false
}
}
curScreen := "screen1"
input1 := "input1"
input2 := "input2"
input3 := "input3"
}
native channel ScreenUpdate {
in screen(curSc: Json, update(curSc, nextSc)) = nextSc
}
native channel SetLayout {
in screen.layout(curLayout: Bool, setLayout(nextLayout)) = nextLayout
}
native channel SetVisible(wid: Str) {
in screen.widgets.{wid}.visible(curVisible: Bool, setVisible(nextVisible)) = nextVisible
}
native channel SetText(wid: Str) {
in screen.widgets.{wid}.text(curText: Str, setText(nextText)) = nextText
}
native channel SetX(wid: Str) {
in screen.widgets.{wid}.x(curX: Int, setX(nextX)) = nextX
}
native channel SetY(wid: Str) {
in screen.widgets.{wid}.y(curY: Int, setY(nextY)) = nextY
}
native channel SetWidth(wid: Str) {
in screen.widgets.{wid}.width(curWidth: Int, setWidth(nextWidth)) = nextWidth
}
native channel SetHeight(wid: Str) {
in screen.widgets.{wid}.height(curHeight: Int, setHeight(nextHeight)) = nextHeight
}
native channel MouseEvent(wid: Str) {
out screen.widgets.{wid}.state(curState: Int, mouseEvent(nextState)) = nextState
}
native channel TextEvent(wid: Str) {
out screen.widgets.{wid}.text(curText: Str, textEvent(nextText)) = nextText
}
channel ChangeCurScreen {
out curScreen(curScId: Str, changeCurScreen(nextScId)) = nextScId
}
channel ScreenTransition {
in curScreen(curScId: Str, transScreen(nextScId, screen)) = nextScId
ref screenTemplates.{nextScId}(screen, transScreen(nextScId, screen))
out screen(curS, transScreen(nextScId, screen)) = screen
}
channel EventDispatch(wid: Str) {
in screen.widgets.{wid}.state(curState: Int, dispatchEvent(curScId, wid, nextState)) = nextState
ref curScreen(curScId: Str, dispatchEvent(curScId, wid, nextState))
out screenTemplates.{curScId}.widgets.{wid}.state(curState: Int, dispatchEvent(curScId, wid, nextState)) = nextState
}
channel EventDispatch2(wid: Str) {
in screen.widgets.{wid}.text(curText: Str, dispatchEvent2(curScId, wid, nextText)) = nextText
ref curScreen(curScId: Str, dispatchEvent2(curScId, wid, nextText))
out screenTemplates.{curScId}.widgets.{wid}.text(curText: Str, dispatchEvent2(curScId, wid, nextText)) = nextText
}
channel btn1AccountsSetData(scId: Str, wid: Str){
in screenTemplates.{scId="screen1"}.widgets.{wid="btn1"}.state(curState, btn1AccountsSetData(nextState, id, input1, name, input2, age, input3, accountsRef)) = nextState
ref input1(input1, btn1AccountsSetData(nextState, id, input1, name, input2, age, input3, accountsRef))
ref screen.widgets.{input1}.text(id, btn1AccountsSetData(nextState, id, input1, name, input2, age, input3, accountsRef))
ref input2(input2, btn1AccountsSetData(nextState, id, input1, name, input2, age, input3, accountsRef))
ref screen.widgets.{input2}.text(name, btn1AccountsSetData(nextState, id, input1, name, input2, age, input3, accountsRef))
ref input3(input3, btn1AccountsSetData(nextState, id, input1, name, input2, age, input3, accountsRef))
ref screen.widgets.{input3}.text(age, btn1AccountsSetData(nextState, id, input1, name, input2, age, input3, accountsRef))
ref accounts(accountsRef, btn1AccountsSetData(nextState, id, input1, name, input2, age, input3, accountsRef))
out accounts(accounts: Map, btn1AccountsSetData(nextState, id, input1, name, input2, age, input3, accountsRef)) = if((nextState == 0) && (id != "") && (!contains(accountsRef, id)), insert(accounts, id, {"name": name, "age": age}), accounts)
out curScreen(curScreen, btn1AccountsSetData(nextState, id, input1, name, input2, age, input3, accountsRef)) = if((nextState == 0), if((id != "") && (!contains(accountsRef, id)), "screen2", "screen3"), curScreen)
}
channel addAccounts {
out accounts(accounts: Map, addAccounts(id: Str, name: Str, age: Int)) = insert(accounts, id, {"name": name,"age": age})
}
channel changeNameOfAccounts(id: Str) {
out accounts.{id}.name(name: Str, changeNameOfAccounts(newName: Str)) = newName
}
channel changeAgeOfAccounts(id: Str) {
out accounts.{id}.age(age: Int, changeAgeOfAccounts(newAge: Int)) = newAge
}
channel addTweets {
out tweets(tweets: Map, addTweets(tweetId: Int, contents: Str, idOfAccounts: Str)) = insert(tweets, tweetId, {"contents": contents,"idOfAccounts": idOfAccounts})
}
channel changeContentsOfTweets(tweetId: Int) {
out tweets.{tweetId}.contents(contents: Str, changeContentsOfTweets(newContents: Str)) = newContents
}
channel changeIdOfAccountsOfTweets(tweetId: Int) {
out tweets.{tweetId}.idOfAccounts(idOfAccounts: Str, changeIdOfAccountsOfTweets(newIdOfAccounts: Str)) = newIdOfAccounts
}
channel nameOfAccountsOfTweets(tweetId: Int){
in tweets.{tweetId}.idOfAccounts(idOfAccounts: Str, nameOfAccountsOfTweets(newIdOfAccounts: Str, newNameOfAccounts: Str)) = newIdOfAccounts
in accounts.{newIdOfAccounts}.name(name: Str, nameOfAccountsOfTweets(newIdOfAccounts, newNameOfAccounts)) = newNameOfAccounts
out tweets.{tweetId}.nameOfAccounts(nameOfAccounts, nameOfAccountsOfTweets(newIdOfAccounts, newNameOfAccounts)) = newNameOfAccounts
}
channel ageOfAccountsOfTweets(tweetId: Int){
in tweets.{tweetId}.idOfAccounts(idOfAccounts: Str, ageOfAccountsOfTweets(newIdOfAccounts: Str, newAgeOfAccounts: Int)) = newIdOfAccounts
in accounts.{newIdOfAccounts}.age(age: Int, ageOfAccountsOfTweets(newIdOfAccounts, newAgeOfAccounts)) = newAgeOfAccounts
out tweets.{tweetId}.ageOfAccounts(ageOfAccounts, ageOfAccountsOfTweets(newIdOfAccounts, newAgeOfAccounts)) = newAgeOfAccounts
}