Author: bernhard Date: Sat Jan 3 06:42:10 2009 New Revision: 34879 Modified: trunk/languages/pipp/src/pmc/phparray.pmc
Log: [Pipp] small beautifications Modified: trunk/languages/pipp/src/pmc/phparray.pmc ============================================================================== --- trunk/languages/pipp/src/pmc/phparray.pmc (original) +++ trunk/languages/pipp/src/pmc/phparray.pmc Sat Jan 3 06:42:10 2009 @@ -1,5 +1,5 @@ /* -Copyright (C) 2008, The Perl Foundation. +Copyright (C) 2008-2009, The Perl Foundation. $Id$ =head1 NAME @@ -8,6 +8,8 @@ =head1 DESCRIPTION +Implementation of the Array datatype. + =head2 VTABLE Functions =over 4 @@ -29,7 +31,7 @@ maps Array maps Hash { - ATTR struct pipp_hash_table *hash_table; + ATTR struct pipp_hash_table *hash_table; /* @@ -46,7 +48,7 @@ mem_allocate_zeroed_typed(Parrot_PhpArray_attributes); arr->hash_table = pipp_hash_create(INTERP, 4); - PMC_data(SELF) = arr; + PMC_data(SELF) = arr; PObj_custom_mark_destroy_SETALL(SELF); } @@ -124,6 +126,7 @@ PippHashTable *ht; GET_ATTR_hash_table(INTERP, SELF, ht); + return ht->elementCount; } @@ -148,6 +151,7 @@ if (next_key == NULL) { /* dispatch to set_integer_keyed_str */ SELF.set_integer_keyed_str(s_key, i_val); + return; } @@ -173,7 +177,7 @@ =cut */ - VTABLE void set_integer_keyed_str(STRING *s_key, INTVAL i_val){ + VTABLE void set_integer_keyed_str(STRING *s_key, INTVAL i_val) { PippHashTable *ht; PMC *p_val = pmc_new(INTERP, enum_class_Integer); @@ -192,7 +196,7 @@ =cut */ - VTABLE void set_string_keyed_int(INTVAL i_key, INTVAL i_val){ + VTABLE void set_string_keyed_int(INTVAL i_key, INTVAL i_val) { PippHashTable *ht; PMC *p_val = pmc_new(INTERP, enum_class_Integer); @@ -224,6 +228,7 @@ if (next_key == NULL) { /* dispatch to set_pmc_keyed_str */ SELF.set_pmc_keyed_str(s_key, p_val); + return; } @@ -249,7 +254,7 @@ =cut */ - VTABLE void set_pmc_keyed_str(STRING *s_key, PMC *p_val){ + VTABLE void set_pmc_keyed_str(STRING *s_key, PMC *p_val) { PippHashTable *ht; @@ -266,7 +271,7 @@ =cut */ - VTABLE void set_pmc_keyed_int(INTVAL i_key, PMC *p_val){ + VTABLE void set_pmc_keyed_int(INTVAL i_key, PMC *p_val) { PippHashTable *ht; STRING *s_key = string_from_int(INTERP, i_key); @@ -296,6 +301,7 @@ if (next_key == NULL) { /* dispatch to set_string_keyed_str */ SELF.set_string_keyed_str(s_key, s_val); + return; } @@ -321,7 +327,7 @@ =cut */ - VTABLE void set_string_keyed_str(STRING *s_key, STRING *s_val){ + VTABLE void set_string_keyed_str(STRING *s_key, STRING *s_val) { PippHashTable *ht; PMC *p_val = pmc_new(INTERP, enum_class_String); @@ -340,7 +346,7 @@ =cut */ - VTABLE void set_string_keyed_int(INTVAL i_key, STRING *s_val){ + VTABLE void set_string_keyed_int(INTVAL i_key, STRING *s_val) { PippHashTable *ht; STRING *s_key = string_from_int(INTERP, i_key); @@ -372,6 +378,7 @@ if (next_key == NULL) { /* dispatch to set_number_keyed_str */ SELF.set_number_keyed_str(s_key, f_val); + return; } @@ -379,7 +386,7 @@ box = SELF.get_pmc_keyed_str(s_key); /* autovivify if needed */ - if (PMC_IS_NULL(box)){ + if (PMC_IS_NULL(box)) { box = pmc_new(INTERP, PMC_type(SELF)); SELF.set_pmc_keyed_str(s_key, box); } @@ -397,7 +404,7 @@ =cut */ - VTABLE void set_number_keyed_str(STRING *s_key, FLOATVAL f_val){ + VTABLE void set_number_keyed_str(STRING *s_key, FLOATVAL f_val) { PippHashTable *ht; @@ -417,7 +424,7 @@ =cut */ - VTABLE void set_number_keyed_int(INTVAL i_key, FLOATVAL f_val){ + VTABLE void set_number_keyed_int(INTVAL i_key, FLOATVAL f_val) { PippHashTable *ht; STRING *s_key = string_from_int(INTERP, i_key); @@ -454,6 +461,7 @@ /* if there isn't one (i.e. key is null) */ if (next_key == NULL) { /* dispatch to get_integer_keyed_str */ + return SELF.get_integer_keyed_str(s_key); } @@ -476,7 +484,7 @@ =cut */ - VTABLE INTVAL get_integer_keyed_str(STRING *s_key){ + VTABLE INTVAL get_integer_keyed_str(STRING *s_key) { PippHashTable *ht; PMC *p_val; @@ -497,7 +505,7 @@ =cut */ - VTABLE INTVAL get_integer_keyed_int(INTVAL i_key){ + VTABLE INTVAL get_integer_keyed_int(INTVAL i_key) { PippHashTable *ht; PMC *p_val; @@ -568,8 +576,7 @@ =cut */ - VTABLE PMC *get_pmc_keyed_str(STRING *s_key){ - + VTABLE PMC *get_pmc_keyed_str(STRING *s_key) { PippHashTable *ht; @@ -588,7 +595,7 @@ =cut */ - VTABLE PMC *get_pmc_keyed_int(INTVAL i_key){ + VTABLE PMC *get_pmc_keyed_int(INTVAL i_key) { PippHashTable *ht; STRING *s_key = string_from_int(INTERP, i_key); @@ -655,7 +662,7 @@ =cut */ - VTABLE STRING *get_string_keyed_str(STRING *s_key){ + VTABLE STRING *get_string_keyed_str(STRING *s_key) { PippHashTable *ht; PMC *p_val; @@ -677,7 +684,7 @@ =cut */ - VTABLE STRING *get_string_keyed_int(INTVAL i_key){ + VTABLE STRING *get_string_keyed_int(INTVAL i_key) { PippHashTable *ht; PMC *p_val; @@ -738,7 +745,7 @@ =cut */ - VTABLE FLOATVAL get_number_keyed_str(STRING *s_key){ + VTABLE FLOATVAL get_number_keyed_str(STRING *s_key) { PippHashTable *ht; PMC *p_val; @@ -760,7 +767,7 @@ =cut */ - VTABLE FLOATVAL get_number_keyed_int(INTVAL i_key){ + VTABLE FLOATVAL get_number_keyed_int(INTVAL i_key) { PippHashTable *ht; PMC *p_val; @@ -814,7 +821,7 @@ =cut */ - VTABLE INTVAL exists_keyed_str(STRING *s_key){ + VTABLE INTVAL exists_keyed_str(STRING *s_key) { PippHashTable *ht; @@ -832,7 +839,7 @@ =cut */ - VTABLE INTVAL exists_keyed_int(INTVAL i_key){ + VTABLE INTVAL exists_keyed_int(INTVAL i_key) { PippHashTable *ht; STRING *s_key = string_from_int(INTERP, i_key); @@ -874,6 +881,7 @@ /* recurse into that box */ VTABLE_delete_keyed(INTERP, box, next_key); + return; } @@ -887,14 +895,13 @@ =cut */ - VTABLE void delete_keyed_str(STRING *s_key){ + VTABLE void delete_keyed_str(STRING *s_key) { PippHashTable *ht; GET_ATTR_hash_table(INTERP, SELF, ht); pipp_hash_delete(INTERP, ht, s_key); - } /* @@ -907,7 +914,7 @@ =cut */ - VTABLE void delete_keyed_int(INTVAL i_key){ + VTABLE void delete_keyed_int(INTVAL i_key) { PippHashTable *ht; STRING *s_key = string_from_int(INTERP, i_key); @@ -1427,7 +1434,7 @@ =cut */ - VTABLE PMC *get_iter(){ + VTABLE PMC *get_iter() { PippHashTable *ht; PippBucket *bkt; @@ -1497,15 +1504,15 @@ */ VTABLE void assign_pmc(PMC *src) { - PMC *value_copy; - STRING *key_copy; + PMC *value_copy; + STRING *key_copy; PippHashTable *my_ht; GET_ATTR_hash_table(INTERP, SELF, my_ht); if (PMC_type(src) == PMC_type(SELF)) { - PippBucket *bkt; + PippBucket *bkt; PippHashTable *src_ht; GET_ATTR_hash_table(INTERP, src, src_ht); @@ -1809,7 +1816,7 @@ */ - VTABLE STRING *get_repr(){ + VTABLE STRING *get_repr() { PippHashTable *ht; PippBucket *bkt;