Author: jonathan
Date: Sun Apr 1 15:57:10 2007
New Revision: 17936
Modified:
trunk/src/objects.c
trunk/src/pmc/class.pmc
trunk/t/pmc/class.t
Log:
[PDD15]: Make sure we use shift_string when iterating a hash rather than
shift_pmc, since that doesn't seem to work.Untodo the failing new(...) test.
Modified: trunk/src/objects.c
==============================================================================
--- trunk/src/objects.c (original)
+++ trunk/src/objects.c Sun Apr 1 15:57:10 2007
@@ -1898,9 +1898,8 @@
methods_iter = VTABLE_get_iter(interp, methods);
while (VTABLE_get_bool(interp, methods_iter)) {
/* Get current method and its name. */
- PMC *method_name_pmc = VTABLE_shift_pmc(interp, methods_iter);
- STRING *method_name = VTABLE_get_string(interp, method_name_pmc);
- PMC *cur_method = VTABLE_get_pmc_keyed(interp, methods,
method_name_pmc);
+ STRING *method_name = VTABLE_shift_string(interp, methods_iter);
+ PMC *cur_method = VTABLE_get_pmc_keyed_str(interp, methods,
method_name);
/* Need to find the name we'll check for a conflict on. */
STRING *check_name = method_name;
@@ -1967,10 +1966,9 @@
methods_iter = VTABLE_get_iter(interp, proposed_add_methods);
while (VTABLE_get_bool(interp, methods_iter)) {
/* Get current method and its name. */
- PMC *method_name_pmc = VTABLE_shift_pmc(interp, methods_iter);
- STRING *method_name = VTABLE_get_string(interp, method_name_pmc);
- PMC *cur_method = VTABLE_get_pmc_keyed(interp, proposed_add_methods,
- method_name_pmc);
+ STRING *method_name = VTABLE_shift_string(interp, methods_iter);
+ PMC *cur_method = VTABLE_get_pmc_keyed_str(interp,
proposed_add_methods,
+ method_name);
/* Add it to the methods of the class. */
VTABLE_set_pmc_keyed_str(interp, methods_hash, method_name,
Modified: trunk/src/pmc/class.pmc
==============================================================================
--- trunk/src/pmc/class.pmc (original)
+++ trunk/src/pmc/class.pmc Sun Apr 1 15:57:10 2007
@@ -90,8 +90,8 @@
/* Iterate over the attributes. */
while (VTABLE_get_bool(interp, iter)) {
/* Get attribute. */
- PMC *cur_attrib = VTABLE_get_pmc_keyed(interp, attribs,
- VTABLE_shift_pmc(interp, iter));
+ PMC *cur_attrib = VTABLE_get_pmc_keyed_str(interp, attribs,
+ VTABLE_shift_string(interp, iter));
STRING *attrib_name;
STRING *full_key = string_copy(interp, fq_class);
@@ -373,8 +373,7 @@
iter = VTABLE_get_iter(interp, args);
while (VTABLE_get_bool(interp, iter)) {
/* Get name and value. */
- STRING *attr_name = VTABLE_get_string(interp,
- VTABLE_shift_pmc(interp, iter));
+ STRING *attr_name = VTABLE_shift_string(interp, iter);
PMC *attr_value = VTABLE_get_pmc_keyed_str(interp, args,
attr_name);
/* Set the attribute. */
Modified: trunk/t/pmc/class.t
==============================================================================
--- trunk/t/pmc/class.t (original)
+++ trunk/t/pmc/class.t Sun Apr 1 15:57:10 2007
@@ -91,7 +91,7 @@
OUT
# L<PDD15/Class PMC API/=item new>
-pir_output_is( <<'CODE', <<'OUT', 'new', todo => ':slurpy :named bug' );
+pir_output_is( <<'CODE', <<'OUT', 'new' );
.sub 'test' :main
new $P0, .Class
$P1 = $P0.'new'()
@@ -106,7 +106,7 @@
clear_eh
print 'not '
ok_2:
- say 'ok 2 - new with non-attribute key fails'
+ say 'ok 2 - new() with non-attribute key fails'
$P0 = new .Class
$P0.'add_attribute'('foo')
@@ -116,14 +116,14 @@
say $P2
$P2 = getattribute $P1, 'bar'
say $P2
- say 'ok 3 - new with key/value pairs sets attributes'
+ say 'ok 3 - new() with key/value pairs sets attributes'
.end
CODE
ok 1 - new() with no args returns an object
ok 2 - new() with non-attribute key fails
1
2
-ok 3 - new with key/value pairs sets attributes
+ok 3 - new() with key/value pairs sets attributes
OUT
# L<PDD15/Class PMC API/=item attributes>