home *** CD-ROM | disk | FTP | other *** search
/ Mixa 155: Dogs / MIXA 155: Dogs.iso / pc / Viewer / BROWSER(W) / フィルタ / PDF / LIB / gs_btokn.ps < prev    next >
Encoding:
Text File  |  2002-10-29  |  10.2 KB  |  306 lines

  1. %    Copyright (C) 1994, 2000 Aladdin Enterprises.  All rights reserved.
  2. % This software is licensed to a single customer by Artifex Software Inc.
  3. % under the terms of a specific OEM agreement.
  4.  
  5. % $RCSfile: gs_btokn.ps,v $ $Revision: 1.10 $
  6. % Initialization file for binary tokens.
  7. % When this is run, systemdict is still writable,
  8. % but everything defined here goes into level2dict.
  9.  
  10. % Define whether or not to allow writing dictionaries.
  11. % This is a non-standard feature!
  12. /WRITEDICTS false def
  13.  
  14. languagelevel 1 .setlanguagelevel
  15. level2dict begin
  16.  
  17. % Initialization for the system name table.
  18.  
  19. mark
  20. % 0
  21.     /abs /add /aload /anchorsearch /and
  22.     /arc /arcn /arct /arcto /array
  23.     /ashow /astore /awidthshow /begin /bind
  24.     /bitshift /ceiling /charpath /clear /cleartomark
  25. % 20
  26.     /clip /clippath /closepath /concat /concatmatrix
  27.     /copy /count /counttomark /currentcmykcolor /currentdash
  28.     /currentdict /currentfile /currentfont /currentgray /currentgstate
  29.     /currenthsbcolor /currentlinecap /currentlinejoin /currentlinewidth /currentmatrix
  30. % 40
  31.     /currentpoint /currentrgbcolor /currentshared /curveto /cvi
  32.     /cvlit /cvn /cvr /cvrs /cvs
  33.     /cvx /def /defineusername /dict /div
  34.     /dtransform /dup /end /eoclip /eofill
  35. % 60
  36.     /eoviewclip /eq /exch /exec /exit
  37.     /file /fill /findfont /flattenpath /floor
  38.     /flush /flushfile /for /forall /ge
  39.     /get /getinterval /grestore /gsave /gstate
  40. % 80
  41.     /gt /identmatrix /idiv /idtransform /if
  42.     /ifelse /image /imagemask /index /ineofill
  43.     /infill /initviewclip /inueofill /inufill /invertmatrix
  44.     /itransform /known /le /length /lineto
  45. % 100
  46.     /load /loop /lt /makefont /matrix
  47.     /maxlength /mod /moveto /mul /ne
  48.     /neg /newpath /not /null /or
  49.     /pathbbox /pathforall /pop /print /printobject
  50. % 120
  51.     /put /putinterval /rcurveto /read /readhexstring
  52.     /readline /readstring /rectclip /rectfill /rectstroke
  53.     /rectviewclip /repeat /restore /rlineto /rmoveto
  54.     /roll /rotate /round /save /scale
  55. % 140
  56.     /scalefont /search /selectfont /setbbox /setcachedevice
  57.     /setcachedevice2 /setcharwidth /setcmykcolor /setdash /setfont
  58.     /setgray /setgstate /sethsbcolor /setlinecap /setlinejoin
  59.     /setlinewidth /setmatrix /setrgbcolor /setshared /shareddict
  60. % 160
  61.     /show /showpage /stop /stopped /store
  62.     /string /stringwidth /stroke /strokepath /sub
  63.     /systemdict /token /transform /translate /truncate
  64.     /type /uappend /ucache /ueofill /ufill
  65. % 180
  66.     /undef /upath /userdict /ustroke /viewclip
  67.     /viewclippath /where /widthshow /write /writehexstring
  68.     /writeobject /writestring /wtranslation /xor /xshow
  69.     /xyshow /yshow /FontDirectory /SharedFontDirectory /Courier
  70. % 200
  71.     /Courier-Bold /Courier-BoldOblique /Courier-Oblique /Helvetica /Helvetica-Bold
  72.     /Helvetica-BoldOblique /Helvetica-Oblique /Symbol /Times-Bold /Times-BoldItalic
  73.     /Times-Italic /Times-Roman /execuserobject /currentcolor /currentcolorspace
  74.     /currentglobal /execform /filter /findresource /globaldict
  75. % 220
  76.     /makepattern /setcolor /setcolorspace /setglobal /setpagedevice
  77.     /setpattern
  78. % pad to 256
  79.     counttomark 256 exch sub { 0 } repeat
  80. % 256
  81.     /= /== /ISOLatin1Encoding /StandardEncoding
  82. % 260
  83.     ([) cvn (]) cvn /atan /banddevice /bytesavailable
  84.     /cachestatus /closefile /colorimage /condition /copypage
  85.     /cos /countdictstack /countexecstack /cshow /currentblackgeneration
  86.     /currentcacheparams /currentcolorscreen /currentcolortransfer /currentcontext /currentflat
  87. % 280
  88.     /currenthalftone /currenthalftonephase /currentmiterlimit /currentobjectformat /currentpacking
  89.     /currentscreen /currentstrokeadjust /currenttransfer /currentundercolorremoval /defaultmatrix
  90.     /definefont /deletefile /detach /deviceinfo /dictstack
  91.     /echo /erasepage /errordict /execstack /executeonly
  92. % 300
  93.     /exp /false /filenameforall /fileposition /fork
  94.     /framedevice /grestoreall /handleerror /initclip /initgraphics
  95.     /initmatrix /instroke /inustroke /join /kshow
  96.     /ln /lock /log /mark /monitor
  97. % 320
  98.     /noaccess /notify /nulldevice /packedarray /quit
  99.     /rand /rcheck /readonly /realtime /renamefile
  100.     /renderbands /resetfile /reversepath /rootfont /rrand
  101.     /run /scheck /setblackgeneration /setcachelimit /setcacheparams
  102. % 340
  103.     /setcolorscreen /setcolortransfer /setfileposition /setflat /sethalftone
  104.     /sethalftonephase /setmiterlimit /setobjectformat /setpacking /setscreen
  105.     /setstrokeadjust /settransfer /setucacheparams /setundercolorremoval /sin
  106.     /sqrt /srand /stack /status /statusdict
  107. % 360
  108.     /true /ucachestatus /undefinefont /usertime /ustrokepath
  109.     /version /vmreclaim /vmstatus /wait /wcheck
  110.     /xcheck /yield /defineuserobject /undefineuserobject /UserObjects
  111.     /cleardictstack
  112. % 376
  113.     /A /B /C /D /E /F /G /H /I /J /K /L /M
  114.     /N /O /P /Q /R /S /T /U /V /W /X /Y /Z
  115.     /a /b /c /d /e /f /g /h /i /j /k /l /m
  116.     /n /o /p /q /r /s /t /u /v /w /x /y /z
  117. % 428
  118.     /setvmthreshold (<<) cvn
  119.     (>>) cvn /currentcolorrendering /currentdevparams /currentoverprint /currentpagedevice
  120.     /currentsystemparams /currentuserparams /defineresource /findencoding /gcheck
  121. % 440
  122.     /glyphshow /languagelevel /product /pstack /resourceforall
  123.     /resourcestatus /revision /serialnumber /setcolorrendering /setdevparams
  124.     /setoverprint /setsystemparams /setuserparams /startjob /undefineresource
  125.     /GlobalFontDirectory /ASCII85Decode /ASCII85Encode /ASCIIHexDecode /ASCIIHexEncode
  126. % 460
  127.     /CCITTFaxDecode /CCITTFaxEncode /DCTDecode /DCTEncode /LZWDecode
  128.     /LZWEncode /NullEncode /RunLengthDecode /RunLengthEncode /SubFileDecode
  129.     /CIEBasedA /CIEBasedABC /DeviceCMYK /DeviceGray /DeviceRGB
  130.     /Indexed /Pattern /Separation /CIEBasedDEF /CIEBasedDEFG
  131. % 480
  132.     /DeviceN
  133. % 481 -- end
  134. .packtomark
  135. dup /SystemNames exch def .installsystemnames
  136.  
  137. % Define printobject and writeobject.
  138. % These are mostly implemented in PostScript, so that we don't have to
  139. % worry about interrupts or callbacks when writing to the output file.
  140.  
  141. % Define procedures for accumulating the space required to represent
  142. % an object in binary form.
  143. /cntdict mark        % <#refs> <#chars> <obj> -proc- <#refs> <#chars>
  144.   /integertype /pop load
  145.   /realtype 1 index
  146.   /marktype 1 index
  147.   /nulltype 1 index
  148.   /booleantype 1 index
  149.   /nametype { length add } bind
  150.   /stringtype 1 index
  151.   /arraytype null
  152.   /dicttype null
  153. .dicttomark def
  154. cntdict /arraytype {
  155.   dup dup length 5 -1 roll add 4 2 roll {
  156.     dup type //cntdict exch get exec
  157.   } forall
  158. } bind put
  159. cntdict /dicttype {
  160.   WRITEDICTS {
  161.     dup dup length 2 mul 5 -1 roll add 4 2 roll {
  162.       4 1 roll dup type //cntdict exch get exec
  163.       3 -1 roll dup type //cntdict exch get exec
  164.     } forall
  165.   } {
  166.     /writeobject load /typecheck signalerror
  167.   } ifelse
  168. } bind put
  169.  
  170. /w2dict mark
  171.   /nametype { 2 copy .writecvs pop } bind
  172.   /stringtype 1 index
  173. .dicttomark def
  174.  
  175. /.bosheader {        % <top_length> <total_length> <string8> .bosheader
  176.             %   <string4|8>
  177.   dup 0 currentobjectformat 127 add put        % object format => BOS tag
  178.   2 index 255 le 2 index 65531 le and {
  179.     % Use the short header format: tag toplen(1) totlen(2)
  180.     exch 4 add exch
  181.     0 4 getinterval
  182.     dup 1 5 -1 roll put
  183.   } {
  184.     % Use the long header format: tag 0(1) toplen(2) totlen(4)
  185.     exch 8 add exch
  186.     0 0 4 2 roll .bosobject exch pop exch pop    % store with byte swapping
  187.   } ifelse        % Stack: shortlen str
  188.   exch dup -8 bitshift exch 255 and    % str hibyte lobyte
  189.   currentobjectformat 1 and 0 eq {    % lsb first
  190.     exch
  191.   } if
  192.   2 index 3 3 -1 roll put
  193.   1 index 2 3 -1 roll put
  194. } .bind def
  195.  
  196. /.writeobjects {    % <file> <tag> <array> .writeobjects -
  197.   mark exch
  198.  
  199.     % Count the space required for refs and strings.
  200.  
  201.   dup length 0 3 -1 roll
  202.     % Stack: file tag -mark- #refs #chars array
  203.   dup 4 1 roll {
  204.     dup type //cntdict exch get exec
  205.    } forall
  206.  
  207.     % Write the header.
  208.  
  209.     % Stack: file tag -mark- array1 ... array|dictN #refs #chars
  210.   counttomark 3 add -2 roll 4 1 roll
  211.     % Stack: -mark- array1 ... array|dictN tag #refs #chars file
  212.   dup counttomark 1 sub index length
  213.   4 index 3 bitshift 4 index add
  214.   (xxxxxxxx) .bosheader writestring
  215.  
  216.     % Write the objects per se.
  217.  
  218.   3 1 roll pop
  219.   counttomark 1 sub index length 3 bitshift exch
  220.   3 bitshift
  221.     % Stack: -mark- array1 ... array|dictN tag file ref# char#
  222.   counttomark 4 sub {
  223.     counttomark -1 roll dup 6 1 roll
  224.     dup type /dicttype eq {        % can't be first object
  225.       { 5 1 roll (xxxxxxxx) .bosobject
  226.     3 index exch writestring
  227.     4 -1 roll (xxxxxxxx) .bosobject
  228.     3 index exch writestring
  229.       } forall
  230.     } {
  231.       { (xxxxxxxx) .bosobject
  232.     dup 1 6 index put
  233.     3 index exch writestring
  234.     4 -1 roll pop 0 4 1 roll    % clear tag
  235.       } forall
  236.     } ifelse
  237.   } repeat
  238.  
  239.     % Write the strings and names.
  240.  
  241.   pop pop exch pop
  242.     % Stack: -mark- array1 ... array|dictN file
  243.   counttomark 1 sub {
  244.     counttomark -1 roll {
  245.         % The counting pass ensured that the keys and values
  246.         % of any dictionary must be writable objects.
  247.         % Hence, we are processing a dictionary iff
  248.         % the next-to-top stack element is not a file.
  249.       1 index type /filetype ne {
  250.     exch 2 index exch dup type //w2dict exch .knownget
  251.      { exec } { pop } ifelse pop
  252.       } if
  253.       dup type //w2dict exch .knownget { exec } { pop } ifelse
  254.     } forall
  255.   } repeat
  256.  
  257.     % Clean up.
  258.  
  259.     % Stack: -mark- file
  260.   pop pop
  261.  
  262. } odef
  263.  
  264. /printobject {        % <obj> <tag> printobject -
  265.   (%stdout) (w) file 2 index 2 index writeobject pop pop
  266. } odef
  267. /writeobject {        % <file> <obj> <tag> writeobject -
  268.   3 copy exch
  269.         % We must allocate the array in local VM
  270.         % to avoid a possible invalidaccess.
  271.   .currentglobal false .setglobal exch 1 array astore exch .setglobal
  272.   .writeobjects pop pop pop
  273. } odef
  274.  
  275. % Implement binary error message output.
  276. /.objectprinttest {        % <obj> .objectprinttest -
  277.         % This is a pseudo-operator so it will restore the stack
  278.         % if it gets an error.
  279.   0 0 2 index dup type //cntdict exch get exec pop pop
  280. } bind odef
  281. /.printerror {
  282.   $error /binary get .languagelevel 2 ge and {
  283.     currentobjectformat 0 ne {
  284.       [ /Error $error /errorname get $error /command get
  285.         % Convert the object with cvs if it isn't printable.
  286.       dup { .objectprinttest } .internalstopped {
  287.     pop 100 string cvs
  288.       } if
  289.       false ] 250 printobject
  290.     }
  291.     //.printerror    % known to be a procedure
  292.     ifelse
  293.   }
  294.   //.printerror        % known to be a procedure
  295.   ifelse
  296. } bind def
  297.  
  298. currentdict /cntdict .undef
  299. currentdict /w2dict .undef
  300.  
  301. % End of level2dict
  302.  
  303. end
  304. .setlanguagelevel
  305.