From 5a9e940a7d2fdd72a5c6e7cf00595a1bbc4f3f08 Mon Sep 17 00:00:00 2001 From: Emery Hemingway Date: Tue, 2 May 2023 22:07:00 +0100 Subject: [PATCH] Idomatic dataspace passing at boot --- README.md | 21 ++++++++++----------- fontconfig_actor.nimble | 2 +- protocol.prs | 2 +- src/fontconfig_actor.nim | 2 +- src/protocol.nim | 10 +++++----- 5 files changed, 18 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 7f8e524..a2f15b8 100644 --- a/README.md +++ b/README.md @@ -10,22 +10,21 @@ For a list of possibly supported properties see the [Fontconfig documentation](h Example [Syndicate server](https://git.syndicate-lang.org/syndicate-lang/syndicate-rs) configuration: ``` -> +let ?fontspace = dataspace + + -let ?fontspace = dataspace - - -? ?cap> [ - $cap -] - -$fontspace [ - ? [ - $log ! }> +? [ + > + ? ?cap> [ + $cap { dataspace: $fontspace } + $socketspace ? [ + $log ! }> + ] ] ] ``` diff --git a/fontconfig_actor.nimble b/fontconfig_actor.nimble index 7d647ce..7749be5 100644 --- a/fontconfig_actor.nimble +++ b/fontconfig_actor.nimble @@ -1,6 +1,6 @@ # Package -version = "20230329" +version = "20230502" author = "Emery Hemingway" description = "Syndicate actor for asserting Fontconfig information" license = "Unlicense" diff --git a/protocol.prs b/protocol.prs index f90f4d8..f2a470b 100644 --- a/protocol.prs +++ b/protocol.prs @@ -1,4 +1,4 @@ version 1 . -Serve = . +BootArguments = {dataspace: #!any} . Properties = {symbol: any ...:...} . FontAssertion = . diff --git a/src/fontconfig_actor.nim b/src/fontconfig_actor.nim index a89eca9..1b7110f 100644 --- a/src/fontconfig_actor.nim +++ b/src/fontconfig_actor.nim @@ -168,7 +168,7 @@ proc serve(ds: Ref; turn: var Turn) = bootDataspace("main") do (root: Ref; turn: var Turn): connectStdio(root, turn) - during(turn, root, ?Serve) do (ds: Ref): + onPublish(turn, root, ?BootArguments) do (ds: Ref): serve(ds, turn) runForever() diff --git a/src/protocol.nim b/src/protocol.nim index 58ef084..6a8484b 100644 --- a/src/protocol.nim +++ b/src/protocol.nim @@ -3,16 +3,16 @@ import std/typetraits, preserves, std/tables type - Serve* {.preservesRecord: "serve".} = object - `cap`* {.preservesEmbedded.}: Preserve[void] - FontAssertion* {.preservesRecord: "fontconfig".} = object `pattern`*: Properties `attributes`*: Properties + BootArguments* {.preservesDictionary.} = object + `dataspace`* {.preservesEmbedded.}: Preserve[void] + Properties* = Table[Symbol, Preserve[void]] -proc `$`*(x: Serve | FontAssertion | Properties): string = +proc `$`*(x: FontAssertion | BootArguments | Properties): string = `$`(toPreserve(x)) -proc encode*(x: Serve | FontAssertion | Properties): seq[byte] = +proc encode*(x: FontAssertion | BootArguments | Properties): seq[byte] = encode(toPreserve(x))