Re: How to handle void*, void** in JNI Layer!!
From: Atul Jawale (atuljawale_at_yahoo.com)
Date: 11/30/04
- Next message: Gordon Beaton: "Re: How to handle void*, void** in JNI Layer!!"
- Previous message: Steve: "Re: Java Website"
- In reply to: Atul Jawale: "How to handle void*, void** in JNI Layer!!"
- Next in thread: Gordon Beaton: "Re: How to handle void*, void** in JNI Layer!!"
- Reply: Gordon Beaton: "Re: How to handle void*, void** in JNI Layer!!"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 30 Nov 2004 05:21:10 -0800
Example for this is :
JAVA Layer :
public class MyInteger implements java.io.Serializable
{
public int value;
}
Calling this function in Java file as :
MyInteger obj = new MyInteger();
obj.value = 10;
inVoidStar(obj);
JNI Layer, Now I want to pass jobject to in_void_star() C functions?
Same thing for the values which comes as out value from C to Java as
VOID**?
JNIEXPORT void JNICALL Java_1impl_inVoidStar(JNIEnv *env, jobject
_pObject, jobject void_obj)
{
/*
jclass cls = env->GetObjectClass(void_obj);
jfieldID fid = env->GetFieldID(cls,"value", "I");
int value = env->GetIntField(void_obj, fid);
void *void_ptr = &value;
*/
int API_status = in_void_star((void*)void_obj);
} // inVoidStar
C Layer :
extern int in_void_star(void* ptr)
{
int *p = (int*)ptr;
printf("in_void_star() : %d\n", *p);
return 0;
}
-----------------------------------------------------------------------
atuljawale@yahoo.com (Atul Jawale) wrote in message news:<657b7b97.0411250332.722172d1@posting.google.com>...
> Hi,
>
> We are writing some Wrapper Methods in Java for the existing C
> Methods. So, while calling C Method from Java we have to go thru JNI
> layer where one has to Marshal and Unmarshal arguments in Java to
> C(for input type of argument)and C to Java (for Output type of
> argumemts).
>
> I got stuck in handling void*, void** kind of parameters in C
> functions. I have done some work on this but I think it is not
> sufficient.
>
> Mapping for JAVA - JNI : Object - jobject
> Now, I want to convert this jobject parameter in to void* while
> passing this into C land.
>
> Mapping for JAVA - JNI : Object[] - jobjectArray
> Now, I want to convert this jobjectArray parameter in to void* while
> passing this into C land.
>
> Can anyone suggest some way to convert obejcts?
>
> Thanks,
> Atul
- Next message: Gordon Beaton: "Re: How to handle void*, void** in JNI Layer!!"
- Previous message: Steve: "Re: Java Website"
- In reply to: Atul Jawale: "How to handle void*, void** in JNI Layer!!"
- Next in thread: Gordon Beaton: "Re: How to handle void*, void** in JNI Layer!!"
- Reply: Gordon Beaton: "Re: How to handle void*, void** in JNI Layer!!"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|