Skip to content

Commit

Permalink
Swig refactor, no more char_vector from alerts
Browse files Browse the repository at this point in the history
  • Loading branch information
aldenml committed Feb 4, 2016
1 parent 7937370 commit b455c1f
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 56 deletions.
Expand Up @@ -23,7 +23,7 @@ public DhtMutableItemAlert(dht_mutable_item_alert alert) {
* @return
*/
public byte[] getKey() {
return Vectors.char_vector2bytes(alert.key_v());
return Vectors.byte_vector2bytes(alert.key_v());
}

/**
Expand All @@ -36,7 +36,7 @@ public byte[] getKey() {
* @return
*/
public byte[] getSignature() {
return Vectors.char_vector2bytes(alert.signature_v());
return Vectors.byte_vector2bytes(alert.signature_v());
}

/**
Expand Down
Expand Up @@ -34,7 +34,7 @@ public Sha1Hash getTarget() {
* @return
*/
public byte[] getPublicKey() {
return Vectors.char_vector2bytes(alert.public_key_v());
return Vectors.byte_vector2bytes(alert.public_key_v());
}

/**
Expand All @@ -44,7 +44,7 @@ public byte[] getPublicKey() {
* @return
*/
public byte[] getSignature() {
return Vectors.char_vector2bytes(alert.signature_v());
return Vectors.byte_vector2bytes(alert.signature_v());
}

/**
Expand Down
Expand Up @@ -84,12 +84,12 @@ public boolean getAuthoritative() {
return libtorrent_jni.dht_mutable_item_alert_authoritative_get(swigCPtr, this);
}

public char_vector key_v() {
return new char_vector(libtorrent_jni.dht_mutable_item_alert_key_v(swigCPtr, this), true);
public byte_vector key_v() {
return new byte_vector(libtorrent_jni.dht_mutable_item_alert_key_v(swigCPtr, this), true);
}

public char_vector signature_v() {
return new char_vector(libtorrent_jni.dht_mutable_item_alert_signature_v(swigCPtr, this), true);
public byte_vector signature_v() {
return new byte_vector(libtorrent_jni.dht_mutable_item_alert_signature_v(swigCPtr, this), true);
}

public final static int priority = libtorrent_jni.dht_mutable_item_alert_priority_get();
Expand Down
Expand Up @@ -84,12 +84,12 @@ public int getNum_success() {
return libtorrent_jni.dht_put_alert_num_success_get(swigCPtr, this);
}

public char_vector public_key_v() {
return new char_vector(libtorrent_jni.dht_put_alert_public_key_v(swigCPtr, this), true);
public byte_vector public_key_v() {
return new byte_vector(libtorrent_jni.dht_put_alert_public_key_v(swigCPtr, this), true);
}

public char_vector signature_v() {
return new char_vector(libtorrent_jni.dht_put_alert_signature_v(swigCPtr, this), true);
public byte_vector signature_v() {
return new byte_vector(libtorrent_jni.dht_put_alert_signature_v(swigCPtr, this), true);
}

public final static int priority = libtorrent_jni.dht_put_alert_priority_get();
Expand Down
5 changes: 3 additions & 2 deletions src/test/java/com/frostwire/jlibtorrent/demo/DhtNs.java
Expand Up @@ -2,6 +2,7 @@

import com.frostwire.jlibtorrent.*;
import com.frostwire.jlibtorrent.alerts.*;
import com.frostwire.jlibtorrent.swig.byte_vector;
import com.frostwire.jlibtorrent.swig.char_vector;
import com.frostwire.jlibtorrent.swig.entry;
import com.frostwire.jlibtorrent.swig.settings_pack;
Expand Down Expand Up @@ -179,9 +180,9 @@ public void alert(Alert<?> alert) {
if (alert instanceof DhtMutableItemAlert) {
DhtMutableItemAlert mutableAlert = (DhtMutableItemAlert) alert;
Entry item = mutableAlert.getItem();
char_vector key_char_vector = mutableAlert.getSwig().key_v();
byte_vector key_char_vector = mutableAlert.getSwig().key_v();
byte[] keyInBytes = new byte[(int) key_char_vector.size()];
Vectors.char_vector2bytes(key_char_vector, keyInBytes);
Vectors.byte_vector2bytes(key_char_vector, keyInBytes);
System.out.println("DHT Mutable Item Alert (" + toHex(keyInBytes) + ") => ");
System.out.println("\t\t\t\t" + item);
System.out.println("Seq: " + mutableAlert.getSeq());
Expand Down
16 changes: 8 additions & 8 deletions swig/libtorrent.i
Expand Up @@ -976,26 +976,26 @@ namespace libtorrent {
};

%extend dht_mutable_item_alert {
std::vector<char> key_v() {
std::vector<int8_t> key_v() {
boost::array<char, 32> arr = $self->key;
return std::vector<char>(arr.begin(), arr.end());
return std::vector<int8_t>(arr.begin(), arr.end());
}

std::vector<char> signature_v() {
std::vector<int8_t> signature_v() {
boost::array<char, 64> arr = $self->signature;
return std::vector<char>(arr.begin(), arr.end());
return std::vector<int8_t>(arr.begin(), arr.end());
}
};

%extend dht_put_alert {
std::vector<char> public_key_v() {
std::vector<int8_t> public_key_v() {
boost::array<char, 32> arr = $self->public_key;
return std::vector<char>(arr.begin(), arr.end());
return std::vector<int8_t>(arr.begin(), arr.end());
}

std::vector<char> signature_v() {
std::vector<int8_t> signature_v() {
boost::array<char, 64> arr = $self->signature;
return std::vector<char>(arr.begin(), arr.end());
return std::vector<int8_t>(arr.begin(), arr.end());
}
};

Expand Down
34 changes: 17 additions & 17 deletions swig/libtorrent_jni.cpp
Expand Up @@ -1404,21 +1404,21 @@ SWIGINTERN int libtorrent_stats_alert_get_transferred(libtorrent::stats_alert *s
SWIGINTERN long long libtorrent_session_stats_alert_get_value(libtorrent::session_stats_alert *self,int index){
return self->values[index];
}
SWIGINTERN std::vector< char > libtorrent_dht_mutable_item_alert_key_v(libtorrent::dht_mutable_item_alert *self){
SWIGINTERN std::vector< int8_t > libtorrent_dht_mutable_item_alert_key_v(libtorrent::dht_mutable_item_alert *self){
boost::array<char, 32> arr = self->key;
return std::vector<char>(arr.begin(), arr.end());
return std::vector<int8_t>(arr.begin(), arr.end());
}
SWIGINTERN std::vector< char > libtorrent_dht_mutable_item_alert_signature_v(libtorrent::dht_mutable_item_alert *self){
SWIGINTERN std::vector< int8_t > libtorrent_dht_mutable_item_alert_signature_v(libtorrent::dht_mutable_item_alert *self){
boost::array<char, 64> arr = self->signature;
return std::vector<char>(arr.begin(), arr.end());
return std::vector<int8_t>(arr.begin(), arr.end());
}
SWIGINTERN std::vector< char > libtorrent_dht_put_alert_public_key_v(libtorrent::dht_put_alert *self){
SWIGINTERN std::vector< int8_t > libtorrent_dht_put_alert_public_key_v(libtorrent::dht_put_alert *self){
boost::array<char, 32> arr = self->public_key;
return std::vector<char>(arr.begin(), arr.end());
return std::vector<int8_t>(arr.begin(), arr.end());
}
SWIGINTERN std::vector< char > libtorrent_dht_put_alert_signature_v(libtorrent::dht_put_alert *self){
SWIGINTERN std::vector< int8_t > libtorrent_dht_put_alert_signature_v(libtorrent::dht_put_alert *self){
boost::array<char, 64> arr = self->signature;
return std::vector<char>(arr.begin(), arr.end());
return std::vector<int8_t>(arr.begin(), arr.end());
}
SWIGINTERN int libtorrent_dht_stats_alert_total_nodes(libtorrent::dht_stats_alert *self){
int total = 0;
Expand Down Expand Up @@ -44210,7 +44210,7 @@ SWIGEXPORT jboolean JNICALL Java_com_frostwire_jlibtorrent_swig_libtorrent_1jni_
SWIGEXPORT jlong JNICALL Java_com_frostwire_jlibtorrent_swig_libtorrent_1jni_dht_1mutable_1item_1alert_1key_1v(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_) {
jlong jresult = 0 ;
libtorrent::dht_mutable_item_alert *arg1 = (libtorrent::dht_mutable_item_alert *) 0 ;
std::vector< char > result;
std::vector< int8_t > result;

(void)jenv;
(void)jcls;
Expand All @@ -44225,15 +44225,15 @@ SWIGEXPORT jlong JNICALL Java_com_frostwire_jlibtorrent_swig_libtorrent_1jni_dht
SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, "Unknown exception type");
}
}
*(std::vector< char > **)&jresult = new std::vector< char >((const std::vector< char > &)result);
*(std::vector< int8_t > **)&jresult = new std::vector< int8_t >((const std::vector< int8_t > &)result);
return jresult;
}


SWIGEXPORT jlong JNICALL Java_com_frostwire_jlibtorrent_swig_libtorrent_1jni_dht_1mutable_1item_1alert_1signature_1v(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_) {
jlong jresult = 0 ;
libtorrent::dht_mutable_item_alert *arg1 = (libtorrent::dht_mutable_item_alert *) 0 ;
std::vector< char > result;
std::vector< int8_t > result;

(void)jenv;
(void)jcls;
Expand All @@ -44248,7 +44248,7 @@ SWIGEXPORT jlong JNICALL Java_com_frostwire_jlibtorrent_swig_libtorrent_1jni_dht
SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, "Unknown exception type");
}
}
*(std::vector< char > **)&jresult = new std::vector< char >((const std::vector< char > &)result);
*(std::vector< int8_t > **)&jresult = new std::vector< int8_t >((const std::vector< int8_t > &)result);
return jresult;
}

Expand Down Expand Up @@ -44561,7 +44561,7 @@ SWIGEXPORT jint JNICALL Java_com_frostwire_jlibtorrent_swig_libtorrent_1jni_dht_
SWIGEXPORT jlong JNICALL Java_com_frostwire_jlibtorrent_swig_libtorrent_1jni_dht_1put_1alert_1public_1key_1v(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_) {
jlong jresult = 0 ;
libtorrent::dht_put_alert *arg1 = (libtorrent::dht_put_alert *) 0 ;
std::vector< char > result;
std::vector< int8_t > result;

(void)jenv;
(void)jcls;
Expand All @@ -44576,15 +44576,15 @@ SWIGEXPORT jlong JNICALL Java_com_frostwire_jlibtorrent_swig_libtorrent_1jni_dht
SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, "Unknown exception type");
}
}
*(std::vector< char > **)&jresult = new std::vector< char >((const std::vector< char > &)result);
*(std::vector< int8_t > **)&jresult = new std::vector< int8_t >((const std::vector< int8_t > &)result);
return jresult;
}


SWIGEXPORT jlong JNICALL Java_com_frostwire_jlibtorrent_swig_libtorrent_1jni_dht_1put_1alert_1signature_1v(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_) {
jlong jresult = 0 ;
libtorrent::dht_put_alert *arg1 = (libtorrent::dht_put_alert *) 0 ;
std::vector< char > result;
std::vector< int8_t > result;

(void)jenv;
(void)jcls;
Expand All @@ -44599,7 +44599,7 @@ SWIGEXPORT jlong JNICALL Java_com_frostwire_jlibtorrent_swig_libtorrent_1jni_dht
SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, "Unknown exception type");
}
}
*(std::vector< char > **)&jresult = new std::vector< char >((const std::vector< char > &)result);
*(std::vector< int8_t > **)&jresult = new std::vector< int8_t >((const std::vector< int8_t > &)result);
return jresult;
}

Expand Down Expand Up @@ -63592,7 +63592,7 @@ SWIGEXPORT jstring JNICALL Java_com_frostwire_jlibtorrent_swig_libtorrent_1jni_J

(void)jenv;
(void)jcls;
result = (char *)("ed62d0524647105b8958b40b4cc8de89d595ee1e");
result = (char *)("7937370c2d7f056c10634cb7d674b6b09459be9e");
if (result) jresult = jenv->NewStringUTF((const char *)result);
return jresult;
}
Expand Down
34 changes: 17 additions & 17 deletions swig/libtorrent_node.cpp
Expand Up @@ -2865,21 +2865,21 @@ v8::Handle<v8::Value> SWIG_From_unsigned_SS_long_SS_long (unsigned long long va
SWIGV8_INTEGER_NEW_UNS(value) : SWIGV8_INTEGER_NEW((long)(value));
}

SWIGINTERN std::vector< char > libtorrent_dht_mutable_item_alert_key_v(libtorrent::dht_mutable_item_alert *self){
SWIGINTERN std::vector< int8_t > libtorrent_dht_mutable_item_alert_key_v(libtorrent::dht_mutable_item_alert *self){
boost::array<char, 32> arr = self->key;
return std::vector<char>(arr.begin(), arr.end());
return std::vector<int8_t>(arr.begin(), arr.end());
}
SWIGINTERN std::vector< char > libtorrent_dht_mutable_item_alert_signature_v(libtorrent::dht_mutable_item_alert *self){
SWIGINTERN std::vector< int8_t > libtorrent_dht_mutable_item_alert_signature_v(libtorrent::dht_mutable_item_alert *self){
boost::array<char, 64> arr = self->signature;
return std::vector<char>(arr.begin(), arr.end());
return std::vector<int8_t>(arr.begin(), arr.end());
}
SWIGINTERN std::vector< char > libtorrent_dht_put_alert_public_key_v(libtorrent::dht_put_alert *self){
SWIGINTERN std::vector< int8_t > libtorrent_dht_put_alert_public_key_v(libtorrent::dht_put_alert *self){
boost::array<char, 32> arr = self->public_key;
return std::vector<char>(arr.begin(), arr.end());
return std::vector<int8_t>(arr.begin(), arr.end());
}
SWIGINTERN std::vector< char > libtorrent_dht_put_alert_signature_v(libtorrent::dht_put_alert *self){
SWIGINTERN std::vector< int8_t > libtorrent_dht_put_alert_signature_v(libtorrent::dht_put_alert *self){
boost::array<char, 64> arr = self->signature;
return std::vector<char>(arr.begin(), arr.end());
return std::vector<int8_t>(arr.begin(), arr.end());
}
SWIGINTERN int libtorrent_dht_stats_alert_total_nodes(libtorrent::dht_stats_alert *self){
int total = 0;
Expand Down Expand Up @@ -71444,7 +71444,7 @@ static SwigV8ReturnValue _wrap_dht_mutable_item_alert_key_v(const SwigV8Argument
libtorrent::dht_mutable_item_alert *arg1 = (libtorrent::dht_mutable_item_alert *) 0 ;
void *argp1 = 0 ;
int res1 = 0 ;
std::vector< char > result;
std::vector< int8_t > result;

if(args.Length() != 0) SWIG_exception_fail(SWIG_ERROR, "Illegal number of arguments for _wrap_dht_mutable_item_alert_key_v.");

Expand All @@ -71454,7 +71454,7 @@ static SwigV8ReturnValue _wrap_dht_mutable_item_alert_key_v(const SwigV8Argument
}
arg1 = (libtorrent::dht_mutable_item_alert *)(argp1);
result = libtorrent_dht_mutable_item_alert_key_v(arg1);
jsresult = SWIG_NewPointerObj((new std::vector< char >((const std::vector< char >&)(result))), SWIGTYPE_p_std__vectorT_char_t, SWIG_POINTER_OWN | 0 );
jsresult = SWIG_NewPointerObj((new std::vector< int8_t >((const std::vector< int8_t >&)(result))), SWIGTYPE_p_std__vectorT_signed_char_t, SWIG_POINTER_OWN | 0 );


SWIGV8_RETURN(jsresult);
Expand All @@ -71472,7 +71472,7 @@ static SwigV8ReturnValue _wrap_dht_mutable_item_alert_signature_v(const SwigV8Ar
libtorrent::dht_mutable_item_alert *arg1 = (libtorrent::dht_mutable_item_alert *) 0 ;
void *argp1 = 0 ;
int res1 = 0 ;
std::vector< char > result;
std::vector< int8_t > result;

if(args.Length() != 0) SWIG_exception_fail(SWIG_ERROR, "Illegal number of arguments for _wrap_dht_mutable_item_alert_signature_v.");

Expand All @@ -71482,7 +71482,7 @@ static SwigV8ReturnValue _wrap_dht_mutable_item_alert_signature_v(const SwigV8Ar
}
arg1 = (libtorrent::dht_mutable_item_alert *)(argp1);
result = libtorrent_dht_mutable_item_alert_signature_v(arg1);
jsresult = SWIG_NewPointerObj((new std::vector< char >((const std::vector< char >&)(result))), SWIGTYPE_p_std__vectorT_char_t, SWIG_POINTER_OWN | 0 );
jsresult = SWIG_NewPointerObj((new std::vector< int8_t >((const std::vector< int8_t >&)(result))), SWIGTYPE_p_std__vectorT_signed_char_t, SWIG_POINTER_OWN | 0 );


SWIGV8_RETURN(jsresult);
Expand Down Expand Up @@ -71932,7 +71932,7 @@ static SwigV8ReturnValue _wrap_dht_put_alert_public_key_v(const SwigV8Arguments
libtorrent::dht_put_alert *arg1 = (libtorrent::dht_put_alert *) 0 ;
void *argp1 = 0 ;
int res1 = 0 ;
std::vector< char > result;
std::vector< int8_t > result;

if(args.Length() != 0) SWIG_exception_fail(SWIG_ERROR, "Illegal number of arguments for _wrap_dht_put_alert_public_key_v.");

Expand All @@ -71942,7 +71942,7 @@ static SwigV8ReturnValue _wrap_dht_put_alert_public_key_v(const SwigV8Arguments
}
arg1 = (libtorrent::dht_put_alert *)(argp1);
result = libtorrent_dht_put_alert_public_key_v(arg1);
jsresult = SWIG_NewPointerObj((new std::vector< char >((const std::vector< char >&)(result))), SWIGTYPE_p_std__vectorT_char_t, SWIG_POINTER_OWN | 0 );
jsresult = SWIG_NewPointerObj((new std::vector< int8_t >((const std::vector< int8_t >&)(result))), SWIGTYPE_p_std__vectorT_signed_char_t, SWIG_POINTER_OWN | 0 );


SWIGV8_RETURN(jsresult);
Expand All @@ -71960,7 +71960,7 @@ static SwigV8ReturnValue _wrap_dht_put_alert_signature_v(const SwigV8Arguments &
libtorrent::dht_put_alert *arg1 = (libtorrent::dht_put_alert *) 0 ;
void *argp1 = 0 ;
int res1 = 0 ;
std::vector< char > result;
std::vector< int8_t > result;

if(args.Length() != 0) SWIG_exception_fail(SWIG_ERROR, "Illegal number of arguments for _wrap_dht_put_alert_signature_v.");

Expand All @@ -71970,7 +71970,7 @@ static SwigV8ReturnValue _wrap_dht_put_alert_signature_v(const SwigV8Arguments &
}
arg1 = (libtorrent::dht_put_alert *)(argp1);
result = libtorrent_dht_put_alert_signature_v(arg1);
jsresult = SWIG_NewPointerObj((new std::vector< char >((const std::vector< char >&)(result))), SWIGTYPE_p_std__vectorT_char_t, SWIG_POINTER_OWN | 0 );
jsresult = SWIG_NewPointerObj((new std::vector< int8_t >((const std::vector< int8_t >&)(result))), SWIGTYPE_p_std__vectorT_signed_char_t, SWIG_POINTER_OWN | 0 );


SWIGV8_RETURN(jsresult);
Expand Down Expand Up @@ -107274,7 +107274,7 @@ static SwigV8ReturnValue _wrap_JLIBTORRENT_REVISION_SHA1(v8::Local<v8::String> p

v8::Handle<v8::Value> jsresult;

jsresult = SWIG_FromCharPtr((const char *)"ed62d0524647105b8958b40b4cc8de89d595ee1e");
jsresult = SWIG_FromCharPtr((const char *)"7937370c2d7f056c10634cb7d674b6b09459be9e");

SWIGV8_RETURN_INFO(jsresult, info);

Expand Down

0 comments on commit b455c1f

Please sign in to comment.