Panda3D

interrogateFunctionWrapper.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 interrogateFunctionWrapper.h
10 * @author drose
11 * @date 2000-08-06
12 */
13
14 #ifndef INTERROGATEFUNCTIONWRAPPER_H
15 #define INTERROGATEFUNCTIONWRAPPER_H
16
17 #include "dtoolbase.h"
18
19 #include "interrogateComponent.h"
20
21 #include <vector>
22
23 class IndexRemapper;
24
25 /**
26 * An internal representation of a callable function.
27 */
28 class EXPCL_INTERROGATEDB InterrogateFunctionWrapper : public InterrogateComponent {
29 public:
30 INLINE InterrogateFunctionWrapper(InterrogateModuleDef *def = nullptr);
31 INLINE InterrogateFunctionWrapper(const InterrogateFunctionWrapper &copy);
32 INLINE void operator = (const InterrogateFunctionWrapper &copy);
33
34 INLINE FunctionIndex get_function() const;
35
36 INLINE bool is_callable_by_name() const;
37
38 INLINE bool has_return_value() const;
39 INLINE TypeIndex get_return_type() const;
40 INLINE bool caller_manages_return_value() const;
41 INLINE FunctionIndex get_return_value_destructor() const;
42
43 INLINE int number_of_parameters() const;
44 INLINE TypeIndex parameter_get_type(int n) const;
45 INLINE bool parameter_has_name(int n) const;
46 INLINE const std::string &parameter_get_name(int n) const;
47 INLINE bool parameter_is_this(int n) const;
48
49 INLINE const std::string &get_unique_name() const;
50
51 INLINE bool has_comment() const;
52 INLINE const std::string &get_comment() const;
53
54 void output(std::ostream &out) const;
55 void input(std::istream &in);
56
57 void remap_indices(const IndexRemapper &remap);
58
59 private:
60 enum Flags {
61 F_caller_manages = 0x0001,
62 F_has_return = 0x0002,
63 F_callable_by_name = 0x0004
64 };
65
66 enum ParameterFlags {
67 PF_has_name = 0x0001,
68 PF_is_this = 0x0002,
69 };
70
71 int _flags;
72 FunctionIndex _function;
73 TypeIndex _return_type;
74 FunctionIndex _return_value_destructor;
75 std::string _unique_name;
76 std::string _comment;
77
78 public:
79 // This nested class must be declared public just so we can declare the
80 // external ostream and istream IO operator functions, on the SGI compiler.
81 // Arguably a compiler bug, but what can you do.
82 class Parameter {
83 public:
84 void output(std::ostream &out) const;
85 void input(std::istream &in);
86
87 int _parameter_flags;
88 TypeIndex _type;
89 std::string _name;
90 };
91
92 private:
93 typedef std::vector<Parameter> Parameters;
94 Parameters _parameters;
95
96 friend class InterrogateBuilder;
97 friend class FunctionRemap;
98 };
99
100 INLINE std::ostream &operator << (std::ostream &out, const InterrogateFunctionWrapper &wrapper);
101 INLINE std::istream &operator >> (std::istream &in, InterrogateFunctionWrapper &wrapper);
102
103 INLINE std::ostream &operator << (std::ostream &out, const InterrogateFunctionWrapper::Parameter &p);
104 INLINE std::istream &operator >> (std::istream &in, InterrogateFunctionWrapper::Parameter &p);
105
106 #include "interrogateFunctionWrapper.I"
107
108 #endif
IndexRemapper
This class manages a mapping of integers to integers.
Definition: indexRemapper.h:29
InterrogateComponent
The base class for things that are part of the interrogate database.
Definition: interrogateComponent.h:30
InterrogateComponent::input
void input(std::istream &in)
Reads the data file as previously formatted by output().
Definition: interrogateComponent.cxx:39
InterrogateComponent::output
void output(std::ostream &out) const
Formats the component for output to a data file.
Definition: interrogateComponent.cxx:25
InterrogateFunctionWrapper
An internal representation of a callable function.
Definition: interrogateFunctionWrapper.h:28
dtoolbase.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
interrogateComponent.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
interrogateFunctionWrapper.I
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
InterrogateModuleDef
Definition: interrogate_request.h:52