mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-28 07:58:08 +01:00
refactor: make vtable population test xplatform
This commit is contained in:
parent
ddb01d8930
commit
988facccd1
6 changed files with 34 additions and 17 deletions
|
@ -27,6 +27,7 @@
|
||||||
#include "andutils.h"
|
#include "andutils.h"
|
||||||
#include "paths.h"
|
#include "paths.h"
|
||||||
#include "LocalizedStrIncludes.h"
|
#include "LocalizedStrIncludes.h"
|
||||||
|
#include "dbgutil.h"
|
||||||
|
|
||||||
#define MAX_QUANTITY_STRS 4
|
#define MAX_QUANTITY_STRS 4
|
||||||
|
|
||||||
|
@ -909,6 +910,7 @@ makeUtil( MPFORMAL EnvThreadInfo* ti, jobject jutil, CurGameInfo* gi,
|
||||||
SET_PROC(getDevUtilCtxt);
|
SET_PROC(getDevUtilCtxt);
|
||||||
|
|
||||||
#undef SET_PROC
|
#undef SET_PROC
|
||||||
|
assertTableFull( vtable, sizeof(*vtable), "util" );
|
||||||
return (XW_UtilCtxt*)util;
|
return (XW_UtilCtxt*)util;
|
||||||
} /* makeUtil */
|
} /* makeUtil */
|
||||||
|
|
||||||
|
@ -965,6 +967,9 @@ makeDUtil( MPFORMAL EnvThreadInfo* ti, jobject jdutil, VTableMgr* vtMgr,
|
||||||
SET_DPROC(notifyPause);
|
SET_DPROC(notifyPause);
|
||||||
SET_DPROC(onDupTimerChanged);
|
SET_DPROC(onDupTimerChanged);
|
||||||
|
|
||||||
|
#undef SET_DPROC
|
||||||
|
|
||||||
|
assertTableFull( vtable, sizeof(*vtable), "dutil" );
|
||||||
return &dutil->dutil;
|
return &dutil->dutil;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -126,5 +126,24 @@ devIDTypeToStr(DevIDType typ)
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef CASESTR
|
#undef CASESTR
|
||||||
|
typedef void (*ProcPtr)();
|
||||||
|
void
|
||||||
|
assertTableFull( void* table, size_t sizeInBytes, const XP_UCHAR* tableName )
|
||||||
|
{
|
||||||
|
if ( 0 != sizeInBytes % sizeof(ProcPtr) ) {
|
||||||
|
XP_LOGFF( "bad call? vtable size: %zu; proc ptr size: %zu", sizeInBytes, sizeof(ProcPtr) );
|
||||||
|
XP_ASSERT( 0 );
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
ProcPtr* proc = (ProcPtr*)table;
|
||||||
|
int count = sizeInBytes / sizeof(ProcPtr);
|
||||||
|
for ( int ii = 0; ii < count; ++ii ) {
|
||||||
|
if ( !*proc ) {
|
||||||
|
XP_LOGFF( "%s.vtable[%d] missing", tableName, ii );
|
||||||
|
XP_ASSERT( 0 );
|
||||||
|
}
|
||||||
|
++proc;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* DEBUG */
|
||||||
|
|
|
@ -53,4 +53,10 @@ const char* devIDTypeToStr(DevIDType typ);
|
||||||
# define SET_DIRTY( ptr )
|
# define SET_DIRTY( ptr )
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
|
# ifdef DEBUG
|
||||||
|
void assertTableFull( void* table, size_t sizeInBytes, const XP_UCHAR* tableName );
|
||||||
|
# else
|
||||||
|
# define assertTableFull( table, sizeInBytes, tableName )
|
||||||
|
# endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -34,6 +34,7 @@
|
||||||
#include "gsrcwrap.h"
|
#include "gsrcwrap.h"
|
||||||
#include "linuxsms.h"
|
#include "linuxsms.h"
|
||||||
#include "strutils.h"
|
#include "strutils.h"
|
||||||
|
#include "dbgutil.h"
|
||||||
|
|
||||||
typedef struct CursesBoardState {
|
typedef struct CursesBoardState {
|
||||||
CursesAppGlobals* aGlobals;
|
CursesAppGlobals* aGlobals;
|
||||||
|
@ -1128,7 +1129,7 @@ setupCursesUtilCallbacks( CursesBoardGlobals* bGlobals, XW_UtilCtxt* util )
|
||||||
#endif
|
#endif
|
||||||
#undef SET_PROC
|
#undef SET_PROC
|
||||||
|
|
||||||
assertUtilCallbacksSet( util );
|
assertTableFull( util->vtable, sizeof(*util->vtable), "curses util" );
|
||||||
} /* setupCursesUtilCallbacks */
|
} /* setupCursesUtilCallbacks */
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
|
|
|
@ -2232,7 +2232,7 @@ setupGtkUtilCallbacks( GtkGameGlobals* globals, XW_UtilCtxt* util )
|
||||||
|
|
||||||
#undef SET_PROC
|
#undef SET_PROC
|
||||||
|
|
||||||
assertUtilCallbacksSet( util );
|
assertTableFull( util->vtable, sizeof(*util->vtable), "gtk util" );
|
||||||
} /* setupGtkUtilCallbacks */
|
} /* setupGtkUtilCallbacks */
|
||||||
|
|
||||||
#ifndef XWFEATURE_STANDALONE_ONLY
|
#ifndef XWFEATURE_STANDALONE_ONLY
|
||||||
|
|
|
@ -2388,20 +2388,6 @@ setupLinuxUtilCallbacks( XW_UtilCtxt* util )
|
||||||
#undef SET_PROC
|
#undef SET_PROC
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
assertUtilCallbacksSet( XW_UtilCtxt* util )
|
|
||||||
{
|
|
||||||
XWStreamCtxt* (**proc)(XW_UtilCtxt*, XP_PlayerAddr ) =
|
|
||||||
&util->vtable->m_util_makeStreamFromAddr;
|
|
||||||
for ( int ii = 0; ii < sizeof(*util->vtable)/sizeof(*proc); ++ii ) {
|
|
||||||
if ( !*proc ) {
|
|
||||||
XP_LOGF( "%s(): null ptr at index %d", __func__, ii );
|
|
||||||
XP_ASSERT( 0 );
|
|
||||||
}
|
|
||||||
++proc;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
assertDrawCallbacksSet( const DrawCtxVTable* vtable )
|
assertDrawCallbacksSet( const DrawCtxVTable* vtable )
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue