cppSimpleType.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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_char16_t,
  28. T_char32_t,
  29. T_int,
  30. T_float,
  31. T_double,
  32. T_void,
  33. // We need something to represent the type of nullptr so that we can
  34. // return it from decltype(nullptr). Note that this is not the same as
  35. // nullptr_t, which is a typedef of decltype(nullptr).
  36. T_nullptr,
  37. // T_parameter is a special type which is assigned to expressions that are
  38. // discovered where a formal parameter was expected. This is a special
  39. // case for handling cases like this: int foo(0); which really means the
  40. // same thing as: int foo = 0; but it initially looks like a function
  41. // prototype.
  42. T_parameter,
  43. // T_auto is also a special type that corresponds to the "auto" keyword
  44. // used in a variable assignment. The type of it is automatically
  45. // determined at a later stage based on the type of the expression that is
  46. // assigned to it.
  47. T_auto,
  48. };
  49. enum Flags {
  50. F_long = 0x001,
  51. F_longlong = 0x002,
  52. F_short = 0x004,
  53. F_unsigned = 0x008,
  54. F_signed = 0x010,
  55. };
  56. CPPSimpleType(Type type, int flags = 0);
  57. Type _type;
  58. int _flags;
  59. virtual bool is_tbd() const;
  60. bool is_arithmetic() const;
  61. virtual bool is_fundamental() const;
  62. virtual bool is_standard_layout() const;
  63. virtual bool is_trivial() const;
  64. virtual bool is_constructible(const CPPType *type) const;
  65. virtual bool is_default_constructible() const;
  66. virtual bool is_copy_constructible() const;
  67. virtual bool is_copy_assignable() const;
  68. virtual bool is_destructible() const;
  69. virtual bool is_parameter_expr() const;
  70. virtual std::string get_preferred_name() const;
  71. virtual void output(std::ostream &out, int indent_level, CPPScope *scope,
  72. bool complete) const;
  73. virtual SubType get_subtype() const;
  74. virtual CPPSimpleType *as_simple_type();
  75. protected:
  76. virtual bool is_equal(const CPPDeclaration *other) const;
  77. virtual bool is_less(const CPPDeclaration *other) const;
  78. };
  79. #endif