summaryrefslogtreecommitdiff
path: root/Master/tlpkg/tlgs/Resource/Init/gs_btokn.ps
blob: 1f63fb5c4e004124a8f1ae50544181662fa56eaf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
% Copyright (C) 2001-2021 Artifex Software, Inc.
% All Rights Reserved.
%
% This software is provided AS-IS with no warranty, either express or
% implied.
%
% This software is distributed under license and may not be copied,
% modified or distributed except as expressly authorized under the terms
% of the license contained in the file LICENSE in this distribution.
%
% Refer to licensing information at http://www.artifex.com or contact
% Artifex Software, Inc.,  1305 Grant Avenue - Suite 200, Novato,
% CA 94945, U.S.A., +1(415)492-9861, for further information.
%

% Initialization file for binary tokens.
% When this is run, systemdict is still writable,
% but everything defined here goes into level2dict.

% Define whether or not to allow writing dictionaries.
% This is a non-standard feature!
/WRITEDICTS //false def

languagelevel 1 .setlanguagelevel
level2dict begin

% Initialization for the system name table.

mark
% 0
        /abs /add /aload /anchorsearch /and
        /arc /arcn /arct /arcto /array
        /ashow /astore /awidthshow /begin /bind
        /bitshift /ceiling /charpath /clear /cleartomark
% 20
        /clip /clippath /closepath /concat /concatmatrix
        /copy /count /counttomark /currentcmykcolor /currentdash
        /currentdict /currentfile /currentfont /currentgray /currentgstate
        /currenthsbcolor /currentlinecap /currentlinejoin /currentlinewidth /currentmatrix
% 40
        /currentpoint /currentrgbcolor /currentshared /curveto /cvi
        /cvlit /cvn /cvr /cvrs /cvs
        /cvx /def /defineusername /dict /div
        /dtransform /dup /end /eoclip /eofill
% 60
        /eoviewclip /eq /exch /exec /exit
        /file /fill /findfont /flattenpath /floor
        /flush /flushfile /for /forall /ge
        /get /getinterval /grestore /gsave /gstate
% 80
        /gt /identmatrix /idiv /idtransform /if
        /ifelse /image /imagemask /index /ineofill
        /infill /initviewclip /inueofill /inufill /invertmatrix
        /itransform /known /le /length /lineto
% 100
        /load /loop /lt /makefont /matrix
        /maxlength /mod /moveto /mul /ne
        /neg /newpath /not /null /or
        /pathbbox /pathforall /pop /print /printobject
% 120
        /put /putinterval /rcurveto /read /readhexstring
        /readline /readstring /rectclip /rectfill /rectstroke
        /rectviewclip /repeat /restore /rlineto /rmoveto
        /roll /rotate /round /save /scale
% 140
        /scalefont /search /selectfont /setbbox /setcachedevice
        /setcachedevice2 /setcharwidth /setcmykcolor /setdash /setfont
        /setgray /setgstate /sethsbcolor /setlinecap /setlinejoin
        /setlinewidth /setmatrix /setrgbcolor /setshared /shareddict
% 160
        /show /showpage /stop /stopped /store
        /string /stringwidth /stroke /strokepath /sub
        /systemdict /token /transform /translate /truncate
        /type /uappend /ucache /ueofill /ufill
% 180
        /undef /upath /userdict /ustroke /viewclip
        /viewclippath /where /widthshow /write /writehexstring
        /writeobject /writestring /wtranslation /xor /xshow
        /xyshow /yshow /FontDirectory /SharedFontDirectory /Courier
% 200
        /Courier-Bold /Courier-BoldOblique /Courier-Oblique /Helvetica /Helvetica-Bold
        /Helvetica-BoldOblique /Helvetica-Oblique /Symbol /Times-Bold /Times-BoldItalic
        /Times-Italic /Times-Roman /execuserobject /currentcolor /currentcolorspace
        /currentglobal /execform /filter /findresource /globaldict
% 220
        /makepattern /setcolor /setcolorspace /setglobal /setpagedevice
        /setpattern
% pad to 256
        counttomark 256 exch sub { 0 } repeat
% 256
        /= /== /ISOLatin1Encoding /StandardEncoding
% 260
        ([) cvn (]) cvn /atan /banddevice /bytesavailable
        /cachestatus /closefile /colorimage /condition /copypage
        /cos /countdictstack /countexecstack /cshow /currentblackgeneration
        /currentcacheparams /currentcolorscreen /currentcolortransfer /currentcontext /currentflat
% 280
        /currenthalftone /currenthalftonephase /currentmiterlimit /currentobjectformat /currentpacking
        /currentscreen /currentstrokeadjust /currenttransfer /currentundercolorremoval /defaultmatrix
        /definefont /deletefile /detach /deviceinfo /dictstack
        /echo /erasepage /errordict /execstack /executeonly
% 300
        /exp /false /filenameforall /fileposition /fork
        /framedevice /grestoreall /handleerror /initclip /initgraphics
        /initmatrix /instroke /inustroke /join /kshow
        /ln /lock /log /mark /monitor
% 320
        /noaccess /notify /nulldevice /packedarray /quit
        /rand /rcheck /readonly /realtime /renamefile
        /renderbands /resetfile /reversepath /rootfont /rrand
        /run /scheck /setblackgeneration /setcachelimit /setcacheparams
% 340
        /setcolorscreen /setcolortransfer /setfileposition /setflat /sethalftone
        /sethalftonephase /setmiterlimit /setobjectformat /setpacking /setscreen
        /setstrokeadjust /settransfer /setucacheparams /setundercolorremoval /sin
        /sqrt /srand /stack /status /statusdict
% 360
        /true /ucachestatus /undefinefont /usertime /ustrokepath
        /version /vmreclaim /vmstatus /wait /wcheck
        /xcheck /yield /defineuserobject /undefineuserobject /UserObjects
        /cleardictstack
% 376
        /A /B /C /D /E /F /G /H /I /J /K /L /M
        /N /O /P /Q /R /S /T /U /V /W /X /Y /Z
        /a /b /c /d /e /f /g /h /i /j /k /l /m
        /n /o /p /q /r /s /t /u /v /w /x /y /z
% 428
        /setvmthreshold (<<) cvn
        (>>) cvn /currentcolorrendering /currentdevparams /currentoverprint /currentpagedevice
        /currentsystemparams /currentuserparams /defineresource /findencoding /gcheck
% 440
        /glyphshow /languagelevel /product /pstack /resourceforall
        /resourcestatus /revision /serialnumber /setcolorrendering /setdevparams
        /setoverprint /setsystemparams /setuserparams /startjob /undefineresource
        /GlobalFontDirectory /ASCII85Decode /ASCII85Encode /ASCIIHexDecode /ASCIIHexEncode
% 460
        /CCITTFaxDecode /CCITTFaxEncode /DCTDecode /DCTEncode /LZWDecode
        /LZWEncode /NullEncode /RunLengthDecode /RunLengthEncode /SubFileDecode
        /CIEBasedA /CIEBasedABC /DeviceCMYK /DeviceGray /DeviceRGB
        /Indexed /Pattern /Separation /CIEBasedDEF /CIEBasedDEFG
% 480
        /DeviceN
% 481 -- end
//.packtomark exec .installsystemnames

% Define printobject and writeobject.
% These are mostly implemented in PostScript, so that we don't have to
% worry about interrupts or callbacks when writing to the output file.

% Define procedures for accumulating the space required to represent
% an object in binary form.
%	<#refs> <#chars> <obj> -proc- <#refs'> <#chars'>
/cntdict mark
  /integertype /pop load
  /realtype 1 index
  /marktype 1 index
  /nulltype 1 index
  /booleantype 1 index
  /nametype { length add } .bind
  /stringtype 1 index
  /arraytype 0	% replaced below
  /dicttype 0	% replaced below
.dicttomark def
/.cntobj {
  dup type //cntdict exch get exec
} .bind def
cntdict /arraytype {
  dup length            % #refs #chars array len
  4 -1 roll add         % #chars array #refs+len
  dup 65536 gt {
    /writeobject .systemvar /limitcheck signalerror
  } if
  3 1 roll              % #refs+len #chars array
  //.cntobj forall
} .bind put	% replace arraytype in cntdict

cntdict /dicttype {
  /writeobject .systemvar /typecheck signalerror
} bind put


/.bosheader {		% <top_length> <total_length> <string8> .bosheader
                        %   <string4|8>
  dup 0 currentobjectformat 127 add put		% object format => BOS tag
  2 index 255 le 2 index 65531 le and {
        % Use the short header format: tag toplen(1) totlen(2)
    exch 4 add exch
    0 4 getinterval
    dup 1 5 -1 roll put
  } {
        % Use the long header format: tag 0(1) toplen(2) totlen(4)
    exch 8 add exch
     0 0 4 2 roll .bosobject exch pop exch pop	% store with byte swapping
  } ifelse		% Stack: shortlen str
  exch dup -8 bitshift exch 255 and	% str hibyte lobyte
  currentobjectformat 1 and 0 eq {	% lsb first
    exch
  } if
  2 index 3 3 -1 roll put
  1 index 2 3 -1 roll put
} .bind def

/.writeobjects {	% <file> <tag> <array> .writeobjects -
  % Apply the tag early and forget about it.
  (12345678) dup 1 5 -1 roll       % file array (...) (...) 1 tag
  put exch                         % file (.t.) array

  % Calculate the space required for refs and strings.
  % Reject excessively large graphs or graphs with loops.
  0 0                              % file (.t.) array #refs #chars
  2 index //.cntobj exec           % file (.t.) array #refs #chars

  % Write the header.
  1 index 8 mul add                % file (.t.) array #refs #refs*8+#chars
  2 index length exch (12345678)   % file (.t.) array #refs len(array) #refs*8+#chars (...)
  //.bosheader exec                % file (.t.) array #refs (...)
  4 index exch writestring         % file (.t.) array #refs

  % Traverse an array tree in width-first order and place all the
  % arrays that are found on the operand stack. Acyclic graphs are
  % expanded to trees. The top parameter K indicates the number
  % of arrays on a given depth level. At the root level, K is equal to 1.
  mark 2 index 1                   % file (.t.) array #refs -mark- array K
  { dup 0 le { pop exit } if
    dup {
      dup index {
        dup type /arraytype eq {
          exch 1 add
        } {
          pop
        } ifelse
      } forall
      1 sub
    } repeat
  } loop                           % file (.t.) array #refs -mark- array1 ... arrayN
  counttomark 5 add -4 roll        % -mark- array1 ... arrayN file (.t.) array #refs

  % Write the content of the root array
  8 mul                            % -mark- array1 ... arrayN file (.t.) array #refs*8
  exch dup length 8 mul            % -mark- array1 ... arrayN file (.t.) #refs*8 array len(array)*8
  3 1 roll                         % -mark- array1 ... arrayN file (.t.) len(array)*8 #refs*8 array
  { 3 index                        % -mark- array1 ... arrayN file (.t.) len(array)*8 #refs*8 obj (.t.)
    .bosobject                     % -mark- array1 ... arrayN file (.t.) len(array)*8 #refs*8 (.t.)
    4 index exch writestring       % -mark- array1 ... arrayN file (.t.) len(array)*8 #refs*8
  } forall
  3 -1 roll pop                    % -mark- array1 ... arrayN file len(array)*8 #refs*8

  % Write the remaining arrays
  counttomark 2 sub -1 3 {
    index {                       % ... file #refs #str obj
        (1\000345678) .bosobject  % ... file #refs #str (...)
        3 index exch writestring  % ... file #refs #str
    } forall
  } for
  pop pop                         % -mark- array1 ... arrayN file

  % Write strings and names.
  counttomark 1 sub -1 1 {
    index {
      dup type /nametype eq {
        .namestring
      } if
      dup type /stringtype eq {
        1 index exch writestring
      } {
        pop
      } ifelse
    } forall
  } for

  cleartomark		% Clean up
} .bind def

/.writeobject {
  3 copy exch
                % We must allocate the array in local VM
                % to avoid a possible invalidaccess.
  .currentglobal //false .setglobal exch 1 array astore exch .setglobal
  //.writeobjects exec pop pop pop
} .bind def

/printobject {		% <obj> <tag> printobject -
  currentobjectformat 0 eq {
      /printobject .systemvar /undefined signalerror
  } if
  (%stdout) (w) file 2 index 2 index //.writeobject exec pop pop
} odef

/writeobject {		% <file> <obj> <tag> writeobject -
  currentobjectformat 0 eq {
      /writeobject .systemvar /undefined signalerror
  } if
  2 .argindex pop	% check # of args
  //.writeobject exec
} odef

% Implement binary error message output.
/.objectprinttest {		% <obj> .objectprinttest -
                % This is a pseudo-operator so it will restore the stack
                % if it gets an error.
  mark 0 0 3 .argindex //.cntobj exec cleartomark pop
} bind def
/.printerror {
  $error /binary get .languagelevel 2 ge and {
    currentobjectformat 0 ne {
      [ /Error $error /errorname get $error /command get
                % Convert the object with cvs if it isn't printable.
      dup { //.objectprinttest exec } //.internalstopped exec {
        pop 100 string cvs
      } if
      //false ] 250 printobject
    }
    //.printerror	% known to be a procedure
    ifelse
  }
  //.printerror		% known to be a procedure
  ifelse
} bind def

currentdict /cntdict .undef

% End of level2dict

end
.setlanguagelevel

% undefine things defined in this file and not referenced elsewhere
[
    /.objectprinttest
    /.bosheader
    /.cntobj
    /.writeobject
    /.writeobjects
] dup level2dict .undefinternalnames
systemdict .undefinternalnames