# New Ticket Created by  Nick Glencross 
# Please include the string:  [perl #37609]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org/rt3/Ticket/Display.html?id=37609 >


Guys,

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.

Nick
Index: runtime/parrot/library/YAML/Parser/Syck.imc
===================================================================
--- runtime/parrot/library/YAML/Parser/Syck.imc (revision 9770)
+++ runtime/parrot/library/YAML/Parser/Syck.imc (working copy)
@@ -55,7 +55,7 @@
     # 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
Index: src/inter_cb.c
===================================================================
--- src/inter_cb.c      (revision 9770)
+++ src/inter_cb.c      (working copy)
@@ -61,6 +61,14 @@
     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 @@
             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 @@
 
     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';
Index: t/pmc/nci.t
===================================================================
--- t/pmc/nci.t (revision 9770)
+++ t/pmc/nci.t (working copy)
@@ -1322,7 +1322,7 @@
   # 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 @@
     # 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 @@
   # 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 @@
     # 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 @@
   # 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 @@
   # 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 @@
     # 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 @@
     # 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 @@
     # 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

Reply via email to