Skip to content

Commit

Permalink
Initialize all bitfields to zero in generated constructors
Browse files Browse the repository at this point in the history
This currently requires bitfields to be defined with the <bitfield> tag -
currently, all bitfield fields with a type-name use <compound> instead.

DFHack/dfhack#1047 (partial fix)
DFHack/dfhack#1038
DFHack#169
DFHack#171
  • Loading branch information
lethosor committed Dec 18, 2016
1 parent d08339d commit 8a3a366
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions StructFields.pm
Original file line number Diff line number Diff line change
Expand Up @@ -348,8 +348,8 @@ sub render_field_init($) {
} elsif ($meta eq 'global' || $meta eq 'compound') {
return unless $subtype;

if ($subtype eq 'bitfield' && defined $cur_init_value) {
emit $cur_init_field, '.whole = ', $cur_init_value, ';';
if ($subtype eq 'bitfield') {
emit $cur_init_field, '.whole = ', ($cur_init_value || 0), ';';
} elsif ($subtype eq 'enum') {
if ($meta eq 'global') {
my $tname = $field->getAttribute('type-name');
Expand Down

0 comments on commit 8a3a366

Please sign in to comment.