[svn:parrot] r46048 - in trunk: include/parrot src/string/charset

petdance at svn.parrot.org petdance at svn.parrot.org
Tue Apr 27 06:00:58 UTC 2010


Author: petdance
Date: Tue Apr 27 06:00:57 2010
New Revision: 46048
URL: https://trac.parrot.org/parrot/changeset/46048

Log:
starting to convert the virtual functions to const STRING *

Modified:
   trunk/include/parrot/charset.h
   trunk/src/string/charset/ascii.c
   trunk/src/string/charset/ascii.h
   trunk/src/string/charset/binary.c
   trunk/src/string/charset/iso-8859-1.c
   trunk/src/string/charset/unicode.c

Modified: trunk/include/parrot/charset.h
==============================================================================
--- trunk/include/parrot/charset.h	Tue Apr 27 01:25:42 2010	(r46047)
+++ trunk/include/parrot/charset.h	Tue Apr 27 06:00:57 2010	(r46048)
@@ -29,11 +29,11 @@
 #define PARROT_BINARY_CHARSET Parrot_binary_charset_ptr
 #define PARROT_UNICODE_CHARSET Parrot_unicode_charset_ptr
 
-typedef STRING * (*charset_get_graphemes_t)(PARROT_INTERP, STRING *src, UINTVAL offset, UINTVAL count);
+typedef STRING * (*charset_get_graphemes_t)(PARROT_INTERP, ARGIN(const STRING *src), UINTVAL offset, UINTVAL count);
 typedef STRING * (*charset_to_charset_t)(PARROT_INTERP, STRING *src);
 typedef STRING * (*charset_from_unicode_t)(PARROT_INTERP, STRING *src);
-typedef STRING * (*charset_compose_t)(PARROT_INTERP, STRING *src);
-typedef STRING * (*charset_decompose_t)(PARROT_INTERP, STRING *src);
+typedef STRING * (*charset_compose_t)(PARROT_INTERP, ARGIN(const STRING *src));
+typedef STRING * (*charset_decompose_t)(PARROT_INTERP, ARGIN(const STRING *src));
 typedef STRING * (*charset_upcase_t)(PARROT_INTERP, const STRING *src);
 typedef STRING * (*charset_downcase_t)(PARROT_INTERP, const STRING *src);
 typedef STRING * (*charset_titlecase_t)(PARROT_INTERP, const STRING *src);

Modified: trunk/src/string/charset/ascii.c
==============================================================================
--- trunk/src/string/charset/ascii.c	Tue Apr 27 01:25:42 2010	(r46047)
+++ trunk/src/string/charset/ascii.c	Tue Apr 27 06:00:57 2010	(r46048)
@@ -32,15 +32,14 @@
 /* Don't modify between HEADERIZER BEGIN / HEADERIZER END.  Your changes will be lost. */
 
 PARROT_CANNOT_RETURN_NULL
-static STRING* compose(PARROT_INTERP, ARGIN(STRING *src))
+static STRING* compose(PARROT_INTERP, ARGIN(const STRING *src))
         __attribute__nonnull__(1)
         __attribute__nonnull__(2);
 
 PARROT_CANNOT_RETURN_NULL
-static STRING* decompose(PARROT_INTERP, ARGMOD(STRING *src))
+static STRING* decompose(PARROT_INTERP, ARGIN(const STRING *src))
         __attribute__nonnull__(1)
-        __attribute__nonnull__(2)
-        FUNC_MODIFIES(*src);
+        __attribute__nonnull__(2);
 
 PARROT_CANNOT_RETURN_NULL
 static STRING* downcase(PARROT_INTERP, ARGIN(const STRING *src))
@@ -166,8 +165,8 @@
 
 /*
 
-=item C<STRING * ascii_get_graphemes(PARROT_INTERP, STRING *src, UINTVAL offset,
-UINTVAL count)>
+=item C<STRING * ascii_get_graphemes(PARROT_INTERP, const STRING *src, UINTVAL
+offset, UINTVAL count)>
 
 Retrieves the graphemes for the STRING C<src>, starting at
 C<offset> and ending at C<offset + count>.
@@ -179,7 +178,7 @@
 PARROT_CANNOT_RETURN_NULL
 PARROT_WARN_UNUSED_RESULT
 STRING *
-ascii_get_graphemes(PARROT_INTERP, ARGIN(STRING *src), UINTVAL offset, UINTVAL count)
+ascii_get_graphemes(PARROT_INTERP, ARGIN(const STRING *src), UINTVAL offset, UINTVAL count)
 {
     ASSERT_ARGS(ascii_get_graphemes)
     return ENCODING_GET_BYTES(interp, src, offset, count);
@@ -251,10 +250,9 @@
     }
 }
 
-/* A noop. can't compose ascii */
 /*
 
-=item C<static STRING* compose(PARROT_INTERP, STRING *src)>
+=item C<static STRING* compose(PARROT_INTERP, const STRING *src)>
 
 Can't compose ASCII strings, so performs a string copy on it and
 returns the new string.
@@ -265,16 +263,18 @@
 
 PARROT_CANNOT_RETURN_NULL
 static STRING*
-compose(PARROT_INTERP, ARGIN(STRING *src))
+compose(PARROT_INTERP, ARGIN(const STRING *src))
 {
     ASSERT_ARGS(compose)
-    return src;
+
+    STRING * const dest = Parrot_str_copy(interp, src);
+
+    return dest;
 }
 
-/* A noop. can't decompose ascii */
 /*
 
-=item C<static STRING* decompose(PARROT_INTERP, STRING *src)>
+=item C<static STRING* decompose(PARROT_INTERP, const STRING *src)>
 
 Can't decompose ASCII, so we perform a string copy instead and return
 a pointer to the new string.
@@ -285,10 +285,13 @@
 
 PARROT_CANNOT_RETURN_NULL
 static STRING*
-decompose(PARROT_INTERP, ARGMOD(STRING *src))
+decompose(PARROT_INTERP, ARGIN(const STRING *src))
 {
     ASSERT_ARGS(decompose)
-    return src;
+
+    STRING * const dest = Parrot_str_copy(interp, src);
+
+    return dest;
 }
 
 /*

Modified: trunk/src/string/charset/ascii.h
==============================================================================
--- trunk/src/string/charset/ascii.h	Tue Apr 27 01:25:42 2010	(r46047)
+++ trunk/src/string/charset/ascii.h	Tue Apr 27 06:00:57 2010	(r46048)
@@ -55,7 +55,7 @@
 PARROT_CANNOT_RETURN_NULL
 PARROT_WARN_UNUSED_RESULT
 STRING * ascii_get_graphemes(PARROT_INTERP,
-    ARGIN(STRING *src),
+    ARGIN(const STRING *src),
     UINTVAL offset,
     UINTVAL count)
         __attribute__nonnull__(1)

Modified: trunk/src/string/charset/binary.c
==============================================================================
--- trunk/src/string/charset/binary.c	Tue Apr 27 01:25:42 2010	(r46047)
+++ trunk/src/string/charset/binary.c	Tue Apr 27 06:00:57 2010	(r46048)
@@ -34,7 +34,7 @@
         __attribute__nonnull__(3);
 
 PARROT_CANNOT_RETURN_NULL
-static STRING* compose(PARROT_INTERP, SHIM(STRING *src))
+static STRING* compose(PARROT_INTERP, SHIM(const STRING *src))
         __attribute__nonnull__(1);
 
 static INTVAL cs_index(SHIM_INTERP,
@@ -48,7 +48,7 @@
     SHIM(UINTVAL offset));
 
 PARROT_CANNOT_RETURN_NULL
-static STRING* decompose(PARROT_INTERP, SHIM(STRING *src))
+static STRING* decompose(PARROT_INTERP, SHIM(const STRING *src))
         __attribute__nonnull__(1);
 
 PARROT_CANNOT_RETURN_NULL
@@ -171,7 +171,7 @@
 
 /*
 
-=item C<static STRING* compose(PARROT_INTERP, STRING *src)>
+=item C<static STRING* compose(PARROT_INTERP, const STRING *src)>
 
 Throws an exception because we cannot compose a binary string.
 
@@ -182,7 +182,7 @@
 /* A err. can't compose binary */
 PARROT_CANNOT_RETURN_NULL
 static STRING*
-compose(PARROT_INTERP, SHIM(STRING *src))
+compose(PARROT_INTERP, SHIM(const STRING *src))
 {
     ASSERT_ARGS(compose)
     EXCEPTION(EXCEPTION_INVALID_CHARTYPE, "Can't compose binary data");
@@ -190,7 +190,7 @@
 
 /*
 
-=item C<static STRING* decompose(PARROT_INTERP, STRING *src)>
+=item C<static STRING* decompose(PARROT_INTERP, const STRING *src)>
 
 Throws an exception because we cannot decompose a binary string.
 
@@ -201,7 +201,7 @@
 /* A err. can't decompose binary */
 PARROT_CANNOT_RETURN_NULL
 static STRING*
-decompose(PARROT_INTERP, SHIM(STRING *src))
+decompose(PARROT_INTERP, SHIM(const STRING *src))
 {
     ASSERT_ARGS(decompose)
     EXCEPTION(EXCEPTION_INVALID_CHARTYPE, "Can't decompose binary data");

Modified: trunk/src/string/charset/iso-8859-1.c
==============================================================================
--- trunk/src/string/charset/iso-8859-1.c	Tue Apr 27 01:25:42 2010	(r46047)
+++ trunk/src/string/charset/iso-8859-1.c	Tue Apr 27 06:00:57 2010	(r46048)
@@ -27,12 +27,12 @@
 
 PARROT_CANNOT_RETURN_NULL
 PARROT_WARN_UNUSED_RESULT
-static STRING* compose(PARROT_INTERP, ARGIN(STRING *src))
+static STRING* compose(PARROT_INTERP, ARGIN(const STRING *src))
         __attribute__nonnull__(1)
         __attribute__nonnull__(2);
 
 PARROT_CANNOT_RETURN_NULL
-static STRING* decompose(PARROT_INTERP, SHIM(STRING *src))
+static STRING* decompose(PARROT_INTERP, SHIM(const STRING *src))
         __attribute__nonnull__(1);
 
 PARROT_CANNOT_RETURN_NULL
@@ -267,7 +267,7 @@
 
 /*
 
-=item C<static STRING* compose(PARROT_INTERP, STRING *src)>
+=item C<static STRING* compose(PARROT_INTERP, const STRING *src)>
 
 ISO-8859-1 does not support composing, so we just copy the STRING C<src> and return the
 copy.
@@ -276,19 +276,21 @@
 
 */
 
-/* A noop. can't compose iso-8859-1 */
 PARROT_CANNOT_RETURN_NULL
 PARROT_WARN_UNUSED_RESULT
 static STRING*
-compose(PARROT_INTERP, ARGIN(STRING *src))
+compose(PARROT_INTERP, ARGIN(const STRING *src))
 {
     ASSERT_ARGS(compose)
-    return src;
+
+    STRING * const dest = Parrot_str_copy(interp, src);
+
+    return dest;
 }
 
 /*
 
-=item C<static STRING* decompose(PARROT_INTERP, STRING *src)>
+=item C<static STRING* decompose(PARROT_INTERP, const STRING *src)>
 
 SO-8859-1 does not support decomposing, so we throw an exception.
 
@@ -298,7 +300,7 @@
 
 PARROT_CANNOT_RETURN_NULL
 static STRING*
-decompose(PARROT_INTERP, SHIM(STRING *src))
+decompose(PARROT_INTERP, SHIM(const STRING *src))
 {
     ASSERT_ARGS(decompose)
     Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_UNIMPLEMENTED,

Modified: trunk/src/string/charset/unicode.c
==============================================================================
--- trunk/src/string/charset/unicode.c	Tue Apr 27 01:25:42 2010	(r46047)
+++ trunk/src/string/charset/unicode.c	Tue Apr 27 06:00:57 2010	(r46048)
@@ -34,7 +34,7 @@
         __attribute__nonnull__(3);
 
 PARROT_CANNOT_RETURN_NULL
-static STRING* compose(PARROT_INTERP, ARGIN(STRING *src))
+static STRING* compose(PARROT_INTERP, ARGIN(const STRING *src))
         __attribute__nonnull__(1)
         __attribute__nonnull__(2);
 
@@ -51,7 +51,7 @@
         __attribute__nonnull__(1);
 
 PARROT_CANNOT_RETURN_NULL
-static STRING* decompose(PARROT_INTERP, SHIM(STRING *src))
+static STRING* decompose(PARROT_INTERP, SHIM(const STRING *src))
         __attribute__nonnull__(1);
 
 PARROT_CANNOT_RETURN_NULL
@@ -81,7 +81,7 @@
 
 PARROT_CANNOT_RETURN_NULL
 static STRING * get_graphemes(PARROT_INTERP,
-    ARGIN(STRING *src),
+    ARGIN(const STRING *src),
     UINTVAL offset,
     UINTVAL count)
         __attribute__nonnull__(1)
@@ -201,7 +201,7 @@
 
 /*
 
-=item C<static STRING * get_graphemes(PARROT_INTERP, STRING *src, UINTVAL
+=item C<static STRING * get_graphemes(PARROT_INTERP, const STRING *src, UINTVAL
 offset, UINTVAL count)>
 
 Gets the graphemes from STRING C<src> starting at C<offset>. Gets
@@ -213,8 +213,7 @@
 
 PARROT_CANNOT_RETURN_NULL
 static STRING *
-get_graphemes(PARROT_INTERP, ARGIN(STRING *src),
-        UINTVAL offset, UINTVAL count)
+get_graphemes(PARROT_INTERP, ARGIN(const STRING *src), UINTVAL offset, UINTVAL count)
 {
     ASSERT_ARGS(get_graphemes)
     return ENCODING_GET_CODEPOINTS(interp, src, offset, count);
@@ -249,7 +248,7 @@
 
 /*
 
-=item C<static STRING* compose(PARROT_INTERP, STRING *src)>
+=item C<static STRING* compose(PARROT_INTERP, const STRING *src)>
 
 If Parrot is built with ICU, composes the STRING C<src>. Attempts to
 denormalize the STRING into the ICU default, NFC.
@@ -262,7 +261,7 @@
 
 PARROT_CANNOT_RETURN_NULL
 static STRING*
-compose(PARROT_INTERP, ARGIN(STRING *src))
+compose(PARROT_INTERP, ARGIN(const STRING *src))
 {
     ASSERT_ARGS(compose)
 #if PARROT_HAS_ICU
@@ -312,7 +311,7 @@
 
 /*
 
-=item C<static STRING* decompose(PARROT_INTERP, STRING *src)>
+=item C<static STRING* decompose(PARROT_INTERP, const STRING *src)>
 
 Decompose function for unicode charset. This function is not yet implemented.
 
@@ -322,7 +321,7 @@
 
 PARROT_CANNOT_RETURN_NULL
 static STRING*
-decompose(PARROT_INTERP, SHIM(STRING *src))
+decompose(PARROT_INTERP, SHIM(const STRING *src))
 {
     ASSERT_ARGS(decompose)
     /* TODO: https://trac.parrot.org/parrot/wiki/StringsTasklist Implement this. */


More information about the parrot-commits mailing list