mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-30 08:34:16 +01:00
oops: set typeset field in java struct
This commit is contained in:
parent
ebfe8ceb28
commit
2e74b97b4a
3 changed files with 21 additions and 10 deletions
|
@ -1,4 +1,4 @@
|
||||||
/* -*-mode: C; compile-command: "cd ..; ../scripts/ndkbuild.sh -j3"; -*- */
|
/* -*- compile-command: "find-and-ant.sh debug install"; -*- */
|
||||||
/*
|
/*
|
||||||
* Copyright © 2009-2010 by Eric House (xwords@eehouse.org). All
|
* Copyright © 2009-2010 by Eric House (xwords@eehouse.org). All
|
||||||
* rights reserved.
|
* rights reserved.
|
||||||
|
@ -418,20 +418,27 @@ getMethodID( JNIEnv* env, jobject obj, const char* proc, const char* sig )
|
||||||
return mid;
|
return mid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
setTypeSetFieldIn( JNIEnv* env, const CommsAddrRec* addr, jobject jTarget,
|
||||||
|
const char* fieldName )
|
||||||
|
{
|
||||||
|
jobject jtypset = addrTypesToJ( env, addr );
|
||||||
|
XP_ASSERT( !!jtypset );
|
||||||
|
jclass cls = (*env)->GetObjectClass( env, jTarget );
|
||||||
|
XP_ASSERT( !!cls );
|
||||||
|
jfieldID fid = (*env)->GetFieldID( env, cls, fieldName, //"conTypes",
|
||||||
|
"L" PKG_PATH("jni/CommsAddrRec$CommsConnTypeSet") ";" );
|
||||||
|
XP_ASSERT( !!fid );
|
||||||
|
(*env)->SetObjectField( env, jTarget, fid, jtypset );
|
||||||
|
deleteLocalRef( env, jtypset );
|
||||||
|
}
|
||||||
|
|
||||||
/* Copy C object data into Java object */
|
/* Copy C object data into Java object */
|
||||||
void
|
void
|
||||||
setJAddrRec( JNIEnv* env, jobject jaddr, const CommsAddrRec* addr )
|
setJAddrRec( JNIEnv* env, jobject jaddr, const CommsAddrRec* addr )
|
||||||
{
|
{
|
||||||
XP_ASSERT( !!addr );
|
XP_ASSERT( !!addr );
|
||||||
jobject jtypset = addrTypesToJ( env, addr );
|
setTypeSetFieldIn( env, addr, jaddr, "conTypes" );
|
||||||
XP_ASSERT( !!jtypset );
|
|
||||||
jclass cls = (*env)->GetObjectClass( env, jaddr );
|
|
||||||
XP_ASSERT( !!cls );
|
|
||||||
jfieldID fid = (*env)->GetFieldID( env, cls, "conTypes",
|
|
||||||
"L" PKG_PATH("jni/CommsAddrRec$CommsConnTypeSet") ";" );
|
|
||||||
XP_ASSERT( !!fid );
|
|
||||||
(*env)->SetObjectField( env, jaddr, fid, jtypset );
|
|
||||||
deleteLocalRefs( env, cls, jtypset, DELETE_NO_REF );
|
|
||||||
|
|
||||||
CommsConnType typ;
|
CommsConnType typ;
|
||||||
for ( XP_U32 st = 0; addr_iter( addr, &typ, &st ); ) {
|
for ( XP_U32 st = 0; addr_iter( addr, &typ, &st ); ) {
|
||||||
|
|
|
@ -84,6 +84,8 @@ jmethodID getMethodID( JNIEnv* env, jobject obj, const char* proc,
|
||||||
|
|
||||||
void setJAddrRec( JNIEnv* env, jobject jaddr, const CommsAddrRec* addr );
|
void setJAddrRec( JNIEnv* env, jobject jaddr, const CommsAddrRec* addr );
|
||||||
void getJAddrRec( JNIEnv* env, CommsAddrRec* addr, jobject jaddr );
|
void getJAddrRec( JNIEnv* env, CommsAddrRec* addr, jobject jaddr );
|
||||||
|
void setTypeSetFieldIn( JNIEnv* env, const CommsAddrRec* addr, jobject jTarget,
|
||||||
|
const char* fldName );
|
||||||
jobject addrTypesToJ( JNIEnv* env, const CommsAddrRec* addr );
|
jobject addrTypesToJ( JNIEnv* env, const CommsAddrRec* addr );
|
||||||
jint jenumFieldToInt( JNIEnv* env, jobject jobj, const char* field,
|
jint jenumFieldToInt( JNIEnv* env, jobject jobj, const char* field,
|
||||||
const char* fieldSig );
|
const char* fieldSig );
|
||||||
|
|
|
@ -1346,6 +1346,8 @@ Java_org_eehouse_android_xw4_jni_XwJNI_game_1summarize
|
||||||
setInt( env, jsummary, "nPacketsPending",
|
setInt( env, jsummary, "nPacketsPending",
|
||||||
comms_countPendingPackets( state->game.comms ) );
|
comms_countPendingPackets( state->game.comms ) );
|
||||||
|
|
||||||
|
setTypeSetFieldIn( env, &addr, jsummary, "conTypes" );
|
||||||
|
|
||||||
CommsConnType typ;
|
CommsConnType typ;
|
||||||
for ( XP_U32 st = 0; addr_iter( &addr, &typ, &st ); ) {
|
for ( XP_U32 st = 0; addr_iter( &addr, &typ, &st ); ) {
|
||||||
switch( typ ) {
|
switch( typ ) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue