[svn:parrot] r45689 - in branches/immutable_strings_part1: include/parrot src/string/encoding
bacek at svn.parrot.org
bacek at svn.parrot.org
Thu Apr 15 13:15:29 UTC 2010
Author: bacek
Date: Thu Apr 15 13:15:28 2010
New Revision: 45689
URL: https://trac.parrot.org/parrot/changeset/45689
Log:
Constify to_encoding
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 Thu Apr 15 13:15:12 2010 (r45688)
+++ branches/immutable_strings_part1/include/parrot/encoding.h Thu Apr 15 13:15:28 2010 (r45689)
@@ -15,7 +15,7 @@
#include "parrot/parrot.h"
-typedef STRING * (*encoding_to_encoding_t)(PARROT_INTERP, NOTNULL(STRING *src));
+typedef STRING * (*encoding_to_encoding_t)(PARROT_INTERP, NOTNULL(const STRING *src));
typedef UINTVAL (*encoding_get_codepoint_t)(PARROT_INTERP, const STRING *src, UINTVAL offset);
typedef void (*encoding_set_codepoint_t)(PARROT_INTERP, STRING *src, UINTVAL offset, UINTVAL codepoint);
typedef UINTVAL (*encoding_get_byte_t)(PARROT_INTERP, const STRING *src, UINTVAL offset);
Modified: branches/immutable_strings_part1/src/string/encoding/fixed_8.c
==============================================================================
--- branches/immutable_strings_part1/src/string/encoding/fixed_8.c Thu Apr 15 13:15:12 2010 (r45688)
+++ branches/immutable_strings_part1/src/string/encoding/fixed_8.c Thu Apr 15 13:15:28 2010 (r45689)
@@ -144,7 +144,7 @@
PARROT_DOES_NOT_RETURN
PARROT_CANNOT_RETURN_NULL
-static STRING * to_encoding(PARROT_INTERP, SHIM(STRING *src))
+static STRING * to_encoding(PARROT_INTERP, SHIM(const STRING *src))
__attribute__nonnull__(1);
#define ASSERT_ARGS_become_encoding __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
@@ -208,7 +208,7 @@
/*
-=item C<static STRING * to_encoding(PARROT_INTERP, STRING *src)>
+=item C<static STRING * to_encoding(PARROT_INTERP, const STRING *src)>
Converts the string C<src> to this particular encoding. If C<dest> is
provided, it will contain the result. Otherwise this function operates in
@@ -222,7 +222,7 @@
PARROT_DOES_NOT_RETURN
PARROT_CANNOT_RETURN_NULL
static STRING *
-to_encoding(PARROT_INTERP, SHIM(STRING *src))
+to_encoding(PARROT_INTERP, SHIM(const STRING *src))
{
ASSERT_ARGS(to_encoding)
UNIMPL;
Modified: branches/immutable_strings_part1/src/string/encoding/ucs2.c
==============================================================================
--- branches/immutable_strings_part1/src/string/encoding/ucs2.c Thu Apr 15 13:15:12 2010 (r45688)
+++ branches/immutable_strings_part1/src/string/encoding/ucs2.c Thu Apr 15 13:15:28 2010 (r45689)
@@ -125,7 +125,7 @@
PARROT_WARN_UNUSED_RESULT
PARROT_CANNOT_RETURN_NULL
-static STRING * to_encoding(PARROT_INTERP, ARGIN(STRING *src))
+static STRING * to_encoding(PARROT_INTERP, ARGIN(const STRING *src))
__attribute__nonnull__(1)
__attribute__nonnull__(2);
@@ -217,7 +217,7 @@
/*
-=item C<static STRING * to_encoding(PARROT_INTERP, STRING *src)>
+=item C<static STRING * to_encoding(PARROT_INTERP, const STRING *src)>
Converts the string C<src> to this particular encoding. If C<dest> is
provided, it will contain the result. Otherwise this function operates in
@@ -230,7 +230,7 @@
PARROT_WARN_UNUSED_RESULT
PARROT_CANNOT_RETURN_NULL
static STRING *
-to_encoding(PARROT_INTERP, ARGIN(STRING *src))
+to_encoding(PARROT_INTERP, ARGIN(const STRING *src))
{
ASSERT_ARGS(to_encoding)
STRING * const result =
Modified: branches/immutable_strings_part1/src/string/encoding/utf16.c
==============================================================================
--- branches/immutable_strings_part1/src/string/encoding/utf16.c Thu Apr 15 13:15:12 2010 (r45688)
+++ branches/immutable_strings_part1/src/string/encoding/utf16.c Thu Apr 15 13:15:28 2010 (r45689)
@@ -118,7 +118,7 @@
PARROT_WARN_UNUSED_RESULT
PARROT_CANNOT_RETURN_NULL
-static STRING * to_encoding(PARROT_INTERP, ARGIN(STRING *src))
+static STRING * to_encoding(PARROT_INTERP, ARGIN(const STRING *src))
__attribute__nonnull__(1)
__attribute__nonnull__(2);
@@ -209,7 +209,7 @@
/*
-=item C<static STRING * to_encoding(PARROT_INTERP, STRING *src)>
+=item C<static STRING * to_encoding(PARROT_INTERP, const STRING *src)>
Converts the string C<src> to this particular encoding. If C<dest> is
provided, it will contain the result. Otherwise this function operates in
@@ -223,7 +223,7 @@
PARROT_WARN_UNUSED_RESULT
PARROT_CANNOT_RETURN_NULL
static STRING *
-to_encoding(PARROT_INTERP, ARGIN(STRING *src))
+to_encoding(PARROT_INTERP, ARGIN(const STRING *src))
{
ASSERT_ARGS(to_encoding)
#if PARROT_HAS_ICU
@@ -236,7 +236,7 @@
if (src->encoding == Parrot_utf16_encoding_ptr ||
src->encoding == Parrot_ucs2_encoding_ptr)
- return src;
+ return Parrot_str_clone(interp, src);
result = Parrot_gc_new_string_header(interp, 0);
Modified: branches/immutable_strings_part1/src/string/encoding/utf8.c
==============================================================================
--- branches/immutable_strings_part1/src/string/encoding/utf8.c Thu Apr 15 13:15:12 2010 (r45688)
+++ branches/immutable_strings_part1/src/string/encoding/utf8.c Thu Apr 15 13:15:28 2010 (r45689)
@@ -112,10 +112,9 @@
__attribute__nonnull__(1);
PARROT_CAN_RETURN_NULL
-static STRING * to_encoding(PARROT_INTERP, ARGMOD(STRING *src))
+static STRING * to_encoding(PARROT_INTERP, ARGIN(const STRING *src))
__attribute__nonnull__(1)
- __attribute__nonnull__(2)
- FUNC_MODIFIES(*src);
+ __attribute__nonnull__(2);
static UINTVAL utf8_characters(PARROT_INTERP,
ARGIN(const utf8_t *ptr),
@@ -537,7 +536,7 @@
/*
-=item C<static STRING * to_encoding(PARROT_INTERP, STRING *src)>
+=item C<static STRING * to_encoding(PARROT_INTERP, const STRING *src)>
Converts the string C<src> to this particular encoding. If C<dest> is
provided, it will contain the result. Otherwise this function operates in
@@ -549,7 +548,7 @@
PARROT_CAN_RETURN_NULL
static STRING *
-to_encoding(PARROT_INTERP, ARGMOD(STRING *src))
+to_encoding(PARROT_INTERP, ARGIN(const STRING *src))
{
ASSERT_ARGS(to_encoding)
STRING *result;
@@ -558,7 +557,7 @@
unsigned char *p;
if (src->encoding == Parrot_utf8_encoding_ptr)
- return src;
+ return Parrot_str_clone(interp, src);
result = Parrot_gc_new_string_header(interp, 0);
src_len = src->strlen;
More information about the parrot-commits
mailing list