petdance/scratch — Issue #383: [NCI] callback sub parameter definition isn't unified with  callback definition in the C lib.
Author: petdance
Created: 2011-11-01 05:42:11+00:00
State: open
Labels: bug, core, Pri-normal, Sev-medium

Hello,
see https://github.com/parrot/parrot/blob/master/src/nci_test.c#-115 , there are two define here.

{{{
typedef void (*cb_C1_func)(const char*, void*);
PARROT_DYNEXT_EXPORT void nci_cb_C1(cb_C1_func, void*);
}}}

the callback is created by:

{{{
cb_wrapped = new_callback cb, user_data, "vtU"
}}}

which means it's first parameter is external_data, and the two is user_data. that is, the callback function should be defined as this one:

{{{
.sub _call_back
.param string external_data
.param pmc user_data
print "user data: "
print u
print "\n"
print "external data: "
print s
print "\n"
.end
}}}

but actually in t/pmc/nci.t, it's defined as:

{{{
.sub _call_back
.param pmc user_data
.param string external_data
print "user data: "
print u
print "\n"
print "external data: "
print s
print "\n"
.end

}}}

according to t/pmc/nci.t it seems that no matter user_data is the first parameter or two, the callback sub must be defined as:

{{{
.sub _call_back
.param pmc user_data
.param string external_data
.end
}}}

then I took a look at PDD16, and it's said user_data should be defined in the second parameter:

{{{
.sub _call_back
.param string external_data
.param pmc user_data
.end

}}}

which is right.

Originally http://trac.parrot.org/parrot/ticket/1992