* Add line numbers to the AST for %loadFunc directives
* Utilize these line numbers to generate #line directives in the output file git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5438 4a71c877-e1ca-e34f-864e-861f7616d084master
parent
1ceafee327
commit
3b57831282
|
@ -7,6 +7,9 @@ use strict;
|
|||
# Code generator for C code to load contents of the SQL tables from an SQLite
|
||||
# database into the C struct definitions.
|
||||
|
||||
my $filename = "";
|
||||
my $outfile = "";
|
||||
|
||||
sub printComments
|
||||
{
|
||||
my ($output, $comments, $indent) = @_;
|
||||
|
@ -67,7 +70,12 @@ sub printFuncHeader
|
|||
. " * \@return true if we succesfully loaded all available rows from the table,\n"
|
||||
. " * false otherwise.\n"
|
||||
. " */\n"
|
||||
. "bool ${${$struct}{\"qualifiers\"}}{\"loadFunc\"}(sqlite3* db)";
|
||||
. "#line ${${${$struct}{\"qualifiers\"}}{\"loadFunc\"}}{\"line\"} \"$filename\"\n"
|
||||
. "bool ${${${$struct}{\"qualifiers\"}}{\"loadFunc\"}}{\"name\"}(sqlite3* db)\n";
|
||||
|
||||
my $line = $$output =~ s/\n/\n/sg;
|
||||
$line += 2;
|
||||
$$output .= "#line $line \"$outfile\"\n";
|
||||
}
|
||||
|
||||
sub printFuncFooter
|
||||
|
@ -537,7 +545,7 @@ sub printLoadFunc
|
|||
# Open the function
|
||||
$$output .= "\n";
|
||||
printFuncHeader($output, $struct, $structName);
|
||||
$$output .= "\n{\n";
|
||||
$$output .= "{\n";
|
||||
|
||||
printSqlQueryVariables($output, $struct, $structMap, $enumMap);
|
||||
|
||||
|
@ -607,6 +615,10 @@ sub startFile()
|
|||
|
||||
$$output .= "/* This file is generated automatically, do not edit, change the source ($name) instead. */\n\n";
|
||||
|
||||
$filename = $name;
|
||||
$outfile = $name;
|
||||
$outfile =~ s/\.[^.]*$/.c/;
|
||||
|
||||
return unless $startTpl;
|
||||
|
||||
# Replace the extension with ".h" so that we can use it to #include the header
|
||||
|
|
|
@ -110,7 +110,9 @@ sub parseStruct
|
|||
}
|
||||
elsif (/^loadFunc\s+\"([^\"]+)\"$/)
|
||||
{
|
||||
${$curStruct{"qualifiers"}}{"loadFunc"} = $1;
|
||||
my %loadFunc = (name=>$1, line=>$$count);
|
||||
|
||||
${$curStruct{"qualifiers"}}{"loadFunc"} = \%loadFunc;
|
||||
}
|
||||
elsif (/^abstract$/)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue