From: Stefan R. <ken...@go...> - 2011-09-20 17:18:34
|
Mathieu Malaterre <mathieu.malaterre <at> gmail.com> writes: > > On Sun, Sep 18, 2011 at 10:38 PM, Stefan Reusch > <kenterfie <at> googlemail.com> wrote: > > Hi Jose, > > > > i know, the topic is some month old, but i have the same problem and i cant find > > something about a solution for it. it would be great, when you find a solution > > to give me some help to implement it into my own project. > > I have been using this to do something very similar: > > %include "arrays_java.i" > JAVA_ARRAYS_IMPL(char, jbyte, Byte, Char) > JAVA_ARRAYS_TYPEMAPS(char, byte, jbyte, Char, "[B") > %typecheck(SWIG_TYPECHECK_INT8_ARRAY) /* Java byte[] */ > signed char[ANY], signed char[] > "" > %typemap(memberin) charANY], char[]; > %typemap(globalin) charANY], char[]; > > HTH Thanks for your help, but it doesnt fixed my problem. I get ever this message ogp_swig.h(32) : Warning 810: No jni typemap defined for int for use in OGPCallb acks::SendTo (skipping director method) My interface file looks like %include "typemaps.i" %include "arrays_java.i" typedef unsigned char ogp_uint8_t; typedef unsigned short ogp_uint16_t; typedef unsigned long ogp_uint32_t; typedef unsigned __int64 ogp_uint64_t; typedef signed char ogp_int8_t; typedef signed short ogp_int16_t; typedef signed long ogp_int32_t; typedef signed __int64 ogp_int64_t; typedef char OGP_CHAR; #if defined(SWIGJAVA) %typemap(in) (char *BYTE, int LENGTH) { /* Functions from jni.h */ $1 = (char *) JCALL2(GetByteArrayElements, jenv, $input, 0); $2 = (int) JCALL1(GetArrayLength, jenv, $input); } %typemap(jni) (char *BYTE, int LENGTH) "jbyteArray" %typemap(jtype) (char *BYTE, int LENGTH) "byte[]" %typemap(jstype) (char *BYTE, int LENGTH) "byte[]" %typemap(javain) (char *BYTE, int LENGTH) "$javainput" %typemap(argout) char *BYTE { JCALL3(ReleaseByteArrayElements, jenv, $input, (jbyte *) $1, 0); } %typemap(javain) char *BYTE "$javainput" %typemap(freearg) char *BYTE "" /* Specify signature of method to handle */ %apply (char *BYTE, int LENGTH) { (char * byteArray, long len) }; #else %apply (char *STRING, int LENGTH) { (char * byteArray, long len) }; #endif and works good, only exception is the missing director class functions for class OGPCallbacks { public: virtual ~OGPCallbacks() { } virtual void SendTo(char *BYTE, int LENGTH, const char* addrstr, int port) { } virtual void UpdateServerData(ogp_serverdata_t* pServerData) { } virtual int IsBanned(const char* addrstr) { return 0; } }; or better for the sendto function only someone knows where the problem is or how the missing typemap looks like? regards Stefan R. |