The package, app id, modules, services, store document, locale keys, assets and data folder are now called Entity. An existing self data folder moves to entity once. The key-file field self_context= and the Daochi sign-in id stay, so existing backups and sessions still work.
47 lines
2.0 KiB
Ziran
47 lines
2.0 KiB
Ziran
#import, file "../src/model.zi";
|
|
#import, file "../src/node_url.zi";
|
|
#import "std/c_string"
|
|
#import "std/text_buffer"
|
|
|
|
#program_export
|
|
main :: () -> s32 {
|
|
decoded: EntityState
|
|
legacy := "{\"version\":1,\"name\":\"\",\"intention\":\"\",\"picture\":0,\"theme\":0,\"accent\":0,\"material\":1,\"controls\":0,\"preferred\":0,\"nodes\":[\"https://example.com\"],\"extensions\":[]}"
|
|
if !EntityDecode(legacy, *decoded) || decoded.host_navigation { return 10 }
|
|
state := EntityDefault()
|
|
if state.host_navigation { return 8 }
|
|
state.host_navigation = true
|
|
unused CopyCString("Waozi \"quoted\" \\ UTF-8: 花", state.name[:])
|
|
unused CopyCString("Breathe slowly", state.intention[:])
|
|
state.picture = 27
|
|
state.theme = 2
|
|
state.node_count = 2
|
|
state.preferred = 1
|
|
unused CopyCString("http://127.0.0.1:8090", state.nodes[1][:])
|
|
EntityAddExtension(*state, "inbe", "Inner Breeze")
|
|
encoded := EntityEncode(state)
|
|
if !EntityDecode(encoded, *decoded) { return 1 }
|
|
if !decoded.host_navigation { return 9 }
|
|
if TextUntilNul(decoded.name[:]) != TextUntilNul(state.name[:]) ||
|
|
TextUntilNul(decoded.intention[:]) != "Breathe slowly" || decoded.picture != 27 ||
|
|
decoded.preferred != 1 || decoded.node_count != 2 ||
|
|
TextUntilNul(decoded.extensions[0].id[:]) != "inbe" { return 2 }
|
|
EntityFree(encoded)
|
|
state.preferred = 2
|
|
invalid := EntityEncode(state)
|
|
if EntityDecode(invalid, *decoded) { return 3 }
|
|
EntityFree(invalid)
|
|
state.preferred = 0
|
|
state.nodes[1] = state.nodes[0]
|
|
duplicate := EntityEncode(state)
|
|
if EntityDecode(duplicate, *decoded) { return 4 }
|
|
EntityFree(duplicate)
|
|
unused CopyCString("https://example.com/path", state.nodes[1][:])
|
|
path := EntityEncode(state)
|
|
if EntityDecode(path, *decoded) { return 5 }
|
|
EntityFree(path)
|
|
if EntityDecode("{\"version\":2}", *decoded) { return 6 }
|
|
if NodeOrigin("http://example.com") != "" || NodeOrigin("https://name:[email protected]") != "" { return 7 }
|
|
return 0
|
|
}
|