cppMakeProperty.cxx 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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. {
  31. _ident->_native_scope = current_scope;
  32. }
  33. /**
  34. *
  35. */
  36. string CPPMakeProperty::
  37. get_simple_name() const {
  38. return _ident->get_simple_name();
  39. }
  40. /**
  41. *
  42. */
  43. string CPPMakeProperty::
  44. get_local_name(CPPScope *scope) const {
  45. return _ident->get_local_name(scope);
  46. }
  47. /**
  48. *
  49. */
  50. string CPPMakeProperty::
  51. get_fully_scoped_name() const {
  52. return _ident->get_fully_scoped_name();
  53. }
  54. /**
  55. *
  56. */
  57. void CPPMakeProperty::
  58. output(ostream &out, int indent_level, CPPScope *scope, bool complete) const {
  59. if (_length_function != NULL) {
  60. out << "__make_seq_property";
  61. } else {
  62. out << "__make_property";
  63. }
  64. if (_has_function != NULL) {
  65. out.put('2');
  66. }
  67. out << "(" << _ident->get_local_name(scope);
  68. if (_length_function != NULL) {
  69. out << ", " << _length_function->_name;
  70. }
  71. if (_has_function != NULL) {
  72. out << ", " << _has_function->_name;
  73. }
  74. out << ", " << _get_function->_name;
  75. if (_set_function != NULL) {
  76. out << ", " << _set_function->_name;
  77. }
  78. if (_clear_function != NULL) {
  79. out << ", " << _clear_function->_name;
  80. }
  81. if (_del_function != NULL) {
  82. out << ", " << _del_function->_name;
  83. }
  84. out << ");";
  85. }
  86. /**
  87. *
  88. */
  89. CPPDeclaration::SubType CPPMakeProperty::
  90. get_subtype() const {
  91. return ST_make_property;
  92. }
  93. /**
  94. *
  95. */
  96. CPPMakeProperty *CPPMakeProperty::
  97. as_make_property() {
  98. return this;
  99. }