Polly 20.0.0git
plain_cpp.h
Go to the documentation of this file.
1#ifndef ISL_INTERFACE_PLAIN_CPP_H
2#define ISL_INTERFACE_PLAIN_CPP_H
3
4#include <functional>
5#include <memory>
6
7#include "cpp.h"
8#include "generator.h"
9
10using namespace std;
11using namespace clang;
12
13/* A type printer for converting argument and return types
14 * to string representations of the corresponding types
15 * in the checked C++ interface.
16 */
18 virtual std::string isl_bool() const override;
19 virtual std::string isl_stat() const override;
20 virtual std::string isl_size() const override;
21 virtual std::string isl_namespace() const override;
22};
23
24/* Generator for plain C++ bindings.
25 *
26 * "checked" is set if C++ bindings should be generated
27 * that rely on the user to check for error conditions.
28 */
30 struct plain_printer;
31 struct decl_printer;
32 struct impl_printer;
33protected:
34 bool checked;
35public:
36 plain_cpp_generator(SourceManager &SM,
37 set<RecordDecl *> &exported_types,
38 set<FunctionDecl *> exported_functions,
39 set<FunctionDecl *> functions,
40 bool checked = false);
41
42 virtual void generate();
43private:
44 void print_forward_declarations(ostream &os);
45 void print_declarations(ostream &os);
46 void print_class(ostream &os, const isl_class &clazz);
47 void print_class_forward_decl(ostream &os, const isl_class &clazz);
48 void print_implementations(ostream &os);
49 void print_class_impl(ostream &os, const isl_class &clazz);
51 const isl_class &clazz, FunctionDecl *fd);
52 void print_invalid(ostream &os, int indent, const char *msg,
53 const char *checked_code);
54 void print_method_param_use(ostream &os, ParmVarDecl *param,
55 bool load_from_this_ptr);
56 std::unique_ptr<cpp_type_printer> type_printer();
57 std::string get_return_type(const Method &method);
58 string generate_callback_args(QualType type, bool cpp);
59 string generate_callback_type(QualType type);
60 string isl_bool2cpp();
61 string isl_namespace();
62 string param2cpp(QualType type);
63};
64
65/* A helper class for printing method declarations and definitions
66 * of a class for the plain C++ interface.
67 *
68 * "generator" is the C++ interface generator printing the classes.
69 */
72
73 plain_printer(std::ostream &os, const isl_class &clazz,
74 plain_cpp_generator &generator, bool is_declaration) :
75 class_printer(os, clazz, generator, is_declaration),
77
78 void print_persistent_callback_prototype(FunctionDecl *method);
79 void print_persistent_callback_setter_prototype(FunctionDecl *method);
80 void print_full_method_header(const Method &method);
81 void print_callback_data_decl(ParmVarDecl *param, const string &name);
82 virtual bool want_descendent_overloads(const function_set &methods)
83 override;
84 virtual void print_public_constructors() = 0;
85 virtual void print_copy_assignment() = 0;
86 virtual void print_destructor() = 0;
87 virtual void print_ptr() = 0;
88 virtual void print_downcast() = 0;
89 virtual void print_ctx() = 0;
90 virtual void print_method_separator() = 0;
91 virtual void print_persistent_callbacks() = 0;
94 void print_id_user_header(bool optional);
95 virtual void print_id_constructor_user() = 0;
96 virtual void print_id_user(bool optional) = 0;
97 void print_special_id();
98 void print_special();
99};
100
101/* A helper class for printing method declarations of a class.
102 */
105{
106 decl_printer(std::ostream &os, const isl_class &clazz,
108 plain_printer(os, clazz, generator, true) {}
109
110 void print_subclass_type();
111 void print_class_factory(const std::string &prefix = std::string());
113 virtual void print_copy_assignment() override;
114 virtual void print_public_constructors() override;
115 virtual void print_destructor() override;
116 virtual void print_ptr() override;
117 void print_isa_type_template(int indent, const isl_class &super);
118 virtual void print_downcast() override;
119 virtual void print_ctx() override;
120 virtual void print_method_separator() override;
121 void print_persistent_callback_data(FunctionDecl *method);
122 virtual void print_persistent_callbacks() override;
123 virtual void print_method(const Method &method) override;
124 virtual void print_method(const ConversionMethod &method) override;
125 virtual void print_get_method(FunctionDecl *fd) override;
126 virtual void print_id_constructor_user() override;
127 virtual void print_id_user(bool optional) override;
128};
129
130/* A helper class for printing method definitions of a class.
131 */
134{
135 impl_printer(std::ostream &os, const isl_class &clazz,
138
139 void print_arg_conversion(ParmVarDecl *dst, ParmVarDecl *src);
140 virtual void print_method(const Method &method) override;
141 virtual void print_method(const ConversionMethod &method) override;
142 virtual void print_get_method(FunctionDecl *fd) override;
143 void print_check_ptr(const char *ptr);
144 void print_check_ptr_start(const char *ptr);
145 void print_check_ptr_end(const char *ptr);
146 void print_class_factory();
148 virtual void print_public_constructors() override;
149 virtual void print_copy_assignment() override;
150 virtual void print_destructor() override;
151 virtual void print_ptr() override;
152 virtual void print_downcast() override;
153 virtual void print_ctx() override;
154 virtual void print_method_separator() override;
155 void print_set_persistent_callback(const Method &method);
156 virtual void print_persistent_callbacks() override;
157 void print_argument_validity_check(const Method &method);
158 void print_save_ctx(const std::string &ctx);
159 void print_save_ctx(const Method &method);
161 void print_exceptional_execution_check(const Method &method);
162 void print_method_return(const Method &method);
164 void print_wrapped_call_checked(int indent, const std::string &call);
165 void print_wrapped_call(int indent, const std::string &call,
166 QualType rtype);
167 void print_callback_body(int indent, ParmVarDecl *param,
168 const string &name);
169 void print_callback_local(ParmVarDecl *param);
170 virtual void print_id_constructor_user() override;
171 virtual void print_id_user(bool optional) override;
172};
173
174#endif
SourceManager & SM
Definition: generator.h:146
void print_class_forward_decl(ostream &os, const isl_class &clazz)
Definition: plain_cpp.cc:271
void print_check_no_persistent_callback(ostream &os, const isl_class &clazz, FunctionDecl *fd)
Definition: plain_cpp.cc:1137
void print_invalid(ostream &os, int indent, const char *msg, const char *checked_code)
Definition: plain_cpp.cc:702
void print_class_impl(ostream &os, const isl_class &clazz)
Definition: plain_cpp.cc:657
void print_class(ostream &os, const isl_class &clazz)
Definition: plain_cpp.cc:238
void print_declarations(ostream &os)
Definition: plain_cpp.cc:164
virtual void generate()
Definition: plain_cpp.cc:130
string isl_namespace()
Definition: plain_cpp.cc:2084
string generate_callback_args(QualType type, bool cpp)
Definition: plain_cpp.cc:1648
string param2cpp(QualType type)
Definition: plain_cpp.cc:2095
void print_method_param_use(ostream &os, ParmVarDecl *param, bool load_from_this_ptr)
string generate_callback_type(QualType type)
Definition: plain_cpp.cc:1659
void print_implementations(ostream &os)
Definition: plain_cpp.cc:181
std::unique_ptr< cpp_type_printer > type_printer()
Definition: plain_cpp.cc:1508
std::string get_return_type(const Method &method)
Definition: plain_cpp.cc:1524
void print_forward_declarations(ostream &os)
Definition: plain_cpp.cc:152
std::set< FunctionDecl *, function_name_less > function_set
Definition: generator.h:45
enum isl_fold type
Definition: isl_test.c:4017
const char * name
Definition: isl_test.c:10938
Definition: cpp.h:19
virtual std::string isl_stat() const override
Definition: plain_cpp.cc:2057
virtual std::string isl_bool() const override
Definition: plain_cpp.cc:2039
virtual std::string isl_namespace() const override
Definition: plain_cpp.cc:2075
virtual std::string isl_size() const override
Definition: plain_cpp.cc:2066
std::ostream & os
Definition: cpp.h:183
const isl_class & clazz
Definition: cpp.h:184
virtual void print_id_constructor_user() override
Definition: plain_cpp.cc:376
virtual void print_downcast() override
Definition: plain_cpp.cc:501
decl_printer(std::ostream &os, const isl_class &clazz, plain_cpp_generator &generator)
Definition: plain_cpp.h:106
virtual void print_persistent_callbacks() override
Definition: plain_cpp.cc:627
virtual void print_id_user(bool optional) override
Definition: plain_cpp.cc:385
virtual void print_method_separator() override
Definition: plain_cpp.cc:527
void print_persistent_callback_data(FunctionDecl *method)
Definition: plain_cpp.cc:600
virtual void print_method(const Method &method) override
Definition: plain_cpp.cc:368
virtual void print_get_method(FunctionDecl *fd) override
Definition: plain_cpp.cc:648
virtual void print_ptr() override
Definition: plain_cpp.cc:452
virtual void print_copy_assignment() override
Definition: plain_cpp.cc:397
virtual void print_ctx() override
Definition: plain_cpp.cc:518
void print_isa_type_template(int indent, const isl_class &super)
Definition: plain_cpp.cc:477
virtual void print_destructor() override
Definition: plain_cpp.cc:408
virtual void print_public_constructors() override
Definition: plain_cpp.cc:349
void print_class_factory(const std::string &prefix=std::string())
Definition: plain_cpp.cc:299
void print_check_ptr(const char *ptr)
Definition: plain_cpp.cc:756
void print_save_ctx(const std::string &ctx)
Definition: plain_cpp.cc:1365
void print_set_persistent_callback(const Method &method)
Definition: plain_cpp.cc:1538
virtual void print_persistent_callbacks() override
Definition: plain_cpp.cc:1265
virtual void print_copy_assignment() override
Definition: plain_cpp.cc:1099
virtual void print_ctx() override
Definition: plain_cpp.cc:1242
virtual void print_destructor() override
Definition: plain_cpp.cc:1118
void print_wrapped_call(int indent, const std::string &call, QualType rtype)
Definition: plain_cpp.cc:1719
virtual void print_id_constructor_user() override
Definition: plain_cpp.cc:1036
void print_arg_conversion(ParmVarDecl *dst, ParmVarDecl *src)
Definition: plain_cpp.cc:965
void print_callback_local(ParmVarDecl *param)
Definition: plain_cpp.cc:2011
void print_argument_validity_check(const Method &method)
Definition: plain_cpp.cc:1324
virtual void print_method_separator() override
Definition: plain_cpp.cc:1258
virtual void print_public_constructors() override
Definition: plain_cpp.cc:873
void print_method_return(const Method &method)
Definition: plain_cpp.cc:1595
virtual void print_id_user(bool optional) override
Definition: plain_cpp.cc:1070
void print_check_ptr_start(const char *ptr)
Definition: plain_cpp.cc:770
impl_printer(std::ostream &os, const isl_class &clazz, plain_cpp_generator &generator)
Definition: plain_cpp.h:135
void print_wrapped_call_checked(int indent, const std::string &call)
Definition: plain_cpp.cc:1674
virtual void print_method(const Method &method) override
Definition: plain_cpp.cc:924
void print_check_ptr_end(const char *ptr)
Definition: plain_cpp.cc:786
void print_exceptional_execution_check(const Method &method)
Definition: plain_cpp.cc:1472
virtual void print_downcast() override
Definition: plain_cpp.cc:1199
virtual void print_ptr() override
Definition: plain_cpp.cc:1155
void print_callback_body(int indent, ParmVarDecl *param, const string &name)
Definition: plain_cpp.cc:1927
virtual void print_get_method(FunctionDecl *fd) override
Definition: plain_cpp.cc:1297
virtual void print_id_user(bool optional)=0
virtual void print_persistent_callbacks()=0
void print_persistent_callback_setter_prototype(FunctionDecl *method)
Definition: plain_cpp.cc:574
virtual void print_public_constructors()=0
virtual void print_copy_assignment()=0
virtual void print_method_separator()=0
void print_persistent_callback_prototype(FunctionDecl *method)
Definition: plain_cpp.cc:545
void print_callback_data_decl(ParmVarDecl *param, const string &name)
Definition: plain_cpp.cc:1770
virtual void print_id_constructor_user()=0
void print_full_method_header(const Method &method)
Definition: plain_cpp.cc:1628
plain_cpp_generator & generator
Definition: plain_cpp.h:71
virtual bool want_descendent_overloads(const function_set &methods) override
Definition: plain_cpp.cc:1799
plain_printer(std::ostream &os, const isl_class &clazz, plain_cpp_generator &generator, bool is_declaration)
Definition: plain_cpp.h:73
void print_id_user_header(bool optional)
Definition: plain_cpp.cc:1828