Panda3D
Loading...
Searching...
No Matches
interrogateType.h
Go to the documentation of this file.
1/**
2 * PANDA 3D SOFTWARE
3 * Copyright (c) Carnegie Mellon University. All rights reserved.
4 *
5 * All use of this software is subject to the terms of the revised BSD
6 * license. You should have received a copy of this license along
7 * with this source code in a file named "LICENSE."
8 *
9 * @file interrogateType.h
10 * @author drose
11 * @date 2000-07-31
12 */
13
14#ifndef INTERROGATETYPE_H
15#define INTERROGATETYPE_H
16
17#include "dtoolbase.h"
18
20
21#include <vector>
22
23class IndexRemapper;
24class CPPType;
25class CPPScope;
26
27/**
28 * An internal representation of a type.
29 */
30class EXPCL_INTERROGATEDB InterrogateType : public InterrogateComponent {
31public:
34 void operator = (const InterrogateType &copy);
35
36 INLINE bool is_global() const;
37
38 INLINE bool has_scoped_name() const;
39 INLINE const std::string &get_scoped_name() const;
40
41 INLINE bool has_true_name() const;
42 INLINE const std::string &get_true_name() const;
43
44 INLINE bool has_comment() const;
45 INLINE const std::string &get_comment() const;
46
47 INLINE bool is_nested() const;
48 INLINE TypeIndex get_outer_class() const;
49
50 INLINE bool is_atomic() const;
51 INLINE AtomicToken get_atomic_token() const;
52 INLINE bool is_unsigned() const;
53 INLINE bool is_signed() const;
54 INLINE bool is_long() const;
55 INLINE bool is_longlong() const;
56 INLINE bool is_short() const;
57
58 INLINE bool is_wrapped() const;
59 INLINE bool is_pointer() const;
60 INLINE bool is_const() const;
61 INLINE bool is_typedef() const;
62 INLINE TypeIndex get_wrapped_type() const;
63
64 INLINE bool is_array() const;
65 INLINE int get_array_size() const;
66
67 INLINE bool is_enum() const;
68 INLINE bool is_scoped_enum() const;
69 INLINE int number_of_enum_values() const;
70 INLINE const std::string &get_enum_value_name(int n) const;
71 INLINE const std::string &get_enum_value_scoped_name(int n) const;
72 INLINE const std::string &get_enum_value_comment(int n) const;
73 INLINE int get_enum_value(int n) const;
74
75 INLINE bool is_struct() const;
76 INLINE bool is_class() const;
77 INLINE bool is_union() const;
78 INLINE bool is_final() const;
79
80 INLINE bool is_fully_defined() const;
81 INLINE bool is_unpublished() const;
82 INLINE int number_of_constructors() const;
83 INLINE FunctionIndex get_constructor(int n) const;
84 INLINE bool has_destructor() const;
85 INLINE bool destructor_is_inherited() const;
86 INLINE bool destructor_is_implicit() const;
87 INLINE FunctionIndex get_destructor() const;
88 INLINE int number_of_elements() const;
89 INLINE ElementIndex get_element(int n) const;
90 INLINE int number_of_methods() const;
91 INLINE FunctionIndex get_method(int n) const;
92 INLINE int number_of_make_seqs() const;
93 INLINE MakeSeqIndex get_make_seq(int n) const;
94
95 INLINE int number_of_casts() const;
96 INLINE FunctionIndex get_cast(int n) const;
97
98 INLINE int number_of_derivations() const;
99 INLINE TypeIndex get_derivation(int n) const;
100
101 INLINE bool derivation_has_upcast(int n) const;
102 INLINE FunctionIndex derivation_get_upcast(int n) const;
103
104 INLINE bool derivation_downcast_is_impossible(int n) const;
105 INLINE bool derivation_has_downcast(int n) const;
106 INLINE FunctionIndex derivation_get_downcast(int n) const;
107
108 INLINE int number_of_nested_types() const;
109 INLINE TypeIndex get_nested_type(int n) const;
110
111 void merge_with(const InterrogateType &other);
112 void output(std::ostream &out) const;
113 void input(std::istream &in);
114
115 void remap_indices(const IndexRemapper &remap);
116
117private:
118 enum Flags {
119 F_global = 0x000001,
120 F_atomic = 0x000002,
121 F_unsigned = 0x000004,
122 F_signed = 0x000008,
123 F_long = 0x000010,
124 F_longlong = 0x000020,
125 F_short = 0x000040,
126 F_wrapped = 0x000080,
127 F_pointer = 0x000100,
128 F_const = 0x000200,
129 F_struct = 0x000400,
130 F_class = 0x000800,
131 F_union = 0x001000,
132 F_fully_defined = 0x002000,
133 F_true_destructor = 0x004000,
134 F_private_destructor = 0x008000,
135 F_inherited_destructor = 0x010000,
136 F_implicit_destructor = 0x020000,
137 F_nested = 0x040000,
138 F_enum = 0x080000,
139 F_unpublished = 0x100000,
140 F_typedef = 0x200000,
141 F_array = 0x400000,
142 F_scoped_enum = 0x800000,
143 F_final =0x1000000,
144 };
145
146public:
147 int _flags;
148
149 std::string _scoped_name;
150 std::string _true_name;
151 std::string _comment;
152 TypeIndex _outer_class;
153 AtomicToken _atomic_token;
154 TypeIndex _wrapped_type;
155 int _array_size;
156
157 typedef std::vector<FunctionIndex> Functions;
158 Functions _constructors;
159 FunctionIndex _destructor;
160
161 typedef std::vector<ElementIndex> Elements;
162 Elements _elements;
163 Functions _methods;
164 Functions _casts;
165
166 typedef std::vector<MakeSeqIndex> MakeSeqs;
167 MakeSeqs _make_seqs;
168
169 enum DerivationFlags {
170 DF_upcast = 0x01,
171 DF_downcast = 0x02,
172 DF_downcast_impossible = 0x04
173 };
174
175public:
176 // This nested class must be declared public just so we can declare the
177 // external ostream and istream IO operator functions, on the SGI compiler.
178 // Arguably a compiler bug, but what can you do.
180 public:
181 void output(std::ostream &out) const;
182 void input(std::istream &in);
183
184 int _flags;
185 TypeIndex _base;
186 FunctionIndex _upcast;
187 FunctionIndex _downcast;
188 };
189
190private:
191 typedef std::vector<Derivation> Derivations;
192 Derivations _derivations;
193
194public:
195 // This nested class must also be public, for the same reason.
196 class EnumValue {
197 public:
198 void output(std::ostream &out) const;
199 void input(std::istream &in);
200
201 std::string _name;
202 std::string _scoped_name;
203 std::string _comment;
204 int _value;
205 };
206
207private:
208 typedef std::vector<EnumValue> EnumValues;
209 EnumValues _enum_values;
210
211 typedef std::vector<TypeIndex> Types;
212 Types _nested_types;
213
214public:
215 // The rest of the members in this class aren't part of the public interface
216 // to interrogate, but are used internally as the interrogate database is
217 // built. They are valid only during the session of interrogate that
218 // generates the database, and will not be filled in when the database is
219 // reloaded from disk.
220 CPPType *_cpptype;
221 CPPScope *_cppscope;
222
223 friend class InterrogateBuilder;
224};
225
226INLINE std::ostream &operator << (std::ostream &out, const InterrogateType &type);
227INLINE std::istream &operator >> (std::istream &in, InterrogateType &type);
228
229INLINE std::ostream &operator << (std::ostream &out, const InterrogateType::Derivation &d);
230INLINE std::istream &operator >> (std::istream &in, InterrogateType::Derivation &d);
231
232INLINE std::ostream &operator << (std::ostream &out, const InterrogateType::EnumValue &d);
233INLINE std::istream &operator >> (std::istream &in, InterrogateType::EnumValue &d);
234
235#include "interrogateType.I"
236
237#endif
This class manages a mapping of integers to integers.
The base class for things that are part of the interrogate database.
void input(std::istream &in)
Reads the data file as previously formatted by output().
void output(std::ostream &out) const
Formats the component for output to a data file.
An internal representation of a type.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.