From f50e6b3f1b37f19ebd549da55fabac4ce8c9afd7 Mon Sep 17 00:00:00 2001 From: Andy2 Date: Mon, 6 Dec 2010 18:25:23 -0800 Subject: [PATCH] turn dict_getLangCode into dict_getInfo, adding a struct that contains lang code and new word count. --- xwords4/android/XWords4/jni/xwjni.c | 11 +++++--- .../org/eehouse/android/xw4/jni/DictInfo.java | 26 +++++++++++++++++++ .../org/eehouse/android/xw4/jni/XwJNI.java | 3 ++- 3 files changed, 35 insertions(+), 5 deletions(-) create mode 100644 xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/DictInfo.java diff --git a/xwords4/android/XWords4/jni/xwjni.c b/xwords4/android/XWords4/jni/xwjni.c index fb21adc95..526c5b1dc 100644 --- a/xwords4/android/XWords4/jni/xwjni.c +++ b/xwords4/android/XWords4/jni/xwjni.c @@ -260,9 +260,9 @@ Java_org_eehouse_android_xw4_jni_XwJNI_comms_1getInitialAddr setJAddrRec( env, jaddr, &addr ); } -JNIEXPORT jint JNICALL -Java_org_eehouse_android_xw4_jni_XwJNI_dict_1getLanguageCode -(JNIEnv* env, jclass C, jbyteArray jDictBytes, jobject jniu ) +JNIEXPORT void JNICALL +Java_org_eehouse_android_xw4_jni_XwJNI_dict_1getInfo +(JNIEnv* env, jclass C, jbyteArray jDictBytes, jobject jniu, jobject jinfo ) { #ifdef MEM_DEBUG MemPoolCtx* mpool = mpool_make(); @@ -271,12 +271,15 @@ Java_org_eehouse_android_xw4_jni_XwJNI_dict_1getLanguageCode DictionaryCtxt* dict = makeDict( MPPARM(mpool) env, jniutil, jDictBytes, NULL ); jint code = dict_getLangCode( dict ); + jint nWords = dict_getWordCount( dict ); dict_destroy( dict ); destroyJNIUtil( &jniutil ); + + setInt( env, jinfo, "langCode", code ); + setInt( env, jinfo, "wordCount", nWords ); #ifdef MEM_DEBUG mpool_destroy( mpool ); #endif - return code; } /* Dictionary methods: don't use gamePtr */ diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/DictInfo.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/DictInfo.java new file mode 100644 index 000000000..825f9ecf9 --- /dev/null +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/DictInfo.java @@ -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; +}; diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/XwJNI.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/XwJNI.java index 5810b2053..affde8755 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/XwJNI.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/XwJNI.java @@ -208,5 +208,6 @@ public class XwJNI { // Dicts public static native boolean dict_tilesAreSame( int dictPtr1, int dictPtr2 ); 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 ); }