home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / Pascal / Libraries / WASTE 1.1a4 / WASTE Source / WEInterface.p < prev    next >
Encoding:
Text File  |  1994-11-12  |  17.1 KB  |  578 lines  |  [TEXT/PJMM]

  1. unit WEInterface;
  2.  
  3. { WASTE PROJECT: }
  4. { Internal interface: constants, types and inline code }
  5.  
  6. { Copyright © 1993-1994 Marco Piovanelli }
  7. { All Rights Reserved }
  8.  
  9. interface
  10.     uses
  11.         LongCoords;
  12.  
  13.     const
  14.  
  15. { result codes }
  16.  
  17.         weCantUndoErr = -9479;                            { undo buffer is clear }
  18.         weUnknownObjectTypeErr = -9478;            { specified object type was not registered }
  19.         weObjectNotFoundErr = -9477;                    { no object found at specified offset }
  20.  
  21. { alignment styles }
  22.  
  23.         weFlushLeft = -2;
  24.         weFlushRight = -1;
  25.         weFlushDefault = 0;
  26.         weCenter = 1;
  27.         weJustify = 2;
  28.  
  29. { values for the edge parameter }
  30.  
  31.         kLeadingEdge = -1;                { point is on the leading edge of a glyph }
  32.         kTrailingEdge = 0;                    { point is on the trailing edge of a glyph }
  33.         kObjectEdge = 2;                    { point is inside an embedded object }
  34.  
  35. { control character codes }
  36.  
  37.         kObjectMarker = 1;
  38.         kBackspace = 8;
  39.         kEOL = 13;
  40.         kArrowLeft = 28;
  41.         kArrowRight = 29;
  42.         kArrowUp = 30;
  43.         kArrowDown = 31;
  44.         kForwardDelete = 127;
  45.  
  46. { bit equates for QuickDraw styles }
  47.  
  48.         tsBold = 0;
  49.         tsItalic = 1;
  50.         tsUnderline = 2;
  51.         tsOutline = 3;
  52.         tsShadow = 4;
  53.         tsCondense = 5;
  54.         tsExtend = 6;
  55.  
  56. { bit equates for the tsFlags field of the WETextStyle record }
  57.  
  58.         tsTSMHilite = 4;                            { set if style run is part of active input area }
  59.         tsTSMSelected = 5;                        { set for selected raw/converted text }
  60.         tsTSMConverted = 6;                        { set for converted text, clear for raw text }
  61.         tsRightToLeft = 7;                            { specifies style run direction }
  62.  
  63. { bit equates for the mode parameter in WESetStyle and WEContinuousStyle }
  64.  
  65.         kModeFont = 0;
  66.         kModeFace = 1;
  67.         kModeSize = 2;
  68.         kModeColor = 3;
  69.         kModeAddSize = 4;
  70.         kModeToggleFace = 5;
  71.         kModeReplaceFace = 6;
  72.         kModeObject = 14;
  73.         kModeFlags = 15;
  74.  
  75. { values for the mode parameter in WESetStyle and WEContinuousStyle }
  76.  
  77.         weDoFont = $0001;
  78.         weDoFace = $0002;
  79.         weDoSize = $0004;
  80.         weDoColor = $0008;
  81.         weDoAll = weDoFont + weDoFace + weDoSize + weDoColor;
  82.         weDoAddSize = $0010;
  83.         weDoToggleFace = $0020;
  84.         weDoReplaceFace = $0040;
  85.         weDoObject = $4000;
  86.         weDoFlags = $8000;
  87.  
  88. { values for WEFeatureFlag action parameter }
  89.  
  90.         weBitClear = 0;                                { disables the specified feature }
  91.         weBitSet = 1;                                { enables the specified feature }
  92.         weBitTest = -1;                                { returns the current setting of the specified feature }
  93.  
  94. { bit equates for the flags field in the WE record }
  95. { bits 0..15 can be used to turn on and off specific features with WEFeatureFlag }
  96. { bits 16..31 are used internally and should not be modified }
  97.  
  98.         weFHasColorQD = 31;                    { Color QuickDraw is available }
  99.         weFHasTextServices = 30;                { Text Services Manager is available }
  100.         weFNonRoman = 29;                        { At least one non-Roman script is enabled }
  101.         weFDoubleByte = 28;                    { A double-byte script is installed }
  102.         weFCaretVisible = 24;                    { Caret is currently visible }
  103.         weFMouseTracking = 23;                { Set internally during mouse tracking }
  104.         weFAnchorIsEnd = 22;                    { Anchor offset is selEnd }
  105.         weFUseNullStyle = 21;                    { A null style is associated with the empty selection }
  106.         weFActive = 20;                            { TRUE if text pane is active }
  107.         weFHilited = 19;                            { TRUE if text pane is highlighted (for Drag & Drop) }
  108.         weFCanAcceptDrag = 18;                { The drag in the text pane can be accepted }
  109.         weFDragCaretVisible = 17;            { Drag caret is currently visible }
  110.  
  111.         weFDrawOffscreen = 11;                { Draw text offscreen for smoother visual results }
  112.         weFUseTempMem = 10;                { Use temporary memory }
  113.         weFInhibitRecal = 9;                        { If set, recals and redraws are inhibited }
  114.         weFDragAndDrop = 8;                    { Text drag-and-drop }
  115.         weFIntCutAndPaste = 7;                { Intelligent Cut & Paste }
  116.         weFUndoSupport = 6;                    { Support Undo/Redo }
  117.         weFOutlineHilite = 2;                    { Outline selection range when text pane is inactive }
  118.         weFAutoScroll = 0;                        { Automatically scroll text when cursor is outside pane }
  119.  
  120. { masks for setting the feature bits }
  121.  
  122.         weDoAutoScroll = $0001;                { 1 << weFAutoScroll }
  123.         weDoOutlineHilite = $0004;            { 1 << weFOutlineHilite }
  124.         weDoUndoSupport = $0040;            { 1 << weFUndoSupport }
  125.         weDoIntCutAndPaste = $0080;        { 1 << weFIntCutAndPaste }
  126.         weDoDragAndDrop = $0100;            { 1 << weFDragAndDrop }
  127.         weDoInhibitRecal = $0200;            { 1 << weFInhibitRecal }
  128.         weDoUseTempMem = $0400;        { 1 << weFUseTempMem }
  129.         weDoDrawOffscreen = $0800;        { 1 << weFDrawOffscreen }
  130.  
  131. { scrap types }
  132.  
  133.         kTypeText = 'TEXT';
  134.         kTypeStyles = 'styl';
  135.         kTypeSoup = 'SOUP';
  136.  
  137. { selectors for WEGetInfo/WESetInfo }
  138.  
  139.         weClickLoop = 'clik';
  140.         weCurrentDrag = 'drag';
  141.         weLineArray = 'line';
  142.         wePort = 'port';
  143.         weRefCon = 'refc';
  144.         weRunArray = 'runa';
  145.         weScrollProc = 'scrl';
  146.         weStyleTable = 'styl';
  147.         weText = 'text';
  148.         weTranslateDragHook = 'xdrg';
  149.         weTSMDocumentID = 'tsmd';
  150.         weTSMPostUpdate = 'post';
  151.         weTSMPreUpdate = 'pre ';
  152.  
  153. { possible values returned by WEIntelligentPaste }
  154.  
  155.         weDontAddSpaces = 0;
  156.         weAddSpaceOnLeftSide = -1;
  157.         weAddSpaceOnRightSide = 1;
  158.  
  159. { values for WEAllocate allocFlags parameter }
  160.  
  161.         kAllocClear = $0001;                        { clear handle after allocation }
  162.         kAllocTemp = $0002;                    { use temporary memory if available }
  163.  
  164. { other miscellaneous constants }
  165.  
  166.         kCaretWidth = 1;                            { width of the caret, in pixels }
  167.         kMinFontSize = 1;                            { minimum valid value for the font size }
  168.         kMaxFontSize = maxint;                { maximum valid value for the font size }
  169.         kOneToOneScaling = $00010001;    { 1:1 scaling ratio }
  170.         kInvalidOffset = -1;                        { used to flag an invalid or nonexistent offset }
  171.         kNullDrag = 0;                                { null or nonexistent drag reference }
  172.         kNullObject = 0;                            { null object reference }
  173.  
  174.     type
  175.  
  176.         WEChars = packed array[0..999999] of Char;
  177.         WECharsPtr = ^WEChars;
  178.         WECharsHandle = ^WECharsPtr;
  179.  
  180.         DoubleByte = packed record
  181.                 firstByte: SignedByte;
  182.                 secondByte: SignedByte;
  183.             end;  { DoubleByte }
  184.  
  185.         WEFieldDescriptor = record
  186.                 fOffset: Integer;
  187.                 fLength: Integer;
  188.             end;  { WEFieldDescriptor }
  189.  
  190.         WELookupTableElement = record
  191.                 selector: OSType;
  192.                 desc: WEFieldDescriptor;
  193.             end;  { WELookupTableElement }
  194.  
  195.         WELookupTable = array[0..0] of WELookupTableElement;
  196.  
  197.         WETextStyle = record
  198.                 case Integer of
  199.                     0: (
  200.                             tsFont: Integer;
  201.                             tsFace: SignedByte;
  202.                             tsFlags: SignedByte;
  203.                             tsSize: Integer;
  204.                             tsColor: RGBColor;
  205.                     );
  206.                     1: (
  207.                             tsTEStyle: TextStyle;                    { TextEdit style attributes }
  208.                             tsObject: LongInt;                        { embedded object reference }
  209.                     );
  210.             end;  { WETextStyle }
  211.         WETextStylePtr = ^WETextStyle;
  212.  
  213.         TERunAttributes = record
  214.                 runHeight: Integer;
  215.                 runAscent: Integer;
  216.                 runTEStyle: TextStyle;
  217.             end;  { TERunAttributes }
  218.         TERunAttributesPtr = ^TERunAttributes;
  219.  
  220.         TEStyleScrapElement = record
  221.                 scrpStartChar: LongInt;
  222.                 scrpTEAttrs: TERunAttributes;
  223.             end;  { TEStyleScrapElement }
  224.         TEStyleScrapElementPtr = ^TEStyleScrapElement;
  225.  
  226.         TEStyleScrap = record
  227.                 scrpNStyles: Integer;
  228.                 scrpStyleTab: array[0..0] of TEStyleScrapElement;
  229.             end;
  230.         TEStyleScrapPtr = ^TEStyleScrap;
  231.         TEStyleScrapHandle = ^TEStyleScrapPtr;
  232.  
  233.         WERunAttributes = record
  234.                 case Integer of
  235.                     0: (
  236.                             runHeight: Integer;                { run height (ascent + descent + leading) }
  237.                             runAscent: Integer;            { font ascent }
  238.                             runStyle: WETextStyle;
  239.                     );
  240.                     1: (
  241.                             runTEAttrs: TERunAttributes;
  242.                     );
  243.             end;  { WERunAttributes }
  244.         WERunAttributesPtr = ^WERunAttributes;
  245.  
  246.         WERunInfo = record
  247.                 runStart: LongInt;
  248.                 runEnd: LongInt;
  249.                 runAttrs: WERunAttributes;
  250.             end;  { WERunInfo }
  251.         WERunInfoPtr = ^WERunInfo;
  252.  
  253.         GrafPort1 = record
  254.                 device: Integer;
  255.                 portBits: BitMap;
  256.                 portRect: Rect;
  257.                 visRgn: RgnHandle;
  258.                 clipRgn: RgnHandle;
  259.                 bkPat: Pattern;
  260.                 fillPat: Pattern;
  261.                 pnLoc: Point;
  262.                 pnSize: Point;
  263.                 pnMode: Integer;
  264.                 pnPat: Pattern;
  265.                 pnVis: Integer;
  266.                 txFont: Integer;
  267.                 txFace: SignedByte;
  268.                 filler: SignedByte;
  269.                 txMode: Integer;
  270.                 txSize: Integer;
  271.                 spExtra: Fixed;
  272.                 fgColor: LongInt;
  273.                 bkColor: LongInt;
  274.                 colrBit: Integer;
  275.                 patStretch: Integer;
  276.                 picSave: Handle;
  277.                 rgnSave: Handle;
  278.                 polySave: Handle;
  279.                 grafProcs: QDProcsPtr;
  280.             end;  { GrafPort1 }
  281.         GrafPtr1 = ^GrafPort1;
  282.  
  283.         QDEnvironment = record
  284.                 envPort: GrafPtr;
  285.                 envPen: PenState;
  286.                 envStyle: WETextStyle;
  287.                 envMode: Integer;
  288.             end;  { QDEnvironment }
  289.  
  290.         TEStyleScrapPair = record
  291.                 first: TEStyleScrapElement;
  292.                 second: TEStyleScrapElement;
  293.             end;  { TEStyleScrapPair }
  294.         TEStyleScrapPeek = ^TEStyleScrapPair;
  295.  
  296.         RunArrayElement = record
  297.                 runStart: LongInt;                        { offset to first character in style run }
  298.                 styleIndex: LongInt;                    { index into style table }
  299.             end;  { RunArrayElement }
  300.         RunArrayElementPtr = ^RunArrayElement;
  301.         RunArrayElementHandle = ^RunArrayElementPtr;
  302.  
  303.         RunArrayPair = record
  304.                 first: RunArrayElement;
  305.                 second: RunArrayElement;
  306.             end;  { RunArrayPair }
  307.         RunArrayPeek = ^RunArrayPair;    { useful to "peek" at a portion of the run array }
  308.  
  309.     const
  310.         kRunArrayMaxIndex = (maxLongInt div SizeOf(RunArrayElement)) - 1;
  311.  
  312.     type
  313.         RunArray = array[0..kRunArrayMaxIndex] of RunArrayElement;
  314.         RunArrayPtr = ^RunArray;
  315.         RunArrayHandle = ^RunArrayPtr;
  316.  
  317.         StyleTableElement = record
  318.                 refCount: LongInt;                    { reference count }
  319.                 info: WERunAttributes;                { style information }
  320.             end;  { StyleTableElement }
  321.         StyleTableElementPtr = ^StyleTableElement;
  322.         StyleTableElementHandle = ^StyleTableElementPtr;
  323.  
  324.     const
  325.         kStyleTableMaxIndex = (maxint div SizeOf(StyleTableElement)) - 1;
  326.  
  327.     type
  328.         StyleTable = array[0..kStyleTableMaxIndex] of StyleTableElement;
  329.         StyleTablePtr = ^StyleTable;
  330.         StyleTableHandle = ^StyleTablePtr;
  331.  
  332.         LineRec = record
  333.                 lineStart: LongInt;                    { offset to first character in line }
  334.                 lineOrigin: LongInt;                    { distance from destRect.top, in pixels }
  335.                 lineAscent: Integer;                    { maximum font ascent for this line, in pixels }
  336.                 lineSlop: Integer;                        { extra pixels needed to fill up the line }
  337.                 lineJustAmount: Fixed;                { normalized slop value for justification }
  338.             end;  { LineRec }
  339.         LinePtr = ^LineRec;
  340.         LineHandle = ^LinePtr;
  341.  
  342.         LinePair = record
  343.                 first: LineRec;
  344.                 second: LineRec;
  345.             end;  { LinePair }
  346.         LinePeek = ^LinePair;                    { useful to "peek" at a portion of the line array }
  347.  
  348.     const
  349.         kLineArrayMaxIndex = (maxLongInt div SizeOf(LineRec)) - 1;
  350.  
  351.     type
  352.         LineArray = array[0..kLineArrayMaxIndex] of LineRec;
  353.         LineArrayPtr = ^LineArray;
  354.         LineArrayHandle = ^LineArrayPtr;
  355.  
  356.         WERec = record
  357.                 port: GrafPtr;                                { graphics port }
  358.                 hText: Handle;                                { handle to the raw text }
  359.                 hLines: LineArrayHandle;                { handle to the line array }
  360.                 hStyles: StyleTableHandle;            { handle to the style table }
  361.                 hRuns: RunArrayHandle;                { handle to the style run array }
  362.                 textLength: LongInt;                        { length of raw text block }
  363.                 nLines: LongInt;                            { number of lines }
  364.                 nStyles: LongInt;                            { number of distinct styles in the style table }
  365.                 nRuns: LongInt;                            { number of style runs in the style run array }
  366.                 viewRect: LongRect;                        { view rectangle }
  367.                 destRect: LongRect;                        { destination rectangle }
  368.                 selStart: LongInt;                            { start of selection range }
  369.                 selEnd: LongInt;                            { end of selection range }
  370.                 flags: LongInt;                                { 32 bits of miscellaneous flags }
  371.                 caretTime: LongInt;                        { time of most recent caret xoring }
  372.                 clickTime: LongInt;                        { time of most recent click }
  373.                 clickLoc: LongInt;                            { byte offset of most recent click }
  374.                 anchorStart: LongInt;                    { anchor word start }
  375.                 anchorEnd: LongInt;                        { anchor word end }
  376.                 clickLoop: ProcPtr;                        { click loop callback }
  377.                 unused1: SignedByte;                    { unused }
  378.                 clickEdge: SignedByte;                    { edge of character hit by most recent click }
  379.                 unused2: SignedByte;                    { unused }
  380.                 firstByte: SignedByte;                    { first byte of a double-byte character }
  381.                 offscreenPort: GrafPtr;                    { offscreen graphics world }
  382.                 viewRgn: RgnHandle;                    { handle to the view region }
  383.                 scrollProc: ProcPtr;                        { scroll callback }
  384.                 clickCount: Integer;                        { multiple click count }
  385.                 alignment: Integer;                        { alignment style }
  386.                 refCon: LongInt;                            { reference value for client use }
  387.                 tsmReference: Ptr;                        { Text Services Manager document ID }
  388.                 tsmAreaStart: LongInt;                    { start of active inline input area }
  389.                 tsmAreaEnd: LongInt;                    { end of active inline input area }
  390.                 tsmPreUpdate: ProcPtr;                { called before handling a TSM updt event }
  391.                 tsmPostUpdate: ProcPtr;                { called after handling a TSM updt event }
  392.                 currentDrag: LongInt;                    { reference of drag being tracked by _WEDrag }
  393.                 dragCaretOffset: LongInt;                { offset to caret displayed during a drag }
  394.                 translateDragHook: ProcPtr;            { drag translation hook }
  395.                 hActionStack: Handle;                    { action stack for undo }
  396.                 modCount: LongInt;                        { modification count }
  397.                 nullStyle: WERunAttributes;            { style for null selection }
  398.             end;  { WERec }
  399.         WEPtr = ^WERec;
  400.         WEHandle = ^WEPtr;
  401.  
  402.  
  403.     var
  404.  
  405. { externally defined global variables }
  406.  
  407. {$PUSH}
  408. {$J+}
  409.  
  410.         _WEMainSelectorTable: WELookupTable;
  411.         _WEObjectHandlerSelectorTable: WELookupTable;
  412.  
  413. {$POP}
  414.  
  415. { routines defined in the implementation section of this unit }
  416.  
  417.     function _WEAllocate (blockSize: Size;
  418.                                     allocFlags: Integer;
  419.                                     var h: univ Handle): OSErr;
  420.  
  421. {$IFC WASTE_DEBUG}
  422.  
  423.     procedure _WEAssert (condition: Boolean;
  424.                                     message: string);
  425.  
  426. {$ENDC}
  427.  
  428. { ****** ASSEMBLY ROUTINES DEFINED IN WASTEUTILS.LIB ****** }
  429.  
  430.     procedure _WEForgetHandle (var h: univ Handle);
  431.     function _WESetHandleLock (h: univ Handle;
  432.                                     lock: Boolean): Boolean;
  433.     procedure _WEBlockClr (blockPtr: Ptr;
  434.                                     blockSize: LongInt);
  435.     function _WEBlockCmp (block1, block2: Ptr;
  436.                                     blockSize: LongInt): Boolean;
  437.     function _WEInsertSlot (h: univ Handle;
  438.                                     element: univ Ptr;
  439.                                     insertAt: LongInt;
  440.                                     slotSize: LongInt): OSErr;
  441.     function _WERemoveSlot (h: univ Handle;
  442.                                     removeAt: LongInt;
  443.                                     slotSize: LongInt): OSErr;
  444.     procedure _WEReorder (var a, b: LongInt);
  445.     function _WEGetField (table: WELookupTable;
  446.                                     selector: OSType;
  447.                                     info: univ Ptr;
  448.                                     structure: univ Ptr): OSErr;
  449.     function _WESetField (table: WELookupTable;
  450.                                     selector: OSType;
  451.                                     info: univ Ptr;
  452.                                     structure: univ Ptr): OSErr;
  453.  
  454.  
  455. { ****** USEFUL INLINE ASSEMBLY ****** }
  456.  
  457.     function %_NewHandle (blockSize: Size;
  458.                                     var h: Handle): OSErr;
  459.     inline
  460.         $225F,                                { movea.l (sp)+, a1 }
  461.         $201F,                                { move.l (sp)+, d0 }
  462.         $A122,                                { _NewHandle }
  463.         $3E80,                                 { move.w d0, (sp) }
  464.         $2288;                                { move.l a0, (a1) }
  465.  
  466.     function %_GetHandleSize (h: univ Handle): Size;
  467.     inline
  468.         $205F,                                 { movea.l (sp)+, a0 }
  469.         $A025,                             { _GetHandleSize }
  470.         $2E80,                                 { move.l d0, (sp) }
  471.         $6A02,                             { bpl.s *+4 }
  472.         $4297;                                { clr.l (sp) }
  473.  
  474.     function %_SetHandleSize (h: univ Handle;
  475.                                     blockSize: Size): OSErr;
  476.     inline
  477.         $201F,                                 { move.l (sp)+, d0 }
  478.         $205F,                                { movea.l (sp)+, a0 }
  479.         $A024,                             { _SetHandleSize }
  480.         $3E80;                                { move.w d0, (sp) }
  481.  
  482.     procedure %_BlockMoveData (sourcePtr, destPtr: univ Ptr;
  483.                                     byteCount: LongInt);
  484.     inline
  485.         $201F,                                 { move.l (sp)+, d0 }
  486.         $225F,                                 { movea.l (sp)+, a1 }
  487.         $205F,                                 { movea.l (sp)+, d0 }
  488.         $A22E;                                { _BlockMove, IMMED }
  489.  
  490.     function %_PtrAndHand (thePointer: Ptr;
  491.                                     theHandle: Handle;
  492.                                     theSize: Size): OSErr;
  493.     inline
  494.         $201F,                                { move.l (sp)+, d0 }
  495.         $225F,                                { movea.l (sp)+, a1 }
  496.         $205F,                                { movea.l (sp)+, a0 }
  497.         $A9EF,                                { _PtrAndHand }
  498.         $3E80;                                { move.w d0, (sp) }
  499.  
  500.     procedure %_TextFace (face: Integer);
  501.     inline
  502.         $A888;                                { _TextFace }
  503.  
  504.     function %_Gestalt (selector: OSType;
  505.                                     var response: LongInt): OSErr;
  506.     inline
  507.         $225F,                                 { movea.l (sp)+, a1 }
  508.         $201F,                                 { move.l (sp)+, d0 }
  509.         $A1AD,                             { _Gestalt }
  510.         $3E80,                                 { move.w d0, (sp) }
  511.         $2288;                                { move.l a0, (a1) }
  512.  
  513.     function %_LongMul (dummy, a, b: LongInt): LongInt;
  514.     inline
  515.         $486F, $0008,                     { pea 8(sp)            ; push address of dummy }
  516.         $A867,                             { _LongMul            ; _LongMul returns a 64-bit result }
  517.         $584F;                                { addq.w #4, sp        ; throw away high long }
  518.  
  519.     procedure IgnoreBoolean (b: Boolean);
  520.     inline
  521.         $544F;                                { addq.w #2, sp }
  522.  
  523.     procedure IgnoreShort (w: Integer);
  524.     inline
  525.         $544F;                                { addq.w #2, sp }
  526.  
  527.     procedure IgnoreLong (l: LongInt);
  528.     inline
  529.         $584F;                                { addq.w #4, sp }
  530.  
  531. implementation
  532.  
  533.     function _WEAllocate (blockSize: Size;
  534.                                     allocFlags: Integer;
  535.                                     var h: univ Handle): OSErr;
  536.  
  537. { Allocate a new relocatable block. }
  538. { AllocFlags may specify whether the block should be cleared and whether }
  539. { temporary memory should be used. }
  540.  
  541.         var
  542.             theHandle: Handle;
  543.     begin
  544.         theHandle := nil;
  545.  
  546. { if kAllocTemp is specified, try tapping temporary memory }
  547.         if (BitAnd(allocFlags, kAllocTemp) <> 0) then
  548.             theHandle := TempNewHandle(blockSize, _WEAllocate);
  549.  
  550. { if kAllocTemp isn't specified, or TempNewHandle failed, try with current heap }
  551.         if (theHandle = nil) then
  552.             _WEAllocate := %_NewHandle(blockSize, theHandle);
  553.  
  554. { if kAllocClear is specified, zero the block }
  555.         if (BitAnd(allocFlags, kAllocClear) <> 0) then
  556.             if (theHandle <> nil) then
  557.                 _WEBlockClr(theHandle^, blockSize);
  558.  
  559. { return handle through VAR parameter }
  560.         h := theHandle;
  561.  
  562.     end;  { _WEAllocate }
  563.  
  564. {$IFC WASTE_DEBUG}
  565.  
  566.     procedure _WEAssert (condition: Boolean;
  567.                                     message: string);
  568.     begin
  569.         if (condition = false) then
  570.             begin
  571.                 message := Concat('Assertion Failed: ', message);
  572.                 DebugStr(message);
  573.             end;
  574.     end;  { _WEAssert }
  575.  
  576. {$ENDC}
  577.  
  578. end.