Panda3D
interrogateFunctionWrapper.I
1 // Filename: interrogateFunctionWrapper.I
2 // Created by: drose (06Aug00)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 
16 ////////////////////////////////////////////////////////////////////
17 // Function: InterrogateFunctionWrapper::Constructor
18 // Access: Public
19 // Description:
20 ////////////////////////////////////////////////////////////////////
21 INLINE InterrogateFunctionWrapper::
22 InterrogateFunctionWrapper(InterrogateModuleDef *def) :
24 {
25  _flags = 0;
26  _function = 0;
27  _return_type = 0;
28  _return_value_destructor = 0;
29 }
30 
31 ////////////////////////////////////////////////////////////////////
32 // Function: InterrogateFunctionWrapper::Copy Constructor
33 // Access: Public
34 // Description:
35 ////////////////////////////////////////////////////////////////////
36 INLINE InterrogateFunctionWrapper::
37 InterrogateFunctionWrapper(const InterrogateFunctionWrapper &copy) {
38  (*this) = copy;
39 }
40 
41 ////////////////////////////////////////////////////////////////////
42 // Function: InterrogateFunctionWrapper::Copy Assignment Operator
43 // Access: Public
44 // Description:
45 ////////////////////////////////////////////////////////////////////
46 INLINE void InterrogateFunctionWrapper::
47 operator = (const InterrogateFunctionWrapper &copy) {
48  InterrogateComponent::operator = (copy);
49  _flags = copy._flags;
50  _function = copy._function;
51  _return_type = copy._return_type;
52  _return_value_destructor = copy._return_value_destructor;
53  _unique_name = copy._unique_name;
54  _comment = copy._comment;
55  _parameters = copy._parameters;
56 }
57 
58 ////////////////////////////////////////////////////////////////////
59 // Function: InterrogateFunctionWrapper::get_function
60 // Access: Public
61 // Description: Returns the FunctionIndex of the function that this
62 // wrapper corresponds to.
63 ////////////////////////////////////////////////////////////////////
64 INLINE FunctionIndex InterrogateFunctionWrapper::
65 get_function() const {
66  return _function;
67 }
68 
69 ////////////////////////////////////////////////////////////////////
70 // Function: InterrogateFunctionWrapper::is_callable_by_name
71 // Access: Public
72 // Description:
73 ////////////////////////////////////////////////////////////////////
74 INLINE bool InterrogateFunctionWrapper::
75 is_callable_by_name() const {
76  return (_flags & F_callable_by_name) != 0;
77 }
78 
79 ////////////////////////////////////////////////////////////////////
80 // Function: InterrogateFunctionWrapper::has_return_value
81 // Access: Public
82 // Description:
83 ////////////////////////////////////////////////////////////////////
84 INLINE bool InterrogateFunctionWrapper::
85 has_return_value() const {
86  return (_flags & F_has_return) != 0;
87 }
88 
89 ////////////////////////////////////////////////////////////////////
90 // Function: InterrogateFunctionWrapper::get_return_type
91 // Access: Public
92 // Description:
93 ////////////////////////////////////////////////////////////////////
94 INLINE TypeIndex InterrogateFunctionWrapper::
95 get_return_type() const {
96  return _return_type;
97 }
98 
99 ////////////////////////////////////////////////////////////////////
100 // Function: InterrogateFunctionWrapper::caller_manages_return_value
101 // Access: Public
102 // Description:
103 ////////////////////////////////////////////////////////////////////
104 INLINE bool InterrogateFunctionWrapper::
105 caller_manages_return_value() const {
106  return (_flags & F_caller_manages) != 0;
107 }
108 
109 ////////////////////////////////////////////////////////////////////
110 // Function: InterrogateFunctionWrapper::get_return_value_destructor
111 // Access: Public
112 // Description:
113 ////////////////////////////////////////////////////////////////////
114 INLINE FunctionIndex InterrogateFunctionWrapper::
115 get_return_value_destructor() const {
116  return _return_value_destructor;
117 }
118 
119 ////////////////////////////////////////////////////////////////////
120 // Function: InterrogateFunctionWrapper::number_of_parameters
121 // Access: Public
122 // Description:
123 ////////////////////////////////////////////////////////////////////
124 INLINE int InterrogateFunctionWrapper::
125 number_of_parameters() const {
126  return _parameters.size();
127 }
128 
129 ////////////////////////////////////////////////////////////////////
130 // Function: InterrogateFunctionWrapper::parameter_get_type
131 // Access: Public
132 // Description:
133 ////////////////////////////////////////////////////////////////////
134 INLINE TypeIndex InterrogateFunctionWrapper::
135 parameter_get_type(int n) const {
136  if (n >= 0 && n < (int)_parameters.size()) {
137  return _parameters[n]._type;
138  }
139  return 0;
140 }
141 
142 ////////////////////////////////////////////////////////////////////
143 // Function: InterrogateFunctionWrapper::parameter_has_name
144 // Access: Public
145 // Description:
146 ////////////////////////////////////////////////////////////////////
147 INLINE bool InterrogateFunctionWrapper::
148 parameter_has_name(int n) const {
149  if (n >= 0 && n < (int)_parameters.size()) {
150  return (_parameters[n]._parameter_flags & PF_has_name) != 0;
151  }
152  return false;
153 }
154 
155 ////////////////////////////////////////////////////////////////////
156 // Function: InterrogateFunctionWrapper::parameter_get_name
157 // Access: Public
158 // Description:
159 ////////////////////////////////////////////////////////////////////
160 INLINE const string &InterrogateFunctionWrapper::
161 parameter_get_name(int n) const {
162  static string bogus_string;
163  if (n >= 0 && n < (int)_parameters.size()) {
164  return _parameters[n]._name;
165  }
166  return bogus_string;
167 }
168 
169 ////////////////////////////////////////////////////////////////////
170 // Function: InterrogateFunctionWrapper::parameter_is_this
171 // Access: Public
172 // Description:
173 ////////////////////////////////////////////////////////////////////
174 INLINE bool InterrogateFunctionWrapper::
175 parameter_is_this(int n) const {
176  if (n >= 0 && n < (int)_parameters.size()) {
177  return (_parameters[n]._parameter_flags & PF_is_this) != 0;
178  }
179  return false;
180 }
181 
182 ////////////////////////////////////////////////////////////////////
183 // Function: InterrogateFunctionWrapper::get_unique_name
184 // Access: Public
185 // Description:
186 ////////////////////////////////////////////////////////////////////
187 INLINE const string &InterrogateFunctionWrapper::
188 get_unique_name() const {
189  return _unique_name;
190 }
191 
192 ////////////////////////////////////////////////////////////////////
193 // Function: InterrogateFunctionWrapper::has_comment
194 // Access: Public
195 // Description:
196 ////////////////////////////////////////////////////////////////////
197 INLINE bool InterrogateFunctionWrapper::
198 has_comment() const {
199  return !_comment.empty();
200 }
201 
202 ////////////////////////////////////////////////////////////////////
203 // Function: InterrogateFunctionWrapper::get_comment
204 // Access: Public
205 // Description:
206 ////////////////////////////////////////////////////////////////////
207 INLINE const string &InterrogateFunctionWrapper::
208 get_comment() const {
209  return _comment;
210 }
211 
212 INLINE ostream &
213 operator << (ostream &out, const InterrogateFunctionWrapper &wrapper) {
214  wrapper.output(out);
215  return out;
216 }
217 
218 INLINE istream &
219 operator >> (istream &in, InterrogateFunctionWrapper &wrapper) {
220  wrapper.input(in);
221  return in;
222 }
223 
224 INLINE ostream &
225 operator << (ostream &out, const InterrogateFunctionWrapper::Parameter &p) {
226  p.output(out);
227  return out;
228 }
229 
230 INLINE istream &
231 operator >> (istream &in, InterrogateFunctionWrapper::Parameter &p) {
232  p.input(in);
233  return in;
234 }
235 
FunctionIndex get_function() const
Returns the FunctionIndex of the function that this wrapper corresponds to.
An internal representation of a callable function.
void output(ostream &out) const
Formats the InterrogateFunctionWrapper data for output to a data file.
The base class for things that are part of the interrogate database.
void input(istream &in)
Reads the data file as previously formatted by output().