… | |
… | |
99 | |
99 | |
100 | if ($arch->{type} =~ s/^(bitmask)_(.*)/$1/) { |
100 | if ($arch->{type} =~ s/^(bitmask)_(.*)/$1/) { |
101 | $arch->{value} = $bitmask{$2} ||= {}; |
101 | $arch->{value} = $bitmask{$2} ||= {}; |
102 | } elsif ($arch->{type} =~ s/^(list)_(.*)/$1/) { |
102 | } elsif ($arch->{type} =~ s/^(list)_(.*)/$1/) { |
103 | $arch->{value} = $list{$2} ||= {}; |
103 | $arch->{value} = $list{$2} ||= {}; |
|
|
104 | } elsif ($arch->{type} eq "fixed") { |
|
|
105 | $arch->{value} = $e->attr ("value"); |
104 | } elsif ($arch->{type} =~ s/^bool_special$/bool/) { |
106 | } elsif ($arch->{type} =~ s/^bool_special$/bool/) { |
105 | $arch->{value} = [$e->attr ("false"), $e->attr ("true")]; |
107 | $arch->{value} = [$e->attr ("false"), $e->attr ("true")]; |
106 | } |
108 | } |
107 | |
109 | |
108 | $sect->{$e->attr ("arch") || $e->attr("arch_begin")} = $arch; |
110 | push @$sect, [$e->attr ("arch") || $e->attr("arch_begin"), $arch]; |
109 | } |
111 | } |
110 | |
112 | |
111 | sub parse_type { |
113 | sub parse_type { |
112 | my ($e, $type) = @_; |
114 | my ($e, $type) = @_; |
113 | |
115 | |
114 | my %main; |
116 | my %main; |
115 | |
117 | |
116 | for my $e (grep ref, @{$e->contents}) { |
118 | for my $e (grep ref, @{$e->contents}) { |
117 | if ($e->name eq "required") { |
119 | if ($e->name eq "required") { |
|
|
120 | # not used |
118 | for my $i (grep ref, @{$e->contents}) { |
121 | #for my $i (grep ref, @{$e->contents}) { |
119 | $type->{required}{$i->attr ("arch")} = $i->attr ("value"); |
122 | # $type->{required}{$i->attr ("arch")} = $i->attr ("value"); |
120 | } |
123 | #} |
121 | } elsif ($e->name eq "attribute") { |
124 | } elsif ($e->name eq "attribute") { |
122 | parse_attr $e, $type->{attr} ||= {}; |
125 | parse_attr $e, $type->{attr} ||= []; |
123 | } elsif ($e->name eq "ignore") { |
126 | } elsif ($e->name eq "ignore") { |
124 | for my $i (grep ref, @{$e->contents}) { |
127 | for my $i (grep ref, @{$e->contents}) { |
125 | if ($i->name eq "ignore_list") { |
128 | if ($i->name eq "ignore_list") { |
126 | push @{$type->{ignore}}, $ignore_list{$i->attr ("name")} ||= []; |
129 | push @{$type->{ignore}}, $ignore_list{$i->attr ("name")} ||= []; |
127 | } elsif ($i->name eq "attribute") { |
130 | } elsif ($i->name eq "attribute") { |
128 | push @{$type->{ignore}}, $i->attr ("arch"); |
131 | push @{$type->{ignore}}, $i->attr ("arch"); |
129 | } |
132 | } |
130 | } |
133 | } |
131 | } elsif ($e->name eq "import_type") { |
134 | } elsif ($e->name eq "import_type") { |
132 | push @{$type->{import}}, $type{$e->attr ("name")} ||= {}; |
135 | #push @{$type->{import}}, $type{$e->attr ("name")} ||= {}; |
|
|
136 | push @{$type->{import}}, $e->attr ("name"); |
133 | } elsif ($e->name eq "use") { |
137 | } elsif ($e->name eq "use") { |
134 | $type->{use} = string $e; |
138 | $type->{use} = string $e; |
135 | } elsif ($e->name eq "description") { |
139 | } elsif ($e->name eq "description") { |
136 | $type->{desc} = string $e; |
140 | $type->{desc} = string $e; |
137 | } elsif ($e->name eq "section") { |
141 | } elsif ($e->name eq "section") { |
138 | my %attr; |
142 | my @attr; |
139 | for my $i (grep ref, @{$e->contents}) { |
143 | for my $i (grep ref, @{$e->contents}) { |
140 | parse_attr $i, \%attr; |
144 | parse_attr $i, \@attr; |
141 | } |
145 | } |
142 | push @{ $type->{section} }, [$e->attr ("name") => \%attr]; |
146 | push @{ $type->{section} }, [$e->attr ("name") => \@attr]; |
143 | } else { |
147 | } else { |
144 | warn "unknown types subelement ", $e->name; |
148 | warn "unknown types subelement ", $e->name; |
145 | } |
149 | } |
146 | } |
150 | } |
147 | |
151 | |
… | |
… | |
170 | my $type = $type{$e->attr ("name")} ||= {}; |
174 | my $type = $type{$e->attr ("name")} ||= {}; |
171 | |
175 | |
172 | $type->{name} = $e->attr ("name"); |
176 | $type->{name} = $e->attr ("name"); |
173 | |
177 | |
174 | parse_type $e, $type; |
178 | parse_type $e, $type; |
175 | #unshift @{$type->{import}}, \%default_attr; |
|
|
176 | |
179 | |
177 | if ($e->attr ("number") > 0) { |
180 | if ($e->attr ("number") > 0) { |
178 | $attr{$e->attr ("number")} = $type; |
181 | $attr{$e->attr ("number")} = $type; |
179 | } elsif ($e->attr ("name") eq "Misc") { |
182 | } elsif ($e->attr ("name") eq "Misc") { |
180 | delete $type->{required}; |
183 | delete $type->{required}; |
… | |
… | |
198 | |
201 | |
199 | for (grep ref, @{$spell->root->contents}) { |
202 | for (grep ref, @{$spell->root->contents}) { |
200 | $spell{$_->attr ("id")} = $_->attr ("name"); |
203 | $spell{$_->attr ("id")} = $_->attr ("name"); |
201 | } |
204 | } |
202 | |
205 | |
203 | dump_hash ["BITMASK", "LIST", "IGNORE_LIST", "DEFAULT_ATTR", "TYPE", "ATTR0", "ATTR", "TYPENAME", "SPELL"], |
206 | dump_hash ["BITMASK", "LIST", "IGNORE_LIST", "DEFAULT_ATTR", "TYPE", "ATTR", "TYPENAME", "SPELL"], |
204 | [\%bitmask, \%list, \%ignore_list, \%default_attr, \%type, \@attr0, \%attr, \%typename, \%spell]; |
207 | [\%bitmask, \%list, \%ignore_list, \%default_attr, \%type, \%attr, \%typename, \%spell]; |
205 | |
208 | |
206 | print <<EOF; |
209 | print <<EOF; |
207 | |
210 | |
208 | =head1 AUTHOR |
211 | =head1 AUTHOR |
209 | |
212 | |