cppTypeParser.cxx 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. // Filename: cppTypeParser.cxx
  2. // Created by: drose (14Dec99)
  3. //
  4. ////////////////////////////////////////////////////////////////////
  5. //
  6. // PANDA 3D SOFTWARE
  7. // Copyright (c) Carnegie Mellon University. All rights reserved.
  8. //
  9. // All use of this software is subject to the terms of the revised BSD
  10. // license. You should have received a copy of this license along
  11. // with this source code in a file named "LICENSE."
  12. //
  13. ////////////////////////////////////////////////////////////////////
  14. #include "cppTypeParser.h"
  15. #include "cppType.h"
  16. ////////////////////////////////////////////////////////////////////
  17. // Function: CPPTypeParser::Constructor
  18. // Access: Public
  19. // Description:
  20. ////////////////////////////////////////////////////////////////////
  21. CPPTypeParser::
  22. CPPTypeParser(CPPScope *current_scope, CPPScope *global_scope) :
  23. _current_scope(current_scope),
  24. _global_scope(global_scope)
  25. {
  26. _type = NULL;
  27. }
  28. ////////////////////////////////////////////////////////////////////
  29. // Function: CPPTypeParser::Destructor
  30. // Access: Public
  31. // Description:
  32. ////////////////////////////////////////////////////////////////////
  33. CPPTypeParser::
  34. ~CPPTypeParser() {
  35. }
  36. ////////////////////////////////////////////////////////////////////
  37. // Function: CPPTypeParser::parse_type
  38. // Access: Public
  39. // Description:
  40. ////////////////////////////////////////////////////////////////////
  41. bool CPPTypeParser::
  42. parse_type(const string &type) {
  43. if (!init_type(type)) {
  44. cerr << "Unable to parse type\n";
  45. return false;
  46. }
  47. _type = ::parse_type(this, _current_scope, _global_scope);
  48. return get_error_count() == 0;
  49. }
  50. ////////////////////////////////////////////////////////////////////
  51. // Function: CPPTypeParser::parse_type
  52. // Access: Public
  53. // Description:
  54. ////////////////////////////////////////////////////////////////////
  55. bool CPPTypeParser::
  56. parse_type(const string &type, const CPPPreprocessor &filepos) {
  57. if (!init_type(type)) {
  58. cerr << "Unable to parse type\n";
  59. return false;
  60. }
  61. copy_filepos(filepos);
  62. _type = ::parse_type(this, _current_scope, _global_scope);
  63. return get_error_count() == 0;
  64. }
  65. ////////////////////////////////////////////////////////////////////
  66. // Function: CPPTypeParser::output
  67. // Access: Public
  68. // Description:
  69. ////////////////////////////////////////////////////////////////////
  70. void CPPTypeParser::
  71. output(ostream &out) const {
  72. if (_type == NULL) {
  73. out << "(null type)";
  74. } else {
  75. out << *_type;
  76. }
  77. }