next up previous
Next: The library Up: The Proxy Generator Previous: The Proxy Generator

Getting Around Parse Problems


The proxy generator inherits from the SAGE parser a problem with certain C++ constructs that are valid in gcc-2.7.0. In particular it fails with _G_config.h which is included by many of libg++'s header files, for example iostream.h. Thus, there is currently a hack such that the standard header drectory is not searched by the parser: instead the directory $(UCPP_ROOT)/DUMMY_HEADERS/ is searched for standard header. In that directory there are several dummy headers that include minimal information about classes that might be needed to allow successful parsing of the user defined headers. As required we will need to add more header, and more information to the headers in that directory.

It is possible to get round parse problems in other library header files by passing a different include directory to the parser than you do to the compiler, so that dummy versions of the headers are picked up. This is done in the polygon example to avoid parse problems with the LEDA header files: see the makefile in examples/polygon.

Any other parse problems can be got round using the defined symbol PROXYGEN which is defined when the proxy generator scans the code, but not when the code is compiled. Thus, the parser has trouble with templates, so to get round this, and allow a member function to return a list of polygons, we use the following hack

#ifndef PROXYGEN
typedef list<Polygon> polylist;
typedef int polylist;

/* and then in farmer

class Farmer : public Activatable {
  virtual polylist *getWork();
  int lastPolySent;
  int workSize;
  Map *map;

Thus the proxy generator thinks that a polylist is just an int, but the compile which actually generates the code will know it is a list of polygons. This method will clearly not work if the body of the function getWork is parsed, but until the parser gets to understand templated fully it provides a means to get it to accept anything we want. Apart from templates there are not too many problems like this.

next up previous
Next: The library Up: The Proxy Generator Previous: The Proxy Generator

send comments or suggestions to

Click here for more information on UCL-CS.