Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

dtool/src/interrogatedb/interrogateType.cxx

Go to the documentation of this file.
00001 // Filename: interrogateType.cxx
00002 // Created by:  drose (31Jul00)
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 #include "interrogateType.h"
00020 #include "indexRemapper.h"
00021 #include "interrogate_datafile.h"
00022 
00023 #include <algorithm>
00024 
00025 // This static string is just kept around as a handy bogus return
00026 // value for functions that must return a const string reference.
00027 string InterrogateType::_empty_string;
00028 
00029 ////////////////////////////////////////////////////////////////////
00030 //     Function: InterrogateType::Derivation::output
00031 //       Access: Public
00032 //  Description:
00033 ////////////////////////////////////////////////////////////////////
00034 void InterrogateType::Derivation::
00035 output(ostream &out) const {
00036   out << _flags << " " << _base << " " << _upcast << " " << _downcast;
00037 }
00038 
00039 ////////////////////////////////////////////////////////////////////
00040 //     Function: InterrogateType::Derivation::input
00041 //       Access: Public
00042 //  Description:
00043 ////////////////////////////////////////////////////////////////////
00044 void InterrogateType::Derivation::
00045 input(istream &in) {
00046   in >> _flags >> _base >> _upcast >> _downcast;
00047 }
00048 
00049 ////////////////////////////////////////////////////////////////////
00050 //     Function: InterrogateType::EnumValue::output
00051 //       Access: Public
00052 //  Description:
00053 ////////////////////////////////////////////////////////////////////
00054 void InterrogateType::EnumValue::
00055 output(ostream &out) const {
00056   idf_output_string(out, _name);
00057   idf_output_string(out, _scoped_name);
00058   out << _value;
00059 }
00060 
00061 ////////////////////////////////////////////////////////////////////
00062 //     Function: InterrogateType::EnumValue::input
00063 //       Access: Public
00064 //  Description:
00065 ////////////////////////////////////////////////////////////////////
00066 void InterrogateType::EnumValue::
00067 input(istream &in) {
00068   idf_input_string(in, _name);
00069   idf_input_string(in, _scoped_name);
00070   in >> _value;
00071 }
00072 
00073 ////////////////////////////////////////////////////////////////////
00074 //     Function: InterrogateType::Copy Assignment Operator
00075 //       Access: Public
00076 //  Description:
00077 ////////////////////////////////////////////////////////////////////
00078 void InterrogateType::
00079 operator = (const InterrogateType &copy) {
00080   InterrogateComponent::operator = (copy);
00081   _flags = copy._flags;
00082   _scoped_name = copy._scoped_name;
00083   _true_name = copy._true_name;
00084   _comment = copy._comment;
00085   _outer_class = copy._outer_class;
00086   _atomic_token = copy._atomic_token;
00087   _wrapped_type = copy._wrapped_type;
00088   _constructors = copy._constructors;
00089   _destructor = copy._destructor;
00090   _elements = copy._elements;
00091   _methods = copy._methods;
00092   _casts = copy._casts;
00093   _derivations = copy._derivations;
00094   _enum_values = copy._enum_values;
00095   _nested_types = copy._nested_types;
00096 
00097   _cpptype = copy._cpptype;
00098   _cppscope = copy._cppscope;
00099 }
00100 
00101 ////////////////////////////////////////////////////////////////////
00102 //     Function: InterrogateType::merge_with
00103 //       Access: Public
00104 //  Description: Combines type with the other similar definition.  If
00105 //               one type is "fully defined" and the other one isn't,
00106 //               the fully-defined type wins.
00107 ////////////////////////////////////////////////////////////////////
00108 void InterrogateType::
00109 merge_with(const InterrogateType &other) {
00110   // The only thing we care about copying from the non-fully-defined
00111   // type right now is the global flag.
00112 
00113   if (is_fully_defined()) {
00114     // We win.
00115     _flags |= (other._flags & F_global);
00116 
00117   } else {
00118     // They win.
00119     int old_flags = (_flags & F_global);
00120     (*this) = other;
00121     _flags |= old_flags;
00122   }
00123 }
00124 
00125 ////////////////////////////////////////////////////////////////////
00126 //     Function: InterrogateType::output
00127 //       Access: Public
00128 //  Description: Formats the InterrogateType data for output to a data
00129 //               file.
00130 ////////////////////////////////////////////////////////////////////
00131 void InterrogateType::
00132 output(ostream &out) const {
00133   InterrogateComponent::output(out);
00134 
00135   out << _flags << " ";
00136   idf_output_string(out, _scoped_name);
00137   idf_output_string(out, _true_name);
00138   out << _outer_class << " "
00139       << (int)_atomic_token << " "
00140       << _wrapped_type << " ";
00141   idf_output_vector(out, _constructors);
00142   out << _destructor << " ";
00143   idf_output_vector(out, _elements);
00144   idf_output_vector(out, _methods);
00145   idf_output_vector(out, _casts);
00146   idf_output_vector(out, _derivations);
00147   idf_output_vector(out, _enum_values);
00148   idf_output_vector(out, _nested_types);
00149   idf_output_string(out, _comment, '\n');
00150 }
00151 
00152 ////////////////////////////////////////////////////////////////////
00153 //     Function: InterrogateType::input
00154 //       Access: Public
00155 //  Description: Reads the data file as previously formatted by
00156 //               output().
00157 ////////////////////////////////////////////////////////////////////
00158 void InterrogateType::
00159 input(istream &in) {
00160   InterrogateComponent::input(in);
00161 
00162   in >> _flags;
00163   idf_input_string(in, _scoped_name);
00164   idf_input_string(in, _true_name);
00165 
00166   in >> _outer_class;
00167   int token;
00168   in >> token;
00169   _atomic_token = (AtomicToken)token;
00170   in >> _wrapped_type;
00171 
00172   idf_input_vector(in, _constructors);
00173   in >> _destructor;
00174 
00175   idf_input_vector(in, _elements);
00176   idf_input_vector(in, _methods);
00177   idf_input_vector(in, _casts);
00178   idf_input_vector(in, _derivations);
00179   idf_input_vector(in, _enum_values);
00180   idf_input_vector(in, _nested_types);
00181   idf_input_string(in, _comment);
00182 }
00183 
00184 ////////////////////////////////////////////////////////////////////
00185 //     Function: InterrogateType::remap_indices
00186 //       Access: Public
00187 //  Description: Remaps all internal index numbers according to the
00188 //               indicated map.  This called from
00189 //               InterrogateDatabase::remap_indices().
00190 ////////////////////////////////////////////////////////////////////
00191 void InterrogateType::
00192 remap_indices(const IndexRemapper &remap) {
00193   _outer_class = remap.map_from(_outer_class);
00194   _wrapped_type = remap.map_from(_wrapped_type);
00195 
00196   Functions::iterator fi;
00197   for (fi = _constructors.begin(); fi != _constructors.end(); ++fi) {
00198     (*fi) = remap.map_from(*fi);
00199   }
00200   _destructor = remap.map_from(_destructor);
00201 
00202   Elements::iterator ei;
00203   for (ei = _elements.begin(); ei != _elements.end(); ++ei) {
00204     (*ei) = remap.map_from(*ei);
00205   }
00206 
00207   for (fi = _methods.begin(); fi != _methods.end(); ++fi) {
00208     (*fi) = remap.map_from(*fi);
00209   }
00210   for (fi = _casts.begin(); fi != _casts.end(); ++fi) {
00211     (*fi) = remap.map_from(*fi);
00212   }
00213 
00214   Derivations::iterator di;
00215   for (di = _derivations.begin(); di != _derivations.end(); ++di) {
00216     (*di)._base = remap.map_from((*di)._base);
00217     (*di)._upcast = remap.map_from((*di)._upcast);
00218     (*di)._downcast = remap.map_from((*di)._downcast);
00219   }
00220 
00221   Types::iterator ti;
00222   for (ti = _nested_types.begin(); ti != _nested_types.end(); ++ti) {
00223     (*ti) = remap.map_from(*ti);
00224   }
00225 
00226 }

Generated on Thu May 1 22:13:07 2003 for DTool by doxygen1.3