interrogateFunctionWrapper.I 7.0 KB

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