# Copyright 2003-2004 Kevin Reid. # This source code and related files are distributed under the MIT License, as described in the document named "License.txt" which should be provided with this source distribution. pragma.syntax("0.8") pragma.enable("noun-string") def := def := def lazy := def Description := lazy(fn{ }) def Entrance := lazy(fn{ }) def JPanel__quasiParser := lazy(fn{ }) def description__quasiParser := def makeInspectorReference := lazy(fn{ }) def makeLamportSlot := def makePropertyTextField := lazy(fn{ }) def makeThing := lazy(fn{ }) def makeExit { to __optUncall() :any { return [, "get", [meta.context().getFQNPrefix().split("$")[0]]] } to run([ => self := (def ::"exit"; ::"exit"), "super" => optSuper := null, => var destination :rcvr[Entrance], => var optOriginInterior := null, "message" => initMessage := description`%?(en:%exterior:I; %!:(goes/go) %exit:i;.%|jbo:%exterior:i; cliva fi %exit:i;%)` ] | superArgs) :any { def &message := makeLamportSlot(Description, initMessage) bind ::"exit" extends if (optSuper != null) { optSuper } else { makeThing([=> self] | superArgs | ["name" => "exit", "description" => description``]) } { to __optUncall() :any { [makeExit, "run", [[=> self, => super, => destination, => optOriginInterior, => message]]] } to __conformTo(guard) :any { if (guard.__respondsTo("isDenDetailGuard", 0) && guard.isDenDetailGuard()) { def outerPanel def superDetail := guard.sprout().coerce(super).getComponent() def destinationInspectorComponent := makeInspectorReference.asStatic("destination", destination, false) def optOriginInteriorInspectorComponent := makeInspectorReference.asStatic("optOriginInterior", optOriginInterior, false) def messageField := makePropertyTextField(self, "message", "transformer" => description__quasiParser.getTransformer()) bind outerPanel := JPanel` ${superDetail}.X.Y > ${("Message: ")} $messageField.X ${("Destination: ")} $destinationInspectorComponent.X.Y ${("Origin Interior: ")} $optOriginInteriorInspectorComponent.X.Y ` def detail { to isDenDetail() :any { true } to getComponent() :any { outerPanel } } } else { ::"exit" } } to getDestination() :any { destination } to setDestination(new) :void { destination := new } to getMessage() :any { message } to getMessageReporter() :any { (&message).readOnly() } to setMessage(new) :void { message := new } to getOptOriginInterior() :any { optOriginInterior } to setOptOriginInterior(new) :void { optOriginInterior := new } to exterior_getOptEntrance() :any { # FIXME: make events for the appropriate container. Currently, we may end up giving an event for the wrong location, which will naturally be ignored/complained about. def entrance implements Entrance { to __optSealedDispatch(brand) :any { switch (brand) { match ==(self.getOwner().getEditSealer().getBrand()) { self.getOwner().getEditSealer().seal(self) } match _ { null } } } /** see Entrance */ to admit(admitExteriorBox, admitIdentity :SturdyRef, admitOptions) :any { def wait := if (admitOptions.fetch("departureEventResolver", fn{}) =~ resRcvr :notNull) { resRcvr <- resolve({ def location := self.getExterior().getLocation() def assertions := [ "org.cubik.den.eventDescription" => description__quasiParser.substitute(message, ["exterior" => admitIdentity, "exit" => self.getExterior().getIdentityHolder().getIdentity()]), ] def event := location <- makeEvent() when ( if (optOriginInterior != null) { optOriginInterior.getIdentityHolder().makeAssertions(event, assertions) }, self.getIdentityHolder().makeAssertions(event, assertions) ) -> doneAssert(_, _) :any { event } catch p { throw(p) } }) } when (wait) -> doneWaitEventSlot(_) :any { destination <- admit(admitExteriorBox, admitIdentity, admitOptions) } catch p { throw(p) } } /** see Entrance */ to look() :any { destination <- look() } } } to exterior_didChangeLocation() :void { if (optOriginInterior != null) { self.getOwner().trace("exit", `$self discarding optOriginInterior $optOriginInterior due to move`) optOriginInterior := null } super.exterior_didChangeLocation() } to interact_moveInto([[inModes, outModes], optAllegedActor], entrance, options) :vow[void] { throw("not moving") } } #end bind exit } #end run } ? def makeExit := # value: ?# fixme: more updoc