00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef PPL_ppl_ocaml_common_defs_hh
00025 #define PPL_ppl_ocaml_common_defs_hh 1
00026
00027 #include "ppl.hh"
00028 #ifdef PPL_WATCHDOG_LIBRARY_ENABLED
00029 #include "pwl.hh"
00030 #endif
00031 #include "interfaced_boxes.hh"
00032 #include "marked_pointers.hh"
00033
00034
00035 extern "C" {
00036
00037 #define CAML_NAME_SPACE
00038 #include "caml/mlvalues.h"
00039 #include "caml/memory.h"
00040 #include "caml/custom.h"
00041 #include "caml/fail.h"
00042 #include "caml/callback.h"
00043 #include "caml/alloc.h"
00044 #undef CAML_NAME_SPACE
00045
00046 }
00047
00048 namespace Parma_Polyhedra_Library {
00049
00050 namespace Interfaces {
00051
00052 namespace OCaml {
00053
00054 template <typename U_Int>
00055 U_Int value_to_unsigned(value v);
00056
00057 value
00058 ppl_dimension_to_value(dimension_type dim);
00059
00060 dimension_type
00061 value_to_ppl_dimension(value dim);
00062
00063 Variable
00064 build_ppl_Variable(value var);
00065
00066 Degenerate_Element
00067 build_ppl_Degenerate_Element(value de);
00068
00069 Complexity_Class
00070 build_ppl_Complexity_Class(value cc);
00071
00072 Relation_Symbol
00073 build_ppl_relsym(value caml_relsym);
00074
00075 Bounded_Integer_Type_Overflow
00076 build_ppl_bounded_integer_type_overflow(value caml_oflow);
00077
00078 Bounded_Integer_Type_Representation
00079 build_ppl_bounded_integer_type_representation(value caml_rep);
00080
00081 Bounded_Integer_Type_Width
00082 build_ppl_bounded_integer_type_width(value caml_width);
00083
00084 Coefficient
00085 build_ppl_Coefficient(value coeff);
00086
00087 Variable
00088 build_ppl_Variable(value caml_var);
00089
00090 Variables_Set
00091 build_ppl_Variables_Set(value caml_vset);
00092
00093 Linear_Expression
00094 build_ppl_Linear_Expression(value e);
00095
00096 Constraint
00097 build_ppl_Constraint(value c);
00098
00099 Congruence
00100 build_ppl_Congruence(value c);
00101
00102 Generator
00103 build_ppl_Generator(value g);
00104
00105 Grid_Generator
00106 build_ppl_Grid_Generator(value gg);
00107
00108 Constraint_System
00109 build_ppl_Constraint_System(value cl);
00110
00111 Congruence_System
00112 build_ppl_Congruence_System(value cgl);
00113
00114 Generator_System
00115 build_ppl_Generator_System(value gl);
00116
00117 Grid_Generator_System
00118 build_ppl_Grid_Generator_System(value ggs);
00119
00120 value
00121 build_ocaml_poly_con_relation(Poly_Con_Relation& r);
00122
00123 value
00124 build_ocaml_poly_gen_relation(Poly_Gen_Relation& r);
00125
00126 value
00127 build_ocaml_coefficient(const Coefficient& c);
00128
00129 value
00130 build_ocaml_constraint(const Constraint& c);
00131
00132 value
00133 build_ocaml_congruence(const Congruence& cg);
00134
00135 value
00136 build_ocaml_generator(const Generator& g);
00137
00138 value
00139 build_ocaml_constraint_system(const Constraint_System& cs);
00140
00141 value
00142 build_ocaml_congruence_system(const Congruence_System& cgs);
00143
00144 value
00145 build_ocaml_grid_generator(const Grid_Generator& gg);
00146
00147 value
00148 build_ocaml_generator_system(const Generator_System& gs);
00149
00150 value
00151 build_ocaml_grid_generator_system(const Grid_Generator_System& ggs);
00152
00153 class timeout_exception
00154 : public Parma_Polyhedra_Library::Throwable {
00155 public:
00156 void throw_me() const {
00157 throw *this;
00158 }
00159 int priority() const {
00160 return 0;
00161 }
00162 };
00163
00164 class deterministic_timeout_exception
00165 : public Parma_Polyhedra_Library::Throwable {
00166 public:
00167 void throw_me() const {
00168 throw *this;
00169 }
00170 int priority() const {
00171 return 0;
00172 }
00173 };
00174
00175 void reset_timeout();
00176
00177 void reset_deterministic_timeout();
00178
00179 }
00180
00181 }
00182
00183 }
00184
00185 #define CATCH_ALL \
00186 catch(std::bad_alloc&) { \
00187 caml_raise_out_of_memory(); \
00188 } \
00189 catch(std::invalid_argument& e) { \
00190 caml_invalid_argument(const_cast<char*>(e.what())); \
00191 } \
00192 catch(std::overflow_error& e) { \
00193 caml_raise_with_string(*caml_named_value("PPL_arithmetic_overflow"), \
00194 (const_cast<char*>(e.what()))); \
00195 } \
00196 catch(std::domain_error& e) { \
00197 caml_raise_with_string(*caml_named_value("PPL_domain_error"), \
00198 (const_cast<char*>(e.what()))); \
00199 } \
00200 catch(std::length_error& e) { \
00201 caml_raise_with_string(*caml_named_value("PPL_length_error"), \
00202 (const_cast<char*>(e.what()))); \
00203 } \
00204 catch(std::logic_error& e) { \
00205 caml_raise_with_string(*caml_named_value("PPL_logic_error"), \
00206 (const_cast<char*>(e.what()))); \
00207 } \
00208 catch(std::runtime_error& e) { \
00209 caml_raise_with_string(*caml_named_value("PPL_internal_error"), \
00210 (const_cast<char*>(e.what()))); \
00211 } \
00212 catch(std::exception& e) { \
00213 caml_raise_with_string(*caml_named_value("PPL_unknown_standard_exception"), \
00214 (const_cast<char*>(e.what()))); \
00215 } \
00216 catch(timeout_exception&) { \
00217 reset_timeout(); \
00218 caml_raise_constant(*caml_named_value("PPL_timeout_exception")); \
00219 } \
00220 catch(deterministic_timeout_exception&) { \
00221 reset_deterministic_timeout(); \
00222 caml_raise_constant(*caml_named_value("PPL_timeout_exception")); \
00223 } \
00224 catch(...) { \
00225 caml_raise_constant(*caml_named_value("PPL_unexpected_error")); \
00226 }
00227
00228 #include "ppl_ocaml_common.inlines.hh"
00229
00230 #endif // !defined(PPL_ppl_prolog_common_defs_hh)