[svn:parrot] r46039 - in trunk: examples/embed src/pmc t/pmc

NotFound at svn.parrot.org NotFound at svn.parrot.org
Mon Apr 26 20:01:49 UTC 2010


Author: NotFound
Date: Mon Apr 26 20:01:49 2010
New Revision: 46039
URL: https://trac.parrot.org/parrot/changeset/46039

Log:
fixes and improvements in example cotorra

Modified:
   trunk/examples/embed/cotorra.c
   trunk/src/pmc/imageio.pmc
   trunk/t/pmc/packfile.t

Modified: trunk/examples/embed/cotorra.c
==============================================================================
--- trunk/examples/embed/cotorra.c	Mon Apr 26 19:49:14 2010	(r46038)
+++ trunk/examples/embed/cotorra.c	Mon Apr 26 20:01:49 2010	(r46039)
@@ -169,7 +169,7 @@
                 fail("Option needs argument");
             Parrot_set_trace(interp, getuintval(argv[i]));
         }
-        if (strcmp(argv[i], "--warnings") == 0) {
+        else if (strcmp(argv[i], "--warnings") == 0) {
             ++i;
             if (i >= argc)
                 fail("Option needs argument");
@@ -213,10 +213,10 @@
         return 0;
     }
 
-    if (i >= argc && ! module)
+    if (i >= argc && ! (module && stname))
         fail("No file to load");
     source = argv[i];
-    if (source) {
+    if (source && ! stname) {
         pf = Parrot_pbc_read(interp, source, 0);
         if (! pf)
             fail("Cannot load file");
@@ -232,7 +232,18 @@
         Parrot_PMC start = Parrot_PMC_get_pmc_strkey(interp, parrotns, name);
         if (Parrot_pmc_is_null(interp, start))
             fail("start sub not found");
-        Parrot_ext_call(interp, start, "->");
+        if (i < argc) {
+            int pos;
+            Parrot_PMC arg = Parrot_PMC_new(interp,
+                    Parrot_PMC_typenum(interp, "FixedStringArray"));
+            Parrot_PMC_set_intval(interp, arg, argc - i);
+            for (pos = 0; i < argc; ++i, ++pos) {
+                Parrot_PMC_set_string_intkey(interp, arg, pos, create_string(interp, argv[i]));
+            }
+            Parrot_ext_call(interp, start, "P->", arg);
+        }
+        else
+            Parrot_ext_call(interp, start, "->");
     }
     else {
         Parrot_runcode(interp, argc - i, argv + i);

Modified: trunk/src/pmc/imageio.pmc
==============================================================================
--- trunk/src/pmc/imageio.pmc	Mon Apr 26 19:49:14 2010	(r46038)
+++ trunk/src/pmc/imageio.pmc	Mon Apr 26 20:01:49 2010	(r46039)
@@ -261,8 +261,10 @@
       case enum_PackID_normal:
         {
             const INTVAL type = VTABLE_shift_integer(interp, info);
-            if (type <= 0 || type > interp->n_vtable_max)
+            if (type <= 0 || type > interp->n_vtable_max) {
+	        abort();
                 Parrot_ex_throw_from_c_args(interp, NULL, 1, "Unknown PMC type to thaw %d", type);
+            }
 
             pmc = Parrot_pmc_new_noinit(interp, type);
             VTABLE_thaw(interp, pmc, info);
@@ -274,6 +276,7 @@
         }
         break;
       default:
+        abort();
         Parrot_ex_throw_from_c_args(interp, NULL, 1, "Unknown PMC id args thaw %d", packid_flags);
         break;
     }

Modified: trunk/t/pmc/packfile.t
==============================================================================
--- trunk/t/pmc/packfile.t	Mon Apr 26 19:49:14 2010	(r46038)
+++ trunk/t/pmc/packfile.t	Mon Apr 26 20:01:49 2010	(r46039)
@@ -100,6 +100,7 @@
 # Packfile.set_string_native, Packfile.get_integer_keyed_str
 .sub 'test_get_integer'
     .local pmc pf
+    push_eh unknown_key
     pf  = _pbc()
     $I0 = pf["version_major"]
     ok(1, "get_integer_keyed_str(version_major)")
@@ -111,7 +112,6 @@
     ok(1, "get_integer_keyed_str(version_patch)")
 
     # Requesting unknown key should throw exception
-    push_eh unknown_key
     $I3 = pf["foo"]
     ok(0, "get_integer_keyed_str return unknown key")
     .return ()


More information about the parrot-commits mailing list