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) 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 INTERROGATEFUNCTION_H
  19. #define INTERROGATEFUNCTION_H
  20. #include "dtoolbase.h"
  21. #include "interrogateComponent.h"
  22. #include <vector>
  23. #include <map>
  24. class IndexRemapper;
  25. class CPPInstance;
  26. ////////////////////////////////////////////////////////////////////
  27. // Class : InterrogateFunction
  28. // Description : An internal representation of a function.
  29. ////////////////////////////////////////////////////////////////////
  30. class EXPCL_DTOOLCONFIG InterrogateFunction : public InterrogateComponent {
  31. public:
  32. INLINE InterrogateFunction(InterrogateModuleDef *def = NULL);
  33. INLINE InterrogateFunction(const InterrogateFunction &copy);
  34. void operator = (const InterrogateFunction &copy);
  35. INLINE bool is_global() const;
  36. INLINE bool is_virtual() const;
  37. INLINE bool is_method() const;
  38. INLINE TypeIndex get_class() const;
  39. INLINE bool has_scoped_name() const;
  40. INLINE const string &get_scoped_name() const;
  41. INLINE bool has_comment() const;
  42. INLINE const string &get_comment() const;
  43. INLINE bool has_prototype() const;
  44. INLINE const string &get_prototype() const;
  45. INLINE int number_of_c_wrappers() const;
  46. INLINE FunctionWrapperIndex get_c_wrapper(int n) const;
  47. INLINE int number_of_python_wrappers() const;
  48. INLINE FunctionWrapperIndex get_python_wrapper(int n) const;
  49. void output(ostream &out) const;
  50. void input(istream &in);
  51. void remap_indices(const IndexRemapper &remap);
  52. private:
  53. enum Flags {
  54. F_global = 0x0001,
  55. F_virtual = 0x0002,
  56. F_method = 0x0004,
  57. F_typecast = 0x0008,
  58. F_getter = 0x0010,
  59. F_setter = 0x0020,
  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