Panda3D

Loading...
Searching...
No Matches
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 INLINE bool is_copy_constructor() const;
38 INLINE bool is_coerce_constructor() const;
39 INLINE bool is_extension() const;
40
41 INLINE bool has_return_value() const;
42 INLINE TypeIndex get_return_type() const;
43 INLINE bool caller_manages_return_value() const;
44 INLINE FunctionIndex get_return_value_destructor() const;
45
46 INLINE int number_of_parameters() const;
47 INLINE TypeIndex parameter_get_type(int n) const;
48 INLINE bool parameter_has_name(int n) const;
49 INLINE const std::string &parameter_get_name(int n) const;
50 INLINE bool parameter_is_this(int n) const;
51 INLINE bool parameter_is_optional(int n) const;
52
53 INLINE const std::string &get_unique_name() const;
54
55 INLINE bool has_comment() const;
56 INLINE const std::string &get_comment() 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_caller_manages = 0x0001,
66 F_has_return = 0x0002,
67 F_callable_by_name = 0x0004,
68 F_copy_constructor = 0x0008,
69 F_coerce_constructor = 0x0010,
70 F_extension = 0x0020,
71 };
72
73 enum ParameterFlags {
74 PF_has_name = 0x0001,
75 PF_is_this = 0x0002,
76 PF_is_optional = 0x0004,
77 };
78
79 int _flags;
80 FunctionIndex _function;
81 TypeIndex _return_type;
82 FunctionIndex _return_value_destructor;
83 std::string _unique_name;
84 std::string _comment;
85
86 public:
87 // This nested class must be declared public just so we can declare the
88 // external ostream and istream IO operator functions, on the SGI compiler.
89 // Arguably a compiler bug, but what can you do.
90 class Parameter {
91 public:
92 void output(std::ostream &out) const;
93 void input(std::istream &in);
94
95 int _parameter_flags;
96 TypeIndex _type;
97 std::string _name;
98 };
99
100 private:
101 typedef std::vector<Parameter> Parameters;
102 Parameters _parameters;
103
104 friend class InterrogateBuilder;
105 friend class FunctionRemap;
106};
107
108INLINE std::ostream &operator << (std::ostream &out, const InterrogateFunctionWrapper &wrapper);
109INLINE std::istream &operator >> (std::istream &in, InterrogateFunctionWrapper &wrapper);
110
111INLINE std::ostream &operator << (std::ostream &out, const InterrogateFunctionWrapper::Parameter &p);
112INLINE std::istream &operator >> (std::istream &in, InterrogateFunctionWrapper::Parameter &p);
113
114#include "interrogateFunctionWrapper.I"
115
116#endif
IndexRemapper
This class manages a mapping of integers to integers.
Definition indexRemapper.h:29
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
InterrogateFunctionWrapper::is_coerce_constructor
bool is_coerce_constructor() const
Definition interrogateFunctionWrapper.I:78
InterrogateFunctionWrapper::get_function
FunctionIndex get_function() const
Returns the FunctionIndex of the function that this wrapper corresponds to.
Definition interrogateFunctionWrapper.I:54
InterrogateFunctionWrapper::output
void output(std::ostream &out) const
Formats the InterrogateFunctionWrapper data for output to a data file.
Definition interrogateFunctionWrapper.cxx:45
InterrogateFunctionWrapper::remap_indices
void remap_indices(const IndexRemapper &remap)
Remaps all internal index numbers according to the indicated map.
Definition interrogateFunctionWrapper.cxx:76
InterrogateFunctionWrapper::input
void input(std::istream &in)
Reads the data file as previously formatted by output().
Definition interrogateFunctionWrapper.cxx:60
InterrogateFunctionWrapper::is_copy_constructor
bool is_copy_constructor() const
Definition interrogateFunctionWrapper.I:70
InterrogateFunctionWrapper::is_extension
bool is_extension() const
Definition interrogateFunctionWrapper.I:86
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