[svn:parrot] r45736 - in branches/immutable_strings_part1: include/parrot src/string/encoding

petdance at svn.parrot.org petdance at svn.parrot.org
Sat Apr 17 05:01:48 UTC 2010


Author: petdance
Date: Sat Apr 17 05:01:47 2010
New Revision: 45736
URL: https://trac.parrot.org/parrot/changeset/45736

Log:
consting args in the worker methods

Modified:
   branches/immutable_strings_part1/include/parrot/encoding.h
   branches/immutable_strings_part1/src/string/encoding/fixed_8.c
   branches/immutable_strings_part1/src/string/encoding/ucs2.c
   branches/immutable_strings_part1/src/string/encoding/utf16.c
   branches/immutable_strings_part1/src/string/encoding/utf8.c

Modified: branches/immutable_strings_part1/include/parrot/encoding.h
==============================================================================
--- branches/immutable_strings_part1/include/parrot/encoding.h	Sat Apr 17 04:21:51 2010	(r45735)
+++ branches/immutable_strings_part1/include/parrot/encoding.h	Sat Apr 17 05:01:47 2010	(r45736)
@@ -22,8 +22,8 @@
 typedef void (*encoding_set_byte_t)(PARROT_INTERP, const STRING *src, UINTVAL offset, UINTVAL count);
 typedef STRING *(*encoding_get_codepoints_t)(PARROT_INTERP, STRING *src, UINTVAL offset, UINTVAL count);
 typedef STRING *(*encoding_get_bytes_t)(PARROT_INTERP, STRING *src, UINTVAL offset, UINTVAL count);
-typedef UINTVAL (*encoding_codepoints_t)(PARROT_INTERP, STRING *src);
-typedef UINTVAL (*encoding_bytes_t)(PARROT_INTERP, STRING *src);
+typedef UINTVAL (*encoding_codepoints_t)(PARROT_INTERP, ARGIN(const STRING *src));
+typedef UINTVAL (*encoding_bytes_t)(PARROT_INTERP, ARGIN(const STRING *src));
 typedef UINTVAL (*encoding_find_cclass_t)(PARROT_INTERP, STRING *s, const INTVAL *typetable, INTVAL flags, UINTVAL offset, UINTVAL count);
 typedef size_t (*encoding_hash_t)(PARROT_INTERP, const STRING *s, size_t hashval);
 

Modified: branches/immutable_strings_part1/src/string/encoding/fixed_8.c
==============================================================================
--- branches/immutable_strings_part1/src/string/encoding/fixed_8.c	Sat Apr 17 04:21:51 2010	(r45735)
+++ branches/immutable_strings_part1/src/string/encoding/fixed_8.c	Sat Apr 17 05:01:47 2010	(r45736)
@@ -24,21 +24,20 @@
 /* HEADERIZER BEGIN: static */
 /* Don't modify between HEADERIZER BEGIN / HEADERIZER END.  Your changes will be lost. */
 
-static UINTVAL bytes(SHIM_INTERP, ARGIN(STRING *source_string))
+static UINTVAL bytes(SHIM_INTERP, ARGIN(const STRING *source_string))
         __attribute__nonnull__(2);
 
-static UINTVAL codepoints(PARROT_INTERP, ARGIN(STRING *source_string))
+static UINTVAL codepoints(PARROT_INTERP, ARGIN(const STRING *source_string))
         __attribute__nonnull__(1)
         __attribute__nonnull__(2);
 
 PARROT_WARN_UNUSED_RESULT
-static UINTVAL find_cclass(PARROT_INTERP,
+static UINTVAL find_cclass(SHIM_INTERP,
     ARGIN(STRING *s),
     ARGIN(const INTVAL *typetable),
     INTVAL flags,
     UINTVAL pos,
     UINTVAL end)
-        __attribute__nonnull__(1)
         __attribute__nonnull__(2)
         __attribute__nonnull__(3);
 
@@ -60,17 +59,15 @@
         __attribute__nonnull__(2)
         FUNC_MODIFIES(*iter);
 
-static size_t fixed_8_hash(PARROT_INTERP,
+static size_t fixed_8_hash(SHIM_INTERP,
     ARGIN(const STRING *s),
     size_t hashval)
-        __attribute__nonnull__(1)
         __attribute__nonnull__(2);
 
 PARROT_WARN_UNUSED_RESULT
-static UINTVAL get_byte(PARROT_INTERP,
+static UINTVAL get_byte(SHIM_INTERP,
     ARGIN(const STRING *source_string),
     UINTVAL offset)
-        __attribute__nonnull__(1)
         __attribute__nonnull__(2);
 
 PARROT_WARN_UNUSED_RESULT
@@ -130,8 +127,7 @@
        PARROT_ASSERT_ARG(interp) \
     , PARROT_ASSERT_ARG(source_string))
 #define ASSERT_ARGS_find_cclass __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
-       PARROT_ASSERT_ARG(interp) \
-    , PARROT_ASSERT_ARG(s) \
+       PARROT_ASSERT_ARG(s) \
     , PARROT_ASSERT_ARG(typetable))
 #define ASSERT_ARGS_fixed8_get_next __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
        PARROT_ASSERT_ARG(interp) \
@@ -142,11 +138,9 @@
 #define ASSERT_ARGS_fixed8_set_position __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
        PARROT_ASSERT_ARG(iter))
 #define ASSERT_ARGS_fixed_8_hash __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
-       PARROT_ASSERT_ARG(interp) \
-    , PARROT_ASSERT_ARG(s))
+       PARROT_ASSERT_ARG(s))
 #define ASSERT_ARGS_get_byte __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
-       PARROT_ASSERT_ARG(interp) \
-    , PARROT_ASSERT_ARG(source_string))
+       PARROT_ASSERT_ARG(source_string))
 #define ASSERT_ARGS_get_bytes __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
        PARROT_ASSERT_ARG(interp) \
     , PARROT_ASSERT_ARG(source_string))
@@ -249,11 +243,11 @@
 
 PARROT_WARN_UNUSED_RESULT
 static UINTVAL
-find_cclass(PARROT_INTERP, ARGIN(STRING *s), ARGIN(const INTVAL *typetable),
+find_cclass(SHIM_INTERP, ARGIN(STRING *s), ARGIN(const INTVAL *typetable),
 INTVAL flags, UINTVAL pos, UINTVAL end)
 {
     ASSERT_ARGS(find_cclass)
-    unsigned char *contents = (unsigned char *)s->strstart;
+    const unsigned char *contents = (const unsigned char *)s->strstart;
     for (; pos < end; ++pos) {
         if ((typetable[contents[pos]] & flags) != 0) {
             return pos;
@@ -275,10 +269,10 @@
 
 PARROT_WARN_UNUSED_RESULT
 static UINTVAL
-get_byte(PARROT_INTERP, ARGIN(const STRING *source_string), UINTVAL offset)
+get_byte(SHIM_INTERP, ARGIN(const STRING *source_string), UINTVAL offset)
 {
     ASSERT_ARGS(get_byte)
-    unsigned char *contents = (unsigned char *)source_string->strstart;
+    const unsigned char *contents = (const unsigned char *)source_string->strstart;
 
     if (offset >= source_string->bufused) {
 /*        Parrot_ex_throw_from_c_args(interp, NULL, 0,
@@ -375,7 +369,7 @@
 
 /*
 
-=item C<static UINTVAL codepoints(PARROT_INTERP, STRING *source_string)>
+=item C<static UINTVAL codepoints(PARROT_INTERP, const STRING *source_string)>
 
 Returns the number of codepoints in string C<src>.
 
@@ -384,7 +378,7 @@
 */
 
 static UINTVAL
-codepoints(PARROT_INTERP, ARGIN(STRING *source_string))
+codepoints(PARROT_INTERP, ARGIN(const STRING *source_string))
 {
     ASSERT_ARGS(codepoints)
     return bytes(interp, source_string);
@@ -392,7 +386,7 @@
 
 /*
 
-=item C<static UINTVAL bytes(PARROT_INTERP, STRING *source_string)>
+=item C<static UINTVAL bytes(PARROT_INTERP, const STRING *source_string)>
 
 Returns the number of bytes in string C<src>.
 
@@ -401,7 +395,7 @@
 */
 
 static UINTVAL
-bytes(SHIM_INTERP, ARGIN(STRING *source_string))
+bytes(SHIM_INTERP, ARGIN(const STRING *source_string))
 {
     ASSERT_ARGS(bytes)
     return source_string->bufused;
@@ -505,10 +499,10 @@
 */
 
 static size_t
-fixed_8_hash(PARROT_INTERP, ARGIN(const STRING *s), size_t hashval)
+fixed_8_hash(SHIM_INTERP, ARGIN(const STRING *s), size_t hashval)
 {
     ASSERT_ARGS(fixed_8_hash)
-    unsigned char *pos = (unsigned char *)s->strstart;
+    const unsigned char *pos = (const unsigned char *)s->strstart;
     UINTVAL        len = s->strlen;
 
     while (len--) {

Modified: branches/immutable_strings_part1/src/string/encoding/ucs2.c
==============================================================================
--- branches/immutable_strings_part1/src/string/encoding/ucs2.c	Sat Apr 17 04:21:51 2010	(r45735)
+++ branches/immutable_strings_part1/src/string/encoding/ucs2.c	Sat Apr 17 05:01:47 2010	(r45736)
@@ -37,12 +37,11 @@
 /* Don't modify between HEADERIZER BEGIN / HEADERIZER END.  Your changes will be lost. */
 
 PARROT_WARN_UNUSED_RESULT
-static UINTVAL bytes(PARROT_INTERP, ARGIN(STRING *src))
-        __attribute__nonnull__(1)
+static UINTVAL bytes(SHIM_INTERP, ARGIN(const STRING *src))
         __attribute__nonnull__(2);
 
 PARROT_WARN_UNUSED_RESULT
-static UINTVAL codepoints(PARROT_INTERP, ARGIN(STRING *src))
+static UINTVAL codepoints(PARROT_INTERP, ARGIN(const STRING *src))
         __attribute__nonnull__(1)
         __attribute__nonnull__(2);
 
@@ -138,8 +137,7 @@
         FUNC_MODIFIES(*i);
 
 #define ASSERT_ARGS_bytes __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
-       PARROT_ASSERT_ARG(interp) \
-    , PARROT_ASSERT_ARG(src))
+       PARROT_ASSERT_ARG(src))
 #define ASSERT_ARGS_codepoints __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
        PARROT_ASSERT_ARG(interp) \
     , PARROT_ASSERT_ARG(src))
@@ -237,10 +235,11 @@
 {
     ASSERT_ARGS(get_codepoint)
 #if PARROT_HAS_ICU
-    UChar * const s = (UChar*) src->strstart;
+    const UChar * const s = (const UChar*) src->strstart;
     return s[offset];
 #else
-    UNUSED(offset)
+    UNUSED(offset);
+    UNUSED(src);
     no_ICU_lib(interp);
 #endif
 }
@@ -287,6 +286,12 @@
 find_cclass(PARROT_INTERP, ARGIN(STRING *s), ARGIN(const INTVAL *typetable),
 INTVAL flags, UINTVAL pos, UINTVAL end)
 {
+    UNUSED(s);
+    UNUSED(typetable);
+    UNUSED(flags);
+    UNUSED(pos);
+    UNUSED(end);
+
     Parrot_ex_throw_from_c_args(interp, NULL,
         EXCEPTION_UNIMPLEMENTED,
         "No find_cclass support in unicode encoding plugins");
@@ -394,7 +399,7 @@
 
 /*
 
-=item C<static UINTVAL codepoints(PARROT_INTERP, STRING *src)>
+=item C<static UINTVAL codepoints(PARROT_INTERP, const STRING *src)>
 
 Returns the number of codepoints in string C<src>.
 
@@ -404,19 +409,21 @@
 
 PARROT_WARN_UNUSED_RESULT
 static UINTVAL
-codepoints(PARROT_INTERP, ARGIN(STRING *src))
+codepoints(PARROT_INTERP, ARGIN(const STRING *src))
 {
     ASSERT_ARGS(codepoints)
 #if PARROT_HAS_ICU
+    UNUSED(interp);
     return src->bufused / sizeof (UChar);
 #else
+    UNUSED(src);
     no_ICU_lib(interp);
 #endif
 }
 
 /*
 
-=item C<static UINTVAL bytes(PARROT_INTERP, STRING *src)>
+=item C<static UINTVAL bytes(PARROT_INTERP, const STRING *src)>
 
 Returns the number of bytes in string C<src>.
 
@@ -426,7 +433,7 @@
 
 PARROT_WARN_UNUSED_RESULT
 static UINTVAL
-bytes(PARROT_INTERP, ARGIN(STRING *src))
+bytes(SHIM_INTERP, ARGIN(const STRING *src))
 {
     ASSERT_ARGS(bytes)
     return src->bufused;
@@ -448,7 +455,7 @@
     ASSERT_ARGS(ucs2_decode_and_advance)
 
 #if PARROT_HAS_ICU
-    UChar * const s = (UChar*) i->str->strstart;
+    const UChar * const s = (UChar*) i->str->strstart;
     size_t pos = i->bytepos / sizeof (UChar);
 
     /* TODO either make sure that we don't go past end or use SAFE
@@ -463,6 +470,8 @@
      * See TT #557
      */
     PARROT_ASSERT(0);
+    UNUSED(interp);
+    UNUSED(i);
     return (UINTVAL)0; /* Stop the static analyzers from panicing */
 #endif
 }
@@ -485,7 +494,7 @@
     ASSERT_ARGS(ucs2_encode_and_advance)
 
 #if PARROT_HAS_ICU
-    UChar * const s = (UChar*) i->str->strstart;
+    const UChar * const s = (const UChar*) i->str->strstart;
     UINTVAL pos = i->bytepos / sizeof (UChar);
     s[pos++] = (UChar)c;
     i->charpos++;
@@ -494,6 +503,9 @@
     /* This function must never be called if compiled without ICU.
      * See TT #557
      */
+    UNUSED(interp);
+    UNUSED(i);
+    UNUSED(c);
     PARROT_ASSERT(0);
 #endif
 }
@@ -554,6 +566,8 @@
     /* This function must never be called if compiled without ICU.
      * See TT #557
      */
+    UNUSED(i);
+    UNUSED(n);
     PARROT_ASSERT(0);
 #endif
 }
@@ -582,6 +596,8 @@
     iter->set_and_advance = ucs2_encode_and_advance;
     iter->set_position    = ucs2_set_position;
 #else
+    UNUSED(src);
+    UNUSED(iter);
     no_ICU_lib(interp);
 #endif
 }

Modified: branches/immutable_strings_part1/src/string/encoding/utf16.c
==============================================================================
--- branches/immutable_strings_part1/src/string/encoding/utf16.c	Sat Apr 17 04:21:51 2010	(r45735)
+++ branches/immutable_strings_part1/src/string/encoding/utf16.c	Sat Apr 17 05:01:47 2010	(r45736)
@@ -27,11 +27,11 @@
 /* Don't modify between HEADERIZER BEGIN / HEADERIZER END.  Your changes will be lost. */
 
 PARROT_WARN_UNUSED_RESULT
-static UINTVAL bytes(SHIM_INTERP, ARGIN(STRING *src))
+static UINTVAL bytes(SHIM_INTERP, ARGIN(const STRING *src))
         __attribute__nonnull__(2);
 
 PARROT_WARN_UNUSED_RESULT
-static UINTVAL codepoints(PARROT_INTERP, ARGIN(STRING *src))
+static UINTVAL codepoints(PARROT_INTERP, ARGIN(const STRING *src))
         __attribute__nonnull__(1)
         __attribute__nonnull__(2);
 
@@ -343,6 +343,12 @@
 find_cclass(PARROT_INTERP, ARGIN(STRING *s), ARGIN(const INTVAL *typetable),
 INTVAL flags, UINTVAL pos, UINTVAL end)
 {
+    UNUSED(s);
+    UNUSED(typetable);
+    UNUSED(flags);
+    UNUSED(pos);
+    UNUSED(end);
+
     Parrot_ex_throw_from_c_args(interp, NULL,
         EXCEPTION_UNIMPLEMENTED,
         "No find_cclass support in unicode encoding plugins");
@@ -458,7 +464,7 @@
 
 /*
 
-=item C<static UINTVAL codepoints(PARROT_INTERP, STRING *src)>
+=item C<static UINTVAL codepoints(PARROT_INTERP, const STRING *src)>
 
 Returns the number of codepoints in string C<src>.
 
@@ -468,7 +474,7 @@
 
 PARROT_WARN_UNUSED_RESULT
 static UINTVAL
-codepoints(PARROT_INTERP, ARGIN(STRING *src))
+codepoints(PARROT_INTERP, ARGIN(const STRING *src))
 {
     ASSERT_ARGS(codepoints)
     String_iter iter;
@@ -484,7 +490,7 @@
 
 /*
 
-=item C<static UINTVAL bytes(PARROT_INTERP, STRING *src)>
+=item C<static UINTVAL bytes(PARROT_INTERP, const STRING *src)>
 
 Returns the number of bytes in string C<src>.
 
@@ -494,7 +500,7 @@
 
 PARROT_WARN_UNUSED_RESULT
 static UINTVAL
-bytes(SHIM_INTERP, ARGIN(STRING *src))
+bytes(SHIM_INTERP, ARGIN(const STRING *src))
 {
     ASSERT_ARGS(bytes)
     return src->bufused;

Modified: branches/immutable_strings_part1/src/string/encoding/utf8.c
==============================================================================
--- branches/immutable_strings_part1/src/string/encoding/utf8.c	Sat Apr 17 04:21:51 2010	(r45735)
+++ branches/immutable_strings_part1/src/string/encoding/utf8.c	Sat Apr 17 05:01:47 2010	(r45736)
@@ -28,13 +28,12 @@
 /* Don't modify between HEADERIZER BEGIN / HEADERIZER END.  Your changes will be lost. */
 
 PARROT_PURE_FUNCTION
-static UINTVAL bytes(SHIM_INTERP, ARGIN(STRING *src))
+static UINTVAL bytes(SHIM_INTERP, ARGIN(const STRING *src))
         __attribute__nonnull__(2);
 
-static UINTVAL codepoints(PARROT_INTERP, ARGMOD(STRING *src))
+static UINTVAL codepoints(PARROT_INTERP, ARGIN(const STRING *src))
         __attribute__nonnull__(1)
-        __attribute__nonnull__(2)
-        FUNC_MODIFIES(*src);
+        __attribute__nonnull__(2);
 
 PARROT_WARN_UNUSED_RESULT
 static UINTVAL find_cclass(PARROT_INTERP,
@@ -218,10 +217,6 @@
     4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6      /* cjk etc. */
 };
 
-#if 0
-typedef unsigned char utf8_t;
-#endif
-
 /*
 
 =item C<static UINTVAL utf8_characters(PARROT_INTERP, const utf8_t *ptr, UINTVAL
@@ -771,7 +766,7 @@
 
 /*
 
-=item C<static UINTVAL codepoints(PARROT_INTERP, STRING *src)>
+=item C<static UINTVAL codepoints(PARROT_INTERP, const STRING *src)>
 
 Returns the number of codepoints in string C<src>.
 
@@ -780,7 +775,7 @@
 */
 
 static UINTVAL
-codepoints(PARROT_INTERP, ARGMOD(STRING *src))
+codepoints(PARROT_INTERP, ARGIN(const STRING *src))
 {
     ASSERT_ARGS(codepoints)
     String_iter iter;
@@ -796,7 +791,7 @@
 
 /*
 
-=item C<static UINTVAL bytes(PARROT_INTERP, STRING *src)>
+=item C<static UINTVAL bytes(PARROT_INTERP, const STRING *src)>
 
 Returns the number of bytes in string C<src>.
 
@@ -806,7 +801,7 @@
 
 PARROT_PURE_FUNCTION
 static UINTVAL
-bytes(SHIM_INTERP, ARGIN(STRING *src))
+bytes(SHIM_INTERP, ARGIN(const STRING *src))
 {
     ASSERT_ARGS(bytes)
     return src->bufused;


More information about the parrot-commits mailing list