summaryrefslogtreecommitdiff
path: root/embed.pl
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2010-09-29 16:10:19 +0100
committerNicholas Clark <nick@ccl4.org>2010-09-29 16:12:34 +0100
commit9516dc403f4585f22115d8ee45c2c0393b765366 (patch)
treedec163795b26663e3d375d9e10899bc6611f7efe /embed.pl
parenta6696b9232179cc55e02a89971d26878ab2fe23c (diff)
downloadperl-9516dc403f4585f22115d8ee45c2c0393b765366.tar.gz
In embed.pl, directly iterate @embed to generate proto.h
This replaces calling walk_table() with a file handle and a reference to &write_protos.
Diffstat (limited to 'embed.pl')
-rwxr-xr-xembed.pl39
1 files changed, 18 insertions, 21 deletions
diff --git a/embed.pl b/embed.pl
index e1c7d61ee6..aab23d899a 100755
--- a/embed.pl
+++ b/embed.pl
@@ -176,14 +176,18 @@ sub walk_table (&@) {
# generate proto.h
my $wrote_protected = 0;
-sub write_protos {
+{
+ my $pr = safer_open('proto.h-new');
+ print $pr do_not_edit ("proto.h"), "\nSTART_EXTERN_C\n";
my $ret;
- if (@_ == 1) {
- my $arg = shift;
- $ret = "$arg\n";
- }
- else {
- my ($flags,$retval,$plain_func,@args) = @_;
+
+ foreach (@embed) {
+ if (@$_ == 1) {
+ print $pr "$_->[0]\n";
+ next;
+ }
+
+ my ($flags,$retval,$plain_func,@args) = @$_;
my @nonnull;
my $has_context = ( $flags !~ /n/ );
my $never_returns = ( $flags =~ /r/ );
@@ -294,8 +298,14 @@ sub write_protos {
. join '; ', map "assert($_)", @names_of_nn;
}
$ret .= @attrs ? "\n\n" : "\n";
+
+ print $pr $ret;
}
- $ret;
+
+ print $pr "END_EXTERN_C\n/* ex: set ro: */\n";
+
+ safer_close($pr);
+ rename_if_different('proto.h-new', 'proto.h');
}
# generates global.sym (API export list)
@@ -317,19 +327,6 @@ sub write_protos {
}
}
-{
- my $pr = safer_open('proto.h-new');
-
- print $pr do_not_edit ("proto.h"), "\nSTART_EXTERN_C\n";
-
- walk_table(\&write_protos, $pr);
-
- print $pr "END_EXTERN_C\n/* ex: set ro: */\n";
-
- safer_close($pr);
- rename_if_different('proto.h-new', 'proto.h');
-}
-
warn "$unflagged_pointers pointer arguments to clean up\n" if $unflagged_pointers;
walk_table(\&write_global_sym, "global.sym", "# ex: set ro:\n");