[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: PostScript wrappers
From: |
Adam Fedor |
Subject: |
Re: PostScript wrappers |
Date: |
Tue, 20 Jan 2004 15:39:54 -0700 |
On Tuesday, January 20, 2004, at 10:34 AM, Chris B. Vetter wrote:
It's really not feasible in the general case, since a psw file can
contain any type of PostScript - thus we'd need a full PS interpreter.
pswrap translates the psw file to binary sequences that the PS
interpreter can read, so we'd have to write something to decode that
as well. Pretty hard.
Yes, I thought so. But in this case, does it even make much sense to
have the <instance>_PSWRAP_FILES 'command' in -make if it cannot be
properly/completely supported?
Probably not.
The best I can think of is perhaps writing our own limited PSW->C
translator. Most psw files are pretty simple so it would probably work
most of the time.
Wouldn't it suffice to check the headers in -dgs and try to implement
the functions as wrappers to what we already have in -back?
I'm not sure I understand, but for example, look at a really simple psw
function:
--------------------------------------------
defineps PSWFrameRect (float x, y, w, h)
1 setlinewidth
0 setgray
x y w h rectstroke
endps
--------------------------------------------
which pswrap translates to:
--------------------------------------------
void PSWFrameRect(x, y, w, h)
float x, y, w, h;
{
typedef struct {
unsigned char tokenType;
unsigned char topLevelCount;
unsigned short nBytes;
DPSBinObjGeneric obj0;
DPSBinObjGeneric obj1;
DPSBinObjGeneric obj2;
DPSBinObjGeneric obj3;
DPSBinObjReal obj4;
DPSBinObjReal obj5;
DPSBinObjReal obj6;
DPSBinObjReal obj7;
DPSBinObjGeneric obj8;
} _dpsQ;
static _dpsQ _dpsF = {
DPS_DEF_TOKENTYPE, 9, 76,
{DPS_LITERAL|DPS_INT, 0, 0, 1},
{DPS_EXEC|DPS_NAME, 0, DPSSYSNAME, 155}, /* setlinewidth */
{DPS_LITERAL|DPS_INT, 0, 0, 0},
{DPS_EXEC|DPS_NAME, 0, DPSSYSNAME, 150}, /* setgray */
{DPS_LITERAL|DPS_REAL, 0, 0, 0}, /* param: x */
{DPS_LITERAL|DPS_REAL, 0, 0, 0}, /* param: y */
{DPS_LITERAL|DPS_REAL, 0, 0, 0}, /* param: w */
{DPS_LITERAL|DPS_REAL, 0, 0, 0}, /* param: h */
{DPS_EXEC|DPS_NAME, 0, DPSSYSNAME, 129}, /* rectstroke */
}; /* _dpsQ */
register DPSContext _dpsCurCtxt = DPSPrivCurrentContext();
register DPSBinObjRec *_dpsP = (DPSBinObjRec *)&_dpsF.obj0;
_dpsP[4].val.realVal = x;
_dpsP[5].val.realVal = y;
_dpsP[6].val.realVal = w;
_dpsP[7].val.realVal = h;
DPSBinObjSeqWrite(_dpsCurCtxt,(char *) &_dpsF,76);
DPSSYNCHOOK(_dpsCurCtxt)
}
--------------------------------------------
Sure you could say that helps since pswrap has already parsed the
function and we ONLY need to implement DPSBinObjSeqWrite to read in the
tokens and call the correct functions. Still that's an awful lot of
work compared to just telling the developer to rewrite the psw function
in C. Try for instance, trying to write something that will interpret
this slightly more complicated psw function:
--------------------------------------------
defineps PSWRectFillListGray (float rectvals[x]; int x)
mark rectvals {counttomark 4 gt {setgray rectfill} if} forall pop
endps
--------------------------------------------