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 const std::string &InterrogateFunctionWrapper::
155get_unique_name() const {
156 return _unique_name;
157}
158
159/**
160 *
161 */
162INLINE bool InterrogateFunctionWrapper::
163has_comment() const {
164 return !_comment.empty();
165}
166
167/**
168 *
169 */
170INLINE const std::string &InterrogateFunctionWrapper::
171get_comment() const {
172 return _comment;
173}
174
175INLINE std::ostream &
176operator << (std::ostream &out, const InterrogateFunctionWrapper &wrapper) {
177 wrapper.output(out);
178 return out;
179}
180
181INLINE std::istream &
182operator >> (std::istream &in, InterrogateFunctionWrapper &wrapper) {
183 wrapper.input(in);
184 return in;
185}
186
187INLINE std::ostream &
188operator << (std::ostream &out, const InterrogateFunctionWrapper::Parameter &p) {
189 p.output(out);
190 return out;
191}
192
193INLINE std::istream &
194operator >> (std::istream &in, InterrogateFunctionWrapper::Parameter &p) {
195 p.input(in);
196 return in;
197}
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().