cppClassTemplateParameter.cxx 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. // Filename: cppClassTemplateParameter.cxx
  2. // Created by: drose (28Oct99)
  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. #include "cppClassTemplateParameter.h"
  19. #include "cppIdentifier.h"
  20. ////////////////////////////////////////////////////////////////////
  21. // Function: CPPClassTemplateParameter::Constructor
  22. // Access: Public
  23. // Description:
  24. ////////////////////////////////////////////////////////////////////
  25. CPPClassTemplateParameter::
  26. CPPClassTemplateParameter(CPPIdentifier *ident, CPPType *default_type) :
  27. CPPType(CPPFile()),
  28. _ident(ident),
  29. _default_type(default_type)
  30. {
  31. }
  32. ////////////////////////////////////////////////////////////////////
  33. // Function: CPPClassTemplateParameter::is_fully_specified
  34. // Access: Public, Virtual
  35. // Description: Returns true if this declaration is an actual,
  36. // factual declaration, or false if some part of the
  37. // declaration depends on a template parameter which has
  38. // not yet been instantiated.
  39. ////////////////////////////////////////////////////////////////////
  40. bool CPPClassTemplateParameter::
  41. is_fully_specified() const {
  42. return false;
  43. }
  44. ////////////////////////////////////////////////////////////////////
  45. // Function: CPPClassTemplateParameter::output
  46. // Access: Public, Virtual
  47. // Description:
  48. ////////////////////////////////////////////////////////////////////
  49. void CPPClassTemplateParameter::
  50. output(ostream &out, int indent_level, CPPScope *scope, bool complete) const {
  51. if (complete) {
  52. out << "class ";
  53. _ident->output(out, scope);
  54. if (_default_type) {
  55. out << " = ";
  56. _default_type->output(out, indent_level, scope, false);
  57. }
  58. } else {
  59. _ident->output(out, scope);
  60. }
  61. }
  62. ////////////////////////////////////////////////////////////////////
  63. // Function: CPPClassTemplateParameter::get_subtype
  64. // Access: Public, Virtual
  65. // Description:
  66. ////////////////////////////////////////////////////////////////////
  67. CPPDeclaration::SubType CPPClassTemplateParameter::
  68. get_subtype() const {
  69. return ST_class_template_parameter;
  70. }
  71. ////////////////////////////////////////////////////////////////////
  72. // Function: CPPClassTemplateParameter::as_classTemplateParameter
  73. // Access: Public, Virtual
  74. // Description:
  75. ////////////////////////////////////////////////////////////////////
  76. CPPClassTemplateParameter *CPPClassTemplateParameter::
  77. as_class_template_parameter() {
  78. return this;
  79. }
  80. ////////////////////////////////////////////////////////////////////
  81. // Function: CPPClassTemplateParameter::is_equal
  82. // Access: Protected, Virtual
  83. // Description: Called by CPPDeclaration() to determine whether this type is
  84. // equivalent to another type of the same type.
  85. ////////////////////////////////////////////////////////////////////
  86. bool CPPClassTemplateParameter::
  87. is_equal(const CPPDeclaration *other) const {
  88. const CPPClassTemplateParameter *ot = ((CPPDeclaration *)other)->as_class_template_parameter();
  89. assert(ot != NULL);
  90. if (_default_type != ot->_default_type) {
  91. return false;
  92. }
  93. return *_ident == *ot->_ident;
  94. }
  95. ////////////////////////////////////////////////////////////////////
  96. // Function: CPPClassTemplateParameter::is_less
  97. // Access: Protected, Virtual
  98. // Description: Called by CPPDeclaration() to determine whether this type
  99. // should be ordered before another type of the same
  100. // type, in an arbitrary but fixed ordering.
  101. ////////////////////////////////////////////////////////////////////
  102. bool CPPClassTemplateParameter::
  103. is_less(const CPPDeclaration *other) const {
  104. const CPPClassTemplateParameter *ot = ((CPPDeclaration *)other)->as_class_template_parameter();
  105. assert(ot != NULL);
  106. if (_default_type != ot->_default_type) {
  107. return _default_type < ot->_default_type;
  108. }
  109. return *_ident < *ot->_ident;
  110. }