56 |
sub code ($$) { |
sub code ($$) { |
57 |
my ($Info, $code) = @_; |
my ($Info, $code) = @_; |
58 |
for (keys %{$Info->{const}}) { |
for (keys %{$Info->{const}}) { |
59 |
$code =~ s/\$$_\b/literal $Info->{const}->{$_}/ge; |
$code =~ s/\$$_\b/$Info->{const}->{$_}/ge; |
60 |
} |
} |
61 |
$code =~ s/__FUNCPACK__/$Info->{module_name}/g; |
$code =~ s/__FUNCPACK__/$Info->{module_name}/g; |
62 |
$code; |
$code; |
227 |
my $flag = '//'; |
my $flag = '//'; |
228 |
$flag .= 'f' if $opt{IsFragment}; |
$flag .= 'f' if $opt{IsFragment}; |
229 |
$flag .= 'p' if $opt{IsPlaceholder}; |
$flag .= 'p' if $opt{IsPlaceholder}; |
230 |
if ($Converter->{$opt{Type}.$flag}) { |
my $type = $opt{Type} ? |
231 |
$converter = $Converter->{$opt{Type}.$flag}; |
$opt{Type} . |
232 |
|
SuikaWiki::Format::Definition->__get_param_string |
233 |
|
($opt{Type_param}) : undef; |
234 |
|
if ($Converter->{$type.$flag}) { |
235 |
|
$converter = $Converter->{$type.$flag}; |
236 |
} elsif ($Converter->{$opt{Name}.'/'.$opt{Version}.$flag}) { |
} elsif ($Converter->{$opt{Name}.'/'.$opt{Version}.$flag}) { |
237 |
$converter = $Converter->{'/'.$opt{Name}.'/'.$opt{Version}.$flag}; |
$converter = $Converter->{'/'.$opt{Name}.'/'.$opt{Version}.$flag}; |
238 |
} |
} |
255 |
$r .= code $Info, $_->get_attribute_value ('Main'); |
$r .= code $Info, $_->get_attribute_value ('Main'); |
256 |
$r .= line $Info, reset => 1; |
$r .= line $Info, reset => 1; |
257 |
$r .= qq(}\n); |
$r .= qq(}\n); |
258 |
|
} elsif ($_->local_name eq 'HeadSummary') { |
259 |
|
$r .= q(sub headsummary {)."\n".q(my ($self, $source, %opt) = @_;); |
260 |
|
$r .= line $Info, node_path => qq(Format[module-name()=$module_name]/HeadSummary); |
261 |
|
$r .= code $Info, $_->get_attribute_value ('Main'); |
262 |
|
$r .= line $Info, reset => 1; |
263 |
|
$r .= qq(}\n); |
264 |
} elsif ($_->local_name eq 'NextIndex') { |
} elsif ($_->local_name eq 'NextIndex') { |
265 |
my $name = $_->get_attribute_value ('Name', default => ''); |
my $name = $_->get_attribute_value ('Name', default => ''); |
266 |
$r .= q(sub next_index_for_).$name |
$r .= q(sub next_index_for_).$name |
345 |
sub register_plugin_const ($$) { |
sub register_plugin_const ($$) { |
346 |
my ($src, $Info) = @_; |
my ($src, $Info) = @_; |
347 |
for (@{$src->child_nodes}) { |
for (@{$src->child_nodes}) { |
348 |
$Info->{const}->{$_->local_name} = $_->value; |
$Info->{const}->{$_->local_name} = literal_or_code $Info, $_->value; |
349 |
} |
} |
350 |
} |
} |
351 |
|
|
415 |
@{[change_package $Info, $ViewProp->{pack_name}]} |
@{[change_package $Info, $ViewProp->{pack_name}]} |
416 |
our \@ISA = q#SuikaWiki::View::template#; |
our \@ISA = q#SuikaWiki::View::template#; |
417 |
EOH |
EOH |
418 |
|
|
419 |
|
my $use = $src->get_attribute ('Use'); |
420 |
|
if (ref $use) { |
421 |
|
$r .= line $Info, node_path => "ViewDefinition[Mode='$ViewProp->{Name}']/Use"; |
422 |
|
$r .= $use->inner_text . "\n\n"; |
423 |
|
} |
424 |
|
|
425 |
for (@{$src->child_nodes}) { |
for (@{$src->child_nodes}) { |
426 |
if ($_->local_name eq 'template') { |
if ($_->local_name eq 'template') { |
427 |
$r .= make_view_template_method ($_, $Info, $ViewProp); |
$r .= make_view_template_method ($_, $Info, $ViewProp); |
538 |
"FormattingRule[name()='@{[list $type]}/$name']/".$codename->[0]) |
"FormattingRule[name()='@{[list $type]}/$name']/".$codename->[0]) |
539 |
. $main; |
. $main; |
540 |
|
|
541 |
$main = q{my ($f, $rule_name, $p, $o, %opt) = @_;}."\n".$main |
if ( $main =~ /\$f\b/ |
|
if $main =~ /\$f\b/ |
|
542 |
or $main =~ /\$rule_name\b/ |
or $main =~ /\$rule_name\b/ |
543 |
or $main =~ /\$[opr]\b/ |
or $main =~ /\$[opr]\b/ |
544 |
or $main =~ /[%\$]opt\b/; |
or $main =~ /[%\$]opt\b/ |
545 |
|
or $main =~ /\$param_(?:name|value)\n/) { |
546 |
|
if ($codename->[0] ne 'Attribute') { |
547 |
|
$main = q{my ($f, $rule_name, $p, $o, %opt) = @_;}."\n".$main; |
548 |
|
} else { |
549 |
|
$main = q{my ($f, $rule_name, $p, $o, $param_name => $param_value, %opt) = @_;}."\n".$main; |
550 |
|
} |
551 |
|
} |
552 |
if ($main =~ /\$r\b/) { |
if ($main =~ /\$r\b/) { |
553 |
warn qq(Rule @{[list $type]}/$name: Use of \$r is deprecated); |
warn qq(Rule @{[list $type]}/$name: Use of \$r is deprecated); |
554 |
$main = q{my $r = '';} . "\n" . $main . "\n" |
$main = q{my $r = '';} . "\n" . $main . "\n" |