Posted By:
Anonymous
Posted On:
Monday, July 29, 2002 02:01 AM
Hi! Im working on a project that involves the use of JNI. My question goes this way. I have to call a C++ function that stores information on a parameter. m_pMedMp->GET_BalanceInfo(o_eBalanceAry); The function GET_BalanceInfo retrieves balance information and stores it in o_eBalanceAry. o_eBalanceAry is defined as structure whose definition is below. struct { unsigned char ucCategory; // (Category) unsigned char ucBalance[4]; // (Balance) } ENBalance; I made a java class that implements this struct.
More>>
Hi! Im working on a project
that involves the use of JNI.
My question goes this way. I have to call a C++ function that stores information
on a parameter.
m_pMedMp->GET_BalanceInfo(o_eBalanceAry);
The function GET_BalanceInfo
retrieves balance information and stores it in o_eBalanceAry. o_eBalanceAry
is defined as structure whose definition is below.
struct {
unsigned char ucCategory; // (Category)
unsigned char ucBalance[4]; // (Balance)
} ENBalance;
I made a java class that
implements this struct.
class ENBalance {
char ucCategory;
char ucBalance[];
/** Creates new ENBalance*/
public ENBalance() {
ucBalance = new char[4];
}
}
After that ive implemented
the JNI of the GET_BalanceInfo function. My problem is how do i access ENBalance's
member array variable ucBalance? I have no problems accessing and assigning
values to ucCategory. Here's the code
JNIEXPORT void JNICALL
Java_JmedMultiPockets_GET_1BalanceInfo (JNIEnv *env, jobject obj, jobject o_pBalanceAry){
jclass cls = env->GetObjectClass(o_pBalanceAry);
jfieldID fid;
ENCardInfo m_eCardInfo;
// C++ implementation
of Get Balance info here//
m_pMedMp->GET_BalanceInfo(o_eBalanceAry);
// setting of ENBalance on java class //
ucCategory fid = env->GetFieldID(cls, "ucCategory", "C");
if (fid != 0) {
env->SetCharField(obj, fid, o_eBalanceAry.ucCategory);
}
}
I hope to hear from anyone
soon. Thanks in advance!
Mao Ronan
<<Less