6 /* Generator for C++ bindings.
8 * "checked" is set if C++ bindings should be generated
9 * that rely on the user to check for error conditions.
11 class cpp_generator
: public generator
{
15 cpp_generator(SourceManager
&SM
, set
<RecordDecl
*> &exported_types
,
16 set
<FunctionDecl
*> exported_functions
,
17 set
<FunctionDecl
*> functions
,
18 bool checked
= false) :
19 generator(SM
, exported_types
, exported_functions
, functions
),
23 function_kind_static_method
,
24 function_kind_member_method
,
25 function_kind_constructor
,
28 virtual void generate();
30 void print_file(ostream
&os
, std::string filename
);
31 void print_forward_declarations(ostream
&os
);
32 void print_declarations(ostream
&os
);
33 void print_class(ostream
&os
, const isl_class
&clazz
);
34 void print_class_forward_decl(ostream
&os
, const isl_class
&clazz
);
35 void print_class_factory_decl(ostream
&os
, const isl_class
&clazz
,
36 const std::string
&prefix
= std::string());
37 void print_private_constructors_decl(ostream
&os
,
38 const isl_class
&clazz
);
39 void print_copy_assignment_decl(ostream
&os
, const isl_class
&clazz
);
40 void print_public_constructors_decl(ostream
&os
,
41 const isl_class
&clazz
);
42 void print_constructors_decl(ostream
&os
, const isl_class
&clazz
);
43 void print_destructor_decl(ostream
&os
, const isl_class
&clazz
);
44 void print_ptr_decl(ostream
&os
, const isl_class
&clazz
);
45 void print_get_ctx_decl(ostream
&os
);
46 void print_methods_decl(ostream
&os
, const isl_class
&clazz
);
47 void print_method_group_decl(ostream
&os
, const isl_class
&clazz
,
48 const set
<FunctionDecl
*> &methods
);
49 void print_method_decl(ostream
&os
, const isl_class
&clazz
,
50 FunctionDecl
*method
, function_kind kind
);
51 void print_implementations(ostream
&os
);
52 void print_class_impl(ostream
&os
, const isl_class
&clazz
);
53 void print_check_ptr(ostream
&os
, const char *ptr
);
54 void print_check_ptr_start(ostream
&os
, const isl_class
&clazz
,
56 void print_check_ptr_end(ostream
&os
, const char *ptr
);
57 void print_class_factory_impl(ostream
&os
, const isl_class
&clazz
);
58 void print_private_constructors_impl(ostream
&os
,
59 const isl_class
&clazz
);
60 void print_public_constructors_impl(ostream
&os
,
61 const isl_class
&clazz
);
62 void print_constructors_impl(ostream
&os
, const isl_class
&clazz
);
63 void print_copy_assignment_impl(ostream
&os
, const isl_class
&clazz
);
64 void print_destructor_impl(ostream
&os
, const isl_class
&clazz
);
65 void print_ptr_impl(ostream
&os
, const isl_class
&clazz
);
66 void print_get_ctx_impl(ostream
&os
, const isl_class
&clazz
);
67 void print_methods_impl(ostream
&os
, const isl_class
&clazz
);
68 void print_method_group_impl(ostream
&os
, const isl_class
&clazz
,
69 const set
<FunctionDecl
*> &methods
);
70 void print_argument_validity_check(ostream
&os
, FunctionDecl
*method
,
72 void print_save_ctx(ostream
&os
, FunctionDecl
*method
,
74 void print_on_error_continue(ostream
&os
);
75 void print_exceptional_execution_check(ostream
&os
,
76 FunctionDecl
*method
);
77 void print_method_return(ostream
&os
, const isl_class
&clazz
,
78 FunctionDecl
*method
);
79 void print_method_impl(ostream
&os
, const isl_class
&clazz
,
80 FunctionDecl
*method
, function_kind kind
);
81 void print_stream_insertion(ostream
&os
, const isl_class
&clazz
);
82 void print_method_param_use(ostream
&os
, ParmVarDecl
*param
,
83 bool load_from_this_ptr
);
84 void print_method_header(ostream
&os
, const isl_class
&clazz
,
85 FunctionDecl
*method
, bool is_declaration
, function_kind kind
);
86 string
generate_callback_args(QualType type
, bool cpp
);
87 string
generate_callback_type(QualType type
);
88 void print_wrapped_call_checked(std::ostream
&os
,
89 const std::string
&call
);
90 void print_wrapped_call(std::ostream
&os
, const std::string
&call
);
91 void print_callback_local(ostream
&os
, ParmVarDecl
*param
);
92 std::string
rename_method(std::string name
);
93 string
type2cpp(const isl_class
&clazz
);
94 string
type2cpp(QualType type
);
95 bool is_implicit_conversion(const isl_class
&clazz
, FunctionDecl
*cons
);
96 bool is_subclass(QualType subclass_type
, const isl_class
&class_type
);
97 function_kind
get_method_kind(const isl_class
&clazz
,
98 FunctionDecl
*method
);
100 static string
type2cpp(string type_string
);