Author: leo
Date: Fri Nov 4 06:18:47 2005
New Revision: 9773
Modified:
trunk/runtime/parrot/library/YAML/Parser/Syck.imc
trunk/src/inter_cb.c
trunk/t/pmc/nci.t
Log:
[perl #37609] Add return type to new_callback signature
As hinted in an earlier email, I'd like to propose the addition of a
return type to the new_callback signature. This will add consistency,
and prevent breakage when we support other NCI backends.
I've also made a change to the 'unhandled signature' which didn't look
like it was printing the signature correctly.
All NCI tests pass.
Courtesy of Nick Glencross <[EMAIL PROTECTED]>
Modified: trunk/runtime/parrot/library/YAML/Parser/Syck.imc
==============================================================================
--- trunk/runtime/parrot/library/YAML/Parser/Syck.imc (original)
+++ trunk/runtime/parrot/library/YAML/Parser/Syck.imc Fri Nov 4 06:18:47 2005
@@ -55,7 +55,7 @@ Parses a YAML string and returns a data
# this callback function will eventually by called by the library
.const .Sub yaml_handler = "_yaml_handler"
.local pmc yaml_handler_wrapped
- yaml_handler_wrapped = new_callback yaml_handler, user_data, "Up" # Z in
pdd16
+ yaml_handler_wrapped = new_callback yaml_handler, user_data, "vUp" # Z in
pdd16
.local pmc synchronous
synchronous = new Integer
Modified: trunk/src/inter_cb.c
==============================================================================
--- trunk/src/inter_cb.c (original)
+++ trunk/src/inter_cb.c Fri Nov 4 06:18:47 2005
@@ -61,6 +61,14 @@ Parrot_make_cb(Parrot_Interp interpreter
VTABLE_setprop(interpreter, user_data, sc, sub);
/* only ASCII signatures are supported */
sig_str = cb_signature->strstart;
+
+ if (strlen (sig_str) != 3) {
+ internal_exception(1, "unhandled signature '%s' in make_cb",
+ cb_signature->strstart);
+ }
+
+ ++sig_str; /* Skip callback return type */
+
if (*sig_str == 'U') {
type = 'D';
}
@@ -70,8 +78,8 @@ Parrot_make_cb(Parrot_Interp interpreter
type = 'C';
}
else {
- internal_exception(1, "unhandled signature '%Ss' in make_cb",
- cb_signature);
+ internal_exception(1, "unhandled signature '%s' in make_cb",
+ cb_signature->strstart);
}
}
@@ -264,6 +272,7 @@ Parrot_run_callback(Parrot_Interp interp
sig_str = VTABLE_get_string(interpreter, signature);
p = sig_str->strstart;
+ ++p; /* Skip return type */
pasm_sig[0] = 'v'; /* no return value supported yet */
pasm_sig[1] = 'P';
Modified: trunk/t/pmc/nci.t
==============================================================================
--- trunk/t/pmc/nci.t (original)
+++ trunk/t/pmc/nci.t Fri Nov 4 06:18:47 2005
@@ -1322,7 +1322,7 @@ pasm_output_is(<<'CODE', <<'OUTPUT', "nc
# prepare user data
new P7, .Integer
set P7, 42
- new_callback P5, P6, P7, "tU" # Z in pdd16
+ new_callback P5, P6, P7, "vtU" # Z in pdd16
print "ok 1\n"
# now call the external sub, that takes a call_back and user_data
loadlib P1, "libnci_test"
@@ -1391,7 +1391,7 @@ pir_output_is(<<'CODE', <<'OUTPUT', "nci
# this callback function will eventually by called by the library
.const .Sub cb = "_call_back"
.local pmc cb_wrapped
- cb_wrapped = new_callback cb, user_data, "tU" # Z in pdd16
+ cb_wrapped = new_callback cb, user_data, "vtU" # Z in pdd16
print "created a callback sub\n"
# now call the external sub, that takes a callback and user data
@@ -1456,7 +1456,7 @@ pasm_output_is(<<'CODE', <<'OUTPUT', "nc
# prepare user data
new P7, .Integer
set P7, 42
- new_callback P5, P6, P7, "iU" # Z in pdd16
+ new_callback P5, P6, P7, "viU" # Z in pdd16
print "ok 1\n"
# now call the external sub, that takes a call_back and user_data
loadlib P1, "libnci_test"
@@ -1529,7 +1529,7 @@ pir_output_is(<<'CODE', <<'OUTPUT', "nci
# this callback function will eventually by called by the library
.const .Sub cb = "_call_back"
.local pmc cb_wrapped
- cb_wrapped = new_callback cb, user_data, "pU" # Z in pdd16
+ cb_wrapped = new_callback cb, user_data, "vpU" # Z in pdd16
print "created a callback sub\n"
# now call the external sub, that takes a callback and user data
@@ -1604,7 +1604,7 @@ pasm_output_is(<<'CODE', <<'OUTPUT', "nc
# prepare user data
new P7, .Integer
set P7, 42
- new_callback P5, P6, P7, "Ut" # Z in pdd16
+ new_callback P5, P6, P7, "vUt" # Z in pdd16
print "ok 1\n"
# now call the external sub, that takes a call_back and user_data
loadlib P1, "libnci_test"
@@ -1663,7 +1663,7 @@ pasm_output_is(<<'CODE', <<'OUTPUT', "nc
# prepare user data
new P7, .Integer
set P7, 42
- new_callback P5, P6, P7, "Ui" # Z in pdd16
+ new_callback P5, P6, P7, "vUi" # Z in pdd16
print "ok 1\n"
# now call the external sub, that takes a call_back and user_data
loadlib P1, "libnci_test"
@@ -1732,7 +1732,7 @@ pir_output_is(<<'CODE', <<'OUTPUT', "nci
# this callback function will eventually by called by the library
.const .Sub cb = "_call_back"
.local pmc cb_wrapped
- cb_wrapped = new_callback cb, user_data, "Ui" # Z in pdd16
+ cb_wrapped = new_callback cb, user_data, "vUi" # Z in pdd16
print "created a callback sub\n"
# now call the external sub, that takes a callback and user data
@@ -1810,7 +1810,7 @@ pir_output_is(<<'CODE', <<'OUTPUT', "nci
# this callback function will eventually by called by the library
.const .Sub cb = "_call_back"
.local pmc cb_wrapped
- cb_wrapped = new_callback cb, user_data, "Up" # Z in pdd16
+ cb_wrapped = new_callback cb, user_data, "vUp" # Z in pdd16
print "created a callback sub\n"
# now call the external sub, that takes a callback and user data
@@ -1910,7 +1910,7 @@ pir_output_is(<<'CODE', <<'OUTPUT', "nci
# this callback function will eventually by called by the library
.const .Sub cb = "_call_back"
.local pmc cb_wrapped
- cb_wrapped = new_callback cb, user_data, "Up" # Z in pdd16
+ cb_wrapped = new_callback cb, user_data, "vUp" # Z in pdd16
print "created a callback sub\n"
# now call the external sub, that takes a callback and user data