Panda3D
interrogateFunctionWrapper.I
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 interrogateFunctionWrapper.I
10  * @author drose
11  * @date 2000-08-06
12  */
13 
14 /**
15  *
16  */
17 INLINE InterrogateFunctionWrapper::
18 InterrogateFunctionWrapper(InterrogateModuleDef *def) :
20 {
21  _flags = 0;
22  _function = 0;
23  _return_type = 0;
24  _return_value_destructor = 0;
25 }
26 
27 /**
28  *
29  */
30 INLINE InterrogateFunctionWrapper::
31 InterrogateFunctionWrapper(const InterrogateFunctionWrapper &copy) {
32  (*this) = copy;
33 }
34 
35 /**
36  *
37  */
38 INLINE void InterrogateFunctionWrapper::
39 operator = (const InterrogateFunctionWrapper &copy) {
40  InterrogateComponent::operator = (copy);
41  _flags = copy._flags;
42  _function = copy._function;
43  _return_type = copy._return_type;
44  _return_value_destructor = copy._return_value_destructor;
45  _unique_name = copy._unique_name;
46  _comment = copy._comment;
47  _parameters = copy._parameters;
48 }
49 
50 /**
51  * Returns the FunctionIndex of the function that this wrapper corresponds to.
52  */
53 INLINE FunctionIndex InterrogateFunctionWrapper::
54 get_function() const {
55  return _function;
56 }
57 
58 /**
59  *
60  */
61 INLINE bool InterrogateFunctionWrapper::
62 is_callable_by_name() const {
63  return (_flags & F_callable_by_name) != 0;
64 }
65 
66 /**
67  *
68  */
69 INLINE bool InterrogateFunctionWrapper::
70 has_return_value() const {
71  return (_flags & F_has_return) != 0;
72 }
73 
74 /**
75  *
76  */
77 INLINE TypeIndex InterrogateFunctionWrapper::
78 get_return_type() const {
79  return _return_type;
80 }
81 
82 /**
83  *
84  */
85 INLINE bool InterrogateFunctionWrapper::
86 caller_manages_return_value() const {
87  return (_flags & F_caller_manages) != 0;
88 }
89 
90 /**
91  *
92  */
93 INLINE FunctionIndex InterrogateFunctionWrapper::
94 get_return_value_destructor() const {
95  return _return_value_destructor;
96 }
97 
98 /**
99  *
100  */
101 INLINE int InterrogateFunctionWrapper::
102 number_of_parameters() const {
103  return _parameters.size();
104 }
105 
106 /**
107  *
108  */
109 INLINE TypeIndex InterrogateFunctionWrapper::
110 parameter_get_type(int n) const {
111  if (n >= 0 && n < (int)_parameters.size()) {
112  return _parameters[n]._type;
113  }
114  return 0;
115 }
116 
117 /**
118  *
119  */
120 INLINE bool InterrogateFunctionWrapper::
121 parameter_has_name(int n) const {
122  if (n >= 0 && n < (int)_parameters.size()) {
123  return (_parameters[n]._parameter_flags & PF_has_name) != 0;
124  }
125  return false;
126 }
127 
128 /**
129  *
130  */
131 INLINE const std::string &InterrogateFunctionWrapper::
132 parameter_get_name(int n) const {
133  static std::string bogus_string;
134  if (n >= 0 && n < (int)_parameters.size()) {
135  return _parameters[n]._name;
136  }
137  return bogus_string;
138 }
139 
140 /**
141  *
142  */
143 INLINE bool InterrogateFunctionWrapper::
144 parameter_is_this(int n) const {
145  if (n >= 0 && n < (int)_parameters.size()) {
146  return (_parameters[n]._parameter_flags & PF_is_this) != 0;
147  }
148  return false;
149 }
150 
151 /**
152  *
153  */
154 INLINE const std::string &InterrogateFunctionWrapper::
155 get_unique_name() const {
156  return _unique_name;
157 }
158 
159 /**
160  *
161  */
162 INLINE bool InterrogateFunctionWrapper::
163 has_comment() const {
164  return !_comment.empty();
165 }
166 
167 /**
168  *
169  */
170 INLINE const std::string &InterrogateFunctionWrapper::
171 get_comment() const {
172  return _comment;
173 }
174 
175 INLINE std::ostream &
176 operator << (std::ostream &out, const InterrogateFunctionWrapper &wrapper) {
177  wrapper.output(out);
178  return out;
179 }
180 
181 INLINE std::istream &
182 operator >> (std::istream &in, InterrogateFunctionWrapper &wrapper) {
183  wrapper.input(in);
184  return in;
185 }
186 
187 INLINE std::ostream &
188 operator << (std::ostream &out, const InterrogateFunctionWrapper::Parameter &p) {
189  p.output(out);
190  return out;
191 }
192 
193 INLINE std::istream &
194 operator >> (std::istream &in, InterrogateFunctionWrapper::Parameter &p) {
195  p.input(in);
196  return in;
197 }
FunctionIndex get_function() const
Returns the FunctionIndex of the function that this wrapper corresponds to.
An internal representation of a callable function.
void output(std::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(std::istream &in)
Reads the data file as previously formatted by output().