%{ #include "expr/expr.h" #ifdef SWIGJAVA #include "bindings/java_iterator_adapter.h" #include "bindings/java_stream_adapters.h" #endif /* SWIGJAVA */ %} #ifdef SWIGPYTHON %rename(doApply) CVC4::ExprHashFunction::operator()(CVC4::Expr) const; #else /* SWIGPYTHON */ %rename(apply) CVC4::ExprHashFunction::operator()(CVC4::Expr) const; #endif /* SWIGPYTHON */ #ifdef SWIGJAVA %typemap(javabody) CVC4::Expr %{ private long swigCPtr; protected boolean swigCMemOwn; protected $javaclassname(long cPtr, boolean cMemoryOwn) { swigCMemOwn = cMemoryOwn; swigCPtr = cPtr; this.em = SmtEngine.mkRef(getExprManager()); // keep ref to em in SWIG proxy class } protected static long getCPtr($javaclassname obj) { return (obj == null) ? 0 : obj.swigCPtr; } %} %javamethodmodifiers CVC4::Expr::operator=(const Expr&) "protected"; %typemap(javacode) CVC4::Expr %{ // a ref is kept here to keep Java GC from collecting the ExprManager // before the Expr private Object em; public Expr assign(Expr e) { Expr r = assignInternal(e); this.em = SmtEngine.mkRef(getExprManager()); // keep ref to em in SWIG proxy class return r; } %} %typemap(javaconstruct) Expr { this($imcall, true); this.em = SmtEngine.mkRef(getExprManager()); // keep ref to em in SWIG proxy class } %typemap(javadestruct, methodname="delete", methodmodifiers="public synchronized") CVC4::Expr { SmtEngine.dlRef(em); em = null; if (swigCPtr != 0) { if (swigCMemOwn) { swigCMemOwn = false; CVC4JNI.delete_Expr(swigCPtr); } swigCPtr = 0; } } #endif /* SWIGJAVA */ %ignore CVC4::operator<<(std::ostream&, const Expr&); %ignore CVC4::operator<<(std::ostream&, const TypeCheckingException&); %ignore CVC4::expr::operator<<(std::ostream&, ExprSetDepth); %ignore CVC4::expr::operator<<(std::ostream&, ExprPrintTypes); %ignore CVC4::expr::operator<<(std::ostream&, ExprDag); %ignore CVC4::expr::operator<<(std::ostream&, ExprSetLanguage); %rename(assignInternal) CVC4::Expr::operator=(const Expr&); %rename(equals) CVC4::Expr::operator==(const Expr&) const; %ignore CVC4::Expr::operator!=(const Expr&) const; %rename(less) CVC4::Expr::operator<(const Expr&) const; %rename(lessEqual) CVC4::Expr::operator<=(const Expr&) const; %rename(greater) CVC4::Expr::operator>(const Expr&) const; %rename(greaterEqual) CVC4::Expr::operator>=(const Expr&) const; %rename(getChild) CVC4::Expr::operator[](unsigned i) const; %ignore CVC4::Expr::operator bool() const;// can just use isNull() namespace CVC4 { namespace expr { %ignore exportInternal; }/* 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 iterator() { return CVC4::JavaIteratorAdapter(*$self); } } // Expr is "iterable" on the Java side %typemap(javainterfaces) CVC4::Expr "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 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::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" %template(getConstTypeConstant) CVC4::Expr::getConst; %template(getConstArrayStoreAll) CVC4::Expr::getConst; %template(getConstBitVectorSize) CVC4::Expr::getConst; %template(getConstAscriptionType) CVC4::Expr::getConst; %template(getConstBitVectorBitOf) CVC4::Expr::getConst; %template(getConstSubrangeBounds) CVC4::Expr::getConst; %template(getConstBitVectorRepeat) CVC4::Expr::getConst; %template(getConstBitVectorExtract) CVC4::Expr::getConst; %template(getConstBitVectorRotateLeft) CVC4::Expr::getConst; %template(getConstBitVectorSignExtend) CVC4::Expr::getConst; %template(getConstBitVectorZeroExtend) CVC4::Expr::getConst; %template(getConstBitVectorRotateRight) CVC4::Expr::getConst; %template(getConstUninterpretedConstant) CVC4::Expr::getConst; %template(getConstKind) CVC4::Expr::getConst; %template(getConstDatatype) CVC4::Expr::getConst; %template(getConstRational) CVC4::Expr::getConst; %template(getConstBitVector) CVC4::Expr::getConst; %template(getConstPredicate) CVC4::Expr::getConst; %template(getConstString) CVC4::Expr::getConst; %template(getConstRegExp) CVC4::Expr::getConst; %template(getConstEmptySet) CVC4::Expr::getConst; %template(getConstBoolean) CVC4::Expr::getConst; #ifdef SWIGJAVA %include "bindings/java_iterator_adapter.h" %include "bindings/java_stream_adapters.h" %template(JavaIteratorAdapter_Expr) CVC4::JavaIteratorAdapter; #endif /* SWIGJAVA */ %include "expr/expr.h"