[svn:parrot] r39239 - in trunk: src t/oo
pmichaud at svn.parrot.org
pmichaud at svn.parrot.org
Fri May 29 16:36:03 UTC 2009
Author: pmichaud
Date: Fri May 29 16:36:02 2009
New Revision: 39239
URL: https://trac.parrot.org/parrot/changeset/39239
Log:
[core]: Revise r39220 commit for PMCProxy, to avoid conflicts with methods.
Adds a test as well.
Modified:
trunk/src/oo.c
trunk/t/oo/proxy.t
Modified: trunk/src/oo.c
==============================================================================
--- trunk/src/oo.c Fri May 29 12:24:06 2009 (r39238)
+++ trunk/src/oo.c Fri May 29 16:36:02 2009 (r39239)
@@ -371,7 +371,10 @@
=item C<static PMC * get_pmc_proxy(PARROT_INTERP, STRING *name)>
Get the PMC proxy for a PMC with the name given, creating it if does not exist.
-If name is not an existing PMC, return PMCNULL.
+If name is not an existing PMC, return PMCNULL. This code assumes that
+all PMCProxy objects live in the 'parrot' HLL namespace -- if/when
+we allow PMC types to exist in other HLL namespaces, this code will
+need to be updated.
For internal use only.
@@ -393,23 +396,19 @@
if (type > interp->n_vtable_max || type <= 0)
return PMCNULL;
else {
- /* Look for a proxy */
- PMC * const pmc_hll_ns = interp->vtables[type]->_namespace;
- PMC * const pmc_ns =
- Parrot_get_namespace_keyed_str(interp, pmc_hll_ns, name);
- PMC *new_class = PMC_IS_NULL(pmc_ns) ?
- PMCNULL : VTABLE_get_class(interp, pmc_ns);
- /* If Proxy not found, create it */
- if (PMC_IS_NULL(new_class)) {
- PMC *new_ns = pmc_ns;
+ PMC * const parrot_hll = Parrot_get_namespace_keyed_str(interp, interp->root_namespace, CONST_STRING(interp, "parrot") );
+ PMC * const pmc_ns =
+ Parrot_make_namespace_keyed_str(interp, parrot_hll, name);
+ PMC * proxy = VTABLE_get_class(interp, pmc_ns);
+
+ /* Create proxy if not found */
+ if (PMC_IS_NULL(proxy)) {
PMC * const type_num = pmc_new(interp, enum_class_Integer);
VTABLE_set_integer_native(interp, type_num, type);
- new_class = pmc_new_init(interp, enum_class_PMCProxy, type_num);
- if (pmc_ns->vtable->base_type != enum_class_NameSpace)
- new_ns = Parrot_make_namespace_keyed_str(interp, pmc_hll_ns, name);
- Parrot_PCCINVOKE(interp, new_ns, CONST_STRING(interp, "set_class"), "P->", new_class);
+ proxy = pmc_new_init(interp, enum_class_PMCProxy, type_num);
+ Parrot_PCCINVOKE(interp, pmc_ns, CONST_STRING(interp, "set_class"), "P->", proxy);
}
- return new_class;
+ return proxy;
}
}
Modified: trunk/t/oo/proxy.t
==============================================================================
--- trunk/t/oo/proxy.t Fri May 29 12:24:06 2009 (r39238)
+++ trunk/t/oo/proxy.t Fri May 29 16:36:02 2009 (r39239)
@@ -19,13 +19,14 @@
.sub main :main
.include 'test_more.pir'
- plan(10)
+ plan(11)
typeof_a_low_level_object()
typeof_a_high_level_object()
typeof_a_class_object()
proxy_as_parent_of_class()
proxy_as_parent_of_class_with_new()
+ proxy_no_method_conflict()
.local pmc proxy_no_invade
proxy_no_invade = get_root_global ['foo'], 'proxy_no_invade'
proxy_no_invade()
@@ -83,6 +84,19 @@
is ($S0, 'Foo;Bar', 'object is typeof Foo;Bar')
.end
+.sub proxy_no_method_conflict
+ $P0 = new 'Complex'
+ $P0['real'] = 1
+ $P1 = $P0.'Complex'()
+ $S0 = $P1
+ is($S0, "1+0i", 'Complex method survived')
+.end
+
+.namespace ['Complex']
+.sub 'Complex' :method
+ .return (self)
+.end
+
.HLL 'foo'
.sub proxy_no_invade
@@ -99,6 +113,7 @@
is($I1, 0, 'No proxy in current HLL namespace, TT #715')
.end
+
# Local Variables:
# mode: pir
# fill-column: 100
More information about the parrot-commits
mailing list