From c90564313e268e403ca9a6c13a80432bd7a6fa79 Mon Sep 17 00:00:00 2001 From: Morgan Deters Date: Wed, 27 Mar 2013 23:42:13 -0400 Subject: [PATCH] some Java bindings fixes (fixes Debian build problems) --- src/cvc4.i | 2 ++ src/expr/command.i | 6 ++++++ src/expr/expr.i | 6 ++++++ src/util/record.i | 13 +++++++++++-- 4 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/cvc4.i b/src/cvc4.i index ebb8cbd63..965452b84 100644 --- a/src/cvc4.i +++ b/src/cvc4.i @@ -66,6 +66,8 @@ std::set CVC4::JavaInputStreamAdapter::s_adapters; %template(vectorDatatypeType) std::vector< CVC4::DatatypeType >; %template(vectorSExpr) std::vector< CVC4::SExpr >; %template(vectorString) std::vector< std::string >; +%template(vectorPairStringType) std::vector< std::pair< std::string, CVC4::Type > >; +%template(pairStringType) std::pair< std::string, CVC4::Type >; %template(setType) std::set< CVC4::Type >; %template(hashmapExpr) std::hash_map< CVC4::Expr, CVC4::Expr, CVC4::ExprHashFunction >; diff --git a/src/expr/command.i b/src/expr/command.i index 6085a444f..76c8fa674 100644 --- a/src/expr/command.i +++ b/src/expr/command.i @@ -54,6 +54,12 @@ // getNext() just allows C++ iterator access from Java-side next(), make it private %javamethodmodifiers CVC4::JavaIteratorAdapter::getNext() "private"; +// map the types appropriately +%typemap(jni) CVC4::CommandSequence::const_iterator::value_type "jobject"; +%typemap(jtype) CVC4::CommandSequence::const_iterator::value_type "edu.nyu.acsys.CVC4.Command"; +%typemap(jstype) CVC4::CommandSequence::const_iterator::value_type "edu.nyu.acsys.CVC4.Command"; +%typemap(javaout) CVC4::CommandSequence::const_iterator::value_type { return $jnicall; } + #endif /* SWIGJAVA */ %include "expr/command.h" diff --git a/src/expr/expr.i b/src/expr/expr.i index 92ab517b1..977345a63 100644 --- a/src/expr/expr.i +++ b/src/expr/expr.i @@ -72,6 +72,12 @@ namespace CVC4 { // getNext() just allows C++ iterator access from Java-side next(), make it private %javamethodmodifiers CVC4::JavaIteratorAdapter::getNext() "private"; +// map the types appropriately +%typemap(jni) CVC4::Expr::const_iterator::value_type "jobject"; +%typemap(jtype) CVC4::Expr::const_iterator::value_type "edu.nyu.acsys.CVC4.Expr"; +%typemap(jstype) CVC4::Expr::const_iterator::value_type "edu.nyu.acsys.CVC4.Expr"; +%typemap(javaout) CVC4::Expr::const_iterator::value_type { return $jnicall; } + #endif /* SWIGJAVA */ %include "expr/expr.h" diff --git a/src/util/record.i b/src/util/record.i index 2805d2fdf..368519f5b 100644 --- a/src/util/record.i +++ b/src/util/record.i @@ -19,6 +19,8 @@ %ignore CVC4::Record::operator!=(const Record&) const; %rename(getField) CVC4::Record::operator[](size_t) const; +#ifdef SWIGJAVA + // 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) std::pair "jobjectArray"; @@ -33,8 +35,6 @@ jenv->SetObjectArrayElement($result, 1, jenv->NewObject(clazz, methodid, reinterpret_cast(new CVC4::Type($1.second)), true)); }; -#ifdef SWIGJAVA - // Instead of Record::begin() and end(), create an // iterator() method on the Java side that returns a Java-style // Iterator. @@ -79,6 +79,15 @@ // 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 */ %include "util/record.h" -- 2.30.2