interrogateFunctionWrapper.I 6.6 KB

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