[svn:parrot] r38492 - in trunk: runtime/parrot/library t/library
jonathan at svn.parrot.org
jonathan at svn.parrot.org
Tue May 5 16:57:38 UTC 2009
Author: jonathan
Date: Tue May 5 16:57:33 2009
New Revision: 38492
URL: https://trac.parrot.org/parrot/changeset/38492
Log:
[p6object] Add variants of some meta-class methods that take the object to operate on as the first parameter, as is Perl 6 spec. Move the main implementation to these, have the existing variants forward to them and document them as deprecated.
Modified:
trunk/runtime/parrot/library/P6object.pir
trunk/t/library/p6object.t
Modified: trunk/runtime/parrot/library/P6object.pir
==============================================================================
--- trunk/runtime/parrot/library/P6object.pir Tue May 5 16:42:42 2009 (r38491)
+++ trunk/runtime/parrot/library/P6object.pir Tue May 5 16:57:33 2009 (r38492)
@@ -154,7 +154,7 @@
=cut
-.sub 'isa' :method
+.sub 'isa' :method :multi(_,_, _)
.param pmc obj
.param pmc x
@@ -182,19 +182,34 @@
=item add_parent(parentclass [, 'to'=>parrotclass])
+Deprecated; use add_parent(class, parentclass)
+
=cut
-.sub 'add_parent' :method
+.sub 'add_parent' :method :multi(_,_)
.param pmc parentclass
.param pmc options :slurpy :named
- parentclass = self.'get_parrotclass'(parentclass)
$P0 = options['to']
unless null $P0 goto have_to
$P0 = self
have_to:
+ .tailcall self.'add_parent'($P0, parentclass)
+.end
+
+
+=item add_parent(class, parentclass)
+
+=cut
+
+.sub 'add_parent' :method :multi(_,_,_)
+ .param pmc obj
+ .param pmc parentclass
+
+ parentclass = self.'get_parrotclass'(parentclass)
+
.local pmc parrotclass
- parrotclass = self.'get_parrotclass'($P0)
+ parrotclass = self.'get_parrotclass'(obj)
if null parrotclass goto end
## if parrotclass isa parentclass, we're done
@@ -237,9 +252,11 @@
Add C<method> with C<name> to C<parrotclass>.
+DEPRECATED. Use add_method(class, name, method)
+
=cut
-.sub 'add_method' :method
+.sub 'add_method' :method :multi(_,_,_)
.param string name
.param pmc method
.param pmc options :slurpy :named
@@ -248,16 +265,50 @@
unless null $P0 goto have_to
$P0 = self
have_to:
+ .tailcall self.'add_method'($P0, name, method)
+.end
+
+
+=item add_method(class, name, method)
+
+Add C<method> with C<name> to C<class>.
+
+=cut
+
+
+.sub 'add_method' :method :multi(_,_,_,_)
+ .param pmc obj
+ .param string name
+ .param pmc method
+
.local pmc parrotclass
- parrotclass = self.'get_parrotclass'($P0)
+ parrotclass = self.'get_parrotclass'(obj)
parrotclass.'add_method'(name, method)
.end
+=item add_attribute(class, name)
+
+Add C<method> with C<name> to C<class>.
+
+=cut
+
+.sub 'add_attribute' :method
+ .param pmc obj
+ .param string name
+ .param pmc options :slurpy :named
+ .local pmc parrotclass
+ parrotclass = self.'get_parrotclass'(obj)
+ parrotclass.'add_attribute'(name)
+.end
+
+
=item add_role(role, [, 'to'=>parrotclass])
Add C<role> to C<parrotclass>.
+DEPRECATED. Use compose_role(class, role)
+
=cut
.sub 'add_role' :method
@@ -268,8 +319,22 @@
unless null $P0 goto have_to
$P0 = self
have_to:
+ .tailcall self.'compose_role'($P0, role)
+.end
+
+
+=item compose_role(class, role)
+
+Add C<role> to C<class>.
+
+=cut
+
+.sub 'compose_role' :method
+ .param pmc obj
+ .param pmc role
+
.local pmc parrotclass
- parrotclass = self.'get_parrotclass'($P0)
+ parrotclass = self.'get_parrotclass'(obj)
parrotclass.'add_role'(role)
.end
Modified: trunk/t/library/p6object.t
==============================================================================
--- trunk/t/library/p6object.t Tue May 5 16:42:42 2009 (r38491)
+++ trunk/t/library/p6object.t Tue May 5 16:57:33 2009 (r38492)
@@ -36,7 +36,7 @@
goto load_success
load_fail:
- ok(0, "load_bytecode 'P6object.pir' failed -- skipping tests")
+ ok(0, "load_bytecode 'P6object.pbc' failed -- skipping tests")
.return ()
load_success:
More information about the parrot-commits
mailing list