cppDeclaration.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. // Filename: cppDeclaration.h
  2. // Created by: drose (19Oct99)
  3. //
  4. ////////////////////////////////////////////////////////////////////
  5. //
  6. // PANDA 3D SOFTWARE
  7. // Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved
  8. //
  9. // All use of this software is subject to the terms of the Panda 3d
  10. // Software license. You should have received a copy of this license
  11. // along with this source code; you will also find a current copy of
  12. // the license at http://www.panda3d.org/license.txt .
  13. //
  14. // To contact the maintainers of this program write to
  15. // [email protected] .
  16. //
  17. ////////////////////////////////////////////////////////////////////
  18. #ifndef CPPDECLARATION_H
  19. #define CPPDECLARATION_H
  20. #include <dtoolbase.h>
  21. #include "cppVisibility.h"
  22. #include "cppFile.h"
  23. #include "cppCommentBlock.h"
  24. #include <string>
  25. #include <vector>
  26. #include <map>
  27. #include <set>
  28. using namespace std;
  29. class CPPInstance;
  30. class CPPTemplateParameterList;
  31. class CPPTypedef;
  32. class CPPTypeDeclaration;
  33. class CPPExpression;
  34. class CPPType;
  35. class CPPNamespace;
  36. class CPPUsing;
  37. class CPPSimpleType;
  38. class CPPPointerType;
  39. class CPPReferenceType;
  40. class CPPArrayType;
  41. class CPPConstType;
  42. class CPPFunctionType;
  43. class CPPFunctionGroup;
  44. class CPPExtensionType;
  45. class CPPStructType;
  46. class CPPEnumType;
  47. class CPPTypeProxy;
  48. class CPPClassTemplateParameter;
  49. class CPPTBDType;
  50. class CPPScope;
  51. class CPPTemplateScope;
  52. class CPPPreprocessor;
  53. ///////////////////////////////////////////////////////////////////
  54. // Class : CPPDeclaration
  55. // Description :
  56. ////////////////////////////////////////////////////////////////////
  57. class CPPDeclaration {
  58. public:
  59. enum SubType {
  60. // Subtypes of CPPDeclaration
  61. ST_instance,
  62. ST_typedef,
  63. ST_type_declaration,
  64. ST_expression,
  65. ST_type,
  66. ST_namespace,
  67. ST_using,
  68. // Subtypes of CPPType
  69. ST_simple,
  70. ST_pointer,
  71. ST_reference,
  72. ST_array,
  73. ST_const,
  74. ST_function,
  75. ST_function_group,
  76. ST_extension,
  77. ST_struct,
  78. ST_enum,
  79. ST_class_template_parameter,
  80. ST_tbd,
  81. ST_type_proxy,
  82. };
  83. CPPDeclaration(const CPPFile &file);
  84. CPPDeclaration(const CPPDeclaration &copy);
  85. virtual ~CPPDeclaration();
  86. bool operator == (const CPPDeclaration &other) const;
  87. bool operator != (const CPPDeclaration &other) const;
  88. bool operator < (const CPPDeclaration &other) const;
  89. bool is_template() const;
  90. CPPTemplateScope *get_template_scope() const;
  91. virtual bool is_fully_specified() const;
  92. virtual CPPDeclaration *
  93. instantiate(const CPPTemplateParameterList *actual_params,
  94. CPPScope *current_scope, CPPScope *global_scope,
  95. CPPPreprocessor *error_sink = NULL) const;
  96. typedef map<CPPDeclaration *, CPPDeclaration *> SubstDecl;
  97. virtual CPPDeclaration *substitute_decl(SubstDecl &subst,
  98. CPPScope *current_scope,
  99. CPPScope *global_scope);
  100. typedef set<CPPDeclaration *> Instantiations;
  101. Instantiations _instantiations;
  102. virtual void output(ostream &out, int indent_level, CPPScope *scope,
  103. bool complete) const=0;
  104. virtual SubType get_subtype() const=0;
  105. virtual CPPInstance *as_instance();
  106. virtual CPPClassTemplateParameter *as_class_template_parameter();
  107. virtual CPPTypedef *as_typedef();
  108. virtual CPPTypeDeclaration *as_type_declaration();
  109. virtual CPPExpression *as_expression();
  110. virtual CPPType *as_type();
  111. virtual CPPNamespace *as_namespace();
  112. virtual CPPUsing *as_using();
  113. virtual CPPSimpleType *as_simple_type();
  114. virtual CPPPointerType *as_pointer_type();
  115. virtual CPPReferenceType *as_reference_type();
  116. virtual CPPArrayType *as_array_type();
  117. virtual CPPConstType *as_const_type();
  118. virtual CPPFunctionType *as_function_type();
  119. virtual CPPFunctionGroup *as_function_group();
  120. virtual CPPExtensionType *as_extension_type();
  121. virtual CPPStructType *as_struct_type();
  122. virtual CPPEnumType *as_enum_type();
  123. virtual CPPTBDType *as_tbd_type();
  124. virtual CPPTypeProxy *as_type_proxy();
  125. CPPVisibility _vis;
  126. CPPTemplateScope *_template_scope;
  127. CPPFile _file;
  128. CPPCommentBlock *_leading_comment;
  129. protected:
  130. virtual bool is_equal(const CPPDeclaration *other) const;
  131. virtual bool is_less(const CPPDeclaration *other) const;
  132. };
  133. inline ostream &
  134. operator << (ostream &out, const CPPDeclaration &decl) {
  135. decl.output(out, 0, (CPPScope *)NULL, false);
  136. return out;
  137. }
  138. #endif