ISNode.mesa
Copyright © 1985 by Xerox Corporation. All rights reserved.
edit by Ayers 22-May-85 13:21:31
Rick Beach, August 1, 1985 3:03:20 pm PDT
MKaplan, September 13, 1985 2:21:55 pm PDT
DIRECTORY
Imager USING [Context],
ISOut USING [Handle],
ISToken USING [TVObject, TVHandle, InterscriptContext],
ISBinding USING [Handle],
Rope USING [ROPE],
ViewerClasses USING [Viewer];
ISNode: CEDAR DEFINITIONS
= BEGIN
ISNode.Object holds all information collected in parsing an object. Some of its fields are implementation dependent (i.e., useful only for some tags, like text for CHARS$). It can probably be cleaned up.
Handle: TYPE = REF Object;
Object: TYPE = RECORD [
implementationChainHandle: --PRIVATE-- REFNIL,
^^ ISNodeImpl.ImplementationChainHandle speeds search --
empty: BOOLEANFALSE, -- for marking empty nodes in pages --
parent: ISNode.Handle ← NIL,
format: ATOM, --for PARA$--
text: Rope.ROPE, --for CHARS$--
looks: Rope.ROPE, --for CHARS$--
contextThread: ContextHandle ← NIL,
printProc: TiogaPrintProc,
taggedBindingsList: LIST OF ISBinding.Handle ← NIL, --Stores bindings assoc. with secondary tags, which have to stick around.--
seenSubnode: BOOLFALSE, --Used to tell if a CHARS$ child of a PARA$ should have ISContinuation property set in Tioga--
lastNodeEnd: INT ← 0, --Used in CHARS$ nodes to note end of previous node's text in temp file--
textIndex: INT ← 0, -- saves position of last character in first pass temp file --
primaryTag: ATOM,
tag: ATOM, --tag currently being internalized, used by ISImplProcs.DefaultInternalizeProc--
tagThread: TagHandle ← NIL]; -- array of booleans for standardized --
Context records are saved in the node. Really, only content and embedded contexts are used, a contentThread might be more appropriate for keeping in the node.
ContextRecord: TYPE = RECORD [
type: ATOM, context: ISToken.InterscriptContext,
next: ContextHandle ];
ContextHandle: TYPE = REF ContextRecord;
TagRecord: TYPE = RECORD [tag: ATOM, next: TagHandle];
TagHandle: TYPE = REF TagRecord;
Implementation objects map node types to functions that internalize them. These functions are the "code generation component" of the parser. Only internalize, and printTioga fields are used by us.
ImplementationClass: TYPE = {primary, onlyBindings, onlyTag};
Implementation: TYPE = REF ImplementationObject;
ImplementationObject: TYPE = RECORD [
internalize: InternalizeProc,
externalize: ExternalizeProc,
destroy: DestroyProc ← NIL,
printTioga: TiogaPrintProc ← NIL,
interpress: InterpressProc ← NIL,
createWindow: CreateWindowProc ← NIL,
enumerate: EnumerateChildrenProc ← NIL,
copy: CopyProc ← NIL,
getBinding: GetBindingProc ← NIL,
setBinding: SetBindingProc ← NIL,
getContentItem: GetContentItemProc ← NIL,
coerceBindings: CoerceBindingsProc ← NIL, --added 22may85 rma--
implementationClass: ImplementationClass,
mustInternalizeAllContent: BOOLEANFALSE ];

InternalizeProcs are handed contexts as they are parsed. initial contexts for initializing nodes, content and embedded contexts for dealing with things that go into the node, end contexts for cleaning up.
InternalizeProc: TYPE = PROCEDURE [node: Handle, interscriptContext: ISToken.InterscriptContext];
TiogaPrintProc is called once the node has been fully parsed, to write it out in tioga format.
TiogaPrintProc: TYPE = PROCEDURE [deltaLevel: INT, node: ISNode.Handle] RETURNS [nests: INT ← 0];
ExternalizeProc: TYPE = PROCEDURE [node: Handle, externalizeContext: --ISOut.Handle-- REF];
DestroyProc: TYPE = PROCEDURE [node: Handle];
InterpressClippingBox: TYPE = RECORD [x, y, w, h: REAL];
InterpressProc: TYPE = PROCEDURE [
node: Handle,
interpressContext: Imager.Context,
clippingBox: InterpressClippingBox ];
EditMode: TYPE = {galley, layout};
CreateWindowProc: TYPE = PROCEDURE [
node: Handle,
editMode: EditMode,
micasPerPixel: CARDINAL]
RETURNS
[ViewerClasses.Viewer];
EnumerateChildrenAnswerType: TYPE = {node, characters};
EnumerateChildrenAnswer: TYPE = RECORD [
body: SELECT type: EnumerateChildrenAnswerType FROM
node => [handle: ISNode.Handle],
characters => [
readerBody: Rope.ROPE,
font: INTEGER,
labels: SEQUENCE number: CARDINAL OF ATOM ],
ENDCASENULL ];
EnumerateChildrenCallback: TYPE = PROCEDURE [
child: EnumerateChildrenAnswer,
context: REF ANY ]
RETURNS
[continue: BOOLEANTRUE];
EnumerateChildrenProc: TYPE = PROCEDURE [
node: Handle,
context: REF ANY,
enumerationProc: EnumerateChildrenCallback ];
CopyProc: TYPE = PROCEDURE [ old, new: Handle ];
GetBindingProc: TYPE = PROCEDURE [node: Handle, binding: ATOM]
RETURNS [ISToken.TVObject];
SetBindingProc: TYPE = PROCEDURE [
node: Handle, binding: ATOM, value: ISToken.TVHandle];
GetContentItemProc: TYPE = PROCEDURE [node: Handle, index: CARDINAL]
RETURNS [ISToken.TVObject];
CoerceBindingsProc: TYPE = PROCEDURE [to, from: Handle, coercion: ISToken.TVHandle ← NIL];
ErrorCode: TYPE = {spare, extra};
Error: ERROR [code: ErrorCode];
SetImplementation: PROCEDURE [ -- Installation of an implementation --
tag: ATOM,
family: ATOM,
implementation: Implementation]
RETURNS [oldImplementation: Implementation];
GetImplementation: PROCEDURE[
tag: ATOM,
family: ATOM ]
RETURNS [implementation: Implementation];
GetPrimaryImpl: PROCEDURE [Handle] RETURNS [Implementation];
GetPrimaryImplAndTag: PROCEDURE [Handle]
RETURNS [implementation: Implementation, tag: ATOM];
Plug-ins called by node implementations
Externalize: ExternalizeProc;
Interpress: InterpressProc;
CreateWindow: CreateWindowProc;
Enumerate: EnumerateChildrenProc;
Copy: PROCEDURE [old: Handle, with: Handle ← NIL] RETURNS [Handle];
Create: PROCEDURE [--with: ISNode.Handle--] RETURNS [Handle];
Destroy: PROCEDURE [REF Handle];
GetContext: PROCEDURE [node: Handle, type: ATOM]
RETURNS [context: ISToken.InterscriptContext];
SetContext: PROCEDURE [node: Handle, type: ATOM, context: ISToken.InterscriptContext];
EnumerateContextsCallback: TYPE = PROCEDURE [node: Handle, type: ATOM, context: REF ]
RETURNS
[continue: BOOLEANTRUE];
EnumerateContexts: PROCEDURE [node: Handle,
enumerationProc: EnumerateContextsCallback, context: REF];
GetNextWindow: PROCEDURE [node: Handle, window: Window.Handle]
RETURNS
[Window.Handle];
GetWindowsNode: PROCEDURE[window: Window.Handle] RETURNS[Handle];
SetTag: PROCEDURE [node: Handle, tag: ATOM];
ClearTag: PROCEDURE [node: Handle, tag: ATOM];
HasTag: PROCEDURE [node: Handle, tag: ATOM] RETURNS [BOOLEAN];
AllocateInitialNode: PROCEDURE [session: REF]
RETURNS [ISNode.Handle];
END.