while (stream_getline($src)) {
last if (/^\s*\}\s*;\s*/);
- if (/^\s*\.(push|kind|ctype|check)\s*=\s*(.*?)\s*;\s*$/) {
+ if (/^\s*\.(push|kind|ctype|dtor|ctor|check)\s*=\s*(.*?)\s*;\s*$/) {
$t{$1} = $2;
if ($1 eq "kind") {
if ($2 =~ /^'([bis])'$/) {
}
}
- for my $i ('kind', 'ctype') {
- fatal($src, "incomplete type $type: missing .$i") unless defined $t{$i};
+ for ('kind', 'ctype') {
+ fatal($src, "incomplete type $type: missing .$_") unless defined $t{$_};
+ }
+ if ($t{kind} eq 's') {
+ for ('dtor', 'ctor') {
+ fatal($src, "incomplete type $type: missing .$_") unless defined $t{$_};
+ }
}
unless (defined $t{check}) {
if ($t{kind} eq 'b') {
next if $t{const};
put_line($p, 0);
- print " $var = $p->{init};\n" if ($t{type}->{kind} eq 'b');
- print " $var = $p->{init};\n" if ($t{type}->{kind} eq 'i');
- print " m_strreplace(&$var, $p->{init});\n" if ($t{type}->{kind} eq 's');
+ if ($t{type}->{dtor}) {
+ my $dtor = $t{type}->{dtor};
+ $dtor =~ s/\$\$/\&$var/;
+ print " $dtor;\n";
+ }
+ print " $var = $p->{init};\n"
}
print "};\n";
};
foreach (@{$pkg->{props}}) {
my $p = $pkg->{members}{$_};
my %t = find_type($p, $p->{type});
- printf " $t{type}->{ctypefmt};\n", $p->{name};
+ if ($t{const}) {
+ printf " const $t{type}->{ctypefmt};\n", $p->{name};
+ } else {
+ printf " $t{type}->{ctypefmt};\n", $p->{name};
+ }
}
put_line($pkg, 0);
print <<EOF;
put_line($p, 0);
print " case LTK_$tok: \n";
- print " $var = $check" if ($t{type}->{kind} eq 'b');
- print " $var = $check" if ($t{type}->{kind} eq 'i');
- print " m_strreplace(&$var, $check)" if ($t{type}->{kind} eq 's');
-
- print ";\n return 1;\n";
+ if ($t{type}->{dtor}) {
+ my $dtor = $t{type}->{dtor};
+ $dtor =~ s/\$\$/\&$var/;
+ print " $dtor;\n";
+ }
+ if ($t{type}->{ctor}) {
+ my $ctor = $t{type}->{ctor};
+ $ctor =~ s/\$\$/$check/;
+ $check = $ctor;
+ }
+ print " $var = $check;\n";
+ print " return 1;\n";
}
print <<EOF;