LupineMarshalPrivate.mesa.
Copyright © 1985 by Xerox Corporation. All rights reserved.
Last edited by
BZM on 9-Mar-82 17:52:16.
Birrell, September 8, 1983 4:31 pm
Swinehart, July 3, 1984 10:27:46 am PDT
Bob Hagmann February 8, 1985 5:03:45 pm PST
LupineMarshalPrivate is used and exported only by LupineMarshal*Impl.
DIRECTORY
LupineManagerPrivate USING [
ErrorCode, Nest, Options, ParamPassingMethod, String, StringNIL],
LupineMarshal USING [
AllocZone, Chars, FieldInfo, ParamInfo,
ParamLocation, ParamProcedure, ParamRecordKind,
VariableNames, Words ],
LupineSymbolTable USING [
SymbolHandle, SymbolHandleNIL, TypeHandle, TypeHandleNIL, TypeInfo ],
Rope USING [ROPE],
RPCLupine USING [maxDataLength, maxShortStringLength];
LupineMarshalPrivate: DEFINITIONS
= BEGIN OPEN LupineManagerPrivate, LupineMarshal, ST: LupineSymbolTable;
Most of these constants are implicit marshaling parameters.
MaxDataLength, MaxDataSize: Words = RPCLupine.maxDataLength;
RpcPrivate.maxDataLength is the limit on DATA words in any packet.
MaxShortStringLength: Chars = RPCLupine.maxShortStringLength;
RpcPrivate.maxShortStringLength is the size limit on short string types.
DynamicSizeThreshhold: Words = MaxDataSize;
Sequences and descriptors whose net size is bigger than this
are assumed to have dynamic length (they're larger than a pkt).
MaxPointerDepth: INTEGER = 4;
Random pointer recursion can go this deep before Lupine gives up;
of course, LIST OF has no restrictions.
These are information routines used between LupineMarshal*Impl.
NeedsOperationProc: TYPE =
PROCEDURE [type: ST.TypeHandle] RETURNS [--yes:-- BOOLEAN];
NeedsMarshaling: NeedsOperationProc;
ContainsRefs: NeedsOperationProc;
ContainsEmbeddedPtrs: NeedsOperationProc;
ContainsStatics: NeedsOperationProc;
ContainsSequences: NeedsOperationProc;
Cardinality: PROCEDURE [index: ST.TypeHandle] RETURNS [LONG INTEGER];
VectorSize: PROCEDURE [vectorInfo: ST.TypeInfo] RETURNS [size: Words];
HasDynamicIndex: PROCEDURE [vectorInfo: ST.TypeInfo]
RETURNS [--yes:-- BOOLEAN] =
INLINE {RETURN[VectorSize[vectorInfo] > DynamicSizeThreshhold]};
HasEmptyIndex: PROCEDURE [index: ST.TypeHandle] RETURNS [--yes:-- BOOLEAN] =
INLINE {RETURN[Cardinality[index] = 0]};
IsShortString: PROCEDURE [candidate: ST.TypeHandle] RETURNS [yes: BOOLEAN];
IsExplicitHandle: PROCEDURE [typeInfo: ST.TypeInfo] RETURNS [yes: BOOLEAN];
These are private routines used by LupineMarshalType*Impl.
Type marshaling should logically be in one module, but there's too much
and unpleasant module splits have resulted.
MarshalInfo: TYPE = POINTER TO MarshalInfoObject;
MarshalInfoObject: TYPE = RECORD [
paramInfo: ParamInfo,
paramFieldInfo: FieldInfo,
varNames: VariableNames,
direction: Direction,
The following VAR fields are updated as a parameter is marshaled:
depth, ptrDepth: LONG INTEGER ← 0,
transferParamIndex: ST.Index ← 0,
numAllocs: ARRAY AllocZone OF LONG INTEGERALL[0] ];
ParentInfo: TYPE = RECORD [
name: String ← StringNIL,
typeInfo: ST.TypeInfo ← [info: Null[]] ];
ParentInfoNull: ParentInfo = [];
Direction: TYPE = {toPkt, fromPkt};
SubStrings: TYPE = RECORD [s1, s2, s3: String ← StringNIL];
OperationProc: TYPE = PROCEDURE [
name: String,
type: ST.TypeHandle,
parentInfo: ParentInfo,
marshalInfo: MarshalInfo,
nest: Nest,
options: Options ];
The top-level marshaling routine:
MarshalType: OperationProc;
Individual routines for marshaling type constructors:
MarshalTransfer: PROCEDURE [
name: String,
transferInfo: Transfer ST.TypeInfo,
parentInfo: ParentInfo,
marshalInfo: MarshalInfo,
nest: Nest,
options: Options ];
MarshalRecord: PROCEDURE [
name: String,
recInfo: Record ST.TypeInfo,
parentInfo: ParentInfo,
marshalInfo: MarshalInfo,
nest: Nest,
options: Options ];
MarshalVariantPart: PROCEDURE [
name: String,
varInfo: VariantPart ST.TypeInfo,
parentInfo: ParentInfo,
marshalInfo: MarshalInfo,
nest: Nest,
options: Options ];
MarshalPointer: PROCEDURE [
name: String,
pointerInfo: Pointer ST.TypeInfo,
parentInfo: ParentInfo,
marshalInfo: MarshalInfo,
nest: Nest,
options: Options ];
MarshalRef: PROCEDURE [
name: String,
refInfo: Ref ST.TypeInfo,
parentInfo: ParentInfo,
marshalInfo: MarshalInfo,
nest: Nest,
options: Options ];
MarshalList: PROCEDURE [
name: String,
listInfo: List ST.TypeInfo,
parentInfo: ParentInfo,
marshalInfo: MarshalInfo,
nest: Nest,
options: Options ];
MarshalArray: PROCEDURE [
name: String,
arrayInfo: Array ST.TypeInfo,
parentInfo: ParentInfo,
marshalInfo: MarshalInfo,
nest: Nest,
options: Options ];
MarshalDescriptor: PROCEDURE [
name: String,
descInfo: Descriptor ST.TypeInfo,
parentInfo: ParentInfo,
marshalInfo: MarshalInfo,
nest: Nest,
options: Options ];
MarshalSequence: PROCEDURE [
name: String,
seqInfo: Sequence ST.TypeInfo,
parentInfo: ParentInfo,
marshalInfo: MarshalInfo,
nest: Nest,
options: Options ];
Managing deferred Marshal Types.
InitMarshalTypes: PROC;
WriteMarshalProcs: PROC;
Utilities.
VerifyPassingMethods: PROCEDURE [
var, value, result, handle, all: BOOLEANFALSE,
marshalInfo: MarshalInfo ];
UniqueName: PROCEDURE [
root: String,
suffix: String ← StringNIL,
marshalInfo: MarshalInfo ]
RETURNS[nameString: String];
Passing: PROCEDURE [
passingMethod: ParamPassingMethod,
paramKind: ParamRecordKind,
marshalInfo: MarshalInfo ]
RETURNS [--yes:-- BOOLEAN] =
INLINE BEGIN
RETURN[
marshalInfo.paramFieldInfo.passingMethod = passingMethod AND
marshalInfo.paramInfo.paramRecordKind = paramKind ];
END;
These are utility code generation routines used by LupineMarshalType*Impl.
CopyOne: PROCEDURE [
wordsNeeded: Words,
value: SubStrings,
nullValue, oneStmt: BOOLEANFALSE,
marshalInfo: MarshalInfo,
nest: Nest ];
CopyTwo: PROCEDURE [
wordsNeeded: Words,
value: SubStrings,
nullValue, oneStmt: BOOLEANFALSE,
marshalInfo: MarshalInfo,
nest: Nest ];
CopyCharacters: PROCEDURE [
textName: SubStrings,
numCharsName: String,
marshalInfo: MarshalInfo,
nest: Nest ];
CopyType, CopyUninterpreted: PROCEDURE [
variableName: String,
variableInfo: ST.TypeInfo,
parentInfo: ParentInfo,
marshalInfo: MarshalInfo,
nest: Nest ];
AllocationOperation: TYPE = {new, cons, list};
WriteNEW: PROCEDURE [
allocOp: AllocationOperation ← new,
ptrInfo: ST.TypeInfo,
marshalInfo: --VAR-- MarshalInfo,
options: Options,
dontUseHeap: BOOL ← FALSE ]
RETURNS [allocSizeName: Rope.ROPE ← NIL];
General marshaling utilities.
EnumerateOverlayParams: PROCEDURE [
paramInfo: ParamInfo,
overlayProc: ParamProcedure ] =
INLINE BEGIN
EnumerateSomeParams[paramInfo, overlayProc, inPktOverlay, inFrameAndOverlay];
END;
EnumerateFrameParams: PROCEDURE [
paramInfo: ParamInfo,
frameProc: ParamProcedure ] =
INLINE BEGIN
EnumerateSomeParams[paramInfo, frameProc, inFrame, inFrameAndOverlay];
END;
EnumerateSomeParams: PRIVATE PROCEDURE [
paramInfo: ParamInfo, proc: ParamProcedure,
place1, place2: ParamLocation ];
Error: PROCEDURE [
code: ErrorCode,
symbol: ST.SymbolHandle ← ST.SymbolHandleNIL,
type: ST.TypeHandle ← ST.TypeHandleNIL,
string: String ← StringNIL,
causeError: BOOLEANTRUE ];
Warning: PROCEDURE [
code: ErrorCode,
symbol: ST.SymbolHandle ← ST.SymbolHandleNIL,
type: ST.TypeHandle ← ST.TypeHandleNIL,
string: String ← StringNIL,
causeError: BOOLEANFALSE ];
END. -- LupineMarshalPrivate.