Broadworks-OCIP
view release on metacpan or search on metacpan
utilities/schema_to_perl.pl view on Meta::CPAN
push( @{$input_parameter_names}, $ipname );
$return_param = sprintf( '%s => %s', $name, $ipname );
push( @{$param_pod}, sprintf( '=item B<%s%s> - I<%s>', $prefix, $name, $type ) );
}
##print " $return_param\n";
return $return_param;
}
# ----------------------------------------------------------------------
sub expand_parameters {
my $info = shift;
my @input_parameter_names;
my @output_parameter_map;
my @parameter_pod;
my $count = 0;
# deal with initial fixed parameters
foreach my $pname ( @{ $info->{fixed_parameters} } ) {
my $type = $info->{parameter_type}{$pname};
push( @output_parameter_map,
expand_one_parameter( $pname, $type, \$count, '', \@input_parameter_names, \@parameter_pod ) );
}
# deal with generic output parameters
if ( $info->{need_generic_params} ) {
push( @output_parameter_map, '@generic_params' );
}
# deal with trailing fixed parameters
foreach my $pname ( @{ $info->{end_fixed_parameters} } ) {
my $type = $info->{parameter_type}{$pname};
push( @output_parameter_map,
expand_one_parameter( $pname, $type, \$count, '', \@input_parameter_names, \@parameter_pod ) );
}
# deal with generic input parameters
if ( $info->{need_generic_params} ) {
push( @input_parameter_names, '@generic_params' );
}
$info->{input_parameter_names} = \@input_parameter_names;
$info->{output_parameter_map} = \@output_parameter_map;
$info->{parameter_pod} = \@parameter_pod;
$info->{parameter_count} = $count;
}
# ----------------------------------------------------------------------
sub generate_code_header {
my $fh = shift;
my $set_name = shift;
my $deprecated = shift;
$fh->printf( "package Broadworks::OCIP::%s;\n", $set_name );
$fh->print("\n");
$fh->printf( "# ABSTRACT: Broadworks OCI-P %s autogenerated from XML Schema\n", $set_name );
$fh->print("\n");
$fh->print("use strict;\n");
$fh->print("use warnings;\n");
$fh->print("use utf8;\n");
$fh->print("use namespace::autoclean;\n");
$fh->print("use Function::Parameters;\n");
if ($deprecated) {
$fh->print("use Moose::Role;\n");
}
else {
$fh->print("use Moose;\n");
}
##$fh->print("# This file will be too big for perl critic to work well\n");
##$fh->print("## no critic\n");
$fh->print("\n");
$fh->print("# VERSION\n");
$fh->print("# AUTHORITY\n");
$fh->print("\n");
$fh->print("# ----------------------------------------------------------------------\n");
$fh->print("\n");
}
# ----------------------------------------------------------------------
sub generate_code_trailer {
my $fh = shift;
my $set_name = shift;
my $deprecated = shift;
$fh->print("\n");
$fh->print("__PACKAGE__->meta->make_immutable;\n") unless ($deprecated);
$fh->print("1;\n");
}
# ----------------------------------------------------------------------
sub generate_pod_header {
my $fh = shift;
my $set_name = shift;
my $deprecated = shift;
$fh->printf( "# PODNAME: Broadworks::OCIP::OCIP::%s\n", $set_name );
$fh->printf( "# ABSTRACT: Broadworks OCI-P %s autogenerated from XML Schema\n", $set_name );
$fh->print("\n");
}
# ----------------------------------------------------------------------
sub generate_pod_trailer {
my $fh = shift;
my $set_name = shift;
my $deprecated = shift;
$fh->print("\n");
}
# ----------------------------------------------------------------------
sub get_class_name {
my $fn = shift;
my ( $volume, $directories, $file ) = File::Spec->splitpath($fn);
my $class = $file;
$class =~ s/\..*$//; # remove extension
$class =~ s/OCISchema//; # remove basename
return $class;
}
( run in 1.070 second using v1.01-cache-2.11-cpan-97f6503c9c8 )