From 44498017455cce207bf9cb0a1ebbf67c4a4d77cf Mon Sep 17 00:00:00 2001 From: Morgan Deters Date: Sat, 17 Nov 2012 04:05:17 +0000 Subject: * Fix for bug 445 agreed to in meeting 11/13/2012: always dump in ALL_SUPPORTED logic * Java bindings fixes: fixed access to ostreams, iterators * Make SmtEngine::setUserAttribute() (and others) take a const string& * Also a few compliance fixes (this commit was certified error- and warning-free by the test-and-commit script.) --- src/util/Makefile.am | 4 +++- src/util/output.i | 23 +++++++++++++++++--- src/util/predicate.i | 8 +++++++ src/util/result.i | 5 +++++ src/util/statistics.i | 46 +++++++++++++++++++++++++++++++++++++++ src/util/uninterpreted_constant.i | 13 +++++++++++ 6 files changed, 95 insertions(+), 4 deletions(-) create mode 100644 src/util/predicate.i create mode 100644 src/util/uninterpreted_constant.i (limited to 'src/util') diff --git a/src/util/Makefile.am b/src/util/Makefile.am index f3ae43b05..e72706ea3 100644 --- a/src/util/Makefile.am +++ b/src/util/Makefile.am @@ -141,7 +141,9 @@ EXTRA_DIST = \ array_store_all.i \ ascription_type.i \ rational.i \ - hash.i + hash.i \ + predicate.i \ + uninterpreted_constant.i DISTCLEANFILES = \ integer.h.tmp \ diff --git a/src/util/output.i b/src/util/output.i index e9f674240..dc524e185 100644 --- a/src/util/output.i +++ b/src/util/output.i @@ -2,7 +2,7 @@ #include "util/output.h" %} -%feature("valuewrapper") CVC4::null_streambuf; +%ignore CVC4::null_streambuf; %feature("valuewrapper") std::ostream; // There are issues with SWIG's attempted wrapping of these variables when @@ -24,8 +24,25 @@ %ignore CVC4::ScopedTrace::ScopedTrace(std::string); %ignore CVC4::ScopedTrace::ScopedTrace(std::string, bool); -%rename(getostream) operator std::ostream&; -%rename(getCVC4ostream) operator CVC4ostream; +%ignore CVC4::WarningC::getStream(); +%ignore CVC4::MessageC::getStream(); +%ignore CVC4::NoticeC::getStream(); +%ignore CVC4::ChatC::getStream(); +%ignore CVC4::TraceC::getStream(); +%ignore CVC4::DebugC::getStream(); +%ignore CVC4::DumpOutC::getStream(); + +%ignore CVC4::WarningC::setStream(std::ostream&); +%ignore CVC4::MessageC::setStream(std::ostream&); +%ignore CVC4::NoticeC::setStream(std::ostream&); +%ignore CVC4::ChatC::setStream(std::ostream&); +%ignore CVC4::TraceC::setStream(std::ostream&); +%ignore CVC4::DebugC::setStream(std::ostream&); +%ignore CVC4::DumpOutC::setStream(std::ostream&); + +%ignore operator std::ostream&; +%ignore operator CVC4ostream; + %rename(get) operator(); %rename(ok) operator bool; diff --git a/src/util/predicate.i b/src/util/predicate.i new file mode 100644 index 000000000..233da01f9 --- /dev/null +++ b/src/util/predicate.i @@ -0,0 +1,8 @@ +%{ +#include "util/predicate.h" +%} + +%rename(equals) CVC4::Predicate::operator==(const Predicate&) const; +%rename(toExpr) CVC4::Predicate::operator Expr() const; + +%include "util/predicate.h" diff --git a/src/util/result.i b/src/util/result.i index c0d86b30a..029a3618a 100644 --- a/src/util/result.i +++ b/src/util/result.i @@ -11,4 +11,9 @@ %ignore CVC4::operator<<(std::ostream&, enum Result::Validity); %ignore CVC4::operator<<(std::ostream&, enum Result::UnknownExplanation); +%ignore CVC4::operator==(enum Result::Sat, const Result&); +%ignore CVC4::operator==(enum Result::Validity, const Result&); +%ignore CVC4::operator!=(enum Result::Sat, const Result&); +%ignore CVC4::operator!=(enum Result::Validity, const Result&); + %include "util/result.h" diff --git a/src/util/statistics.i b/src/util/statistics.i index a14fc29dd..1f5cab2e1 100644 --- a/src/util/statistics.i +++ b/src/util/statistics.i @@ -1,8 +1,54 @@ %{ #include "util/statistics.h" +#include "bindings/java_iterator_adapter.h" +#include "bindings/java_output_stream_adapter.h" %} %rename(assign) CVC4::Statistics::operator=(const StatisticsBase&); %rename(assign) CVC4::Statistics::operator=(const Statistics& stats); +%ignore CVC4::StatisticsBase::begin(); +%ignore CVC4::StatisticsBase::end(); +%ignore CVC4::StatisticsBase::begin() const; +%ignore CVC4::StatisticsBase::end() const; +%extend CVC4::StatisticsBase { + CVC4::JavaIteratorAdapter iterator() { + return CVC4::JavaIteratorAdapter(*$self); + } +} + +%typemap(javainterfaces) CVC4::StatisticsBase "java.lang.Iterable"; + +%typemap(javaclassmodifiers) CVC4::JavaIteratorAdapter "class"; +%typemap(javainterfaces) CVC4::JavaIteratorAdapter "java.util.Iterator"; +%typemap(javacode) CVC4::JavaIteratorAdapter " + public void remove() { + throw new java.lang.UnsupportedOperationException(); + } + + public Object next() { + if(hasNext()) { + return getNext(); + } else { + throw new java.util.NoSuchElementException(); + } + } +" + +%typemap(jni) CVC4::StatisticsBase::const_iterator::value_type "jobjectArray"; +%typemap(jtype) CVC4::StatisticsBase::const_iterator::value_type "java.lang.Object[]"; +%typemap(jstype) CVC4::StatisticsBase::const_iterator::value_type "java.lang.Object[]"; +%typemap(javaout) CVC4::StatisticsBase::const_iterator::value_type { return $jnicall; } +%typemap(out) CVC4::StatisticsBase::const_iterator::value_type { + $result = jenv->NewObjectArray(2, jenv->FindClass("java/lang/Object"), $null); + jenv->SetObjectArrayElement($result, 0, jenv->NewStringUTF($1.first.c_str())); + jclass clazz = jenv->FindClass("edu/nyu/acsys/CVC4/SExpr"); + jmethodID methodid = jenv->GetMethodID(clazz, "", "(JZ)V"); + jenv->SetObjectArrayElement($result, 1, jenv->NewObject(jenv->FindClass("edu/nyu/acsys/CVC4/SExpr"), methodid, reinterpret_cast(new CVC4::SExpr($1.second)), true)); + }; + %include "util/statistics.h" +%include "bindings/java_iterator_adapter.h" +%include "bindings/java_output_stream_adapter.h" + +%template(JavaIteratorAdapter_StatisticsBase) CVC4::JavaIteratorAdapter; diff --git a/src/util/uninterpreted_constant.i b/src/util/uninterpreted_constant.i new file mode 100644 index 000000000..c0bdc5390 --- /dev/null +++ b/src/util/uninterpreted_constant.i @@ -0,0 +1,13 @@ +%{ +#include "util/uninterpreted_constant.h" +%} + +%rename(less) CVC4::UninterpretedConstant::operator<(const UninterpretedConstant&) const; +%rename(lessEqual) CVC4::UninterpretedConstant::operator<=(const UninterpretedConstant&) const; +%rename(greater) CVC4::UninterpretedConstant::operator>(const UninterpretedConstant&) const; +%rename(greaterEqual) CVC4::UninterpretedConstant::operator>=(const UninterpretedConstant&) const; + +%rename(equals) CVC4::UninterpretedConstant::operator==(const UninterpretedConstant&) const; +%ignore CVC4::UninterpretedConstant::operator!=(const UninterpretedConstant&) const; + +%include "util/uninterpreted_constant.h" -- cgit v1.2.3