Debian Codegraph @

perllib/Debian/PkgKde/SymbolsHelper/Subst.pm

raw
1 # Copyright (C) 2008-2010 Modestas Vainius <[email protected]>
2 #
3 # This program is free software: you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation, either version 3 of the License, or
6 # (at your option) any later version.
7 #
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
12 #
13 # You should have received a copy of the GNU General Public License
14 # along with this program. If not, see <http://www.gnu.org/licenses/>
15
16 package Debian::PkgKde::SymbolsHelper::Subst;
17
18 use strict;
19 use warnings;
20
21 sub new {
22 my ($class, %opts) = @_;
23 return bless { cache => {}, %opts }, $class;
24 }
25
26 sub get_name {
27 my $self = shift;
28 # Must be overriden
29 }
30
31 sub _expand {
32 my ($self, $arch, $val) = @_;
33 # Must be overriden
34 }
35
36 # $subst is here in order to support substs with values
37 sub expand {
38 my ($self, $arch, $val) = @_;
39 my $cache = ($val) ? "${arch}__$val" : $arch;
40 unless (exists $self->{cache}{$cache}) {
41 $self->{cache}{$cache} = $self->_expand($arch, $val);
42 }
43 return $self->{cache}{$cache};
44 }
45
46 # Prepare $rawname before detect()/neutralize()
47 # my ($self, $rawname, $arch) = @_;
48 sub prep {
49 }
50
51 # Make the raw symbol name architecture neutral
52 # my ($self, $rawname) = @_;
53 sub neutralize {
54 return undef;
55 }
56
57 # Hinted neutralize where $hint is an already "detected"
58 # SymbolsHelper::String
59 # my ($self, $rawname, $hint) = @_;
60 sub hinted_neutralize {
61 return undef;
62 }
63
64 # Detect if the substitution can be applied to a bunch of
65 # arch specific raw names.
66 # my ($self, $rawname, $arch, $arch_rawnames) = @_;
67 sub detect {
68 return 0;
69 }
70
71 # Verifies if the subst is correct at $pos
72 # my ($self, $pos, $arch_rawnames) = @_;
73 sub verify_at {
74 return undef;
75 }
76
77 1;