interrogateFunctionWrapper.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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.h
  10. * @author drose
  11. * @date 2000-08-06
  12. */
  13. #ifndef INTERROGATEFUNCTIONWRAPPER_H
  14. #define INTERROGATEFUNCTIONWRAPPER_H
  15. #include "dtoolbase.h"
  16. #include "interrogateComponent.h"
  17. #include <vector>
  18. class IndexRemapper;
  19. /**
  20. * An internal representation of a callable function.
  21. */
  22. class EXPCL_INTERROGATEDB InterrogateFunctionWrapper : public InterrogateComponent {
  23. public:
  24. INLINE InterrogateFunctionWrapper(InterrogateModuleDef *def = NULL);
  25. INLINE InterrogateFunctionWrapper(const InterrogateFunctionWrapper &copy);
  26. INLINE void operator = (const InterrogateFunctionWrapper &copy);
  27. INLINE FunctionIndex get_function() const;
  28. INLINE bool is_callable_by_name() const;
  29. INLINE bool has_return_value() const;
  30. INLINE TypeIndex get_return_type() const;
  31. INLINE bool caller_manages_return_value() const;
  32. INLINE FunctionIndex get_return_value_destructor() const;
  33. INLINE int number_of_parameters() const;
  34. INLINE TypeIndex parameter_get_type(int n) const;
  35. INLINE bool parameter_has_name(int n) const;
  36. INLINE const string &parameter_get_name(int n) const;
  37. INLINE bool parameter_is_this(int n) const;
  38. INLINE const string &get_unique_name() const;
  39. INLINE bool has_comment() const;
  40. INLINE const string &get_comment() const;
  41. void output(ostream &out) const;
  42. void input(istream &in);
  43. void remap_indices(const IndexRemapper &remap);
  44. private:
  45. enum Flags {
  46. F_caller_manages = 0x0001,
  47. F_has_return = 0x0002,
  48. F_callable_by_name = 0x0004
  49. };
  50. enum ParameterFlags {
  51. PF_has_name = 0x0001,
  52. PF_is_this = 0x0002,
  53. };
  54. int _flags;
  55. FunctionIndex _function;
  56. TypeIndex _return_type;
  57. FunctionIndex _return_value_destructor;
  58. string _unique_name;
  59. string _comment;
  60. public:
  61. // This nested class must be declared public just so we can declare the
  62. // external ostream and istream IO operator functions, on the SGI compiler.
  63. // Arguably a compiler bug, but what can you do.
  64. class Parameter {
  65. public:
  66. void output(ostream &out) const;
  67. void input(istream &in);
  68. int _parameter_flags;
  69. TypeIndex _type;
  70. string _name;
  71. };
  72. private:
  73. typedef vector<Parameter> Parameters;
  74. Parameters _parameters;
  75. friend class InterrogateBuilder;
  76. friend class FunctionRemap;
  77. };
  78. INLINE ostream &operator << (ostream &out, const InterrogateFunctionWrapper &wrapper);
  79. INLINE istream &operator >> (istream &in, InterrogateFunctionWrapper &wrapper);
  80. INLINE ostream &operator << (ostream &out, const InterrogateFunctionWrapper::Parameter &p);
  81. INLINE istream &operator >> (istream &in, InterrogateFunctionWrapper::Parameter &p);
  82. #include "interrogateFunctionWrapper.I"
  83. #endif