interrogateFunction.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. // Filename: interrogateFunction.h
  2. // Created by: drose (01Aug00)
  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. #ifndef INTERROGATEFUNCTION_H
  15. #define INTERROGATEFUNCTION_H
  16. #include "dtoolbase.h"
  17. #include "interrogateComponent.h"
  18. #include <vector>
  19. #include <map>
  20. class IndexRemapper;
  21. class CPPInstance;
  22. ////////////////////////////////////////////////////////////////////
  23. // Class : InterrogateFunction
  24. // Description : An internal representation of a function.
  25. ////////////////////////////////////////////////////////////////////
  26. class EXPCL_DTOOLCONFIG InterrogateFunction : public InterrogateComponent {
  27. public:
  28. InterrogateFunction(InterrogateModuleDef *def = NULL);
  29. InterrogateFunction(const InterrogateFunction &copy);
  30. void operator = (const InterrogateFunction &copy);
  31. INLINE bool is_global() const;
  32. INLINE bool is_virtual() const;
  33. INLINE bool is_method() const;
  34. INLINE bool is_unary_op() const;
  35. INLINE bool is_operator_typecast() const;
  36. INLINE TypeIndex get_class() const;
  37. INLINE bool has_scoped_name() const;
  38. INLINE const string &get_scoped_name() const;
  39. INLINE bool has_comment() const;
  40. INLINE const string &get_comment() const;
  41. INLINE bool has_prototype() const;
  42. INLINE const string &get_prototype() const;
  43. INLINE int number_of_c_wrappers() const;
  44. INLINE FunctionWrapperIndex get_c_wrapper(int n) const;
  45. INLINE int number_of_python_wrappers() const;
  46. INLINE FunctionWrapperIndex get_python_wrapper(int n) const;
  47. void output(ostream &out) const;
  48. void input(istream &in);
  49. void remap_indices(const IndexRemapper &remap);
  50. private:
  51. enum Flags {
  52. F_global = 0x0001,
  53. F_virtual = 0x0002,
  54. F_method = 0x0004,
  55. F_typecast = 0x0008,
  56. F_getter = 0x0010,
  57. F_setter = 0x0020,
  58. F_unary_op = 0x0040,
  59. F_operator_typecast = 0x0080,
  60. };
  61. int _flags;
  62. string _scoped_name;
  63. string _comment;
  64. string _prototype;
  65. TypeIndex _class;
  66. typedef vector<FunctionWrapperIndex> Wrappers;
  67. Wrappers _c_wrappers;
  68. Wrappers _python_wrappers;
  69. public:
  70. // The rest of the members in this class aren't part of the public
  71. // interface to interrogate, but are used internally as the
  72. // interrogate database is built. They are valid only during the
  73. // session of interrogate that generates the database, and will not
  74. // be filled in when the database is reloaded from disk.
  75. // This must be a pointer, rather than a concrete map, so we don't
  76. // risk trying to create a map in one DLL and access it in another.
  77. // Silly Windows.
  78. typedef map<string, CPPInstance *> Instances;
  79. Instances *_instances;
  80. string _expression;
  81. friend class InterrogateBuilder;
  82. friend class InterfaceMakerC;
  83. friend class InterfaceMakerPythonSimple;
  84. friend class InterfaceMakerPythonNative;
  85. friend class FunctionRemap;
  86. };
  87. INLINE ostream &operator << (ostream &out, const InterrogateFunction &function);
  88. INLINE istream &operator >> (istream &in, InterrogateFunction &function);
  89. #include "interrogateFunction.I"
  90. #endif