1 /* 2 =========================================================================== 3 4 Doom 3 GPL Source Code 5 Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company. 6 7 This file is part of the Doom 3 GPL Source Code ("Doom 3 Source Code"). 8 9 Doom 3 Source Code is free software: you can redistribute it and/or modify 10 it under the terms of the GNU General Public License as published by 11 the Free Software Foundation, either version 3 of the License, or 12 (at your option) any later version. 13 14 Doom 3 Source Code is distributed in the hope that it will be useful, 15 but WITHOUT ANY WARRANTY; without even the implied warranty of 16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 GNU General Public License for more details. 18 19 You should have received a copy of the GNU General Public License 20 along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>. 21 22 In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below. 23 24 If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA. 25 26 =========================================================================== 27 */ 28 29 #ifndef __TYPEINFOGEN_H__ 30 #define __TYPEINFOGEN_H__ 31 32 /* 33 =================================================================================== 34 35 Type Info Generator 36 37 - template classes are commented out (different instantiations are not identified) 38 - bit fields are commented out (cannot get the address of bit fields) 39 - multiple inheritance is not supported (only tracks a single super type) 40 41 =================================================================================== 42 */ 43 44 class idConstantInfo { 45 public: 46 idStr name; 47 idStr type; 48 idStr value; 49 }; 50 51 class idEnumValueInfo { 52 public: 53 idStr name; 54 int value; 55 }; 56 57 class idEnumTypeInfo { 58 public: 59 idStr typeName; 60 idStr scope; 61 bool unnamed; 62 bool isTemplate; 63 idList<idEnumValueInfo> values; 64 }; 65 66 class idClassVariableInfo { 67 public: 68 idStr name; 69 idStr type; 70 int bits; 71 }; 72 73 class idClassTypeInfo { 74 public: 75 idStr typeName; 76 idStr superType; 77 idStr scope; 78 bool unnamed; 79 bool isTemplate; 80 idList<idClassVariableInfo> variables; 81 }; 82 83 class idTypeInfoGen { 84 public: 85 idTypeInfoGen( void ); 86 ~idTypeInfoGen( void ); 87 88 void AddDefine( const char *define ); 89 void CreateTypeInfo( const char *path ); 90 void WriteTypeInfo( const char *fileName ) const; 91 92 private: 93 idStrList defines; 94 95 idList<idConstantInfo *> constants; 96 idList<idEnumTypeInfo *> enums; 97 idList<idClassTypeInfo *> classes; 98 99 int numTemplates; 100 int maxInheritance; 101 idStr maxInheritanceClass; 102 103 int GetInheritance( const char *typeName ) const; 104 int EvaluateIntegerString( const idStr &string ); 105 float EvaluateFloatString( const idStr &string ); 106 idConstantInfo * FindConstant( const char *name ); 107 int GetIntegerConstant( const char *scope, const char *name, idParser &src ); 108 float GetFloatConstant( const char *scope, const char *name, idParser &src ); 109 int ParseArraySize( const char *scope, idParser &src ); 110 void ParseConstantValue( const char *scope, idParser &src, idStr &value ); 111 idEnumTypeInfo * ParseEnumType( const char *scope, bool isTemplate, bool typeDef, idParser &src ); 112 idClassTypeInfo * ParseClassType( const char *scope, const char *templateArgs, bool isTemplate, bool typeDef, idParser &src ); 113 void ParseScope( const char *scope, bool isTemplate, idParser &src, idClassTypeInfo *typeInfo ); 114 }; 115 116 #endif /* !__TYPEINFOGEN_H__ */ 117