blob: 9fc0dcda62c1122c0d999e23b97553435c241363 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
%{
#include "util/unsat_core.h"
%}
#ifdef SWIGJAVA
// Instead of UnsatCore::begin() and end(), create an
// iterator() method on the Java side that returns a Java-style
// Iterator.
%ignore CVC4::UnsatCore::begin();
%ignore CVC4::UnsatCore::end();
%ignore CVC4::UnsatCore::begin() const;
%ignore CVC4::UnsatCore::end() const;
%extend CVC4::UnsatCore {
CVC4::JavaIteratorAdapter<CVC4::UnsatCore> iterator() {
return CVC4::JavaIteratorAdapter<CVC4::UnsatCore>(*$self);
}
}
// UnsatCore is "iterable" on the Java side
%typemap(javainterfaces) CVC4::UnsatCore "java.lang.Iterable<edu.nyu.acsys.CVC4.Expr>";
// the JavaIteratorAdapter should not be public, and implements Iterator
%typemap(javaclassmodifiers) CVC4::JavaIteratorAdapter<CVC4::UnsatCore> "class";
%typemap(javainterfaces) CVC4::JavaIteratorAdapter<CVC4::UnsatCore> "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::UnsatCore> "
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::UnsatCore>::getNext() "private";
// map the types appropriately
%typemap(jni) CVC4::UnsatCore::const_iterator::value_type "jobject";
%typemap(jtype) CVC4::UnsatCore::const_iterator::value_type "edu.nyu.acsys.CVC4.Expr";
%typemap(jstype) CVC4::UnsatCore::const_iterator::value_type "edu.nyu.acsys.CVC4.Expr";
%typemap(javaout) CVC4::UnsatCore::const_iterator::value_type { return $jnicall; }
#endif /* SWIGJAVA */
%include "util/unsat_core.h"
|