2 * Copyright 2018 Sven Verdoolaege
4 * Use of this software is governed by the MIT license
6 * Written by Sven Verdoolaege.
14 #include "cpp_conversion.h"
16 /* Print a function called "function" for converting objects of
17 * type "name" from the "from" bindings to the "to" bindings.
19 static void convert(const char *name
, const char *from
, const char *to
,
22 printf("%s%s %s(%s%s obj) {\n", to
, name
, function
, from
, name
);
23 printf("\t""return %s""manage(obj.copy());\n", to
);
28 /* Print functions for converting objects of "clazz"
29 * between the default and the checked C++ bindings.
31 * The conversion from default to checked is called "check".
32 * The inverse conversion is called "uncheck".
33 * For example, to "set", the following two functions are generated:
35 * checked::set check(set obj) {
36 * return checked::manage(obj.copy());
39 * set uncheck(checked::set obj) {
40 * return manage(obj.copy());
43 static void print(const isl_class
&clazz
)
45 string name
= cpp_generator::type2cpp(clazz
.name
);
47 convert(name
.c_str(), "", "checked::", "check");
48 convert(name
.c_str(), "checked::", "", "uncheck");
51 /* Generate conversion functions for converting objects between
52 * the default and the checked C++ bindings.
53 * Do this for each exported class.
55 void cpp_conversion_generator::generate()
57 map
<string
, isl_class
>::iterator ci
;
59 printf("namespace isl {\n\n");
60 for (ci
= classes
.begin(); ci
!= classes
.end(); ++ci
)
62 printf("} // namespace isl\n");