28 #include "../idlib/precompiled.h"
33 #define TYPE_INFO_GEN_VERSION "1.0"
63 if (
classes[i]->typeName.Cmp( typeName ) == 0 ) {
64 if (
classes[i]->superType[0] !=
'\0' ) {
82 if (
string.Find(
"::" ) != -1 ) {
85 evalString =
"$evalint(" +
string +
")";
99 if (
string.Find(
"::" ) != -1 ) {
102 evalString =
"$evalfloat(" +
string +
")";
116 if (
constants[i]->name.Cmp( name ) == 0 ) {
130 if ( constant ==
NULL ) {
136 src.
Warning(
"unknown value '%s' in constant expression", name );
147 if ( constant ==
NULL ) {
153 src.
Warning(
"unknown value '%s' in constant expression", name );
164 idStr sizeString, constantString;
174 if ( token ==
"]" ) {
175 if ( sizeString.
Length() ) {
186 constantString = token;
189 constantString +=
"::" + token;
207 idStr constantString;
211 if ( token ==
"(" ) {
213 }
else if ( token ==
")" ) {
215 }
else if ( indent == 0 && ( token ==
";" || token ==
"," || token ==
"}" ) ) {
219 constantString = token;
222 constantString +=
"::" + token;
244 typeInfo->
scope = scope;
264 enumValue.
name = token;
269 if ( valueString.
Length() ) {
281 constantInfo->
name = scope + enumValue.
name;
282 constantInfo->
type =
"int";
283 constantInfo->
value =
va(
"%d", value );
316 typeInfo->
scope = scope;
320 typeInfo->
typeName = token + templateArgs;
332 while( token ==
"public" ||
333 token ==
"protected" ||
334 token ==
"private" ) {
349 if ( token ==
"<" ) {
351 }
else if ( token ==
">" ) {
386 typeInfo->
typeName = token + templateArgs;
408 bool isConst =
false;
409 bool isStatic =
false;
417 if ( token ==
"{" ) {
420 if ( token ==
"{" ) {
422 }
else if ( token ==
"}" ) {
425 varType += token +
" ";
426 }
while( indent > 1 && src.
ReadToken( &token ) );
428 }
else if ( token ==
"}" ) {
433 }
else if ( token ==
"<" ) {
436 if ( token ==
"<" ) {
438 }
else if ( token ==
">" ) {
441 varType += token +
" ";
442 }
while( indent > 1 && src.
ReadToken( &token ) );
444 }
else if ( token ==
";" ) {
450 }
else if ( token ==
"public" || token ==
"protected" || token ==
"private" ) {
459 }
else if ( token ==
"friend" ) {
463 if ( token ==
"{" ) {
465 }
else if ( token ==
"}" ) {
470 }
else if ( token ==
";" && indent == 1 ) {
479 }
else if ( token ==
"template" ) {
488 if ( token ==
"<" ) {
490 }
else if ( token ==
">" ) {
496 varType += token +
" ";
513 if ( token ==
"{" ) {
515 }
else if ( token ==
"}" ) {
520 }
else if ( token ==
";" && indent == 1 ) {
530 }
else if ( token ==
"namespace" ) {
536 }
else if ( token ==
"class" ) {
544 }
else if ( token ==
"struct" ) {
553 }
else if ( token ==
"union" ) {
561 }
else if ( token ==
"enum" ) {
570 }
else if ( token ==
"typedef" ) {
572 if ( token ==
"class" ) {
608 if ( token ==
"{" ) {
610 }
else if ( token ==
"}" ) {
612 }
else if ( token ==
";" && indent == 1 ) {
622 }
else if ( token ==
"const" ) {
624 varType += token +
" ";
627 }
else if ( token ==
"static" ) {
629 varType += token +
" ";
637 if ( token ==
"operator" ) {
639 if ( token ==
"(" ) {
650 while( indent > 1 && src.
ReadToken( &token ) ) {
651 if ( token ==
"(" ) {
653 }
else if ( token ==
")" ) {
660 while( indent > 1 && src.
ReadToken( &token ) ) {
661 if ( token ==
"(" ) {
663 }
else if ( token ==
")" ) {
678 while( indent > 1 && src.
ReadToken( &token ) ) {
679 if ( token ==
"{" ) {
681 }
else if ( token ==
"}" ) {
695 constantInfo->
name = scope + token;
696 constantInfo->
type = varType;
701 }
else if ( isStatic ) {
704 varType += token +
" ";
719 var.
type +=
va(
"[%d]", arraySize );
765 varType += token +
" ";
780 varType += token +
" ";
800 int i,
j, inheritance;
816 if ( !src.
LoadFile( fileName,
true ) ) {
840 if (
classes[i]->isTemplate ) {
905 "===================================================================================\n"
907 "\tThis file has been generated with the Type Info Generator v"TYPE_INFO_GEN_VERSION" (c) 2004 id Software\n"
911 "\t%d classes/structs/unions\n"
913 "\t%d max inheritance level for '%s'\n"
915 "===================================================================================\n"
922 "\t" "const char * name;\n"
923 "\t" "const char * type;\n"
924 "\t" "const char * value;\n"
925 "} constantInfo_t;\n"
928 "\t" "const char * name;\n"
930 "} enumValueInfo_t;\n"
933 "\t" "const char * typeName;\n"
934 "\t" "const enumValueInfo_t * values;\n"
935 "} enumTypeInfo_t;\n"
938 "\t" "const char * type;\n"
939 "\t" "const char * name;\n"
942 "} classVariableInfo_t;\n"
945 "\t" "const char * typeName;\n"
946 "\t" "const char * superType;\n"
948 "\t" "const classVariableInfo_t * variables;\n"
949 "} classTypeInfo_t;\n"
964 for ( i = 0; i <
enums.
Num(); i++ ) {
972 for ( j = 0; j < info->
values.
Num(); j++ ) {
986 for ( i = 0; i <
enums.
Num(); i++ ) {
990 idStr typeInfoName = typeName;
1007 idStr typeInfoName = typeName;
1013 const char *varName = info->
variables[
j].name.c_str();
1014 const char *varType = info->
variables[
j].type.c_str();
1019 file->
WriteFloatString(
"\t{ \"%s\", \"%s\", (int)(&((%s *)0)->%s), sizeof( ((%s *)0)->%s ) },\n",
1020 varType, varName, typeName.
c_str(), varName, typeName.
c_str(), varName );
1034 idStr typeInfoName = typeName;
1040 file->
WriteFloatString(
"\t{ \"%s\", \"%s\", sizeof(%s), %s_typeInfo },\n",
idList< idEnumValueInfo > values
GLsizei const GLfloat * value
int AddDefine(const char *string)
assert(prefInfo.fullscreenBtn)
void UnreadToken(idToken *token)
idEnumTypeInfo * ParseEnumType(const char *scope, bool isTemplate, bool typeDef, idParser &src)
idList< idClassTypeInfo * > classes
void ParseScope(const char *scope, bool isTemplate, idParser &src, idClassTypeInfo *typeInfo)
idConstantInfo * FindConstant(const char *name)
int GetNumFiles(void) const
void WriteTypeInfo(const char *fileName) const
void StripTrailing(const char c)
#define TYPE_INFO_GEN_VERSION
idFileSystem * fileSystem
int LoadMemory(const char *ptr, int length, const char *name)
void FreeSource(bool keepDefines=false)
int EvaluateIntegerString(const idStr &string)
int ExpectTokenString(const char *string)
idStr maxInheritanceClass
idClassTypeInfo * ParseClassType(const char *scope, const char *templateArgs, bool isTemplate, bool typeDef, idParser &src)
float EvaluateFloatString(const idStr &string)
int ReadToken(idToken *token)
idList< idConstantInfo * > constants
void ExtractFileName(idStr &dest) const
const char * GetFile(int index) const
void void Warning(const char *str,...) const id_attribute((format(printf
void DeleteContents(bool clear)
virtual int WriteFloatString(const char *fmt,...) id_attribute((format(printf
void AddDefine(const char *define)
virtual void FreeFileList(idFileList *fileList)=0
virtual void Printf(const char *fmt,...) id_attribute((format(printf
int ParseArraySize(const char *scope, idParser &src)
virtual const char * RelativePathToOSPath(const char *relativePath, const char *basePath="fs_devpath")=0
int Append(const type &obj)
virtual idFile * OpenExplicitFileWrite(const char *OSPath)=0
void ParseConstantValue(const char *scope, idParser &src, idStr &value)
int GetInheritance(const char *typeName) const
virtual idFileList * ListFilesTree(const char *relativePath, const char *extension, bool sort=false, const char *gamedir=NULL)=0
int LoadFile(const char *filename, bool OSPath=false)
int CheckTokenString(const char *string)
idList< idClassVariableInfo > variables
const char * c_str(void) const
void CleanName(idStr &name)
idList< idEnumTypeInfo * > enums
char * va(const char *fmt,...)
void CreateTypeInfo(const char *path)
virtual void CloseFile(idFile *f)=0
float GetFloatConstant(const char *scope, const char *name, idParser &src)
void Replace(const char *old, const char *nw)
int GetIntegerConstant(const char *scope, const char *name, idParser &src)
virtual void virtual void Warning(const char *fmt,...) id_attribute((format(printf
int sprintf(idStr &string, const char *fmt,...)
int CheckTokenType(int type, int subtype, idToken *token)
int ExpectTokenType(int type, int subtype, idToken *token)