Ticket #1992 (new bug)

Opened 3 years ago

Last modified 3 years ago

[NCI] callback sub parameter definition isn't unified with callback definition in the C lib.

Reported by: jimmy Owned by:
Priority: normal Milestone:
Component: core Version: 3.0.0
Severity: medium Keywords:
Cc: Language:
Patch status: Platform:

Description (last modified by jimmy) (diff)

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.

Change History

Changed 3 years ago by jimmy

  • description modified (diff)

Changed 3 years ago by jimmy

  • description modified (diff)

Changed 3 years ago by plobsing

It is true that the callback parameters are inconsistent between C and PIR. However, it does mean that all callbacks defined from within parrot are consistent, regardless of dissagreements between C libraries.

Note: See TracTickets for help on using tickets.