add dict_getStartsWith to jni

This commit is contained in:
Andy2 2011-11-01 18:43:36 -07:00
parent 482aca5cfb
commit 9f2158f094
2 changed files with 24 additions and 0 deletions

View file

@ -1455,4 +1455,26 @@ Java_org_eehouse_android_xw4_jni_XwJNI_dict_1iter_1nthWord
}
return result;
}
JNIEXPORT jint JNICALL
Java_org_eehouse_android_xw4_jni_XwJNI_dict_1iter_1getStartsWith
( JNIEnv* env, jclass C, jint closure, jstring jprefix )
{
jint result = -1;
DictIterData* data = (DictIterData*)closure;
if ( NULL != data ) {
Tile tiles[MAX_COLS];
XP_U16 nTiles = VSIZE(tiles);
const char* prefix = (*env)->GetStringUTFChars( env, jprefix, NULL );
if ( dict_tilesForString( data->dict, prefix, tiles, &nTiles ) ) {
IndexData* idata = NULL;
DictPosition pos = dict_getStartsWith( data->dict, idata, tiles,
nTiles );
result = pos;
}
(*env)->ReleaseStringUTFChars( env, jprefix, prefix );
}
return result;
}
#endif /* XWFEATURE_BOARDWORDS */

View file

@ -244,4 +244,6 @@ public class XwJNI {
public static native void dict_iter_makeIndex( int closure );
public static native String[] dict_iter_getPrefixes( int closure );
public static native int[] dict_iter_getIndices( int closure );
public static native int dict_iter_getStartsWith( int closure,
String prefix );
}