TypeInfoGen.h 4.0 KB

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