home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 20 / AACD20.BIN / AACD / Programming / Jikes / Source / src / jikesapi.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-02-24  |  3.9 KB  |  163 lines

  1. /*
  2.  * $Id: jikesapi.h,v 1.11 2001/01/16 22:52:40 mdejong Exp $
  3.  */
  4.  
  5. #ifndef _JIKES_API_H_FLAG_
  6. #define _JIKES_API_H_FLAG_
  7.  
  8. class JikesOption
  9. {    
  10.  public:
  11.     
  12.     char *classpath;
  13.     char *directory;
  14.     char *encoding;
  15.  
  16.     // Each of these fields is a boolean value
  17.     // 0 if false, non-zero if true
  18.     int nowrite;
  19.     int deprecation;
  20.     int O;
  21.     int g;
  22.     int verbose;
  23.     int depend;
  24.     int nowarn;
  25.     int old_classpath_search_order;
  26.     int zero_defect;
  27.  
  28.     virtual ~JikesOption();
  29.  
  30.  protected:
  31.     
  32.     JikesOption();
  33. };
  34.  
  35. class JikesError
  36. {
  37.  public:
  38.  
  39.     enum JikesErrorSeverity
  40.     {
  41.         JIKES_ERROR,
  42.         JIKES_CAUTION,
  43.         JIKES_WARNING
  44.     } ;
  45.         
  46.     virtual JikesErrorSeverity getSeverity() = 0 ;
  47.     virtual const char *getFileName() = 0 ;
  48.     
  49.     virtual int getLeftLineNo      () = 0 ;
  50.     virtual int getLeftColumnNo    () = 0 ;
  51.     virtual int getRightLineNo     () = 0 ;
  52.     virtual int getRightColumnNo   () = 0 ;
  53.  
  54.     /**
  55.      * Returns message describing error.
  56.      */
  57.     virtual const wchar_t *getErrorMessage() = 0;
  58.  
  59.     /**
  60.      * Returns formatter error report. 
  61.      */
  62.     virtual const wchar_t *getErrorReport() = 0;
  63.  
  64.  protected:
  65.  
  66.     const char *getSeverityString();
  67. };
  68.  
  69. /**
  70.  * API to jikes compiler.
  71.  */
  72. class JikesAPI
  73. {
  74.  public:
  75.  
  76.     JikesAPI();
  77.     
  78.     virtual ~JikesAPI();
  79.        
  80.     /**
  81.      * Returns instance of current compiler options.
  82.      * returned pointer can be used to modify current
  83.      * compiler options.
  84.      */
  85.     virtual JikesOption *getOptions();
  86.     
  87.     /**
  88.      * Creates instance of compiler options,
  89.      * corresponding to given command line parameters.
  90.      *
  91.      * @return list of java file names found on command line
  92.      * Caller should not attempt to manage the memory returned
  93.      * by this method as it can be freed during another call
  94.      * to parseOptions() or when this object is destroyed.
  95.      */
  96.     virtual char** parseOptions(int argc, char **argv) ;
  97.  
  98.     /**
  99.      * Compile given list ofiles using current compiler options.
  100.      */
  101.     virtual int compile(char ** filenames);
  102.  
  103.     /**
  104.      * Jikes API implements singelton pattern.
  105.      * This is a way to get instance of it.
  106.      */
  107.     static JikesAPI * getInstance();
  108.  
  109.     /**
  110.      * This method will be called for each error reported.
  111.      */
  112.     virtual void reportError(JikesError *error);
  113.     
  114.     
  115.     /**
  116.      * Define the virtual base class for all Readers.
  117.      * A pointer to an object of this type is returned by JikesAPI::read()
  118.      */
  119.     class FileReader
  120.         {
  121.     public:
  122.             virtual  ~FileReader()  {}
  123.             
  124.             virtual const char     *getBuffer()      = 0;    // If the file is unreadable an object should still be created but GetBuffer() should return NULL.
  125.             virtual       size_t    getBufferSize()  = 0;    // If the file is unreadable GetBufferSize() is undefined.
  126.         };
  127.  
  128.     /**
  129.      * Define the virtual base class for all WriteObjects.
  130.      * A pointer to an object of this type is returned by JikesAPI::write()
  131.      */
  132.     class FileWriter
  133.         {
  134.     public:
  135.             FileWriter(size_t mS):   maxSize(mS) {} 
  136.             virtual  ~FileWriter() {}
  137.             
  138.             size_t    write(const unsigned char *data, size_t size);
  139.             virtual  int      isValid()                         = 0;
  140.             
  141.     private:
  142.             
  143.             virtual  size_t    doWrite(const unsigned char *data, size_t size)   = 0;    // Garanteed not to be called with a combined total of more than maxSize bytes during the lifespan of the object.
  144.             size_t   maxSize;
  145.         };
  146.         
  147.     virtual int stat(const char *filename, struct stat *status);
  148.     
  149.     virtual FileReader  *read  (const char *filename              );
  150.     virtual FileWriter  *write (const char *filename, size_t bytes);
  151.     
  152.  private:
  153.  
  154.     void cleanupOptions(); // Helper to delete option and parsedOptions
  155.  
  156.     JikesOption *option;
  157.     char **parsedOptions;
  158.  
  159.     static JikesAPI *instance;
  160. };
  161.  
  162. #endif // _JIKES_API_H_FLAG_
  163.