aboutsummaryrefslogtreecommitdiff
path: root/tools/cfsml.pl
diff options
context:
space:
mode:
authorWillem Jan Palenstijn2009-02-28 10:05:07 +0000
committerWillem Jan Palenstijn2009-02-28 10:05:07 +0000
commit4febcde1706d20c445b226855b373b004380950d (patch)
treea4cf73e7bb586bf32395dd215b8275bb6ac3d2f0 /tools/cfsml.pl
parentc76dc0b71c0d448a63a1a3eef989b4f4521a5998 (diff)
downloadscummvm-rg350-4febcde1706d20c445b226855b373b004380950d.tar.gz
scummvm-rg350-4febcde1706d20c445b226855b373b004380950d.tar.bz2
scummvm-rg350-4febcde1706d20c445b226855b373b004380950d.zip
Make CFSML writers take const arguments
svn-id: r38952
Diffstat (limited to 'tools/cfsml.pl')
-rw-r--r--tools/cfsml.pl16
1 files changed, 13 insertions, 3 deletions
diff --git a/tools/cfsml.pl b/tools/cfsml.pl
index 13c54508ca..0f014f3dcf 100644
--- a/tools/cfsml.pl
+++ b/tools/cfsml.pl
@@ -375,12 +375,13 @@ sub create_declaration
{
$typename = $type;
$ctype = $types{$type}->{'ctype'};
+ $constpctype = $types{$type}->{'constpctype'};
if (not $types{$type}->{'external'}) {
$types{$type}{'writer'} = "_cfsml_write_" . $typename;
$types{$type}{'reader'} = "_cfsml_read_" . $typename;
write_line_pp(__LINE__, 0);
- print "static void $types{$type}{'writer'}(Common::WriteStream *fh, $ctype* save_struc);\n";
+ print "static void $types{$type}{'writer'}(Common::WriteStream *fh, $constpctype save_struc);\n";
print "static int $types{$type}{'reader'}(Common::SeekableReadStream *fh, $ctype* save_struc, const char *lastval, int *line, int *hiteof);\n\n";
};
@@ -390,9 +391,10 @@ sub create_writer
{
$typename = $type;
$ctype = $types{$type}{'ctype'};
+ $constpctype = $types{$type}->{'constpctype'};
write_line_pp(__LINE__, 0);
- print "static void\n_cfsml_write_$typename(Common::WriteStream *fh, $ctype* save_struc)\n{\n";
+ print "static void\n_cfsml_write_$typename(Common::WriteStream *fh, $constpctype save_struc)\n{\n";
if ($types{$type}{'type'} eq $type_integer) {
print " WSprintf(fh, \"%li\", (long)*save_struc);\n";
@@ -460,7 +462,7 @@ sub create_writer
} else { # Normal record entry
print " $types{$n->{'type'}}{'writer'}";
- print "(fh, ($types{$n->{'type'}}{'ctype'}*) &(save_struc->$n->{'name'}));\n";
+ print "(fh, ($types{$n->{'type'}}{'constpctype'}) &(save_struc->$n->{'name'}));\n";
}
@@ -720,11 +722,13 @@ sub create_reader
'int' => {
'type' => $type_integer,
'ctype' => "int",
+ 'constpctype' => "int const *",
},
'string' => {
'type' => $type_string,
'ctype' => "char *",
+ 'constpctype' => "const char * const *",
},
);
@@ -995,6 +999,11 @@ while (<STDIN>) {
my $newtype = $tokens[1];
$types{$newtype}->{'ctype'} = $tokens[2];
+ if ($tokens[2] =~ /\*\$/) {
+ $types{$newtype}->{'ctype'} = "const " . $tokens[2] . " const *";
+ } else {
+ $types{$newtype}->{'constpctype'} = $tokens[2] . " const *";
+ }
if ($tokens_nr == 5) { # must be ...LIKE...
@@ -1043,6 +1052,7 @@ while (<STDIN>) {
} elsif ($tokens_nr == 3) {
$types{$struct}{'ctype'} = $struct;
}
+ $types{$struct}{'constpctype'} = $struct . " const *";
if (($tokens_nr > $extoffset + 1) && ($extoffset + 1 <= $tokens_nr)) {
if ($tokens[$extoffset] ne "EXTENDS") {