[svn:parrot] r45501 - in trunk: include/parrot src/io

petdance at svn.parrot.org petdance at svn.parrot.org
Sat Apr 10 04:54:49 UTC 2010


Author: petdance
Date: Sat Apr 10 04:54:48 2010
New Revision: 45501
URL: https://trac.parrot.org/parrot/changeset/45501

Log:
more funcation annotations

Modified:
   trunk/include/parrot/io.h
   trunk/include/parrot/io_unix.h
   trunk/src/io/api.c
   trunk/src/io/filehandle.c
   trunk/src/io/unix.c

Modified: trunk/include/parrot/io.h
==============================================================================
--- trunk/include/parrot/io.h	Sat Apr 10 04:18:29 2010	(r45500)
+++ trunk/include/parrot/io.h	Sat Apr 10 04:54:48 2010	(r45501)
@@ -1,5 +1,5 @@
 /* io.h
- *  Copyright (C) 2001-2003, Parrot Foundation.
+ *  Copyright (C) 2001-2010, Parrot Foundation.
  *  SVN Info
  *     $Id$
  *  Overview:
@@ -584,24 +584,29 @@
         FUNC_MODIFIES(*pmc);
 
 PARROT_EXPORT
+PARROT_WARN_UNUSED_RESULT
 PARROT_CAN_RETURN_NULL
 unsigned char * Parrot_io_get_buffer_end(SHIM_INTERP,
-    ARGIN_NULLOK(PMC *filehandle));
+    ARGIN(const PMC *filehandle))
+        __attribute__nonnull__(2);
 
 PARROT_EXPORT
 PARROT_CAN_RETURN_NULL
 unsigned char * Parrot_io_get_buffer_next(SHIM_INTERP,
-    ARGIN(PMC *filehandle))
+    ARGIN(const PMC *filehandle))
         __attribute__nonnull__(2);
 
 PARROT_EXPORT
+PARROT_WARN_UNUSED_RESULT
 PARROT_CAN_RETURN_NULL
 unsigned char * Parrot_io_get_buffer_start(SHIM_INTERP,
     ARGIN(PMC *filehandle))
         __attribute__nonnull__(2);
 
 PARROT_EXPORT
-PIOOFF_T Parrot_io_get_file_position(SHIM_INTERP, ARGIN(PMC *filehandle))
+PARROT_WARN_UNUSED_RESULT
+PIOOFF_T Parrot_io_get_file_position(SHIM_INTERP,
+    ARGIN(const PMC *filehandle))
         __attribute__nonnull__(2);
 
 PARROT_EXPORT
@@ -613,24 +618,26 @@
         __attribute__nonnull__(2);
 
 PARROT_EXPORT
+PARROT_WARN_UNUSED_RESULT
 PIOOFF_T Parrot_io_get_last_file_position(SHIM_INTERP,
-    ARGIN(PMC *filehandle))
+    ARGIN(const PMC *filehandle))
         __attribute__nonnull__(2);
 
 PARROT_EXPORT
-PIOHANDLE Parrot_io_get_os_handle(SHIM_INTERP, ARGIN(PMC *filehandle))
+PARROT_WARN_UNUSED_RESULT
+PIOHANDLE Parrot_io_get_os_handle(SHIM_INTERP, ARGIN(const PMC *filehandle))
         __attribute__nonnull__(2);
 
 PARROT_EXPORT
-INTVAL Parrot_io_is_closed_filehandle(PARROT_INTERP, ARGMOD(PMC *pmc))
+PARROT_WARN_UNUSED_RESULT
+INTVAL Parrot_io_is_closed_filehandle(PARROT_INTERP, ARGIN(const PMC *pmc))
         __attribute__nonnull__(1)
-        __attribute__nonnull__(2)
-        FUNC_MODIFIES(*pmc);
+        __attribute__nonnull__(2);
 
 PARROT_EXPORT
 PARROT_WARN_UNUSED_RESULT
 INTVAL Parrot_io_is_encoding(PARROT_INTERP,
-    ARGIN(PMC *filehandle),
+    ARGIN(const PMC *filehandle),
     ARGIN(STRING *value))
         __attribute__nonnull__(1)
         __attribute__nonnull__(2)
@@ -644,9 +651,10 @@
 
 PARROT_EXPORT
 void Parrot_io_set_file_position(SHIM_INTERP,
-    ARGIN(PMC *filehandle),
+    ARGMOD(PMC *filehandle),
     PIOOFF_T file_pos)
-        __attribute__nonnull__(2);
+        __attribute__nonnull__(2)
+        FUNC_MODIFIES(*filehandle);
 
 PARROT_EXPORT
 void Parrot_io_set_file_size(SHIM_INTERP,
@@ -660,21 +668,24 @@
 
 PARROT_EXPORT
 void Parrot_io_set_os_handle(SHIM_INTERP,
-    ARGIN(PMC *filehandle),
+    ARGMOD(PMC *filehandle),
     PIOHANDLE file_descriptor)
-        __attribute__nonnull__(2);
+        __attribute__nonnull__(2)
+        FUNC_MODIFIES(*filehandle);
 
 PARROT_CAN_RETURN_NULL
-void Parrot_io_clear_buffer(PARROT_INTERP, ARGIN(PMC *filehandle))
+void Parrot_io_clear_buffer(PARROT_INTERP, ARGMOD(PMC *filehandle))
         __attribute__nonnull__(1)
-        __attribute__nonnull__(2);
+        __attribute__nonnull__(2)
+        FUNC_MODIFIES(*filehandle);
 
 PARROT_CAN_RETURN_NULL
-INTVAL Parrot_io_get_buffer_flags(SHIM_INTERP, ARGIN(PMC *filehandle))
+INTVAL Parrot_io_get_buffer_flags(SHIM_INTERP, ARGIN(const PMC *filehandle))
         __attribute__nonnull__(2);
 
 PARROT_CAN_RETURN_NULL
-size_t Parrot_io_get_buffer_size(SHIM_INTERP, ARGIN(PMC *filehandle))
+PARROT_WARN_UNUSED_RESULT
+size_t Parrot_io_get_buffer_size(SHIM_INTERP, ARGIN(const PMC *filehandle))
         __attribute__nonnull__(2);
 
 PARROT_WARN_UNUSED_RESULT
@@ -687,29 +698,34 @@
         FUNC_MODIFIES(*buf);
 
 void Parrot_io_set_buffer_end(SHIM_INTERP,
-    ARGIN(PMC *filehandle),
+    ARGMOD(PMC *filehandle),
     ARGIN_NULLOK(unsigned char *new_end))
-        __attribute__nonnull__(2);
+        __attribute__nonnull__(2)
+        FUNC_MODIFIES(*filehandle);
 
 void Parrot_io_set_buffer_flags(SHIM_INTERP,
-    ARGIN(PMC *filehandle),
+    ARGMOD(PMC *filehandle),
     INTVAL new_flags)
-        __attribute__nonnull__(2);
+        __attribute__nonnull__(2)
+        FUNC_MODIFIES(*filehandle);
 
 void Parrot_io_set_buffer_next(SHIM_INTERP,
-    ARGIN(PMC *filehandle),
+    ARGMOD(PMC *filehandle),
     ARGIN_NULLOK(unsigned char *new_next))
-        __attribute__nonnull__(2);
+        __attribute__nonnull__(2)
+        FUNC_MODIFIES(*filehandle);
 
 void Parrot_io_set_buffer_size(SHIM_INTERP,
-    ARGIN(PMC *filehandle),
+    ARGMOD(PMC *filehandle),
     size_t new_size)
-        __attribute__nonnull__(2);
+        __attribute__nonnull__(2)
+        FUNC_MODIFIES(*filehandle);
 
 void Parrot_io_set_buffer_start(SHIM_INTERP,
-    ARGIN(PMC *filehandle),
+    ARGMOD(PMC *filehandle),
     ARGIN_NULLOK(unsigned char *new_start))
-        __attribute__nonnull__(2);
+        __attribute__nonnull__(2)
+        FUNC_MODIFIES(*filehandle);
 
 #define ASSERT_ARGS_Parrot_io_close_filehandle __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
        PARROT_ASSERT_ARG(interp) \
@@ -717,7 +733,8 @@
 #define ASSERT_ARGS_Parrot_io_flush_filehandle __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
        PARROT_ASSERT_ARG(interp) \
     , PARROT_ASSERT_ARG(pmc))
-#define ASSERT_ARGS_Parrot_io_get_buffer_end __attribute__unused__ int _ASSERT_ARGS_CHECK = (0)
+#define ASSERT_ARGS_Parrot_io_get_buffer_end __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
+       PARROT_ASSERT_ARG(filehandle))
 #define ASSERT_ARGS_Parrot_io_get_buffer_next __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
        PARROT_ASSERT_ARG(filehandle))
 #define ASSERT_ARGS_Parrot_io_get_buffer_start __attribute__unused__ int _ASSERT_ARGS_CHECK = (\

Modified: trunk/include/parrot/io_unix.h
==============================================================================
--- trunk/include/parrot/io_unix.h	Sat Apr 10 04:18:29 2010	(r45500)
+++ trunk/include/parrot/io_unix.h	Sat Apr 10 04:54:48 2010	(r45501)
@@ -55,7 +55,7 @@
 INTVAL Parrot_io_init_unix(PARROT_INTERP)
         __attribute__nonnull__(1);
 
-INTVAL Parrot_io_is_closed_unix(PARROT_INTERP, ARGIN(PMC *filehandle))
+INTVAL Parrot_io_is_closed_unix(PARROT_INTERP, ARGIN(const PMC *filehandle))
         __attribute__nonnull__(1)
         __attribute__nonnull__(2);
 

Modified: trunk/src/io/api.c
==============================================================================
--- trunk/src/io/api.c	Sat Apr 10 04:18:29 2010	(r45500)
+++ trunk/src/io/api.c	Sat Apr 10 04:54:48 2010	(r45501)
@@ -179,9 +179,8 @@
 {
     ASSERT_ARGS(Parrot_io_fdopen)
     PMC *new_filehandle;
-    INTVAL flags;
+    const INTVAL flags = Parrot_io_parse_open_flags(interp, sflags);
 
-    flags = Parrot_io_parse_open_flags(interp, sflags);
     if (!flags)
         return PMCNULL;
 

Modified: trunk/src/io/filehandle.c
==============================================================================
--- trunk/src/io/filehandle.c	Sat Apr 10 04:18:29 2010	(r45500)
+++ trunk/src/io/filehandle.c	Sat Apr 10 04:54:48 2010	(r45501)
@@ -1,5 +1,5 @@
 /*
-Copyright (C) 2001-2009, Parrot Foundation.
+Copyright (C) 2001-2010, Parrot Foundation.
 $Id$
 
 =head1 NAME
@@ -51,7 +51,7 @@
     mode_len = Parrot_str_byte_length(interp, mode_str);
 
     for (i = 0; i < mode_len; ++i) {
-        INTVAL s = Parrot_str_indexed(interp, mode_str, i);
+        const INTVAL s = Parrot_str_indexed(interp, mode_str, i);
         switch (s) {
           case 'r':
             flags |= PIO_F_READ;
@@ -124,7 +124,7 @@
         return *buf;
     }
     else {
-        STRING *s = *buf;
+        STRING * const s = *buf;
         if (s->bufused < len)
             Parrot_gc_reallocate_string_storage(interp, s, len);
         return s;
@@ -154,7 +154,7 @@
 
 PARROT_EXPORT
 void
-Parrot_io_set_os_handle(SHIM_INTERP, ARGIN(PMC *filehandle), PIOHANDLE file_descriptor)
+Parrot_io_set_os_handle(SHIM_INTERP, ARGMOD(PMC *filehandle), PIOHANDLE file_descriptor)
 {
     ASSERT_ARGS(Parrot_io_set_os_handle)
     PARROT_FILEHANDLE(filehandle)->os_handle = file_descriptor;
@@ -162,7 +162,7 @@
 
 /*
 
-=item C<PIOHANDLE Parrot_io_get_os_handle(PARROT_INTERP, PMC *filehandle)>
+=item C<PIOHANDLE Parrot_io_get_os_handle(PARROT_INTERP, const PMC *filehandle)>
 
 Retrieve the C<os_handle> attribute of the FileHandle object, which stores the
 low-level filehandle for the OS.
@@ -177,8 +177,9 @@
 */
 
 PARROT_EXPORT
+PARROT_WARN_UNUSED_RESULT
 PIOHANDLE
-Parrot_io_get_os_handle(SHIM_INTERP, ARGIN(PMC *filehandle))
+Parrot_io_get_os_handle(SHIM_INTERP, ARGIN(const PMC *filehandle))
 {
     ASSERT_ARGS(Parrot_io_get_os_handle)
     return PARROT_FILEHANDLE(filehandle)->os_handle;
@@ -205,7 +206,7 @@
 Parrot_io_set_flags(SHIM_INTERP, ARGIN(PMC *filehandle), INTVAL flags)
 {
     ASSERT_ARGS(Parrot_io_set_flags)
-    Parrot_FileHandle_attributes *handle_struct = PARROT_FILEHANDLE(filehandle);
+    Parrot_FileHandle_attributes * const handle_struct = PARROT_FILEHANDLE(filehandle);
     handle_struct->flags = flags;
 }
 
@@ -304,7 +305,7 @@
 */
 
 void
-Parrot_io_set_buffer_start(SHIM_INTERP, ARGIN(PMC *filehandle),
+Parrot_io_set_buffer_start(SHIM_INTERP, ARGMOD(PMC *filehandle),
         ARGIN_NULLOK(unsigned char *new_start))
 {
     ASSERT_ARGS(Parrot_io_set_buffer_start)
@@ -329,6 +330,7 @@
 */
 
 PARROT_EXPORT
+PARROT_WARN_UNUSED_RESULT
 PARROT_CAN_RETURN_NULL
 unsigned char *
 Parrot_io_get_buffer_start(SHIM_INTERP, ARGIN(PMC *filehandle))
@@ -339,7 +341,7 @@
 
 /*
 
-=item C<unsigned char * Parrot_io_get_buffer_next(PARROT_INTERP, PMC
+=item C<unsigned char * Parrot_io_get_buffer_next(PARROT_INTERP, const PMC
 *filehandle)>
 
 Get the C<buffer_next> attribute of the FileHandle object, which stores
@@ -357,7 +359,7 @@
 PARROT_EXPORT
 PARROT_CAN_RETURN_NULL
 unsigned char *
-Parrot_io_get_buffer_next(SHIM_INTERP, ARGIN(PMC *filehandle))
+Parrot_io_get_buffer_next(SHIM_INTERP, ARGIN(const PMC *filehandle))
 {
     ASSERT_ARGS(Parrot_io_get_buffer_next)
     return PARROT_FILEHANDLE(filehandle)->buffer_next;
@@ -381,7 +383,7 @@
 */
 
 void
-Parrot_io_set_buffer_next(SHIM_INTERP, ARGIN(PMC *filehandle),
+Parrot_io_set_buffer_next(SHIM_INTERP, ARGMOD(PMC *filehandle),
         ARGIN_NULLOK(unsigned char *new_next))
 {
     ASSERT_ARGS(Parrot_io_set_buffer_next)
@@ -390,7 +392,7 @@
 
 /*
 
-=item C<unsigned char * Parrot_io_get_buffer_end(PARROT_INTERP, PMC
+=item C<unsigned char * Parrot_io_get_buffer_end(PARROT_INTERP, const PMC
 *filehandle)>
 
 Get the C<buffer_end> attribute of the FileHandle object, which stores
@@ -406,9 +408,10 @@
 */
 
 PARROT_EXPORT
+PARROT_WARN_UNUSED_RESULT
 PARROT_CAN_RETURN_NULL
 unsigned char *
-Parrot_io_get_buffer_end(SHIM_INTERP, ARGIN_NULLOK(PMC *filehandle))
+Parrot_io_get_buffer_end(SHIM_INTERP, ARGIN(const PMC *filehandle))
 {
     ASSERT_ARGS(Parrot_io_get_buffer_end)
     return PARROT_FILEHANDLE(filehandle)->buffer_end;
@@ -432,7 +435,7 @@
 */
 
 void
-Parrot_io_set_buffer_end(SHIM_INTERP, ARGIN(PMC *filehandle),
+Parrot_io_set_buffer_end(SHIM_INTERP, ARGMOD(PMC *filehandle),
         ARGIN_NULLOK(unsigned char *new_end))
 {
     ASSERT_ARGS(Parrot_io_set_buffer_end)
@@ -441,7 +444,7 @@
 
 /*
 
-=item C<INTVAL Parrot_io_get_buffer_flags(PARROT_INTERP, PMC *filehandle)>
+=item C<INTVAL Parrot_io_get_buffer_flags(PARROT_INTERP, const PMC *filehandle)>
 
 Get the C<buffer_flags> attribute of the FileHandle object, which stores
 a collection of flags specific to the buffer.
@@ -457,7 +460,7 @@
 
 PARROT_CAN_RETURN_NULL
 INTVAL
-Parrot_io_get_buffer_flags(SHIM_INTERP, ARGIN(PMC *filehandle))
+Parrot_io_get_buffer_flags(SHIM_INTERP, ARGIN(const PMC *filehandle))
 {
     ASSERT_ARGS(Parrot_io_get_buffer_flags)
     return PARROT_FILEHANDLE(filehandle)->buffer_flags;
@@ -481,7 +484,7 @@
 */
 
 void
-Parrot_io_set_buffer_flags(SHIM_INTERP, ARGIN(PMC *filehandle), INTVAL new_flags)
+Parrot_io_set_buffer_flags(SHIM_INTERP, ARGMOD(PMC *filehandle), INTVAL new_flags)
 {
     ASSERT_ARGS(Parrot_io_set_buffer_flags)
     PARROT_FILEHANDLE(filehandle)->buffer_flags = new_flags;
@@ -489,7 +492,7 @@
 
 /*
 
-=item C<size_t Parrot_io_get_buffer_size(PARROT_INTERP, PMC *filehandle)>
+=item C<size_t Parrot_io_get_buffer_size(PARROT_INTERP, const PMC *filehandle)>
 
 Get the C<buffer_size> attribute of the FileHandle object, which stores
 the size of the buffer (in bytes).
@@ -504,8 +507,9 @@
 */
 
 PARROT_CAN_RETURN_NULL
+PARROT_WARN_UNUSED_RESULT
 size_t
-Parrot_io_get_buffer_size(SHIM_INTERP, ARGIN(PMC *filehandle))
+Parrot_io_get_buffer_size(SHIM_INTERP, ARGIN(const PMC *filehandle))
 {
     ASSERT_ARGS(Parrot_io_get_buffer_size)
     return PARROT_FILEHANDLE(filehandle)->buffer_size;
@@ -529,7 +533,7 @@
 */
 
 void
-Parrot_io_set_buffer_size(SHIM_INTERP, ARGIN(PMC *filehandle), size_t new_size)
+Parrot_io_set_buffer_size(SHIM_INTERP, ARGMOD(PMC *filehandle), size_t new_size)
 {
     ASSERT_ARGS(Parrot_io_set_buffer_size)
     PARROT_FILEHANDLE(filehandle)->buffer_size = new_size;
@@ -552,7 +556,7 @@
 
 PARROT_CAN_RETURN_NULL
 void
-Parrot_io_clear_buffer(PARROT_INTERP, ARGIN(PMC *filehandle))
+Parrot_io_clear_buffer(PARROT_INTERP, ARGMOD(PMC *filehandle))
 {
     ASSERT_ARGS(Parrot_io_clear_buffer)
     Parrot_FileHandle_attributes * const io = PARROT_FILEHANDLE(filehandle);
@@ -564,7 +568,8 @@
 
 /*
 
-=item C<PIOOFF_T Parrot_io_get_file_position(PARROT_INTERP, PMC *filehandle)>
+=item C<PIOOFF_T Parrot_io_get_file_position(PARROT_INTERP, const PMC
+*filehandle)>
 
 Get the C<file_pos> attribute of the FileHandle object, which stores
 the current file position of the filehandle.
@@ -579,8 +584,9 @@
 */
 
 PARROT_EXPORT
+PARROT_WARN_UNUSED_RESULT
 PIOOFF_T
-Parrot_io_get_file_position(SHIM_INTERP, ARGIN(PMC *filehandle))
+Parrot_io_get_file_position(SHIM_INTERP, ARGIN(const PMC *filehandle))
 {
     ASSERT_ARGS(Parrot_io_get_file_position)
     return PARROT_FILEHANDLE(filehandle)->file_pos;
@@ -588,7 +594,7 @@
 
 /*
 
-=item C<PIOOFF_T Parrot_io_get_last_file_position(PARROT_INTERP, PMC
+=item C<PIOOFF_T Parrot_io_get_last_file_position(PARROT_INTERP, const PMC
 *filehandle)>
 
 Get the C<file_pos> attribute of the FileHandle object, which stores
@@ -604,8 +610,9 @@
 */
 
 PARROT_EXPORT
+PARROT_WARN_UNUSED_RESULT
 PIOOFF_T
-Parrot_io_get_last_file_position(SHIM_INTERP, ARGIN(PMC *filehandle))
+Parrot_io_get_last_file_position(SHIM_INTERP, ARGIN(const PMC *filehandle))
 {
     ASSERT_ARGS(Parrot_io_get_last_file_position)
     return PARROT_FILEHANDLE(filehandle)->last_pos;
@@ -631,7 +638,7 @@
 
 PARROT_EXPORT
 void
-Parrot_io_set_file_position(SHIM_INTERP, ARGIN(PMC *filehandle), PIOOFF_T file_pos)
+Parrot_io_set_file_position(SHIM_INTERP, ARGMOD(PMC *filehandle), PIOOFF_T file_pos)
 {
     ASSERT_ARGS(Parrot_io_set_file_position)
     Parrot_FileHandle_attributes * const handle_struct = PARROT_FILEHANDLE(filehandle);
@@ -641,8 +648,8 @@
 
 /*
 
-=item C<INTVAL Parrot_io_is_encoding(PARROT_INTERP, PMC *filehandle, STRING
-*value)>
+=item C<INTVAL Parrot_io_is_encoding(PARROT_INTERP, const PMC *filehandle,
+STRING *value)>
 
 Check whether the encoding attribute of the filehandle matches a passed in
 string.
@@ -659,7 +666,7 @@
 PARROT_EXPORT
 PARROT_WARN_UNUSED_RESULT
 INTVAL
-Parrot_io_is_encoding(PARROT_INTERP, ARGIN(PMC *filehandle), ARGIN(STRING *value))
+Parrot_io_is_encoding(PARROT_INTERP, ARGIN(const PMC *filehandle), ARGIN(STRING *value))
 {
     ASSERT_ARGS(Parrot_io_is_encoding)
     Parrot_FileHandle_attributes * const handle_struct = PARROT_FILEHANDLE(filehandle);
@@ -704,7 +711,7 @@
 
 /*
 
-=item C<INTVAL Parrot_io_is_closed_filehandle(PARROT_INTERP, PMC *pmc)>
+=item C<INTVAL Parrot_io_is_closed_filehandle(PARROT_INTERP, const PMC *pmc)>
 
 Test whether a filehandle is closed.
 
@@ -713,8 +720,9 @@
 */
 
 PARROT_EXPORT
+PARROT_WARN_UNUSED_RESULT
 INTVAL
-Parrot_io_is_closed_filehandle(PARROT_INTERP, ARGMOD(PMC *pmc))
+Parrot_io_is_closed_filehandle(PARROT_INTERP, ARGIN(const PMC *pmc))
 {
     ASSERT_ARGS(Parrot_io_is_closed_filehandle)
     return PIO_IS_CLOSED(interp, pmc);

Modified: trunk/src/io/unix.c
==============================================================================
--- trunk/src/io/unix.c	Sat Apr 10 04:18:29 2010	(r45500)
+++ trunk/src/io/unix.c	Sat Apr 10 04:54:48 2010	(r45501)
@@ -388,7 +388,7 @@
 
 /*
 
-=item C<INTVAL Parrot_io_is_closed_unix(PARROT_INTERP, PMC *filehandle)>
+=item C<INTVAL Parrot_io_is_closed_unix(PARROT_INTERP, const PMC *filehandle)>
 
 Test whether the filehandle has been closed.
 
@@ -397,7 +397,7 @@
 */
 
 INTVAL
-Parrot_io_is_closed_unix(PARROT_INTERP, ARGIN(PMC *filehandle))
+Parrot_io_is_closed_unix(PARROT_INTERP, ARGIN(const PMC *filehandle))
 {
     ASSERT_ARGS(Parrot_io_is_closed_unix)
     if (Parrot_io_get_os_handle(interp, filehandle) == -1)


More information about the parrot-commits mailing list