Migrate to non-generic Preserves
This commit is contained in:
parent
b5aa2a7b8f
commit
c0cff79313
|
@ -6,7 +6,7 @@
|
|||
import std/[asyncdispatch, macros, tables, typetraits]
|
||||
|
||||
import preserves
|
||||
export fromPreserve, toPreserve
|
||||
export fromPreserves, toPreserves
|
||||
|
||||
import ./syndicate/[actors, dataspaces, durings, patterns]
|
||||
import ./syndicate/protocols/dataspace
|
||||
|
@ -32,7 +32,7 @@ proc `??`*(pat: Pattern; bindings: openArray[(int, Pattern)]): Pattern {.inline.
|
|||
patterns.inject(pat, bindings)
|
||||
|
||||
type
|
||||
Observe* = dataspace.Observe[Cap]
|
||||
Observe* = dataspace.Observe
|
||||
PublishProc = proc (turn: var Turn; v: Assertion; h: Handle) {.closure, gcsafe.}
|
||||
RetractProc = proc (turn: var Turn; h: Handle) {.closure, gcsafe.}
|
||||
MessageProc = proc (turn: var Turn; v: Assertion) {.closure, gcsafe.}
|
||||
|
@ -94,7 +94,7 @@ proc wrapPublishHandler(turn, handler: NimNode): NimNode =
|
|||
quote do:
|
||||
proc `handlerSym`(`turn`: var Turn; `bindingsSym`: Assertion; `handleSym`: Handle) =
|
||||
`varSection`
|
||||
if fromPreserve(`valuesSym`, bindings):
|
||||
if fromPreserves(`valuesSym`, bindings):
|
||||
`publishBody`
|
||||
|
||||
proc wrapMessageHandler(turn, handler: NimNode): NimNode =
|
||||
|
@ -106,7 +106,7 @@ proc wrapMessageHandler(turn, handler: NimNode): NimNode =
|
|||
quote do:
|
||||
proc `handlerSym`(`turn`: var Turn; `bindingsSym`: Assertion) =
|
||||
`varSection`
|
||||
if fromPreserve(`valuesSym`, bindings):
|
||||
if fromPreserves(`valuesSym`, bindings):
|
||||
`body`
|
||||
|
||||
proc wrapDuringHandler(turn, entryBody, exitBody: NimNode): NimNode =
|
||||
|
@ -120,13 +120,13 @@ proc wrapDuringHandler(turn, entryBody, exitBody: NimNode): NimNode =
|
|||
quote do:
|
||||
proc `duringSym`(`turn`: var Turn; `bindingsSym`: Assertion; `handleSym`: Handle): TurnAction =
|
||||
`varSection`
|
||||
if fromPreserve(`valuesSym`, `bindingsSym`):
|
||||
if fromPreserves(`valuesSym`, `bindingsSym`):
|
||||
`publishBody`
|
||||
else:
|
||||
quote do:
|
||||
proc `duringSym`(`turn`: var Turn; `bindingsSym`: Assertion; `handleSym`: Handle): TurnAction =
|
||||
`varSection`
|
||||
if fromPreserve(`valuesSym`, `bindingsSym`):
|
||||
if fromPreserves(`valuesSym`, `bindingsSym`):
|
||||
`publishBody`
|
||||
proc action(`turn`: var Turn) =
|
||||
`exitBody`
|
||||
|
|
|
@ -27,14 +27,14 @@ generateIdType(TurnId)
|
|||
|
||||
type
|
||||
Oid = sturdy.Oid
|
||||
Assertion* = Preserve[Cap]
|
||||
Caveat = sturdy.Caveat[Cap]
|
||||
Assertion* = Value
|
||||
Caveat = sturdy.Caveat
|
||||
Attenuation = seq[Caveat]
|
||||
Rewrite = sturdy.Rewrite[Cap]
|
||||
Rewrite = sturdy.Rewrite
|
||||
|
||||
AssertionRef* = ref object
|
||||
value*: Preserve[Cap]
|
||||
# if the Enity methods take a Preserve[Cap] object then the generated
|
||||
value*: Value
|
||||
# if the Enity methods take a Value object then the generated
|
||||
# C code has "redefinition of struct" problems when orc is enabled
|
||||
|
||||
Entity* = ref object of RootObj
|
||||
|
@ -75,7 +75,7 @@ type
|
|||
facet: Facet
|
||||
queues: Queues # a ref object that can outlive Turn
|
||||
when tracing:
|
||||
desc: TurnDescription[void]
|
||||
desc: TurnDescription
|
||||
|
||||
Facet* = ref FacetObj
|
||||
FacetObj = object
|
||||
|
@ -96,17 +96,17 @@ when tracing:
|
|||
|
||||
proc trace(actor: Actor; act: ActorActivation) =
|
||||
if not actor.traceStream.isNil:
|
||||
var entry = TraceEntry[void](
|
||||
var entry = TraceEntry(
|
||||
timestamp: getTime().toUnixFloat(),
|
||||
actor: initRecord("named", actor.name.toPreserve(void)),
|
||||
actor: initRecord("named", actor.name.toPreserves),
|
||||
item: act)
|
||||
actor.traceStream.writeText entry.toPreserve(void)
|
||||
actor.traceStream.writeText entry.toPreserves
|
||||
actor.traceStream.writeLine()
|
||||
|
||||
proc path(facet: Facet): seq[trace.FacetId[void]] =
|
||||
proc path(facet: Facet): seq[trace.FacetId] =
|
||||
var f = facet
|
||||
while not f.isNil:
|
||||
result.add f.id.toPreserve
|
||||
result.add f.id.toPreserves
|
||||
f = f.parent
|
||||
|
||||
method publish*(e: Entity; turn: var Turn; v: AssertionRef; h: Handle) {.base, gcsafe.} = discard
|
||||
|
@ -164,7 +164,7 @@ proc enqueue(turn: var Turn; target: Facet; action: TurnAction) =
|
|||
else:
|
||||
turn.queues[target] = @[action]
|
||||
|
||||
type Bindings = Table[Preserve[Cap], Preserve[Cap]]
|
||||
type Bindings = Table[Value, Value]
|
||||
|
||||
proc match(bindings: var Bindings; p: Pattern; v: Assertion): bool =
|
||||
case p.orKind
|
||||
|
@ -182,7 +182,7 @@ proc match(bindings: var Bindings; p: Pattern; v: Assertion): bool =
|
|||
result = v.isEmbedded
|
||||
of PatternKind.Pbind:
|
||||
if match(bindings, p.pbind.pattern, v):
|
||||
bindings[toPreserve(p.pbind.pattern, Cap)] = v
|
||||
bindings[p.pbind.pattern.toPreserves] = v
|
||||
result = true
|
||||
of PatternKind.Pand:
|
||||
for pp in p.pand.patterns:
|
||||
|
@ -234,7 +234,7 @@ proc instantiate(t: Template; bindings: Bindings): Assertion =
|
|||
result = embed(attenuate(v.embed, t.tattenuate.attenuation))
|
||||
of TemplateKind.TRef:
|
||||
let n = $t.tref.binding.int
|
||||
try: result = bindings[toPreserve(n, Cap)]
|
||||
try: result = bindings[n.toPreserves]
|
||||
except KeyError:
|
||||
raise newException(ValueError, "unbound reference: " & n)
|
||||
of TemplateKind.Lit:
|
||||
|
@ -246,11 +246,11 @@ proc instantiate(t: Template; bindings: Bindings): Assertion =
|
|||
for i, tt in t.tcompound.rec.fields:
|
||||
result[i] = instantiate(tt, bindings)
|
||||
of TCompoundKind.arr:
|
||||
result = initSequence(t.tcompound.arr.items.len, Cap)
|
||||
result = initSequence(t.tcompound.arr.items.len)
|
||||
for i, tt in t.tcompound.arr.items:
|
||||
result[i] = instantiate(tt, bindings)
|
||||
of TCompoundKind.dict:
|
||||
result = initDictionary(Cap)
|
||||
result = initDictionary()
|
||||
for key, tt in t.tcompound.dict.entries:
|
||||
result[key] = instantiate(tt, bindings)
|
||||
|
||||
|
@ -286,13 +286,13 @@ proc publish(turn: var Turn; r: Cap; v: Assertion; h: Handle) =
|
|||
e.established = true
|
||||
publish(r.target, turn, AssertionRef(value: a), e.handle)
|
||||
when tracing:
|
||||
var act = ActionDescription[void](orKind: ActionDescriptionKind.enqueue)
|
||||
act.enqueue.event.target.actor = turn.facet.actor.id.toPreserve
|
||||
act.enqueue.event.target.facet = turn.facet.id.toPreserve
|
||||
act.enqueue.event.target.oid = r.target.oid.toPreserve
|
||||
act.enqueue.event.detail = trace.TurnEvent[void](orKind: TurnEventKind.assert)
|
||||
var act = ActionDescription(orKind: ActionDescriptionKind.enqueue)
|
||||
act.enqueue.event.target.actor = turn.facet.actor.id.toPreserves
|
||||
act.enqueue.event.target.facet = turn.facet.id.toPreserves
|
||||
act.enqueue.event.target.oid = r.target.oid.toPreserves
|
||||
act.enqueue.event.detail = trace.TurnEvent(orKind: TurnEventKind.assert)
|
||||
act.enqueue.event.detail.assert.assertion.value.value =
|
||||
contract(v) do (r: Cap) -> Preserve[void]:
|
||||
contract(v) do (r: Cap) -> Value:
|
||||
discard
|
||||
act.enqueue.event.detail.assert.handle = h
|
||||
turn.desc.actions.add act
|
||||
|
@ -303,7 +303,7 @@ proc publish*(turn: var Turn; r: Cap; a: Assertion): Handle =
|
|||
publish(turn, r, a, result)
|
||||
|
||||
proc publish*[T](turn: var Turn; r: Cap; a: T): Handle =
|
||||
publish(turn, r, toPreserve(a, Cap))
|
||||
publish(turn, r, a.toPreserves)
|
||||
|
||||
proc retract(turn: var Turn; e: OutboundAssertion) =
|
||||
enqueue(turn, e.peer.relay) do (turn: var Turn):
|
||||
|
@ -323,7 +323,7 @@ proc message*(turn: var Turn; r: Cap; v: Assertion) =
|
|||
r.target.message(turn, AssertionRef(value: a))
|
||||
|
||||
proc message*[T](turn: var Turn; r: Cap; v: T) =
|
||||
message(turn, r, toPreserve(v, Cap))
|
||||
message(turn, r, v.toPreserves)
|
||||
|
||||
proc sync(turn: var Turn; e: Entity; peer: Cap) =
|
||||
e.sync(turn, peer)
|
||||
|
@ -405,7 +405,7 @@ proc terminate(facet; turn: var Turn; orderly: bool) {.gcsafe.} =
|
|||
else:
|
||||
terminate(facet.actor, turn, nil)
|
||||
when tracing:
|
||||
var act = ActionDescription[void](orKind: ActionDescriptionKind.facetStop)
|
||||
var act = ActionDescription(orKind: ActionDescriptionKind.facetStop)
|
||||
act.facetstop.path = facet.path
|
||||
turn.desc.actions.add act
|
||||
|
||||
|
@ -424,7 +424,7 @@ proc newFacet*(turn: var Turn): Facet = newFacet(turn.facet.actor, turn.facet)
|
|||
proc inFacet*(turn: var Turn; bootProc: TurnAction): Facet =
|
||||
result = newFacet(turn)
|
||||
when tracing:
|
||||
var act = ActionDescription[void](orKind: ActionDescriptionKind.facetstart)
|
||||
var act = ActionDescription(orKind: ActionDescriptionKind.facetstart)
|
||||
act.facetstart.path.add result.path
|
||||
turn.desc.actions.add act
|
||||
inFacet(turn, result, stopIfInertAfter(bootProc))
|
||||
|
@ -442,9 +442,9 @@ proc newActor(name: string; handleAlloc: ref Handle): Actor =
|
|||
)
|
||||
result.root = newFacet(result, nil)
|
||||
when tracing:
|
||||
var act = ActorActivation[void](orKind: ActorActivationKind.start)
|
||||
act.start.actorName = Name[void](orKind: NameKind.named)
|
||||
act.start.actorName.named.name = name.toPreserve(void)
|
||||
var act = ActorActivation(orKind: ActorActivationKind.start)
|
||||
act.start.actorName = Name(orKind: NameKind.named)
|
||||
act.start.actorName.named.name = name.toPreserves
|
||||
trace(result, act)
|
||||
|
||||
proc run(actor; bootProc: TurnAction; initialAssertions: OutboundTable) =
|
||||
|
@ -471,8 +471,8 @@ proc spawn*(name: string; turn: var Turn; bootProc: TurnAction; initialAssertion
|
|||
when tracing:
|
||||
actor.turnIdAllocator = turn.facet.actor.turnIdAllocator
|
||||
actor.traceStream = turn.facet.actor.traceStream
|
||||
var act = ActionDescription[void](orKind: ActionDescriptionKind.spawn)
|
||||
act.spawn.id = actor.id.toPreserve
|
||||
var act = ActionDescription(orKind: ActionDescriptionKind.spawn)
|
||||
act.spawn.id = actor.id.toPreserves
|
||||
turn.desc.actions.add act
|
||||
run(actor, bootProc, newOutBound)
|
||||
actor
|
||||
|
@ -488,7 +488,7 @@ proc terminate(actor; turn; reason: ref Exception) =
|
|||
actor.exiting = true
|
||||
actor.exitReason = reason
|
||||
when tracing:
|
||||
var act = ActorActivation[void](orKind: ActorActivationKind.stop)
|
||||
var act = ActorActivation(orKind: ActorActivationKind.stop)
|
||||
if not reason.isNil:
|
||||
act.stop.status = ExitStatus(orKind: ExitStatusKind.Error)
|
||||
act.stop.status.error.message = reason.msg
|
||||
|
@ -525,8 +525,8 @@ proc run*(facet; action: TurnAction; zombieTurn = false) =
|
|||
var turn = Turn(facet: facet, queues: queues)
|
||||
action(turn)
|
||||
when tracing:
|
||||
turn.desc.id = facet.nextTurnId.toPreserve
|
||||
facet.actor.trace ActorActivation[void](
|
||||
turn.desc.id = facet.nextTurnId.toPreserves
|
||||
facet.actor.trace ActorActivation(
|
||||
orKind: ActorActivationKind.turn, turn: turn.desc)
|
||||
for facet, queue in queues:
|
||||
for action in queue: run(facet, action)
|
||||
|
@ -543,8 +543,8 @@ proc addCallback*(fut: FutureBase; facet: Facet; act: TurnAction) =
|
|||
else:
|
||||
when tracing:
|
||||
run(facet) do (turn: var Turn):
|
||||
turn.desc.cause = TurnCause[void](orKind: TurnCauseKind.external)
|
||||
turn.desc.cause.external.description = "Future".toPreserve
|
||||
turn.desc.cause = TurnCause(orKind: TurnCauseKind.external)
|
||||
turn.desc.cause.external.description = "Future".toPreserves
|
||||
act(turn)
|
||||
else:
|
||||
run(facet, act)
|
||||
|
@ -564,8 +564,8 @@ proc addCallback*[T](fut: Future[T]; turn: var Turn; act: proc (t: var Turn, x:
|
|||
if fut.failed: terminate(turn.facet, fut.error)
|
||||
else:
|
||||
when tracing:
|
||||
turn.desc.cause = TurnCause[void](orKind: TurnCauseKind.external)
|
||||
turn.desc.cause.external.description = "Future".toPreserve
|
||||
turn.desc.cause = TurnCause(orKind: TurnCauseKind.external)
|
||||
turn.desc.cause.external.description = "Future".toPreserves
|
||||
act(turn, read fut)
|
||||
|
||||
proc stop*(turn: var Turn, facet: Facet) =
|
||||
|
|
|
@ -10,7 +10,7 @@ from syndicate/protocols/dataspace import Observe
|
|||
|
||||
export timer
|
||||
|
||||
type Observe = dataspace.Observe[Cap]
|
||||
type Observe = dataspace.Observe
|
||||
|
||||
proc now: float64 = getTime().toUnixFloat()
|
||||
|
||||
|
|
|
@ -19,16 +19,16 @@ export `$`
|
|||
proc hmac(key, data: openarray[byte]): seq[byte] =
|
||||
count[Hmac[BLAKE2S_256]](key, data).data[0..15].toSeq
|
||||
|
||||
proc mint*[T](key: openarray[byte]; oid: Preserve[T]): SturdyRef[T] =
|
||||
proc mint*(key: openarray[byte]; oid: Value): SturdyRef =
|
||||
SturdyRef[T](parameters: {
|
||||
"oid": oid,
|
||||
"sig": hmac(key, encode(oid)).toPreserve(T),
|
||||
"sig": hmac(key, encode(oid)).toPreserves(T),
|
||||
}.toDictionary,
|
||||
)
|
||||
|
||||
proc mint*(): SturdyRef[Cap] =
|
||||
proc mint*(): SturdyRef =
|
||||
var key: array[16, byte]
|
||||
mint(key, toPreserve("syndicate", Cap))
|
||||
mint(key, "syndicate".toPreserves)
|
||||
|
||||
proc attenuate*[T](r: SturdyRef[T]; caveats: seq[Caveat]): SturdyRef[T] =
|
||||
result = SturdyRef[T](
|
||||
|
|
|
@ -8,8 +8,8 @@ import ./actors, ./protocols/dataspace, ./skeletons
|
|||
from ./protocols/protocol import Handle
|
||||
|
||||
type
|
||||
Assertion = Preserve[Cap]
|
||||
Observe = dataspace.Observe[Cap]
|
||||
Assertion = Value
|
||||
Observe = dataspace.Observe
|
||||
Turn = actors.Turn
|
||||
|
||||
Dataspace {.final.} = ref object of Entity
|
||||
|
@ -19,7 +19,7 @@ type
|
|||
method publish(ds: Dataspace; turn: var Turn; a: AssertionRef; h: Handle) {.gcsafe.} =
|
||||
if add(ds.index, turn, a.value):
|
||||
var obs: Observe
|
||||
if obs.fromPreserve a.value:
|
||||
if obs.fromPreserves(a.value):
|
||||
ds.index.add(turn, obs.pattern, obs.observer)
|
||||
ds.handleMap[h] = a.value
|
||||
|
||||
|
@ -28,7 +28,7 @@ method retract(ds: Dataspace; turn: var Turn; h: Handle) {.gcsafe.} =
|
|||
if remove(ds.index, turn, v):
|
||||
ds.handleMap.del h
|
||||
var obs: Observe
|
||||
if obs.fromPreserve v:
|
||||
if obs.fromPreserves v:
|
||||
ds.index.remove(turn, obs.pattern, obs.observer)
|
||||
|
||||
method message(ds: Dataspace; turn: var Turn; a: AssertionRef) {.gcsafe.} =
|
||||
|
|
|
@ -8,7 +8,7 @@ import ./actors, ./patterns, ./protocols/dataspace
|
|||
from ./protocols/protocol import Handle
|
||||
|
||||
type
|
||||
Observe = dataspace.Observe[Cap]
|
||||
Observe = dataspace.Observe
|
||||
Turn = actors.Turn
|
||||
|
||||
type
|
||||
|
|
|
@ -10,15 +10,14 @@ from ./actors import Cap
|
|||
export dataspacePatterns.`$`, PatternKind, DCompoundKind, AnyAtomKind
|
||||
|
||||
type
|
||||
Value = Preserve[Cap]
|
||||
AnyAtom = dataspacePatterns.AnyAtom[Cap]
|
||||
DBind = dataspacePatterns.DBind[Cap]
|
||||
DCompound = dataspacePatterns.DCompound[Cap]
|
||||
DCompoundArr = dataspacePatterns.DCompoundArr[Cap]
|
||||
DCompoundDict = dataspacePatterns.DCompoundDict[Cap]
|
||||
DCompoundRec = dataspacePatterns.DCompoundRec[Cap]
|
||||
DLit = dataspacePatterns.DLit[Cap]
|
||||
Pattern* = dataspacePatterns.Pattern[Cap]
|
||||
AnyAtom = dataspacePatterns.AnyAtom
|
||||
DBind = dataspacePatterns.DBind
|
||||
DCompound = dataspacePatterns.DCompound
|
||||
DCompoundArr = dataspacePatterns.DCompoundArr
|
||||
DCompoundDict = dataspacePatterns.DCompoundDict
|
||||
DCompoundRec = dataspacePatterns.DCompoundRec
|
||||
DLit = dataspacePatterns.DLit
|
||||
Pattern* = dataspacePatterns.Pattern
|
||||
|
||||
iterator orderedEntries*(dict: DCompoundDict): (Value, Pattern) =
|
||||
## Iterate a `DCompoundDict` in Preserves order.
|
||||
|
@ -58,7 +57,7 @@ proc drop*(): Pattern {.inline.} = Pattern(orKind: PatternKind.DDiscard)
|
|||
proc grab*(): Pattern {.inline.} = DBind(pattern: drop()).toPattern
|
||||
## Create a pattern to capture any value.
|
||||
|
||||
proc grab*[T](pr: Preserve[T]): Pattern =
|
||||
proc grab*[T](pr: Value): Pattern =
|
||||
## Convert a `Preserve` value to a `Pattern`.
|
||||
runnableExamples:
|
||||
from std/unittest import check
|
||||
|
@ -88,15 +87,15 @@ proc grab*[T](pr: Preserve[T]): Pattern =
|
|||
drop()
|
||||
else:
|
||||
DCompoundRec(
|
||||
label: cast[Preserve[Cap]](pr.label), # TODO: don't cast like this
|
||||
fields: map[Preserve[T], Pattern](pr.fields, grab)).toPattern
|
||||
label: pr.label,
|
||||
fields: map[Value, Pattern](pr.fields, grab)).toPattern
|
||||
of pkSequence:
|
||||
DCompoundArr(items: map(pr.sequence, grab)).toPattern
|
||||
of pkSet:
|
||||
raiseAssert "cannot construct a pattern over a set literal"
|
||||
of pkDictionary:
|
||||
var dict = DCompoundDict()
|
||||
for key, val in pr.pairs: dict.entries[cast[Preserve[Cap]](key)] = grab val
|
||||
for key, val in pr.pairs: dict.entries[key] = grab val
|
||||
dict.toPattern
|
||||
of pkEmbedded:
|
||||
# TODO: can patterns be constructed over embedded literals?
|
||||
|
@ -112,20 +111,20 @@ proc grab*[T](val: T): Pattern =
|
|||
$grab(true) == "<lit #t>"
|
||||
$grab(3.14) == "<lit 3.14>"
|
||||
$grab([0, 1, 2, 3]) == "<arr [<lit 0> <lit 1> <lit 2> <lit 3>]>"
|
||||
grab (toPreserve(val, Cap))
|
||||
grab(val)
|
||||
|
||||
proc patternOfType(typ: static typedesc; `bind`: static bool): Pattern =
|
||||
when typ is ref:
|
||||
patternOfType(pointerBase(typ), `bind`)
|
||||
elif typ.hasPreservesRecordPragma:
|
||||
var rec = DCompoundRec(label: typ.recordLabel.tosymbol(Cap))
|
||||
var rec = DCompoundRec(label: typ.recordLabel.toSymbol)
|
||||
for _, f in fieldPairs(default typ):
|
||||
add(rec.fields, patternOfType(typeof f, `bind`))
|
||||
result = rec.toPattern
|
||||
elif typ.hasPreservesDictionaryPragma:
|
||||
var dict = DCompoundDict()
|
||||
for key, val in fieldPairs(default typ):
|
||||
dict.entries[toSymbol(key, Cap)] = patternOfType(typeof val, `bind`)
|
||||
dict.entries[key.toSymbol] = patternOfType(typeof val, `bind`)
|
||||
dict.toPattern
|
||||
elif typ is tuple:
|
||||
var arr = DCompoundArr()
|
||||
|
@ -182,7 +181,7 @@ proc grab*(typ: static typedesc; bindings: sink openArray[(int, Pattern)]): Patt
|
|||
when typ is ptr | ref:
|
||||
grab(pointerBase(typ), bindings)
|
||||
elif typ.hasPreservesRecordPragma:
|
||||
var rec = DCompoundRec(label: typ.recordLabel.tosymbol(Cap))
|
||||
var rec = DCompoundRec(label: typ.recordLabel.toSymbol)
|
||||
rec.fields.setLen(fieldCount typ)
|
||||
var i: int
|
||||
for _, f in fieldPairs(default typ):
|
||||
|
@ -205,14 +204,14 @@ proc grabLit*(): Pattern =
|
|||
from std/unittest import check
|
||||
check:
|
||||
$grabLit() == """<rec lit [<bind <_>>]>"""
|
||||
grabType(dataspacePatterns.DLit[void])
|
||||
grabType(dataspacePatterns.DLit)
|
||||
|
||||
proc grabDict*(): Pattern =
|
||||
grabType(dataspacePatterns.DCompoundDict[void])
|
||||
grabType(dataspacePatterns.DCompoundDict)
|
||||
|
||||
proc unpackLiterals*[E](pr: Preserve[E]): Preserve[E] =
|
||||
proc unpackLiterals*(pr: Value): Value =
|
||||
result = pr
|
||||
apply(result) do (pr: var Preserve[E]):
|
||||
apply(result) do (pr: var Value):
|
||||
if pr.isRecord("lit", 1) or pr.isRecord("dict", 1) or pr.isRecord("arr", 1) or pr.isRecord("set", 1):
|
||||
pr = pr.record[0]
|
||||
|
||||
|
@ -258,7 +257,7 @@ proc inject*(pat: Pattern; bindings: openArray[(int, Pattern)]): Pattern =
|
|||
var offset = 0
|
||||
inject(pat, bindings, offset)
|
||||
|
||||
proc inject*(pat: Pattern; bindings: openArray[(Preserve[Cap], Pattern)]): Pattern =
|
||||
proc inject*(pat: Pattern; bindings: openArray[(Value, Pattern)]): Pattern =
|
||||
## Inject `bindings` into a dictionary pattern.
|
||||
assert pat.orKind == PatternKind.DCompound
|
||||
assert pat.dcompound.orKind == DCompoundKind.dict
|
||||
|
@ -266,19 +265,19 @@ proc inject*(pat: Pattern; bindings: openArray[(Preserve[Cap], Pattern)]): Patte
|
|||
for (key, val) in bindings:
|
||||
result.dcompound.dict.entries[key] = val
|
||||
|
||||
proc grabRecord*(label: Preserve[Cap], fields: varargs[Pattern]): Pattern =
|
||||
proc grabRecord*(label: Value, fields: varargs[Pattern]): Pattern =
|
||||
runnableExamples:
|
||||
from std/unittest import check
|
||||
import syndicate/actors, preserves
|
||||
check:
|
||||
$grabRecord("Says".toSymbol(Cap), grab(), grab()) ==
|
||||
$grabRecord("Says".toSymbol, grab(), grab()) ==
|
||||
"""<rec Says [<bind <_>> <bind <_>>]>"""
|
||||
DCompoundRec(label: label, fields: fields.toSeq).toPattern
|
||||
|
||||
proc grabRecord*(label: string, fields: varargs[Pattern]): Pattern =
|
||||
## Sugar for creating record patterns.
|
||||
## `label` is converted to a symbol value.
|
||||
grabRecord(label.toSymbol(Cap), fields)
|
||||
grabRecord(label.toSymbol, fields)
|
||||
|
||||
proc grabDictionary*(bindings: sink openArray[(Value, Pattern)]): Pattern =
|
||||
## Construct a pattern that grabs some dictionary pairs.
|
||||
|
@ -289,7 +288,7 @@ proc grabDictionary*(bindings: sink openArray[(string, Pattern)]): Pattern =
|
|||
## Keys are converted from strings to symbols.
|
||||
result = DCompoundDict().toPattern
|
||||
for (key, val) in bindings.items:
|
||||
result.dcompound.dict.entries[key.toSymbol(Cap)] = val
|
||||
result.dcompound.dict.entries[key.toSymbol] = val
|
||||
|
||||
proc depattern(comp: DCompound; values: var seq[Value]; index: var int): Value {.gcsafe.}
|
||||
|
||||
|
@ -302,7 +301,7 @@ proc depattern(pat: Pattern; values: var seq[Value]; index: var int): Value =
|
|||
result = move values[index]
|
||||
inc index
|
||||
of PatternKind.DLit:
|
||||
result = pat.dlit.value.toPreserve(Cap)
|
||||
result = pat.dlit.value.toPreserves
|
||||
of PatternKind.DCompound:
|
||||
result = depattern(pat.dcompound, values, index)
|
||||
|
||||
|
@ -313,7 +312,7 @@ proc depattern(comp: DCompound; values: var seq[Value]; index: var int): Value {
|
|||
for i, f in comp.rec.fields:
|
||||
result[i] = depattern(f, values, index)
|
||||
of DCompoundKind.arr:
|
||||
result = initSequence(comp.arr.items.len, Cap)
|
||||
result = initSequence(comp.arr.items.len)
|
||||
for i, e in comp.arr.items:
|
||||
result[i] = depattern(e, values, index)
|
||||
of DCompoundKind.dict:
|
||||
|
@ -330,12 +329,12 @@ type Literal*[T] = object
|
|||
## A wrapper type to deserialize patterns to native values.
|
||||
value*: T
|
||||
|
||||
proc fromPreserveHook*[T, E](lit: var Literal[T]; pr: Preserve[E]): bool =
|
||||
proc fromPreservesHook*[T](lit: var Literal[T]; pr: Value): bool =
|
||||
var pat: Pattern
|
||||
pat.fromPreserve(pr) and lit.value.fromPreserve(depattern(pat, @[]))
|
||||
pat.fromPreserves(pr) and lit.value.fromPreserves(depattern(pat, @[]))
|
||||
|
||||
proc toPreserveHook*[T](lit: Literal[T]; E: typedesc): Preserve[E] =
|
||||
lit.value.grab.toPreserve(E)
|
||||
proc toPreservesHook*[T](lit: Literal[T]): Value =
|
||||
lit.value.grab.toPreserves
|
||||
|
||||
type
|
||||
Path* = seq[Value]
|
||||
|
@ -349,7 +348,7 @@ type
|
|||
func walk(result: var Analysis; path: var Path; p: Pattern)
|
||||
|
||||
func walk(result: var Analysis; path: var Path; key: int|Value; pat: Pattern) =
|
||||
path.add(key.toPreserve(Cap))
|
||||
path.add(key.toPreserves)
|
||||
walk(result, path, pat)
|
||||
discard path.pop
|
||||
|
||||
|
@ -369,7 +368,7 @@ func walk(result: var Analysis; path: var Path; p: Pattern) =
|
|||
of PatternKind.DDiscard: discard
|
||||
of PatternKind.DLit:
|
||||
result.constPaths.add(path)
|
||||
result.constValues.add(p.dlit.value.toPreserve(Cap))
|
||||
result.constValues.add(p.dlit.value.toPreserves)
|
||||
|
||||
func analyse*(p: Pattern): Analysis =
|
||||
var path: Path
|
||||
|
|
|
@ -3,12 +3,12 @@ import
|
|||
preserves, dataspacePatterns
|
||||
|
||||
type
|
||||
Observe*[Cap] {.acyclic, preservesRecord: "Observe".} = ref object
|
||||
`pattern`*: dataspacePatterns.Pattern[Cap]
|
||||
`observer`*: Cap
|
||||
Observe* {.preservesRecord: "Observe".} = object
|
||||
`pattern`*: dataspacePatterns.Pattern
|
||||
`observer`*: Value
|
||||
|
||||
proc `$`*[Cap](x: Observe[Cap]): string =
|
||||
`$`(toPreserve(x, Cap))
|
||||
proc `$`*(x: Observe): string =
|
||||
`$`(toPreserves(x))
|
||||
|
||||
proc encode*[Cap](x: Observe[Cap]): seq[byte] =
|
||||
encode(toPreserve(x, Cap))
|
||||
proc encode*(x: Observe): seq[byte] =
|
||||
encode(toPreserves(x))
|
||||
|
|
|
@ -12,8 +12,8 @@ type
|
|||
AnyAtomString* = string
|
||||
AnyAtomBytes* = seq[byte]
|
||||
AnyAtomSymbol* = Symbol
|
||||
AnyAtomEmbedded*[Cap] = Cap
|
||||
`AnyAtom`*[Cap] {.preservesOr.} = object
|
||||
AnyAtomEmbedded* = Value
|
||||
`AnyAtom`* {.preservesOr.} = object
|
||||
case orKind*: AnyAtomKind
|
||||
of AnyAtomKind.`bool`:
|
||||
`bool`*: AnyAtomBool
|
||||
|
@ -37,68 +37,61 @@ type
|
|||
`symbol`*: AnyAtomSymbol
|
||||
|
||||
of AnyAtomKind.`embedded`:
|
||||
`embedded`*: AnyAtomEmbedded[Cap]
|
||||
`embedded`*: AnyAtomEmbedded
|
||||
|
||||
|
||||
DLit*[Cap] {.preservesRecord: "lit".} = object
|
||||
`value`*: AnyAtom[Cap]
|
||||
DLit* {.preservesRecord: "lit".} = object
|
||||
`value`*: AnyAtom
|
||||
|
||||
DBind*[Cap] {.acyclic, preservesRecord: "bind".} = ref object
|
||||
`pattern`*: Pattern[Cap]
|
||||
DBind* {.preservesRecord: "bind".} = object
|
||||
`pattern`*: Pattern
|
||||
|
||||
DDiscard* {.preservesRecord: "_".} = object
|
||||
|
||||
DCompoundKind* {.pure.} = enum
|
||||
`rec`, `arr`, `dict`
|
||||
DCompoundRec*[Cap] {.acyclic, preservesRecord: "rec".} = ref object
|
||||
`label`*: Preserve[Cap]
|
||||
`fields`*: seq[Pattern[Cap]]
|
||||
DCompoundRec* {.preservesRecord: "rec".} = object
|
||||
`label`*: Value
|
||||
`fields`*: seq[Pattern]
|
||||
|
||||
DCompoundArr*[Cap] {.acyclic, preservesRecord: "arr".} = ref object
|
||||
`items`*: seq[Pattern[Cap]]
|
||||
DCompoundArr* {.preservesRecord: "arr".} = object
|
||||
`items`*: seq[Pattern]
|
||||
|
||||
DCompoundDict*[Cap] {.acyclic, preservesRecord: "dict".} = ref object
|
||||
`entries`*: Table[Preserve[Cap], Pattern[Cap]]
|
||||
DCompoundDict* {.preservesRecord: "dict".} = object
|
||||
`entries`*: Table[Value, Pattern]
|
||||
|
||||
`DCompound`*[Cap] {.acyclic, preservesOr.} = ref object
|
||||
`DCompound`* {.preservesOr.} = object
|
||||
case orKind*: DCompoundKind
|
||||
of DCompoundKind.`rec`:
|
||||
`rec`*: DCompoundRec[Cap]
|
||||
`rec`*: DCompoundRec
|
||||
|
||||
of DCompoundKind.`arr`:
|
||||
`arr`*: DCompoundArr[Cap]
|
||||
`arr`*: DCompoundArr
|
||||
|
||||
of DCompoundKind.`dict`:
|
||||
`dict`*: DCompoundDict[Cap]
|
||||
`dict`*: DCompoundDict
|
||||
|
||||
|
||||
PatternKind* {.pure.} = enum
|
||||
`DDiscard`, `DBind`, `DLit`, `DCompound`
|
||||
`Pattern`*[Cap] {.acyclic, preservesOr.} = ref object
|
||||
`Pattern`* {.acyclic, preservesOr.} = ref object
|
||||
case orKind*: PatternKind
|
||||
of PatternKind.`DDiscard`:
|
||||
`ddiscard`*: DDiscard
|
||||
|
||||
of PatternKind.`DBind`:
|
||||
`dbind`*: DBind[Cap]
|
||||
`dbind`*: DBind
|
||||
|
||||
of PatternKind.`DLit`:
|
||||
`dlit`*: DLit[Cap]
|
||||
`dlit`*: DLit
|
||||
|
||||
of PatternKind.`DCompound`:
|
||||
`dcompound`*: DCompound[Cap]
|
||||
`dcompound`*: DCompound
|
||||
|
||||
|
||||
proc `$`*[Cap](x: AnyAtom[Cap] | DLit[Cap] | DBind[Cap] | DCompound[Cap] |
|
||||
Pattern[Cap]): string =
|
||||
`$`(toPreserve(x, Cap))
|
||||
proc `$`*(x: AnyAtom | DLit | DBind | DDiscard | DCompound | Pattern): string =
|
||||
`$`(toPreserves(x))
|
||||
|
||||
proc encode*[Cap](x: AnyAtom[Cap] | DLit[Cap] | DBind[Cap] | DCompound[Cap] |
|
||||
Pattern[Cap]): seq[byte] =
|
||||
encode(toPreserve(x, Cap))
|
||||
|
||||
proc `$`*(x: DDiscard): string =
|
||||
`$`(toPreserve(x))
|
||||
|
||||
proc encode*(x: DDiscard): seq[byte] =
|
||||
encode(toPreserve(x))
|
||||
proc encode*(x: AnyAtom | DLit | DBind | DDiscard | DCompound | Pattern): seq[
|
||||
byte] =
|
||||
encode(toPreserves(x))
|
||||
|
|
|
@ -3,106 +3,102 @@ import
|
|||
preserves
|
||||
|
||||
type
|
||||
Bind*[Cap] {.preservesRecord: "bind".} = object
|
||||
`description`*: Description[Cap]
|
||||
`target`*: Cap
|
||||
`observer`*: BindObserver[Cap]
|
||||
Bind* {.preservesRecord: "bind".} = object
|
||||
`description`*: Description
|
||||
`target`*: Value
|
||||
`observer`*: BindObserver
|
||||
|
||||
Route*[Cap] {.preservesRecord: "route".} = object
|
||||
`transports`*: seq[Preserve[Cap]]
|
||||
`pathSteps`* {.preservesTupleTail.}: seq[PathStep[Cap]]
|
||||
Route* {.preservesRecord: "route".} = object
|
||||
`transports`*: seq[Value]
|
||||
`pathSteps`* {.preservesTupleTail.}: seq[PathStep]
|
||||
|
||||
BindObserverKind* {.pure.} = enum
|
||||
`present`, `absent`
|
||||
BindObserverPresent*[Cap] = Cap
|
||||
`BindObserver`*[Cap] {.preservesOr.} = object
|
||||
BindObserverPresent* = Bound
|
||||
`BindObserver`* {.preservesOr.} = object
|
||||
case orKind*: BindObserverKind
|
||||
of BindObserverKind.`present`:
|
||||
`present`*: BindObserverPresent[Cap]
|
||||
`present`*: BindObserverPresent
|
||||
|
||||
of BindObserverKind.`absent`:
|
||||
`absent`* {.preservesLiteral: "#f".}: bool
|
||||
|
||||
|
||||
TransportConnection*[Cap] {.preservesRecord: "connect-transport".} = object
|
||||
`addr`*: Preserve[Cap]
|
||||
`control`*: Cap
|
||||
`resolved`*: Resolved[Cap]
|
||||
TransportConnection* {.preservesRecord: "connect-transport".} = object
|
||||
`addr`*: Value
|
||||
`control`*: TransportControl
|
||||
`resolved`*: Resolved
|
||||
|
||||
Step*[Cap] = Preserve[Cap]
|
||||
ResolvedPathStep*[Cap] {.preservesRecord: "path-step".} = object
|
||||
`origin`*: Cap
|
||||
`pathStep`*: PathStep[Cap]
|
||||
`resolved`*: Resolved[Cap]
|
||||
Step* = Value
|
||||
ResolvedPathStep* {.preservesRecord: "path-step".} = object
|
||||
`origin`*: Resolve
|
||||
`pathStep`*: PathStep
|
||||
`resolved`*: Resolved
|
||||
|
||||
BoundKind* {.pure.} = enum
|
||||
`bound`, `Rejected`
|
||||
BoundBound*[Cap] {.preservesRecord: "bound".} = object
|
||||
`pathStep`*: PathStep[Cap]
|
||||
BoundBound* {.preservesRecord: "bound".} = object
|
||||
`pathStep`*: PathStep
|
||||
|
||||
`Bound`*[Cap] {.preservesOr.} = object
|
||||
`Bound`* {.preservesOr.} = object
|
||||
case orKind*: BoundKind
|
||||
of BoundKind.`bound`:
|
||||
`bound`*: BoundBound[Cap]
|
||||
`bound`*: BoundBound
|
||||
|
||||
of BoundKind.`Rejected`:
|
||||
`rejected`*: Rejected[Cap]
|
||||
`rejected`*: Rejected
|
||||
|
||||
|
||||
ForceDisconnect* {.preservesRecord: "force-disconnect".} = object
|
||||
|
||||
Description*[Cap] = Preserve[Cap]
|
||||
Rejected*[Cap] {.preservesRecord: "rejected".} = object
|
||||
`detail`*: Preserve[Cap]
|
||||
Description* = Value
|
||||
Rejected* {.preservesRecord: "rejected".} = object
|
||||
`detail`*: Value
|
||||
|
||||
Resolve*[Cap] {.preservesRecord: "resolve".} = object
|
||||
`step`*: Step[Cap]
|
||||
`observer`*: Cap
|
||||
Resolve* {.preservesRecord: "resolve".} = object
|
||||
`step`*: Step
|
||||
`observer`*: Resolved
|
||||
|
||||
ResolvedKind* {.pure.} = enum
|
||||
`accepted`, `Rejected`
|
||||
ResolvedAccepted*[Cap] {.preservesRecord: "accepted".} = object
|
||||
`responderSession`*: Cap
|
||||
ResolvedAccepted* {.preservesRecord: "accepted".} = object
|
||||
`responderSession`*: Value
|
||||
|
||||
`Resolved`*[Cap] {.preservesOr.} = object
|
||||
`Resolved`* {.preservesOr.} = object
|
||||
case orKind*: ResolvedKind
|
||||
of ResolvedKind.`accepted`:
|
||||
`accepted`*: ResolvedAccepted[Cap]
|
||||
`accepted`*: ResolvedAccepted
|
||||
|
||||
of ResolvedKind.`Rejected`:
|
||||
`rejected`*: Rejected[Cap]
|
||||
`rejected`*: Rejected
|
||||
|
||||
|
||||
TransportControl* = ForceDisconnect
|
||||
ResolvePath*[Cap] {.preservesRecord: "resolve-path".} = object
|
||||
`route`*: Route[Cap]
|
||||
`addr`*: Preserve[Cap]
|
||||
`control`*: Cap
|
||||
`resolved`*: Resolved[Cap]
|
||||
ResolvePath* {.preservesRecord: "resolve-path".} = object
|
||||
`route`*: Route
|
||||
`addr`*: Value
|
||||
`control`*: TransportControl
|
||||
`resolved`*: Resolved
|
||||
|
||||
PathStep*[Cap] = Preserve[Cap]
|
||||
proc `$`*[Cap](x: Bind[Cap] | Route[Cap] | BindObserver[Cap] |
|
||||
TransportConnection[Cap] |
|
||||
ResolvedPathStep[Cap] |
|
||||
Bound[Cap] |
|
||||
Rejected[Cap] |
|
||||
Resolve[Cap] |
|
||||
Resolved[Cap] |
|
||||
ResolvePath[Cap]): string =
|
||||
`$`(toPreserve(x, Cap))
|
||||
PathStep* = Value
|
||||
proc `$`*(x: Bind | Route | BindObserver | TransportConnection |
|
||||
ResolvedPathStep |
|
||||
Bound |
|
||||
ForceDisconnect |
|
||||
Rejected |
|
||||
Resolve |
|
||||
Resolved |
|
||||
TransportControl |
|
||||
ResolvePath): string =
|
||||
`$`(toPreserves(x))
|
||||
|
||||
proc encode*[Cap](x: Bind[Cap] | Route[Cap] | BindObserver[Cap] |
|
||||
TransportConnection[Cap] |
|
||||
ResolvedPathStep[Cap] |
|
||||
Bound[Cap] |
|
||||
Rejected[Cap] |
|
||||
Resolve[Cap] |
|
||||
Resolved[Cap] |
|
||||
ResolvePath[Cap]): seq[byte] =
|
||||
encode(toPreserve(x, Cap))
|
||||
|
||||
proc `$`*(x: ForceDisconnect | TransportControl): string =
|
||||
`$`(toPreserve(x))
|
||||
|
||||
proc encode*(x: ForceDisconnect | TransportControl): seq[byte] =
|
||||
encode(toPreserve(x))
|
||||
proc encode*(x: Bind | Route | BindObserver | TransportConnection |
|
||||
ResolvedPathStep |
|
||||
Bound |
|
||||
ForceDisconnect |
|
||||
Rejected |
|
||||
Resolve |
|
||||
Resolved |
|
||||
TransportControl |
|
||||
ResolvePath): seq[byte] =
|
||||
encode(toPreserves(x))
|
||||
|
|
|
@ -0,0 +1,176 @@
|
|||
|
||||
import
|
||||
preserves, std/tables
|
||||
|
||||
type
|
||||
HostPatternKind* {.pure.} = enum
|
||||
`host`, `any`
|
||||
HostPatternHost* = string
|
||||
`HostPattern`* {.preservesOr.} = object
|
||||
case orKind*: HostPatternKind
|
||||
of HostPatternKind.`host`:
|
||||
`host`*: HostPatternHost
|
||||
|
||||
of HostPatternKind.`any`:
|
||||
`any`* {.preservesLiteral: "#f".}: bool
|
||||
|
||||
|
||||
HttpListener* {.preservesRecord: "http-listener".} = object
|
||||
`port`*: BiggestInt
|
||||
|
||||
MethodPatternKind* {.pure.} = enum
|
||||
`any`, `specific`
|
||||
MethodPatternSpecific* = Symbol
|
||||
`MethodPattern`* {.preservesOr.} = object
|
||||
case orKind*: MethodPatternKind
|
||||
of MethodPatternKind.`any`:
|
||||
`any`* {.preservesLiteral: "#f".}: bool
|
||||
|
||||
of MethodPatternKind.`specific`:
|
||||
`specific`*: MethodPatternSpecific
|
||||
|
||||
|
||||
MimeType* = Symbol
|
||||
QueryValueKind* {.pure.} = enum
|
||||
`string`, `file`
|
||||
QueryValueString* = string
|
||||
QueryValueFile* {.preservesRecord: "file".} = object
|
||||
`filename`*: string
|
||||
`headers`*: Headers
|
||||
`body`*: seq[byte]
|
||||
|
||||
`QueryValue`* {.preservesOr.} = object
|
||||
case orKind*: QueryValueKind
|
||||
of QueryValueKind.`string`:
|
||||
`string`*: QueryValueString
|
||||
|
||||
of QueryValueKind.`file`:
|
||||
`file`*: QueryValueFile
|
||||
|
||||
|
||||
HttpRequest* {.preservesRecord: "http-request".} = object
|
||||
`sequenceNumber`*: BiggestInt
|
||||
`host`*: string
|
||||
`port`*: BiggestInt
|
||||
`method`*: Symbol
|
||||
`path`*: seq[string]
|
||||
`headers`*: Headers
|
||||
`query`*: Table[Symbol, seq[QueryValue]]
|
||||
`body`*: RequestBody
|
||||
|
||||
RequestBodyKind* {.pure.} = enum
|
||||
`present`, `absent`
|
||||
RequestBodyPresent* = seq[byte]
|
||||
`RequestBody`* {.preservesOr.} = object
|
||||
case orKind*: RequestBodyKind
|
||||
of RequestBodyKind.`present`:
|
||||
`present`*: RequestBodyPresent
|
||||
|
||||
of RequestBodyKind.`absent`:
|
||||
`absent`* {.preservesLiteral: "#f".}: bool
|
||||
|
||||
|
||||
Headers* = Table[Symbol, string]
|
||||
HttpResponseKind* {.pure.} = enum
|
||||
`status`, `header`, `chunk`, `done`
|
||||
HttpResponseStatus* {.preservesRecord: "status".} = object
|
||||
`code`*: BiggestInt
|
||||
`message`*: string
|
||||
|
||||
HttpResponseHeader* {.preservesRecord: "header".} = object
|
||||
`name`*: Symbol
|
||||
`value`*: string
|
||||
|
||||
HttpResponseChunk* {.preservesRecord: "chunk".} = object
|
||||
`chunk`*: Chunk
|
||||
|
||||
HttpResponseDone* {.preservesRecord: "done".} = object
|
||||
`chunk`*: Chunk
|
||||
|
||||
`HttpResponse`* {.preservesOr.} = object
|
||||
case orKind*: HttpResponseKind
|
||||
of HttpResponseKind.`status`:
|
||||
`status`*: HttpResponseStatus
|
||||
|
||||
of HttpResponseKind.`header`:
|
||||
`header`*: HttpResponseHeader
|
||||
|
||||
of HttpResponseKind.`chunk`:
|
||||
`chunk`*: HttpResponseChunk
|
||||
|
||||
of HttpResponseKind.`done`:
|
||||
`done`*: HttpResponseDone
|
||||
|
||||
|
||||
HttpService* {.preservesRecord: "http-service".} = object
|
||||
`host`*: HostPattern
|
||||
`port`*: BiggestInt
|
||||
`method`*: MethodPattern
|
||||
`path`*: PathPattern
|
||||
|
||||
HttpBinding* {.preservesRecord: "http-bind".} = object
|
||||
`host`*: HostPattern
|
||||
`port`*: BiggestInt
|
||||
`method`*: MethodPattern
|
||||
`path`*: PathPattern
|
||||
`handler`* {.preservesEmbedded.}: HttpRequest
|
||||
|
||||
HttpContext* {.preservesRecord: "request".} = object
|
||||
`req`*: HttpRequest
|
||||
`res`* {.preservesEmbedded.}: HttpResponse
|
||||
|
||||
PathPatternElementKind* {.pure.} = enum
|
||||
`label`, `wildcard`, `rest`
|
||||
PathPatternElementLabel* = string
|
||||
`PathPatternElement`* {.preservesOr.} = object
|
||||
case orKind*: PathPatternElementKind
|
||||
of PathPatternElementKind.`label`:
|
||||
`label`*: PathPatternElementLabel
|
||||
|
||||
of PathPatternElementKind.`wildcard`:
|
||||
`wildcard`* {.preservesLiteral: "_".}: bool
|
||||
|
||||
of PathPatternElementKind.`rest`:
|
||||
`rest`* {.preservesLiteral: "|...|".}: bool
|
||||
|
||||
|
||||
ChunkKind* {.pure.} = enum
|
||||
`string`, `bytes`
|
||||
ChunkString* = string
|
||||
ChunkBytes* = seq[byte]
|
||||
`Chunk`* {.preservesOr.} = object
|
||||
case orKind*: ChunkKind
|
||||
of ChunkKind.`string`:
|
||||
`string`*: ChunkString
|
||||
|
||||
of ChunkKind.`bytes`:
|
||||
`bytes`*: ChunkBytes
|
||||
|
||||
|
||||
PathPattern* = seq[PathPatternElement]
|
||||
proc `$`*(x: HostPattern | HttpListener | MethodPattern | MimeType | QueryValue |
|
||||
HttpRequest |
|
||||
RequestBody |
|
||||
Headers |
|
||||
HttpResponse |
|
||||
HttpService |
|
||||
HttpBinding |
|
||||
HttpContext |
|
||||
PathPatternElement |
|
||||
Chunk |
|
||||
PathPattern): string =
|
||||
`$`(toPreserves(x))
|
||||
|
||||
proc encode*(x: HostPattern | HttpListener | MethodPattern | MimeType |
|
||||
QueryValue |
|
||||
HttpRequest |
|
||||
RequestBody |
|
||||
Headers |
|
||||
HttpResponse |
|
||||
HttpService |
|
||||
HttpBinding |
|
||||
HttpContext |
|
||||
PathPatternElement |
|
||||
Chunk |
|
||||
PathPattern): seq[byte] =
|
||||
encode(toPreserves(x))
|
|
@ -0,0 +1,105 @@
|
|||
|
||||
import
|
||||
preserves, std/tables
|
||||
|
||||
type
|
||||
NoiseDescriptionDetail* = NoiseServiceSpec
|
||||
NoisePreSharedKeysKind* {.pure.} = enum
|
||||
`present`, `invalid`, `absent`
|
||||
NoisePreSharedKeysPresent* {.preservesDictionary.} = object
|
||||
`preSharedKeys`*: seq[seq[byte]]
|
||||
|
||||
NoisePreSharedKeysInvalid* {.preservesDictionary.} = object
|
||||
`preSharedKeys`*: Value
|
||||
|
||||
NoisePreSharedKeysAbsent* {.preservesDictionary.} = object
|
||||
|
||||
`NoisePreSharedKeys`* {.preservesOr.} = object
|
||||
case orKind*: NoisePreSharedKeysKind
|
||||
of NoisePreSharedKeysKind.`present`:
|
||||
`present`*: NoisePreSharedKeysPresent
|
||||
|
||||
of NoisePreSharedKeysKind.`invalid`:
|
||||
`invalid`*: NoisePreSharedKeysInvalid
|
||||
|
||||
of NoisePreSharedKeysKind.`absent`:
|
||||
`absent`*: NoisePreSharedKeysAbsent
|
||||
|
||||
|
||||
SecretKeyFieldKind* {.pure.} = enum
|
||||
`present`, `invalid`, `absent`
|
||||
SecretKeyFieldPresent* {.preservesDictionary.} = object
|
||||
`secretKey`*: seq[byte]
|
||||
|
||||
SecretKeyFieldInvalid* {.preservesDictionary.} = object
|
||||
`secretKey`*: Value
|
||||
|
||||
SecretKeyFieldAbsent* {.preservesDictionary.} = object
|
||||
|
||||
`SecretKeyField`* {.preservesOr.} = object
|
||||
case orKind*: SecretKeyFieldKind
|
||||
of SecretKeyFieldKind.`present`:
|
||||
`present`*: SecretKeyFieldPresent
|
||||
|
||||
of SecretKeyFieldKind.`invalid`:
|
||||
`invalid`*: SecretKeyFieldInvalid
|
||||
|
||||
of SecretKeyFieldKind.`absent`:
|
||||
`absent`*: SecretKeyFieldAbsent
|
||||
|
||||
|
||||
NoiseProtocolKind* {.pure.} = enum
|
||||
`present`, `invalid`, `absent`
|
||||
NoiseProtocolPresent* {.preservesDictionary.} = object
|
||||
`protocol`*: string
|
||||
|
||||
NoiseProtocolInvalid* {.preservesDictionary.} = object
|
||||
`protocol`*: Value
|
||||
|
||||
NoiseProtocolAbsent* {.preservesDictionary.} = object
|
||||
|
||||
`NoiseProtocol`* {.preservesOr.} = object
|
||||
case orKind*: NoiseProtocolKind
|
||||
of NoiseProtocolKind.`present`:
|
||||
`present`*: NoiseProtocolPresent
|
||||
|
||||
of NoiseProtocolKind.`invalid`:
|
||||
`invalid`*: NoiseProtocolInvalid
|
||||
|
||||
of NoiseProtocolKind.`absent`:
|
||||
`absent`*: NoiseProtocolAbsent
|
||||
|
||||
|
||||
NoisePathStepDetail* = NoiseSpec
|
||||
`NoiseServiceSpec`* = Table[Symbol, Value]
|
||||
ServiceSelector* = Value
|
||||
NoiseStepDetail* = ServiceSelector
|
||||
`NoiseSpec`* = Table[Symbol, Value]
|
||||
PacketKind* {.pure.} = enum
|
||||
`complete`, `fragmented`
|
||||
PacketComplete* = seq[byte]
|
||||
PacketFragmented* = seq[seq[byte]]
|
||||
`Packet`* {.preservesOr.} = object
|
||||
case orKind*: PacketKind
|
||||
of PacketKind.`complete`:
|
||||
`complete`*: PacketComplete
|
||||
|
||||
of PacketKind.`fragmented`:
|
||||
`fragmented`*: PacketFragmented
|
||||
|
||||
|
||||
proc `$`*(x: NoiseDescriptionDetail | NoisePreSharedKeys | SecretKeyField |
|
||||
NoiseProtocol |
|
||||
NoisePathStepDetail |
|
||||
NoiseServiceSpec |
|
||||
NoiseSpec |
|
||||
Packet): string =
|
||||
`$`(toPreserves(x))
|
||||
|
||||
proc encode*(x: NoiseDescriptionDetail | NoisePreSharedKeys | SecretKeyField |
|
||||
NoiseProtocol |
|
||||
NoisePathStepDetail |
|
||||
NoiseServiceSpec |
|
||||
NoiseSpec |
|
||||
Packet): seq[byte] =
|
||||
encode(toPreserves(x))
|
|
@ -5,7 +5,7 @@ import
|
|||
type
|
||||
Error* {.preservesRecord: "error".} = object
|
||||
`message`*: string
|
||||
`detail`*: Preserve[void]
|
||||
`detail`*: Value
|
||||
|
||||
Turn* = seq[TurnEvent]
|
||||
Message* {.preservesRecord: "message".} = object
|
||||
|
@ -18,7 +18,7 @@ type
|
|||
`assertion`*: Assertion
|
||||
`handle`*: Handle
|
||||
|
||||
Extension* = Preserve[void]
|
||||
Extension* = Value
|
||||
Sync* {.preservesRecord: "sync".} = object
|
||||
`peer`* {.preservesLiteral: "#!#t".}: tuple[]
|
||||
|
||||
|
@ -27,7 +27,7 @@ type
|
|||
`event`*: Event
|
||||
|
||||
Oid* = BiggestInt
|
||||
Assertion* = Preserve[void]
|
||||
Assertion* = Value
|
||||
Handle* = BiggestInt
|
||||
PacketKind* {.pure.} = enum
|
||||
`Turn`, `Error`, `Extension`
|
||||
|
@ -64,11 +64,11 @@ proc `$`*(x: Error | Turn | Message | Retract | Assert | Sync | TurnEvent | Oid
|
|||
Handle |
|
||||
Packet |
|
||||
Event): string =
|
||||
`$`(toPreserve(x))
|
||||
`$`(toPreserves(x))
|
||||
|
||||
proc encode*(x: Error | Turn | Message | Retract | Assert | Sync | TurnEvent |
|
||||
Oid |
|
||||
Handle |
|
||||
Packet |
|
||||
Event): seq[byte] =
|
||||
encode(toPreserve(x))
|
||||
encode(toPreserves(x))
|
||||
|
|
|
@ -5,8 +5,8 @@ import
|
|||
type
|
||||
StateKind* {.pure.} = enum
|
||||
`started`, `ready`, `failed`, `complete`, `userDefined`
|
||||
StateUserDefined*[Cap] = Preserve[Cap]
|
||||
`State`*[Cap] {.preservesOr.} = object
|
||||
StateUserDefined* = Value
|
||||
`State`* {.preservesOr.} = object
|
||||
case orKind*: StateKind
|
||||
of StateKind.`started`:
|
||||
`started`* {.preservesLiteral: "started".}: bool
|
||||
|
@ -21,40 +21,38 @@ type
|
|||
`complete`* {.preservesLiteral: "complete".}: bool
|
||||
|
||||
of StateKind.`userDefined`:
|
||||
`userdefined`*: StateUserDefined[Cap]
|
||||
`userdefined`*: StateUserDefined
|
||||
|
||||
|
||||
ServiceObject*[Cap] {.preservesRecord: "service-object".} = object
|
||||
`serviceName`*: Preserve[Cap]
|
||||
`object`*: Preserve[Cap]
|
||||
ServiceObject* {.preservesRecord: "service-object".} = object
|
||||
`serviceName`*: Value
|
||||
`object`*: Value
|
||||
|
||||
RequireService*[Cap] {.preservesRecord: "require-service".} = object
|
||||
`serviceName`*: Preserve[Cap]
|
||||
RequireService* {.preservesRecord: "require-service".} = object
|
||||
`serviceName`*: Value
|
||||
|
||||
RestartService*[Cap] {.preservesRecord: "restart-service".} = object
|
||||
`serviceName`*: Preserve[Cap]
|
||||
RestartService* {.preservesRecord: "restart-service".} = object
|
||||
`serviceName`*: Value
|
||||
|
||||
RunService*[Cap] {.preservesRecord: "run-service".} = object
|
||||
`serviceName`*: Preserve[Cap]
|
||||
RunService* {.preservesRecord: "run-service".} = object
|
||||
`serviceName`*: Value
|
||||
|
||||
ServiceState*[Cap] {.preservesRecord: "service-state".} = object
|
||||
`serviceName`*: Preserve[Cap]
|
||||
`state`*: State[Cap]
|
||||
ServiceState* {.preservesRecord: "service-state".} = object
|
||||
`serviceName`*: Value
|
||||
`state`*: State
|
||||
|
||||
ServiceDependency*[Cap] {.preservesRecord: "depends-on".} = object
|
||||
`depender`*: Preserve[Cap]
|
||||
`dependee`*: ServiceState[Cap]
|
||||
ServiceDependency* {.preservesRecord: "depends-on".} = object
|
||||
`depender`*: Value
|
||||
`dependee`*: ServiceState
|
||||
|
||||
proc `$`*[Cap](x: State[Cap] | ServiceObject[Cap] | RequireService[Cap] |
|
||||
RestartService[Cap] |
|
||||
RunService[Cap] |
|
||||
ServiceState[Cap] |
|
||||
ServiceDependency[Cap]): string =
|
||||
`$`(toPreserve(x, Cap))
|
||||
proc `$`*(x: State | ServiceObject | RequireService | RestartService |
|
||||
RunService |
|
||||
ServiceState |
|
||||
ServiceDependency): string =
|
||||
`$`(toPreserves(x))
|
||||
|
||||
proc encode*[Cap](x: State[Cap] | ServiceObject[Cap] | RequireService[Cap] |
|
||||
RestartService[Cap] |
|
||||
RunService[Cap] |
|
||||
ServiceState[Cap] |
|
||||
ServiceDependency[Cap]): seq[byte] =
|
||||
encode(toPreserve(x, Cap))
|
||||
proc encode*(x: State | ServiceObject | RequireService | RestartService |
|
||||
RunService |
|
||||
ServiceState |
|
||||
ServiceDependency): seq[byte] =
|
||||
encode(toPreserves(x))
|
||||
|
|
|
@ -18,76 +18,76 @@ type
|
|||
StreamError* {.preservesRecord: "error".} = object
|
||||
`message`*: string
|
||||
|
||||
StreamListenerError*[Cap] {.preservesRecord: "stream-listener-error".} = object
|
||||
`spec`*: Preserve[Cap]
|
||||
StreamListenerError* {.preservesRecord: "stream-listener-error".} = object
|
||||
`spec`*: Value
|
||||
`message`*: string
|
||||
|
||||
StreamConnection*[Cap] {.preservesRecord: "stream-connection".} = object
|
||||
`source`*: Cap
|
||||
`sink`*: Cap
|
||||
`spec`*: Preserve[Cap]
|
||||
StreamConnection* {.preservesRecord: "stream-connection".} = object
|
||||
`source`*: Source
|
||||
`sink`*: Sink
|
||||
`spec`*: Value
|
||||
|
||||
`LineMode`* {.preservesOr, pure.} = enum
|
||||
`lf`, `crlf`
|
||||
SourceKind* {.pure.} = enum
|
||||
`sink`, `StreamError`, `credit`
|
||||
SourceSink*[Cap] {.preservesRecord: "sink".} = object
|
||||
`controller`*: Cap
|
||||
SourceSink* {.preservesRecord: "sink".} = object
|
||||
`controller`*: Sink
|
||||
|
||||
SourceCredit*[Cap] {.preservesRecord: "credit".} = object
|
||||
SourceCredit* {.preservesRecord: "credit".} = object
|
||||
`amount`*: CreditAmount
|
||||
`mode`*: Mode[Cap]
|
||||
`mode`*: Mode
|
||||
|
||||
`Source`*[Cap] {.preservesOr.} = object
|
||||
`Source`* {.acyclic, preservesOr.} = ref object
|
||||
case orKind*: SourceKind
|
||||
of SourceKind.`sink`:
|
||||
`sink`*: SourceSink[Cap]
|
||||
`sink`*: SourceSink
|
||||
|
||||
of SourceKind.`StreamError`:
|
||||
`streamerror`*: StreamError
|
||||
|
||||
of SourceKind.`credit`:
|
||||
`credit`*: SourceCredit[Cap]
|
||||
`credit`*: SourceCredit
|
||||
|
||||
|
||||
SinkKind* {.pure.} = enum
|
||||
`source`, `StreamError`, `data`, `eof`
|
||||
SinkSource*[Cap] {.preservesRecord: "source".} = object
|
||||
`controller`*: Cap
|
||||
SinkSource* {.preservesRecord: "source".} = object
|
||||
`controller`*: Source
|
||||
|
||||
SinkData*[Cap] {.preservesRecord: "data".} = object
|
||||
`payload`*: Preserve[Cap]
|
||||
`mode`*: Mode[Cap]
|
||||
SinkData* {.preservesRecord: "data".} = object
|
||||
`payload`*: Value
|
||||
`mode`*: Mode
|
||||
|
||||
SinkEof* {.preservesRecord: "eof".} = object
|
||||
|
||||
`Sink`*[Cap] {.preservesOr.} = object
|
||||
`Sink`* {.acyclic, preservesOr.} = ref object
|
||||
case orKind*: SinkKind
|
||||
of SinkKind.`source`:
|
||||
`source`*: SinkSource[Cap]
|
||||
`source`*: SinkSource
|
||||
|
||||
of SinkKind.`StreamError`:
|
||||
`streamerror`*: StreamError
|
||||
|
||||
of SinkKind.`data`:
|
||||
`data`*: SinkData[Cap]
|
||||
`data`*: SinkData
|
||||
|
||||
of SinkKind.`eof`:
|
||||
`eof`*: SinkEof
|
||||
|
||||
|
||||
StreamListenerReady*[Cap] {.preservesRecord: "stream-listener-ready".} = object
|
||||
`spec`*: Preserve[Cap]
|
||||
StreamListenerReady* {.preservesRecord: "stream-listener-ready".} = object
|
||||
`spec`*: Value
|
||||
|
||||
ModeKind* {.pure.} = enum
|
||||
`bytes`, `lines`, `packet`, `object`
|
||||
ModePacket* {.preservesRecord: "packet".} = object
|
||||
`size`*: BiggestInt
|
||||
|
||||
ModeObject*[Cap] {.preservesRecord: "object".} = object
|
||||
`description`*: Preserve[Cap]
|
||||
ModeObject* {.preservesRecord: "object".} = object
|
||||
`description`*: Value
|
||||
|
||||
`Mode`*[Cap] {.preservesOr.} = object
|
||||
`Mode`* {.preservesOr.} = object
|
||||
case orKind*: ModeKind
|
||||
of ModeKind.`bytes`:
|
||||
`bytes`* {.preservesLiteral: "bytes".}: bool
|
||||
|
@ -99,24 +99,20 @@ type
|
|||
`packet`*: ModePacket
|
||||
|
||||
of ModeKind.`object`:
|
||||
`object`*: ModeObject[Cap]
|
||||
`object`*: ModeObject
|
||||
|
||||
|
||||
proc `$`*[Cap](x: StreamListenerError[Cap] | StreamConnection[Cap] | Source[Cap] |
|
||||
Sink[Cap] |
|
||||
StreamListenerReady[Cap] |
|
||||
Mode[Cap]): string =
|
||||
`$`(toPreserve(x, Cap))
|
||||
proc `$`*(x: CreditAmount | StreamError | StreamListenerError | StreamConnection |
|
||||
Source |
|
||||
Sink |
|
||||
StreamListenerReady |
|
||||
Mode): string =
|
||||
`$`(toPreserves(x))
|
||||
|
||||
proc encode*[Cap](x: StreamListenerError[Cap] | StreamConnection[Cap] |
|
||||
Source[Cap] |
|
||||
Sink[Cap] |
|
||||
StreamListenerReady[Cap] |
|
||||
Mode[Cap]): seq[byte] =
|
||||
encode(toPreserve(x, Cap))
|
||||
|
||||
proc `$`*(x: CreditAmount | StreamError): string =
|
||||
`$`(toPreserve(x))
|
||||
|
||||
proc encode*(x: CreditAmount | StreamError): seq[byte] =
|
||||
encode(toPreserve(x))
|
||||
proc encode*(x: CreditAmount | StreamError | StreamListenerError |
|
||||
StreamConnection |
|
||||
Source |
|
||||
Sink |
|
||||
StreamListenerReady |
|
||||
Mode): seq[byte] =
|
||||
encode(toPreserves(x))
|
||||
|
|
|
@ -5,100 +5,100 @@ import
|
|||
type
|
||||
PCompoundKind* {.pure.} = enum
|
||||
`rec`, `arr`, `dict`
|
||||
PCompoundRec*[Cap] {.acyclic, preservesRecord: "rec".} = ref object
|
||||
`label`*: Preserve[Cap]
|
||||
`fields`*: seq[Pattern[Cap]]
|
||||
PCompoundRec* {.preservesRecord: "rec".} = object
|
||||
`label`*: Value
|
||||
`fields`*: seq[Pattern]
|
||||
|
||||
PCompoundArr*[Cap] {.acyclic, preservesRecord: "arr".} = ref object
|
||||
`items`*: seq[Pattern[Cap]]
|
||||
PCompoundArr* {.preservesRecord: "arr".} = object
|
||||
`items`*: seq[Pattern]
|
||||
|
||||
PCompoundDict*[Cap] {.acyclic, preservesRecord: "dict".} = ref object
|
||||
`entries`*: Table[Preserve[Cap], Pattern[Cap]]
|
||||
PCompoundDict* {.preservesRecord: "dict".} = object
|
||||
`entries`*: Table[Value, Pattern]
|
||||
|
||||
`PCompound`*[Cap] {.acyclic, preservesOr.} = ref object
|
||||
`PCompound`* {.preservesOr.} = object
|
||||
case orKind*: PCompoundKind
|
||||
of PCompoundKind.`rec`:
|
||||
`rec`*: PCompoundRec[Cap]
|
||||
`rec`*: PCompoundRec
|
||||
|
||||
of PCompoundKind.`arr`:
|
||||
`arr`*: PCompoundArr[Cap]
|
||||
`arr`*: PCompoundArr
|
||||
|
||||
of PCompoundKind.`dict`:
|
||||
`dict`*: PCompoundDict[Cap]
|
||||
`dict`*: PCompoundDict
|
||||
|
||||
|
||||
Reject*[Cap] {.acyclic, preservesRecord: "reject".} = ref object
|
||||
`pattern`*: Pattern[Cap]
|
||||
Reject* {.preservesRecord: "reject".} = object
|
||||
`pattern`*: Pattern
|
||||
|
||||
CaveatsFieldKind* {.pure.} = enum
|
||||
`present`, `invalid`, `absent`
|
||||
CaveatsFieldPresent*[Cap] {.acyclic, preservesDictionary.} = ref object
|
||||
`caveats`*: seq[Caveat[Cap]]
|
||||
CaveatsFieldPresent* {.preservesDictionary.} = object
|
||||
`caveats`*: seq[Caveat]
|
||||
|
||||
CaveatsFieldInvalid*[Cap] {.preservesDictionary.} = object
|
||||
`caveats`*: Preserve[Cap]
|
||||
CaveatsFieldInvalid* {.preservesDictionary.} = object
|
||||
`caveats`*: Value
|
||||
|
||||
CaveatsFieldAbsent* {.preservesDictionary.} = object
|
||||
|
||||
`CaveatsField`*[Cap] {.acyclic, preservesOr.} = ref object
|
||||
`CaveatsField`* {.preservesOr.} = object
|
||||
case orKind*: CaveatsFieldKind
|
||||
of CaveatsFieldKind.`present`:
|
||||
`present`*: CaveatsFieldPresent[Cap]
|
||||
`present`*: CaveatsFieldPresent
|
||||
|
||||
of CaveatsFieldKind.`invalid`:
|
||||
`invalid`*: CaveatsFieldInvalid[Cap]
|
||||
`invalid`*: CaveatsFieldInvalid
|
||||
|
||||
of CaveatsFieldKind.`absent`:
|
||||
`absent`*: CaveatsFieldAbsent
|
||||
|
||||
|
||||
SturdyDescriptionDetail*[Cap] {.preservesDictionary.} = object
|
||||
SturdyDescriptionDetail* {.preservesDictionary.} = object
|
||||
`key`*: seq[byte]
|
||||
`oid`*: Preserve[Cap]
|
||||
`oid`*: Value
|
||||
|
||||
PAnd*[Cap] {.acyclic, preservesRecord: "and".} = ref object
|
||||
`patterns`*: seq[Pattern[Cap]]
|
||||
PAnd* {.preservesRecord: "and".} = object
|
||||
`patterns`*: seq[Pattern]
|
||||
|
||||
SturdyStepDetail*[Cap] = Parameters[Cap]
|
||||
Rewrite*[Cap] {.acyclic, preservesRecord: "rewrite".} = ref object
|
||||
`pattern`*: Pattern[Cap]
|
||||
`template`*: Template[Cap]
|
||||
SturdyStepDetail* = Parameters
|
||||
Rewrite* {.preservesRecord: "rewrite".} = object
|
||||
`pattern`*: Pattern
|
||||
`template`*: Template
|
||||
|
||||
Parameters*[Cap] = Preserve[Cap]
|
||||
`Parameters`* = Table[Symbol, Value]
|
||||
TRef* {.preservesRecord: "ref".} = object
|
||||
`binding`*: BiggestInt
|
||||
|
||||
PBind*[Cap] {.acyclic, preservesRecord: "bind".} = ref object
|
||||
`pattern`*: Pattern[Cap]
|
||||
PBind* {.preservesRecord: "bind".} = object
|
||||
`pattern`*: Pattern
|
||||
|
||||
Lit*[Cap] {.preservesRecord: "lit".} = object
|
||||
`value`*: Preserve[Cap]
|
||||
Lit* {.preservesRecord: "lit".} = object
|
||||
`value`*: Value
|
||||
|
||||
TCompoundKind* {.pure.} = enum
|
||||
`rec`, `arr`, `dict`
|
||||
TCompoundRec*[Cap] {.acyclic, preservesRecord: "rec".} = ref object
|
||||
`label`*: Preserve[Cap]
|
||||
`fields`*: seq[Template[Cap]]
|
||||
TCompoundRec* {.preservesRecord: "rec".} = object
|
||||
`label`*: Value
|
||||
`fields`*: seq[Template]
|
||||
|
||||
TCompoundArr*[Cap] {.acyclic, preservesRecord: "arr".} = ref object
|
||||
`items`*: seq[Template[Cap]]
|
||||
TCompoundArr* {.preservesRecord: "arr".} = object
|
||||
`items`*: seq[Template]
|
||||
|
||||
TCompoundDict*[Cap] {.acyclic, preservesRecord: "dict".} = ref object
|
||||
`entries`*: Table[Preserve[Cap], Template[Cap]]
|
||||
TCompoundDict* {.preservesRecord: "dict".} = object
|
||||
`entries`*: Table[Value, Template]
|
||||
|
||||
`TCompound`*[Cap] {.acyclic, preservesOr.} = ref object
|
||||
`TCompound`* {.preservesOr.} = object
|
||||
case orKind*: TCompoundKind
|
||||
of TCompoundKind.`rec`:
|
||||
`rec`*: TCompoundRec[Cap]
|
||||
`rec`*: TCompoundRec
|
||||
|
||||
of TCompoundKind.`arr`:
|
||||
`arr`*: TCompoundArr[Cap]
|
||||
`arr`*: TCompoundArr
|
||||
|
||||
of TCompoundKind.`dict`:
|
||||
`dict`*: TCompoundDict[Cap]
|
||||
`dict`*: TCompoundDict
|
||||
|
||||
|
||||
SturdyPathStepDetail*[Cap] = Parameters[Cap]
|
||||
SturdyPathStepDetail* = Parameters
|
||||
`PAtom`* {.preservesOr, pure.} = enum
|
||||
`Boolean`, `Float`, `Double`, `SignedInteger`, `String`, `ByteString`,
|
||||
`Symbol`
|
||||
|
@ -106,44 +106,44 @@ type
|
|||
|
||||
TemplateKind* {.pure.} = enum
|
||||
`TAttenuate`, `TRef`, `Lit`, `TCompound`
|
||||
`Template`*[Cap] {.acyclic, preservesOr.} = ref object
|
||||
`Template`* {.acyclic, preservesOr.} = ref object
|
||||
case orKind*: TemplateKind
|
||||
of TemplateKind.`TAttenuate`:
|
||||
`tattenuate`*: TAttenuate[Cap]
|
||||
`tattenuate`*: TAttenuate
|
||||
|
||||
of TemplateKind.`TRef`:
|
||||
`tref`*: TRef
|
||||
|
||||
of TemplateKind.`Lit`:
|
||||
`lit`*: Lit[Cap]
|
||||
`lit`*: Lit
|
||||
|
||||
of TemplateKind.`TCompound`:
|
||||
`tcompound`*: TCompound[Cap]
|
||||
`tcompound`*: TCompound
|
||||
|
||||
|
||||
CaveatKind* {.pure.} = enum
|
||||
`Rewrite`, `Alts`, `Reject`, `unknown`
|
||||
CaveatUnknown*[Cap] = Preserve[Cap]
|
||||
`Caveat`*[Cap] {.acyclic, preservesOr.} = ref object
|
||||
CaveatUnknown* = Value
|
||||
`Caveat`* {.preservesOr.} = object
|
||||
case orKind*: CaveatKind
|
||||
of CaveatKind.`Rewrite`:
|
||||
`rewrite`*: Rewrite[Cap]
|
||||
`rewrite`*: Rewrite
|
||||
|
||||
of CaveatKind.`Alts`:
|
||||
`alts`*: Alts[Cap]
|
||||
`alts`*: Alts
|
||||
|
||||
of CaveatKind.`Reject`:
|
||||
`reject`*: Reject[Cap]
|
||||
`reject`*: Reject
|
||||
|
||||
of CaveatKind.`unknown`:
|
||||
`unknown`*: CaveatUnknown[Cap]
|
||||
`unknown`*: CaveatUnknown
|
||||
|
||||
|
||||
PNot*[Cap] {.acyclic, preservesRecord: "not".} = ref object
|
||||
`pattern`*: Pattern[Cap]
|
||||
PNot* {.preservesRecord: "not".} = object
|
||||
`pattern`*: Pattern
|
||||
|
||||
SturdyRef*[Cap] {.acyclic, preservesRecord: "ref".} = ref object
|
||||
`parameters`*: Parameters[Cap]
|
||||
SturdyRef* {.preservesRecord: "ref".} = object
|
||||
`parameters`*: Parameters
|
||||
|
||||
WireRefKind* {.pure.} = enum
|
||||
`mine`, `yours`
|
||||
|
@ -151,32 +151,32 @@ type
|
|||
`field0`* {.preservesLiteral: "0".}: tuple[]
|
||||
`oid`*: Oid
|
||||
|
||||
WireRefYours*[Cap] {.acyclic, preservesTuple.} = ref object
|
||||
WireRefYours* {.preservesTuple.} = object
|
||||
`field0`* {.preservesLiteral: "1".}: tuple[]
|
||||
`oid`*: Oid
|
||||
`attenuation`* {.preservesTupleTail.}: seq[Caveat[Cap]]
|
||||
`attenuation`* {.preservesTupleTail.}: seq[Caveat]
|
||||
|
||||
`WireRef`*[Cap] {.acyclic, preservesOr.} = ref object
|
||||
`WireRef`* {.preservesOr.} = object
|
||||
case orKind*: WireRefKind
|
||||
of WireRefKind.`mine`:
|
||||
`mine`*: WireRefMine
|
||||
|
||||
of WireRefKind.`yours`:
|
||||
`yours`*: WireRefYours[Cap]
|
||||
`yours`*: WireRefYours
|
||||
|
||||
|
||||
TAttenuate*[Cap] {.acyclic, preservesRecord: "attenuate".} = ref object
|
||||
`template`*: Template[Cap]
|
||||
`attenuation`*: seq[Caveat[Cap]]
|
||||
TAttenuate* {.preservesRecord: "attenuate".} = object
|
||||
`template`*: Template
|
||||
`attenuation`*: seq[Caveat]
|
||||
|
||||
Oid* = BiggestInt
|
||||
Alts*[Cap] {.acyclic, preservesRecord: "or".} = ref object
|
||||
`alternatives`*: seq[Rewrite[Cap]]
|
||||
Alts* {.preservesRecord: "or".} = object
|
||||
`alternatives`*: seq[Rewrite]
|
||||
|
||||
PatternKind* {.pure.} = enum
|
||||
`PDiscard`, `PAtom`, `PEmbedded`, `PBind`, `PAnd`, `PNot`, `Lit`,
|
||||
`PCompound`
|
||||
`Pattern`*[Cap] {.acyclic, preservesOr.} = ref object
|
||||
`Pattern`* {.acyclic, preservesOr.} = ref object
|
||||
case orKind*: PatternKind
|
||||
of PatternKind.`PDiscard`:
|
||||
`pdiscard`*: PDiscard
|
||||
|
@ -188,57 +188,60 @@ type
|
|||
`pembedded`* {.preservesLiteral: "Embedded".}: bool
|
||||
|
||||
of PatternKind.`PBind`:
|
||||
`pbind`*: PBind[Cap]
|
||||
`pbind`*: PBind
|
||||
|
||||
of PatternKind.`PAnd`:
|
||||
`pand`*: PAnd[Cap]
|
||||
`pand`*: PAnd
|
||||
|
||||
of PatternKind.`PNot`:
|
||||
`pnot`*: PNot[Cap]
|
||||
`pnot`*: PNot
|
||||
|
||||
of PatternKind.`Lit`:
|
||||
`lit`*: Lit[Cap]
|
||||
`lit`*: Lit
|
||||
|
||||
of PatternKind.`PCompound`:
|
||||
`pcompound`*: PCompound[Cap]
|
||||
`pcompound`*: PCompound
|
||||
|
||||
|
||||
proc `$`*[Cap](x: PCompound[Cap] | Reject[Cap] | CaveatsField[Cap] |
|
||||
SturdyDescriptionDetail[Cap] |
|
||||
PAnd[Cap] |
|
||||
Rewrite[Cap] |
|
||||
PBind[Cap] |
|
||||
Lit[Cap] |
|
||||
TCompound[Cap] |
|
||||
Template[Cap] |
|
||||
Caveat[Cap] |
|
||||
PNot[Cap] |
|
||||
SturdyRef[Cap] |
|
||||
WireRef[Cap] |
|
||||
TAttenuate[Cap] |
|
||||
Alts[Cap] |
|
||||
Pattern[Cap]): string =
|
||||
`$`(toPreserve(x, Cap))
|
||||
proc `$`*(x: PCompound | Reject | CaveatsField | SturdyDescriptionDetail | PAnd |
|
||||
SturdyStepDetail |
|
||||
Rewrite |
|
||||
Parameters |
|
||||
TRef |
|
||||
PBind |
|
||||
Lit |
|
||||
TCompound |
|
||||
SturdyPathStepDetail |
|
||||
PDiscard |
|
||||
Template |
|
||||
Caveat |
|
||||
PNot |
|
||||
SturdyRef |
|
||||
WireRef |
|
||||
TAttenuate |
|
||||
Oid |
|
||||
Alts |
|
||||
Pattern): string =
|
||||
`$`(toPreserves(x))
|
||||
|
||||
proc encode*[Cap](x: PCompound[Cap] | Reject[Cap] | CaveatsField[Cap] |
|
||||
SturdyDescriptionDetail[Cap] |
|
||||
PAnd[Cap] |
|
||||
Rewrite[Cap] |
|
||||
PBind[Cap] |
|
||||
Lit[Cap] |
|
||||
TCompound[Cap] |
|
||||
Template[Cap] |
|
||||
Caveat[Cap] |
|
||||
PNot[Cap] |
|
||||
SturdyRef[Cap] |
|
||||
WireRef[Cap] |
|
||||
TAttenuate[Cap] |
|
||||
Alts[Cap] |
|
||||
Pattern[Cap]): seq[byte] =
|
||||
encode(toPreserve(x, Cap))
|
||||
|
||||
proc `$`*(x: TRef | PDiscard | Oid): string =
|
||||
`$`(toPreserve(x))
|
||||
|
||||
proc encode*(x: TRef | PDiscard | Oid): seq[byte] =
|
||||
encode(toPreserve(x))
|
||||
proc encode*(x: PCompound | Reject | CaveatsField | SturdyDescriptionDetail |
|
||||
PAnd |
|
||||
SturdyStepDetail |
|
||||
Rewrite |
|
||||
Parameters |
|
||||
TRef |
|
||||
PBind |
|
||||
Lit |
|
||||
TCompound |
|
||||
SturdyPathStepDetail |
|
||||
PDiscard |
|
||||
Template |
|
||||
Caveat |
|
||||
PNot |
|
||||
SturdyRef |
|
||||
WireRef |
|
||||
TAttenuate |
|
||||
Oid |
|
||||
Alts |
|
||||
Pattern): seq[byte] =
|
||||
encode(toPreserves(x))
|
||||
|
|
|
@ -7,8 +7,8 @@ type
|
|||
`host`*: string
|
||||
`port`*: BiggestInt
|
||||
|
||||
TcpPeerInfo*[Cap] {.preservesRecord: "tcp-peer".} = object
|
||||
`handle`*: Cap
|
||||
TcpPeerInfo* {.preservesRecord: "tcp-peer".} = object
|
||||
`handle`*: Value
|
||||
`local`*: TcpLocal
|
||||
`remote`*: TcpRemote
|
||||
|
||||
|
@ -16,14 +16,8 @@ type
|
|||
`host`*: string
|
||||
`port`*: BiggestInt
|
||||
|
||||
proc `$`*[Cap](x: TcpPeerInfo[Cap]): string =
|
||||
`$`(toPreserve(x, Cap))
|
||||
proc `$`*(x: TcpLocal | TcpPeerInfo | TcpRemote): string =
|
||||
`$`(toPreserves(x))
|
||||
|
||||
proc encode*[Cap](x: TcpPeerInfo[Cap]): seq[byte] =
|
||||
encode(toPreserve(x, Cap))
|
||||
|
||||
proc `$`*(x: TcpLocal | TcpRemote): string =
|
||||
`$`(toPreserve(x))
|
||||
|
||||
proc encode*(x: TcpLocal | TcpRemote): seq[byte] =
|
||||
encode(toPreserve(x))
|
||||
proc encode*(x: TcpLocal | TcpPeerInfo | TcpRemote): seq[byte] =
|
||||
encode(toPreserves(x))
|
||||
|
|
|
@ -4,11 +4,11 @@ import
|
|||
|
||||
type
|
||||
TimerExpired* {.preservesRecord: "timer-expired".} = object
|
||||
`label`*: Preserve[void]
|
||||
`label`*: Value
|
||||
`seconds`*: float64
|
||||
|
||||
SetTimer* {.preservesRecord: "set-timer".} = object
|
||||
`label`*: Preserve[void]
|
||||
`label`*: Value
|
||||
`seconds`*: float64
|
||||
`kind`*: TimerKind
|
||||
|
||||
|
@ -18,7 +18,7 @@ type
|
|||
`seconds`*: float64
|
||||
|
||||
proc `$`*(x: TimerExpired | SetTimer | LaterThan): string =
|
||||
`$`(toPreserve(x))
|
||||
`$`(toPreserves(x))
|
||||
|
||||
proc encode*(x: TimerExpired | SetTimer | LaterThan): seq[byte] =
|
||||
encode(toPreserve(x))
|
||||
encode(toPreserves(x))
|
||||
|
|
|
@ -3,160 +3,160 @@ import
|
|||
preserves, protocol
|
||||
|
||||
type
|
||||
TargetedTurnEvent*[Cap] {.preservesRecord: "event".} = object
|
||||
`target`*: Target[Cap]
|
||||
`detail`*: TurnEvent[Cap]
|
||||
TargetedTurnEvent* {.preservesRecord: "event".} = object
|
||||
`target`*: Target
|
||||
`detail`*: TurnEvent
|
||||
|
||||
`LinkedTaskReleaseReason`* {.preservesOr, pure.} = enum
|
||||
`cancelled`, `normal`
|
||||
TurnId*[Cap] = Preserve[Cap]
|
||||
TurnId* = Value
|
||||
AssertionDescriptionKind* {.pure.} = enum
|
||||
`value`, `opaque`
|
||||
AssertionDescriptionValue*[Cap] {.preservesRecord: "value".} = object
|
||||
`value`*: Preserve[Cap]
|
||||
AssertionDescriptionValue* {.preservesRecord: "value".} = object
|
||||
`value`*: Value
|
||||
|
||||
AssertionDescriptionOpaque*[Cap] {.preservesRecord: "opaque".} = object
|
||||
`description`*: Preserve[Cap]
|
||||
AssertionDescriptionOpaque* {.preservesRecord: "opaque".} = object
|
||||
`description`*: Value
|
||||
|
||||
`AssertionDescription`*[Cap] {.preservesOr.} = object
|
||||
`AssertionDescription`* {.preservesOr.} = object
|
||||
case orKind*: AssertionDescriptionKind
|
||||
of AssertionDescriptionKind.`value`:
|
||||
`value`*: AssertionDescriptionValue[Cap]
|
||||
`value`*: AssertionDescriptionValue
|
||||
|
||||
of AssertionDescriptionKind.`opaque`:
|
||||
`opaque`*: AssertionDescriptionOpaque[Cap]
|
||||
`opaque`*: AssertionDescriptionOpaque
|
||||
|
||||
|
||||
NameKind* {.pure.} = enum
|
||||
`anonymous`, `named`
|
||||
NameAnonymous* {.preservesRecord: "anonymous".} = object
|
||||
|
||||
NameNamed*[Cap] {.preservesRecord: "named".} = object
|
||||
`name`*: Preserve[Cap]
|
||||
NameNamed* {.preservesRecord: "named".} = object
|
||||
`name`*: Value
|
||||
|
||||
`Name`*[Cap] {.preservesOr.} = object
|
||||
`Name`* {.preservesOr.} = object
|
||||
case orKind*: NameKind
|
||||
of NameKind.`anonymous`:
|
||||
`anonymous`*: NameAnonymous
|
||||
|
||||
of NameKind.`named`:
|
||||
`named`*: NameNamed[Cap]
|
||||
`named`*: NameNamed
|
||||
|
||||
|
||||
ActorId*[Cap] = Preserve[Cap]
|
||||
FacetId*[Cap] = Preserve[Cap]
|
||||
ActorId* = Value
|
||||
FacetId* = Value
|
||||
`FacetStopReason`* {.preservesOr, pure.} = enum
|
||||
`explicitAction`, `inert`, `parentStopping`, `actorStopping`
|
||||
TaskId*[Cap] = Preserve[Cap]
|
||||
TaskId* = Value
|
||||
ActorActivationKind* {.pure.} = enum
|
||||
`start`, `turn`, `stop`
|
||||
ActorActivationStart*[Cap] {.preservesRecord: "start".} = object
|
||||
`actorName`*: Name[Cap]
|
||||
ActorActivationStart* {.preservesRecord: "start".} = object
|
||||
`actorName`*: Name
|
||||
|
||||
ActorActivationStop* {.preservesRecord: "stop".} = object
|
||||
`status`*: ExitStatus
|
||||
|
||||
`ActorActivation`*[Cap] {.preservesOr.} = object
|
||||
`ActorActivation`* {.preservesOr.} = object
|
||||
case orKind*: ActorActivationKind
|
||||
of ActorActivationKind.`start`:
|
||||
`start`*: ActorActivationStart[Cap]
|
||||
`start`*: ActorActivationStart
|
||||
|
||||
of ActorActivationKind.`turn`:
|
||||
`turn`*: TurnDescription[Cap]
|
||||
`turn`*: TurnDescription
|
||||
|
||||
of ActorActivationKind.`stop`:
|
||||
`stop`*: ActorActivationStop
|
||||
|
||||
|
||||
Target*[Cap] {.preservesRecord: "entity".} = object
|
||||
`actor`*: ActorId[Cap]
|
||||
`facet`*: FacetId[Cap]
|
||||
`oid`*: Oid[Cap]
|
||||
Target* {.preservesRecord: "entity".} = object
|
||||
`actor`*: ActorId
|
||||
`facet`*: FacetId
|
||||
`oid`*: Oid
|
||||
|
||||
TurnCauseKind* {.pure.} = enum
|
||||
`turn`, `cleanup`, `linkedTaskRelease`, `periodicActivation`, `delay`,
|
||||
`external`
|
||||
TurnCauseTurn*[Cap] {.preservesRecord: "caused-by".} = object
|
||||
`id`*: TurnId[Cap]
|
||||
TurnCauseTurn* {.preservesRecord: "caused-by".} = object
|
||||
`id`*: TurnId
|
||||
|
||||
TurnCauseCleanup* {.preservesRecord: "cleanup".} = object
|
||||
|
||||
TurnCauseLinkedTaskRelease*[Cap] {.preservesRecord: "linked-task-release".} = object
|
||||
`id`*: TaskId[Cap]
|
||||
TurnCauseLinkedTaskRelease* {.preservesRecord: "linked-task-release".} = object
|
||||
`id`*: TaskId
|
||||
`reason`*: LinkedTaskReleaseReason
|
||||
|
||||
TurnCausePeriodicActivation* {.preservesRecord: "periodic-activation".} = object
|
||||
`period`*: float64
|
||||
|
||||
TurnCauseDelay*[Cap] {.preservesRecord: "delay".} = object
|
||||
`causingTurn`*: TurnId[Cap]
|
||||
TurnCauseDelay* {.preservesRecord: "delay".} = object
|
||||
`causingTurn`*: TurnId
|
||||
`amount`*: float64
|
||||
|
||||
TurnCauseExternal*[Cap] {.preservesRecord: "external".} = object
|
||||
`description`*: Preserve[Cap]
|
||||
TurnCauseExternal* {.preservesRecord: "external".} = object
|
||||
`description`*: Value
|
||||
|
||||
`TurnCause`*[Cap] {.preservesOr.} = object
|
||||
`TurnCause`* {.preservesOr.} = object
|
||||
case orKind*: TurnCauseKind
|
||||
of TurnCauseKind.`turn`:
|
||||
`turn`*: TurnCauseTurn[Cap]
|
||||
`turn`*: TurnCauseTurn
|
||||
|
||||
of TurnCauseKind.`cleanup`:
|
||||
`cleanup`*: TurnCauseCleanup
|
||||
|
||||
of TurnCauseKind.`linkedTaskRelease`:
|
||||
`linkedtaskrelease`*: TurnCauseLinkedTaskRelease[Cap]
|
||||
`linkedtaskrelease`*: TurnCauseLinkedTaskRelease
|
||||
|
||||
of TurnCauseKind.`periodicActivation`:
|
||||
`periodicactivation`*: TurnCausePeriodicActivation
|
||||
|
||||
of TurnCauseKind.`delay`:
|
||||
`delay`*: TurnCauseDelay[Cap]
|
||||
`delay`*: TurnCauseDelay
|
||||
|
||||
of TurnCauseKind.`external`:
|
||||
`external`*: TurnCauseExternal[Cap]
|
||||
`external`*: TurnCauseExternal
|
||||
|
||||
|
||||
TurnEventKind* {.pure.} = enum
|
||||
`assert`, `retract`, `message`, `sync`, `breakLink`
|
||||
TurnEventAssert*[Cap] {.preservesRecord: "assert".} = object
|
||||
`assertion`*: AssertionDescription[Cap]
|
||||
TurnEventAssert* {.preservesRecord: "assert".} = object
|
||||
`assertion`*: AssertionDescription
|
||||
`handle`*: protocol.Handle
|
||||
|
||||
TurnEventRetract* {.preservesRecord: "retract".} = object
|
||||
`handle`*: protocol.Handle
|
||||
|
||||
TurnEventMessage*[Cap] {.preservesRecord: "message".} = object
|
||||
`body`*: AssertionDescription[Cap]
|
||||
TurnEventMessage* {.preservesRecord: "message".} = object
|
||||
`body`*: AssertionDescription
|
||||
|
||||
TurnEventSync*[Cap] {.preservesRecord: "sync".} = object
|
||||
`peer`*: Target[Cap]
|
||||
TurnEventSync* {.preservesRecord: "sync".} = object
|
||||
`peer`*: Target
|
||||
|
||||
TurnEventBreakLink*[Cap] {.preservesRecord: "break-link".} = object
|
||||
`source`*: ActorId[Cap]
|
||||
TurnEventBreakLink* {.preservesRecord: "break-link".} = object
|
||||
`source`*: ActorId
|
||||
`handle`*: protocol.Handle
|
||||
|
||||
`TurnEvent`*[Cap] {.preservesOr.} = object
|
||||
`TurnEvent`* {.preservesOr.} = object
|
||||
case orKind*: TurnEventKind
|
||||
of TurnEventKind.`assert`:
|
||||
`assert`*: TurnEventAssert[Cap]
|
||||
`assert`*: TurnEventAssert
|
||||
|
||||
of TurnEventKind.`retract`:
|
||||
`retract`*: TurnEventRetract
|
||||
|
||||
of TurnEventKind.`message`:
|
||||
`message`*: TurnEventMessage[Cap]
|
||||
`message`*: TurnEventMessage
|
||||
|
||||
of TurnEventKind.`sync`:
|
||||
`sync`*: TurnEventSync[Cap]
|
||||
`sync`*: TurnEventSync
|
||||
|
||||
of TurnEventKind.`breakLink`:
|
||||
`breaklink`*: TurnEventBreakLink[Cap]
|
||||
`breaklink`*: TurnEventBreakLink
|
||||
|
||||
|
||||
TurnDescription*[Cap] {.preservesRecord: "turn".} = object
|
||||
`id`*: TurnId[Cap]
|
||||
`cause`*: TurnCause[Cap]
|
||||
`actions`*: seq[ActionDescription[Cap]]
|
||||
TurnDescription* {.preservesRecord: "turn".} = object
|
||||
`id`*: TurnId
|
||||
`cause`*: TurnCause
|
||||
`actions`*: seq[ActionDescription]
|
||||
|
||||
ExitStatusKind* {.pure.} = enum
|
||||
`ok`, `Error`
|
||||
|
@ -169,101 +169,95 @@ type
|
|||
`error`*: protocol.Error
|
||||
|
||||
|
||||
TraceEntry*[Cap] {.preservesRecord: "trace".} = object
|
||||
TraceEntry* {.preservesRecord: "trace".} = object
|
||||
`timestamp`*: float64
|
||||
`actor`*: ActorId[Cap]
|
||||
`item`*: ActorActivation[Cap]
|
||||
`actor`*: ActorId
|
||||
`item`*: ActorActivation
|
||||
|
||||
Oid*[Cap] = Preserve[Cap]
|
||||
Oid* = Value
|
||||
ActionDescriptionKind* {.pure.} = enum
|
||||
`dequeue`, `enqueue`, `dequeueInternal`, `enqueueInternal`, `spawn`, `link`,
|
||||
`facetStart`, `facetStop`, `linkedTaskStart`
|
||||
ActionDescriptionDequeue*[Cap] {.preservesRecord: "dequeue".} = object
|
||||
`event`*: TargetedTurnEvent[Cap]
|
||||
ActionDescriptionDequeue* {.preservesRecord: "dequeue".} = object
|
||||
`event`*: TargetedTurnEvent
|
||||
|
||||
ActionDescriptionEnqueue*[Cap] {.preservesRecord: "enqueue".} = object
|
||||
`event`*: TargetedTurnEvent[Cap]
|
||||
ActionDescriptionEnqueue* {.preservesRecord: "enqueue".} = object
|
||||
`event`*: TargetedTurnEvent
|
||||
|
||||
ActionDescriptionDequeueInternal*[Cap] {.preservesRecord: "dequeue-internal".} = object
|
||||
`event`*: TargetedTurnEvent[Cap]
|
||||
ActionDescriptionDequeueInternal* {.preservesRecord: "dequeue-internal".} = object
|
||||
`event`*: TargetedTurnEvent
|
||||
|
||||
ActionDescriptionEnqueueInternal*[Cap] {.preservesRecord: "enqueue-internal".} = object
|
||||
`event`*: TargetedTurnEvent[Cap]
|
||||
ActionDescriptionEnqueueInternal* {.preservesRecord: "enqueue-internal".} = object
|
||||
`event`*: TargetedTurnEvent
|
||||
|
||||
ActionDescriptionSpawn*[Cap] {.preservesRecord: "spawn".} = object
|
||||
ActionDescriptionSpawn* {.preservesRecord: "spawn".} = object
|
||||
`link`*: bool
|
||||
`id`*: ActorId[Cap]
|
||||
`id`*: ActorId
|
||||
|
||||
ActionDescriptionLink*[Cap] {.preservesRecord: "link".} = object
|
||||
`parentActor`*: ActorId[Cap]
|
||||
ActionDescriptionLink* {.preservesRecord: "link".} = object
|
||||
`parentActor`*: ActorId
|
||||
`childToParent`*: protocol.Handle
|
||||
`childActor`*: ActorId[Cap]
|
||||
`childActor`*: ActorId
|
||||
`parentToChild`*: protocol.Handle
|
||||
|
||||
ActionDescriptionFacetStart*[Cap] {.preservesRecord: "facet-start".} = object
|
||||
`path`*: seq[FacetId[Cap]]
|
||||
ActionDescriptionFacetStart* {.preservesRecord: "facet-start".} = object
|
||||
`path`*: seq[FacetId]
|
||||
|
||||
ActionDescriptionFacetStop*[Cap] {.preservesRecord: "facet-stop".} = object
|
||||
`path`*: seq[FacetId[Cap]]
|
||||
ActionDescriptionFacetStop* {.preservesRecord: "facet-stop".} = object
|
||||
`path`*: seq[FacetId]
|
||||
`reason`*: FacetStopReason
|
||||
|
||||
ActionDescriptionLinkedTaskStart*[Cap] {.preservesRecord: "linked-task-start".} = object
|
||||
`taskName`*: Name[Cap]
|
||||
`id`*: TaskId[Cap]
|
||||
ActionDescriptionLinkedTaskStart* {.preservesRecord: "linked-task-start".} = object
|
||||
`taskName`*: Name
|
||||
`id`*: TaskId
|
||||
|
||||
`ActionDescription`*[Cap] {.preservesOr.} = object
|
||||
`ActionDescription`* {.preservesOr.} = object
|
||||
case orKind*: ActionDescriptionKind
|
||||
of ActionDescriptionKind.`dequeue`:
|
||||
`dequeue`*: ActionDescriptionDequeue[Cap]
|
||||
`dequeue`*: ActionDescriptionDequeue
|
||||
|
||||
of ActionDescriptionKind.`enqueue`:
|
||||
`enqueue`*: ActionDescriptionEnqueue[Cap]
|
||||
`enqueue`*: ActionDescriptionEnqueue
|
||||
|
||||
of ActionDescriptionKind.`dequeueInternal`:
|
||||
`dequeueinternal`*: ActionDescriptionDequeueInternal[Cap]
|
||||
`dequeueinternal`*: ActionDescriptionDequeueInternal
|
||||
|
||||
of ActionDescriptionKind.`enqueueInternal`:
|
||||
`enqueueinternal`*: ActionDescriptionEnqueueInternal[Cap]
|
||||
`enqueueinternal`*: ActionDescriptionEnqueueInternal
|
||||
|
||||
of ActionDescriptionKind.`spawn`:
|
||||
`spawn`*: ActionDescriptionSpawn[Cap]
|
||||
`spawn`*: ActionDescriptionSpawn
|
||||
|
||||
of ActionDescriptionKind.`link`:
|
||||
`link`*: ActionDescriptionLink[Cap]
|
||||
`link`*: ActionDescriptionLink
|
||||
|
||||
of ActionDescriptionKind.`facetStart`:
|
||||
`facetstart`*: ActionDescriptionFacetStart[Cap]
|
||||
`facetstart`*: ActionDescriptionFacetStart
|
||||
|
||||
of ActionDescriptionKind.`facetStop`:
|
||||
`facetstop`*: ActionDescriptionFacetStop[Cap]
|
||||
`facetstop`*: ActionDescriptionFacetStop
|
||||
|
||||
of ActionDescriptionKind.`linkedTaskStart`:
|
||||
`linkedtaskstart`*: ActionDescriptionLinkedTaskStart[Cap]
|
||||
`linkedtaskstart`*: ActionDescriptionLinkedTaskStart
|
||||
|
||||
|
||||
proc `$`*[Cap](x: TargetedTurnEvent[Cap] | AssertionDescription[Cap] | Name[Cap] |
|
||||
ActorActivation[Cap] |
|
||||
Target[Cap] |
|
||||
TurnCause[Cap] |
|
||||
TurnEvent[Cap] |
|
||||
TurnDescription[Cap] |
|
||||
TraceEntry[Cap] |
|
||||
ActionDescription[Cap]): string =
|
||||
`$`(toPreserve(x, Cap))
|
||||
proc `$`*(x: TargetedTurnEvent | AssertionDescription | Name | ActorActivation |
|
||||
Target |
|
||||
TurnCause |
|
||||
TurnEvent |
|
||||
TurnDescription |
|
||||
ExitStatus |
|
||||
TraceEntry |
|
||||
ActionDescription): string =
|
||||
`$`(toPreserves(x))
|
||||
|
||||
proc encode*[Cap](x: TargetedTurnEvent[Cap] | AssertionDescription[Cap] |
|
||||
Name[Cap] |
|
||||
ActorActivation[Cap] |
|
||||
Target[Cap] |
|
||||
TurnCause[Cap] |
|
||||
TurnEvent[Cap] |
|
||||
TurnDescription[Cap] |
|
||||
TraceEntry[Cap] |
|
||||
ActionDescription[Cap]): seq[byte] =
|
||||
encode(toPreserve(x, Cap))
|
||||
|
||||
proc `$`*(x: ExitStatus): string =
|
||||
`$`(toPreserve(x))
|
||||
|
||||
proc encode*(x: ExitStatus): seq[byte] =
|
||||
encode(toPreserve(x))
|
||||
proc encode*(x: TargetedTurnEvent | AssertionDescription | Name |
|
||||
ActorActivation |
|
||||
Target |
|
||||
TurnCause |
|
||||
TurnEvent |
|
||||
TurnDescription |
|
||||
ExitStatus |
|
||||
TraceEntry |
|
||||
ActionDescription): seq[byte] =
|
||||
encode(toPreserves(x))
|
||||
|
|
|
@ -16,7 +16,7 @@ type
|
|||
`port`*: BiggestInt
|
||||
|
||||
proc `$`*(x: WebSocket | Stdio | Unix | Tcp): string =
|
||||
`$`(toPreserve(x))
|
||||
`$`(toPreserves(x))
|
||||
|
||||
proc encode*(x: WebSocket | Stdio | Unix | Tcp): seq[byte] =
|
||||
encode(toPreserve(x))
|
||||
encode(toPreserves(x))
|
||||
|
|
|
@ -3,12 +3,12 @@ import
|
|||
preserves
|
||||
|
||||
type
|
||||
Instance*[Cap] {.preservesRecord: "Instance".} = object
|
||||
Instance* {.preservesRecord: "Instance".} = object
|
||||
`name`*: string
|
||||
`argument`*: Preserve[Cap]
|
||||
`argument`*: Value
|
||||
|
||||
proc `$`*[Cap](x: Instance[Cap]): string =
|
||||
`$`(toPreserve(x, Cap))
|
||||
proc `$`*(x: Instance): string =
|
||||
`$`(toPreserves(x))
|
||||
|
||||
proc encode*[Cap](x: Instance[Cap]): seq[byte] =
|
||||
encode(toPreserve(x, Cap))
|
||||
proc encode*(x: Instance): seq[byte] =
|
||||
encode(toPreserves(x))
|
||||
|
|
|
@ -22,9 +22,8 @@ type
|
|||
export Stdio, Tcp, WebSocket, Unix
|
||||
|
||||
type
|
||||
Value = Preserve[void]
|
||||
Assertion = Preserve[Cap]
|
||||
WireRef = sturdy.WireRef[void]
|
||||
Assertion = Value
|
||||
WireRef = sturdy.WireRef
|
||||
Turn = syndicate.Turn
|
||||
|
||||
type
|
||||
|
@ -78,7 +77,7 @@ proc newSyncPeerEntity(r: Relay; p: Cap): SyncPeerEntity =
|
|||
|
||||
proc rewriteCapOut(relay: Relay; cap: Cap; exported: var seq[WireSymbol]): WireRef =
|
||||
if cap.target of RelayEntity and cap.target.RelayEntity.relay == relay and cap.attenuation.len == 0:
|
||||
WireRef(orKind: WireRefKind.yours, yours: WireRefYours[void](oid: cap.target.oid))
|
||||
WireRef(orKind: WireRefKind.yours, yours: WireRefYours(oid: cap.target.oid))
|
||||
else:
|
||||
var ws = grab(relay.exported, cap)
|
||||
if ws.isNil:
|
||||
|
@ -93,7 +92,7 @@ proc rewriteOut(relay: Relay; v: Assertion):
|
|||
tuple[rewritten: Value, exported: seq[WireSymbol]] {.gcsafe.} =
|
||||
var exported: seq[WireSymbol]
|
||||
result.rewritten = contract(v) do (r: Cap) -> Value:
|
||||
rewriteCapOut(relay, r, exported).toPreserve
|
||||
rewriteCapOut(relay, r, exported).toPreserves
|
||||
result.exported = exported
|
||||
|
||||
proc register(relay: Relay; v: Assertion; h: Handle): tuple[rewritten: Value, exported: seq[WireSymbol]] =
|
||||
|
@ -185,9 +184,9 @@ proc rewriteIn(relay; facet; v: Value):
|
|||
var imported: seq[WireSymbol]
|
||||
result.rewritten = expand(v) do (pr: Value) -> Assertion:
|
||||
var wr: WireRef
|
||||
if not fromPreserve(wr, pr):
|
||||
if not wr.fromPreserves(pr):
|
||||
raiseAssert "expansion of embedded value failed"
|
||||
rewriteCapIn(relay, facet, wr, imported).toPreserve(Cap)
|
||||
rewriteCapIn(relay, facet, wr, imported).toPreserves
|
||||
result.imported = imported
|
||||
|
||||
proc close(r: Relay) = discard
|
||||
|
@ -224,7 +223,7 @@ proc dispatch*(relay: Relay; v: Value) {.gcsafe.} =
|
|||
trace "S: ", v
|
||||
run(relay.facet) do (t: var Turn):
|
||||
var pkt: Packet
|
||||
if fromPreserve(pkt, v):
|
||||
if pkt.fromPreserves(v):
|
||||
case pkt.orKind
|
||||
of PacketKind.Turn:
|
||||
# https://synit.org/book/protocol.html#turn-packets
|
||||
|
@ -263,9 +262,9 @@ proc newRelay(turn: var Turn; opts: RelayOptions; setup: RelaySetup): Relay =
|
|||
discard result.facet.preventInertCheck()
|
||||
setup(turn, result)
|
||||
|
||||
proc transportConnectionResolve(addrAss: Assertion; ds: Cap): gatekeeper.TransportConnection[Cap] =
|
||||
proc transportConnectionResolve(addrAss: Assertion; ds: Cap): gatekeeper.TransportConnection =
|
||||
result.`addr` = addrAss
|
||||
result.resolved = Resolved[Cap](orKind: ResolvedKind.accepted)
|
||||
result.resolved = Resolved(orKind: ResolvedKind.accepted)
|
||||
result.resolved.accepted.responderSession = ds
|
||||
|
||||
proc spawnRelay*(name: string; turn: var Turn; ds: Cap; addrAss: Assertion; opts: RelayActorOptions; setup: RelaySetup) =
|
||||
|
@ -305,7 +304,7 @@ export Tcp
|
|||
when defined(posix):
|
||||
export Unix
|
||||
|
||||
proc connect*(turn: var Turn; ds: Cap; route: Route; addrAss: Assertion; socket: AsyncSocket; step: Preserve[Cap]) =
|
||||
proc connect*(turn: var Turn; ds: Cap; route: Route; addrAss: Assertion; socket: AsyncSocket; step: Value) =
|
||||
## Relay a dataspace over an open `AsyncSocket`.
|
||||
proc socketWriter(packet: sink Packet): Future[void] =
|
||||
socket.send(cast[string](encode(packet)))
|
||||
|
@ -339,28 +338,28 @@ when defined(posix):
|
|||
turn.facet.actor.atExit do (turn: var Turn): close(socket)
|
||||
discard publish(turn, connectionClosedCap, true)
|
||||
shutdownCap = newCap(turn, ShutdownEntity())
|
||||
onPublish(turn, ds, TransportConnection[Cap] ?: {0: ?addrAss, 2: ?:Rejected[Cap]}) do (detail: Value):
|
||||
onPublish(turn, ds, TransportConnection ?: {0: ?addrAss, 2: ?:Rejected}) do (detail: Value):
|
||||
raise newException(IOError, $detail)
|
||||
onPublish(turn, ds, TransportConnection[Cap] ?: {0: ?addrAss, 2: ?:ResolvedAccepted[Cap]}) do (gatekeeper: Cap):
|
||||
onPublish(turn, ds, TransportConnection ?: {0: ?addrAss, 2: ?:ResolvedAccepted}) do (gatekeeper: Cap):
|
||||
run(gatekeeper.relay) do (turn: var Turn):
|
||||
reenable()
|
||||
discard publish(turn, shutdownCap, true)
|
||||
proc duringCallback(turn: var Turn; ass: Assertion; h: Handle): TurnAction =
|
||||
let facet = inFacet(turn) do (turn: var Turn):
|
||||
var resolvePath = ResolvePath[Cap](route: route, `addr`: addrAss)
|
||||
if resolvePath.resolved.fromPreserve(ass):
|
||||
var resolvePath = ResolvePath(route: route, `addr`: addrAss)
|
||||
if resolvePath.resolved.fromPreserves(ass):
|
||||
discard publish(turn, ds, resolvePath)
|
||||
else:
|
||||
raise newException(CatchableError, "unhandled gatekeeper response " & $ass)
|
||||
proc action(turn: var Turn) =
|
||||
stop(turn, facet)
|
||||
result = action
|
||||
discard publish(turn, gatekeeper, Resolve[Cap](
|
||||
discard publish(turn, gatekeeper, Resolve(
|
||||
step: step,
|
||||
observer: newCap(turn, during(duringCallback)),
|
||||
))
|
||||
|
||||
proc connect*(turn: var Turn; ds: Cap; route: Route; transport: Tcp; step: Preserve[Cap]) =
|
||||
proc connect*(turn: var Turn; ds: Cap; route: Route; transport: Tcp; step: Value) =
|
||||
## Relay a dataspace over TCP.
|
||||
let socket = newAsyncSocket(
|
||||
domain = AF_INET,
|
||||
|
@ -369,9 +368,9 @@ when defined(posix):
|
|||
buffered = false)
|
||||
let fut = connect(socket, transport.host, Port transport.port)
|
||||
addCallback(fut, turn) do (turn: var Turn):
|
||||
connect(turn, ds, route, transport.toPreserve(Cap), socket, step)
|
||||
connect(turn, ds, route, transport.toPreserves, socket, step)
|
||||
|
||||
proc connect*(turn: var Turn; ds: Cap; route: Route; transport: Unix; step: Preserve[Cap]) =
|
||||
proc connect*(turn: var Turn; ds: Cap; route: Route; transport: Unix; step: Value) =
|
||||
## Relay a dataspace over a UNIX socket.
|
||||
let socket = newAsyncSocket(
|
||||
domain = AF_UNIX,
|
||||
|
@ -380,7 +379,7 @@ when defined(posix):
|
|||
buffered = false)
|
||||
let fut = connectUnix(socket, transport.path)
|
||||
addCallback(fut, turn) do (turn: var Turn):
|
||||
connect(turn, ds, route, transport.toPreserve(Cap), socket, step)
|
||||
connect(turn, ds, route, transport.toPreserves, socket, step)
|
||||
|
||||
import std/asyncfile
|
||||
|
||||
|
@ -398,7 +397,7 @@ when defined(posix):
|
|||
packetWriter: stdoutWriter,
|
||||
initialCap: ds,
|
||||
initialOid: 0.Oid.some)
|
||||
spawnRelay("stdio", turn, ds, Stdio().toPreserve(Cap), opts) do (turn: var Turn; relay: Relay):
|
||||
spawnRelay("stdio", turn, ds, Stdio().toPreserves, opts) do (turn: var Turn; relay: Relay):
|
||||
let
|
||||
facet = turn.facet
|
||||
asyncStdin = openAsync("/dev/stdin") # this is universal now?
|
||||
|
@ -421,15 +420,15 @@ when defined(posix):
|
|||
|
||||
type BootProc* = proc (turn: var Turn; ds: Cap) {.gcsafe.}
|
||||
|
||||
proc envRoute*: Route[Cap] =
|
||||
proc envRoute*: Route =
|
||||
var text = getEnv("SYNDICATE_ROUTE")
|
||||
if text == "":
|
||||
var tx = (getEnv("XDG_RUNTIME_DIR", "/run/user/1000") / "dataspace").toPreserve(Cap)
|
||||
var tx = (getEnv("XDG_RUNTIME_DIR", "/run/user/1000") / "dataspace").toPreserves
|
||||
result.transports = @[initRecord("unix", tx)]
|
||||
result.pathSteps = @[capabilities.mint().toPreserve(Cap)]
|
||||
result.pathSteps = @[capabilities.mint().toPreserves]
|
||||
else:
|
||||
var pr = parsePreserves(text, Cap)
|
||||
if not result.fromPreserve(pr):
|
||||
if not result.fromPreserves(pr):
|
||||
raise newException(ValueError, "failed to parse $SYNDICATE_ROUTE " & $pr)
|
||||
|
||||
proc resolve*(turn: var Turn; ds: Cap; route: Route; bootProc: BootProc) =
|
||||
|
@ -439,15 +438,15 @@ proc resolve*(turn: var Turn; ds: Cap; route: Route; bootProc: BootProc) =
|
|||
stdio: Stdio
|
||||
doAssert(route.transports.len == 1, "only a single transport supported for routes")
|
||||
doAssert(route.pathSteps.len < 2, "multiple path steps not supported for routes")
|
||||
if unix.fromPreserve route.transports[0]:
|
||||
if unix.fromPreserves route.transports[0]:
|
||||
connect(turn, ds, route, unix, route.pathSteps[0])
|
||||
elif tcp.fromPreserve route.transports[0]:
|
||||
elif tcp.fromPreserves route.transports[0]:
|
||||
connect(turn, ds, route, tcp, route.pathSteps[0])
|
||||
elif stdio.fromPreserve route.transports[0]:
|
||||
elif stdio.fromPreserves route.transports[0]:
|
||||
connectStdio(turn, ds)
|
||||
bootProc(turn, ds)
|
||||
else:
|
||||
raise newException(ValueError, "unsupported route")
|
||||
|
||||
during(turn, ds, ResolvePath[Cap] ?: { 0: ?route, 3: ?:ResolvedAccepted[Cap]}) do (dest: Cap):
|
||||
during(turn, ds, ResolvePath ?: { 0: ?route, 3: ?:ResolvedAccepted}) do (dest: Cap):
|
||||
bootProc(turn, dest)
|
||||
|
|
|
@ -9,9 +9,8 @@ import ./actors, ./bags, ./patterns
|
|||
import ./protocols/dataspacePatterns
|
||||
|
||||
type
|
||||
DCompound = dataspacePatterns.DCompound[Cap]
|
||||
Pattern = dataspacePatterns.Pattern[Cap]
|
||||
Value = Preserve[Cap]
|
||||
DCompound = dataspacePatterns.DCompound
|
||||
Pattern = dataspacePatterns.Pattern
|
||||
Path = seq[Value]
|
||||
ClassKind = enum classNone, classRecord, classSequence, classDictionary
|
||||
Class = object
|
||||
|
@ -178,7 +177,7 @@ proc modify(node: Node; turn: var Turn; outerValue: Value; event: EventKind;
|
|||
if event == removedEvent and nextNode.isEmpty:
|
||||
table.del(nextClass)
|
||||
|
||||
walk(node, turn, @[@[outerValue].toPreserve(Cap)])
|
||||
walk(node, turn, @[@[outerValue].toPreserves])
|
||||
|
||||
proc getOrNew[A, B, C](t: var Table[A, TableRef[B, C]], k: A): TableRef[B, C] =
|
||||
result = t.getOrDefault(k)
|
||||
|
@ -190,10 +189,10 @@ iterator pairs(dc: DCompound): (Value, Pattern) =
|
|||
case dc.orKind
|
||||
of DCompoundKind.rec:
|
||||
for i, p in dc.rec.fields:
|
||||
yield (toPreserve(i, Cap), p,)
|
||||
yield (i.toPreserves, p,)
|
||||
of DCompoundKind.arr:
|
||||
for i, p in dc.arr.items:
|
||||
yield (toPreserve(i, Cap), p,)
|
||||
yield (i.toPreserves, p,)
|
||||
of DCompoundKind.dict:
|
||||
for pair in dc.dict.entries.pairs:
|
||||
yield pair
|
||||
|
@ -227,7 +226,7 @@ proc extendWalk(node: Node; popCount: Natural; stepIndex: Value; pat: Pattern; p
|
|||
|
||||
proc extend(node: var Node; pat: Pattern): Continuation =
|
||||
var path: Path
|
||||
extendWalk(node, 0, toPreserve(0, Cap), pat, path).nextNode.continuation
|
||||
extendWalk(node, 0, 0.toPreserves, pat, path).nextNode.continuation
|
||||
|
||||
type
|
||||
Index* = object
|
||||
|
@ -293,7 +292,7 @@ proc adjustAssertion(index: var Index; turn: var Turn; outerValue: Value; delta:
|
|||
let change = group.cachedCaptures.change(vs, +1)
|
||||
if change == cdAbsentToPresent:
|
||||
for (observer, captureMap) in group.observers.pairs:
|
||||
captureMap[vs] = publish(turn, observer, vs.toPreserve(Cap))
|
||||
captureMap[vs] = publish(turn, observer, vs.toPreserves)
|
||||
# TODO: this handle is coming from the facet?
|
||||
modify(index.root, turn, outerValue, addedEvent, modContinuation, modLeaf, modObserver)
|
||||
of cdPresentToAbsent:
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# Package
|
||||
|
||||
version = "20231229"
|
||||
version = "20231231"
|
||||
author = "Emery Hemingway"
|
||||
description = "Syndicated actors for conversational concurrency"
|
||||
license = "Unlicense"
|
||||
|
|
|
@ -15,9 +15,9 @@ test "patterns":
|
|||
|
||||
let
|
||||
worte = @["alles", "in", "ordnung"]
|
||||
observer = Observe(pattern: inject(?:Foo, { 0: ?worte })).toPreserve(Cap)
|
||||
have = capture(observerPat, observer).toPreserve(Cap).unpackLiterals
|
||||
want = [worte.toPreserve].toPreserve(Cap)
|
||||
observer = Observe(pattern: inject(?:Foo, { 0: ?worte })).toPreserves
|
||||
have = capture(observerPat, observer).toPreserves.unpackLiterals
|
||||
want = [worte.toPreserves].toPreserves
|
||||
check(have == want)
|
||||
|
||||
type Obj {.preservesDictionary.} = object
|
||||
|
@ -26,15 +26,15 @@ type Obj {.preservesDictionary.} = object
|
|||
test "dictionaries":
|
||||
let pat = ?:Obj
|
||||
var source = initDictionary(Cap)
|
||||
source["b".toSymbol(Cap)] = 2.toPreserve(Cap)
|
||||
source["c".toSymbol(Cap)] = 3.toPreserve(Cap)
|
||||
source["a".toSymbol(Cap)] = 1.toPreserve(Cap)
|
||||
source["b".toSymbol] = 2.toPreserves
|
||||
source["c".toSymbol] = 3.toPreserves
|
||||
source["a".toSymbol] = 1.toPreserves
|
||||
|
||||
let values = capture(pat, source)
|
||||
check values.len == 3
|
||||
check values[0] == 1.toPreserve(Cap)
|
||||
check values[1] == 2.toPreserve(Cap)
|
||||
check values[2] == 3.toPreserve(Cap)
|
||||
check values[0] == 1.toPreserves
|
||||
check values[1] == 2.toPreserves
|
||||
check values[2] == 3.toPreserves
|
||||
|
||||
type
|
||||
File {.preservesDictionary.} = object
|
||||
|
@ -55,4 +55,4 @@ test "literals":
|
|||
var pr = parsePreserves(txt, Cap)
|
||||
|
||||
var capture: Literal[Request]
|
||||
check capture.fromPreserve(pr)
|
||||
check capture.fromPreserves(pr)
|
||||
|
|
|
@ -4,7 +4,7 @@ import preserves
|
|||
import syndicate/relays
|
||||
import syndicate/protocols/sturdy
|
||||
|
||||
type WireRef = sturdy.WireRef[void]
|
||||
type WireRef = sturdy.WireRef
|
||||
|
||||
suite "protocols":
|
||||
test "PDiscard":
|
||||
|
|
|
@ -9,7 +9,7 @@ type
|
|||
`z`*: BiggestInt
|
||||
|
||||
proc `$`*(x: Foo): string =
|
||||
`$`(toPreserve(x))
|
||||
`$`(toPreserves(x))
|
||||
|
||||
proc encode*(x: Foo): seq[byte] =
|
||||
encode(toPreserve(x))
|
||||
encode(toPreserves(x))
|
||||
|
|
Loading…
Reference in New Issue