From a0c5d25a60c9602b2452633a9c70aa034669462c Mon Sep 17 00:00:00 2001 From: Tim King Date: Wed, 16 Dec 2015 12:36:16 -0500 Subject: [PATCH] Removing the Record iterator from the swig interface. Moving the cvc4 autogen include in interactive_shell.cpp. --- src/expr/record.h | 2 +- src/expr/record.i | 54 +--------------------------------- src/main/interactive_shell.cpp | 4 ++- 3 files changed, 5 insertions(+), 55 deletions(-) diff --git a/src/expr/record.h b/src/expr/record.h index 2cd7defe9..d30536fb0 100644 --- a/src/expr/record.h +++ b/src/expr/record.h @@ -29,7 +29,7 @@ namespace CVC4 { // This forward delcartion is required to resolve a cicular dependency with // Record which is a referenced in a Kind file. -class CVC4_PUBLIC Type; +class Type; } /* namespace CVC4 */ namespace CVC4 { diff --git a/src/expr/record.i b/src/expr/record.i index 283f01106..695ff105b 100644 --- a/src/expr/record.i +++ b/src/expr/record.i @@ -43,58 +43,7 @@ jenv->SetObjectArrayElement($result, 1, jenv->NewObject(clazz, methodid, reinterpret_cast(new CVC4::Type($1.second)), true)); }; -// Instead of Record::begin() and end(), create an -// iterator() method on the Java side that returns a Java-style -// Iterator. -%ignore CVC4::Record::begin() const; -%ignore CVC4::Record::end() const; -%extend CVC4::Record { - CVC4::Type find(std::string name) const { - CVC4::Record::const_iterator i; - for(i = $self->begin(); i != $self->end(); ++i) { - if((*i).first == name) { - return (*i).second; - } - } - return CVC4::Type(); - } - - CVC4::JavaIteratorAdapter iterator() { - return CVC4::JavaIteratorAdapter(*$self); - } -} - -// Record is "iterable" on the Java side -%typemap(javainterfaces) CVC4::Record "java.lang.Iterable"; - -// the JavaIteratorAdapter should not be public, and implements Iterator -%typemap(javaclassmodifiers) CVC4::JavaIteratorAdapter "class"; -%typemap(javainterfaces) CVC4::JavaIteratorAdapter "java.util.Iterator"; -// add some functions to the Java side (do it here because there's no way to do these in C++) -%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(); - } - } -" -// getNext() just allows C++ iterator access from Java-side next(), make it private -%javamethodmodifiers CVC4::JavaIteratorAdapter::getNext() "private"; - -// map the types appropriately. for records, the "payload" of the iterator is an Object[]. -// These Object arrays are always of two elements, the first is a String and the second a -// Type. (On the C++ side, it is a std::pair.) -%typemap(jni) CVC4::Record::const_iterator::value_type = std::pair; -%typemap(jtype) CVC4::Record::const_iterator::value_type = std::pair; -%typemap(jstype) CVC4::Record::const_iterator::value_type = std::pair; -%typemap(javaout) CVC4::Record::const_iterator::value_type = std::pair; -%typemap(out) CVC4::Record::const_iterator::value_type = std::pair; + #endif /* SWIGJAVA */ @@ -105,6 +54,5 @@ %include "bindings/java_iterator_adapter.h" %include "bindings/java_stream_adapters.h" -%template(JavaIteratorAdapter_Record) CVC4::JavaIteratorAdapter; #endif /* SWIGJAVA */ diff --git a/src/main/interactive_shell.cpp b/src/main/interactive_shell.cpp index da2813e24..7b146b3b0 100644 --- a/src/main/interactive_shell.cpp +++ b/src/main/interactive_shell.cpp @@ -26,6 +26,9 @@ #include #include +//This must go before HAVE_LIBREADLINE. +#include "cvc4autoconfig.h" + #if HAVE_LIBREADLINE # include # include @@ -36,7 +39,6 @@ #include "base/output.h" -#include "cvc4autoconfig.h" #include "options/language.h" #include "options/main_options.h" #include "options/options.h" -- 2.30.2