Author: petdance
Date: Sun Jun 3 09:23:49 2007
New Revision: 18782
Modified:
trunk/config/gen/makefiles/root.in
trunk/include/parrot/string_funcs.h
trunk/src/string.c
trunk/src/string_primitives.c
trunk/tools/build/headerize.pl
Log:
Updated the headerizer to look for PARROT_API, and updated the string*.c files
to declare them.
Modified: trunk/config/gen/makefiles/root.in
==============================================================================
--- trunk/config/gen/makefiles/root.in (original)
+++ trunk/config/gen/makefiles/root.in Sun Jun 3 09:23:49 2007
@@ -1822,8 +1822,11 @@
headerizer:
$(PERL) $(BUILD_TOOLS_DIR)/headerize.pl $(HEADERIZER_O_FILES)
+# Slowing working my way up to having everything headerized in
$(HEADERIZER_O_FILES)
hwork:
- $(PERL) $(BUILD_TOOLS_DIR)/headerize.pl src/string*.o
+ $(PERL) $(BUILD_TOOLS_DIR)/headerize.pl \
+ src/string.o \
+ src/string_primitives.o \
###############################################################################
#
Modified: trunk/include/parrot/string_funcs.h
==============================================================================
--- trunk/include/parrot/string_funcs.h (original)
+++ trunk/include/parrot/string_funcs.h Sun Jun 3 09:23:49 2007
@@ -138,7 +138,7 @@
UINTVAL limit );
PARROT_API STRING * string_from_const_cstring( Interp *interp,
- const char *buffer,
+ const char *buffer /*NULLOK*/,
UINTVAL len );
PARROT_API STRING * string_from_cstring( Interp *interp,
Modified: trunk/src/string.c
==============================================================================
--- trunk/src/string.c (original)
+++ trunk/src/string.c Sun Jun 3 09:23:49 2007
@@ -57,6 +57,7 @@
*/
+PARROT_API
void
Parrot_unmake_COW(Interp *interp, STRING *s /*NN*/)
{
@@ -118,6 +119,7 @@
extern int Parrot_in_memory_pool(Interp *, void *); /* XXX Move this to a
public .h file */
+PARROT_API
STRING *
Parrot_make_COW_reference(Interp *interp, STRING *s /*NULLOK*/)
{
@@ -166,6 +168,7 @@
*/
+PARROT_API
STRING*
Parrot_reuse_COW_reference(Interp *interp, STRING *s /*NULLOK*/, STRING *d
/*NN*/)
{
@@ -195,6 +198,7 @@
*/
+PARROT_API
STRING *
string_set(Interp *interp, STRING *dest /*NULLOK*/, STRING *src /*NULLOK*/)
{
@@ -229,6 +233,7 @@
*/
+PARROT_API
void
string_init(Parrot_Interp interp)
{
@@ -271,6 +276,7 @@
*/
+PARROT_API
void
string_deinit(Parrot_Interp interp)
{
@@ -290,6 +296,7 @@
*/
+PARROT_API
UINTVAL
string_capacity(Interp *interp, const STRING *s /*NN*/)
{
@@ -304,6 +311,7 @@
*/
+PARROT_API
STRING *
string_make_empty(Interp *interp,
parrot_string_representation_t representation, UINTVAL capacity)
@@ -339,6 +347,7 @@
*/
+PARROT_API
CHARSET *
string_rep_compatible(Interp *interp,
const STRING *a /*NN*/,
@@ -399,6 +408,7 @@
*/
+PARROT_API
STRING *
string_append(Interp *interp, STRING *a /*NULLOK*/, STRING *b /*NULLOK*/)
{
@@ -475,6 +485,7 @@
*/
+PARROT_API
STRING *
string_from_cstring(Interp *interp,
const char *buffer /*NULLOK*/, UINTVAL len)
@@ -494,9 +505,10 @@
*/
/* XXX This is identical to string_from_cstring and should be removed */
+PARROT_API
STRING *
string_from_const_cstring(Interp *interp,
- const char *buffer, UINTVAL len)
+ const char *buffer /*NULLOK*/, UINTVAL len)
{
return string_make_direct(interp, buffer, len ? len :
buffer ? strlen(buffer) : 0,
@@ -514,6 +526,7 @@
*/
+PARROT_API
const char*
string_primary_encoding_for_representation(Interp *interp,
parrot_string_representation_t representation)
@@ -539,6 +552,7 @@
*/
+PARROT_API
STRING *
const_string(Interp *interp, const char *buffer /*NN*/)
{
@@ -574,6 +588,7 @@
*/
+PARROT_API
STRING *
string_make(Interp *interp, const char *buffer /*NULLOK*/,
UINTVAL len, const char *charset_name /*NULLOK*/, UINTVAL flags)
@@ -595,6 +610,7 @@
}
+PARROT_API
STRING *
string_make_direct(Interp *interp, const char *buffer /*NULLOK*/, UINTVAL len,
ENCODING *encoding /*NN*/, CHARSET *charset /*NN*/, UINTVAL flags)
@@ -650,6 +666,7 @@
*/
+PARROT_API
STRING *
string_grow(Interp * interp, STRING *s /*NN*/, INTVAL addlen)
{
@@ -671,6 +688,7 @@
*/
+PARROT_API
UINTVAL
string_length(Interp *interp, const STRING *s /*NULLOK*/)
{
@@ -690,6 +708,7 @@
*/
+PARROT_API
INTVAL
string_index(Interp *interp, const STRING *s /*NN*/, UINTVAL idx)
{
@@ -707,6 +726,7 @@
*/
+PARROT_API
INTVAL
string_str_index(Interp *interp, const STRING *s /*NN*/,
const STRING *s2 /*NN*/, INTVAL start)
@@ -739,6 +759,7 @@
*/
+PARROT_API
INTVAL
string_ord(Interp *interp, const STRING *s /*NULLOK*/, INTVAL idx)
{
@@ -781,6 +802,7 @@
*/
+PARROT_API
STRING *
string_chr(Interp *interp, UINTVAL character)
{
@@ -802,6 +824,7 @@
*/
+PARROT_API
STRING *
string_copy(Interp *interp, STRING *s /*NULLOK*/)
{
@@ -819,6 +842,7 @@
*/
+PARROT_API
INTVAL
string_compute_strlen(Interp *interp, STRING *s /*NN*/)
{
@@ -834,6 +858,7 @@
*/
+PARROT_API
INTVAL
string_max_bytes(Interp *interp, const STRING *s /*NN*/, INTVAL nchars)
{
@@ -852,6 +877,7 @@
*/
+PARROT_API
STRING *
string_concat(Interp *interp, STRING *a /*NULLOK*/, STRING *b /*NULLOK*/,
UINTVAL Uflags)
{
@@ -899,6 +925,7 @@
*/
+PARROT_API
STRING *
string_repeat(Interp *interp, const STRING *s /*NN*/,
UINTVAL num, STRING **d /*NULLOK*/)
@@ -937,6 +964,7 @@
*/
+PARROT_API
STRING *
string_substr(Interp *interp, STRING *src /*NN*/, INTVAL offset, INTVAL length,
STRING **d /*NULLOK*/, int replace_dest)
@@ -1011,6 +1039,7 @@
*/
+PARROT_API
STRING *
string_replace(Interp *interp, STRING *src /*NULLOK*/,
INTVAL offset, INTVAL length, STRING *rep /*NULLOK*/, STRING **d
/*NULLOK*/)
@@ -1151,6 +1180,7 @@
*/
+PARROT_API
STRING *
string_chopn(Interp *interp, STRING *s /*NULLOK*/, INTVAL n, int in_place)
{
@@ -1202,6 +1232,7 @@
}
+PARROT_API
INTVAL
string_compare(Interp *interp, const STRING *s1 /*NULLOK*/, const STRING *s2
/*NULLOK*/)
{
@@ -1233,6 +1264,7 @@
*/
+PARROT_API
INTVAL
string_equal(Interp *interp, const STRING *s1 /*NULLOK*/, const STRING *s2
/*NULLOK*/)
{
@@ -1309,6 +1341,7 @@
*/
+PARROT_API
STRING *
string_bitwise_and(Interp *interp, STRING *s1 /*NULLOK*/,
STRING *s2 /*NULLOK*/, STRING **dest /*NULLOK*/)
@@ -1412,6 +1445,7 @@
*/
+PARROT_API
STRING *
string_bitwise_or(Interp *interp, STRING *s1 /*NULLOK*/,
STRING *s2 /*NULLOK*/, STRING **dest /*NULLOK*/)
@@ -1482,6 +1516,7 @@
*/
+PARROT_API
STRING *
string_bitwise_xor(Interp *interp, STRING *s1 /*NULLOK*/,
STRING *s2 /*NULLOK*/, STRING **dest /*NULLOK*/)
@@ -1563,6 +1598,7 @@
*/
+PARROT_API
STRING *
string_bitwise_not(Interp *interp, STRING *s /*NULLOK*/, STRING **dest
/*NULLOK*/)
{
@@ -1621,6 +1657,7 @@
*/
+PARROT_API
INTVAL
string_bool(Interp *interp, const STRING *s /*NULLOK*/)
{
@@ -1657,6 +1694,7 @@
*/
+PARROT_API
STRING*
string_nprintf(Interp *interp,
STRING *dest, INTVAL bytelen, const char *format /*NN*/, ...)
@@ -1686,13 +1724,13 @@
/*
-
FUNCDOC:
Writes and returns a Parrot string.
*/
+PARROT_API
STRING*
string_printf(Interp *interp, const char *format /*NN*/, ...)
{
@@ -1728,6 +1766,7 @@
*/
+PARROT_API
INTVAL
string_to_int(Interp *interp, const STRING *s /*NULLOK*/)
{
@@ -1783,6 +1822,7 @@
*/
+PARROT_API
FLOATVAL
string_to_num(Interp *interp, const STRING *s /*NULLOK*/)
{
@@ -1821,6 +1861,7 @@
*/
+PARROT_API
STRING *
string_from_int(Interp *interp, INTVAL i)
{
@@ -1836,6 +1877,7 @@
*/
+PARROT_API
STRING *
string_from_num(Interp *interp, FLOATVAL f)
{
@@ -1854,6 +1896,7 @@
*/
+PARROT_API
char *
string_to_cstring(Interp *interp, const STRING * const s /* NULLOK */)
{
@@ -1881,6 +1924,7 @@
*/
+PARROT_API
void
string_cstring_free(char *p /*NULLOK*/)
{
@@ -1896,6 +1940,7 @@
*/
+PARROT_API
void
string_pin(Interp *interp, STRING *s /*NN*/)
{
@@ -1924,6 +1969,7 @@
*/
+PARROT_API
void
string_unpin(Interp *interp, STRING *s /*NN*/)
{
@@ -1965,6 +2011,7 @@
*/
+PARROT_API
size_t
string_hash(Interp *interp, STRING *s /*NULLOK*/, size_t seed)
{
@@ -1993,6 +2040,7 @@
*/
+PARROT_API
STRING *
string_escape_string(Interp *interp, const STRING *src /*NULLOK*/)
{
@@ -2008,6 +2056,7 @@
*/
+PARROT_API
STRING *
string_escape_string_delimited(Interp *interp,
const STRING *src /*NULLOK*/, UINTVAL limit)
@@ -2118,7 +2167,7 @@
*/
-
+PARROT_API
STRING *
string_unescape_cstring(Interp *interp,
const char *cstring /*NN*/, char delimiter, const char *enc_char
/*NULLOK*/)
@@ -2213,7 +2262,7 @@
*/
-
+PARROT_API
STRING *
string_upcase(Interp *interp, const STRING *s /*NULLOK*/)
{
@@ -2230,6 +2279,7 @@
*/
+PARROT_API
void
string_upcase_inplace(Interp *interp, STRING *s /*NULLOK*/)
{
@@ -2247,6 +2297,7 @@
*/
+PARROT_API
STRING *
string_downcase(Interp *interp, const STRING *s /*NULLOK*/)
{
@@ -2263,6 +2314,7 @@
*/
+PARROT_API
void
string_downcase_inplace(Interp *interp, STRING *s /*NULLOK*/)
{
@@ -2286,6 +2338,7 @@
*/
+PARROT_API
STRING *
string_titlecase(Interp *interp, const STRING *s /*NULLOK*/)
{
@@ -2302,6 +2355,7 @@
*/
+PARROT_API
void
string_titlecase_inplace(Interp *interp, STRING *s /*NULLOK*/)
{
@@ -2318,6 +2372,7 @@
*/
+PARROT_API
STRING *
string_increment(Interp *interp, const STRING *s /*NULLOK*/)
{
@@ -2345,6 +2400,7 @@
*/
+PARROT_API
const char *
Parrot_string_cstring(Interp *interp, const STRING *str /*NN*/)
{
@@ -2362,6 +2418,7 @@
*/
+PARROT_API
INTVAL
Parrot_string_is_cclass(Interp *interp, INTVAL flags, STRING *s, UINTVAL
offset)
{
@@ -2370,6 +2427,7 @@
return CHARSET_IS_CCLASS(interp, flags, s, offset);
}
+PARROT_API
INTVAL
Parrot_string_find_cclass(Interp *interp, INTVAL flags, STRING *s,
UINTVAL offset, UINTVAL count)
@@ -2379,6 +2437,7 @@
return CHARSET_FIND_CCLASS(interp, flags, s, offset, count);
}
+PARROT_API
INTVAL
Parrot_string_find_not_cclass(Interp *interp, INTVAL flags, STRING *s
/*NULLOK*/,
UINTVAL offset, UINTVAL count)
@@ -2396,6 +2455,7 @@
*/
+PARROT_API
STRING*
Parrot_string_trans_charset(Interp *interp, STRING *src /*NULLOK*/,
INTVAL charset_nr, STRING *dest /*NULLOK*/)
@@ -2440,6 +2500,7 @@
*/
+PARROT_API
STRING*
Parrot_string_trans_encoding(Interp *interp, STRING *src /*NULLOK*/,
INTVAL encoding_nr, STRING *dest /*NULLOK*/)
@@ -2472,6 +2533,7 @@
return new_encoding->to_encoding(interp, src, dest);
}
+PARROT_API
STRING *
string_compose(Interp *interp, STRING *src /*NULLOK*/)
{
@@ -2482,6 +2544,7 @@
return CHARSET_COMPOSE(interp, src);
}
+PARROT_API
STRING*
string_join(Interp *interp, STRING *j /*NULLOK*/, PMC *ar)
{
@@ -2502,6 +2565,7 @@
return res;
}
+PARROT_API
PMC*
string_split(Interp *interp, STRING *delim /*NN*/, STRING *str /*NN*/)
{
@@ -2558,6 +2622,7 @@
*/
+PARROT_API
STRING*
uint_to_str(Interp *interp,
char *tc /*NN*/, UHUGEINTVAL num, char base, int minus)
@@ -2593,6 +2658,7 @@
*/
+PARROT_API
STRING *
int_to_str(Interp *interp, char *tc /*NN*/, HUGEINTVAL num, char base)
{
Modified: trunk/src/string_primitives.c
==============================================================================
--- trunk/src/string_primitives.c (original)
+++ trunk/src/string_primitives.c Sun Jun 3 09:23:49 2007
@@ -1,5 +1,5 @@
/*
-Copyright (C) 2006, The Perl Foundation.
+Copyright (C) 2006-2007, The Perl Foundation.
$Id$
=head1 NAME
@@ -44,6 +44,7 @@
*/
+PARROT_API
void
string_set_data_directory(const char *dir)
{
@@ -69,17 +70,12 @@
/*
-=item C<void
-string_fill_from_buffer(Interp *interp, const void *buffer,
- UINTVAL len, const char *encoding_name, STRING *s)>
-
Creates a Parrot string from an "external" buffer, converting from any
supported encoding into Parrot string's internal format.
-=cut
-
*/
+PARROT_API
void
string_fill_from_buffer(Interp *interp, const void *buffer,
UINTVAL len, const char *encoding_name, STRING *s /*NULLOK*/)
@@ -161,6 +157,7 @@
/* Unescape a single character. We assume that we're at the start of a
sequence, right after the \ */
+PARROT_API
Parrot_UInt4
string_unescape_one(Interp *interp, UINTVAL *offset /*NN*/,
STRING *string)
@@ -375,6 +372,7 @@
*/
+PARROT_API
UINTVAL
Parrot_char_digit_value(Interp *interp, UINTVAL character)
{
Modified: trunk/tools/build/headerize.pl
==============================================================================
--- trunk/tools/build/headerize.pl (original)
+++ trunk/tools/build/headerize.pl Sun Jun 3 09:23:49 2007
@@ -130,9 +130,16 @@
sub function_components {
my $proto = shift;
- my @parts = split( /\n/, $proto, 2 );
- my $returntype = $parts[0];
- my $parms = $parts[1];
+ my @lines = split( /\n/, $proto );
+ chomp @lines;
+ my $parrot_api;
+ if ( $lines[0] eq 'PARROT_API' ) {
+ $parrot_api = 1;
+ shift @lines;
+ }
+
+ my $returntype = shift @lines;
+ my $parms = join( " ", @lines );
$parms =~ s/\s+/ /g;
$parms =~ s/([^(]+)\s*\((.+)\);?/$2/ or die "Couldn't handle $proto";
@@ -148,7 +155,9 @@
$returntype =~ s/^((static)\s+)?//i;
$static = $2 || '';
- return [ $static, $returntype, $funcname, @parms ];
+ die "Impossible to have both static and PARROT_API" if $parrot_api &&
$static;
+
+ return [ $parrot_api, $static, $returntype, $funcname, @parms ];
}
sub attrs_from_args {
@@ -172,12 +181,13 @@
my @decls;
foreach my $func ( @funcs ) {
- my ($static, $ret_type, $funcname, @args) = @{$func};
+ my ($parrot_api, $static, $ret_type, $funcname, @args) = @{$func};
next if $static;
my $multiline = 0;
- my $decl = sprintf( "PARROT_API %s %s(", $ret_type, $funcname );
+ my $decl = sprintf( "%s %s(", $ret_type, $funcname );
+ $decl = "PARROT_API $decl" if $parrot_api;
my @attrs = attrs_from_args( @args );
my $argline = join( ", ", @args );
@@ -253,9 +263,9 @@
my $header = do { local $/ = undef; <$FILE> }; # slurp
close $FILE;
- for my $cfile ( sort keys %$cfiles ) {
+ for my $cfile ( sort keys %{$cfiles} ) {
my $funcs = $cfiles->{$cfile};
- my @funcs = sort { $a->[2] cmp $b->[2] } @{$funcs};
+ my @funcs = sort { $a->[3] cmp $b->[3] } @{$funcs};
my @function_decls = make_function_decls( @funcs );