Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[CVS ci] approaching pdd16 callbacks

8 views
Skip to first unread message

Leopold Toetsch

unread,
Feb 7, 2004, 7:58:58 AM2/7/04
to P6I
I've implemented a first hackish way to run PASM callbacks called from C
NCI functions. It doesn't use any of the sig chars from pdd16 yet.

1) The callback is created manually for now in Parrot_make_cb()
(when all issues are resolved that step can be hidden then)
All the info we need for running the callback is stuffed into the Sub
PMC, which is passed as user_data.
2) The PMC returned from 1) is actually Parrot_callback_C()
3) When C code invokes the callback, this functions extracts intepreter,
Sub and original user_data
4) Then it schedules an EVENT_TYPE_CALL_BACK event[1]
5) which finally runs the PASM sub

That works so far. But there are still some problems. Its segfaulting
when run with --gc-debug (this seems to be unrelated to this code but
more a problem in library loading).

Then and formost: pdd16 is missing, how we actually can specifiy the
function signature of the PASM callback. src/nci_test.c contains:

typedef void (*cb_C1_func)(const char*, void*);
void nci_cb_C1(cb_C1_func, void*);

that is: the callback might pass a const char* in as external_data
parameter. But we don't know that. The PASM callback should have a S
register param for receiving this argument, but Parrot_callback_C() or
_make_cb() has no information about that.

s. src/nci_test.c, src/interpreter.c, and t/pmc/nci_27.pasm for more

Comments welcome,
leo

[1] pdd16 states:
Hand over control to the external library. IT IS
IMPORTANT THAT THE INTERPRETER YOU ARE CALLING BACK
INTO IS NOT ACTIVE WHEN THE CALLBACK IS MADE!
As we don't know, when the callback is invoked, my scheme uses an event
so that its safe to run the PASM code.

0 new messages