pass closure from js to avoid global

This commit is contained in:
Eric House 2021-02-10 14:19:16 -08:00
parent 880bff747d
commit b368d0b801
2 changed files with 3 additions and 3 deletions

View file

@ -517,10 +517,10 @@ looper( void* closure )
} }
void void
button( const char* msg ) button( void* closure, const char* msg )
{ {
XP_Bool draw = XP_FALSE; XP_Bool draw = XP_FALSE;
Globals* globals = sGlobals; Globals* globals = (Globals*)closure;
BoardCtxt* board = globals->game.board; BoardCtxt* board = globals->game.board;
XP_Bool redo; XP_Bool redo;

View file

@ -195,7 +195,7 @@
} }
function callButton(name) { function callButton(name) {
Module.ccall('button', null, ['string'], [name]); Module.ccall('button', null, ['number', 'string'], [state.closure, name]);
} }
function onHaveDevID(closure, devid) { function onHaveDevID(closure, devid) {