cppType.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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 CPPTypedef;
  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<CPPTypedef *> 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_parameter_expr() const;
  41. bool has_typedef_name() const;
  42. string get_typedef_name(CPPScope *scope = NULL) const;
  43. virtual string get_simple_name() const;
  44. virtual string get_local_name(CPPScope *scope = NULL) const;
  45. virtual string get_fully_scoped_name() const;
  46. virtual string get_preferred_name() const;
  47. int get_num_alt_names() const;
  48. string get_alt_name(int n) const;
  49. virtual bool is_incomplete() const;
  50. virtual bool is_equivalent(const CPPType &other) const;
  51. void output_instance(ostream &out, const string &name,
  52. CPPScope *scope) const;
  53. virtual void output_instance(ostream &out, int indent_level,
  54. CPPScope *scope,
  55. bool complete, const string &prename,
  56. const string &name) const;
  57. virtual CPPType *as_type();
  58. static CPPType *new_type(CPPType *type);
  59. static void record_alt_name_for(const CPPType *type, const string &name);
  60. static string get_preferred_name_for(const CPPType *type);
  61. CPPTypeDeclaration *_declaration;
  62. bool _forcetype;
  63. protected:
  64. typedef set<CPPType *, CPPTypeCompare> Types;
  65. static Types _types;
  66. typedef map<string, string> PreferredNames;
  67. static PreferredNames _preferred_names;
  68. typedef vector<string> Names;
  69. typedef map<string, Names> AltNames;
  70. static AltNames _alt_names;
  71. };
  72. #endif