RefPrintDoc.tioga
Michael Plass, August 30, 1990 3:49 pm PDT
RefPrint
PCEDAR 2.0 — FOR INTERNAL XEROX USE ONLY
RefPrint
An expedient REF printing package
Michael Plass
© Copyright 1988 Xerox Corporation. All rights reserved.
Abstract: In these early days of PCedar, debugging is a pain because (among other things) it is difficult to know what to type to DBX to find out what a complicated structure looks like. And since there is not yet an Abstact Machine for PCedar, a good solution is not just over the horizon. RefPrint provides a registration mechanism for REF printing procedures, which, if used in conjuction with CrankPrinter, can provide a semi-automated way of making your types printable.
Created by: Michael Plass
Maintained by: Michael Plass <Plass:PARC>
Keywords: hack, debugging, temporary relief, Crank
XEROX  Xerox Corporation
   Palo Alto Research Center
   3333 Coyote Hill Road
   Palo Alto, California 94304

For Internal Xerox Use Only
0. News
August 30, 1990 - added a fallback printer that uses the information kept by PCR's garbage collector to guess what's a ref and what's not.
1. Interfaces
RefPrint
This provides a pretty straightforward registration mechanism and calls to print REFs to a stream.
The print procs (of type RefPrint.PrintRefProc) may be generated by hand if necessary, or with some help from a command called CrankPrinter.
2. Commands
RefPrint [ -d depthLimit ] address
If the address is a valid REF, attempts to print it using the registered printing routines or a fallback ref printer.
The depthLimit controls how deeply into the structure to dive; the default is small to keep from wading through a lot of junk.
You may use this command to make a button for easily diving deeper into the structure:
CreateButton Ref RefPrint 0$CurrentSelection$H
3. Using CrankPrinter
(As of August 30, 1990, CrankPrinter is available in Cedar7.0 and on /PlassHacks/)
Make up an interface that copies in all the TYPEs that you are interested in printing REFs to. For example:
ImagerTypes.mesa
Copyright Ó 1988 by Xerox Corporation. All rights reserved.
Michael Plass, May 13, 1988 10:08:11 am PDT
DIRECTORY Imager, ImagerBackdoor, ImagerBox, ImagerColor, ImagerDevice, ImagerFont, ImagerPath, ImagerPixel, ImagerPixelArray, ImagerPrivate, ImagerSample, ImagerState, ImagerTransformation, ImagerTypeface, SF, Vector2, ImagerPen;
ImagerTypes: CEDAR DEFINITIONS
~ BEGIN
ContextRep: TYPE ~ Imager.ContextRep;
ColorRep: TYPE ~ ImagerColor.ColorRep;
Box: TYPE ~ ImagerBox.Box;
Rectangle: TYPE ~ ImagerBox.Rectangle;
Extents: TYPE ~ ImagerBox.Extents;
AllowedMasks: TYPE ~ ImagerDevice.AllowedMasks;
DeviceParmRep: TYPE ~ ImagerDevice.DeviceParmRep;
FontRep: TYPE ~ ImagerFont.FontRep;
OpConstantColorRep: TYPE ~ ImagerColor.ColorRep.constant.op;
SpecialColorRep: TYPE ~ ImagerColor.ColorRep.constant.special;
SampledColorRep: TYPE ~ ImagerColor.ColorRep.sampled;
PixelArrayRep: TYPE ~ ImagerPixelArray.PixelArrayRep;
StateRep: TYPE ~ ImagerState.StateRep;
PenRep: TYPE ~ ImagerPen.PenRep;
VEC: TYPE ~ Vector2.VEC;
SFBox: TYPE ~ SF.Box;
SFVec: TYPE ~ SF.Vec;
TypefaceRep: TYPE ~ ImagerTypeface.TypefaceRep;
TransformationRep: TYPE ~ ImagerTransformation.TransformationRep;
END.
Make a working directory containing the relevant sources; remember that Crank works strictly form source code. If Crank can't find a needed source module in the current directory, it consults the version map, which may not be what you want for PCedar. However, it might be just fine to use the Cedar7.0 interfaces if your program is pretty much source-compatible between Cedar7.0 and PCedar.
Note that the types you want in this interface are the referent types; if you want to be able to print an Imager.Context, you need to include Imager.ContextRep.
Now say (for this example)
CrankPrinter ImagerTypes
If all goes well, this will create ImagerTypesPrintImpl.mesa, which, when run, registers itself with RefPrint. (You might want to run ExpungeOpens over the generated mesa file to prettyprint it).
4. Limitations of CrankPrinter
Crank uses the Cedar interpreter's parser, which is not completely compatible with Mimosa (for instance, PACKED records are not supported). This probably makes it impossible to Crank some of the low-level PCedar interfaces. One workaround is to provide your own simplified versions that don't have the problems.
The first thing you Crank that depends on a lot of stuff will take a long time, because it has to process a lot of source code. The results are cached in memory, though, so that subsequent uses in the same session will not be as painful.