Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.postscript > #1649 > unrolled thread

Named Resources

Started byluser- -droog <mijoryx@yahoo.com>
First post2013-09-24 15:19 -0700
Last post2017-08-30 19:24 +0200
Articles 9 — 5 participants

Back to article view | Back to comp.lang.postscript


Contents

  Named Resources luser- -droog <mijoryx@yahoo.com> - 2013-09-24 15:19 -0700
    Re: Named Resources John Deubert <john@acumentraining.com> - 2013-09-27 07:31 -0700
      Re: Named Resources luser- -droog <mijoryx@yahoo.com> - 2013-09-29 22:32 -0700
    Re: Named Resources John Deubert <john@acumentraining.com> - 2013-09-27 07:44 -0700
    Re: Named Resources John Deubert <john@acumentraining.com> - 2013-09-27 07:49 -0700
    Re: Named Resources John Deubert <john@acumentraining.com> - 2013-09-27 08:44 -0700
    Re: Named Resources wst wst <wouter_staelens@hotmail.com> - 2017-08-29 02:02 -0700
      Re: Named Resources luser droog <luser.droog@gmail.com> - 2017-08-29 19:25 -0700
      Re: Named Resources Carlos <carlos@cvkm.cz> - 2017-08-30 19:24 +0200

#1649 — Named Resources

Fromluser- -droog <mijoryx@yahoo.com>
Date2013-09-24 15:19 -0700
SubjectNamed Resources
Message-ID<ad8a9d89-952f-4e17-8ff8-2fbd8ce6e26e@googlegroups.com>
I've spent the last few weeks trying to wrap my head 
around how to implement Named Resources. I'm just going
to talk about what I think I know. Please correct any 
mistakes!

Named Resources exist in up to 3 places at any given time
while "part of the system".

  * in a filesystem directory
  * in a data structure in local vm
  * in a data structure in global vm

So, I'm going to create 2 data structures, 
as a rough start:

true setglobal
globaldict begin
/globalresourcedict <<
    /Category <<
    >>  
    /Generic <<
    >>  
    /ProcSet <<
    >>  
>> def 
end

false setglobal
userdict begin
/localresourcedict <<
    /Encoding <<
        /StandardEncoding [ ] 
        /ISOLatin1Encoding [ ] 
    >>  
>> def 
end

I still don't understand Category and Generic. :(

[toc] | [next] | [standalone]


#1656

FromJohn Deubert <john@acumentraining.com>
Date2013-09-27 07:31 -0700
Message-ID<2013092707315563519-john@acumentrainingcom>
In reply to#1649
On 2013-09-24 22:19:43 +0000, luser- -droog said:

> I've spent the last few weeks trying to wrap my head
> around how to implement Named Resources. I'm just going
> to talk about what I think I know. Please correct any
> mistakes!
> 
> Named Resources exist in up to 3 places at any given time
> while "part of the system".
> 
>   * in a filesystem directory
>   * in a data structure in local vm
>   * in a data structure in global vm
> 
> So, I'm going to create 2 data structures,
> as a rough start:
> 
> true setglobal
> globaldict begin
> /globalresourcedict <<
>     /Category <<
>     >>
>     /Generic <<
>     >>
>     /ProcSet <<
>     >>
>>> def
> end
> 
> false setglobal
> userdict begin
> /localresourcedict <<
>     /Encoding <<
>         /StandardEncoding [ ]
>         /ISOLatin1Encoding [ ]
>     >>
>>> def
> end
> 
> I still don't understand Category and Generic. :(


Category is the resource category that keeps track of resource 
categories. (That sentence was a paragon of clarity, no?)

The resources in the Category category have names like /Form, /Font, 
/Pattern, /Encoding, etc. The resource data associated with each of 
these names is a dictionary whose contents are mostly procedures with 
names corresponding to the resource-related PostScript operators, 
though capitalized differently: /FindResource, /DefineResource, 
/ResourceForAll, etc. These are the procedures that implement the 
operator activities for that particular resource category.

The findresource operator does the following:
	/Category findresource /FindResource get exec

That is, if you do this:
	/Helvetica /Font findresource

The findresource operator gets the Font Category resource dictionary, 
fetches the FindResource procedure from that dictionary, and then 
executes it. The other resource operators do similar things.

The Generic category is used when you want to create your own resource 
Category. Creating your own category is simple, in principle: just 
create a new Category resource:

/MyNewCategory
<<
	/DefineResource { … }
	/FindResource { … }
	…
>> /Category defineresource

The Generic category exists so you don’t need to forever be coming up 
with your own definitions for those operator-implementation procedures. 
You can simply copy the procedures from the Generic category 
dictionary. (The Generic procedures are parameterized based on the name 
of the category.)

Thus, to create a BBox resource category (to use an example from my 
Advanced PostScript class), you’d do this:

/BBox
	/Generic /Category findresource		% Get the Generic category dict
	dup length dict					% Create an identically-sized dict
	copy									% and copy Generic into the new dict
/Category defineresource pop			% Then make it a resource.

% Now you can create BBox resources:
/Letter [ 0 0 612 792 ] /BBox defineresource pop

% And use them
/Letter /BBox findresource clip

Hope that helped some. Resources takes quite a while to get the hang 
of; it’s a two-hour discussion in the Advanced PostScript class.

In particular, using resources aren’t extremely useful (for what I 
usually do, anyway) unless you have external storage available to the 
interpreter. In that case, you can arrange it so that findresource 
looks on the disk if it doesn’t find the resource you want in memory; 
all future programs sent to that interpreter can use BBox resources (or 
whatever) with no initial work.

I hope some part of that was lucid.

- John


========
John Deubert
Acumen Training
PostScript & PDF Engineering Classes & Consulting
www.acumentraining.com

Learn PostScript programming techniques
Read the free Acumen Journal
acumentraining.com/acumenjournal.html

[toc] | [prev] | [next] | [standalone]


#1664

Fromluser- -droog <mijoryx@yahoo.com>
Date2013-09-29 22:32 -0700
Message-ID<c49d27db-66b0-44b1-a979-465673691d29@googlegroups.com>
In reply to#1656
On Friday, September 27, 2013 9:31:55 AM UTC-5, John Deubert wrote:
> On 2013-09-24 22:19:43 +0000, luser- -droog said:
> 
> 
> 
> > I've spent the last few weeks trying to wrap my head
> > around how to implement Named Resources. I'm just going
> > to talk about what I think I know. Please correct any
> > mistakes!
> > 
> > Named Resources exist in up to 3 places at any given time
> > while "part of the system".
> > 
> >   * in a filesystem directory
> >   * in a data structure in local vm
> >   * in a data structure in global vm
> > 
> > So, I'm going to create 2 data structures,
> > as a rough start:
> > 
> > true setglobal
> > globaldict begin
> > /globalresourcedict <<
> >     /Category <<

Here's one error, I think. /Generic belongs inside the /Category dict. 
It's unclear to me whether it exists as a category in its own right.

> >     >>
> >     /Generic <<
> >     >>

> >     /ProcSet <<
> >     >>
> >>> def
> > end
> > 
> > false setglobal
> > userdict begin
> > /localresourcedict <<
> >     /Encoding <<
> >         /StandardEncoding [ ]
> >         /ISOLatin1Encoding [ ]
> >     >>
> >>> def
> > end
> > 
> > I still don't understand Category and Generic. :(
> 
> 
> 
> 
> 
> Category is the resource category that keeps track of resource 
> categories. (That sentence was a paragon of clarity, no?)
> 

It's no worse than manual. Possibly, it's as good as the material
allows. :)

Between this write-up, anastigmatix's pages, and the manual: this
should theoretically be enough for me to go on. According to my
personality test, I'm an intuitive. So 3 coherent perspectives 
should enable me to build a coherent model. But there's no telling
how much sleep it's require!! :)

> 
> 
> The resources in the Category category have names like /Form, /Font, 
> /Pattern, /Encoding, etc. The resource data associated with each of 
> these names is a dictionary whose contents are mostly procedures with 
> names corresponding to the resource-related PostScript operators, 
> though capitalized differently: /FindResource, /DefineResource, 
> /ResourceForAll, etc. These are the procedures that implement the 
> operator activities for that particular resource category.
> 
> 
> 
> The findresource operator does the following:
> 	/Category findresource /FindResource get exec
> 

Not to kick a gift-horse in the mouth, but the manual says it should
`begin` the category dict, and call FindResource by name. This enables
the category implementation dict to hold extra convenience procedures
for the implementation procedures to use. Presumably they stress this
so as not to encourage people to stop writing well-factored code. :)


> 
> 
> That is, if you do this:
> 
> 	/Helvetica /Font findresource
> 
> The findresource operator gets the Font Category resource dictionary, 
> fetches the FindResource procedure from that dictionary, and then 
> executes it. The other resource operators do similar things.
> 
> 
> The Generic category is used when you want to create your own resource 
> Category. Creating your own category is simple, in principle: just 
> create a new Category resource:
> 
> 
> /MyNewCategory
> <<
> 	/DefineResource { … }
> 	/FindResource { … }
> 	…
> >> /Category defineresource
> 
> The Generic category exists so you don’t need to forever be coming up 
> with your own definitions for those operator-implementation procedures. 
> You can simply copy the procedures from the Generic category 
> dictionary. (The Generic procedures are parameterized based on the name 
> of the category.)
> 
> Thus, to create a BBox resource category (to use an example from my 
> Advanced PostScript class), you’d do this:
> 
> /BBox
> 	/Generic /Category findresource		% Get the Generic category dict
> 	dup length dict			% Create an identically-sized dict
> 	copy									% and copy Generic into the new dict
> /Category defineresource pop			% Then make it a resource.
> 
> 
> % Now you can create BBox resources:
> 
> /Letter [ 0 0 612 792 ] /BBox defineresource pop
> 
> % And use them
> /Letter /BBox findresource clip
> 
> Hope that helped some. Resources takes quite a while to get the hang 
> of; it’s a two-hour discussion in the Advanced PostScript class.
> 
> In particular, using resources aren’t extremely useful (for what I 
> usually do, anyway) unless you have external storage available to the 
> interpreter. In that case, you can arrange it so that findresource 
> looks on the disk if it doesn’t find the resource you want in memory; 
> all future programs sent to that interpreter can use BBox resources (or 
> whatever) with no initial work.
> 
> I hope some part of that was lucid.
> 

Yes. I think so. It's beginning to gel.

I'm hoping to use Named Resourcces to handle the selection of output devices.
PLRM 3ed, p.97:

> OutputDevice
> Instances of the OutputDevice resource category (LanguageLevel 3) are dictionaries that describe certain capabilities of a particular page device, such as the possible page sizes or resolutions (see Section 6.4, “Output Device Dictionary”).

The output device handling is somewhat vague in the Warnock/Wyatt paper, presumably due to the fact that so much of it must have depended on the flexible binding features in the Mesa language. One of the histories of
postscript describe this paper as Warnock's "smuggling" of knowledge 
out of Xerox.

It describes a device constructor function, image constructor, and a 
graphics-state constructor which receives a device or image object.

> Device NewXXXDevice (<optional params>); 
> Image NewXXXImage (<optional params>); 

> DisplayContext NewDisplayContext (Device device); 

So, using named resources would let me give different names to different
device-types, but with a smooth common interface (fingers-crossed).

... [ I also hope this setup to work in tandem with NeWS-style
"magic" dictionaries, once those are designed and written. ]



-- 
too many smileys?

[toc] | [prev] | [next] | [standalone]


#1658

FromJohn Deubert <john@acumentraining.com>
Date2013-09-27 07:44 -0700
Message-ID<2013092707444714021-john@acumentrainingcom>
In reply to#1649
On 2013-09-24 22:19:43 +0000, luser- -droog said:

> I've spent the last few weeks trying to wrap my head
> around how to implement Named Resources. I'm just going
> to talk about what I think I know. Please correct any
> mistakes!
> 
> Named Resources exist in up to 3 places at any given time
> while "part of the system".
> 
>   * in a filesystem directory
>   * in a data structure in local vm
>   * in a data structure in global vm
> 
> So, I'm going to create 2 data structures,
> as a rough start:
> 
> true setglobal
> globaldict begin
> /globalresourcedict <<
>     /Category <<
>     >>
>     /Generic <<
>     >>
>     /ProcSet <<
>     >>
>>> def
> end
> 
> false setglobal
> userdict begin
> /localresourcedict <<
>     /Encoding <<
>         /StandardEncoding [ ]
>         /ISOLatin1Encoding [ ]
>     >>
>>> def
> end
> 
> I still don't understand Category and Generic. :(


Category is the resource category that keeps track of resource 
categories. (That sentence was a paragon of clarity, no?)

The resources in the Category category have names like /Form, /Font, 
/Pattern, /Encoding, etc. The resource data associated with each of 
these names is a dictionary whose contents are mostly procedures with 
names corresponding to the resource-related PostScript operators, 
though capitalized differently: /FindResource, /DefineResource, 
/ResourceForAll, etc. These are the procedures that implement the 
operator activities for that particular resource category.

The findresource operator does the following:
	/Category findresource /FindResource get exec

That is, if you do this:
	/Helvetica /Font findresource

The findresource operator gets the Font Category resource dictionary, 
fetches the FindResource procedure from that dictionary, and then 
executes it. The other resource operators do similar things.

The Generic category is used when you want to create your own resource 
Category. Creating your own category is simple, in principle: just 
create a new Category resource:

	/MyNewCategory
	<<
		/DefineResource { … }
		/FindResource { … }
		…
	>>
	/Category defineresource

The Generic category exists so you don’t need to forever be coming up 
with your own definitions for those operator-implementation procedures. 
You can simply copy the procedures from the Generic category 
dictionary. (The Generic procedures are parameterized based on the name 
of the category.)

Thus, to create a BBox resource category (to use an example from my 
Advanced PostScript class), you’d do this:

/BBox
	/Generic /Category findresource		% Get the Generic category dict
	dup length dict					% Create an identically-sized dict
	copy									% and copy Generic into the new dict
/Category defineresource pop			% Then make it a resource.

% Now you can create BBox resources:
/Letter [ 0 0 612 792 ] /BBox defineresource pop

% And use them
/Letter /BBox findresource clip

Hope that helped some. Resources takes quite a while to get the hang 
of; it’s a two-hour discussion in the Advanced PostScript class.

In particular, using resources aren’t extremely useful (for what I 
usually do, anyway) unless you have external storage available to the 
interpreter. In that case, you can arrange it so that findresource 
looks on the disk if it doesn’t find the resource you want in memory; 
all future programs sent to that interpreter can use BBox resources (or 
whatever) with no initial work.

I hope some part of that was lucid.

- John


-- 
========
John Deubert
Acumen Training
PostScript & PDF Engineering Classes & Consulting
www.acumentraining.com

Learn PostScript programming techniques
Read the free Acumen Journal
acumentraining.com/acumenjournal.html

[toc] | [prev] | [next] | [standalone]


#1659

FromJohn Deubert <john@acumentraining.com>
Date2013-09-27 07:49 -0700
Message-ID<2013092707491716949-john@acumentrainingcom>
In reply to#1649
On 2013-09-24 22:19:43 +0000, luser- -droog said:

> I've spent the last few weeks trying to wrap my head
> around how to implement Named Resources. I'm just going
> to talk about what I think I know. Please correct any
> mistakes!
> 
> Named Resources exist in up to 3 places at any given time
> while "part of the system".
> 
>   * in a filesystem directory
>   * in a data structure in local vm
>   * in a data structure in global vm
> 
> So, I'm going to create 2 data structures,
> as a rough start:
> 
> true setglobal
> globaldict begin
> /globalresourcedict <<
>     /Category <<
>     >>
>     /Generic <<
>     >>
>     /ProcSet <<
>     >>
>>> def
> end
> 
> false setglobal
> userdict begin
> /localresourcedict <<
>     /Encoding <<
>         /StandardEncoding [ ]
>         /ISOLatin1Encoding [ ]
>     >>
>>> def
> end
> 
> I still don't understand Category and Generic. :(

	X-Received:	by 10.66.145.7 with SMTP id 
sq7mr2745294pab.43.1380292315848; Fri, 27 Sep 2013 07:31:55 -0700 (PDT)
	Path: 
border1.nntp.dca3.giganews.com!Xl.tags.giganews.com!border2.nntp.dca3.giganews.com!border4.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!border1.nntp.hkg.giganews.com!news.netfront.net!news.glorb.com!z6no27972927pbz.1!news-out.google.com!z6ni74626pbu.0!nntp.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local2.nntp.dca.giganews.com!news.giganews.com.POSTED!not-for-mail 

	NNTP-Posting-Date:	Fri, 27 Sep 2013 09:31:55 -0500
	From:	John Deubert <john@acumentraining.com>
	Organization:	Acumen Training
	Newsgroups:	comp.lang.postscript
	Date:	Fri, 27 Sep 2013 07:31:55 -0700
	Message-ID:	<2013092707315563519-john@acumentrainingcom>
	References:	<ad8a9d89-952f-4e17-8ff8-2fbd8ce6e26e@googlegroups.com>
	MIME-Version:	1.0
	Subject:	Re: Named Resources
	User-Agent:	Unison/2.1.10
	Lines:	120
	X-Usenet-Provider:	http://www.giganews.com
	X-Trace: 
sv3-ezYP0wfR3Cu/Bz3fBd/WLu0tLHKnRFHiQljeVduelQWqfXMpSAZGc5fcvYlCKa9ShgBlWC1Cq9kte29!FY94CF6efQpZyIiXTWXyiDhRJSZ2SC8tz5DMhDa4TmYKu47Xi/XcsTVIjB8JuIE5msk= 

	X-Complaints-To:	abuse@giganews.com
	X-DMCA-Notifications:	http://www.giganews.com/info/dmca.html
	X-Abuse-and-DMCA-Info:	Please be sure to forward a copy of ALL headers
	X-Abuse-and-DMCA-Info:	Otherwise we will be unable to process your 
complaint properly
	X-Postfilter:	1.3.40
	X-Original-Bytes:	5354
	Content-Type:	text/plain; charset=utf-8; format=flowed
	Content-Transfer-Encoding:	8bit
	Bytes:	5406
	Xref:	number.nntp.dca.giganews.com comp.lang.postscript:73766

On 2013-09-24 22:19:43 +0000, luser- -droog said:

> I've spent the last few weeks trying to wrap my head
> around how to implement Named Resources. I'm just going
> to talk about what I think I know. Please correct any
> mistakes!
> 
> Named Resources exist in up to 3 places at any given time
> while "part of the system".
> 
> * in a filesystem directory
> * in a data structure in local vm
> * in a data structure in global vm
> 
> So, I'm going to create 2 data structures,
> as a rough start:
> 
> true setglobal
> globaldict begin
> /globalresourcedict <<
> /Category <<
>>> 
> /Generic <<
>>> 
> /ProcSet <<
>>> 
>>> def
> end
> 
> false setglobal
> userdict begin
> /localresourcedict <<
> /Encoding <<
> /StandardEncoding [ ]
> /ISOLatin1Encoding [ ]
>>> 
>>> def
> end
> 
> I still don't understand Category and Generic. :(


Category is the resource category that keeps track of resource 
categories. (That sentence was a paragon of clarity, no?)

The resources in the Category category have names like /Form, /Font, 
/Pattern, /Encoding, etc. The resource data associated with each of 
these names is a dictionary whose contents are mostly procedures with 
names corresponding to the resource-related PostScript operators, 
though capitalized differently: /FindResource, /DefineResource, 
/ResourceForAll, etc. These are the procedures that implement the 
operator activities for that particular resource category.

The findresource operator does the following:

	/Category findresource /FindResource get exec

That is, if you do this:

	/Helvetica /Font findresource

The findresource operator gets the Font Category resource dictionary, 
fetches the FindResource procedure from that dictionary, and then 
executes it. The other resource operators do similar things.

The Generic category is used when you want to create your own resource 
Category. Creating your own category is simple, in principle: just 
create a new Category resource:

	/MyNewCategory
	<<
		/DefineResource { ... }
		/FindResource { ...  }
		...
	>>
	/Category defineresource

The Generic category exists so you don't need to forever be coming up 
with your own definitions for those operator-implementation procedures. 
You can simply copy the procedures from the Generic category 
dictionary. (The Generic procedures are parameterized based on the name 
of the category.)

Thus, to create a BBox resource category (to use an example from my 
Advanced PostScript class), you'd do this:

/BBox
	/Generic /Category findresource		% Get the Generic category dict
	dup length dict						% Create an identically-sized dict
	copy								% and copy Generic into the new dict
/Category defineresource pop			% Then make it a resource.

% Now you can create BBox resources:
/Letter [ 0 0 612 792 ] /BBox defineresource pop

% And use them
/Letter /BBox findresource clip

Resources takes quite a while to get the hang of; it's a two-hour 
discussion in the Advanced PostScript class.

In particular, using resources aren't extremely useful (for what I 
usually do, anyway) unless you have external storage available to the 
interpreter. In that case, you can arrange it so that findresource 
looks on the disk if it doesn't find the resource you want in memory; 
all future programs sent to that interpreter can use BBox resources (or 
whatever) with no initial work.

I hope some part of that was lucid.

- John


-- 
========
John Deubert
Acumen Training
PostScript & PDF Engineering Classes & Consulting
www.acumentraining.com

Learn PostScript programming techniques
Read the free Acumen Journal
acumentraining.com/acumenjournal.html

[toc] | [prev] | [next] | [standalone]


#1660

FromJohn Deubert <john@acumentraining.com>
Date2013-09-27 08:44 -0700
Message-ID<20130927084403903-john@acumentrainingcom>
In reply to#1649
On 2013-09-24 22:19:43 +0000, luser- -droog said:

> I've spent the last few weeks trying to wrap my head
> around how to implement Named Resources. I'm just going
> to talk about what I think I know. Please correct any
> mistakes!
> 
> Named Resources exist in up to 3 places at any given time
> while "part of the system".
> 
>   * in a filesystem directory
>   * in a data structure in local vm
>   * in a data structure in global vm
> 
> So, I'm going to create 2 data structures,
> as a rough start:
> 
> true setglobal
> globaldict begin
> /globalresourcedict <<
>     /Category <<
>     >>
>     /Generic <<
>     >>
>     /ProcSet <<
>     >>
>>> def
> end
> 
> false setglobal
> userdict begin
> /localresourcedict <<
>     /Encoding <<
>         /StandardEncoding [ ]
>         /ISOLatin1Encoding [ ]
>     >>
>>> def
> end
> 
> I still don't understand Category and Generic. :(

	X-Received:	by 10.66.145.7 with SMTP id 
sq7mr2745294pab.43.1380292315848; Fri, 27 Sep 2013 07:31:55 -0700 (PDT)
	Path: 
border1.nntp.dca3.giganews.com!Xl.tags.giganews.com!border2.nntp.dca3.giganews.com!border4.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!border1.nntp.hkg.giganews.com!news.netfront.net!news.glorb.com!z6no27972927pbz.1!news-out.google.com!z6ni74626pbu.0!nntp.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local2.nntp.dca.giganews.com!news.giganews.com.POSTED!not-for-mail 

	NNTP-Posting-Date:	Fri, 27 Sep 2013 09:31:55 -0500
	From:	John Deubert <john@acumentraining.com>
	Organization:	Acumen Training
	Newsgroups:	comp.lang.postscript
	Date:	Fri, 27 Sep 2013 07:31:55 -0700
	Message-ID:	<2013092707315563519-john@acumentrainingcom>
	References:	<ad8a9d89-952f-4e17-8ff8-2fbd8ce6e26e@googlegroups.com>
	MIME-Version:	1.0
	Subject:	Re: Named Resources
	User-Agent:	Unison/2.1.10
	Lines:	120
	X-Usenet-Provider:	http://www.giganews.com
	X-Trace: 
sv3-ezYP0wfR3Cu/Bz3fBd/WLu0tLHKnRFHiQljeVduelQWqfXMpSAZGc5fcvYlCKa9ShgBlWC1Cq9kte29!FY94CF6efQpZyIiXTWXyiDhRJSZ2SC8tz5DMhDa4TmYKu47Xi/XcsTVIjB8JuIE5msk= 

	X-Complaints-To:	abuse@giganews.com
	X-DMCA-Notifications:	http://www.giganews.com/info/dmca.html
	X-Abuse-and-DMCA-Info:	Please be sure to forward a copy of ALL headers
	X-Abuse-and-DMCA-Info:	Otherwise we will be unable to process your 
complaint properly
	X-Postfilter:	1.3.40
	X-Original-Bytes:	5354
	Content-Type:	text/plain; charset=utf-8; format=flowed
	Content-Transfer-Encoding:	8bit
	Bytes:	5406
	Xref:	number.nntp.dca.giganews.com comp.lang.postscript:73766

On 2013-09-24 22:19:43 +0000, luser- -droog said:

> I've spent the last few weeks trying to wrap my head
> around how to implement Named Resources. I'm just going
> to talk about what I think I know. Please correct any
> mistakes!
> 
> Named Resources exist in up to 3 places at any given time
> while "part of the system".
> 
> * in a filesystem directory
> * in a data structure in local vm
> * in a data structure in global vm
> 
> So, I'm going to create 2 data structures,
> as a rough start:
> 
> true setglobal
> globaldict begin
> /globalresourcedict <<
> /Category <<
>>> 
> /Generic <<
>>> 
> /ProcSet <<
>>> 
>>> def
> end
> 
> false setglobal
> userdict begin
> /localresourcedict <<
> /Encoding <<
> /StandardEncoding [ ]
> /ISOLatin1Encoding [ ]
>>> 
>>> def
> end
> 
> I still don't understand Category and Generic. :(


[[ Sorry if this is a repeat post; I'm trying out a new newsreader and 
the first attempt didn't seem to take.]]

Category is the resource category that keeps track of resource 
categories. (That sentence was a paragon of clarity, no?)

The resources in the Category category have names like /Form, /Font, 
/Pattern, /Encoding, etc. The resource data associated with each of 
these names is a dictionary whose contents are mostly procedures with 
names corresponding to the resource-related PostScript operators, 
though capitalized differently: /FindResource, /DefineResource, 
/ResourceForAll, etc. These are the procedures that implement the 
operator activities for that particular resource category.

The findresource operator does the following:

	/Category findresource	% Get the appropriate Category resource dictionary
	/FindResource get		% Get the FindResource procedure out of that dict
	exec					% execute it

That is, if you do this:

	/Helvetica /Font findresource

The findresource operator gets the Font Category resource dictionary, 
fetches the FindResource procedure from that dictionary, and then 
executes it. The other resource operators do similar things.

The Generic category is used when you want to create your own resource 
Category. Creating your own category is simple, in principle: just 
create a new Category resource:

	/MyNewCategory
	<<
		/DefineResource { . . . }
		/FindResource { . . .  }
		. . .
	>>
	/Category defineresource

The Generic category exists so you don't need to forever be coming up 
with your own definitions for those operator-implementation procedures. 
You can simply copy the procedures from the Generic category 
dictionary. (The Generic procedures are parameterized based on the name 
of the category.)

Thus, to create a BBox resource category (to use an example from my 
Advanced PostScript class), you'd do this:

/BBox
	/Generic /Category findresource		% Get the Generic category dict
	dup length dict						% Create an identically-sized dict
	copy								% and copy Generic into the new dict
/Category defineresource pop			% Then make it a resource.

% Now you can create BBox resources:

/Letter [ 0 0 612 792 ] /BBox defineresource pop

% And use them

/Letter /BBox findresource clip

Hope that helped some. Resources takes quite a while to get the hang 
of; it's a two-hour discussion in the Advanced PostScript class.

In particular, using resources aren't extremely useful (for what I 
usually do, anyway) unless you have external storage available to the 
interpreter. In that case, you can arrange it so that findresource 
looks on the disk if it doesn't find the resource you want in memory; 
all future programs sent to that interpreter can use BBox resources (or 
whatever) with no initial work.

I hope some part of that was lucid.

- John


-- 
========
John Deubert
Acumen Training
PostScript & PDF Engineering Classes & Consulting
www.acumentraining.com

Learn PostScript programming techniques
Read the free Acumen Journal
acumentraining.com/acumenjournal.html

[toc] | [prev] | [next] | [standalone]


#3170

Fromwst wst <wouter_staelens@hotmail.com>
Date2017-08-29 02:02 -0700
Message-ID<54b963a7-e791-4b21-8eef-532dbe3ca91d@googlegroups.com>
In reply to#1649
Op woensdag 25 september 2013 00:19:43 UTC+2 schreef luser droog:
> I've spent the last few weeks trying to wrap my head 
> around how to implement Named Resources. I'm just going
> to talk about what I think I know. Please correct any 
> mistakes!
> 
> Named Resources exist in up to 3 places at any given time
> while "part of the system".
> 
>   * in a filesystem directory
>   * in a data structure in local vm
>   * in a data structure in global vm
> 
> So, I'm going to create 2 data structures, 
> as a rough start:
> 
> true setglobal
> globaldict begin
> /globalresourcedict <<
>     /Category <<
>     >>  
>     /Generic <<
>     >>  
>     /ProcSet <<
>     >>  
> >> def 
> end
> 
> false setglobal
> userdict begin
> /localresourcedict <<
>     /Encoding <<
>         /StandardEncoding [ ] 
>         /ISOLatin1Encoding [ ] 
>     >>  
> >> def 
> end
> 
> I still don't understand Category and Generic. :(




How do you handle the local and global VM?

The red book states: 
"The resources dictionary should take care of local and global VM resources".

Ghostscript comments say:

% The PostScript manual says that each category must
% manage global and local instances separately.  However, objects in
% global VM other than systemdict can't reference objects in local VM."

Now how is it possible to manage both local and global VM in a single dictionary (the resources dictionary) ?

Is it possible to explain this as I'm confused with the local/global VM in combination with Named Resources... how does that work together?

[toc] | [prev] | [next] | [standalone]


#3172

Fromluser droog <luser.droog@gmail.com>
Date2017-08-29 19:25 -0700
Message-ID<5b56c7ea-86ba-4fd6-bdcb-d4eb030ad22c@googlegroups.com>
In reply to#3170
On Tuesday, August 29, 2017 at 4:02:13 AM UTC-5, wst wst wrote:
> Op woensdag 25 september 2013 00:19:43 UTC+2 schreef luser droog:
> > I've spent the last few weeks trying to wrap my head 
> > around how to implement Named Resources. I'm just going
> > to talk about what I think I know. Please correct any 
> > mistakes!
> > 
> > Named Resources exist in up to 3 places at any given time
> > while "part of the system".
> > 
> >   * in a filesystem directory
> >   * in a data structure in local vm
> >   * in a data structure in global vm
> > 
> > So, I'm going to create 2 data structures, 
> > as a rough start:
> > 
> > true setglobal
> > globaldict begin
> > /globalresourcedict <<
> >     /Category <<
> >     >>  
> >     /Generic <<
> >     >>  
> >     /ProcSet <<
> >     >>  
> > >> def 
> > end
> > 
> > false setglobal
> > userdict begin
> > /localresourcedict <<
> >     /Encoding <<
> >         /StandardEncoding [ ] 
> >         /ISOLatin1Encoding [ ] 
> >     >>  
> > >> def 
> > end
> > 
> > I still don't understand Category and Generic. :(
> 
> 
> 
> 
> How do you handle the local and global VM?
> 
> The red book states: 
> "The resources dictionary should take care of local and global VM resources".
> 
> Ghostscript comments say:
> 
> % The PostScript manual says that each category must
> % manage global and local instances separately.  However, objects in
> % global VM other than systemdict can't reference objects in local VM."
> 
> Now how is it possible to manage both local and global VM in a single dictionary (the resources dictionary) ?
> 
> Is it possible to explain this as I'm confused with the local/global VM in combination with Named Resources... how does that work together?

The OP was several years ago, but I'm still around! It appears from my earlier
message that I had planned 2 dictionaries to manage the local and global stuff
separately. Indeed, it seems impossible to do with 1 dictionary in either memory.
Global of course is forbidden to contain references to objects in local memory.
Conversely, local memory is too perishable. If the user were to do

  save  ... findresource  ... restore

then it all would get lost.

So I think you have to use 2. Unless there's something else I'm not seeing.

[toc] | [prev] | [next] | [standalone]


#3173

FromCarlos <carlos@cvkm.cz>
Date2017-08-30 19:24 +0200
Message-ID<20170830192412.3c393b59@samara.DOMA>
In reply to#3170
[wst wst <wouter_staelens@hotmail.com>, 2017-08-29 02:02]
> Op woensdag 25 september 2013 00:19:43 UTC+2 schreef luser droog:
> > I've spent the last few weeks trying to wrap my head 
> > around how to implement Named Resources. I'm just going
> > to talk about what I think I know. Please correct any 
> > mistakes!
> > 
> > Named Resources exist in up to 3 places at any given time
> > while "part of the system".
> > 
> >   * in a filesystem directory
> >   * in a data structure in local vm
> >   * in a data structure in global vm
> > 
> > So, I'm going to create 2 data structures, 
> > as a rough start:
> > 
> > true setglobal
> > globaldict begin
> > /globalresourcedict <<
> >     /Category <<  
> >     >>    
> >     /Generic <<  
> >     >>    
> >     /ProcSet <<  
> >     >>  
> > >> def   
> > end
> > 
> > false setglobal
> > userdict begin
> > /localresourcedict <<
> >     /Encoding <<
> >         /StandardEncoding [ ] 
> >         /ISOLatin1Encoding [ ]   
> >     >>  
> > >> def   
> > end
> > 
> > I still don't understand Category and Generic. :(  
> 
> 
> 
> 
> How do you handle the local and global VM?
> 
> The red book states: 
> "The resources dictionary should take care of local and global VM resources".
> 
> Ghostscript comments say:
> 
> % The PostScript manual says that each category must
> % manage global and local instances separately.  However, objects in
> % global VM other than systemdict can't reference objects in local VM."
> 
> Now how is it possible to manage both local and global VM in a single
> dictionary (the resources dictionary) ?
> 
> Is it possible to explain this as I'm confused with the local/global VM in
> combination with Named Resources... how does that work together?

Are you talking about "category implementation dictionaries"? That's the
dictionary that holds procedures implementing defineresource, etc. AFAICT, the
book says that each category has only one implementation dictionary for
both its local and global resources, not that the resources should be stored in
a single dictionary. I think it doesn't say how they should be stored at all; as
long as you implement the procedures to define/find/etc them, what
your implementation does is nobody's business.

I also don't see another way than to use two dictionaries, one
global and one local.

-- 

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.postscript


csiph-web