Author: petdance
Date: Sun Jun  3 09:55:19 2007
New Revision: 18784

Modified:
   trunk/include/parrot/string_funcs.h
   trunk/src/string.c
   trunk/tools/build/headerize.pl

Log:
Headerizer now removes consts from the header files that the caller doesnt need 
to see.  This means you can do more internal consting without cluttering your 
API.

Modified: trunk/include/parrot/string_funcs.h
==============================================================================
--- trunk/include/parrot/string_funcs.h (original)
+++ trunk/include/parrot/string_funcs.h Sun Jun  3 09:55:19 2007
@@ -269,7 +269,7 @@
     STRING *s /*NULLOK*/ );
 
 PARROT_API char * string_to_cstring( Interp *interp,
-    const STRING * const s /* NULLOK */ );
+    const STRING *s /* NULLOK */ );
 
 PARROT_API INTVAL string_to_int( Interp *interp, const STRING *s /*NULLOK*/ );
 PARROT_API FLOATVAL string_to_num( Interp *interp,

Modified: trunk/src/string.c
==============================================================================
--- trunk/src/string.c  (original)
+++ trunk/src/string.c  Sun Jun  3 09:55:19 2007
@@ -488,7 +488,7 @@
 PARROT_API
 STRING *
 string_from_cstring(Interp *interp,
-    const char *buffer /*NULLOK*/, UINTVAL len)
+    const char * const buffer /*NULLOK*/, const UINTVAL len)
 {
     return string_make_direct(interp, buffer, len ? len :
             buffer ? strlen(buffer) : 0,
@@ -508,7 +508,7 @@
 PARROT_API
 STRING *
 string_from_const_cstring(Interp *interp,
-    const char *buffer /*NULLOK*/, UINTVAL len)
+    const char * const buffer /*NULLOK*/, const UINTVAL len)
 {
     return string_make_direct(interp, buffer, len ? len :
             buffer ? strlen(buffer) : 0,
@@ -1234,7 +1234,7 @@
 
 PARROT_API
 INTVAL
-string_compare(Interp *interp, const STRING *s1 /*NULLOK*/, const STRING *s2 
/*NULLOK*/)
+string_compare(Interp *interp, const STRING * const s1 /*NULLOK*/, const 
STRING * const s2 /*NULLOK*/)
 {
     if (!s1 && !s2) {
         return 0;

Modified: trunk/tools/build/headerize.pl
==============================================================================
--- trunk/tools/build/headerize.pl      (original)
+++ trunk/tools/build/headerize.pl      Sun Jun  3 09:55:19 2007
@@ -149,6 +149,12 @@
     for (@parms) {
         /\S+\s+\S+/ || ( $_ eq '...' ) || ( $_ eq 'void' ) || /theINTERP/
             or die "Bad parms in $proto";
+        if ( m{(?<!/)\*} ) { # Pointers?
+            s/\*\s*const\s+/*/;
+        }
+        else {
+            s/^const\s+//;
+        }
     }
 
     my $static;

Reply via email to