RE: Callbacks in Eu.ex
- Posted by Matt Lewis <matthewwalkerlewis at yahoo.com> Dec 16, 2004
- 446 views
Elliott S. de Andrade wrote: > > I was planning on doing something like this, but you seem to have > beaten me to it. I wasn't surprised though, since you were the one who wrote > fptr.e. It's no big deal since my attempt was more of a stab at > understanding the source than actually producing anything greatly useful. > Just one thing, you need to change the call to general_callback() in > call_crash_routines() to work with your new version. Whoops, didn't realize that's how that was done. I changed call_crash_routines() a little bit and added call_crash_routines_for_real():
function call_crash_routines_for_real(sequence routine, sequence args) -- call the user's function from an external source val[t_id] = routine[C_USER_ROUTINE] val[t_arglist] = args -- create a stack frame call_stack = call_stack & {length(call_stack), pc, call_back_routine} Code = call_back_code pc = 1 call_proc( forward_do_exec, {}) -- remove the stack frame pc = call_stack[$-1] call_stack = call_stack[1..$-3] -- restore Code = SymTab[call_stack[$]][S_CODE] return val[t_return_val] end function procedure call_crash_routines() -- call all the routines in the crash list object quit if crash_count > 0 then return end if crash_count += 1 -- call them in reverse order err_file_name = "ex_crash.err" for i = length(crash_list) to 1 by -1 do -- do callback to get addr quit = call_crash_routines_for_real( {0, crash_list[i], 1}, {0}) if not equal(quit, 0) then return -- don't call the others end if end for end procedure
Matt Lewis