[svn:parrot] r48842 - in trunk: include/parrot src src/io src/ops src/pmc src/string

nwellnhof at svn.parrot.org nwellnhof at svn.parrot.org
Wed Sep 8 00:26:34 UTC 2010


Author: nwellnhof
Date: Wed Sep  8 00:26:33 2010
New Revision: 48842
URL: https://trac.parrot.org/parrot/changeset/48842

Log:
[str] Remove unused stringrep enum

Modified:
   trunk/include/parrot/pobj.h
   trunk/include/parrot/string_funcs.h
   trunk/src/io/api.c
   trunk/src/io/buffer.c
   trunk/src/io/filehandle.c
   trunk/src/io/socket_unix.c
   trunk/src/io/socket_win32.c
   trunk/src/ops/core_ops.c
   trunk/src/ops/string.ops
   trunk/src/parrot_debugger.c
   trunk/src/pmc/eval.pmc
   trunk/src/pmc/hash.pmc
   trunk/src/pmc/packfile.pmc
   trunk/src/pmc/packfilefixupentry.pmc
   trunk/src/spf_render.c
   trunk/src/string/api.c

Modified: trunk/include/parrot/pobj.h
==============================================================================
--- trunk/include/parrot/pobj.h	Wed Sep  8 00:08:03 2010	(r48841)
+++ trunk/include/parrot/pobj.h	Wed Sep  8 00:26:33 2010	(r48842)
@@ -81,13 +81,6 @@
 #define Buffer_poolptr(b) ((Memory_Block **)Buffer_bufprolog(b))
 
 
-typedef enum {
-    enum_stringrep_unknown = 0,
-    enum_stringrep_one     = 1,
-    enum_stringrep_two     = 2,
-    enum_stringrep_four    = 4
-} parrot_string_representation_t;
-
 /* Here is the Parrot string header object, "inheriting" from Buffer. */
 
 struct parrot_string_t {

Modified: trunk/include/parrot/string_funcs.h
==============================================================================
--- trunk/include/parrot/string_funcs.h	Wed Sep  8 00:08:03 2010	(r48841)
+++ trunk/include/parrot/string_funcs.h	Wed Sep  8 00:26:33 2010	(r48842)
@@ -304,9 +304,7 @@
 
 PARROT_EXPORT
 PARROT_CANNOT_RETURN_NULL
-STRING * Parrot_str_new_noinit(PARROT_INTERP,
-    parrot_string_representation_t representation,
-    UINTVAL capacity)
+STRING * Parrot_str_new_noinit(PARROT_INTERP, UINTVAL capacity)
         __attribute__nonnull__(1);
 
 PARROT_EXPORT
@@ -464,13 +462,6 @@
         __attribute__nonnull__(2);
 
 PARROT_EXPORT
-PARROT_CANNOT_RETURN_NULL
-PARROT_OBSERVER
-const char* string_primary_encoding_for_representation(PARROT_INTERP,
-    parrot_string_representation_t representation)
-        __attribute__nonnull__(1);
-
-PARROT_EXPORT
 PARROT_MALLOC
 PARROT_CAN_RETURN_NULL
 char * string_to_cstring_nullable(SHIM_INTERP,
@@ -648,9 +639,6 @@
 #define ASSERT_ARGS_string_ord __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
        PARROT_ASSERT_ARG(interp) \
     , PARROT_ASSERT_ARG(s))
-#define ASSERT_ARGS_string_primary_encoding_for_representation \
-     __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
-       PARROT_ASSERT_ARG(interp))
 #define ASSERT_ARGS_string_to_cstring_nullable __attribute__unused__ int _ASSERT_ARGS_CHECK = (0)
 #define ASSERT_ARGS_Parrot_str_clone __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
        PARROT_ASSERT_ARG(interp) \

Modified: trunk/src/io/api.c
==============================================================================
--- trunk/src/io/api.c	Wed Sep  8 00:08:03 2010	(r48841)
+++ trunk/src/io/api.c	Wed Sep  8 00:26:33 2010	(r48842)
@@ -335,7 +335,7 @@
             Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_PIO_ERROR,
                 "Cannot read from a closed or non-readable filehandle");
 
-        result = Parrot_str_new_noinit(interp, enum_stringrep_one, length);
+        result = Parrot_str_new_noinit(interp, length);
         result->bufused = length;
 
         if (Parrot_io_is_encoding(interp, pmc, CONST_STRING(interp, "utf8")))

Modified: trunk/src/io/buffer.c
==============================================================================
--- trunk/src/io/buffer.c	Wed Sep  8 00:08:03 2010	(r48841)
+++ trunk/src/io/buffer.c	Wed Sep  8 00:26:33 2010	(r48842)
@@ -293,7 +293,7 @@
         return Parrot_io_readline_buffer(interp, filehandle, buf);
 
     if (*buf == NULL)
-        *buf = Parrot_str_new_noinit(interp, enum_stringrep_one, 2048);
+        *buf = Parrot_str_new_noinit(interp, 2048);
 
     s       = *buf;
     len     = s->bufused;

Modified: trunk/src/io/filehandle.c
==============================================================================
--- trunk/src/io/filehandle.c	Wed Sep  8 00:08:03 2010	(r48841)
+++ trunk/src/io/filehandle.c	Wed Sep  8 00:26:33 2010	(r48842)
@@ -121,7 +121,7 @@
      * when we get a NULL string, we read a default len
      */
     if (*buf == NULL) {
-        *buf = Parrot_str_new_noinit(interp, enum_stringrep_one, len);
+        *buf = Parrot_str_new_noinit(interp, len);
         return *buf;
     }
     else {

Modified: trunk/src/io/socket_unix.c
==============================================================================
--- trunk/src/io/socket_unix.c	Wed Sep  8 00:08:03 2010	(r48841)
+++ trunk/src/io/socket_unix.c	Wed Sep  8 00:26:33 2010	(r48842)
@@ -370,11 +370,11 @@
           case ECONNRESET:
             /* XXX why close it on err return result is -1 anyway */
             close(io->os_handle);
-            *s = Parrot_str_new_noinit(interp, enum_stringrep_one, 0);
+            *s = Parrot_str_new_noinit(interp, 0);
             return -1;
           default:
             close(io->os_handle);
-            *s = Parrot_str_new_noinit(interp, enum_stringrep_one, 0);
+            *s = Parrot_str_new_noinit(interp, 0);
             return -1;
         }
     }

Modified: trunk/src/io/socket_win32.c
==============================================================================
--- trunk/src/io/socket_win32.c	Wed Sep  8 00:08:03 2010	(r48841)
+++ trunk/src/io/socket_win32.c	Wed Sep  8 00:26:33 2010	(r48842)
@@ -320,11 +320,11 @@
           case WSAECONNRESET:
             /* XXX why close it on err return result is -1 anyway */
             close((int)io->os_handle);
-            *s = Parrot_str_new_noinit(interp, enum_stringrep_one, 0);
+            *s = Parrot_str_new_noinit(interp, 0);
             return -1;
           default:
             close((int)io->os_handle);
-            *s = Parrot_str_new_noinit(interp, enum_stringrep_one, 0);
+            *s = Parrot_str_new_noinit(interp, 0);
             return -1;
         }
     }

Modified: trunk/src/ops/core_ops.c
==============================================================================
--- trunk/src/ops/core_ops.c	Wed Sep  8 00:08:03 2010	(r48841)
+++ trunk/src/ops/core_ops.c	Wed Sep  8 00:26:33 2010	(r48842)
@@ -22854,21 +22854,21 @@
 opcode_t *
 Parrot_new_s(opcode_t *cur_opcode, PARROT_INTERP)  {
     const Parrot_Context * const CUR_CTX = Parrot_pcc_get_context_struct(interp, interp->ctx);
-    SREG(1) = Parrot_str_new_noinit(interp, enum_stringrep_one, 0);
+    SREG(1) = Parrot_str_new_noinit(interp, 0);
 
 return (opcode_t *)cur_opcode + 2;}
 
 opcode_t *
 Parrot_new_s_i(opcode_t *cur_opcode, PARROT_INTERP)  {
     const Parrot_Context * const CUR_CTX = Parrot_pcc_get_context_struct(interp, interp->ctx);
-    SREG(1) = Parrot_str_new_noinit(interp, enum_stringrep_one, IREG(2));
+    SREG(1) = Parrot_str_new_noinit(interp, IREG(2));
 
 return (opcode_t *)cur_opcode + 3;}
 
 opcode_t *
 Parrot_new_s_ic(opcode_t *cur_opcode, PARROT_INTERP)  {
     const Parrot_Context * const CUR_CTX = Parrot_pcc_get_context_struct(interp, interp->ctx);
-    SREG(1) = Parrot_str_new_noinit(interp, enum_stringrep_one, cur_opcode[2]);
+    SREG(1) = Parrot_str_new_noinit(interp, cur_opcode[2]);
 
 return (opcode_t *)cur_opcode + 3;}
 

Modified: trunk/src/ops/string.ops
==============================================================================
--- trunk/src/ops/string.ops	Wed Sep  8 00:08:03 2010	(r48841)
+++ trunk/src/ops/string.ops	Wed Sep  8 00:26:33 2010	(r48842)
@@ -323,14 +323,16 @@
 
 Allocate a new empty string of length $2 (optional).
 
+XXX: Do these ops make sense with immutable strings?
+
 =cut
 
 inline op new(out STR) :base_mem {
-    $1 = Parrot_str_new_noinit(interp, enum_stringrep_one, 0);
+    $1 = Parrot_str_new_noinit(interp, 0);
 }
 
 inline op new(out STR, in INT) :base_mem {
-    $1 = Parrot_str_new_noinit(interp, enum_stringrep_one, $2);
+    $1 = Parrot_str_new_noinit(interp, $2);
 }
 
 

Modified: trunk/src/parrot_debugger.c
==============================================================================
--- trunk/src/parrot_debugger.c	Wed Sep  8 00:08:03 2010	(r48841)
+++ trunk/src/parrot_debugger.c	Wed Sep  8 00:26:33 2010	(r48842)
@@ -229,7 +229,7 @@
         const char source []= ".sub aux :main\nexit 0\n.end\n";
         Parrot_compile_string(interp, compiler, source, &errstr);
 
-        if (!Parrot_str_is_null(interp, errstr))
+        if (!STRING_IS_NULL(errstr))
             Parrot_io_eprintf(interp, "%Ss\n", errstr);
     }
 

Modified: trunk/src/pmc/eval.pmc
==============================================================================
--- trunk/src/pmc/eval.pmc	Wed Sep  8 00:08:03 2010	(r48841)
+++ trunk/src/pmc/eval.pmc	Wed Sep  8 00:26:33 2010	(r48842)
@@ -321,8 +321,7 @@
          * effect
          */
         aligned_size = size + 15;
-        res          = Parrot_str_new_noinit(INTERP, enum_stringrep_one,
-                                         aligned_size);
+        res          = Parrot_str_new_noinit(INTERP, aligned_size);
         res->strlen  = res->bufused = size;
 
         if ((size_t)(res->strstart) & 0xf) {

Modified: trunk/src/pmc/hash.pmc
==============================================================================
--- trunk/src/pmc/hash.pmc	Wed Sep  8 00:08:03 2010	(r48841)
+++ trunk/src/pmc/hash.pmc	Wed Sep  8 00:26:33 2010	(r48842)
@@ -628,8 +628,9 @@
         HashBucket * const b =
             parrot_hash_get_bucket(INTERP, hash, hash_key_from_string(INTERP, hash, key));
 
+        /* XXX: shouldn't we return STRINGNULL? */
         if (!b)
-            return Parrot_str_new_noinit(INTERP, enum_stringrep_one, 0);
+            return Parrot_str_new_noinit(INTERP, 0);
 
         return hash_value_to_string(INTERP, hash, b->value);
     }
@@ -640,7 +641,7 @@
             parrot_hash_get_bucket(INTERP, hash, hash_key_from_int(INTERP, hash, key));
 
         if (!b)
-            return Parrot_str_new_noinit(INTERP, enum_stringrep_one, 0);
+            return Parrot_str_new_noinit(INTERP, 0);
 
         return hash_value_to_string(INTERP, hash, b->value);
     }
@@ -661,7 +662,7 @@
         HashBucket * const b        = parrot_hash_get_bucket(INTERP, hash, hash_key);
 
         if (!b)
-            return Parrot_str_new_noinit(INTERP, enum_stringrep_one, 0);
+            return Parrot_str_new_noinit(INTERP, 0);
 
         key = key_next(INTERP, key);
 

Modified: trunk/src/pmc/packfile.pmc
==============================================================================
--- trunk/src/pmc/packfile.pmc	Wed Sep  8 00:08:03 2010	(r48841)
+++ trunk/src/pmc/packfile.pmc	Wed Sep  8 00:26:33 2010	(r48842)
@@ -100,7 +100,7 @@
                 PMC_data_typed(SELF, Parrot_Packfile_attributes*);
         PackFile                   *pf;
 
-        attrs->uuid     = Parrot_str_new_noinit(INTERP, enum_stringrep_one, 0);
+        attrs->uuid     = Parrot_str_new_noinit(INTERP, 0);
         attrs->directory = Parrot_pmc_new(INTERP, enum_class_PackfileDirectory);
 
         /* Create dummy PackFile and copy default attributes to self */

Modified: trunk/src/pmc/packfilefixupentry.pmc
==============================================================================
--- trunk/src/pmc/packfilefixupentry.pmc	Wed Sep  8 00:08:03 2010	(r48841)
+++ trunk/src/pmc/packfilefixupentry.pmc	Wed Sep  8 00:26:33 2010	(r48842)
@@ -42,7 +42,7 @@
         Parrot_PackfileFixupEntry_attributes * attrs =
                 PMC_data_typed(SELF, Parrot_PackfileFixupEntry_attributes*);
 
-        attrs->name = Parrot_str_new_noinit(INTERP, enum_stringrep_one, 0);
+        attrs->name = Parrot_str_new_noinit(INTERP, 0);
 
         PObj_custom_mark_SET(SELF);
     }

Modified: trunk/src/spf_render.c
==============================================================================
--- trunk/src/spf_render.c	Wed Sep  8 00:08:03 2010	(r48841)
+++ trunk/src/spf_render.c	Wed Sep  8 00:26:33 2010	(r48842)
@@ -317,7 +317,7 @@
     HUGEINTVAL num;
 
     /* start with a buffer; double the pattern length to avoid realloc #1 */
-    STRING *targ = Parrot_str_new_noinit(interp, enum_stringrep_one, pat_len * 2);
+    STRING *targ = Parrot_str_new_noinit(interp, pat_len * 2);
 
     /* ts is used almost universally as an intermediate target;
      * tc is used as a temporary buffer by Parrot_str_from_uint and

Modified: trunk/src/string/api.c
==============================================================================
--- trunk/src/string/api.c	Wed Sep  8 00:08:03 2010	(r48841)
+++ trunk/src/string/api.c	Wed Sep  8 00:26:33 2010	(r48842)
@@ -190,8 +190,7 @@
 
 /*
 
-=item C<STRING * Parrot_str_new_noinit(PARROT_INTERP,
-parrot_string_representation_t representation, UINTVAL capacity)>
+=item C<STRING * Parrot_str_new_noinit(PARROT_INTERP, UINTVAL capacity)>
 
 Creates and returns an empty Parrot string.
 
@@ -202,17 +201,11 @@
 PARROT_EXPORT
 PARROT_CANNOT_RETURN_NULL
 STRING *
-Parrot_str_new_noinit(PARROT_INTERP,
-    parrot_string_representation_t representation, UINTVAL capacity)
+Parrot_str_new_noinit(PARROT_INTERP, UINTVAL capacity)
 {
     ASSERT_ARGS(Parrot_str_new_noinit)
     STRING * const s = Parrot_gc_new_string_header(interp, 0);
 
-    /* TODO adapt string creation functions */
-    if (representation != enum_stringrep_one)
-        Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_CHARTYPE,
-            "Unsupported representation");
-
     s->encoding = Parrot_default_encoding_ptr;
 
     Parrot_gc_allocate_string_storage(interp, s,
@@ -448,7 +441,7 @@
     /* calc usable and total bytes */
     total_length = a->bufused + b->bufused;
 
-    dest = Parrot_str_new_noinit(interp, enum_stringrep_one, total_length);
+    dest = Parrot_str_new_noinit(interp, total_length);
     PARROT_ASSERT(enc);
     dest->encoding = enc;
 
@@ -533,37 +526,6 @@
 
 /*
 
-=item C<const char* string_primary_encoding_for_representation(PARROT_INTERP,
-parrot_string_representation_t representation)>
-
-Returns the primary encoding for the specified representation.
-
-This is needed for packfile unpacking, unless we just always use UTF-8 or BOCU.
-
-=cut
-
-*/
-
-PARROT_EXPORT
-PARROT_CANNOT_RETURN_NULL
-PARROT_OBSERVER
-const char*
-string_primary_encoding_for_representation(PARROT_INTERP,
-    parrot_string_representation_t representation)
-{
-    ASSERT_ARGS(string_primary_encoding_for_representation)
-    if (representation == enum_stringrep_one)
-        return "ascii";
-
-    Parrot_ex_throw_from_c_args(interp, NULL,
-        EXCEPTION_INVALID_STRING_REPRESENTATION,
-        "string_primary_encoding_for_representation: "
-        "invalid string representation");
-}
-
-
-/*
-
 =item C<STRING * Parrot_str_new_constant(PARROT_INTERP, const char *buffer)>
 
 Creates and returns a constant Parrot string.
@@ -1007,7 +969,7 @@
 
     /* Allow regexes to return $' easily for "aaa" =~ /aaa/ */
     if (offset == (INTVAL)Parrot_str_length(interp, src) || length < 1)
-        return Parrot_str_new_noinit(interp, enum_stringrep_one, 0);
+        return Parrot_str_new_noinit(interp, 0);
 
     if (offset < 0)
         true_offset = (UINTVAL)(src->strlen + offset);
@@ -3106,7 +3068,7 @@
         return NULL;
 
     if (!src->strlen)
-        return Parrot_str_new_noinit(interp, enum_stringrep_one, 0);
+        return Parrot_str_new_noinit(interp, 0);
 
     return STRING_compose(interp, src);
 }
@@ -3143,7 +3105,7 @@
         int       i;
 
         if (count == 0)
-            return Parrot_str_new_noinit(interp, enum_stringrep_one, 0);
+            return Parrot_str_new_noinit(interp, 0);
 
         first    = VTABLE_get_string_keyed_int(interp, ar, 0);
         length   = Parrot_str_byte_length(interp, first);


More information about the parrot-commits mailing list