Slightly rework c_structdef_cg.pm's header-template processing code to be more similar to c_sqliteload_cg.pm's header-template processing code
git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5441 4a71c877-e1ca-e34f-864e-861f7616d084master
parent
df7b09c6fa
commit
052c32e8ec
|
@ -6,6 +6,10 @@ use strict;
|
||||||
|
|
||||||
# Code generator for C struct definitions
|
# Code generator for C struct definitions
|
||||||
|
|
||||||
|
my $filename = "";
|
||||||
|
my $outfile = "";
|
||||||
|
my $startTpl = "";
|
||||||
|
|
||||||
sub printStructFieldType
|
sub printStructFieldType
|
||||||
{
|
{
|
||||||
my ($output, $field) = @_;
|
my ($output, $field) = @_;
|
||||||
|
@ -205,8 +209,6 @@ sub printHdrGuard
|
||||||
$$output .= "__INCLUDED_DB_TEMPLATE_SCHEMA_STRUCTDEF_${name}_H__";
|
$$output .= "__INCLUDED_DB_TEMPLATE_SCHEMA_STRUCTDEF_${name}_H__";
|
||||||
}
|
}
|
||||||
|
|
||||||
my $startTpl = "";
|
|
||||||
|
|
||||||
sub processCmdLine()
|
sub processCmdLine()
|
||||||
{
|
{
|
||||||
my ($argv) = @_;
|
my ($argv) = @_;
|
||||||
|
@ -218,6 +220,12 @@ sub startFile()
|
||||||
{
|
{
|
||||||
my ($output, $name) = @_;
|
my ($output, $name) = @_;
|
||||||
|
|
||||||
|
$filename = $name;
|
||||||
|
$outfile = $name;
|
||||||
|
|
||||||
|
# Replace the extension with ".h" so that we can use it to #include the header
|
||||||
|
$outfile =~ s/\.[^.]*$/.h/;
|
||||||
|
|
||||||
$$output .= "/* This file is generated automatically, do not edit, change the source ($name) instead. */\n\n";
|
$$output .= "/* This file is generated automatically, do not edit, change the source ($name) instead. */\n\n";
|
||||||
|
|
||||||
$$output .= "#ifndef ";
|
$$output .= "#ifndef ";
|
||||||
|
@ -228,25 +236,20 @@ sub startFile()
|
||||||
printHdrGuard($output, $name);
|
printHdrGuard($output, $name);
|
||||||
$$output .= "\n\n";
|
$$output .= "\n\n";
|
||||||
|
|
||||||
# Replace the extension with ".h" so that we can use it to #include the header
|
|
||||||
my $header = $name;
|
|
||||||
$header =~ s/\.[^.]*$/.h/;
|
|
||||||
|
|
||||||
$$output .= "#line 1 \"$startTpl\"\n";
|
$$output .= "#line 1 \"$startTpl\"\n";
|
||||||
open (TEMPL, $startTpl);
|
open (TEMPL, $startTpl);
|
||||||
while (<TEMPL>)
|
while (<TEMPL>)
|
||||||
{
|
{
|
||||||
s/\$name\b/$name/g;
|
s/\$name\b/$name/g;
|
||||||
s/\$header\b/$header/g;
|
s/\$header\b/$outfile/g;
|
||||||
$$output .= $_;
|
$$output .= $_;
|
||||||
}
|
}
|
||||||
close (TEMPL);
|
close (TEMPL);
|
||||||
|
|
||||||
my $count = $$output =~ s/\n/\n/sg;
|
my $count = $$output =~ s/\n/\n/sg;
|
||||||
$count += 2;
|
$count += 2;
|
||||||
$$output .= "#line $count \"$header\"\n";
|
$$output .= "#line $count \"$outfile\"\n"
|
||||||
|
. "\n";
|
||||||
$$output .= "\n";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub endFile()
|
sub endFile()
|
||||||
|
|
Loading…
Reference in New Issue