minor changes to language bindings
authorMorgan Deters <mdeters@cs.nyu.edu>
Thu, 16 May 2013 21:30:13 +0000 (17:30 -0400)
committerMorgan Deters <mdeters@cs.nyu.edu>
Thu, 16 May 2013 21:30:13 +0000 (17:30 -0400)
config/bindings.m4
src/cvc4.i
src/expr/expr.i
src/expr/type.i

index 6aa9b1ac59c21886c032715b3d3ce7f515a70732..3f75479bd831bdef00cfa1f9b7b82f024ffdee8f 100644 (file)
@@ -10,6 +10,17 @@ AC_DEFUN([CVC4_SUPPORTED_BINDINGS],
 AC_DEFUN([CVC4_ALL_BINDINGS],
 [c,java,csharp,perl,php,python,ruby,tcl,ocaml])
 
+# CVC4_NEED_SWIG_FOR_BINDING
+# --------------------------
+# Used by CVC4_CHECK_BINDINGS to ensure swig is available (and correct
+# version) when a binding needs it
+AC_DEFUN([CVC4_NEED_SWIG_FOR_BINDING], [
+  if test -z "$SWIG"; then
+    AC_MSG_WARN([swig not available or incompatible version; $binding bindings require swig 2.0.0 or later])
+    binding_error=yes
+  fi
+])
+
 # CVC4_CHECK_BINDINGS(DEFAULT_BINDINGS_LIST)
 # ------------------------------------------
 # Check for user language binding preferences, and what is possible
@@ -41,7 +52,27 @@ else
     AC_CHECK_PROG(SWIG, "$SWIG", "$SWIG", [])
   fi
   if test -z "$SWIG"; then
+    AC_MSG_RESULT([not found])
     AC_MSG_WARN([language bindings for native API disabled, swig not found.])
+  else
+    AC_MSG_CHECKING([compatibility with version of swig])
+    cat > conftest.c << _CVC4EOF
+%module conftest
+#if !defined(SWIG_VERSION) || SWIG_VERSION < 0x020000
+#error bad version
+#endif
+_CVC4EOF
+    if $SWIG conftest.c >&AS_MESSAGE_LOG_FD 2>&1; then
+      AC_MSG_RESULT([compatible version])
+    else
+      AC_MSG_RESULT([incompatible version])
+      AC_MSG_WARN([swig version 2.0.0 or later is required to build native API bindings])
+      SWIG=
+      echo '===Failed swig input was:' >&AS_MESSAGE_LOG_FD
+      cat conftest.c >&AS_MESSAGE_LOG_FD
+      echo '===End failed swig input' >&AS_MESSAGE_LOG_FD
+      rm -f conftest.c
+    fi
   fi
 fi
 
@@ -78,30 +109,35 @@ for binding in $try_bindings; do
       AC_MSG_RESULT([C support will be built]);;
     java)
       AC_MSG_RESULT([Java support will be built])
+      CVC4_NEED_SWIG_FOR_BINDING
       AC_ARG_VAR(JAVA_CPPFLAGS, [flags to pass to compiler when building Java bindings])
       CPPFLAGS="$CPPFLAGS $JAVA_CPPFLAGS"
       AC_CHECK_HEADER([jni.h], [cvc4_build_java_bindings=yes], [binding_error=yes])
       ;;
     csharp)
       AC_MSG_RESULT([[C# support will be built]])
+      CVC4_NEED_SWIG_FOR_BINDING
       AC_ARG_VAR(CSHARP_CPPFLAGS, [flags to pass to compiler when building C# bindings])
       CPPFLAGS="$CPPFLAGS $CSHARP_CPPFLAGS"
       cvc4_build_csharp_bindings=yes
       ;;
     perl)
       AC_MSG_RESULT([perl support will be built])
+      CVC4_NEED_SWIG_FOR_BINDING
       AC_ARG_VAR(PERL_CPPFLAGS, [flags to pass to compiler when building perl bindings])
       CPPFLAGS="$CPPFLAGS $PERL_CPPFLAGS"
       AC_CHECK_HEADER([EXTERN.h], [cvc4_build_perl_bindings=yes], [binding_error=yes])
       ;;
     php)
       AC_MSG_RESULT([php support will be built])
+      CVC4_NEED_SWIG_FOR_BINDING
       AC_ARG_VAR(PHP_CPPFLAGS, [flags to pass to compiler when building PHP bindings])
       CPPFLAGS="$CPPFLAGS $PHP_CPPFLAGS"
       AC_CHECK_HEADER([zend.h], [cvc4_build_php_bindings=yes], [binding_error=yes])
       ;;
     python)
       AC_MSG_RESULT([python support will be built])
+      CVC4_NEED_SWIG_FOR_BINDING
       AM_PATH_PYTHON([2.5], [cvc4_build_python_bindings=yes], [binding_error=yes])
       AC_ARG_VAR([PYTHON_INCLUDE], [Include flags for python, bypassing python-config])
       AC_ARG_VAR([PYTHON_CONFIG], [Path to python-config])
@@ -122,18 +158,21 @@ for binding in $try_bindings; do
       ;;
     ruby)
       AC_MSG_RESULT([ruby support will be built])
+      CVC4_NEED_SWIG_FOR_BINDING
       AC_ARG_VAR(RUBY_CPPFLAGS, [flags to pass to compiler when building ruby bindings])
       CPPFLAGS="$CPPFLAGS $RUBY_CPPFLAGS"
       AC_CHECK_HEADER([ruby.h], [cvc4_build_ruby_bindings=yes], [binding_error=yes])
       ;;
     tcl)
       AC_MSG_RESULT([tcl support will be built])
+      CVC4_NEED_SWIG_FOR_BINDING
       AC_ARG_VAR(TCL_CPPFLAGS, [flags to pass to compiler when building tcl bindings])
       CPPFLAGS="$CPPFLAGS $TCL_CPPFLAGS"
       AC_CHECK_HEADER([tcl.h], [cvc4_build_tcl_bindings=yes], [binding_error=yes])
       ;;
     ocaml)
       AC_MSG_RESULT([OCaml support will be built])
+      CVC4_NEED_SWIG_FOR_BINDING
       AC_ARG_VAR(TCL_CPPFLAGS, [flags to pass to compiler when building OCaml bindings])
       CPPFLAGS="$CPPFLAGS $OCAML_CPPFLAGS"
       AC_CHECK_HEADER([caml/misc.h], [cvc4_build_ocaml_bindings=yes], [binding_error=yes])
index 965452b8440efb2daeb6397f412a4dab8cc4c515..386bd00b5c13dc0cb3755fd541d135e07e5878d2 100644 (file)
@@ -54,9 +54,11 @@ using namespace CVC4;
 #include "expr/expr.h"
 #include "util/datatype.h"
 #include "expr/command.h"
-#include "bindings/java_stream_adapters.h"
 
+#ifdef SWIGJAVA
+#include "bindings/java_stream_adapters.h"
 std::set<JavaInputStreamAdapter*> CVC4::JavaInputStreamAdapter::s_adapters;
+#endif
 %}
 
 %template(vectorCommandPtr) std::vector< CVC4::Command* >;
index 977345a63bbe26afb263b641729e8e5ef1b07bfe..c649a5ebbc7880ced816b954c7dae770a01f92d4 100644 (file)
@@ -9,7 +9,11 @@
 #endif /* SWIGJAVA */
 %}
 
+#ifdef SWIGPYTHON
+%rename(doApply) CVC4::ExprHashFunction::operator()(CVC4::Expr) const;
+#else /* SWIGPYTHON */
 %rename(apply) CVC4::ExprHashFunction::operator()(CVC4::Expr) const;
+#endif /* SWIGPYTHON */
 
 %ignore CVC4::operator<<(std::ostream&, const Expr&);
 %ignore CVC4::operator<<(std::ostream&, const TypeCheckingException&);
index e227cca233152e13595c976904155f087da58639..6394dda67ea0839f5867563599fcb4ff3c67798a 100644 (file)
@@ -2,7 +2,11 @@
 #include "expr/type.h"
 %}
 
+#ifdef SWIGPYTHON
+%rename(doApply) CVC4::TypeHashFunction::operator()(const CVC4::Type&) const;
+#else /* SWIGPYTHON */
 %rename(apply) CVC4::TypeHashFunction::operator()(const CVC4::Type&) const;
+#endif /* SWIGPYTHON */
 
 %ignore CVC4::operator<<(std::ostream&, const Type&);