00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef GLUE_HPP
00023 #define GLUE_HPP
00024
00025 #include <stdio.h>
00026 #include <stdlib.h>
00027 #include <string>
00028 #include <list>
00029 #include <map>
00030 #include <iostream>
00031 #include <stdarg.h>
00032
00033 using std::string;
00034 using std::map;
00035 using std::list;
00036
00037 struct Coord_t;
00038 class CBackend;
00039
00043 typedef long INT32;
00047 typedef unsigned long UINT32;
00051 typedef signed long long INT64;
00055 typedef unsigned long long UINT64;
00056
00061 #ifndef TRUE
00062 #define TRUE 1
00063 #endif
00064 #ifndef FALSE
00065 #define FALSE 0
00066 #endif
00067
00068 #define MAX_PATH_LENGTH (256)
00069 #define PATH_SEPARATOR "/"
00070
00071 extern int warningCount;
00072 extern int errorCount;
00073 extern FILE* logfile;
00074
00078 void shell_assert( const char*, int );
00079 void shell_xfree( void*, int );
00080 void* shell_xmalloc( int );
00090 class Message {
00091 public:
00095 enum Action_t {
00096 eIGNORE,
00097 eERROR,
00098 eWARNING,
00099 eINFO
00100 };
00101 private:
00102 static map<string,Message*> abbrev2Message;
00103 static list<Message*> messages;
00104 CBackend* tool;
00105 Action_t action;
00106 int locked;
00107 const string abbrev;
00108 const string helpText;
00109 const string format;
00110 public:
00120 static Message* RegisterWarning( CBackend* tool,
00121 Action_t defaultAction,
00122 const char* abbrev,
00123 const char* format, ... );
00132 static Message* RegisterError( CBackend* tool,
00133 const char* abbrev,
00134 const char* format, ... );
00144 static Message* Find( const char* abbrev );
00149 static list<Message*>& MessageList() { return messages; }
00150 Message( CBackend* tool,
00151 Action_t action,
00152 int locked,
00153 const char* abbrev,
00154 const char* helpText,
00155 const char* format );
00156
00157 const char* Format() { return format.c_str(); }
00158 const char* Abbreviation() { return abbrev.c_str(); }
00159 const char* HelpText() { return helpText.c_str(); }
00160 Action_t Action() { return action; }
00161 void Action( Action_t a ) { if( !locked ) { action = a; } }
00162 CBackend* Tool() { return tool; }
00163 int Locked() { return locked; }
00167 };
00168
00176 void message( struct Coord_t* location, Message* message, ... );
00183 void vlogprintf( const char* format, va_list args );
00190 void logprintf( const char* format, ... );
00191
00192
00197 void warning( struct Coord_t* location, const char* format, ... );
00202 void error( struct Coord_t* location, const char* format, ... );
00207 void info( struct Coord_t* location, const char* format, ... );
00212 void fatal( struct Coord_t* location, const char* format, ... );
00217 void trace( struct Coord_t* location, const char* format, ... );
00218
00219
00225 #define MASSERT(c) if(!(c)) { shell_assert( __FILE__, __LINE__ ); abort(); }
00226
00231 #define MTHROW_NIL(p) MASSERT(p!=NULL);
00232
00233 #endif // GLUE_HPP
00234