Extending GeXX

The major new feature added in VTeX 6.3 is GeXX. The second "X" stands for eXtensible. With GeXX you can supplement the existing set of the PostScript operators with new constructs, implemented in C or C++.

This feature is applicable to both VTeX/Windows and VTeX/Linux implementations. The terminology in this document is tailored to Windows users; Linux users should have no problem with it as long as they translate a few platform-dependant terms; for example, Dynamic Libraries (DLL)'s under Linux are just Shared Objects (.SO's).}

To enrich VTeX with new GeX operators, you should

VTeX 6.3+ distributions includes an example of such an extension for drawing the PieCharts.

Note: To be visible to the VTeX compiler, the extension DLL's should be placed into the VTEX\BIN\GEX subdirectory.

Writing an implementation DLL

An extention DLL must export the following three functions:

Here is a sample implementation of these functions: <font face="verdana,courier> extern "C" WINAPI int Names(int i, char **s, void **p) { if (i == 0) { *s = "piechart"; *p = (void*)piechart; } else { *s = NULL; *p = NULL; } return ((*s) != NULL); }; extern "C" WINAPI int Count() { return 1; } extern "C" WINAPI int Version() { return 630; }

The code above adds new PostScript operator piechart. Notice that .extend will define it in the current top PostScript dictionary.

Writing an extention operator

An extension operator should be declared as an int function; its solo argument is the GeX interface structure, gexi. The function should return 0 in case of success, and a non-zero value otherwise (triggering a PostScript internal error).

The gexi structure provides the plugin author with full access to the GeX imaging machinery, and, via the .tkread/.tkwrite extentions, to the TeX tokens.

The detailed description of the interface is provided in the Pdf version of the documentation; here we only show the flavor of the code one can write. Here is (a very crude) example of sine curve drawing plugin.

int SineCurve(GEXI g) { double x1,x2; g->getOstackNumeric(&x1); // get low bound g->getOstackNumeric(&x2); // get upper bound .............. g->moveto(x1,sin(x2)); for (int i=1; i<=100; i++) g->lineto(x1+(x2-x1)*i/100,sin(x1+(x2-x