cppSimpleType.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /**
  2. * PANDA 3D SOFTWARE
  3. * Copyright (c) Carnegie Mellon University. All rights reserved.
  4. *
  5. * All use of this software is subject to the terms of the revised BSD
  6. * license. You should have received a copy of this license along
  7. * with this source code in a file named "LICENSE."
  8. *
  9. * @file cppSimpleType.h
  10. * @author drose
  11. * @date 1999-10-19
  12. */
  13. #ifndef CPPSIMPLETYPE_H
  14. #define CPPSIMPLETYPE_H
  15. #include "dtoolbase.h"
  16. #include "cppType.h"
  17. /**
  18. * Represents a C++ fundamental type.
  19. */
  20. class CPPSimpleType : public CPPType {
  21. public:
  22. enum Type {
  23. T_unknown,
  24. T_bool,
  25. T_char,
  26. T_wchar_t,
  27. T_char8_t,
  28. T_char16_t,
  29. T_char32_t,
  30. T_int,
  31. T_float,
  32. T_double,
  33. T_void,
  34. // We need something to represent the type of nullptr so that we can
  35. // return it from decltype(nullptr). Note that this is not the same as
  36. // nullptr_t, which is a typedef of decltype(nullptr).
  37. T_nullptr,
  38. // T_parameter is a special type which is assigned to expressions that are
  39. // discovered where a formal parameter was expected. This is a special
  40. // case for handling cases like this: int foo(0); which really means the
  41. // same thing as: int foo = 0; but it initially looks like a function
  42. // prototype.
  43. T_parameter,
  44. // T_auto is also a special type that corresponds to the "auto" keyword
  45. // used in a variable assignment. The type of it is automatically
  46. // determined at a later stage based on the type of the expression that is
  47. // assigned to it.
  48. T_auto,
  49. // This is also a special built-in type.
  50. T_va_list,
  51. };
  52. enum Flags {
  53. F_long = 0x001,
  54. F_longlong = 0x002,
  55. F_short = 0x004,
  56. F_unsigned = 0x008,
  57. F_signed = 0x010,
  58. };
  59. CPPSimpleType(Type type, int flags = 0);
  60. Type _type;
  61. int _flags;
  62. virtual bool is_tbd() const;
  63. bool is_arithmetic() const;
  64. virtual bool is_fundamental() const;
  65. virtual bool is_standard_layout() const;
  66. virtual bool is_trivial() const;
  67. virtual bool is_trivially_copyable() const;
  68. virtual bool is_constructible(const CPPType *type) const;
  69. virtual bool is_default_constructible() const;
  70. virtual bool is_copy_constructible() const;
  71. virtual bool is_copy_assignable() const;
  72. virtual bool is_destructible() const;
  73. virtual bool is_parameter_expr() const;
  74. virtual std::string get_preferred_name() const;
  75. virtual void output(std::ostream &out, int indent_level, CPPScope *scope,
  76. bool complete) const;
  77. virtual SubType get_subtype() const;
  78. virtual CPPSimpleType *as_simple_type();
  79. protected:
  80. virtual bool is_equal(const CPPDeclaration *other) const;
  81. virtual bool is_less(const CPPDeclaration *other) const;
  82. };
  83. #endif