File [Ivy]<Nelson>Lupine>LupineMakeRpcModulesImpl.mesa.
Last edited by BZM on 11-May-82 16:25:46.
Last Edited by: Birrell, September 14, 1983 9:05 am
DIRECTORY
LupineDeclare
USING [
BindingInterface, BindingRoutinesDynamic,
BindingRoutinesPrivate, BindingRoutinesStandard,
DispatcherHead, DispatcherSelect,
DispatcherStubArm, DispatcherStubBody, DispatcherTail,
Directory, DirectoryItem, ModuleHead, ProcedureIndex, ProcedureStub,
SignalCatchStub, SignalCode, SignalIndex ],
LupineMakeRpcModules USING [],
LupineManagerPrivate
USING [
CloseCodeFile, Indent, Language, ModuleName, Nest,
OpenCodeFile, Options, StampCodeFile, StampTranslationOptions,
String, StringNIL, WF1, WFL1, WFS1, WFS, WFSL ],
LupineMarshal USING [ParameterProtocolVersions],
LupineSymbolTable USING [EnumerateTransfers, TransferProcedure];
LupineMakeRpcModulesImpl:
PROGRAM
IMPORTS
Declare: LupineDeclare, LupineManagerPrivate,
Marshal: LupineMarshal, ST: LupineSymbolTable
EXPORTS LupineMakeRpcModules =
BEGIN OPEN LupineMakeRpcModules, LupineManagerPrivate;
MakeRpcControlModule:
PUBLIC
PROCEDURE [options: Options] =
BEGIN
controlModuleNames: ARRAY [0..1) OF String ← [ModuleName[control]];
controlDirectoryList:
ARRAY [0..2)
OF Declare.DirectoryItem ← [
[module: ModuleName[interface],
openName: ModuleName[openedInterface],
usedIn: [shares: TRUE, beginOpen: TRUE] ],
[module: ModuleName[rpcPublic],
usingAll: "defaultInterfaceName, EncryptionKey, InterfaceName, Principal, standardZones, VersionRange, Zones",
openName: "RpcPublic",
usedIn: [beginOpen: TRUE] ] ];
oldest, newest: LONG INTEGER;
[oldestSupported: oldest, newestSupported: newest]
← Marshal.ParameterProtocolVersions[];
OpenCodeFile[ModuleName[control]];
BEGIN ENABLE UNWIND => CloseCodeFile;
StampCodeFile[ModuleName[control]];
StampModuleNames;
StampTranslationOptions[options];
Declare.Directory [
includeInterfaceDirectory: TRUE,
extraDirectories: DESCRIPTOR[controlDirectoryList],
options: options ];
Declare.ModuleHead [
moduleNames: DESCRIPTOR[controlModuleNames],
moduleType: "DEFINITIONS",
interfaceList: DESCRIPTOR[controlDirectoryList],
options: options ];
Declare.BindingInterface[options];
WFS1["
-- Definitions for the stubs.
LupineProtocolVersion: PUBLIC VersionRange = "];
WF1["[first: %g", [integer[oldest]]]; WF1[", last: %g]", [integer[newest]]];
WFS[";
InterMdsCallsOnly: PUBLIC BOOLEAN = ",
(IF options.defaultParamPassing=InterMds THEN "TRUE" ELSE "FALSE"),
";\n"];
Declare.ProcedureIndex[];
Declare.SignalIndex[];
WFS["
END. -- ", ModuleName[control], ".\n"];
END; -- ENABLE UNWIND => CloseCodeFile.
CloseCodeFile[];
END; -- MakeRpcControlModule.
MakeRpcClientModule:
PUBLIC
PROCEDURE [options: Options] =
BEGIN
clientModuleNames: ARRAY [0..1) OF String ← [ModuleName[client]];
clientDirectoryList: ARRAY [0..7) OF Declare.DirectoryItem ← [
Common directory items:
[module: ModuleName[interface],
openName: ModuleName[openedInterface],
usedIn: [exports:
TRUE, shares:
TRUE, beginOpen:
TRUE,
imports: NOT options.declareSignals] ],
[module: ModuleName[control],
openName: "RpcControl",
usedIn: [exports: TRUE, shares: TRUE, beginOpen: TRUE],
usingAll: "InterMdsCallsOnly, LupineProtocolVersion, ProcedureIndex, SignalIndex" ],
[module: ModuleName[rpcPublic],
openName: "RpcPublic",
usedIn: [beginOpen: TRUE],
usingAll: "InterfaceName, standardZones, Zones" ],
[module: ModuleName[rpcPrivate],
openName: "RpcPrivate",
usedIn: [imports: TRUE],
usingSome: "Call, DataLength, Dispatcher, GetStubPkt, ImportHandle, ImportInterface, maxDataLength, maxPrincipalLength, maxShortStringLength, pktOverhead, ReceiveExtraPkt, SendPrelimPkt, StartCall, StartSignal, StubPkt, UnimportInterface" ],
[module: ModuleName[lupineRuntime],
openName: "Lupine",
usedIn: [imports: TRUE],
usingSome: "BindingError, CheckPktLength, CopyFromPkt, CopyFromMultiplePkts, CopyToPkt, CopyToMultiplePkts, defaultZones, DispatchingError, FinishThisPkt, ListHeader, MarshalingError, MarshalingExprError, NilHeader, ProtocolError, RopeHeader, RpcPktDoubleWord, RuntimeError, SequenceHeader, SHORT, StartNextPkt, StringHeader, StubPktDoubleWord, TranslationError, UnmarshalingError, UnmarshalingExprError, WordsForChars" ],
Cedar directory items:
[module: "Atom",
usingSome: "GetPName, MakeAtom",
usedIn: [imports: TRUE],
forLanguage: [Cedar: TRUE] ],
[module: "Rope",
usingSome: "InlineFlatten, Length, NewText, Text",
usedIn: [imports: TRUE, shares: TRUE],
forLanguage: [Cedar: TRUE] ]
OpenCodeFile[ModuleName[client]];
BEGIN ENABLE UNWIND => CloseCodeFile;
StampCodeFile[ModuleName[client]];
StampModuleNames;
StampTranslationOptions[options];
Declare.Directory [
includeInterfaceDirectory: TRUE,
extraDirectories: DESCRIPTOR[clientDirectoryList],
options: options ];
Declare.ModuleHead [
moduleNames: DESCRIPTOR[clientModuleNames],
moduleType: "MONITOR",
interfaceList: DESCRIPTOR[clientDirectoryList],
options: options ];
Declare.BindingRoutinesStandard[kind: import, options: options];
WFS1["
-- Remote public procedure stubs.\n"];
BEGIN
DeclareInterfaceProcStub:
ST.TransferProcedure =
BEGIN
Declare.ProcedureStub[ nest: 1,
transfer: transfer,
transferType: transferType,
transferDeclaration: inInterface,
signalDispatcherType: client,
options: options ];
END; -- DeclareInterfaceProcStub.
[] ← ST.EnumerateTransfers[proc: DeclareInterfaceProcStub, procs: TRUE];
END; -- Remote public procedure stubs.
IF options.declareSignals
THEN
BEGIN
DeclareInterfaceSignal:
ST.TransferProcedure =
BEGIN
Declare.SignalCode[ nest: 1,
transfer: transfer,
transferType: transferType,
transferDeclaration: inInterface,
options: options ];
END; -- DeclareInterfaceSignal.
WFS1["
-- Remote public signals and errors.\n"];
[] ←
ST.EnumerateTransfers[
proc: DeclareInterfaceSignal, signals: TRUE, errors: TRUE ];
END -- Remote public signals and errors.
ELSE WFS1["
--Remote public signals and errors are imported from the interface.\n"];
WFS1["
-- Public signal and error dispatcher.\n"];
Declare.DispatcherHead[type: client, nest: 1];
WFS1["\n"];
Declare.DispatcherSelect[type: client, nest: 1];
BEGIN
DeclareDispatcherArm:
ST.TransferProcedure =
BEGIN
Declare.DispatcherStubArm[ nest: 3,
transfer: transfer,
transferType: transferType,
transferDeclaration: inInterface,
options: options ];
END; -- DeclareDispatcherArm.
[] ←
ST.EnumerateTransfers[
proc: DeclareDispatcherArm, signals:TRUE, errors:TRUE ];
END;
Declare.DispatcherTail[type: client, nest: 1];
WFS1["
-- Public signal and error dispatcher stubs.\n"];
BEGIN
DeclareDispatcherBody:
ST.TransferProcedure =
BEGIN
Declare.DispatcherStubBody[ nest: 1,
transfer: transfer,
transferType: transferType,
transferDeclaration: inInterface,
inlineBody: TRUE,
options: options ];
END; -- DeclareDispatcherBody.
[] ←
ST.EnumerateTransfers[
proc: DeclareDispatcherBody, signals:TRUE, errors:TRUE ];
END;
WFS["
-- No module initialization.
END. -- ", ModuleName[client], ".\n"];
END; -- ENABLE UNWIND => CloseCodeFile.
CloseCodeFile[];
END; -- MakeRpcClientModule.
MakeRpcClientBinderModule:
PUBLIC
PROCEDURE [options: Options] =
BEGIN
clientBinderModuleNames: ARRAY [0..1) OF String ← [ModuleName[clientBinder]];
clientBinderDirectoryList: ARRAY [0..6) OF Declare.DirectoryItem ← [
Common directory items:
[module: ModuleName[interface],
usedIn: [imports: NOT options.declareSignals, shares: TRUE] ],
[module: ModuleName[control],
usingAll: "InterfaceRecord, InterfaceRecordObject",
openName: "RpcControl",
usedIn: [exports: TRUE, shares: TRUE, beginOpen: TRUE] ],
[module: ModuleName[client],
openName: "ClientPrototype",
usedIn: [imports: TRUE] ],
[module: ModuleName[rpcPublic],
openName: "RpcPublic",
usedIn: [beginOpen: TRUE],
usingAll: "InterfaceName, Zones" ],
Cedar directory items:
[module: "SafeStorage",
openName: "RTT",
usingAll: "EnableFinalization, EstablishFinalization, FinalizationQueue, FQEmpty, FQNext, NewFQ",
usedIn: [imports: TRUE],
forLanguage: [Cedar: TRUE] ],
Mesa directory items:
[module: ModuleName[lupineRuntime],
openName: "Lupine",
usingAll: "defaultZones",
usedIn: [imports: TRUE],
forLanguage: [Mesa: TRUE] ] ];
OpenCodeFile[ModuleName[clientBinder]];
BEGIN ENABLE UNWIND => CloseCodeFile;
StampCodeFile[ModuleName[clientBinder]];
StampModuleNames;
StampTranslationOptions[options];
WFS1["
-- NOTE: Discard this module unless you use dynamic client binding.\n"];
Declare.Directory [
includeInterfaceDirectory: FALSE,
extraDirectories: DESCRIPTOR[clientBinderDirectoryList],
options: options ];
Declare.ModuleHead [
moduleNames: DESCRIPTOR[clientBinderModuleNames],
moduleType: "MONITOR",
interfaceList: DESCRIPTOR[clientBinderDirectoryList],
options: options ];
Declare.BindingRoutinesDynamic[kind: import, options: options];
Declare.BindingRoutinesPrivate[kind: import, options: options];
This includes module initialization code, and MUST be at the end.
WFS["
END. -- ", ModuleName[clientBinder], ".\n"];
END; -- ENABLE UNWIND => CloseCodeFile.
CloseCodeFile[];
END; -- MakeRpcClientBinderModule.
MakeRpcServerModule:
PUBLIC
PROCEDURE [options: Options] =
BEGIN
serverModuleNames: ARRAY [0..1) OF String ← [ModuleName[server]];
serverDirectoryList: ARRAY [0..7) OF Declare.DirectoryItem ← [
Common directory items:
[module: ModuleName[interface],
openName: ModuleName[openedInterface],
usedIn: [imports: TRUE, shares: TRUE, beginOpen: TRUE] ],
[module: ModuleName[control],
openName: "RpcControl",
usedIn: [exports: TRUE, shares: TRUE, beginOpen: TRUE],
usingAll: "InterMdsCallsOnly, LupineProtocolVersion, ProcedureIndex, SignalIndex" ],
[module: ModuleName[rpcPublic],
openName: "RpcPublic",
usedIn: [beginOpen: TRUE],
usingAll: "EncryptionKey, InterfaceName, Principal, standardZones, Zones" ],
[module: ModuleName[rpcPrivate],
openName: "RpcPrivate",
usedIn: [imports: TRUE],
usingSome: "Call, DataLength, Dispatcher, ExportHandle, ExportInterface, GetStubPkt, maxDataLength, maxPrincipalLength, maxShortStringLength, pktOverhead, ReceiveExtraPkt, SendPrelimPkt, StartCall, StartSignal, StubPkt, UnexportInterface" ],
[module: ModuleName[lupineRuntime],
openName: "Lupine",
usedIn: [imports: TRUE],
usingSome: "BindingError, CheckPktLength, CopyFromPkt, CopyFromMultiplePkts, CopyToPkt, CopyToMultiplePkts, defaultZones, DispatchingError, FinishThisPkt, ListHeader, MarshalingError, MarshalingExprError, NilHeader, ProtocolError, RopeHeader, RpcPktDoubleWord, RuntimeError, SequenceHeader, SHORT, StartNextPkt, StringHeader, StubPktDoubleWord, TranslationError, UnmarshalingError, UnmarshalingExprError, WordsForChars" ],
Cedar directory items:
[module: "Atom",
usingSome: "GetPName, MakeAtom",
usedIn: [imports: TRUE],
forLanguage: [Cedar: TRUE] ],
[module: "Rope",
usingSome: "InlineFlatten, Length, NewText, Text",
usedIn: [imports: TRUE, shares: TRUE],
forLanguage: [Cedar: TRUE] ]
OpenCodeFile[ModuleName[server]];
BEGIN ENABLE UNWIND => CloseCodeFile;
StampCodeFile[ModuleName[server]];
StampModuleNames;
StampTranslationOptions[options];
Declare.Directory [
includeInterfaceDirectory: TRUE,
extraDirectories: DESCRIPTOR[serverDirectoryList],
options: options ];
Declare.ModuleHead [
moduleNames: DESCRIPTOR[serverModuleNames],
moduleType: "MONITOR",
interfaceList: DESCRIPTOR[serverDirectoryList],
options: options ];
Declare.BindingRoutinesStandard [kind: export, options: options];
WFS1["
-- Public procedure dispatcher and public signal and error catcher.\n"];
Declare.DispatcherHead[type: server, nest: 1];
WFS["\n", Indent[2], "-- Catch public signals.\n\n"];
WFL1[3, "ENABLE BEGIN"];
BEGIN
DeclareSignalCatch:
ST.TransferProcedure =
BEGIN
Declare.SignalCatchStub [ nest: 3,
transfer: transfer,
transferType: transferType,
transferDeclaration: inInterface,
options: options ];
END; -- DeclareSignalCatch.
[] ←
ST.EnumerateTransfers[
proc: DeclareSignalCatch, signals: TRUE, errors: TRUE ];
END;
WFS["\n", Indent[3], "END; -- Catch public signals.\n"];
WFS["\n\n", Indent[2],
"-- Call public procedures (still in dispatcher).\n\n"];
Declare.DispatcherSelect[type: server, nest: 1];
BEGIN
DeclareDispatcherArm:
ST.TransferProcedure =
BEGIN
Declare.DispatcherStubArm[ nest: 3,
transfer: transfer,
transferType: transferType,
transferDeclaration: inInterface,
options: options ];
END; -- DeclareDispatcherArm.
[] ← ST.EnumerateTransfers[proc: DeclareDispatcherArm, procs: TRUE];
END;
Declare.DispatcherTail[type: server, nest: 1];
WFS1["
-- Public procedure dispatcher stubs.\n"];
BEGIN
DeclareDispatcherBody:
ST.TransferProcedure =
BEGIN
Declare.DispatcherStubBody[ nest: 1,
transfer: transfer,
transferType: transferType,
transferDeclaration: inInterface,
inlineBody: options.inlineServerDispatcherStubs,
options: options ];
END; -- DeclareDispatcherBody.
[] ← ST.EnumerateTransfers[proc: DeclareDispatcherBody, procs: TRUE];
END;
WFS["
-- No module initialization.
END. -- ", ModuleName[server], ".\n"];
END; -- ENABLE UNWIND => CloseCodeFile.
CloseCodeFile[];
END; -- MakeRpcServerModule.
Private utility routines.
StampModuleNames:
PROCEDURE =
BEGIN
WFSL["
-- The RPC stub modules for ", ModuleName[interface], " are:
-- ", ModuleName[control], ".mesa;
-- ", ModuleName[client], ".mesa;
-- ", ModuleName[clientBinder], ".mesa;
-- ", ModuleName[server], ".mesa.\n"];
END; -- StampModuleNames.
END. -- LupineMakeRpcModulesImpl.