[PPL-devel] [GIT] ppl/ppl(master): Added string wrapping helper function to OCaml interface.

Enea Zaffanella zaffanella at cs.unipr.it
Sun Mar 29 22:47:46 CEST 2009


Module: ppl/ppl
Branch: master
Commit: fee0c077d5a0fa9a329b46cf859b355d36d135a6
URL:    http://www.cs.unipr.it/git/gitweb.cgi?p=ppl/ppl.git;a=commit;h=fee0c077d5a0fa9a329b46cf859b355d36d135a6

Author: Enea Zaffanella <zaffanella at cs.unipr.it>
Date:   Sun Mar 29 22:46:25 2009 +0200

Added string wrapping helper function to OCaml interface.

---

 interfaces/OCaml/OCaml_interface.dox   |   26 +++++++++++++-------------
 interfaces/OCaml/ppl_ocaml_common.cc   |   23 +++++++++++++++++++++++
 interfaces/OCaml/ppl_ocaml_globals.ml  |    9 ++++++---
 interfaces/OCaml/ppl_ocaml_globals.mli |    9 ++++++---
 4 files changed, 48 insertions(+), 19 deletions(-)

diff --git a/interfaces/OCaml/OCaml_interface.dox b/interfaces/OCaml/OCaml_interface.dox
index 181e147..50c59f1 100644
--- a/interfaces/OCaml/OCaml_interface.dox
+++ b/interfaces/OCaml/OCaml_interface.dox
@@ -22,7 +22,7 @@ site: http://www.cs.unipr.it/ppl/ . */
 
 /*!
   \defgroup PPL_OCaml_interface OCaml Language Interface
-  \brief
+
   The Parma Polyhedra Library comes equipped with an interface for the
   OCaml language.
 */
@@ -174,6 +174,9 @@ included with all instantiations of the OCaml interfaces.
   warranty whatsoever, the C++ compiler used to build the library,
   where to report bugs and where to look for further information.
 
+<H2><CODE> ppl_max_space_dimension </CODE></H2>
+  Returns the maximum space dimension the C++ interface can handle.
+
 <H2><CODE> ppl_Coefficient_is_bounded </CODE></H2>
   Returns true if and only if the coefficients in the C++ interface
   are bounded.
@@ -186,22 +189,19 @@ included with all instantiations of the OCaml interfaces.
   If the coefficients are bounded, returns the minimum coefficient
   the C++ interface can handle.
 
-<H2><CODE> ppl_max_space_dimension </CODE></H2>
-  Returns the maximum space dimension the C++ interface can handle.
-
-<H2><CODE> ppl_set_timeout_exception_atom name </CODE></H2>
-   Sets the term to be thrown by timeout exceptions
-   to <CODE>name</CODE>.
-   The default value is <CODE>time_out</CODE>.
-
-<H2><CODE> ppl_timeout_exception_atom</CODE></H2>
-   Returns the name to be thrown by timeout exceptions
+<H2><CODE> ppl_io_wrap_string </CODE></H2>
+  Utility function for the wrapping of lines of text.
+  The function wraps the lines of text stored in its first string argument
+  according to the next three integer arguments, which are interpreted as
+  the indentation depth, the preferred length for the first line and the
+  preferred length for all the other lines, respecively; it returns a
+  string containing the wrapped text.
 
 <H2><CODE> ppl_set_timeout c_unsigned </CODE></H2>
    Computations taking exponential time will be interrupted
    some time after <CODE>c_unsigned</CODE> ms after that call.
-   If the computation is interrupted that way, the current timeout
-   exception atom will be thrown.
+   If the computation is interrupted that way, a timeout exception
+   will be thrown.
    <CODE>c_unsigned</CODE> must be strictly greater than zero.
 
 <H2><CODE> ppl_reset_timeout </CODE></H2>
diff --git a/interfaces/OCaml/ppl_ocaml_common.cc b/interfaces/OCaml/ppl_ocaml_common.cc
index 7d87e92..d3a3177 100644
--- a/interfaces/OCaml/ppl_ocaml_common.cc
+++ b/interfaces/OCaml/ppl_ocaml_common.cc
@@ -1127,6 +1127,29 @@ CATCH_ALL
 
 extern "C"
 CAMLprim value
+ppl_io_wrap_string(value src,
+                   value indent_depth,
+                   value preferred_first_line_length,
+                   value preferred_line_length) try {
+  CAMLparam4(src, indent_depth, preferred_first_line_length,
+             preferred_line_length);
+  unsigned cpp_indent_depth
+    = value_to_unsigned_native<unsigned>(indent_depth);
+  unsigned cpp_preferred_first_line_length
+    = value_to_unsigned_native<unsigned>(preferred_first_line_length);
+  unsigned cpp_preferred_line_length
+    = value_to_unsigned_native<unsigned>(preferred_line_length);
+  using IO_Operators::wrap_string;
+  CAMLreturn(caml_copy_string(wrap_string(String_val(src),
+                                          cpp_indent_depth,
+                                          cpp_preferred_first_line_length,
+                                          cpp_preferred_line_length
+                                          ).c_str()));
+}
+CATCH_ALL
+
+extern "C"
+CAMLprim value
 ppl_Coefficient_is_bounded(value unit) try {
   CAMLparam1(unit);
   CAMLreturn(std::numeric_limits<Coefficient>::is_bounded
diff --git a/interfaces/OCaml/ppl_ocaml_globals.ml b/interfaces/OCaml/ppl_ocaml_globals.ml
index 9701aba..06e66bf 100644
--- a/interfaces/OCaml/ppl_ocaml_globals.ml
+++ b/interfaces/OCaml/ppl_ocaml_globals.ml
@@ -117,6 +117,12 @@ unit -> string = "ppl_version"
 external ppl_banner:
 unit -> string = "ppl_banner"
 
+external ppl_io_wrap_string:
+string -> int -> int -> int -> string = "ppl_io_wrap_string"
+
+external ppl_max_space_dimension:
+unit -> int = "ppl_max_space_dimension"
+
 external ppl_Coefficient_is_bounded:
 unit -> bool = "ppl_Coefficient_is_bounded"
 
@@ -126,9 +132,6 @@ unit -> Z.t = "ppl_Coefficient_max"
 external ppl_Coefficient_min:
 unit -> Z.t = "ppl_Coefficient_min"
 
-external ppl_max_space_dimension:
-unit -> int = "ppl_max_space_dimension"
-
 external ppl_set_rounding_for_PPL:
 unit -> unit = "ppl_set_rounding_for_PPL"
 
diff --git a/interfaces/OCaml/ppl_ocaml_globals.mli b/interfaces/OCaml/ppl_ocaml_globals.mli
index 7aad9df..8973162 100644
--- a/interfaces/OCaml/ppl_ocaml_globals.mli
+++ b/interfaces/OCaml/ppl_ocaml_globals.mli
@@ -116,6 +116,12 @@ val ppl_version:
 val ppl_banner:
   unit -> string
 
+val ppl_io_wrap_string:
+  string -> int -> int -> int -> string
+
+val ppl_max_space_dimension:
+  unit -> int
+
 val ppl_Coefficient_is_bounded:
   unit -> bool
 
@@ -125,9 +131,6 @@ val ppl_Coefficient_max:
 val ppl_Coefficient_min:
   unit -> Z.t
 
-val ppl_max_space_dimension:
-  unit -> int
-
 val ppl_set_rounding_for_PPL:
   unit -> unit
 




More information about the PPL-devel mailing list