14 #define ISLPP_STRINGIZE_(X) #X
15 #define ISLPP_STRINGIZE(X) ISLPP_STRINGIZE_(X)
17 #define ISLPP_ASSERT(test, message) \
21 fputs("Assertion \"" #test "\" failed at " __FILE__ \
22 ":" ISLPP_STRINGIZE(__LINE__) "\n " message "\n", \
27 /* Class used to check that isl::checked::boolean,
28 * isl::checked::stat and isl::checked::size values are checked for errors.
33 ISLPP_ASSERT(checked, "IMPLEMENTATION ERROR: Unchecked state");
39 mutable std::shared_ptr<checker> check = std::make_shared<checker>();
42 friend boolean manage(isl_bool val);
43 boolean(isl_bool val): val(val) {}
45 static boolean error() {
46 return boolean(isl_bool_error);
49 : val(isl_bool_error) {}
51 /* implicit */ boolean(bool val)
52 : val(val ? isl_bool_true : isl_bool_false) {}
57 check->checked = true;
61 bool is_error() const { check->checked = true; return val == isl_bool_error; }
62 bool is_false() const { check->checked = true; return val == isl_bool_false; }
63 bool is_true() const { check->checked = true; return val == isl_bool_true; }
65 explicit operator bool() const {
66 ISLPP_ASSERT(check->checked, "IMPLEMENTATION ERROR: Unchecked error state");
67 ISLPP_ASSERT(!is_error(), "IMPLEMENTATION ERROR: Unhandled error state");
72 if (val == isl_bool_true)
74 else if (val == isl_bool_false)
79 boolean operator!() const {
80 return boolean(*this).negate();
84 inline boolean manage(isl_bool val) {
91 /* implicit */ ctx(isl_ctx *ctx)
103 /* Class encapsulating an isl_stat value.
107 mutable std::shared_ptr<checker> check = std::make_shared<checker>();
110 friend stat manage(isl_stat val);
111 stat(isl_stat val) : val(val) {}
114 return stat(isl_stat_ok);
116 static stat error() {
117 return stat(isl_stat_error);
119 stat() : val(isl_stat_error) {}
122 check->checked = true;
126 bool is_error() const {
127 check->checked = true;
128 return val == isl_stat_error;
131 check->checked = true;
132 return val == isl_stat_ok;
136 inline stat manage(isl_stat val)
141 /* Class encapsulating an isl_size value.
145 mutable std::shared_ptr<checker> check = std::make_shared<checker>();
148 friend size manage(isl_size val);
149 size(isl_size val) : val(val) {}
151 size() : val(isl_size_error) {}
155 val = isl_size_error;
156 check->checked = true;
160 bool is_error() const {
161 check->checked = true;
162 return val == isl_size_error;
165 explicit operator unsigned() const {
166 ISLPP_ASSERT(check->checked,
167 "IMPLEMENTATION ERROR: Unchecked error state");
168 ISLPP_ASSERT(!is_error(),
169 "IMPLEMENTATION ERROR: Unhandled error state");
174 inline size manage(isl_size val)