cppMakeProperty.cxx 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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 cppMakeProperty.cxx
  10. * @author rdb
  11. * @date 2014-09-18
  12. */
  13. #include "cppMakeProperty.h"
  14. #include "cppFunctionGroup.h"
  15. /**
  16. *
  17. */
  18. CPPMakeProperty::
  19. CPPMakeProperty(CPPIdentifier *ident, Type type,
  20. CPPScope *current_scope, const CPPFile &file) :
  21. CPPDeclaration(file),
  22. _ident(ident),
  23. _type(type),
  24. _length_function(nullptr),
  25. _has_function(nullptr),
  26. _get_function(nullptr),
  27. _set_function(nullptr),
  28. _clear_function(nullptr),
  29. _del_function(nullptr),
  30. _insert_function(nullptr),
  31. _get_key_function(nullptr)
  32. {
  33. _ident->_native_scope = current_scope;
  34. }
  35. /**
  36. *
  37. */
  38. std::string CPPMakeProperty::
  39. get_simple_name() const {
  40. return _ident->get_simple_name();
  41. }
  42. /**
  43. *
  44. */
  45. std::string CPPMakeProperty::
  46. get_local_name(CPPScope *scope) const {
  47. return _ident->get_local_name(scope);
  48. }
  49. /**
  50. *
  51. */
  52. std::string CPPMakeProperty::
  53. get_fully_scoped_name() const {
  54. return _ident->get_fully_scoped_name();
  55. }
  56. /**
  57. *
  58. */
  59. void CPPMakeProperty::
  60. output(std::ostream &out, int indent_level, CPPScope *scope, bool complete) const {
  61. if (_length_function != nullptr) {
  62. out << "__make_seq_property";
  63. } else {
  64. out << "__make_property";
  65. }
  66. if (_has_function != nullptr) {
  67. out.put('2');
  68. }
  69. out << "(" << _ident->get_local_name(scope);
  70. if (_length_function != nullptr) {
  71. out << ", " << _length_function->_name;
  72. }
  73. if (_has_function != nullptr) {
  74. out << ", " << _has_function->_name;
  75. }
  76. out << ", " << _get_function->_name;
  77. if (_set_function != nullptr) {
  78. out << ", " << _set_function->_name;
  79. }
  80. if (_clear_function != nullptr) {
  81. out << ", " << _clear_function->_name;
  82. }
  83. if (_del_function != nullptr) {
  84. out << ", " << _del_function->_name;
  85. }
  86. if (_insert_function != nullptr) {
  87. out << ", " << _insert_function->_name;
  88. }
  89. out << ");";
  90. }
  91. /**
  92. *
  93. */
  94. CPPDeclaration::SubType CPPMakeProperty::
  95. get_subtype() const {
  96. return ST_make_property;
  97. }
  98. /**
  99. *
  100. */
  101. CPPMakeProperty *CPPMakeProperty::
  102. as_make_property() {
  103. return this;
  104. }