diff --git a/xwords4/android/XWords4/jni/andutils.c b/xwords4/android/XWords4/jni/andutils.c index 25d50245b..925e6e9e4 100644 --- a/xwords4/android/XWords4/jni/andutils.c +++ b/xwords4/android/XWords4/jni/andutils.c @@ -22,6 +22,7 @@ #include #include "andutils.h" +#include "paths.h" #include "comtypes.h" #include "xwstream.h" @@ -320,7 +321,7 @@ setJAddrRec( JNIEnv* env, jobject jaddr, const CommsAddrRec* addr ) { XP_ASSERT( !!addr ); intToJenumField( env, jaddr, addr->conType, "conType", - "org/eehouse/android/xw4/jni/CommsAddrRec$CommsConnType" ); + PKG_PATH("jni/CommsAddrRec$CommsConnType") ); switch ( addr->conType ) { case COMMS_CONN_NONE: @@ -348,9 +349,9 @@ setJAddrRec( JNIEnv* env, jobject jaddr, const CommsAddrRec* addr ) void getJAddrRec( JNIEnv* env, CommsAddrRec* addr, jobject jaddr ) { - addr->conType = jenumFieldToInt( env, jaddr, "conType", - "org/eehouse/android/xw4/jni/" - "CommsAddrRec$CommsConnType" ); + addr->conType = + jenumFieldToInt( env, jaddr, "conType", + PKG_PATH("jni/CommsAddrRec$CommsConnType") ); switch ( addr->conType ) { case COMMS_CONN_NONE: diff --git a/xwords4/android/XWords4/jni/drawwrapper.c b/xwords4/android/XWords4/jni/drawwrapper.c index e9e449c8e..fe072416b 100644 --- a/xwords4/android/XWords4/jni/drawwrapper.c +++ b/xwords4/android/XWords4/jni/drawwrapper.c @@ -20,6 +20,7 @@ #include "drawwrapper.h" #include "andutils.h" +#include "paths.h" enum { JCACHE_RECT0 @@ -75,8 +76,7 @@ makeDSI( AndDraw* draw, int indx, const DrawScoreInfo* dsi ) jobject dsiobj = draw->jCache[indx]; if ( !dsiobj ) { - jclass rclass = (*env)->FindClass( env, "org/eehouse/android/" - "xw4/jni/DrawScoreInfo"); + jclass rclass = (*env)->FindClass( env, PKG_PATH("jni/DrawScoreInfo") ); jmethodID initId = (*env)->GetMethodID( env, rclass, "", "()V" ); dsiobj = (*env)->NewObject( env, rclass, initId ); (*env)->DeleteLocalRef( env, rclass ); @@ -153,8 +153,8 @@ and_draw_measureScoreText( DrawCtx* dctx, XP_U16* width, XP_U16* height ) { DRAW_CBK_HEADER("measureScoreText", - "(Landroid/graphics/Rect;Lorg/eehouse/android/" - "xw4/jni/DrawScoreInfo;[I[I)V" ); + "(Landroid/graphics/Rect;L" + PKG_PATH("jni/DrawScoreInfo;[I[I)V") ); jobject jrect = makeJRect( draw, JCACHE_RECT0, r ); jobject jdsi = makeDSI( draw, JCACHE_DSI, dsi ); @@ -192,7 +192,7 @@ and_draw_score_drawPlayer( DrawCtx* dctx, { DRAW_CBK_HEADER("score_drawPlayer", "(Landroid/graphics/Rect;Landroid/graphics/Rect;" - "Lorg/eehouse/android/xw4/jni/DrawScoreInfo;)V" ); + "L" PKG_PATH("jni/DrawScoreInfo") ";)V" ); jobject jrinner = makeJRect( draw, JCACHE_RECT0, rInner ); jobject jrouter = makeJRect( draw, JCACHE_RECT1, rOuter ); diff --git a/xwords4/android/XWords4/jni/paths.h b/xwords4/android/XWords4/jni/paths.h new file mode 100644 index 000000000..6c6b51037 --- /dev/null +++ b/xwords4/android/XWords4/jni/paths.h @@ -0,0 +1,25 @@ +/* -*-mode: C; compile-command: "../../scripts/ndkbuild.sh"; -*- */ +/* + * Copyright © 2012 by Eric House (xwords@eehouse.org). All rights reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifndef _PATHS_H_ +#define _PATHS_H_ + +#define PKG_PATH(elem) "org/eehouse/android/xw4/" elem + +#endif diff --git a/xwords4/android/XWords4/jni/xportwrapper.c b/xwords4/android/XWords4/jni/xportwrapper.c index 656be5fc6..f0e0bfc65 100644 --- a/xwords4/android/XWords4/jni/xportwrapper.c +++ b/xwords4/android/XWords4/jni/xportwrapper.c @@ -20,6 +20,7 @@ #include "xportwrapper.h" #include "andutils.h" +#include "paths.h" typedef struct _AndTransportProcs { TransportProcs tp; @@ -34,7 +35,7 @@ makeJAddr( JNIEnv* env, const CommsAddrRec* addr ) jobject jaddr = NULL; if ( NULL != addr ) { jclass clazz - = (*env)->FindClass(env, "org/eehouse/android/xw4/jni/CommsAddrRec"); + = (*env)->FindClass(env, PKG_PATH("jni/CommsAddrRec") ); XP_ASSERT( !!clazz ); jmethodID mid = getMethodID( env, clazz, "", "()V" ); XP_ASSERT( !!mid ); @@ -73,7 +74,7 @@ and_xport_send( const XP_U8* buf, XP_U16 len, const CommsAddrRec* addr, AndTransportProcs* aprocs = (AndTransportProcs*)closure; if ( NULL != aprocs->jxport ) { JNIEnv* env = *aprocs->envp; - const char* sig = "([BLorg/eehouse/android/xw4/jni/CommsAddrRec;)I"; + const char* sig = "([BL" PKG_PATH("jni/CommsAddrRec") ";)I"; jmethodID mid = getMethodID( env, aprocs->jxport, "transportSend", sig ); jbyteArray jbytes = makeByteArray( env, len, (jbyte*)buf ); @@ -98,12 +99,11 @@ and_xport_relayStatus( void* closure, CommsRelayState newState ) AndTransportProcs* aprocs = (AndTransportProcs*)closure; if ( NULL != aprocs->jxport ) { JNIEnv* env = *aprocs->envp; - const char* sig = "(Lorg/eehouse/android/xw4/jni/" - "TransportProcs$CommsRelayState;)V"; + const char* sig = "(L" PKG_PATH("jni/TransportProcs$CommsRelayState") ";)V"; jmethodID mid = getMethodID( env, aprocs->jxport, "relayStatus", sig ); - jobject jenum = intToJEnum( env, newState, "org/eehouse/android/xw4/jni/" - "TransportProcs$CommsRelayState" ); + jobject jenum = intToJEnum( env, newState, + PKG_PATH("jni/TransportProcs$CommsRelayState") ); (*env)->CallVoidMethod( env, aprocs->jxport, mid, jenum ); (*env)->DeleteLocalRef( env, jenum ); } @@ -155,12 +155,12 @@ and_xport_relayError( void* closure, XWREASON relayErr ) if ( NULL != aprocs->jxport ) { JNIEnv* env = *aprocs->envp; jmethodID mid; - const char* sig = "(Lorg/eehouse/android/xw4/jni/" - "TransportProcs$XWRELAY_ERROR;)V"; + const char* sig = + "(L" PKG_PATH("jni/TransportProcs$XWRELAY_ERROR") ";)V"; mid = getMethodID( env, aprocs->jxport, "relayErrorProc", sig ); - jobject jenum = intToJEnum( env, relayErr, "org/eehouse/android/xw4/jni/" - "TransportProcs$XWRELAY_ERROR" ); + jobject jenum = intToJEnum( env, relayErr, + PKG_PATH("jni/TransportProcs$XWRELAY_ERROR") ); (*env)->CallVoidMethod( env, aprocs->jxport, mid, jenum ); (*env)->DeleteLocalRef( env, jenum ); diff --git a/xwords4/android/XWords4/jni/xwjni.c b/xwords4/android/XWords4/jni/xwjni.c index 4adbc9fa8..2879c0ea5 100644 --- a/xwords4/android/XWords4/jni/xwjni.c +++ b/xwords4/android/XWords4/jni/xwjni.c @@ -37,6 +37,7 @@ #include "anddict.h" #include "andutils.h" #include "jniutlswrapper.h" +#include "paths.h" static CurGameInfo* makeGI( MPFORMAL JNIEnv* env, jobject j_gi ) @@ -65,12 +66,12 @@ makeGI( MPFORMAL JNIEnv* env, jobject j_gi ) gi->allowPickTiles = getBool( env, j_gi, "allowPickTiles" ); gi->allowHintRect = getBool( env, j_gi, "allowHintRect" ); - gi->phoniesAction = jenumFieldToInt( env, j_gi, "phoniesAction", - "org/eehouse/android/xw4/jni/" - "CurGameInfo$XWPhoniesChoice"); + gi->phoniesAction = + jenumFieldToInt( env, j_gi, "phoniesAction", + PKG_PATH("jni/CurGameInfo$XWPhoniesChoice") ); gi->serverRole = - jenumFieldToInt( env, j_gi, "serverRole", - "org/eehouse/android/xw4/jni/CurGameInfo$DeviceRole"); + jenumFieldToInt( env, j_gi, "serverRole", + PKG_PATH("jni/CurGameInfo$DeviceRole")); getString( env, j_gi, "dictName", buf, VSIZE(buf) ); gi->dictName = copyString( mpool, buf ); @@ -78,8 +79,7 @@ makeGI( MPFORMAL JNIEnv* env, jobject j_gi ) XP_ASSERT( gi->nPlayers <= MAX_NUM_PLAYERS ); jobject jplayers; - if ( getObject( env, j_gi, "players", - "[Lorg/eehouse/android/xw4/jni/LocalPlayer;", + if ( getObject( env, j_gi, "players", "[L" PKG_PATH("jni/LocalPlayer") ";", &jplayers ) ) { int ii; for ( ii = 0; ii < gi->nPlayers; ++ii ) { @@ -125,13 +125,13 @@ setJGI( JNIEnv* env, jobject jgi, const CurGameInfo* gi ) setString( env, jgi, "dictName", gi->dictName ); intToJenumField( env, jgi, gi->phoniesAction, "phoniesAction", - "org/eehouse/android/xw4/jni/CurGameInfo$XWPhoniesChoice" ); + PKG_PATH("jni/CurGameInfo$XWPhoniesChoice") ); intToJenumField( env, jgi, gi->serverRole, "serverRole", - "org/eehouse/android/xw4/jni/CurGameInfo$DeviceRole" ); + PKG_PATH("jni/CurGameInfo$DeviceRole") ); jobject jplayers; if ( getObject( env, jgi, "players", - "[Lorg/eehouse/android/xw4/jni/LocalPlayer;", + "[L" PKG_PATH("jni/LocalPlayer") ";", &jplayers ) ) { int ii; for ( ii = 0; ii < gi->nPlayers; ++ii ) { @@ -1077,8 +1077,7 @@ Java_org_eehouse_android_xw4_jni_XwJNI_game_1summarize CommsCtxt* comms = state->game.comms; comms_getAddr( comms, &addr ); intToJenumField( env, jsummary, addr.conType, "conType", - "org/eehouse/android/xw4/jni/" - "CommsAddrRec$CommsConnType" ); + PKG_PATH("jni/CommsAddrRec$CommsConnType") ); if ( COMMS_CONN_RELAY == addr.conType ) { XP_UCHAR buf[128]; XP_U16 len = VSIZE(buf);