Author: chromatic
Date: Sat Jul 26 11:04:46 2008
New Revision: 29766
Modified:
trunk/src/pmc/array.pmc
trunk/src/pmc/iterator.pmc
Log:
[PMC] Added the set_key() method on the Iterator PMC to encapsulate the
key-setting operation. (No more poking into its struct val, which I hope to
remove.)
Modified: trunk/src/pmc/array.pmc
==============================================================================
--- trunk/src/pmc/array.pmc (original)
+++ trunk/src/pmc/array.pmc Sat Jul 26 11:04:46 2008
@@ -1197,8 +1197,9 @@
VTABLE PMC *slice(PMC *key, INTVAL f) {
if (f == 0) {
+ STRING *name = CONST_STRING(interp, "set_key");
PMC * const iter = pmc_new_init(INTERP, enum_class_Iterator, SELF);
- PMC_struct_val(iter) = key;
+ Parrot_PCCINVOKE(interp, iter, name, "P->", key);
return iter;
}
@@ -1206,9 +1207,11 @@
}
VTABLE PMC *get_iter() {
- PMC * const iter = pmc_new_init(INTERP, enum_class_Iterator, SELF);
- PMC * const key = pmc_new(INTERP, enum_class_Key);
- PMC_struct_val(iter) = key;
+ STRING *name = CONST_STRING(interp, "set_key");
+ PMC * const iter = pmc_new_init(INTERP, enum_class_Iterator, SELF);
+ PMC * const key = pmc_new(INTERP, enum_class_Key);
+ Parrot_PCCINVOKE(interp, iter, name, "P->", key);
+
PObj_get_FLAGS(key) |= KEY_integer_FLAG;
PMC_int_val(key) = 0;
Modified: trunk/src/pmc/iterator.pmc
==============================================================================
--- trunk/src/pmc/iterator.pmc (original)
+++ trunk/src/pmc/iterator.pmc Sat Jul 26 11:04:46 2008
@@ -679,6 +679,10 @@
VTABLE PMC *get_iter() {
return SELF;
}
+
+ METHOD set_key(PMC *key) {
+ PMC_struct_val(SELF) = key;
+ }
}
/*