1 % Copyright (C) 2000 artofcode LLC. All rights reserved.
3 % This software is provided AS-IS with no warranty, either express or
6 % This software is distributed under license and may not be copied,
7 % modified or distributed except as expressly authorized under the terms
8 % of the license contained in the file LICENSE in this distribution.
10 % For more information about licensing, please refer to
11 % http://www.ghostscript.com/licensing/. For information on
12 % commercial licensing, go to http://www.artifex.com/licensing/ or
13 % contact Artifex Software, Inc., 101 Lucas Valley Road #110,
14 % San Rafael, CA 94903, U.S.A., +1(415)492-9861.
16 % $Id: gs_resst.ps,v 1.3 2003/08/08 18:45:05 ray Exp $
17 % Redefine generic category with static resource table.
19 languagelevel 2 .setlanguagelevel
21 15 dict begin % a temporary dictionary for local binding.
23 /sep (/) def % The %static% device uses platform independent paths.
25 /tempstring 8192 string def
27 /IsMyRecord % <raw_record> IsMyRecord <raw_record> bool
28 { dup type /dicttype eq { dup /StaticFilePos known } { false } ifelse
31 /append_string % <scratch> <index> <string> append_string <scratch> <index>
33 dup length 3 index 3 index 2 index getinterval % (scratch) index (string) l (scr_substr)
34 3 2 roll exch copy pop add % (scratch) index'
37 /StaticResourceRecordVirtualMethods 4 dict begin
39 /GetFilePath % <scratch> <Name> <record> GetFilePath <filepath>
40 { pop exch % /Name (scratch)
41 (%static%) dup length exch 2 index copy pop % /Name (scratch) l
42 //sep //append_string exec % /Name (scratch) l
43 Category //tempstring cvs //append_string exec % /Name (scratch) l
44 //sep //append_string exec % /Name (scratch) l
45 3 2 roll //tempstring cvs % (scratch) l (Name)
46 //append_string exec % (scratch) l
47 0 exch getinterval % (path)
50 /MakeInstance % <Name> <record> MakeInstance <Name> <Instance> <size>
53 STRESDEBUG { (Loading a static resource ) print dup = } if
54 8192 string 2 index 2 index //GetFilePath exec
56 STRESDEBUG { (Completed loading the static resource ) print dup = } if
57 StaticFileEnd StaticFilePos sub
59 1 index Category findresource
63 /GetSize % <Name> <record> GetSize <size>
65 % WARNING : this retrives file sise rather than VM size
68 StaticFileEnd StaticFilePos sub
72 /IsActive % <record> IsActive <bool>
79 /MappedCategoryRedefiner /ProcSet findresource begin
81 /.StaticResourcesBeg % <end_string> <no_of_resources> <category_name> .StaticResourcesBeg <category_name>
82 % Puts .map dictionary to dstack.
84 STRESDEBUG { (Starting static resources for category ) print dup = } if
85 dup /Category resourcestatus {
86 pop pop exch dict begin exch pop
88 STRESDEBUG { (Skipping the resources because the category isn't defined.) = } if
93 /.StaticResourcesEnd % <category_name> .StaticResourcesEnd -
94 % Removes .map dictionary from dstack.
96 STRESDEBUG { (Completting static resources for category ) print dup = } if
97 currentdict end dup % /CatName <map> <map>
98 systemdict /.io_static_root .knownget not {
99 10 dict % /CatName <map> <map> <dir>
100 % Save it for garbager and for debug purpose :
101 dup systemdict exch /.io_static_root exch put % /CatName <map> <map> <dir>
102 dup .setup_io_static % /CatName <map> <map> <dir>
103 } if % /CatName <map> <map> <dir>
104 exch 3 index exch put % /CatName <map>
106 /.map exch def % /CatName
107 /CategoryName exch def %
108 /IsMapFileOptional true def
109 /VerifyMap { pop } bind def
110 /PreprocessRecord % <map> <Name> <raw_record> PreprocessRecord <map> <Name> <record> <bool>
111 { //IsMyRecord exec dup {
112 pop dup /RecordVirtualMethods //StaticResourceRecordVirtualMethods put
120 end % MappedCategoryRedefiner
121 end % the temporary dictionary for local binding.
123 /.BeginResource % <instance_name> BeginResource <instance_name>
124 % Puts a record dictionary to dstack.
126 STRESDEBUG { (Static resource ) print dup =string cvs print } if
127 currentfile fileposition
128 currentfile =string readline pop dup length 0 exch 10 .min getinterval (%% Replace) ne {
129 % We are in COMPILE_INITS=1 .
131 /StaticFilePos exch def
133 % We are in COMPILE_INITS=0 .
136 (%END_RESOURCE) .skipeof
139 /.EndResource % <instance_name> EndResource -
140 % Removes a record dictionary from dstack.
142 currentdict /StaticFilePos known {
143 /StaticFileEnd currentfile fileposition
144 (.EndResource) length sub
146 STRESDEBUG { ( from position ) print StaticFilePos =string cvs print ( to position ) print StaticFileEnd = } if
150 STRESDEBUG { ( ignored with COMPILE_INITS=0. ) = } if
154 .dicttomark /StaticCategoryRedefiner exch /ProcSet defineresource pop