//============================================================================= void install_mffi(void) { struct { const char* name; VMFunctionType func; int minargnum, maxargnum; } static const tbl[] = { { "load-dll-module", subr_load_dll_module, 1, 1, }, { "free-dll-module", subr_free_dll_module, 1, 1, }, { "get-proc-adr", subr_get_proc_adr, 2, 2, }, { "make-c-function", subr_make_c_function, 3, 3, }, { "make-bytevector", subr_make_bytevector, 1, 1, }, { "get-raw-value", subr_get_raw_value, 3, 3, }, { "set-raw-value!", subr_set_raw_value, 4, 4, }, { "get-raw-pointer", subr_get_raw_pointer, 2, 2, }, }; int i; for (i=0; i<sizeof(tbl)/sizeof(*tbl); ++i) { SExp sym = intern(tbl[i].name); SExp func = gen_prim_func(tbl[i].func, tbl[i].minargnum, tbl[i].maxargnum, tbl[i].name); assign_global(sym, func); } }
int main() { assign_global(); assign_struct(); assign_array(); if (num_hook_calls == 3) return 0; /* Success */ else if (num_hook_calls == 0) FAIL("No hook functions executed.\n"); else FAIL("Number of hook executions did not match expected.\n"); }