diff options
author | Morgan Deters <mdeters@cs.nyu.edu> | 2013-03-26 17:58:39 -0400 |
---|---|---|
committer | Morgan Deters <mdeters@cs.nyu.edu> | 2013-03-26 19:43:25 -0400 |
commit | ad5e31e2031349c9b9d0bf5d9fcaa1ea7950db58 (patch) | |
tree | dd3e7e943628f1410f4a8d2f260c994d62be308d /src/expr | |
parent | a9912269ab2b47b783a66f381b14148c0ac73e93 (diff) |
Fixes for warnings from clang++, from -std=gnu++0x, from swig, and from javac
Diffstat (limited to 'src/expr')
-rw-r--r-- | src/expr/command.i | 58 | ||||
-rw-r--r-- | src/expr/expr.i | 54 | ||||
-rw-r--r-- | src/expr/variable_type_map.i | 4 |
3 files changed, 114 insertions, 2 deletions
diff --git a/src/expr/command.i b/src/expr/command.i index 09e54fec0..6085a444f 100644 --- a/src/expr/command.i +++ b/src/expr/command.i @@ -1,5 +1,12 @@ %{ #include "expr/command.h" + +#ifdef SWIGJAVA + +#include "bindings/java_iterator_adapter.h" +#include "bindings/java_stream_adapters.h" + +#endif /* SWIGJAVA */ %} %ignore CVC4::operator<<(std::ostream&, const Command&) throw(); @@ -7,8 +14,55 @@ %ignore CVC4::operator<<(std::ostream&, BenchmarkStatus status) throw(); %ignore CVC4::GetProofCommand; +%ignore CVC4::CommandPrintSuccess::Scope; + +#ifdef SWIGJAVA + +// Instead of CommandSequence::begin() and end(), create an +// iterator() method on the Java side that returns a Java-style +// Iterator. +%ignore CVC4::CommandSequence::begin(); +%ignore CVC4::CommandSequence::end(); +%ignore CVC4::CommandSequence::begin() const; +%ignore CVC4::CommandSequence::end() const; +%extend CVC4::CommandSequence { + CVC4::JavaIteratorAdapter<CVC4::CommandSequence> iterator() { + return CVC4::JavaIteratorAdapter<CVC4::CommandSequence>(*$self); + } +} + +// CommandSequence is "iterable" on the Java side +%typemap(javainterfaces) CVC4::CommandSequence "java.lang.Iterable<edu.nyu.acsys.CVC4.Command>"; -%rename(beginConst) CVC4::CommandSequence::begin() const throw(); -%rename(endConst) CVC4::CommandSequence::end() const throw(); +// the JavaIteratorAdapter should not be public, and implements Iterator +%typemap(javaclassmodifiers) CVC4::JavaIteratorAdapter<CVC4::CommandSequence> "class"; +%typemap(javainterfaces) CVC4::JavaIteratorAdapter<CVC4::CommandSequence> "java.util.Iterator<edu.nyu.acsys.CVC4.Command>"; +// add some functions to the Java side (do it here because there's no way to do these in C++) +%typemap(javacode) CVC4::JavaIteratorAdapter<CVC4::CommandSequence> " + public void remove() { + throw new java.lang.UnsupportedOperationException(); + } + + public edu.nyu.acsys.CVC4.Command 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<CVC4::CommandSequence>::getNext() "private"; + +#endif /* SWIGJAVA */ %include "expr/command.h" + +#ifdef SWIGJAVA + +%include "bindings/java_iterator_adapter.h" +%include "bindings/java_stream_adapters.h" + +%template(JavaIteratorAdapter_CommandSequence) CVC4::JavaIteratorAdapter<CVC4::CommandSequence>; + +#endif /* SWIGJAVA */ diff --git a/src/expr/expr.i b/src/expr/expr.i index 34f074a6d..92ab517b1 100644 --- a/src/expr/expr.i +++ b/src/expr/expr.i @@ -1,5 +1,12 @@ %{ #include "expr/expr.h" + +#ifdef SWIGJAVA + +#include "bindings/java_iterator_adapter.h" +#include "bindings/java_stream_adapters.h" + +#endif /* SWIGJAVA */ %} %rename(apply) CVC4::ExprHashFunction::operator()(CVC4::Expr) const; @@ -29,6 +36,44 @@ namespace CVC4 { }/* CVC4::expr namespace */ }/* CVC4 namespace */ +#ifdef SWIGJAVA + +// Instead of Expr::begin() and end(), create an +// iterator() method on the Java side that returns a Java-style +// Iterator. +%ignore CVC4::Expr::begin() const; +%ignore CVC4::Expr::end() const; +%extend CVC4::Expr { + CVC4::JavaIteratorAdapter<CVC4::Expr> iterator() { + return CVC4::JavaIteratorAdapter<CVC4::Expr>(*$self); + } +} + +// Expr is "iterable" on the Java side +%typemap(javainterfaces) CVC4::Expr "java.lang.Iterable<edu.nyu.acsys.CVC4.Expr>"; + +// the JavaIteratorAdapter should not be public, and implements Iterator +%typemap(javaclassmodifiers) CVC4::JavaIteratorAdapter<CVC4::Expr> "class"; +%typemap(javainterfaces) CVC4::JavaIteratorAdapter<CVC4::Expr> "java.util.Iterator<edu.nyu.acsys.CVC4.Expr>"; +// add some functions to the Java side (do it here because there's no way to do these in C++) +%typemap(javacode) CVC4::JavaIteratorAdapter<CVC4::Expr> " + public void remove() { + throw new java.lang.UnsupportedOperationException(); + } + + public edu.nyu.acsys.CVC4.Expr 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<CVC4::Expr>::getNext() "private"; + +#endif /* SWIGJAVA */ + %include "expr/expr.h" %template(getConstTypeConstant) CVC4::Expr::getConst<CVC4::TypeConstant>; @@ -52,4 +97,13 @@ namespace CVC4 { %template(getConstString) CVC4::Expr::getConst<std::string>; %template(getConstBoolean) CVC4::Expr::getConst<bool>; +#ifdef SWIGJAVA + +%include "bindings/java_iterator_adapter.h" +%include "bindings/java_stream_adapters.h" + +%template(JavaIteratorAdapter_Expr) CVC4::JavaIteratorAdapter<CVC4::Expr>; + +#endif /* SWIGJAVA */ + %include "expr/expr.h" diff --git a/src/expr/variable_type_map.i b/src/expr/variable_type_map.i index a5d50361f..95c705c1e 100644 --- a/src/expr/variable_type_map.i +++ b/src/expr/variable_type_map.i @@ -5,4 +5,8 @@ %rename(get) CVC4::VariableTypeMap::operator[](Expr); %rename(get) CVC4::VariableTypeMap::operator[](Type); +%ignore CVC4::ExprManagerMapCollection::d_typeMap; +%ignore CVC4::ExprManagerMapCollection::d_to; +%ignore CVC4::ExprManagerMapCollection::d_from; + %include "expr/variable_type_map.h" |