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
|
% Copyright (C) 2000 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.
%
% For more information about licensing, please refer to
% http://www.ghostscript.com/licensing/. For information on
% commercial licensing, go to http://www.artifex.com/licensing/ or
% contact Artifex Software, Inc., 101 Lucas Valley Road #110,
% San Rafael, CA 94903, U.S.A., +1(415)492-9861.
% $Id: gs_resst.ps 8022 2007-06-05 22:23:38Z giles $
% Redefine generic category with static resource table.
languagelevel 2 .setlanguagelevel
15 dict begin % a temporary dictionary for local binding.
/sep (/) def % The %static% device uses platform independent paths.
/tempstring 8192 string def
/IsMyRecord % <raw_record> IsMyRecord <raw_record> bool
{ dup type /dicttype eq { dup /StaticFilePos known } { false } ifelse
} bind def
/append_string % <scratch> <index> <string> append_string <scratch> <index>
{
dup length 3 index 3 index 2 index getinterval % (scratch) index (string) l (scr_substr)
3 2 roll exch copy pop add % (scratch) index'
} bind def
/StaticResourceRecordVirtualMethods 4 dict begin
/GetFilePath % <scratch> <Name> <record> GetFilePath <filepath>
{ pop exch % /Name (scratch)
(%static%) dup length exch 2 index copy pop % /Name (scratch) l
//sep //append_string exec % /Name (scratch) l
Category //tempstring cvs //append_string exec % /Name (scratch) l
//sep //append_string exec % /Name (scratch) l
3 2 roll //tempstring cvs % (scratch) l (Name)
//append_string exec % (scratch) l
0 exch getinterval % (path)
} bind def
/MakeInstance % <Name> <record> MakeInstance <Name> <Instance> <size>
{
begin
STRESDEBUG { (Loading a static resource ) print dup = } if
8192 string 2 index 2 index //GetFilePath exec
(r) file run
STRESDEBUG { (Completed loading the static resource ) print dup = } if
StaticFileEnd StaticFilePos sub
end
1 index Category findresource
exch
} bind def
/GetSize % <Name> <record> GetSize <size>
{
% WARNING : this retrives file sise rather than VM size
begin
pop
StaticFileEnd StaticFilePos sub
end
} bind def
/IsActive % <record> IsActive <bool>
{ pop true
} bind def
currentdict end def
mark
/MappedCategoryRedefiner /ProcSet findresource begin
/.StaticResourcesBeg % <end_string> <no_of_resources> <category_name> .StaticResourcesBeg <category_name>
% Puts .map dictionary to dstack.
{
STRESDEBUG { (Starting static resources for category ) print dup = } if
dup /Category resourcestatus {
pop pop exch dict begin exch pop
} {
STRESDEBUG { (Skipping the resources because the category isn't defined.) = } if
pop pop .skipeof
} ifelse
} bind
/.StaticResourcesEnd % <category_name> .StaticResourcesEnd -
% Removes .map dictionary from dstack.
{
STRESDEBUG { (Completting static resources for category ) print dup = } if
currentdict end dup % /CatName <map> <map>
systemdict /.io_static_root .knownget not {
10 dict % /CatName <map> <map> <dir>
% Save it for garbager and for debug purpose :
dup systemdict exch /.io_static_root exch put % /CatName <map> <map> <dir>
dup .setup_io_static % /CatName <map> <map> <dir>
} if % /CatName <map> <map> <dir>
exch 3 index exch put % /CatName <map>
14 dict begin
/.map exch def % /CatName
/CategoryName exch def %
/IsMapFileOptional true def
/VerifyMap { pop } bind def
/PreprocessRecord % <map> <Name> <raw_record> PreprocessRecord <map> <Name> <record> <bool>
{ //IsMyRecord exec dup {
pop dup /RecordVirtualMethods //StaticResourceRecordVirtualMethods put
true
} if
} bind def
currentdict end
//Redefine exec
} bind
end % MappedCategoryRedefiner
end % the temporary dictionary for local binding.
/.BeginResource % <instance_name> BeginResource <instance_name>
% Puts a record dictionary to dstack.
{
STRESDEBUG { (Static resource ) print dup =string cvs print } if
currentfile fileposition
currentfile =string readline pop dup length 0 exch 10 .min getinterval (%% Replace) ne {
% We are in COMPILE_INITS=1 .
4 dict begin
/StaticFilePos exch def
} {
% We are in COMPILE_INITS=0 .
pop
} ifelse
(%END_RESOURCE) .skipeof
} bind
/.EndResource % <instance_name> EndResource -
% Removes a record dictionary from dstack.
{
currentdict /StaticFilePos known {
/StaticFileEnd currentfile fileposition
(.EndResource) length sub
def
STRESDEBUG { ( from position ) print StaticFilePos =string cvs print ( to position ) print StaticFileEnd = } if
currentdict end def
} {
pop
STRESDEBUG { ( ignored with COMPILE_INITS=0. ) = } if
} ifelse
} bind
.dicttomark /StaticCategoryRedefiner exch /ProcSet defineresource pop
.setlanguagelevel
|