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
20
21#include <vector>
22
23class IndexRemapper;
24
25/**
26 * An internal representation of a callable function.
27 */
28class EXPCL_INTERROGATEDB InterrogateFunctionWrapper : public InterrogateComponent {
29public:
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 INLINE bool parameter_is_optional(int n) const;
49
50 INLINE const std::string &get_unique_name() const;
51
52 INLINE bool has_comment() const;
53 INLINE const std::string &get_comment() const;
54
55 void output(std::ostream &out) const;
56 void input(std::istream &in);
57
58 void remap_indices(const IndexRemapper &remap);
59
60private:
61 enum Flags {
62 F_caller_manages = 0x0001,
63 F_has_return = 0x0002,
64 F_callable_by_name = 0x0004
65 };
66
67 enum ParameterFlags {
68 PF_has_name = 0x0001,
69 PF_is_this = 0x0002,
70 PF_is_optional = 0x0004,
71 };
72
73 int _flags;
74 FunctionIndex _function;
75 TypeIndex _return_type;
76 FunctionIndex _return_value_destructor;
77 std::string _unique_name;
78 std::string _comment;
79
80public:
81 // This nested class must be declared public just so we can declare the
82 // external ostream and istream IO operator functions, on the SGI compiler.
83 // Arguably a compiler bug, but what can you do.
84 class Parameter {
85 public:
86 void output(std::ostream &out) const;
87 void input(std::istream &in);
88
89 int _parameter_flags;
90 TypeIndex _type;
91 std::string _name;
92 };
93
94private:
95 typedef std::vector<Parameter> Parameters;
96 Parameters _parameters;
97
98 friend class InterrogateBuilder;
99 friend class FunctionRemap;
100};
101
102INLINE std::ostream &operator << (std::ostream &out, const InterrogateFunctionWrapper &wrapper);
103INLINE std::istream &operator >> (std::istream &in, InterrogateFunctionWrapper &wrapper);
104
105INLINE std::ostream &operator << (std::ostream &out, const InterrogateFunctionWrapper::Parameter &p);
106INLINE std::istream &operator >> (std::istream &in, InterrogateFunctionWrapper::Parameter &p);
107
109
110#endif
This class manages a mapping of integers to integers.
Definition: indexRemapper.h:29
The base class for things that are part of the interrogate database.
void input(std::istream &in)
Reads the data file as previously formatted by output().
void output(std::ostream &out) const
Formats the component for output to a data file.
An internal representation of a callable function.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.