mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-16 15:41:16 +01:00
add makeByteArray()
This commit is contained in:
parent
8def96dd59
commit
333c5fc040
2 changed files with 24 additions and 10 deletions
|
@ -1,4 +1,4 @@
|
||||||
/* -*-mode: C; compile-command: "cd XWords4; ../scripts/ndkbuild.sh"; -*- */
|
/* -*-mode: C; compile-command: "../../scripts/ndkbuild.sh"; -*- */
|
||||||
|
|
||||||
#include "andutils.h"
|
#include "andutils.h"
|
||||||
|
|
||||||
|
@ -60,10 +60,9 @@ getInt( JNIEnv* env, jobject obj, const char* name, int* result )
|
||||||
bool success = false;
|
bool success = false;
|
||||||
jclass cls = (*env)->GetObjectClass( env, obj );
|
jclass cls = (*env)->GetObjectClass( env, obj );
|
||||||
jfieldID fid = (*env)->GetFieldID( env, cls, name, "I");
|
jfieldID fid = (*env)->GetFieldID( env, cls, name, "I");
|
||||||
if ( 0 != fid ) {
|
XP_ASSERT( !!fid );
|
||||||
*result = (*env)->GetIntField( env, obj, fid );
|
*result = (*env)->GetIntField( env, obj, fid );
|
||||||
success = true;
|
success = true;
|
||||||
}
|
|
||||||
(*env)->DeleteLocalRef( env, cls );
|
(*env)->DeleteLocalRef( env, cls );
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
@ -74,10 +73,9 @@ setInt( JNIEnv* env, jobject obj, const char* name, int value )
|
||||||
bool success = false;
|
bool success = false;
|
||||||
jclass cls = (*env)->GetObjectClass( env, obj );
|
jclass cls = (*env)->GetObjectClass( env, obj );
|
||||||
jfieldID fid = (*env)->GetFieldID( env, cls, name, "I");
|
jfieldID fid = (*env)->GetFieldID( env, cls, name, "I");
|
||||||
if ( 0 != fid ) {
|
XP_ASSERT( !!fid );
|
||||||
(*env)->SetIntField( env, obj, fid, value );
|
(*env)->SetIntField( env, obj, fid, value );
|
||||||
success = true;
|
success = true;
|
||||||
}
|
|
||||||
(*env)->DeleteLocalRef( env, cls );
|
(*env)->DeleteLocalRef( env, cls );
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
@ -185,6 +183,20 @@ makeIntArray( JNIEnv *env, int siz, const jint* vals )
|
||||||
return array;
|
return array;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
jbyteArray
|
||||||
|
makeByteArray( JNIEnv *env, int siz, const jbyte* vals )
|
||||||
|
{
|
||||||
|
jbyteArray array = (*env)->NewByteArray( env, siz );
|
||||||
|
XP_ASSERT( !!array );
|
||||||
|
if ( !!vals ) {
|
||||||
|
jbyte* elems = (*env)->GetByteArrayElements( env, array, NULL );
|
||||||
|
XP_ASSERT( !!elems );
|
||||||
|
XP_MEMCPY( elems, vals, siz * sizeof(*elems) );
|
||||||
|
(*env)->ReleaseByteArrayElements( env, array, elems, 0 );
|
||||||
|
}
|
||||||
|
return array;
|
||||||
|
}
|
||||||
|
|
||||||
jbooleanArray
|
jbooleanArray
|
||||||
makeBooleanArray( JNIEnv *env, int siz, const jboolean* vals )
|
makeBooleanArray( JNIEnv *env, int siz, const jboolean* vals )
|
||||||
{
|
{
|
||||||
|
|
|
@ -27,7 +27,9 @@ bool getObject( JNIEnv* env, jobject obj, const char* name, const char* sig,
|
||||||
jintArray makeIntArray( JNIEnv *env, int size, const jint* vals );
|
jintArray makeIntArray( JNIEnv *env, int size, const jint* vals );
|
||||||
int getIntFromArray( JNIEnv* env, jintArray arr, bool del );
|
int getIntFromArray( JNIEnv* env, jintArray arr, bool del );
|
||||||
|
|
||||||
jbooleanArray makeBooleanArray( JNIEnv *env, int size, const jboolean* vals );
|
jbyteArray makeByteArray( JNIEnv* env, int size, const jbyte* vals );
|
||||||
|
|
||||||
|
jbooleanArray makeBooleanArray( JNIEnv* env, int size, const jboolean* vals );
|
||||||
|
|
||||||
jobjectArray makeStringArray( JNIEnv *env, int size, const XP_UCHAR** vals );
|
jobjectArray makeStringArray( JNIEnv *env, int size, const XP_UCHAR** vals );
|
||||||
jstring streamToJString( MPFORMAL JNIEnv* env, XWStreamCtxt* stream );
|
jstring streamToJString( MPFORMAL JNIEnv* env, XWStreamCtxt* stream );
|
||||||
|
|
Loading…
Reference in a new issue