00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef INTERROGATETYPE_H
00016 #define INTERROGATETYPE_H
00017
00018 #include "dtoolbase.h"
00019
00020 #include "interrogateComponent.h"
00021
00022 #include <vector>
00023
00024 class IndexRemapper;
00025 class CPPType;
00026 class CPPScope;
00027
00028
00029
00030
00031
00032 class EXPCL_DTOOLCONFIG InterrogateType : public InterrogateComponent {
00033 public:
00034 InterrogateType(InterrogateModuleDef *def = NULL);
00035 InterrogateType(const InterrogateType ©);
00036 void operator = (const InterrogateType ©);
00037
00038 INLINE bool is_global() const;
00039
00040 INLINE bool has_scoped_name() const;
00041 INLINE const string &get_scoped_name() const;
00042
00043 INLINE bool has_true_name() const;
00044 INLINE const string &get_true_name() const;
00045
00046 INLINE bool has_comment() const;
00047 INLINE const string &get_comment() const;
00048
00049 INLINE bool is_nested() const;
00050 INLINE TypeIndex get_outer_class() const;
00051
00052 INLINE bool is_atomic() const;
00053 INLINE AtomicToken get_atomic_token() const;
00054 INLINE bool is_unsigned() const;
00055 INLINE bool is_signed() const;
00056 INLINE bool is_long() const;
00057 INLINE bool is_longlong() const;
00058 INLINE bool is_short() const;
00059
00060 INLINE bool is_wrapped() const;
00061 INLINE bool is_pointer() const;
00062 INLINE bool is_const() const;
00063 INLINE TypeIndex get_wrapped_type() const;
00064
00065 INLINE bool is_enum() const;
00066 INLINE int number_of_enum_values() const;
00067 INLINE const string &get_enum_value_name(int n) const;
00068 INLINE const string &get_enum_value_scoped_name(int n) const;
00069 INLINE int get_enum_value(int n) const;
00070
00071 INLINE bool is_struct() const;
00072 INLINE bool is_class() const;
00073 INLINE bool is_union() const;
00074
00075 INLINE bool is_fully_defined() const;
00076 INLINE bool is_unpublished() const;
00077 INLINE int number_of_constructors() const;
00078 INLINE FunctionIndex get_constructor(int n) const;
00079 INLINE bool has_destructor() const;
00080 INLINE bool destructor_is_inherited() const;
00081 INLINE FunctionIndex get_destructor() const;
00082 INLINE int number_of_elements() const;
00083 INLINE ElementIndex get_element(int n) const;
00084 INLINE int number_of_methods() const;
00085 INLINE FunctionIndex get_method(int n) const;
00086 INLINE int number_of_make_seqs() const;
00087 INLINE MakeSeqIndex get_make_seq(int n) const;
00088
00089 INLINE int number_of_casts() const;
00090 INLINE FunctionIndex get_cast(int n) const;
00091
00092 INLINE int number_of_derivations() const;
00093 INLINE TypeIndex get_derivation(int n) const;
00094
00095 INLINE bool derivation_has_upcast(int n) const;
00096 INLINE FunctionIndex derivation_get_upcast(int n) const;
00097
00098 INLINE bool derivation_downcast_is_impossible(int n) const;
00099 INLINE bool derivation_has_downcast(int n) const;
00100 INLINE FunctionIndex derivation_get_downcast(int n) const;
00101
00102 INLINE int number_of_nested_types() const;
00103 INLINE TypeIndex get_nested_type(int n) const;
00104
00105 void merge_with(const InterrogateType &other);
00106 void output(ostream &out) const;
00107 void input(istream &in);
00108
00109 void remap_indices(const IndexRemapper &remap);
00110
00111 private:
00112 enum Flags {
00113 F_global = 0x000001,
00114 F_atomic = 0x000002,
00115 F_unsigned = 0x000004,
00116 F_signed = 0x000008,
00117 F_long = 0x000010,
00118 F_longlong = 0x000020,
00119 F_short = 0x000040,
00120 F_wrapped = 0x000080,
00121 F_pointer = 0x000100,
00122 F_const = 0x000200,
00123 F_struct = 0x000400,
00124 F_class = 0x000800,
00125 F_union = 0x001000,
00126 F_fully_defined = 0x002000,
00127 F_true_destructor = 0x004000,
00128 F_private_destructor = 0x008000,
00129 F_inherited_destructor = 0x010000,
00130 F_implicit_destructor = 0x020000,
00131 F_nested = 0x040000,
00132 F_enum = 0x080000,
00133 F_unpublished = 0x100000,
00134 };
00135
00136 public:
00137 int _flags;
00138
00139 string _scoped_name;
00140 string _true_name;
00141 string _comment;
00142 TypeIndex _outer_class;
00143 AtomicToken _atomic_token;
00144 TypeIndex _wrapped_type;
00145
00146 typedef vector<FunctionIndex> Functions;
00147 Functions _constructors;
00148 FunctionIndex _destructor;
00149
00150 typedef vector<ElementIndex> Elements;
00151 Elements _elements;
00152 Functions _methods;
00153 Functions _casts;
00154
00155 typedef vector<MakeSeqIndex> MakeSeqs;
00156 MakeSeqs _make_seqs;
00157
00158 enum DerivationFlags {
00159 DF_upcast = 0x01,
00160 DF_downcast = 0x02,
00161 DF_downcast_impossible = 0x04
00162 };
00163
00164 public:
00165
00166
00167
00168 class Derivation {
00169 public:
00170 void output(ostream &out) const;
00171 void input(istream &in);
00172
00173 int _flags;
00174 TypeIndex _base;
00175 FunctionIndex _upcast;
00176 FunctionIndex _downcast;
00177 };
00178
00179 private:
00180 typedef vector<Derivation> Derivations;
00181 Derivations _derivations;
00182
00183 public:
00184
00185 class EnumValue {
00186 public:
00187 void output(ostream &out) const;
00188 void input(istream &in);
00189
00190 string _name;
00191 string _scoped_name;
00192 int _value;
00193 };
00194
00195 private:
00196 typedef vector<EnumValue> EnumValues;
00197 EnumValues _enum_values;
00198
00199 typedef vector<TypeIndex> Types;
00200 Types _nested_types;
00201
00202 public:
00203
00204
00205
00206
00207
00208 CPPType *_cpptype;
00209 CPPScope *_cppscope;
00210
00211 friend class InterrogateBuilder;
00212 };
00213
00214 INLINE ostream &operator << (ostream &out, const InterrogateType &type);
00215 INLINE istream &operator >> (istream &in, InterrogateType &type);
00216
00217 INLINE ostream &operator << (ostream &out, const InterrogateType::Derivation &d);
00218 INLINE istream &operator >> (istream &in, InterrogateType::Derivation &d);
00219
00220 INLINE ostream &operator << (ostream &out, const InterrogateType::EnumValue &d);
00221 INLINE istream &operator >> (istream &in, InterrogateType::EnumValue &d);
00222
00223 #include "interrogateType.I"
00224
00225 #include <set>
00226 #include <map>
00227 struct Dtool_PyTypedObject;
00228 typedef std::map< int , Dtool_PyTypedObject *> RunTimeTypeDictionary;
00229 typedef std::set<int > RunTimeTypeList;
00230
00231 EXPCL_DTOOLCONFIG RunTimeTypeDictionary & GetRunTimeDictionary();
00232 EXPCL_DTOOLCONFIG RunTimeTypeList & GetRunTimeTypeList();
00233
00234
00235 #endif