00001 // Filename: cppTypeParser.cxx 00002 // Created by: drose (14Dec99) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved 00008 // 00009 // All use of this software is subject to the terms of the Panda 3d 00010 // Software license. You should have received a copy of this license 00011 // along with this source code; you will also find a current copy of 00012 // the license at http://www.panda3d.org/license.txt . 00013 // 00014 // To contact the maintainers of this program write to 00015 // panda3d@yahoogroups.com . 00016 // 00017 //////////////////////////////////////////////////////////////////// 00018 00019 00020 #include "cppTypeParser.h" 00021 #include "cppType.h" 00022 00023 //////////////////////////////////////////////////////////////////// 00024 // Function: CPPTypeParser::Constructor 00025 // Access: Public 00026 // Description: 00027 //////////////////////////////////////////////////////////////////// 00028 CPPTypeParser:: 00029 CPPTypeParser(CPPScope *current_scope, CPPScope *global_scope) : 00030 _current_scope(current_scope), 00031 _global_scope(global_scope) 00032 { 00033 _type = NULL; 00034 } 00035 00036 //////////////////////////////////////////////////////////////////// 00037 // Function: CPPTypeParser::Destructor 00038 // Access: Public 00039 // Description: 00040 //////////////////////////////////////////////////////////////////// 00041 CPPTypeParser:: 00042 ~CPPTypeParser() { 00043 } 00044 00045 //////////////////////////////////////////////////////////////////// 00046 // Function: CPPTypeParser::parse_type 00047 // Access: Public 00048 // Description: 00049 //////////////////////////////////////////////////////////////////// 00050 bool CPPTypeParser:: 00051 parse_type(const string &type) { 00052 if (!init_type(type)) { 00053 cerr << "Unable to parse type\n"; 00054 return false; 00055 } 00056 00057 _type = ::parse_type(this, _current_scope, _global_scope); 00058 00059 return get_error_count() == 0; 00060 } 00061 00062 //////////////////////////////////////////////////////////////////// 00063 // Function: CPPTypeParser::parse_type 00064 // Access: Public 00065 // Description: 00066 //////////////////////////////////////////////////////////////////// 00067 bool CPPTypeParser:: 00068 parse_type(const string &type, const CPPPreprocessor &filepos) { 00069 if (!init_type(type)) { 00070 cerr << "Unable to parse type\n"; 00071 return false; 00072 } 00073 00074 copy_filepos(filepos); 00075 00076 _type = ::parse_type(this, _current_scope, _global_scope); 00077 00078 return get_error_count() == 0; 00079 } 00080 00081 //////////////////////////////////////////////////////////////////// 00082 // Function: CPPTypeParser::output 00083 // Access: Public 00084 // Description: 00085 //////////////////////////////////////////////////////////////////// 00086 void CPPTypeParser:: 00087 output(ostream &out) const { 00088 if (_type == NULL) { 00089 out << "(null type)"; 00090 } else { 00091 out << *_type; 00092 } 00093 }