interrogateFunctionWrapper.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. // Filename: interrogateFunctionWrapper.h
  2. // Created by: drose (06Aug00)
  3. //
  4. ////////////////////////////////////////////////////////////////////
  5. //
  6. // PANDA 3D SOFTWARE
  7. // Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved
  8. //
  9. // All use of this software is subject to the terms of the Panda 3d
  10. // Software license. You should have received a copy of this license
  11. // along with this source code; you will also find a current copy of
  12. // the license at http://etc.cmu.edu/panda3d/docs/license/ .
  13. //
  14. // To contact the maintainers of this program write to
  15. // [email protected] .
  16. //
  17. ////////////////////////////////////////////////////////////////////
  18. #ifndef INTERROGATEFUNCTIONWRAPPER_H
  19. #define INTERROGATEFUNCTIONWRAPPER_H
  20. #include "dtoolbase.h"
  21. #include "interrogateComponent.h"
  22. #include <vector>
  23. class IndexRemapper;
  24. ////////////////////////////////////////////////////////////////////
  25. // Class : InterrogateFunctionWrapper
  26. // Description : An internal representation of a callable function.
  27. ////////////////////////////////////////////////////////////////////
  28. class EXPCL_DTOOLCONFIG InterrogateFunctionWrapper : public InterrogateComponent {
  29. public:
  30. INLINE InterrogateFunctionWrapper(InterrogateModuleDef *def = NULL);
  31. INLINE InterrogateFunctionWrapper(const InterrogateFunctionWrapper &copy);
  32. INLINE void operator = (const InterrogateFunctionWrapper &copy);
  33. INLINE FunctionIndex get_function() const;
  34. INLINE bool is_callable_by_name() const;
  35. INLINE bool has_return_value() const;
  36. INLINE TypeIndex get_return_type() const;
  37. INLINE bool caller_manages_return_value() const;
  38. INLINE FunctionIndex get_return_value_destructor() const;
  39. INLINE int number_of_parameters() const;
  40. INLINE TypeIndex parameter_get_type(int n) const;
  41. INLINE bool parameter_has_name(int n) const;
  42. INLINE const string &parameter_get_name(int n) const;
  43. INLINE bool parameter_is_this(int n) const;
  44. INLINE const string &get_unique_name() const;
  45. void output(ostream &out) const;
  46. void input(istream &in);
  47. void remap_indices(const IndexRemapper &remap);
  48. private:
  49. enum Flags {
  50. F_caller_manages = 0x0001,
  51. F_has_return = 0x0002,
  52. F_callable_by_name = 0x0004
  53. };
  54. enum ParameterFlags {
  55. PF_has_name = 0x0001,
  56. PF_is_this = 0x0002,
  57. };
  58. int _flags;
  59. FunctionIndex _function;
  60. TypeIndex _return_type;
  61. FunctionIndex _return_value_destructor;
  62. string _unique_name;
  63. public:
  64. // This nested class must be declared public just so we can declare
  65. // the external ostream and istream I/O operator functions, on the
  66. // SGI compiler. Arguably a compiler bug, but what can you do.
  67. class Parameter {
  68. public:
  69. void output(ostream &out) const;
  70. void input(istream &in);
  71. int _parameter_flags;
  72. TypeIndex _type;
  73. string _name;
  74. };
  75. private:
  76. typedef vector<Parameter> Parameters;
  77. Parameters _parameters;
  78. friend class InterrogateBuilder;
  79. friend class FunctionRemap;
  80. };
  81. INLINE ostream &operator << (ostream &out, const InterrogateFunctionWrapper &wrapper);
  82. INLINE istream &operator >> (istream &in, InterrogateFunctionWrapper &wrapper);
  83. INLINE ostream &operator << (ostream &out, const InterrogateFunctionWrapper::Parameter &p);
  84. INLINE istream &operator >> (istream &in, InterrogateFunctionWrapper::Parameter &p);
  85. #include "interrogateFunctionWrapper.I"
  86. #endif