develooper Front page | perl.cvs.parrot | Postings from January 2009

[svn:parrot] r35930 - trunk/src/pmc

From:
julianalbo
Date:
January 23, 2009 14:54
Subject:
[svn:parrot] r35930 - trunk/src/pmc
Message ID:
20090123225418.7871CCB9AE@x12.develooper.com
Author: julianalbo
Date: Fri Jan 23 14:54:17 2009
New Revision: 35930

Modified:
   trunk/src/pmc/complex.pmc

Log:
allow String subclasses in Complex init_pmc

Modified: trunk/src/pmc/complex.pmc
==============================================================================
--- trunk/src/pmc/complex.pmc	(original)
+++ trunk/src/pmc/complex.pmc	Fri Jan 23 14:54:17 2009
@@ -366,13 +366,19 @@
                     FLOATVAL im = VTABLE_get_number_keyed_int(interp, initializer, 1);
                     SET_ATTR_re(INTERP, SELF, re);
                     SET_ATTR_im(INTERP, SELF, im);
-		    break;
+                    break;
                 }
                 /* else let it fall to default */
             default:
-                Parrot_ex_throw_from_c_args(interp, NULL,
-                    EXCEPTION_INVALID_OPERATION,
-                    "Invalid Complex initializer");
+                if (VTABLE_isa(interp, initializer, CONST_STRING(interp, "String"))) {
+                    STRING * s = VTABLE_get_string(interp, initializer);
+                    SELF.set_string_native(s);
+                }
+                else {
+                    Parrot_ex_throw_from_c_args(interp, NULL,
+                        EXCEPTION_INVALID_OPERATION,
+                        "Invalid Complex initializer");
+                }
         }
     }
 



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About