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 */
17INLINE InterrogateFunctionWrapper::
18InterrogateFunctionWrapper(InterrogateModuleDef *def) :
20{
21 _flags = 0;
22 _function = 0;
23 _return_type = 0;
24 _return_value_destructor = 0;
25}
26
27/**
28 *
29 */
30INLINE InterrogateFunctionWrapper::
31InterrogateFunctionWrapper(const InterrogateFunctionWrapper &copy) {
32 (*this) = copy;
33}
34
35/**
36 *
37 */
38INLINE void InterrogateFunctionWrapper::
39operator = (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 */
53INLINE FunctionIndex InterrogateFunctionWrapper::
54get_function() const {
55 return _function;
56}
57
58/**
59 *
60 */
61INLINE bool InterrogateFunctionWrapper::
62is_callable_by_name() const {
63 return (_flags & F_callable_by_name) != 0;
64}
65
66/**
67 *
68 */
69INLINE bool InterrogateFunctionWrapper::
70has_return_value() const {
71 return (_flags & F_has_return) != 0;
72}
73
74/**
75 *
76 */
77INLINE TypeIndex InterrogateFunctionWrapper::
78get_return_type() const {
79 return _return_type;
80}
81
82/**
83 *
84 */
85INLINE bool InterrogateFunctionWrapper::
86caller_manages_return_value() const {
87 return (_flags & F_caller_manages) != 0;
88}
89
90/**
91 *
92 */
93INLINE FunctionIndex InterrogateFunctionWrapper::
94get_return_value_destructor() const {
95 return _return_value_destructor;
96}
97
98/**
99 *
100 */
101INLINE int InterrogateFunctionWrapper::
102number_of_parameters() const {
103 return _parameters.size();
104}
105
106/**
107 *
108 */
109INLINE TypeIndex InterrogateFunctionWrapper::
110parameter_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 */
120INLINE bool InterrogateFunctionWrapper::
121parameter_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 */
131INLINE const std::string &InterrogateFunctionWrapper::
132parameter_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 */
143INLINE bool InterrogateFunctionWrapper::
144parameter_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 */
154INLINE bool InterrogateFunctionWrapper::
155parameter_is_optional(int n) const {
156 if (n >= 0 && n < (int)_parameters.size()) {
157 return (_parameters[n]._parameter_flags & PF_is_optional) != 0;
158 }
159 return false;
160}
161
162/**
163 *
164 */
165INLINE const std::string &InterrogateFunctionWrapper::
166get_unique_name() const {
167 return _unique_name;
168}
169
170/**
171 *
172 */
173INLINE bool InterrogateFunctionWrapper::
174has_comment() const {
175 return !_comment.empty();
176}
177
178/**
179 *
180 */
181INLINE const std::string &InterrogateFunctionWrapper::
182get_comment() const {
183 return _comment;
184}
185
186INLINE std::ostream &
187operator << (std::ostream &out, const InterrogateFunctionWrapper &wrapper) {
188 wrapper.output(out);
189 return out;
190}
191
192INLINE std::istream &
193operator >> (std::istream &in, InterrogateFunctionWrapper &wrapper) {
194 wrapper.input(in);
195 return in;
196}
197
198INLINE std::ostream &
199operator << (std::ostream &out, const InterrogateFunctionWrapper::Parameter &p) {
200 p.output(out);
201 return out;
202}
203
204INLINE std::istream &
205operator >> (std::istream &in, InterrogateFunctionWrapper::Parameter &p) {
206 p.input(in);
207 return in;
208}
The base class for things that are part of the interrogate database.
An internal representation of a callable function.
FunctionIndex get_function() const
Returns the FunctionIndex of the function that this wrapper corresponds to.
void output(std::ostream &out) const
Formats the InterrogateFunctionWrapper data for output to a data file.
void input(std::istream &in)
Reads the data file as previously formatted by output().