Ticket #1357 (closed patch: fixed)

Opened 5 years ago

Last modified 5 years ago

[patch]changed capture.pmc to use GET_ATTR syntax

Reported by: jimmy Owned by: jkeenan
Priority: normal Milestone:
Component: core Version: 1.8.0
Severity: medium Keywords:
Cc: Language:
Patch status: applied Platform:

Description

changed capture.pmc to use GET_ATTR syntax

Index: src/pmc/capture.pmc
===================================================================
--- src/pmc/capture.pmc	(版本 42868)
+++ src/pmc/capture.pmc	(工作副本)
@@ -18,13 +18,6 @@
 
 */
 
-#define CAPTURE_array_CREATE(i, obj) \
-    if (!PARROT_CAPTURE(obj)->array) \
-        PARROT_CAPTURE(obj)->array = pmc_new((i), enum_class_ResizablePMCArray);
-#define CAPTURE_hash_CREATE(i, obj) \
-    if (!PARROT_CAPTURE(obj)->hash) \
-        PARROT_CAPTURE(obj)->hash = pmc_new((i), enum_class_Hash);
-
 pmclass Capture auto_attrs {
     ATTR PMC    *array;
     ATTR PMC    *hash;
@@ -40,6 +33,9 @@
 */
 
     VTABLE void init() {
+        SET_ATTR_array(interp, SELF,
+                pmc_new(INTERP, enum_class_ResizablePMCArray));
+        SET_ATTR_hash(INTERP, SELF, pmc_new(INTERP, enum_class_Hash));
         PObj_custom_mark_SET(SELF);
     }
 
@@ -85,27 +81,31 @@
 */
 
     VTABLE void set_number_keyed_int(INTVAL key, FLOATVAL value) {
-        CAPTURE_array_CREATE(INTERP, SELF);
-        VTABLE_set_number_keyed_int(INTERP, PARROT_CAPTURE(SELF)->array,
-                                    key, value);
+        PMC *array;
+
+        GET_ATTR_array(INTERP, SELF, array);
+        VTABLE_set_number_keyed_int(INTERP, array, key, value);
     }
 
     VTABLE void set_integer_keyed_int(INTVAL key, INTVAL value) {
-        CAPTURE_array_CREATE(INTERP, SELF);
-        VTABLE_set_integer_keyed_int(INTERP, PARROT_CAPTURE(SELF)->array,
-                                     key, value);
+        PMC *array;
+
+        GET_ATTR_array(INTERP, SELF, array);
+        VTABLE_set_integer_keyed_int(INTERP, array, key, value);
     }
 
     VTABLE void set_pmc_keyed_int(INTVAL key, PMC *value) {
-        CAPTURE_array_CREATE(INTERP, SELF);
-        VTABLE_set_pmc_keyed_int(INTERP, PARROT_CAPTURE(SELF)->array,
-                                 key, value);
+        PMC *array;
+
+        GET_ATTR_array(INTERP, SELF, array);
+        VTABLE_set_pmc_keyed_int(INTERP, array, key, value);
     }
 
     VTABLE void set_string_keyed_int(INTVAL key, STRING *value) {
-        CAPTURE_array_CREATE(INTERP, SELF);
-        VTABLE_set_string_keyed_int(INTERP, PARROT_CAPTURE(SELF)->array,
-                                    key, value);
+        PMC *array;
+
+        GET_ATTR_array(INTERP, SELF, array);
+        VTABLE_set_string_keyed_int(INTERP, array, key, value);
     }
 
 /*
@@ -125,31 +125,47 @@
 */
 
     VTABLE FLOATVAL get_number_keyed_int(INTVAL key) {
-        if (!(PARROT_CAPTURE(SELF)->array))
+        PMC *array;
+
+        GET_ATTR_array(INTERP, SELF, array);
+
+        if (!array)
             return 0.0;
-        return VTABLE_get_number_keyed_int(INTERP, PARROT_CAPTURE(SELF)->array,
-                                           key);
+
+        return VTABLE_get_number_keyed_int(INTERP, array, key);
     }
 
     VTABLE INTVAL get_integer_keyed_int(INTVAL key) {
-        if (!(PARROT_CAPTURE(SELF)->array))
+        PMC *array;
+
+        GET_ATTR_array(INTERP, SELF, array);
+
+        if (!array)
             return 0;
-        return VTABLE_get_integer_keyed_int(INTERP, PARROT_CAPTURE(SELF)->array,
-                                            key);
+
+        return VTABLE_get_integer_keyed_int(INTERP, array, key);
     }
 
     VTABLE PMC *get_pmc_keyed_int(INTVAL key) {
-        if (!(PARROT_CAPTURE(SELF)->array))
+        PMC *array;
+
+        GET_ATTR_array(INTERP, SELF, array);
+
+        if (!array)
             return PMCNULL;
-        return VTABLE_get_pmc_keyed_int(INTERP, PARROT_CAPTURE(SELF)->array,
-                                        key);
+
+        return VTABLE_get_pmc_keyed_int(INTERP, array, key);
     }
 
     VTABLE STRING *get_string_keyed_int(INTVAL key) {
-        if (!(PARROT_CAPTURE(SELF)->array))
+        PMC *array;
+
+        GET_ATTR_array(INTERP, SELF, array);
+
+        if (!array)
             return CONST_STRING(INTERP, "");
-        return VTABLE_get_string_keyed_int(INTERP, PARROT_CAPTURE(SELF)->array,
-                                           key);
+
+        return VTABLE_get_string_keyed_int(INTERP, array, key);
     }
 
 /*
@@ -179,43 +195,66 @@
 */
 
     VTABLE void push_float(FLOATVAL value) {
-        CAPTURE_array_CREATE(INTERP, SELF);
-        VTABLE_push_float(INTERP, PARROT_CAPTURE(SELF)->array, value);
+        PMC *array;
+
+        GET_ATTR_array(INTERP, SELF, array);
+
+        VTABLE_push_float(INTERP, array, value);
     }
 
     VTABLE void push_integer(INTVAL value) {
-        CAPTURE_array_CREATE(INTERP, SELF);
-        VTABLE_push_integer(INTERP, PARROT_CAPTURE(SELF)->array, value);
+        PMC *array;
+
+        GET_ATTR_array(INTERP, SELF, array);
+
+        VTABLE_push_integer(INTERP, array, value);
     }
 
     VTABLE void push_pmc(PMC *value) {
-        CAPTURE_array_CREATE(INTERP, SELF);
-        VTABLE_push_pmc(INTERP, PARROT_CAPTURE(SELF)->array, value);
+        PMC *array;
+
+        GET_ATTR_array(INTERP, SELF, array);
+
+        VTABLE_push_pmc(INTERP, array, value);
     }
 
     VTABLE void push_string(STRING *value) {
-        CAPTURE_array_CREATE(INTERP, SELF);
-        VTABLE_push_string(INTERP, PARROT_CAPTURE(SELF)->array, value);
+        PMC *array;
+
+        GET_ATTR_array(INTERP, SELF, array);
+
+        VTABLE_push_string(INTERP, array, value);
     }
+    VTABLE void unshift_float(FLOATVAL value) {
+        PMC *array;
 
-    VTABLE void unshift_float(FLOATVAL value) {
-        CAPTURE_array_CREATE(INTERP, SELF);
-        VTABLE_unshift_float(INTERP, PARROT_CAPTURE(SELF)->array, value);
+        GET_ATTR_array(INTERP, SELF, array);
+
+        VTABLE_unshift_float(INTERP, array, value);
     }
 
     VTABLE void unshift_integer(INTVAL value) {
-        CAPTURE_array_CREATE(INTERP, SELF);
-        VTABLE_unshift_integer(INTERP, PARROT_CAPTURE(SELF)->array, value);
+        PMC *array;
+
+        GET_ATTR_array(INTERP, SELF, array);
+
+        VTABLE_unshift_integer(INTERP, array, value);
     }
 
     VTABLE void unshift_pmc(PMC *value) {
-        CAPTURE_array_CREATE(INTERP, SELF);
-        VTABLE_unshift_pmc(INTERP, PARROT_CAPTURE(SELF)->array, value);
+        PMC *array;
+
+        GET_ATTR_array(INTERP, SELF, array);
+
+        VTABLE_unshift_pmc(INTERP, array, value);
     }
 
     VTABLE void unshift_string(STRING *value) {
-        CAPTURE_array_CREATE(INTERP, SELF);
-        VTABLE_unshift_string(INTERP, PARROT_CAPTURE(SELF)->array, value);
+        PMC *array;
+
+        GET_ATTR_array(INTERP, SELF, array);
+
+        VTABLE_unshift_string(INTERP, array, value);
     }
 
 /*
@@ -245,43 +284,67 @@
 */
 
     VTABLE FLOATVAL pop_float() {
-        CAPTURE_array_CREATE(INTERP, SELF);
-        return VTABLE_pop_float(INTERP, PARROT_CAPTURE(SELF)->array);
+        PMC *array;
+
+        GET_ATTR_array(INTERP, SELF, array);
+
+        return VTABLE_pop_float(INTERP, array);
     }
 
     VTABLE INTVAL pop_integer() {
-        CAPTURE_array_CREATE(INTERP, SELF);
-        return VTABLE_pop_integer(INTERP, PARROT_CAPTURE(SELF)->array);
+        PMC *array;
+
+        GET_ATTR_array(INTERP, SELF, array);
+
+        return VTABLE_pop_integer(INTERP, array);
     }
 
     VTABLE PMC *pop_pmc() {
-        CAPTURE_array_CREATE(INTERP, SELF);
-        return VTABLE_pop_pmc(INTERP, PARROT_CAPTURE(SELF)->array);
+        PMC *array;
+
+        GET_ATTR_array(INTERP, SELF, array);
+
+        return VTABLE_pop_pmc(INTERP, array);
     }
 
     VTABLE STRING *pop_string() {
-        CAPTURE_array_CREATE(INTERP, SELF);
-        return VTABLE_pop_string(INTERP, PARROT_CAPTURE(SELF)->array);
+        PMC *array;
+
+        GET_ATTR_array(INTERP, SELF, array);
+
+        return VTABLE_pop_string(INTERP, array);
     }
 
     VTABLE FLOATVAL shift_float() {
-        CAPTURE_array_CREATE(INTERP, SELF);
-        return VTABLE_shift_float(INTERP, PARROT_CAPTURE(SELF)->array);
+        PMC *array;
+
+        GET_ATTR_array(INTERP, SELF, array);
+
+        return VTABLE_shift_float(INTERP, array);
     }
 
     VTABLE INTVAL shift_integer() {
-        CAPTURE_array_CREATE(INTERP, SELF);
-        return VTABLE_shift_integer(INTERP, PARROT_CAPTURE(SELF)->array);
+        PMC *array;
+
+        GET_ATTR_array(INTERP, SELF, array);
+
+        return VTABLE_shift_integer(INTERP, array);
     }
 
     VTABLE PMC *shift_pmc() {
-        CAPTURE_array_CREATE(INTERP, SELF);
-        return VTABLE_shift_pmc(INTERP, PARROT_CAPTURE(SELF)->array);
+        PMC *array;
+
+        GET_ATTR_array(INTERP, SELF, array);
+
+        return VTABLE_shift_pmc(INTERP, array);
     }
 
     VTABLE STRING *shift_string() {
-        CAPTURE_array_CREATE(INTERP, SELF);
-        return VTABLE_shift_string(INTERP, PARROT_CAPTURE(SELF)->array);
+        PMC *array;
+
+        GET_ATTR_array(INTERP, SELF, array);
+
+        return VTABLE_shift_string(INTERP, array);
     }
 
 /*
@@ -307,29 +370,45 @@
 */
 
     VTABLE INTVAL elements() {
-        if (!PARROT_CAPTURE(SELF)->array) return 0;
-        return VTABLE_elements(INTERP, PARROT_CAPTURE(SELF)->array);
+        PMC *array;
+
+        GET_ATTR_array(INTERP, SELF, array);
+
+        if (!array)
+	    return 0;
+
+        return VTABLE_elements(INTERP, array);
     }
 
     VTABLE INTVAL defined_keyed_int(INTVAL key) {
-        if (!PARROT_CAPTURE(SELF)->array)
+        PMC *array;
+
+        GET_ATTR_array(INTERP, SELF, array);
+
+        if (!array)
             return 0;
 
-        return VTABLE_defined_keyed_int(INTERP, PARROT_CAPTURE(SELF)->array,
-                                        key);
+        return VTABLE_defined_keyed_int(INTERP, array, key);
     }
 
     VTABLE INTVAL exists_keyed_int(INTVAL key) {
-        if (!PARROT_CAPTURE(SELF)->array)
+        PMC *array;
+
+        GET_ATTR_array(INTERP, SELF, array);
+
+        if (!array)
             return 0;
 
-        return VTABLE_exists_keyed_int(INTERP, PARROT_CAPTURE(SELF)->array,
-                                               key);
+        return VTABLE_exists_keyed_int(INTERP, array, key);
     }
 
     VTABLE void delete_keyed_int(INTVAL key) {
-        if (PARROT_CAPTURE(SELF)->array)
-            VTABLE_delete_keyed_int(INTERP, PARROT_CAPTURE(SELF)->array, key);
+        PMC *array;
+
+        GET_ATTR_array(INTERP, SELF, array);
+
+        if (array)
+            VTABLE_delete_keyed_int(INTERP, array, key);
     }
 
 /*
@@ -349,24 +428,35 @@
 */
 
     VTABLE void set_number_keyed(PMC *key, FLOATVAL value) {
-        CAPTURE_hash_CREATE(INTERP, SELF);
-        VTABLE_set_number_keyed(INTERP, PARROT_CAPTURE(SELF)->hash, key, value);
+        PMC *hash;
+
+        GET_ATTR_hash(INTERP, SELF, hash);
+
+        VTABLE_set_number_keyed(INTERP, hash, key, value);
     }
 
     VTABLE void set_integer_keyed(PMC *key, INTVAL value) {
-        CAPTURE_hash_CREATE(INTERP, SELF);
-        VTABLE_set_integer_keyed(INTERP, PARROT_CAPTURE(SELF)->hash,
-                                 key, value);
+        PMC *hash;
+
+        GET_ATTR_hash(INTERP, SELF, hash);
+
+        VTABLE_set_integer_keyed(INTERP, hash, key, value);
     }
 
     VTABLE void set_pmc_keyed(PMC *key, PMC *value) {
-        CAPTURE_hash_CREATE(INTERP, SELF);
-        VTABLE_set_pmc_keyed(INTERP, PARROT_CAPTURE(SELF)->hash, key, value);
+        PMC *hash;
+
+        GET_ATTR_hash(INTERP, SELF, hash);
+
+        VTABLE_set_pmc_keyed(INTERP, hash, key, value);
     }
 
     VTABLE void set_string_keyed(PMC *key, STRING *value) {
-        CAPTURE_hash_CREATE(INTERP, SELF);
-        VTABLE_set_string_keyed(INTERP, PARROT_CAPTURE(SELF)->hash, key, value);
+        PMC *hash;
+
+        GET_ATTR_hash(INTERP, SELF, hash);
+
+        VTABLE_set_string_keyed(INTERP, hash, key, value);
     }
 
 /*
@@ -386,28 +476,47 @@
 */
 
     VTABLE FLOATVAL get_number_keyed(PMC *key) {
-        if (!(PARROT_CAPTURE(SELF)->hash))
+        PMC *hash;
+
+        GET_ATTR_hash(INTERP, SELF, hash);
+
+        if (!hash)
             return 0.0;
-        return VTABLE_get_number_keyed(INTERP, PARROT_CAPTURE(SELF)->hash, key);
+
+        return VTABLE_get_number_keyed(INTERP, hash, key);
     }
 
     VTABLE INTVAL get_integer_keyed(PMC *key) {
-        if (!(PARROT_CAPTURE(SELF)->hash))
+        PMC *hash;
+
+        GET_ATTR_hash(INTERP, SELF, hash);
+
+        if (!hash)
             return 0;
-        return VTABLE_get_integer_keyed(INTERP, PARROT_CAPTURE(SELF)->hash,
-                                        key);
+
+        return VTABLE_get_integer_keyed(INTERP, hash, key);
     }
 
     VTABLE PMC *get_pmc_keyed(PMC *key) {
-        if (!(PARROT_CAPTURE(SELF)->hash))
+        PMC *hash;
+
+        GET_ATTR_hash(INTERP, SELF, hash);
+
+        if (!hash)
             return PMCNULL;
-        return VTABLE_get_pmc_keyed(INTERP, PARROT_CAPTURE(SELF)->hash, key);
+
+        return VTABLE_get_pmc_keyed(INTERP, hash, key);
     }
 
     VTABLE STRING *get_string_keyed(PMC *key) {
-        if (!(PARROT_CAPTURE(SELF)->hash))
+        PMC *hash;
+
+        GET_ATTR_hash(INTERP, SELF, hash);
+
+        if (!hash)
             return CONST_STRING(INTERP, "");
-        return VTABLE_get_string_keyed(INTERP, PARROT_CAPTURE(SELF)->hash, key);
+
+        return VTABLE_get_string_keyed(INTERP, hash, key);
     }
 
 /*
@@ -427,27 +536,35 @@
 */
 
     VTABLE void set_number_keyed_str(STRING *key, FLOATVAL value) {
-        CAPTURE_hash_CREATE(INTERP, SELF);
-        VTABLE_set_number_keyed_str(INTERP, PARROT_CAPTURE(SELF)->hash,
-                                    key, value);
+        PMC *hash;
+
+        GET_ATTR_hash(INTERP, SELF, hash);
+
+        VTABLE_set_number_keyed_str(INTERP, hash, key, value);
     }
 
     VTABLE void set_integer_keyed_str(STRING *key, INTVAL value) {
-        CAPTURE_hash_CREATE(INTERP, SELF);
-        VTABLE_set_integer_keyed_str(INTERP, PARROT_CAPTURE(SELF)->hash,
-                                     key, value);
+        PMC *hash;
+
+        GET_ATTR_hash(INTERP, SELF, hash);
+
+        VTABLE_set_integer_keyed_str(INTERP, hash, key, value);
     }
 
     VTABLE void set_pmc_keyed_str(STRING *key, PMC *value) {
-        CAPTURE_hash_CREATE(INTERP, SELF);
-        VTABLE_set_pmc_keyed_str(INTERP, PARROT_CAPTURE(SELF)->hash,
-                                 key, value);
+        PMC *hash;
+
+        GET_ATTR_hash(INTERP, SELF, hash);
+
+        VTABLE_set_pmc_keyed_str(INTERP, hash, key, value);
     }
 
     VTABLE void set_string_keyed_str(STRING *key, STRING *value) {
-        CAPTURE_hash_CREATE(INTERP, SELF);
-        VTABLE_set_string_keyed_str(INTERP, PARROT_CAPTURE(SELF)->hash,
-                                    key, value);
+        PMC *hash;
+
+        GET_ATTR_hash(INTERP, SELF, hash);
+
+        VTABLE_set_string_keyed_str(INTERP, hash, key, value);
     }
 
 /*
@@ -467,31 +584,46 @@
 */
 
     VTABLE FLOATVAL get_number_keyed_str(STRING *key) {
-        if (!(PARROT_CAPTURE(SELF)->hash))
+        PMC *hash;
+
+        GET_ATTR_hash(INTERP, SELF, hash);
+
+        if (!hash)
             return 0.0;
-        return VTABLE_get_number_keyed_str(INTERP, PARROT_CAPTURE(SELF)->hash,
-                                           key);
+
+        return VTABLE_get_number_keyed_str(INTERP, hash, key);
     }
 
     VTABLE INTVAL get_integer_keyed_str(STRING *key) {
-        if (!(PARROT_CAPTURE(SELF)->hash))
+        PMC *hash;
+
+        GET_ATTR_hash(INTERP, SELF, hash);
+
+        if (!hash)
             return 0;
-        return VTABLE_get_integer_keyed_str(INTERP, PARROT_CAPTURE(SELF)->hash,
-                                            key);
+
+        return VTABLE_get_integer_keyed_str(INTERP, hash, key);
     }
 
     VTABLE PMC *get_pmc_keyed_str(STRING *key) {
-        if (!(PARROT_CAPTURE(SELF)->hash))
+        PMC *hash;
+
+        GET_ATTR_hash(INTERP, SELF, hash);
+
+        if (!hash)
             return PMCNULL;
-        return VTABLE_get_pmc_keyed_str(INTERP, PARROT_CAPTURE(SELF)->hash,
-                                        key);
+
+        return VTABLE_get_pmc_keyed_str(INTERP, hash, key);
     }
 
     VTABLE STRING *get_string_keyed_str(STRING *key) {
-        if (!(PARROT_CAPTURE(SELF)->hash))
+        PMC *hash;
+
+        GET_ATTR_hash(INTERP, SELF, hash);
+
+        if (!hash)
             return CONST_STRING(INTERP, "");
-        return VTABLE_get_string_keyed_str(INTERP, PARROT_CAPTURE(SELF)->hash,
-                                           key);
+        return VTABLE_get_string_keyed_str(INTERP, hash, key);
     }
 
 /*
@@ -513,18 +645,34 @@
 */
 
     VTABLE INTVAL defined_keyed(PMC *key) {
-        if (!PARROT_CAPTURE(SELF)->hash) return 0;
-        return VTABLE_defined_keyed(INTERP, PARROT_CAPTURE(SELF)->hash, key);
+        PMC *hash;
+
+        GET_ATTR_hash(INTERP, SELF, hash);
+
+        if (!hash)
+            return 0;
+
+        return VTABLE_defined_keyed(INTERP, hash, key);
     }
 
     VTABLE INTVAL exists_keyed(PMC *key) {
-        if (!PARROT_CAPTURE(SELF)->hash) return 0;
-        return VTABLE_exists_keyed(INTERP, PARROT_CAPTURE(SELF)->hash, key);
+        PMC *hash;
+
+        GET_ATTR_hash(INTERP, SELF, hash);
+
+        if (!hash)
+            return 0;
+
+        return VTABLE_exists_keyed(INTERP, hash, key);
     }
 
     VTABLE void delete_keyed(PMC *key) {
-        if (PARROT_CAPTURE(SELF)->hash)
-            VTABLE_delete_keyed(INTERP, PARROT_CAPTURE(SELF)->hash, key);
+        PMC *hash;
+
+        GET_ATTR_hash(INTERP, SELF, hash);
+
+        if (hash)
+            VTABLE_delete_keyed(INTERP, hash, key);
     }
 
 /*
@@ -546,18 +694,32 @@
 */
 
     VTABLE INTVAL defined_keyed_str(STRING *key) {
-        if (!PARROT_CAPTURE(SELF)->hash) return 0;
-        return VTABLE_defined_keyed_str(INTERP, PARROT_CAPTURE(SELF)->hash, key);
+        PMC *hash;
+
+        GET_ATTR_hash(INTERP, SELF, hash);
+
+        if (!hash)
+            return 0;
+        return VTABLE_defined_keyed_str(INTERP, hash, key);
     }
 
     VTABLE INTVAL exists_keyed_str(STRING *key) {
-        if (!PARROT_CAPTURE(SELF)->hash) return 0;
-        return VTABLE_exists_keyed_str(INTERP, PARROT_CAPTURE(SELF)->hash, key);
+        PMC *hash;
+
+        GET_ATTR_hash(INTERP, SELF, hash);
+
+        if (!hash)
+            return 0;
+        return VTABLE_exists_keyed_str(INTERP, hash, key);
     }
 
     VTABLE void delete_keyed_str(STRING *key) {
-        if (PARROT_CAPTURE(SELF)->hash)
-            VTABLE_delete_keyed_str(INTERP, PARROT_CAPTURE(SELF)->hash, key);
+        PMC *hash;
+
+        GET_ATTR_hash(INTERP, SELF, hash);
+
+        if (hash)
+            VTABLE_delete_keyed_str(INTERP, hash, key);
     }
 
 /*
@@ -573,12 +735,15 @@
 
     VTABLE void set_pmc(PMC *capture) {
         if (PMC_IS_NULL(capture)) {
-            PARROT_CAPTURE(SELF)->array = NULL;
-            PARROT_CAPTURE(SELF)->hash = NULL;
+            SET_ATTR_array(INTERP, SELF, NULL);
+            SET_ATTR_hash(INTERP, SELF, NULL);
         }
         else if (VTABLE_isa(INTERP, capture, CONST_STRING(INTERP, "Capture"))) {
-            PARROT_CAPTURE(SELF)->array = PARROT_CAPTURE(capture)->array;
-            PARROT_CAPTURE(SELF)->hash  = PARROT_CAPTURE(capture)->hash;
+            PMC *array, *hash;
+            GET_ATTR_array(INTERP, capture, array);
+            GET_ATTR_hash(INTERP, capture, hash);
+            SET_ATTR_array(INTERP, SELF, array);
+            SET_ATTR_hash(INTERP, SELF, hash);
         }
         else
             Parrot_ex_throw_from_c_args(INTERP, NULL, EXCEPTION_INVALID_OPERATION,
@@ -597,7 +762,7 @@
 */
 
     VTABLE STRING *get_string() {
-        STRING *classname = VTABLE_name(INTERP, SELF);
+        const STRING * const classname = VTABLE_name(INTERP, SELF);
         return Parrot_sprintf_c(INTERP, "%S[0x%x]", classname, SELF);
     }
 
@@ -612,11 +777,13 @@
 */
 
     VTABLE void mark() {
-        Parrot_Capture_attributes * const data = PARROT_CAPTURE(SELF);
-        if (!data)
-            return;
-        Parrot_gc_mark_PMC_alive(INTERP, data->array);
-        Parrot_gc_mark_PMC_alive(INTERP, data->hash);
+        PMC *array, *hash;
+
+        GET_ATTR_array(INTERP, SELF, array);
+        GET_ATTR_hash(INTERP, SELF, hash);
+
+        Parrot_gc_mark_PMC_alive(INTERP, array);
+        Parrot_gc_mark_PMC_alive(INTERP, hash);
     }
 
 /*
@@ -634,20 +801,21 @@
     METHOD list() {
         PMC *capt_array;
         PMC *capt = SELF;
+
         /* XXX:  This workaround is for when we get here as
                  part of a subclass of Capture */
         if (PObj_is_object_TEST(SELF)) {
-            STRING *attribute = CONST_STRING(interp, "proxy");
             PMC    *classobj;
-            PMC *ns = INTERP->root_namespace;
-            ns = Parrot_get_namespace_keyed_str(INTERP, ns, CONST_STRING(INTERP, "parrot"));
-            ns = Parrot_get_namespace_keyed_str(INTERP, ns, CONST_STRING(INTERP, "Capture"));
-            classobj  = Parrot_oo_get_class(INTERP, ns);
-            capt              = VTABLE_get_attr_keyed(interp, SELF, classobj, attribute);
+            PMC    *ns        = INTERP->root_namespace;
+            STRING *attribute = CONST_STRING(INTERP, "proxy");
+
+            ns                = Parrot_get_namespace_keyed_str(INTERP, ns, CONST_STRING(INTERP, "parrot"));
+            ns                = Parrot_get_namespace_keyed_str(INTERP, ns, CONST_STRING(INTERP, "Capture"));
+            classobj          = Parrot_oo_get_class(INTERP, ns);
+            capt              = VTABLE_get_attr_keyed(INTERP, SELF, classobj, attribute);
         }
 
-        CAPTURE_array_CREATE(INTERP, capt);
-        capt_array = PARROT_CAPTURE(capt)->array;
+        GET_ATTR_array(INTERP, capt, capt_array);
 
         RETURN(PMC *capt_array);
     }
@@ -658,13 +826,15 @@
         /* XXX:  This workaround is for when we get here as
                  part of a subclass of Capture */
         if (PObj_is_object_TEST(SELF)) {
-            STRING *classname = CONST_STRING(INTERP, "Capture");
-            PMC    *classobj  = Parrot_oo_get_class_str(INTERP, classname);
-            STRING *attribute = CONST_STRING(interp, "proxy");
-            capt              = VTABLE_get_attr_keyed(interp, SELF, classobj, attribute);
+            STRING * const classname = CONST_STRING(INTERP, "Capture");
+            STRING        *attribute = CONST_STRING(INTERP, "proxy");
+            PMC           *classobj  = Parrot_oo_get_class_str(INTERP, classname);
+
+            capt                     = VTABLE_get_attr_keyed(INTERP, SELF, classobj, attribute);
         }
-        CAPTURE_hash_CREATE(INTERP, capt);
-        capt_hash = PARROT_CAPTURE(capt)->hash;
+
+        GET_ATTR_hash(INTERP, capt, capt_hash);
+
         RETURN(PMC *capt_hash);
     }
 
Index: t/pmc/capture.t
===================================================================
--- t/pmc/capture.t	(版本 42868)
+++ t/pmc/capture.t	(工作副本)
@@ -8,7 +8,7 @@
 
 =head1 SYNOPSIS
 
-    % prove t/pmc/capture.t
+    % parrot t/pmc/capture.t
 
 =head1 DESCRIPTION
 

Attachments

three_test_failures.txt Download (46.0 KB) - added by jkeenan 5 years ago.
Failure in 3 files observed after applying patches from 6 tickets
capture.pmc.patch Download (22.4 KB) - added by jimmy 5 years ago.

Change History

in reply to: ↑ description   Changed 5 years ago by jkeenan

  • component changed from none to core
  • patch set to new

Replying to jimmy:

changed capture.pmc to use GET_ATTR syntax

As noted in  this comment on TT #1348, I've been looking at whether your patches work with one another, "work" meaning "does not prevent Parrot from completing make successfully".

This patch works with:

* the Vtable.pm patch submitted in TT #1354

* the arrayiterator.pmc patch submitted in TT #1349

* the bignum.pmc patch submitted in TT #1351

* the "cage2" patch submitted in TT #1346.

make completed successfully. At that point I ran make test. I got failures in three files. Since I have not been running make test after each build, I can't attribute the test failures to specific patches yet. See attachment.

Thank you very much.

kid51

Changed 5 years ago by jkeenan

Failure in 3 files observed after applying patches from 6 tickets

follow-up: ↓ 3   Changed 5 years ago by jkeenan

  • patch changed from new to rejected

When I applied just this patch by itself, the same 3 files failed during make test as previously reported. So the patch cannot be accepted in its current form.

Thank you very much.

kid51

in reply to: ↑ 2 ; follow-up: ↓ 4   Changed 5 years ago by jimmy

Replying to jkeenan:

When I applied just this patch by itself, the same 3 files failed during make test as previously reported. So the patch cannot be accepted in its current form. Thank you very much. kid51

Hello, I uploaded the patch now it passed those tests. Could you test again?

Thank you very much.

JimmyZ

Changed 5 years ago by jimmy

in reply to: ↑ 3   Changed 5 years ago by jkeenan

  • status changed from new to assigned
  • owner set to jkeenan
  • patch changed from rejected to applied

Replying to jimmy:

Hello, I uploaded the patch now it passed those tests. Could you test again?

This time it passed. Applied in r42933. I will keep the ticket open for several days to record any comments or complaints.

Thank you very much.
kid51

follow-up: ↓ 6   Changed 5 years ago by cotto

To all, please be very careful when before committing patches. In this case, a minor sanity check was dropped. Jimmy noticed this and I committed the fix in r42958, but committers should be very careful when reviewing patches to ensure that any conversions don't lose code.

in reply to: ↑ 5   Changed 5 years ago by jkeenan

Replying to cotto:

To all, please be very careful when before committing patches. In this case, a minor sanity check was dropped. Jimmy noticed this and I committed the fix in r42958, but committers should be very careful when reviewing patches to ensure that any conversions don't lose code.

Cotto:

Yes, I confess: I was the perpetrator of that erroneous commit!

But I think it should be noted that at the point this weekend when I began reviewing JimmyZ's patches, he had 11 tickets open for review. And our PMC/C experts were not exactly rushing to review them. ;-)

I spent quite a few hours running those patches through make and make test and got JimmyZ to correct test failures where I found them. Once we got tests passing, I then had to decide: Do I hold off on committing in the hope that a C expert will review them? Or do I commit them now, both to enable JimmyZ to see some progress and to run the tests through our Smolder testers. I chose the latter in three cases.

The fact that we could drop three lines and still get the tests to pass suggests that our test coverage of src/pmc/capture.pmc was deficient. And, indeed, that was the case. Cf.  this coverage analysis at line 822.

So, JimmyZ, could you explore whether we can add a test to cover the statement at line 822?

Thank you very much.
kid51

  Changed 5 years ago by jimmy

Yes, parrot needs more tests. When I was refactoring them, I got all tests passed, but parrot maked failed when covered pir in pge to pbc. But, I don't know how to write a test to cover line 822, I'm not good at PIR now. :)

JimmyZ

follow-up: ↓ 9   Changed 5 years ago by cotto

Jim, I hope you don't see this as anything personal. I certainly didn't intend it that way.

That said, there are worse things than having tt filled with patch tickets awaiting review. There's a lot of poor code in Parrot and much of it bears rewriting, but we need to be careful not to introduce regressions, especially if they're regressions that wouldn't be caught by the test suite. Patches shouldn't be applied unless the committer has a high degree of confidence that they don't introduce regressions, and our test suite is only the second-best tool we have to test against those. If anyone doesn't have full confidence in his ability to review a patch, he should wait until some who does has the tuits. Note that bumping tickets and bugging people on #parrot is also a valid alternative. This will mean delays (though hopefully they won't be burdensome), but it'll also mean that we can have more confidence about what's going into the bird.

That said, I've been going through JimmyZ's patches and trying to review one or two a night this week. It was the fact that he had so many submitted that got me started. It's great they he's been submitting them and they're appreciated, even if it takes time to get them properly reviewed and committed. JimmyZ, keep 'em coming! We'll get to them.

in reply to: ↑ 8   Changed 5 years ago by jkeenan

Replying to cotto:

If anyone doesn't have full confidence in his ability to review a patch, he should wait until some who does has the tuits.

And wait. And wait. And wait. I've tried that and, for the most part, it doesn't work.

Note that bumping tickets and bugging people on #parrot is also a valid alternative.

Let me give you an illustration of how difficult it is to get feedback on many tickets. TT #509 was filed by gerd 9 months ago. He and wayland posted patches up until 4 months ago. I tried to reconcile people's differences, created the tt509_install_files branch and applied wayland's most recent patch to that. I asked for people to review that branch (a) in the TT; (b) on #parrot; (c) on #parrot private message to likely reviewers; and (d) in the weekly report section of #parrotsketch. Total amount of feedback from these efforts: zilch.

As a consequence, I find that over time I have reduced the scope of what I pay attention to in the Parrot project as well as the hours I devote to it. The only reasons that I don't drop out completely are the facts that: (a) other open source projects I'm interested in seem to have less of a sense of ongoing community than Parrot; and (b) even in my narrowed scope I can be of some benefit to non-committers who have something to contribute to the project (e.g., my work on JimmyZ's patches this past weekend).

kid51

  Changed 5 years ago by jkeenan

  • status changed from assigned to closed
  • resolution set to fixed

We haven't had any complaints about the status of the patch since r42958, and I can't find any failures in our recent Smolder reports attributable to this patch.

So I'm closing this ticket. Thanks again, jimmy!

(We can take the discussion about Parrot process to the list.)

Thank you very much.
kid51

Note: See TracTickets for help on using tickets.