Closed GoogleCodeExporter closed 8 years ago
Could you try again with
public native int callBtSco(int argc, PointerPointer argv);
?
Original comment by samuel.a...@gmail.com
on 25 Feb 2012 at 1:16
It's better but it still fails because of my Java code.
I'm not used to manipulate generic parameters.
<code>
public native int callBtSco(int argc, PointerPointer argv);
public void start()
{
String l_param1 = new String("-vr");
String l_param2 = new String("00:01:02:03:04:05");
char[] l_argv1 = l_param1.toCharArray();
char[] l_argv2 = l_param2.toCharArray();
PointerPointer l_argv = new PointerPointer(l_argv1, l_argv2);
callBtSco(2, l_argv);
}
</code>
<error>
/home/fabien/workspace/btScoTest/bin/classes/com/test/btsco/jniBtSco.cpp: In
function 'jint Java_com_test_btsco_BtSco_00024BtScoClass_callBtSco(JNIEnv*,
_jobject*, jint, _jobject*)':
/home/fabien/workspace/btScoTest/bin/classes/com/test/btsco/jniBtSco.cpp:752:
error: invalid conversion from 'void**' to 'char**'
/home/fabien/workspace/btScoTest/bin/classes/com/test/btsco/jniBtSco.cpp:752:
error: initializing argument 2 of 'int BtSco::BtScoClass::callBtSco(int,
char**)'
</error>
<jniCode>
JNIEXPORT jint JNICALL
Java_com_test_btsco_BtSco_00024BtScoClass_callBtSco(JNIEnv* e, jobject o, jint
p0, jobject p1) {
BtSco::BtScoClass* pointer = (BtSco::BtScoClass*)jlong_to_ptr(e->GetLongField(o, JavaCPP_addressFieldID));
if (pointer == NULL) {
e->ThrowNew(JavaCPP_getClass(e, 1), "This pointer address is NULL.");
return 0;
}
jint position = e->GetIntField(o, JavaCPP_positionFieldID);
pointer += position;
void** pointer1 = p1 == NULL ? NULL : (void**)jlong_to_ptr(e->GetLongField(p1, JavaCPP_addressFieldID));
jint position1 = p1 == NULL ? 0 : e->GetIntField(p1, JavaCPP_positionFieldID);
pointer1 += position1;
jint r = 0;
try {
int rvalue = pointer->callBtSco(p0, pointer1);
r = (jint)rvalue;
} catch (...) {
JavaCPP_handleException(e);
}
return r;
}
</jniCode>
Original comment by theedge...@gmail.com
on 27 Feb 2012 at 2:38
Right, we need an explicit cast:
public native int callBtSco(int argc, @Cast("char**") PointerPointer argv);
And to build a valid PointerPointer for that use case, we can do something like
this:
PointerPointer l_argv = new PointerPointer(new BytePointer(l_param1), new BytePointer(l_param2));
If you need something else than UTF-8, use the other BytePointer constructor to
specify the required character encoding.
Original comment by samuel.a...@gmail.com
on 28 Feb 2012 at 3:08
Thanks Samuel,
It compiles.
Now I have the issue "library not found".
I'll post it on the forum.
You can close this issue.
Original comment by theedge...@gmail.com
on 28 Feb 2012 at 3:47
It it does not sound like a bug, please post your question on the mailing list
if possible, thank you!
I will keep this issue opened and fix the incorrectly generated code above...
it should give us a warning instead.
Original comment by samuel.a...@gmail.com
on 29 Feb 2012 at 2:43
BTW, I haven't seen any message on the forum asking about the "library not
found" problem, have you solved it?
In any case, latest release now properly outputs a warning instead of
generating incorrect code for non-primitive arrays. Thanks for the feedback!
Original comment by samuel.a...@gmail.com
on 3 Mar 2012 at 4:49
I think I have problems with the NDK compiler.
I'll get back when I clarify things.
Thanks for the fix.
Original comment by theedge...@gmail.com
on 3 Mar 2012 at 9:49
Original issue reported on code.google.com by
theedge...@gmail.com
on 24 Feb 2012 at 3:19