turn dict_getLangCode into dict_getInfo, adding a struct that contains

lang code and new word count.
This commit is contained in:
Andy2 2010-12-06 18:25:23 -08:00
parent e4999acc98
commit f50e6b3f1b
3 changed files with 35 additions and 5 deletions

View file

@ -260,9 +260,9 @@ Java_org_eehouse_android_xw4_jni_XwJNI_comms_1getInitialAddr
setJAddrRec( env, jaddr, &addr ); setJAddrRec( env, jaddr, &addr );
} }
JNIEXPORT jint JNICALL JNIEXPORT void JNICALL
Java_org_eehouse_android_xw4_jni_XwJNI_dict_1getLanguageCode Java_org_eehouse_android_xw4_jni_XwJNI_dict_1getInfo
(JNIEnv* env, jclass C, jbyteArray jDictBytes, jobject jniu ) (JNIEnv* env, jclass C, jbyteArray jDictBytes, jobject jniu, jobject jinfo )
{ {
#ifdef MEM_DEBUG #ifdef MEM_DEBUG
MemPoolCtx* mpool = mpool_make(); MemPoolCtx* mpool = mpool_make();
@ -271,12 +271,15 @@ Java_org_eehouse_android_xw4_jni_XwJNI_dict_1getLanguageCode
DictionaryCtxt* dict = makeDict( MPPARM(mpool) env, jniutil, DictionaryCtxt* dict = makeDict( MPPARM(mpool) env, jniutil,
jDictBytes, NULL ); jDictBytes, NULL );
jint code = dict_getLangCode( dict ); jint code = dict_getLangCode( dict );
jint nWords = dict_getWordCount( dict );
dict_destroy( dict ); dict_destroy( dict );
destroyJNIUtil( &jniutil ); destroyJNIUtil( &jniutil );
setInt( env, jinfo, "langCode", code );
setInt( env, jinfo, "wordCount", nWords );
#ifdef MEM_DEBUG #ifdef MEM_DEBUG
mpool_destroy( mpool ); mpool_destroy( mpool );
#endif #endif
return code;
} }
/* Dictionary methods: don't use gamePtr */ /* Dictionary methods: don't use gamePtr */

View file

@ -0,0 +1,26 @@
/* -*- compile-command: "cd ../../../../../../; ant install"; -*- */
/*
* Copyright 2009-2010 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.
*/
package org.eehouse.android.xw4.jni;
public class DictInfo {
public int langCode;
public int wordCount;
};

View file

@ -208,5 +208,6 @@ public class XwJNI {
// Dicts // Dicts
public static native boolean dict_tilesAreSame( int dictPtr1, int dictPtr2 ); public static native boolean dict_tilesAreSame( int dictPtr1, int dictPtr2 );
public static native String[] dict_getChars( int dictPtr ); public static native String[] dict_getChars( int dictPtr );
public static native int dict_getLanguageCode( byte[] dict, JNIUtils jniu ); public static native void dict_getInfo( byte[] dict, JNIUtils jniu,
DictInfo info );
} }