Panda3D

interrogateFunctionWrapper.I

00001 // Filename: interrogateFunctionWrapper.I
00002 // Created by:  drose (06Aug00)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 
00015 
00016 ////////////////////////////////////////////////////////////////////
00017 //     Function: InterrogateFunctionWrapper::Constructor
00018 //       Access: Public
00019 //  Description:
00020 ////////////////////////////////////////////////////////////////////
00021 INLINE InterrogateFunctionWrapper::
00022 InterrogateFunctionWrapper(InterrogateModuleDef *def) :
00023   InterrogateComponent(def)
00024 {
00025   _flags = 0;
00026   _function = 0;
00027   _return_type = 0;
00028   _return_value_destructor = 0;
00029 }
00030 
00031 ////////////////////////////////////////////////////////////////////
00032 //     Function: InterrogateFunctionWrapper::Copy Constructor
00033 //       Access: Public
00034 //  Description:
00035 ////////////////////////////////////////////////////////////////////
00036 INLINE InterrogateFunctionWrapper::
00037 InterrogateFunctionWrapper(const InterrogateFunctionWrapper &copy) {
00038   (*this) = copy;
00039 }
00040 
00041 ////////////////////////////////////////////////////////////////////
00042 //     Function: InterrogateFunctionWrapper::Copy Assignment Operator
00043 //       Access: Public
00044 //  Description:
00045 ////////////////////////////////////////////////////////////////////
00046 INLINE void InterrogateFunctionWrapper::
00047 operator = (const InterrogateFunctionWrapper &copy) {
00048   InterrogateComponent::operator = (copy);
00049   _flags = copy._flags;
00050   _function = copy._function;
00051   _return_type = copy._return_type;
00052   _return_value_destructor = copy._return_value_destructor;
00053   _unique_name = copy._unique_name;
00054   _comment = copy._comment;
00055   _parameters = copy._parameters;
00056 }
00057 
00058 ////////////////////////////////////////////////////////////////////
00059 //     Function: InterrogateFunctionWrapper::get_function
00060 //       Access: Public
00061 //  Description: Returns the FunctionIndex of the function that this
00062 //               wrapper corresponds to.
00063 ////////////////////////////////////////////////////////////////////
00064 INLINE FunctionIndex InterrogateFunctionWrapper::
00065 get_function() const {
00066   return _function;
00067 }
00068 
00069 ////////////////////////////////////////////////////////////////////
00070 //     Function: InterrogateFunctionWrapper::is_callable_by_name
00071 //       Access: Public
00072 //  Description:
00073 ////////////////////////////////////////////////////////////////////
00074 INLINE bool InterrogateFunctionWrapper::
00075 is_callable_by_name() const {
00076   return (_flags & F_callable_by_name) != 0;
00077 }
00078 
00079 ////////////////////////////////////////////////////////////////////
00080 //     Function: InterrogateFunctionWrapper::has_return_value
00081 //       Access: Public
00082 //  Description:
00083 ////////////////////////////////////////////////////////////////////
00084 INLINE bool InterrogateFunctionWrapper::
00085 has_return_value() const {
00086   return (_flags & F_has_return) != 0;
00087 }
00088 
00089 ////////////////////////////////////////////////////////////////////
00090 //     Function: InterrogateFunctionWrapper::get_return_type
00091 //       Access: Public
00092 //  Description:
00093 ////////////////////////////////////////////////////////////////////
00094 INLINE TypeIndex InterrogateFunctionWrapper::
00095 get_return_type() const {
00096   return _return_type;
00097 }
00098 
00099 ////////////////////////////////////////////////////////////////////
00100 //     Function: InterrogateFunctionWrapper::caller_manages_return_value
00101 //       Access: Public
00102 //  Description:
00103 ////////////////////////////////////////////////////////////////////
00104 INLINE bool InterrogateFunctionWrapper::
00105 caller_manages_return_value() const {
00106   return (_flags & F_caller_manages) != 0;
00107 }
00108 
00109 ////////////////////////////////////////////////////////////////////
00110 //     Function: InterrogateFunctionWrapper::get_return_value_destructor
00111 //       Access: Public
00112 //  Description:
00113 ////////////////////////////////////////////////////////////////////
00114 INLINE FunctionIndex InterrogateFunctionWrapper::
00115 get_return_value_destructor() const {
00116   return _return_value_destructor;
00117 }
00118 
00119 ////////////////////////////////////////////////////////////////////
00120 //     Function: InterrogateFunctionWrapper::number_of_parameters
00121 //       Access: Public
00122 //  Description:
00123 ////////////////////////////////////////////////////////////////////
00124 INLINE int InterrogateFunctionWrapper::
00125 number_of_parameters() const {
00126   return _parameters.size();
00127 }
00128 
00129 ////////////////////////////////////////////////////////////////////
00130 //     Function: InterrogateFunctionWrapper::parameter_get_type
00131 //       Access: Public
00132 //  Description:
00133 ////////////////////////////////////////////////////////////////////
00134 INLINE TypeIndex InterrogateFunctionWrapper::
00135 parameter_get_type(int n) const {
00136   if (n >= 0 && n < (int)_parameters.size()) {
00137     return _parameters[n]._type;
00138   }
00139   return 0;
00140 }
00141 
00142 ////////////////////////////////////////////////////////////////////
00143 //     Function: InterrogateFunctionWrapper::parameter_has_name
00144 //       Access: Public
00145 //  Description:
00146 ////////////////////////////////////////////////////////////////////
00147 INLINE bool InterrogateFunctionWrapper::
00148 parameter_has_name(int n) const {
00149   if (n >= 0 && n < (int)_parameters.size()) {
00150     return (_parameters[n]._parameter_flags & PF_has_name) != 0;
00151   }
00152   return false;
00153 }
00154 
00155 ////////////////////////////////////////////////////////////////////
00156 //     Function: InterrogateFunctionWrapper::parameter_get_name
00157 //       Access: Public
00158 //  Description:
00159 ////////////////////////////////////////////////////////////////////
00160 INLINE const string &InterrogateFunctionWrapper::
00161 parameter_get_name(int n) const {
00162   static string bogus_string;
00163   if (n >= 0 && n < (int)_parameters.size()) {
00164     return _parameters[n]._name;
00165   }
00166   return bogus_string;
00167 }
00168 
00169 ////////////////////////////////////////////////////////////////////
00170 //     Function: InterrogateFunctionWrapper::parameter_is_this
00171 //       Access: Public
00172 //  Description:
00173 ////////////////////////////////////////////////////////////////////
00174 INLINE bool InterrogateFunctionWrapper::
00175 parameter_is_this(int n) const {
00176   if (n >= 0 && n < (int)_parameters.size()) {
00177     return (_parameters[n]._parameter_flags & PF_is_this) != 0;
00178   }
00179   return false;
00180 }
00181 
00182 ////////////////////////////////////////////////////////////////////
00183 //     Function: InterrogateFunctionWrapper::get_unique_name
00184 //       Access: Public
00185 //  Description:
00186 ////////////////////////////////////////////////////////////////////
00187 INLINE const string &InterrogateFunctionWrapper::
00188 get_unique_name() const {
00189   return _unique_name;
00190 }
00191 
00192 ////////////////////////////////////////////////////////////////////
00193 //     Function: InterrogateFunctionWrapper::has_comment
00194 //       Access: Public
00195 //  Description:
00196 ////////////////////////////////////////////////////////////////////
00197 INLINE bool InterrogateFunctionWrapper::
00198 has_comment() const {
00199   return !_comment.empty();
00200 }
00201 
00202 ////////////////////////////////////////////////////////////////////
00203 //     Function: InterrogateFunctionWrapper::get_comment
00204 //       Access: Public
00205 //  Description:
00206 ////////////////////////////////////////////////////////////////////
00207 INLINE const string &InterrogateFunctionWrapper::
00208 get_comment() const {
00209   return _comment;
00210 }
00211 
00212 INLINE ostream &
00213 operator << (ostream &out, const InterrogateFunctionWrapper &wrapper) {
00214   wrapper.output(out);
00215   return out;
00216 }
00217 
00218 INLINE istream &
00219 operator >> (istream &in, InterrogateFunctionWrapper &wrapper) {
00220   wrapper.input(in);
00221   return in;
00222 }
00223 
00224 INLINE ostream &
00225 operator << (ostream &out, const InterrogateFunctionWrapper::Parameter &p) {
00226   p.output(out);
00227   return out;
00228 }
00229 
00230 INLINE istream &
00231 operator >> (istream &in, InterrogateFunctionWrapper::Parameter &p) {
00232   p.input(in);
00233   return in;
00234 }
00235 
 All Classes Functions Variables Enumerations