chromatic wrote:
Yes, that's correct.

There is 2 patches:

1. complex.pmc single replacement of PMC_str_val.
2. string.pmc.
  Replaces PMC_str_val;
  Replace VTABLE_get_string(INTERP, SELF) with SELF.get_string();
In set_*_keyed change logick to invoke VTABLE_set_string_native instead of replacing in place.

--
Bacek.
diff --git a/src/pmc/complex.pmc b/src/pmc/complex.pmc
index b147e88..74e61fe 100644
--- a/src/pmc/complex.pmc
+++ b/src/pmc/complex.pmc
@@ -328,7 +328,7 @@ C<complex> object according to 2.1. Built-in Functions.
             PMC * const arg = REG_PMC(interp, 5);
 
             if (arg->vtable->base_type == enum_class_String)
-                VTABLE_set_string_native(INTERP, res, PMC_str_val(arg));
+                VTABLE_set_string_native(INTERP, res, VTABLE_get_string(interp, arg));
             else
                 RE(res) = VTABLE_get_number(INTERP, arg);
         }
commit 377da82bd0a527193d684dc211007839785f2409
Author: Vasily Chekalkin <[EMAIL PROTECTED](none)>
Date:   Sat Sep 13 10:05:30 2008 +1000

    Use less PMC_str_val in favour of VTABLE_get_string. Replace VTABLE_get_string(INTERP, SELF) with SELF.get_string() for readablity sake

diff --git a/src/pmc/string.pmc b/src/pmc/string.pmc
index 6cac0e9..ced7562 100644
--- a/src/pmc/string.pmc
+++ b/src/pmc/string.pmc
@@ -89,7 +89,7 @@ Creates a copy of the string.
     VTABLE PMC *clone() {
         PMC * const dest = pmc_new_noinit(INTERP, SELF->vtable->base_type);
         PObj_custom_mark_SET(dest);
-        PMC_str_val(dest) = string_copy(INTERP, VTABLE_get_string(INTERP, SELF));
+        PMC_str_val(dest) = string_copy(INTERP, SELF.get_string());
         return dest;
     }
 
@@ -104,7 +104,7 @@ Returns the integer representation of the string.
 */
 
     VTABLE INTVAL get_integer() {
-        STRING * const s = (STRING *)VTABLE_get_string(INTERP, SELF);
+        STRING * const s = SELF.get_string();
         return string_to_int(INTERP, s);
     }
 
@@ -119,7 +119,7 @@ Returns the floating-point representation of the string.
 */
 
     VTABLE FLOATVAL get_number() {
-        STRING * const s = (STRING*) VTABLE_get_string(INTERP, SELF);
+        STRING * const s = SELF.get_string();
         return string_to_num(INTERP, s);
     }
 
@@ -134,7 +134,7 @@ Returns the big numbers representation of the string.
 */
 
     VTABLE PMC *get_bignum() {
-        STRING * const s   = VTABLE_get_string(INTERP, SELF);
+        STRING * const s   = SELF.get_string();
         PMC           *ret = pmc_new(INTERP, enum_class_BigInt);
         VTABLE_set_string_native(INTERP, ret, s);
         return ret;
@@ -166,7 +166,7 @@ Returns the boolean value of the string.
 */
 
     VTABLE INTVAL get_bool() {
-        STRING * const s = VTABLE_get_string(INTERP, SELF);
+        STRING * const s = SELF.get_string();
         return string_bool(INTERP, s);
     }
 
@@ -251,7 +251,7 @@ the specified C<String> PMC.
 
     VTABLE void set_string_same(PMC *value) {
         PMC_str_val(SELF) =
-            string_set(INTERP, PMC_str_val(SELF), PMC_str_val(value));
+            string_set(INTERP, SELF.get_string(), VTABLE_get_string(INTERP, value));
     }
 
 /*
@@ -632,26 +632,28 @@ Replace the string at C<key> with the chr of C<value>.
 */
 
     VTABLE STRING *get_string_keyed(PMC *key) {
-        STRING * const s = PMC_str_val(SELF);
+        STRING * const s = SELF.get_string();
         const INTVAL   k = key_integer(INTERP, key);
         return string_substr(INTERP, s, k, 1, NULL, 0);
     }
 
     VTABLE INTVAL get_integer_keyed(PMC *key) {
-        STRING * const s = PMC_str_val(SELF);
+        STRING * const s = SELF.get_string();
         return string_ord(INTERP, s, key_integer(INTERP, key));
     }
 
     void set_string_keyed(PMC *key, STRING * const value) {
-        STRING * const s   = PMC_str_val(SELF);
+        STRING * const s   = SELF.get_string();
         const INTVAL   len = string_length(INTERP, value);
         string_replace(INTERP, s, key_integer(INTERP, key), len, value, NULL);
+        VTABLE_set_string_native(INTERP, SELF, s);
     }
 
     VTABLE void set_integer_keyed(PMC *key, INTVAL value) {
-        STRING * const s = PMC_str_val(SELF);
+        STRING * const s = SELF.get_string();
         STRING * const c = string_chr(INTERP, (UINTVAL) value);
         string_replace(INTERP, s, key_integer(INTERP, key), 1, c, NULL);
+        VTABLE_set_string_native(INTERP, SELF, s);
     }
 /*
 

Reply via email to