Cart fixes (#2462)

* Wrapper fixes: Tversky for De Morgan and java byte functions for ExplicitBitVect

* Wrapper fixes: Tversky for De Morgan and java byte functions for ExplicitBitVect
This commit is contained in:
jones-gareth
2019-05-27 13:29:09 +01:00
committed by Greg Landrum
parent b2a01a09ee
commit ebaa7b64e3
3 changed files with 60 additions and 0 deletions

View File

@@ -43,6 +43,34 @@
%ignore ExplicitBitVect::dp_bits;
%ignore ExplicitBitVect::getOnBits (IntVect& v) const;
%ignore ExplicitBitVect::ExplicitBitVect(unsigned int,bool);
#ifdef SWIGJAVA
%template(UChar_Vect) std::vector<unsigned char>;
%typemap(jni) std::string ExplicitBitVect::toByteArray "jbyteArray"
%typemap(jtype) std::string ExplicitBitVect::toByteArray "byte[]"
%typemap(jstype) std::string ExplicitBitVect::toByteArray "byte[]"
%typemap(javaout) std::string ExplicitBitVect::toByteArray {
return $jnicall;
}
%typemap(out) std::string ExplicitBitVect::toByteArray {
$result = JCALL1(NewByteArray, jenv, $1.size());
JCALL4(SetByteArrayRegion, jenv, $result, 0, $1.size(), (const jbyte*)$1.c_str());
}
#endif
%typemap(javacode) ExplicitBitVect %{
public static ExplicitBitVect fromByteArray(byte[] fp) {
UChar_Vect vec = new UChar_Vect();
vec.reserve(fp.length);
for (int size=0;size<fp.length;++size) {
vec.add(fp[size]);
}
return new ExplicitBitVect(vec);
}
%}
%include <DataStructs/ExplicitBitVect.h>
%newobject ExplicitBitVect::getOnBits;
%extend ExplicitBitVect {
@@ -53,3 +81,18 @@
}
}
#ifdef SWIGJAVA
%extend ExplicitBitVect {
const std::string toByteArray() {
return ($self)->toString();
}
ExplicitBitVect(const std::vector<unsigned char> & data ) {
std::string str(data.begin(), data.end());
return new ExplicitBitVect(str);
}
}
#endif