Main Page | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

l_precomp.h

Go to the documentation of this file.
00001 /*
00002 ===========================================================================
00003 Copyright (C) 1999-2005 Id Software, Inc.
00004 
00005 This file is part of Quake III Arena source code.
00006 
00007 Quake III Arena source code is free software; you can redistribute it
00008 and/or modify it under the terms of the GNU General Public License as
00009 published by the Free Software Foundation; either version 2 of the License,
00010 or (at your option) any later version.
00011 
00012 Quake III Arena source code is distributed in the hope that it will be
00013 useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015 GNU General Public License for more details.
00016 
00017 You should have received a copy of the GNU General Public License
00018 along with Foobar; if not, write to the Free Software
00019 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00020 ===========================================================================
00021 */
00022 
00023 /*****************************************************************************
00024  * name:        l_precomp.h
00025  *
00026  * desc:        pre compiler
00027  *
00028  * $Archive: /source/code/botlib/l_precomp.h $
00029  *
00030  *****************************************************************************/
00031 
00032 #ifndef MAX_PATH
00033     #define MAX_PATH            MAX_QPATH
00034 #endif
00035 
00036 #ifndef PATH_SEPERATORSTR
00037     #if defined(WIN32)|defined(_WIN32)|defined(__NT__)|defined(__WINDOWS__)|defined(__WINDOWS_386__)
00038         #define PATHSEPERATOR_STR       "\\"
00039     #else
00040         #define PATHSEPERATOR_STR       "/"
00041     #endif
00042 #endif
00043 #ifndef PATH_SEPERATORCHAR
00044     #if defined(WIN32)|defined(_WIN32)|defined(__NT__)|defined(__WINDOWS__)|defined(__WINDOWS_386__)
00045         #define PATHSEPERATOR_CHAR      '\\'
00046     #else
00047         #define PATHSEPERATOR_CHAR      '/'
00048     #endif
00049 #endif
00050 
00051 #if defined(BSPC) && !defined(QDECL)
00052 #define QDECL
00053 #endif
00054 
00055 
00056 #define DEFINE_FIXED            0x0001
00057 
00058 #define BUILTIN_LINE            1
00059 #define BUILTIN_FILE            2
00060 #define BUILTIN_DATE            3
00061 #define BUILTIN_TIME            4
00062 #define BUILTIN_STDC            5
00063 
00064 #define INDENT_IF               0x0001
00065 #define INDENT_ELSE             0x0002
00066 #define INDENT_ELIF             0x0004
00067 #define INDENT_IFDEF            0x0008
00068 #define INDENT_IFNDEF           0x0010
00069 
00070 //macro definitions
00071 typedef struct define_s
00072 {
00073     char *name;                         //define name
00074     int flags;                          //define flags
00075     int builtin;                        // > 0 if builtin define
00076     int numparms;                       //number of define parameters
00077     token_t *parms;                     //define parameters
00078     token_t *tokens;                    //macro tokens (possibly containing parm tokens)
00079     struct define_s *next;              //next defined macro in a list
00080     struct define_s *hashnext;          //next define in the hash chain
00081 } define_t;
00082 
00083 //indents
00084 //used for conditional compilation directives:
00085 //#if, #else, #elif, #ifdef, #ifndef
00086 typedef struct indent_s
00087 {
00088     int type;                               //indent type
00089     int skip;                               //true if skipping current indent
00090     script_t *script;                       //script the indent was in
00091     struct indent_s *next;                  //next indent on the indent stack
00092 } indent_t;
00093 
00094 //source file
00095 typedef struct source_s
00096 {
00097     char filename[1024];                    //file name of the script
00098     char includepath[1024];                 //path to include files
00099     punctuation_t *punctuations;            //punctuations to use
00100     script_t *scriptstack;                  //stack with scripts of the source
00101     token_t *tokens;                        //tokens to read first
00102     define_t *defines;                      //list with macro definitions
00103     define_t **definehash;                  //hash chain with defines
00104     indent_t *indentstack;                  //stack with indents
00105     int skip;                               // > 0 if skipping conditional code
00106     token_t token;                          //last read token
00107 } source_t;
00108 
00109 
00110 //read a token from the source
00111 int PC_ReadToken(source_t *source, token_t *token);
00112 //expect a certain token
00113 int PC_ExpectTokenString(source_t *source, char *string);
00114 //expect a certain token type
00115 int PC_ExpectTokenType(source_t *source, int type, int subtype, token_t *token);
00116 //expect a token
00117 int PC_ExpectAnyToken(source_t *source, token_t *token);
00118 //returns true when the token is available
00119 int PC_CheckTokenString(source_t *source, char *string);
00120 //returns true an reads the token when a token with the given type is available
00121 int PC_CheckTokenType(source_t *source, int type, int subtype, token_t *token);
00122 //skip tokens until the given token string is read
00123 int PC_SkipUntilString(source_t *source, char *string);
00124 //unread the last token read from the script
00125 void PC_UnreadLastToken(source_t *source);
00126 //unread the given token
00127 void PC_UnreadToken(source_t *source, token_t *token);
00128 //read a token only if on the same line, lines are concatenated with a slash
00129 int PC_ReadLine(source_t *source, token_t *token);
00130 //returns true if there was a white space in front of the token
00131 int PC_WhiteSpaceBeforeToken(token_t *token);
00132 //add a define to the source
00133 int PC_AddDefine(source_t *source, char *string);
00134 //add a globals define that will be added to all opened sources
00135 int PC_AddGlobalDefine(char *string);
00136 //remove the given global define
00137 int PC_RemoveGlobalDefine(char *name);
00138 //remove all globals defines
00139 void PC_RemoveAllGlobalDefines(void);
00140 //add builtin defines
00141 void PC_AddBuiltinDefines(source_t *source);
00142 //set the source include path
00143 void PC_SetIncludePath(source_t *source, char *path);
00144 //set the punction set
00145 void PC_SetPunctuations(source_t *source, punctuation_t *p);
00146 //set the base folder to load files from
00147 void PC_SetBaseFolder(char *path);
00148 //load a source file
00149 source_t *LoadSourceFile(const char *filename);
00150 //load a source from memory
00151 source_t *LoadSourceMemory(char *ptr, int length, char *name);
00152 //free the given source
00153 void FreeSource(source_t *source);
00154 //print a source error
00155 void QDECL SourceError(source_t *source, char *str, ...);
00156 //print a source warning
00157 void QDECL SourceWarning(source_t *source, char *str, ...);
00158 
00159 #ifdef BSPC
00160 // some of BSPC source does include game/q_shared.h and some does not
00161 // we define pc_token_s pc_token_t if needed (yes, it's ugly)
00162 #ifndef __Q_SHARED_H
00163 #define MAX_TOKENLENGTH     1024
00164 typedef struct pc_token_s
00165 {
00166     int type;
00167     int subtype;
00168     int intvalue;
00169     float floatvalue;
00170     char string[MAX_TOKENLENGTH];
00171 } pc_token_t;
00172 #endif 
00173 #endif //BSPC
00174 
00175 //
00176 int PC_LoadSourceHandle(const char *filename);
00177 int PC_FreeSourceHandle(int handle);
00178 int PC_ReadTokenHandle(int handle, pc_token_t *pc_token);
00179 int PC_SourceFileAndLine(int handle, char *filename, int *line);
00180 void PC_CheckOpenSourceHandles(void);

Generated on Thu Aug 25 12:37:13 2005 for Quake III Arena by  doxygen 1.3.9.1