1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
|
# This file is part of The New Aspell
# Copyright (C) 2001-2002 by Kevin Atkinson under the GNU LGPL
# license version 2.0 or 2.1. You should have received a copy of the
# LGPL license along with this library if you did not you can find it
# at http://www.gnu.org/.
package MkSrc::Methods;
BEGIN {
use Exporter;
our @ISA = qw(Exporter);
our @EXPORT = qw(copy_methods);
}
use strict;
use warnings;
no warnings qw(uninitialized);
no locale;
use MkSrc::Info;
sub copy_n_sub ( $ $ );
sub copy_methods ( $ $ $ ) {
my ($d, $data, $class_name) = @_;
my $ms = $methods{$d->{type}};
if (not defined $d->{name}) {
$d->{name} = $class_name;
$d->{name} =~ s/ [^ ]+$// if $ms->{strip} == 1;
}
my @lst;
if (defined $ms->{'c impl headers'}) {
$data->{'c impl headers'} .= ",$ms->{'c impl headers'}";
}
foreach my $m (@{$ms->{data}}) {
push @lst, copy_n_sub($m, $d->{name});
$lst[-1]{prefix} = $m->{prefix} if exists $d->{prefix};
}
return @lst
}
sub copy_n_sub ( $ $ ) {
my ($d, $name) = @_;
my $new_d = {};
foreach my $k (keys %$d) {
if ($k eq 'data') {
$new_d->{data} = [];
foreach my $d0 (@{$d->{data}}) {
push @{$new_d->{data}}, copy_n_sub($d0, $name);
}
} else {
$new_d->{$k} = $d->{$k};
$new_d->{$k} =~ s/\$/$name/g unless ref $new_d->{$k};
}
}
return $new_d;
}
1;
|