File: Methods.pm

package info (click to toggle)
aspell 0.60.8.2-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 15,336 kB
  • sloc: cpp: 24,378; sh: 12,340; perl: 1,924; ansic: 1,661; makefile: 852; sed: 16
file content (58 lines) | stat: -rw-r--r-- 1,363 bytes parent folder | download | duplicates (13)
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;