add missing callbacks (and assert all there)

This commit is contained in:
Eric House 2020-02-02 17:57:30 -08:00
parent dd0ad8f479
commit 94137322b7
6 changed files with 76 additions and 23 deletions

View file

@ -1166,7 +1166,7 @@ setupCursesUtilCallbacks( CursesBoardGlobals* bGlobals, XW_UtilCtxt* util )
#endif
#undef SET_PROC
assertAllCallbacksSet( util );
assertUtilCallbacksSet( util );
} /* setupCursesUtilCallbacks */
static bool

View file

@ -29,6 +29,7 @@
#include "draw.h"
#include "board.h"
#include "dbgutil.h"
#include "linuxmain.h"
typedef struct CursesDrawCtx {
DrawCtxVTable* vtable;
@ -85,6 +86,11 @@ curses_draw_beginDraw( DrawCtx* XP_UNUSED(p_dctx) )
return XP_TRUE;
}
static void
curses_draw_endDraw( DrawCtx* XP_UNUSED(dctx) )
{
}
static XP_Bool
curses_draw_boardBegin( DrawCtx* XP_UNUSED(p_dctx),
const XP_Rect* XP_UNUSED(rect),
@ -346,6 +352,14 @@ curses_draw_score_pendingScore( DrawCtx* p_dctx, const XP_Rect* rect,
mvwprintw( dctx->boardWin, topbot, rect->left, "%s", buf );
} /* curses_draw_score_pendingScore */
static void
curses_draw_drawTimer( DrawCtx* XP_UNUSED(p_dctx), const XP_Rect* XP_UNUSED(rInner),
XP_U16 XP_UNUSED(playerNum), XP_S16 XP_UNUSED(secondsLeft),
XP_Bool XP_UNUSED(localTurnDone) )
{
LOG_FUNC();
}
static void
curses_draw_objFinished( DrawCtx* p_dctx, BoardObjectType XP_UNUSED(typ),
const XP_Rect* XP_UNUSED(rect),
@ -355,6 +369,14 @@ curses_draw_objFinished( DrawCtx* p_dctx, BoardObjectType XP_UNUSED(typ),
wrefresh( dctx->boardWin );
} /* curses_draw_objFinished */
static XP_Bool
curses_draw_vertScrollBoard( DrawCtx* XP_UNUSED(dctx), XP_Rect* XP_UNUSED(rect),
XP_S16 XP_UNUSED(dist), DrawFocusState XP_UNUSED(dfs) )
{
XP_ASSERT(0);
}
#define MY_PAIR 1
static XP_Bool
@ -415,6 +437,12 @@ curses_draw_drawCell( DrawCtx* p_dctx, const XP_Rect* rect,
return XP_TRUE;
} /* curses_draw_drawCell */
static void
curses_draw_invertCell( DrawCtx* XP_UNUSED(dctx), const XP_Rect* XP_UNUSED(rect) )
{
XP_ASSERT(0);
}
static void
getTops( const XP_Rect* rect, int* toptop, int* topbot )
{
@ -509,6 +537,17 @@ curses_draw_drawTileBack( DrawCtx* p_dctx, const XP_Rect* rect,
return XP_TRUE;
} /* curses_draw_drawTileBack */
static XP_Bool
curses_draw_drawTileMidDrag( DrawCtx* XP_UNUSED(dctx),
const XP_Rect* XP_UNUSED(rect),
const XP_UCHAR* XP_UNUSED(text),
const XP_Bitmaps* XP_UNUSED(bitmaps),
XP_U16 XP_UNUSED(val), XP_U16 XP_UNUSED(owner),
CellFlags XP_UNUSED(flags) )
{
XP_ASSERT( 0 );
}
static void
curses_draw_drawTrayDivider( DrawCtx* p_dctx, const XP_Rect* rect,
CellFlags flags )
@ -611,34 +650,25 @@ curses_draw_frameTray( DrawCtx* p_dctx, XP_Rect* rect )
} /* curses_draw_frameTray */
#endif
static XP_Bool
draw_doNothing( DrawCtx* XP_UNUSED(dctx), ... )
{
LOG_FUNC();
return XP_FALSE;
} /* draw_doNothing */
DrawCtx*
cursesDrawCtxtMake( WINDOW* boardWin )
{
CursesDrawCtx* dctx = malloc( sizeof(CursesDrawCtx) );
CursesDrawCtx* dctx = g_malloc0( sizeof(CursesDrawCtx) );
dctx->vtable = malloc( sizeof(*(((CursesDrawCtx*)dctx)->vtable)) );
for ( int ii = 0;
ii < sizeof(*dctx->vtable)/sizeof(dctx->vtable->m_draw_destroyCtxt);
++ii ) {
((void**)(dctx->vtable))[ii] = draw_doNothing;
}
dctx->vtable = g_malloc0( sizeof(*(((CursesDrawCtx*)dctx)->vtable)) );
SET_VTABLE_ENTRY( dctx->vtable, draw_destroyCtxt, curses );
SET_VTABLE_ENTRY( dctx->vtable, draw_dictChanged, curses );
SET_VTABLE_ENTRY( dctx->vtable, draw_beginDraw, curses );
SET_VTABLE_ENTRY( dctx->vtable, draw_endDraw, curses );
SET_VTABLE_ENTRY( dctx->vtable, draw_boardBegin, curses );
SET_VTABLE_ENTRY( dctx->vtable, draw_trayBegin, curses );
SET_VTABLE_ENTRY( dctx->vtable, draw_scoreBegin, curses );
SET_VTABLE_ENTRY( dctx->vtable, draw_objFinished, curses );
SET_VTABLE_ENTRY( dctx->vtable, draw_vertScrollBoard, curses );
SET_VTABLE_ENTRY( dctx->vtable, draw_drawTimer, curses );
#ifdef XWFEATURE_SCOREONEPASS
SET_VTABLE_ENTRY( dctx->vtable, draw_drawRemText, curses );
@ -651,13 +681,15 @@ cursesDrawCtxtMake( WINDOW* boardWin )
SET_VTABLE_ENTRY( dctx->vtable, draw_score_pendingScore, curses );
SET_VTABLE_ENTRY( dctx->vtable, draw_drawCell, curses );
SET_VTABLE_ENTRY( dctx->vtable, draw_invertCell, curses );
SET_VTABLE_ENTRY( dctx->vtable, draw_drawTile, curses );
SET_VTABLE_ENTRY( dctx->vtable, draw_drawTileBack, curses );
SET_VTABLE_ENTRY( dctx->vtable, draw_drawTileMidDrag, curses );
SET_VTABLE_ENTRY( dctx->vtable, draw_drawTrayDivider, curses );
SET_VTABLE_ENTRY( dctx->vtable, draw_drawBoardArrow, curses );
SET_VTABLE_ENTRY( dctx->vtable, draw_clearRect, curses );
SET_VTABLE_ENTRY( dctx->vtable, draw_drawBoardArrow, curses );
#ifdef XWFEATURE_MINIWIN
SET_VTABLE_ENTRY( dctx->vtable, draw_drawMiniWindow, curses );
@ -665,6 +697,8 @@ cursesDrawCtxtMake( WINDOW* boardWin )
SET_VTABLE_ENTRY( dctx->vtable, draw_measureMiniWText, curses );
#endif
assertDrawCallbacksSet( dctx->vtable );
dctx->boardWin = boardWin;
return (DrawCtx*)dctx;
@ -674,8 +708,8 @@ void
cursesDrawCtxtFree( DrawCtx* pdctx )
{
CursesDrawCtx* dctx = (CursesDrawCtx*)pdctx;
free( dctx->vtable );
free( dctx );
g_free( dctx->vtable );
g_free( dctx );
}
#endif /* PLATFORM_NCURSES */

View file

@ -2418,7 +2418,7 @@ setupGtkUtilCallbacks( GtkGameGlobals* globals, XW_UtilCtxt* util )
#undef SET_PROC
assertAllCallbacksSet( util );
assertUtilCallbacksSet( util );
} /* setupGtkUtilCallbacks */
#ifndef XWFEATURE_STANDALONE_ONLY

View file

@ -1476,6 +1476,8 @@ gtkDrawCtxtMake( GtkWidget* drawing_area, GtkGameGlobals* globals )
SET_VTABLE_ENTRY( dctx->vtable, draw_dictChanged, gtk );
#endif
assertDrawCallbacksSet( dctx->vtable );
dctx->drawing_area = drawing_area;
dctx->globals = globals;

View file

@ -2188,7 +2188,7 @@ setupLinuxUtilCallbacks( XW_UtilCtxt* util )
}
void
assertAllCallbacksSet( XW_UtilCtxt* util )
assertUtilCallbacksSet( XW_UtilCtxt* util )
{
XWStreamCtxt* (**proc)(XW_UtilCtxt*, XP_PlayerAddr ) =
&util->vtable->m_util_makeStreamFromAddr;
@ -2201,6 +2201,22 @@ assertAllCallbacksSet( XW_UtilCtxt* util )
}
}
void
assertDrawCallbacksSet( const DrawCtxVTable* vtable )
{
bool allSet = true;
void(**proc)() = (void(**)())vtable;
for ( int ii = 0; ii < sizeof(*vtable)/sizeof(*proc); ++ii ) {
XP_LOGFF( "looking at index %d", ii );
if ( !*proc ) {
XP_LOGF( "%s(): null ptr at index %d", __func__, ii );
allSet = false;
}
++proc;
}
XP_ASSERT( allSet );
}
void
setupUtil( CommonGlobals* cGlobals )
{

View file

@ -95,7 +95,8 @@ void clearOneSecondTimer( CommonGlobals* cGlobals );
#endif
void setupLinuxUtilCallbacks( XW_UtilCtxt* util );
void assertAllCallbacksSet( XW_UtilCtxt* util );
void assertUtilCallbacksSet( XW_UtilCtxt* util );
void assertDrawCallbacksSet( const DrawCtxVTable* vtable );
void setupUtil( CommonGlobals* cGlobals );
void disposeUtil( CommonGlobals* cGlobals );