00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include "interrogateType.h"
00020 #include "indexRemapper.h"
00021 #include "interrogate_datafile.h"
00022
00023 #include <algorithm>
00024
00025
00026
00027 string InterrogateType::_empty_string;
00028
00029
00030
00031
00032
00033
00034 void InterrogateType::Derivation::
00035 output(ostream &out) const {
00036 out << _flags << " " << _base << " " << _upcast << " " << _downcast;
00037 }
00038
00039
00040
00041
00042
00043
00044 void InterrogateType::Derivation::
00045 input(istream &in) {
00046 in >> _flags >> _base >> _upcast >> _downcast;
00047 }
00048
00049
00050
00051
00052
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
00063
00064
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
00075
00076
00077
00078 void InterrogateType::
00079 operator = (const InterrogateType ©) {
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
00103
00104
00105
00106
00107
00108 void InterrogateType::
00109 merge_with(const InterrogateType &other) {
00110
00111
00112
00113 if (is_fully_defined()) {
00114
00115 _flags |= (other._flags & F_global);
00116
00117 } else {
00118
00119 int old_flags = (_flags & F_global);
00120 (*this) = other;
00121 _flags |= old_flags;
00122 }
00123 }
00124
00125
00126
00127
00128
00129
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
00154
00155
00156
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
00186
00187
00188
00189
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 }