[svn:parrot] r45900 - in branches/string_consting: include/parrot src

bacek at svn.parrot.org bacek at svn.parrot.org
Thu Apr 22 11:33:32 UTC 2010


Author: bacek
Date: Thu Apr 22 11:33:32 2010
New Revision: 45900
URL: https://trac.parrot.org/parrot/changeset/45900

Log:
Consting src/library.c

Modified:
   branches/string_consting/include/parrot/library.h
   branches/string_consting/src/library.c

Modified: branches/string_consting/include/parrot/library.h
==============================================================================
--- branches/string_consting/include/parrot/library.h	Thu Apr 22 11:33:15 2010	(r45899)
+++ branches/string_consting/include/parrot/library.h	Thu Apr 22 11:33:32 2010	(r45900)
@@ -78,22 +78,21 @@
 PARROT_EXPORT
 PARROT_WARN_UNUSED_RESULT
 PARROT_CAN_RETURN_NULL
-STRING* Parrot_locate_runtime_file_str(PARROT_INTERP,
-    ARGMOD(STRING *file),
+const STRING* Parrot_locate_runtime_file_str(PARROT_INTERP,
+    ARGIN(const STRING *file),
     enum_runtime_ft type)
         __attribute__nonnull__(1)
-        __attribute__nonnull__(2)
-        FUNC_MODIFIES(*file);
+        __attribute__nonnull__(2);
 
 void parrot_init_library_paths(PARROT_INTERP)
         __attribute__nonnull__(1);
 
 PARROT_IGNORABLE_RESULT
 PARROT_CANNOT_RETURN_NULL
-STRING * parrot_split_path_ext(PARROT_INTERP,
+const STRING * parrot_split_path_ext(PARROT_INTERP,
     ARGMOD(STRING *in),
-    ARGOUT(STRING **wo_ext),
-    ARGOUT(STRING **ext))
+    ARGOUT(STRING const**wo_ext),
+    ARGOUT(STRING const**ext))
         __attribute__nonnull__(1)
         __attribute__nonnull__(2)
         __attribute__nonnull__(3)

Modified: branches/string_consting/src/library.c
==============================================================================
--- branches/string_consting/src/library.c	Thu Apr 22 11:33:15 2010	(r45899)
+++ branches/string_consting/src/library.c	Thu Apr 22 11:33:32 2010	(r45900)
@@ -44,54 +44,47 @@
 
 PARROT_WARN_UNUSED_RESULT
 PARROT_CANNOT_RETURN_NULL
-static STRING* path_append(PARROT_INTERP,
-    ARGMOD(STRING *l_path),
-    ARGMOD(STRING *r_path))
+static const STRING* path_append(PARROT_INTERP,
+    ARGIN(const STRING *l_path),
+    ARGIN(const STRING *r_path))
         __attribute__nonnull__(1)
         __attribute__nonnull__(2)
-        __attribute__nonnull__(3)
-        FUNC_MODIFIES(*l_path)
-        FUNC_MODIFIES(*r_path);
+        __attribute__nonnull__(3);
 
 PARROT_WARN_UNUSED_RESULT
 PARROT_CANNOT_RETURN_NULL
 static STRING* path_concat(PARROT_INTERP,
-    ARGMOD(STRING *l_path),
-    ARGMOD(STRING *r_path))
+    ARGIN(const STRING *l_path),
+    ARGIN(const STRING *r_path))
         __attribute__nonnull__(1)
         __attribute__nonnull__(2)
-        __attribute__nonnull__(3)
-        FUNC_MODIFIES(*l_path)
-        FUNC_MODIFIES(*r_path);
+        __attribute__nonnull__(3);
 
 PARROT_WARN_UNUSED_RESULT
 PARROT_CANNOT_RETURN_NULL
-static STRING* path_finalize(PARROT_INTERP, ARGMOD(STRING *path))
+static STRING* path_finalize(PARROT_INTERP, ARGIN(const STRING *path))
         __attribute__nonnull__(1)
-        __attribute__nonnull__(2)
-        FUNC_MODIFIES(*path);
+        __attribute__nonnull__(2);
 
 PARROT_WARN_UNUSED_RESULT
 PARROT_CANNOT_RETURN_NULL
-static STRING* path_guarantee_trailing_separator(PARROT_INTERP,
-    ARGMOD(STRING *path))
+static const STRING* path_guarantee_trailing_separator(PARROT_INTERP,
+    ARGIN(const STRING *path))
         __attribute__nonnull__(1)
-        __attribute__nonnull__(2)
-        FUNC_MODIFIES(*path);
+        __attribute__nonnull__(2);
 
 PARROT_WARN_UNUSED_RESULT
 PARROT_CAN_RETURN_NULL
-static STRING* try_bytecode_extensions(PARROT_INTERP, ARGMOD(STRING* path))
+static const STRING* try_bytecode_extensions(PARROT_INTERP,
+    ARGIN(const STRING* path))
         __attribute__nonnull__(1)
-        __attribute__nonnull__(2)
-        FUNC_MODIFIES(* path);
+        __attribute__nonnull__(2);
 
 PARROT_WARN_UNUSED_RESULT
 PARROT_CAN_RETURN_NULL
-static STRING* try_load_path(PARROT_INTERP, ARGMOD(STRING* path))
+static const STRING* try_load_path(PARROT_INTERP, ARGIN(const STRING* path))
         __attribute__nonnull__(1)
-        __attribute__nonnull__(2)
-        FUNC_MODIFIES(* path);
+        __attribute__nonnull__(2);
 
 #define ASSERT_ARGS_cnv_to_win32_filesep __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
        PARROT_ASSERT_ARG(path))
@@ -394,7 +387,7 @@
 
 /*
 
-=item C<static STRING* path_finalize(PARROT_INTERP, STRING *path)>
+=item C<static STRING* path_finalize(PARROT_INTERP, const STRING *path)>
 
 Ensures the given STRING C<path> has a C-style NULL character at the end. The
 length of the string is not increased to account for this NULL, however. In
@@ -408,7 +401,7 @@
 PARROT_WARN_UNUSED_RESULT
 PARROT_CANNOT_RETURN_NULL
 static STRING*
-path_finalize(PARROT_INTERP, ARGMOD(STRING *path))
+path_finalize(PARROT_INTERP, ARGIN(const STRING *path))
 {
     ASSERT_ARGS(path_finalize)
 
@@ -419,21 +412,21 @@
 
     STRING * const nul = string_chr(interp, '\0');
 
-    path = Parrot_str_concat(interp, path, nul);
-    path->bufused--;
-    path->strlen--;
+    STRING * res = Parrot_str_concat(interp, path, nul);
+    res->bufused--;
+    res->strlen--;
 
 #ifdef WIN32
-    cnv_to_win32_filesep(path);
+    cnv_to_win32_filesep(res);
 #endif
 
-    return path;
+    return res;
 }
 
 /*
 
-=item C<static STRING* path_guarantee_trailing_separator(PARROT_INTERP, STRING
-*path)>
+=item C<static const STRING* path_guarantee_trailing_separator(PARROT_INTERP,
+const STRING *path)>
 
 unary path argument. the path string will have a
 trailing path-separator appended if it is not
@@ -445,8 +438,8 @@
 
 PARROT_WARN_UNUSED_RESULT
 PARROT_CANNOT_RETURN_NULL
-static STRING*
-path_guarantee_trailing_separator(PARROT_INTERP, ARGMOD(STRING *path))
+static const STRING*
+path_guarantee_trailing_separator(PARROT_INTERP, ARGIN(const STRING *path))
 {
     ASSERT_ARGS(path_guarantee_trailing_separator)
     STRING * const path_separator_string = string_chr(interp, path_separator);
@@ -461,8 +454,8 @@
 
 /*
 
-=item C<static STRING* path_append(PARROT_INTERP, STRING *l_path, STRING
-*r_path)>
+=item C<static const STRING* path_append(PARROT_INTERP, const STRING *l_path,
+const STRING *r_path)>
 
 binary path arguments, the left arg is modified.
 a trailing separator is guaranteed for the left
@@ -474,8 +467,8 @@
 
 PARROT_WARN_UNUSED_RESULT
 PARROT_CANNOT_RETURN_NULL
-static STRING*
-path_append(PARROT_INTERP, ARGMOD(STRING *l_path), ARGMOD(STRING *r_path))
+static const STRING*
+path_append(PARROT_INTERP, ARGIN(const STRING *l_path), ARGIN(const STRING *r_path))
 {
     ASSERT_ARGS(path_append)
     l_path = path_guarantee_trailing_separator(interp, l_path);
@@ -486,8 +479,8 @@
 
 /*
 
-=item C<static STRING* path_concat(PARROT_INTERP, STRING *l_path, STRING
-*r_path)>
+=item C<static STRING* path_concat(PARROT_INTERP, const STRING *l_path, const
+STRING *r_path)>
 
 binary path arguments. A new string is created
 that is the concatenation of the two path components
@@ -500,21 +493,19 @@
 PARROT_WARN_UNUSED_RESULT
 PARROT_CANNOT_RETURN_NULL
 static STRING*
-path_concat(PARROT_INTERP, ARGMOD(STRING *l_path), ARGMOD(STRING *r_path))
+path_concat(PARROT_INTERP, ARGIN(const STRING *l_path), ARGIN(const STRING *r_path))
 {
     ASSERT_ARGS(path_concat)
-    STRING* join;
+    const STRING* join;
 
     join = l_path;
     join = path_guarantee_trailing_separator(interp, join);
-    join = Parrot_str_concat(interp, join, r_path);
-
-    return join;
+    return Parrot_str_concat(interp, join, r_path);
 }
 
 /*
 
-=item C<static STRING* try_load_path(PARROT_INTERP, STRING* path)>
+=item C<static const STRING* try_load_path(PARROT_INTERP, const STRING* path)>
 
 Attempts to load a file with name C<path>. If the file is successfully located,
 the finalized name of the file is returned as a STRING. Otherwise, returns
@@ -526,8 +517,8 @@
 
 PARROT_WARN_UNUSED_RESULT
 PARROT_CAN_RETURN_NULL
-static STRING*
-try_load_path(PARROT_INTERP, ARGMOD(STRING* path))
+static const STRING*
+try_load_path(PARROT_INTERP, ARGIN(const STRING* path))
 {
     ASSERT_ARGS(try_load_path)
     STRING *final;
@@ -543,7 +534,8 @@
 
 /*
 
-=item C<static STRING* try_bytecode_extensions(PARROT_INTERP, STRING* path)>
+=item C<static const STRING* try_bytecode_extensions(PARROT_INTERP, const
+STRING* path)>
 
 Guess extensions, so that the user can drop the extensions
 leaving it up to the build process/install whether or not
@@ -555,11 +547,11 @@
 
 PARROT_WARN_UNUSED_RESULT
 PARROT_CAN_RETURN_NULL
-static STRING*
-try_bytecode_extensions(PARROT_INTERP, ARGMOD(STRING* path))
+static const STRING*
+try_bytecode_extensions(PARROT_INTERP, ARGIN(const STRING* path))
 {
     ASSERT_ARGS(try_bytecode_extensions)
-    STRING *test_path, *result;
+    const STRING *test_path, *result;
     STRING * const bytecode_extension = CONST_STRING(interp, ".pbc");
     STRING * const pir_extension      = CONST_STRING(interp, ".pir");
     STRING * const pasm_extension     = CONST_STRING(interp, ".pasm");
@@ -670,8 +662,8 @@
 
 /*
 
-=item C<STRING* Parrot_locate_runtime_file_str(PARROT_INTERP, STRING *file,
-enum_runtime_ft type)>
+=item C<const STRING* Parrot_locate_runtime_file_str(PARROT_INTERP, const STRING
+*file, enum_runtime_ft type)>
 
 Locate the full path for C<file_name> and the given file type(s).
 
@@ -685,13 +677,13 @@
 PARROT_EXPORT
 PARROT_WARN_UNUSED_RESULT
 PARROT_CAN_RETURN_NULL
-STRING*
-Parrot_locate_runtime_file_str(PARROT_INTERP, ARGMOD(STRING *file),
+const STRING*
+Parrot_locate_runtime_file_str(PARROT_INTERP, ARGIN(const STRING *file),
         enum_runtime_ft type)
 {
     ASSERT_ARGS(Parrot_locate_runtime_file_str)
-    STRING *prefix;
-    STRING *full_name;
+    const STRING *prefix;
+    const STRING *full_name;
     PMC    *paths;
     INTVAL  i, n;
 
@@ -713,7 +705,7 @@
 
     for (i = 0; i < n; ++i) {
         STRING * const path = VTABLE_get_string_keyed_int(interp, paths, i);
-        STRING *found_name;
+        const STRING *found_name;
 
         full_name = path_append(interp, path, file);
 
@@ -776,8 +768,8 @@
         enum_runtime_ft type)
 {
     ASSERT_ARGS(Parrot_locate_runtime_file)
-    STRING * const file   = Parrot_str_new(interp, file_name, 0);
-    STRING * const result = Parrot_locate_runtime_file_str(interp, file, type);
+    const STRING * const file   = Parrot_str_new(interp, file_name, 0);
+    const STRING * const result = Parrot_locate_runtime_file_str(interp, file, type);
     /*
      * XXX valgrind shows e.g.
      *     invalid read of size 8 inside a string of length 69
@@ -867,8 +859,8 @@
 
 /*
 
-=item C<STRING * parrot_split_path_ext(PARROT_INTERP, STRING *in, STRING
-**wo_ext, STRING **ext)>
+=item C<const STRING * parrot_split_path_ext(PARROT_INTERP, STRING *in, STRING
+const**wo_ext, STRING const**ext)>
 
 Split the pathstring C<in> into <path><filestem><ext>. Return the
 C<filestem> of the pathstring. Set C<wo_ext> to the part without
@@ -880,9 +872,9 @@
 
 PARROT_IGNORABLE_RESULT
 PARROT_CANNOT_RETURN_NULL
-STRING *
+const STRING *
 parrot_split_path_ext(PARROT_INTERP, ARGMOD(STRING *in),
-        ARGOUT(STRING **wo_ext), ARGOUT(STRING **ext))
+        ARGOUT(STRING const**wo_ext), ARGOUT(STRING const**ext))
 {
     ASSERT_ARGS(parrot_split_path_ext)
 


More information about the parrot-commits mailing list