Panda3D
 All Classes Functions Variables Enumerations
interrogateFunctionWrapper.h
1 // Filename: interrogateFunctionWrapper.h
2 // Created by: drose (06Aug00)
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 INTERROGATEFUNCTIONWRAPPER_H
16 #define INTERROGATEFUNCTIONWRAPPER_H
17 
18 #include "dtoolbase.h"
19 
20 #include "interrogateComponent.h"
21 
22 #include <vector>
23 
24 class IndexRemapper;
25 
26 ////////////////////////////////////////////////////////////////////
27 // Class : InterrogateFunctionWrapper
28 // Description : An internal representation of a callable function.
29 ////////////////////////////////////////////////////////////////////
30 class EXPCL_DTOOLCONFIG InterrogateFunctionWrapper : public InterrogateComponent {
31 public:
33  INLINE InterrogateFunctionWrapper(const InterrogateFunctionWrapper &copy);
34  INLINE void operator = (const InterrogateFunctionWrapper &copy);
35 
36  INLINE FunctionIndex get_function() const;
37 
38  INLINE bool is_callable_by_name() const;
39 
40  INLINE bool has_return_value() const;
41  INLINE TypeIndex get_return_type() const;
42  INLINE bool caller_manages_return_value() const;
43  INLINE FunctionIndex get_return_value_destructor() const;
44 
45  INLINE int number_of_parameters() const;
46  INLINE TypeIndex parameter_get_type(int n) const;
47  INLINE bool parameter_has_name(int n) const;
48  INLINE const string &parameter_get_name(int n) const;
49  INLINE bool parameter_is_this(int n) const;
50 
51  INLINE const string &get_unique_name() const;
52 
53  INLINE bool has_comment() const;
54  INLINE const string &get_comment() const;
55 
56  void output(ostream &out) const;
57  void input(istream &in);
58 
59  void remap_indices(const IndexRemapper &remap);
60 
61 private:
62  enum Flags {
63  F_caller_manages = 0x0001,
64  F_has_return = 0x0002,
65  F_callable_by_name = 0x0004
66  };
67 
68  enum ParameterFlags {
69  PF_has_name = 0x0001,
70  PF_is_this = 0x0002,
71  };
72 
73  int _flags;
74  FunctionIndex _function;
75  TypeIndex _return_type;
76  FunctionIndex _return_value_destructor;
77  string _unique_name;
78  string _comment;
79 
80 public:
81  // This nested class must be declared public just so we can declare
82  // the external ostream and istream I/O operator functions, on the
83  // SGI compiler. Arguably a compiler bug, but what can you do.
84  class Parameter {
85  public:
86  void output(ostream &out) const;
87  void input(istream &in);
88 
89  int _parameter_flags;
90  TypeIndex _type;
91  string _name;
92  };
93 
94 private:
95  typedef vector<Parameter> Parameters;
96  Parameters _parameters;
97 
98  friend class InterrogateBuilder;
99  friend class FunctionRemap;
100 };
101 
102 INLINE ostream &operator << (ostream &out, const InterrogateFunctionWrapper &wrapper);
103 INLINE istream &operator >> (istream &in, InterrogateFunctionWrapper &wrapper);
104 
105 INLINE ostream &operator << (ostream &out, const InterrogateFunctionWrapper::Parameter &p);
106 INLINE istream &operator >> (istream &in, InterrogateFunctionWrapper::Parameter &p);
107 
108 #include "interrogateFunctionWrapper.I"
109 
110 #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 callable 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.