BluejayUtilsImpl.mesa
Last Edited by: Swinehart, June 19, 1984 7:49:37 am PDT
DIRECTORY
BluejaySmarts USING [ handle ],
BluejayUtils,
BluejayUtilsRpcControl USING [ ExportInterface, InterfaceName, UnexportInterface ],
Jukebox USING [ CloseTune, CreateTune, DeleteTune, Error, Info, OpenTune, Tune, TuneSize ],
LupineRuntime USING [ BindingError ],
Names USING [ CurrentPasskey ],
Log USING [ Report ],
Thrush USING [ nullTune, Tune ],
ThVersions USING [ JayVR ],
UserProfile USING [ Token ]
;
BluejayUtilsImpl: CEDAR PROGRAM
IMPORTS BluejaySmarts, BluejayUtilsRpcControl, Jukebox, LupineRuntime, Names, Log, ThVersions, UserProfile
EXPORTS BluejayUtils = {
myName: BluejayUtilsRpcControl.InterfaceName;
utilsExported: BOOLFALSE;
Tune: TYPE = Thrush.Tune;
DescribeTune: PUBLIC PROC[tune: Tune]
RETURNS [exists: BOOLTRUE, size: INT] = TRUSTED {
t: Jukebox.Tune = Jukebox.OpenTune[self: BluejaySmarts.handle, tuneId: tune, write: FALSE!
Jukebox.Error=>GOTO NoTune];
size ← Jukebox.TuneSize[t];
Jukebox.CloseTune[BluejaySmarts.handle, t];
EXITS
NoTune => exists←FALSE;
};
DeleteTune: PUBLIC PROC[tune: Tune] RETURNS [existed: BOOLTRUE] = TRUSTED {
Jukebox.DeleteTune[BluejaySmarts.handle, tune!Jukebox.Error => GOTO NoTune];
EXITS
NoTune => existed←FALSE;
};
NewTune: PUBLIC PROC RETURNS [tune: Tune←Thrush.nullTune] = TRUSTED {
t: Jukebox.Tune = Jukebox.CreateTune[self: BluejaySmarts.handle, tuneId: -1!Jukebox.Error=>GOTO NoTune];
tune ← t.tuneId;
Jukebox.CloseTune[BluejaySmarts.handle, t!Jukebox.Error=>GOTO NoTune];
EXITS
NoTune => NULL;
};
TunesInJukebox: PUBLIC PROC RETURNS [nTunes: INT𡤀] = TRUSTED {
nTunes ← Jukebox.Info[BluejaySmarts.handle!Jukebox.Error=>GOTO Problem].nTunes;
EXITS
Problem => NULL;
};
InitializeJukebox: PUBLIC PROC = TRUSTED {
nTunes: NAT = TunesInJukebox[];
FOR i: NAT IN [0..nTunes) DO
Jukebox.DeleteTune[BluejaySmarts.handle, i!Jukebox.Error=>CONTINUE]; ENDLOOP;
};
Initialize: PUBLIC PROC = {
Uninitialize[];
myName ← [
type: "BluejayUtils.Lark",
instance: UserProfile.Token[key: "BluejayServerInstance", default: "Lampson.Lark"],
version: ThVersions.JayVR
];
BluejayUtilsRpcControl.ExportInterface[
interfaceName: myName,
user: myName.instance,
password: Names.CurrentPasskey[UserProfile.Token[
key: "BluejayServerPassword", default: "MFLFLX"]]];
Log.Report["Bluejay Utility interface Initialized and Exported", $Bluejay];
utilsExported ← TRUE;
};
Uninitialize: PUBLIC PROC = {
IF utilsExported THEN
BluejayUtilsRpcControl.UnexportInterface[!LupineRuntime.BindingError=>CONTINUE];
Log.Report["Bluejay Utility interface Unexported", $Bluejay];
utilsExported ← FALSE;
};
}.