Panda3D
interrogateFunction.h
Go to the documentation of this file.
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 interrogateFunction.h
10  * @author drose
11  * @date 2000-08-01
12  */
13 
14 #ifndef INTERROGATEFUNCTION_H
15 #define INTERROGATEFUNCTION_H
16 
17 #include "dtoolbase.h"
18 
19 #include "interrogateComponent.h"
20 
21 #include <vector>
22 #include <map>
23 
24 class IndexRemapper;
25 class CPPInstance;
26 
27 /**
28  * An internal representation of a function.
29  */
30 class EXPCL_INTERROGATEDB InterrogateFunction : public InterrogateComponent {
31 public:
34  void operator = (const InterrogateFunction &copy);
35 
36  INLINE bool is_global() const;
37  INLINE bool is_virtual() const;
38  INLINE bool is_method() const;
39  INLINE bool is_unary_op() const;
40  INLINE bool is_operator_typecast() const;
41  INLINE TypeIndex get_class() const;
42 
43  INLINE bool has_scoped_name() const;
44  INLINE const std::string &get_scoped_name() const;
45 
46  INLINE bool has_comment() const;
47  INLINE const std::string &get_comment() const;
48 
49  INLINE bool has_prototype() const;
50  INLINE const std::string &get_prototype() const;
51 
52  INLINE int number_of_c_wrappers() const;
53  INLINE FunctionWrapperIndex get_c_wrapper(int n) const;
54 
55  INLINE int number_of_python_wrappers() const;
56  INLINE FunctionWrapperIndex get_python_wrapper(int n) const;
57 
58  void output(std::ostream &out) const;
59  void input(std::istream &in);
60 
61  void remap_indices(const IndexRemapper &remap);
62 
63 private:
64  enum Flags {
65  F_global = 0x0001,
66  F_virtual = 0x0002,
67  F_method = 0x0004,
68  F_typecast = 0x0008,
69  F_getter = 0x0010,
70  F_setter = 0x0020,
71  F_unary_op = 0x0040,
72  F_operator_typecast = 0x0080,
73  };
74 
75  int _flags;
76  std::string _scoped_name;
77  std::string _comment;
78  std::string _prototype;
79  TypeIndex _class;
80 
81  typedef std::vector<FunctionWrapperIndex> Wrappers;
82  Wrappers _c_wrappers;
83  Wrappers _python_wrappers;
84 
85 public:
86  // The rest of the members in this class aren't part of the public interface
87  // to interrogate, but are used internally as the interrogate database is
88  // built. They are valid only during the session of interrogate that
89  // generates the database, and will not be filled in when the database is
90  // reloaded from disk.
91 
92  // This must be a pointer, rather than a concrete map, so we don't risk
93  // trying to create a map in one DLL and access it in another. Silly
94  // Windows.
95  typedef std::map<std::string, CPPInstance *> Instances;
96  Instances *_instances;
97  std::string _expression;
98 
99  friend class InterrogateBuilder;
100  friend class InterfaceMakerC;
101  friend class InterfaceMakerPythonSimple;
102  friend class InterfaceMakerPythonNative;
103  friend class FunctionRemap;
104 };
105 
106 INLINE std::ostream &operator << (std::ostream &out, const InterrogateFunction &function);
107 INLINE std::istream &operator >> (std::istream &in, InterrogateFunction &function);
108 
109 #include "interrogateFunction.I"
110 
111 #endif
This class manages a mapping of integers to integers.
Definition: indexRemapper.h:29
void output(std::ostream &out) const
Formats the component for output to a data file.
An internal representation of a function.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
The base class for things that are part of the interrogate database.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void input(std::istream &in)
Reads the data file as previously formatted by output().