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