mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-02-04 20:46:28 +01:00
move stream storage into super
This commit is contained in:
parent
2c7568723f
commit
9bc72d0745
3 changed files with 33 additions and 58 deletions
|
@ -494,16 +494,6 @@ and_dutil_storePtr( XW_DUtilCtxt* duc, XWEnv xwe, const XP_UCHAR* key,
|
||||||
DUTIL_CBK_TAIL();
|
DUTIL_CBK_TAIL();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
and_dutil_storeStream( XW_DUtilCtxt* duc, XWEnv xwe, const XP_UCHAR* key,
|
|
||||||
XWStreamCtxt* stream )
|
|
||||||
{
|
|
||||||
const void* ptr = stream_getPtr( stream );
|
|
||||||
XP_U16 len = stream_getSize( stream );
|
|
||||||
|
|
||||||
and_dutil_storePtr( duc, xwe, key, ptr, len );
|
|
||||||
}
|
|
||||||
|
|
||||||
static jbyteArray
|
static jbyteArray
|
||||||
loadToByteArray( XW_DUtilCtxt* duc, XWEnv xwe, const XP_UCHAR* key,
|
loadToByteArray( XW_DUtilCtxt* duc, XWEnv xwe, const XP_UCHAR* key,
|
||||||
const XP_UCHAR* keySuffix )
|
const XP_UCHAR* keySuffix )
|
||||||
|
@ -538,21 +528,6 @@ and_dutil_loadPtr( XW_DUtilCtxt* duc, XWEnv xwe, const XP_UCHAR* key,
|
||||||
*lenp = len;
|
*lenp = len;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
and_dutil_loadStream( XW_DUtilCtxt* duc, XWEnv xwe, const XP_UCHAR* key,
|
|
||||||
const XP_UCHAR* keySuffix, XWStreamCtxt* stream )
|
|
||||||
{
|
|
||||||
JNIEnv* env = xwe;
|
|
||||||
jbyteArray jvalue = loadToByteArray( duc, xwe, key, keySuffix );
|
|
||||||
if ( jvalue != NULL ) {
|
|
||||||
jbyte* jelems = (*env)->GetByteArrayElements( env, jvalue, NULL );
|
|
||||||
jsize len = (*env)->GetArrayLength( env, jvalue );
|
|
||||||
stream_putBytes( stream, jelems, len );
|
|
||||||
(*env)->ReleaseByteArrayElements( env, jvalue, jelems, 0 );
|
|
||||||
deleteLocalRef( env, jvalue );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
and_util_notifyIllegalWords( XW_UtilCtxt* uc, XWEnv xwe, BadWordInfo* bwi,
|
and_util_notifyIllegalWords( XW_UtilCtxt* uc, XWEnv xwe, BadWordInfo* bwi,
|
||||||
XP_U16 turn, XP_Bool turnLost )
|
XP_U16 turn, XP_Bool turnLost )
|
||||||
|
@ -1022,8 +997,6 @@ makeDUtil( MPFORMAL JNIEnv* env,
|
||||||
SET_DPROC(getCurSeconds);
|
SET_DPROC(getCurSeconds);
|
||||||
SET_DPROC(getUserString);
|
SET_DPROC(getUserString);
|
||||||
SET_DPROC(getUserQuantityString);
|
SET_DPROC(getUserQuantityString);
|
||||||
SET_DPROC(storeStream);
|
|
||||||
SET_DPROC(loadStream);
|
|
||||||
SET_DPROC(storePtr);
|
SET_DPROC(storePtr);
|
||||||
SET_DPROC(loadPtr);
|
SET_DPROC(loadPtr);
|
||||||
# ifdef XWFEATURE_DEVID
|
# ifdef XWFEATURE_DEVID
|
||||||
|
|
|
@ -22,6 +22,36 @@
|
||||||
#include "mempool.h"
|
#include "mempool.h"
|
||||||
#include "comtypes.h"
|
#include "comtypes.h"
|
||||||
#include "dutil.h"
|
#include "dutil.h"
|
||||||
|
#include "xwstream.h"
|
||||||
|
|
||||||
|
static void
|
||||||
|
super_dutil_storeStream( XW_DUtilCtxt* duc, XWEnv xwe, const XP_UCHAR* key,
|
||||||
|
XWStreamCtxt* data )
|
||||||
|
{
|
||||||
|
const void* ptr = stream_getPtr( data );
|
||||||
|
XP_U16 len = stream_getSize( data );
|
||||||
|
dutil_storePtr( duc, xwe, key, ptr, len );
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
super_dutil_loadStream( XW_DUtilCtxt* duc, XWEnv xwe, const XP_UCHAR* key,
|
||||||
|
// PENDING() remove this after a few months.
|
||||||
|
const XP_UCHAR* fallbackKey,
|
||||||
|
XWStreamCtxt* inOut )
|
||||||
|
{
|
||||||
|
/* get the size */
|
||||||
|
XP_U16 len = 0;
|
||||||
|
dutil_loadPtr( duc, xwe, key, fallbackKey, NULL, &len );
|
||||||
|
|
||||||
|
/* load if it exists */
|
||||||
|
if ( 0 < len ) {
|
||||||
|
void* buf = XP_MALLOC( duc->mpool, len );
|
||||||
|
dutil_loadPtr( duc, xwe, key, fallbackKey, buf, &len );
|
||||||
|
|
||||||
|
stream_putBytes( inOut, buf, len );
|
||||||
|
XP_FREEP( duc->mpool, &buf );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
dutil_super_init( MPFORMAL XW_DUtilCtxt* dutil )
|
dutil_super_init( MPFORMAL XW_DUtilCtxt* dutil )
|
||||||
|
@ -31,4 +61,7 @@ dutil_super_init( MPFORMAL XW_DUtilCtxt* dutil )
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
MPASSIGN( dutil->mpool, mpool );
|
MPASSIGN( dutil->mpool, mpool );
|
||||||
|
|
||||||
|
SET_VTABLE_ENTRY( &dutil->vtable, dutil_loadStream, super );
|
||||||
|
SET_VTABLE_ENTRY( &dutil->vtable, dutil_storeStream, super );
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,10 +35,6 @@ static const XP_UCHAR* linux_dutil_getUserString( XW_DUtilCtxt* duc, XWEnv xwe,
|
||||||
static const XP_UCHAR* linux_dutil_getUserQuantityString( XW_DUtilCtxt* duc, XWEnv xwe, XP_U16 code,
|
static const XP_UCHAR* linux_dutil_getUserQuantityString( XW_DUtilCtxt* duc, XWEnv xwe, XP_U16 code,
|
||||||
XP_U16 quantity );
|
XP_U16 quantity );
|
||||||
|
|
||||||
static void linux_dutil_storeStream( XW_DUtilCtxt* duc, XWEnv xwe, const XP_UCHAR* key,
|
|
||||||
XWStreamCtxt* data );
|
|
||||||
static void linux_dutil_loadStream( XW_DUtilCtxt* duc, XWEnv xwe, const XP_UCHAR* key,
|
|
||||||
const XP_UCHAR* keySuffix, XWStreamCtxt* inOut );
|
|
||||||
static void linux_dutil_storePtr( XW_DUtilCtxt* duc, XWEnv xwe, const XP_UCHAR* key,
|
static void linux_dutil_storePtr( XW_DUtilCtxt* duc, XWEnv xwe, const XP_UCHAR* key,
|
||||||
const void* data, XP_U16 len );
|
const void* data, XP_U16 len );
|
||||||
static void linux_dutil_loadPtr( XW_DUtilCtxt* duc, XWEnv xwe, const XP_UCHAR* key,
|
static void linux_dutil_loadPtr( XW_DUtilCtxt* duc, XWEnv xwe, const XP_UCHAR* key,
|
||||||
|
@ -145,8 +141,6 @@ dutils_init( MPFORMAL VTableMgr* vtMgr, void* closure )
|
||||||
SET_PROC(getCurSeconds);
|
SET_PROC(getCurSeconds);
|
||||||
SET_PROC(getUserString);
|
SET_PROC(getUserString);
|
||||||
SET_PROC(getUserQuantityString);
|
SET_PROC(getUserQuantityString);
|
||||||
SET_PROC(storeStream);
|
|
||||||
SET_PROC(loadStream);
|
|
||||||
SET_PROC(storePtr);
|
SET_PROC(storePtr);
|
||||||
SET_PROC(loadPtr);
|
SET_PROC(loadPtr);
|
||||||
|
|
||||||
|
@ -283,31 +277,6 @@ linux_dutil_getUserQuantityString( XW_DUtilCtxt* duc, XWEnv xwe, XP_U16 code,
|
||||||
return linux_dutil_getUserString( duc, xwe, code );
|
return linux_dutil_getUserString( duc, xwe, code );
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
linux_dutil_storeStream( XW_DUtilCtxt* duc, XWEnv xwe,
|
|
||||||
const XP_UCHAR* key, XWStreamCtxt* stream )
|
|
||||||
{
|
|
||||||
const void* ptr = stream_getPtr( stream );
|
|
||||||
XP_U16 len = stream_getSize( stream );
|
|
||||||
linux_dutil_storePtr( duc, xwe, key, ptr, len );
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
linux_dutil_loadStream( XW_DUtilCtxt* duc, XWEnv xwe, const XP_UCHAR* key,
|
|
||||||
const XP_UCHAR* keySuffix, XWStreamCtxt* stream )
|
|
||||||
{
|
|
||||||
XP_U16 len = 0;
|
|
||||||
linux_dutil_loadPtr( duc, xwe, key, keySuffix, NULL, &len );
|
|
||||||
if ( 0 < len ) {
|
|
||||||
XP_U8 buf[len];
|
|
||||||
linux_dutil_loadPtr( duc, xwe, key, keySuffix, buf, &len );
|
|
||||||
|
|
||||||
stream_putBytes( stream, buf, len );
|
|
||||||
}
|
|
||||||
|
|
||||||
XP_LOGF( "%s(key=%s) => len: %d", __func__, key, stream_getSize(stream) );
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
linux_dutil_storePtr( XW_DUtilCtxt* duc, XWEnv XP_UNUSED(xwe), const XP_UCHAR* key,
|
linux_dutil_storePtr( XW_DUtilCtxt* duc, XWEnv XP_UNUSED(xwe), const XP_UCHAR* key,
|
||||||
const void* data, const XP_U16 len )
|
const void* data, const XP_U16 len )
|
||||||
|
|
Loading…
Add table
Reference in a new issue