mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-08 10:14:04 +02:00
Support for template files.
This commit is contained in:
@@ -1,3 +1,9 @@
|
|||||||
|
2002-10-16 Matthias Clasen <maclas@gmx.de>
|
||||||
|
|
||||||
|
* glib-mkenums.in: Support for template files.
|
||||||
|
|
||||||
|
* glib-mkenums.1: Document --template.
|
||||||
|
|
||||||
2002-10-15 Matthias Clasen <maclas@gmx.de>
|
2002-10-15 Matthias Clasen <maclas@gmx.de>
|
||||||
|
|
||||||
* gtype.c (g_type_interface_prerequisites): New function to obtain
|
* gtype.c (g_type_interface_prerequisites): New function to obtain
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
.TH GLIB-MKENUMS 1 "20 Apr 2001"
|
.TH GLIB-MKENUMS 1 "27 Jul 2002"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
glib-mkenums \- C language enum description generation utility
|
glib-mkenums \- C language enum description generation utility
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
@@ -45,6 +45,20 @@ Put out <text> after iterating over all values of an enum.
|
|||||||
Template for auto-generated comments, the default (for C code generations) is
|
Template for auto-generated comments, the default (for C code generations) is
|
||||||
"/* @comment@ */".
|
"/* @comment@ */".
|
||||||
.TP
|
.TP
|
||||||
|
\fI--template file
|
||||||
|
Read templates from the given file. The templates are enclosed in
|
||||||
|
specially-formatted C comments
|
||||||
|
.PP
|
||||||
|
.RS
|
||||||
|
.nf
|
||||||
|
/*** BEGIN section ***/
|
||||||
|
/*** END section ***/
|
||||||
|
.fi
|
||||||
|
.PP
|
||||||
|
where section may be file-header, file-production, file-tail,
|
||||||
|
enumeration-production, value-header, value-production, value-tail or
|
||||||
|
comment.
|
||||||
|
.TP
|
||||||
\fI-h, --help\fP
|
\fI-h, --help\fP
|
||||||
Print brief help and exit.
|
Print brief help and exit.
|
||||||
.TP
|
.TP
|
||||||
|
@@ -113,7 +113,7 @@ sub parse_entries {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sub version {
|
sub version {
|
||||||
print STDERR "glib-mkenums version glib-2.0\n"; # FIXME: autogen version?
|
print STDERR "glib-mkenums version glib-@GLIB_VERSION@\n";
|
||||||
print STDERR "glib-mkenums comes with ABSOLUTELY NO WARRANTY.\n";
|
print STDERR "glib-mkenums comes with ABSOLUTELY NO WARRANTY.\n";
|
||||||
print STDERR "You may redistribute copies of glib-mkenums under the terms of\n";
|
print STDERR "You may redistribute copies of glib-mkenums under the terms of\n";
|
||||||
print STDERR "the GNU General Public License which can be found in the\n";
|
print STDERR "the GNU General Public License which can be found in the\n";
|
||||||
@@ -131,6 +131,7 @@ sub usage {
|
|||||||
print STDERR " --vprod <text> value text, produced for each enum value\n";
|
print STDERR " --vprod <text> value text, produced for each enum value\n";
|
||||||
print STDERR " --vtail <text> value tail, produced after iterating over enum values\n";
|
print STDERR " --vtail <text> value tail, produced after iterating over enum values\n";
|
||||||
print STDERR " --comments <text> comment structure\n";
|
print STDERR " --comments <text> comment structure\n";
|
||||||
|
print STDERR " --template file template file\n";
|
||||||
print STDERR " -h, --help show this help message\n";
|
print STDERR " -h, --help show this help message\n";
|
||||||
print STDERR " -v, --version print version informations\n";
|
print STDERR " -v, --version print version informations\n";
|
||||||
print STDERR "Production text substitutions:\n";
|
print STDERR "Production text substitutions:\n";
|
||||||
@@ -158,13 +159,58 @@ my $vtail = ""; # value tail, produced after iterating over enum values
|
|||||||
# other options
|
# other options
|
||||||
my $comment_tmpl = "/* \@comment\@ */";
|
my $comment_tmpl = "/* \@comment\@ */";
|
||||||
|
|
||||||
|
sub read_template_file {
|
||||||
|
my ($file) = @_;
|
||||||
|
my %tmpl = ('file-header', $fhead,
|
||||||
|
'file-production', $fprod,
|
||||||
|
'file-tail', $ftail,
|
||||||
|
'enumeration-production', $eprod,
|
||||||
|
'value-header', $vhead,
|
||||||
|
'value-production', $vprod,
|
||||||
|
'value-tail', $vtail,
|
||||||
|
'comment', $comment_tmpl);
|
||||||
|
my $in = 'junk';
|
||||||
|
open (FILE, $file) || die "Can't open $file: $!\n";
|
||||||
|
while (<FILE>) {
|
||||||
|
if (/^\/\*\*\*\s+(BEGIN|END)\s+([\w-]+)\s+\*\*\*\//) {
|
||||||
|
if (($in eq 'junk') && ($1 eq 'BEGIN') && (exists($tmpl{$2}))) {
|
||||||
|
$in = $2;
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
elsif (($in eq $2) && ($1 eq 'END') && (exists($tmpl{$2}))) {
|
||||||
|
$in = 'junk';
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
die "Malformed template file $file\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!($in eq 'junk')) {
|
||||||
|
$tmpl{$in} .= $_;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
close (FILE);
|
||||||
|
if (!($in eq 'junk')) {
|
||||||
|
die "Malformed template file $file\n";
|
||||||
|
}
|
||||||
|
$fhead = $tmpl{'file-header'};
|
||||||
|
$fprod = $tmpl{'file-production'};
|
||||||
|
$ftail = $tmpl{'file-tail'};
|
||||||
|
$eprod = $tmpl{'enumeration-production'};
|
||||||
|
$vhead = $tmpl{'value-header'};
|
||||||
|
$vprod = $tmpl{'value-production'};
|
||||||
|
$vtail = $tmpl{'value-tail'};
|
||||||
|
$comment_tmpl = $tmpl{'comment'};
|
||||||
|
}
|
||||||
|
|
||||||
if (!defined $ARGV[0]) {
|
if (!defined $ARGV[0]) {
|
||||||
usage;
|
usage;
|
||||||
}
|
}
|
||||||
while ($_ = $ARGV[0], /^-/) {
|
while ($_ = $ARGV[0], /^-/) {
|
||||||
shift;
|
shift;
|
||||||
last if /^--$/;
|
last if /^--$/;
|
||||||
if (/^--fhead$/) { $fhead = $fhead . shift }
|
if (/^--template$/) { read_template_file (shift); }
|
||||||
|
elsif (/^--fhead$/) { $fhead = $fhead . shift }
|
||||||
elsif (/^--fprod$/) { $fprod = $fprod . shift }
|
elsif (/^--fprod$/) { $fprod = $fprod . shift }
|
||||||
elsif (/^--ftail$/) { $ftail = $ftail . shift }
|
elsif (/^--ftail$/) { $ftail = $ftail . shift }
|
||||||
elsif (/^--eprod$/) { $eprod = $eprod . shift }
|
elsif (/^--eprod$/) { $eprod = $eprod . shift }
|
||||||
@@ -187,7 +233,7 @@ while ($_ = $ARGV[0], /^-/) {
|
|||||||
if (length($fhead)) {
|
if (length($fhead)) {
|
||||||
my $prod = $fhead;
|
my $prod = $fhead;
|
||||||
|
|
||||||
$prod =~ s/\@filename\@/$ARGV/g;
|
$prod =~ s/\@filename\@/$ARGV[0]/g;
|
||||||
$prod =~ s/\\a/\a/g; $prod =~ s/\\b/\b/g; $prod =~ s/\\t/\t/g; $prod =~ s/\\n/\n/g;
|
$prod =~ s/\\a/\a/g; $prod =~ s/\\b/\b/g; $prod =~ s/\\t/\t/g; $prod =~ s/\\n/\n/g;
|
||||||
$prod =~ s/\\f/\f/g; $prod =~ s/\\r/\r/g;
|
$prod =~ s/\\f/\f/g; $prod =~ s/\\r/\r/g;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user