interrogateFunctionWrapper.I 4.3 KB

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