[PPL-devel] [GIT] ppl/ppl(master): Started the installation of the new formatted output machinery.
Roberto Bagnara
bagnara at cs.unipr.it
Mon Mar 23 21:09:33 CET 2009
Module: ppl/ppl
Branch: master
Commit: 52f81f97569aa58d4aa87af0a042d9741c5c515d
URL: http://www.cs.unipr.it/git/gitweb.cgi?p=ppl/ppl.git;a=commit;h=52f81f97569aa58d4aa87af0a042d9741c5c515d
Author: Roberto Bagnara <bagnara at cs.unipr.it>
Date: Mon Mar 23 20:54:14 2009 +0100
Started the installation of the new formatted output machinery.
---
interfaces/C/Makefile.am | 4 +-
interfaces/C/ppl_c_header.h | 2 +
interfaces/C/tests/Makefile.am | 2 +-
interfaces/C/tests/print_to_buffer.c | 98 ++++++++++++++++++++++++++++++++++
interfaces/C/tests/print_to_buffer.h | 11 ++--
src/c_stream.h | 27 +++++++++
6 files changed, 136 insertions(+), 8 deletions(-)
diff --git a/interfaces/C/Makefile.am b/interfaces/C/Makefile.am
index cffb11e..e1db90f 100644
--- a/interfaces/C/Makefile.am
+++ b/interfaces/C/Makefile.am
@@ -73,9 +73,9 @@ LIBPPL_C_LT_CURRENT = 2
LIBPPL_C_LT_REVISION = 0
LIBPPL_C_LT_AGE = 0
-ppl_c.h: ppl_c_header.h ppl_c_version.h ppl_c_domains.h Makefile $(top_builddir)/utils/build_header
+ppl_c.h: ppl_c_header.h ppl_c_version.h ppl_c_domains.h $(top_srcdir)/src/c_stream.h Makefile $(top_builddir)/utils/build_header
$(top_builddir)/utils/build_header \
- -I $(top_builddir)/interfaces/C \
+ -I $(top_builddir)/interfaces/C -I $(top_srcdir)/src \
$(top_srcdir)/interfaces/C/ppl_c_header.h >$@
BUILT_SOURCES = \
diff --git a/interfaces/C/ppl_c_header.h b/interfaces/C/ppl_c_header.h
index 8dd87d9..6f96cab 100644
--- a/interfaces/C/ppl_c_header.h
+++ b/interfaces/C/ppl_c_header.h
@@ -2463,4 +2463,6 @@ PPL_DECLARE_AND_DOCUMENT_IO_FUNCTIONS(MIP_Problem)
#undef PPL_DECLARE_AND_DOCUMENT_ASCII_DUMP_LOAD_FUNCTIONS
#undef PPL_DECLARE_AND_DOCUMENT_IO_FUNCTIONS
+#include "c_stream.h"
+
#endif /* !defined(PPL_ppl_c_h) */
diff --git a/interfaces/C/tests/Makefile.am b/interfaces/C/tests/Makefile.am
index a5260c0..744a53b 100644
--- a/interfaces/C/tests/Makefile.am
+++ b/interfaces/C/tests/Makefile.am
@@ -55,7 +55,7 @@ cxxoutput
# Sources for the tests
#
-cxxoutput_SOURCES = cxxoutput.c print_to_buffer.h print_to_buffer.cc
+cxxoutput_SOURCES = cxxoutput.c print_to_buffer.h print_to_buffer.c
#watchdog1_SRCS = watchdog1.cc
diff --git a/interfaces/C/tests/print_to_buffer.c b/interfaces/C/tests/print_to_buffer.c
new file mode 100644
index 0000000..cafd0e5
--- /dev/null
+++ b/interfaces/C/tests/print_to_buffer.c
@@ -0,0 +1,98 @@
+/* Declarations of print_ppl_*_t_to_buffer() functions.
+ Copyright (C) 2001-2009 Roberto Bagnara <bagnara at cs.unipr.it>
+
+This file is part of the Parma Polyhedra Library (PPL).
+
+The PPL is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 3 of the License, or (at your
+option) any later version.
+
+The PPL is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software Foundation,
+Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307, USA.
+
+For the most up-to-date information see the Parma Polyhedra Library
+site: http://www.cs.unipr.it/ppl/ . */
+
+#include "ppl_c.h"
+#include "print_to_buffer.h"
+#include <malloc.h>
+#include <string.h>
+
+#define DEFINE_PRINT_TO_BUFFER(Type) \
+char* \
+print_##Name##_to_buffer(##Type p, \
+ unsigned indent_depth, \
+ unsigned pfll, \
+ unsigned pll) { \
+ char in[indent_depth + 1]; \
+ memset(in, ' ', indent_depth); \
+ in[indent_depth] = '\0'; \
+ struct ppl_io_format_settings settings = { \
+ 0, /* tr_in */ \
+ 0, /* tr_out */ \
+ "\n", /* paragraph_end */ \
+ { /* wrap points */ \
+ { 0, "," }, /* before, after */ \
+ { " ", 0 } /* before, aftet */ \
+ }, \
+ " ", /* strip_wrap */ \
+ 0, /* top */ \
+ 0, /* bottom */ \
+ { \
+ /* length, left, right, alignment, fill_char */ \
+ { pfll, "", "\n", PPL_IO_FORMAT_ALIGN_LEFT, 0 }, /* FIRST */ \
+ { pfll, "", "\n", PPL_IO_FORMAT_ALIGN_LEFT, 0 }, /* FIRSTLAST */ \
+ { pll, in, "\n", PPL_IO_FORMAT_ALIGN_LEFT, 0 }, /* NEXT */ \
+ { pll, in, "\n", PPL_IO_FORMAT_ALIGN_LEFT, 0 }, /* LAST */ \
+ { 0, "", "\n", PPL_IO_FORMAT_ALIGN_LEFT, 0 }, /* CHOPPED_FIRST */ \
+ { 0, "", "\n", PPL_IO_FORMAT_ALIGN_LEFT, 0 }, /* CHOPPED_NEXT */ \
+ { pfll, "", "\n", PPL_IO_FORMAT_ALIGN_LEFT, 0 }, /* LONGER_FIRST */ \
+ { pfll, "", "\n", PPL_IO_FORMAT_ALIGN_LEFT, 0 }, /* LONGER_FIRSTLAST */ \
+ { pll, in, "\n", PPL_IO_FORMAT_ALIGN_LEFT, 0 }, /* LONGER_NEXT */ \
+ { pll, in, "\n", PPL_IO_FORMAT_ALIGN_LEFT, 0 }, /* LONGER_LAST */ \
+ { pfll, "", "", PPL_IO_FORMAT_ALIGN_LEFT, 0 }, /* UNTERMINATED_FIRST */ \
+ { pll, in, "", PPL_IO_FORMAT_ALIGN_LEFT, 0 } /* UNTERMINATED_NEXT */ \
+ } \
+ }; \
+ struct ppl_io_ostream* target = ppl_io_ostream_buffer_new(); \
+ struct ppl_io_ostream* stream = ppl_io_ostream_format_new(target, &settings); \
+ ppl_io_write_##NAME(stream, object); \
+ ppl_io_ostream_delete(stream); \
+ char *buf; \
+ ppl_io_ostream_buffer_get(target, &buf); \
+ ppl_io_ostream_delete(target); \
+ return buf; \
+}
+
+DEFINE_PRINT_TO_BUFFER(string, char);
+
+#if 0
+DEFINE_PRINT_TO_BUFFER(Coefficient)
+
+DEFINE_PRINT_TO_BUFFER(Linear_Expression)
+
+DEFINE_PRINT_TO_BUFFER(Constraint)
+
+DEFINE_PRINT_TO_BUFFER(Constraint_System)
+
+DEFINE_PRINT_TO_BUFFER(Generator)
+
+DEFINE_PRINT_TO_BUFFER(Generator_System)
+
+DEFINE_PRINT_TO_BUFFER(Congruence)
+
+DEFINE_PRINT_TO_BUFFER(Congruence_System)
+
+DEFINE_PRINT_TO_BUFFER(Grid_Generator)
+
+DEFINE_PRINT_TO_BUFFER(Grid_Generator_System)
+
+DEFINE_PRINT_TO_BUFFER(MIP_Problem)
+#endif
diff --git a/interfaces/C/tests/print_to_buffer.h b/interfaces/C/tests/print_to_buffer.h
index 1e8f9ef..83e57f3 100644
--- a/interfaces/C/tests/print_to_buffer.h
+++ b/interfaces/C/tests/print_to_buffer.h
@@ -33,11 +33,12 @@ site: http://www.cs.unipr.it/ppl/ . */
`preferred_first_line_length' and `preferred_line_length',
respectively.
*/
-#define DECLARE_PRINT_TO_BUFFER(Type) \
-char* print_ppl_##Type##_t_to_buffer(ppl_##Type##_t p, \
- unsigned indent_depth, \
- unsigned preferred_first_line_length, \
- unsigned preferred_line_length);
+#define DECLARE_PRINT_TO_BUFFER(Name, Type) \
+char* \
+print_##Name##_to_buffer(##Type p, \
+ unsigned indent_depth, \
+ unsigned preferred_first_line_length, \
+ unsigned preferred_line_length);
#ifdef __cplusplus
extern "C" {
diff --git a/src/c_stream.h b/src/c_stream.h
index ccde3af..23ca3ff 100644
--- a/src/c_stream.h
+++ b/src/c_stream.h
@@ -1,3 +1,28 @@
+/* Declarations for the formmatted output facility.
+ Copyright (C) 2001-2009 Roberto Bagnara <bagnara at cs.unipr.it>
+
+This file is part of the Parma Polyhedra Library (PPL).
+
+The PPL is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 3 of the License, or (at your
+option) any later version.
+
+The PPL is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software Foundation,
+Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307, USA.
+
+For the most up-to-date information see the Parma Polyhedra Library
+site: http://www.cs.unipr.it/ppl/ . */
+
+#ifndef PPL_c_stream_h
+#define PPL_c_stream_h 1
+
#include <stdio.h>
enum ppl_io_format_line_type {
@@ -86,3 +111,5 @@ DECLARE_WRITE_VAL(float, float);
DECLARE_WRITE_VAL(double, double);
DECLARE_WRITE_VAL(long_double, long double);
DECLARE_WRITE_VAL(string, char*);
+
+#endif /* !defined(PPL_c_stream_h) */
More information about the PPL-devel
mailing list