cppType.h 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. // Filename: cppType.h
  2. // Created by: drose (19Oct99)
  3. //
  4. ////////////////////////////////////////////////////////////////////
  5. //
  6. // PANDA 3D SOFTWARE
  7. // Copyright (c) Carnegie Mellon University. All rights reserved.
  8. //
  9. // All use of this software is subject to the terms of the revised BSD
  10. // license. You should have received a copy of this license along
  11. // with this source code in a file named "LICENSE."
  12. //
  13. ////////////////////////////////////////////////////////////////////
  14. #ifndef CPPTYPE_H
  15. #define CPPTYPE_H
  16. #include "dtoolbase.h"
  17. #include "cppDeclaration.h"
  18. #include <set>
  19. class CPPType;
  20. class CPPTypedefType;
  21. class CPPTypeDeclaration;
  22. // This is an STL function object used to uniquely order CPPType
  23. // pointers.
  24. class CPPTypeCompare {
  25. public:
  26. bool operator () (CPPType *a, CPPType *b) const;
  27. };
  28. ///////////////////////////////////////////////////////////////////
  29. // Class : CPPType
  30. // Description :
  31. ////////////////////////////////////////////////////////////////////
  32. class CPPType : public CPPDeclaration {
  33. public:
  34. typedef vector<CPPTypedefType *> Typedefs;
  35. Typedefs _typedefs;
  36. CPPType(const CPPFile &file);
  37. virtual CPPType *resolve_type(CPPScope *current_scope,
  38. CPPScope *global_scope);
  39. virtual bool is_tbd() const;
  40. virtual bool is_trivial() const;
  41. virtual bool is_parameter_expr() const;
  42. bool has_typedef_name() const;
  43. string get_typedef_name(CPPScope *scope = NULL) const;
  44. virtual string get_simple_name() const;
  45. virtual string get_local_name(CPPScope *scope = NULL) const;
  46. virtual string get_fully_scoped_name() const;
  47. virtual string get_preferred_name() const;
  48. int get_num_alt_names() const;
  49. string get_alt_name(int n) const;
  50. virtual bool is_incomplete() const;
  51. virtual bool is_equivalent(const CPPType &other) const;
  52. void output_instance(ostream &out, const string &name,
  53. CPPScope *scope) const;
  54. virtual void output_instance(ostream &out, int indent_level,
  55. CPPScope *scope,
  56. bool complete, const string &prename,
  57. const string &name) const;
  58. virtual CPPType *as_type();
  59. static CPPType *new_type(CPPType *type);
  60. static void record_alt_name_for(const CPPType *type, const string &name);
  61. static string get_preferred_name_for(const CPPType *type);
  62. CPPTypeDeclaration *_declaration;
  63. bool _forcetype;
  64. protected:
  65. typedef set<CPPType *, CPPTypeCompare> Types;
  66. static Types _types;
  67. typedef map<string, string> PreferredNames;
  68. static PreferredNames _preferred_names;
  69. typedef vector<string> Names;
  70. typedef map<string, Names> AltNames;
  71. static AltNames _alt_names;
  72. };
  73. #endif