Debian Codegraph @

tools/japicc/modules/Internals/TypeAttr.pm

raw
1 ###########################################################################
2 # A module to handle type attributes
3 #
4 # Copyright (C) 2016-2018 Andrey Ponomarenko's ABI Laboratory
5 #
6 # Written by Andrey Ponomarenko
7 #
8 # This library is free software; you can redistribute it and/or
9 # modify it under the terms of the GNU Lesser General Public
10 # License as published by the Free Software Foundation; either
11 # version 2.1 of the License, or (at your option) any later version.
12 #
13 # This library is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 # Lesser General Public License for more details.
17 #
18 # You should have received a copy of the GNU Lesser General Public
19 # License along with this library; if not, write to the Free Software
20 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
21 # MA 02110-1301 USA.
22 ###########################################################################
23 use strict;
24
25 my %Cache;
26
27 #Aliases
28 my %TypeInfo = ();
29
30 sub initAliases_TypeAttr($)
31 {
32 my $LVer = $_[0];
33
34 $TypeInfo{$LVer} = $In::API{$LVer}{"TypeInfo"};
35 }
36
37 sub getTypeName($$)
38 {
39 my ($TypeId, $LVer) = @_;
40 return $TypeInfo{$LVer}{$TypeId}{"Name"};
41 }
42
43 sub getShortName($$)
44 {
45 my ($TypeId, $LVer) = @_;
46 my $TypeName = $TypeInfo{$LVer}{$TypeId}{"Name"};
47 $TypeName=~s/\A.*\.//g;
48 return $TypeName;
49 }
50
51 sub getTypeType($$)
52 {
53 my ($TypeId, $LVer) = @_;
54 return $TypeInfo{$LVer}{$TypeId}{"Type"};
55 }
56
57 sub getBaseType($$)
58 {
59 my ($TypeId, $LVer) = @_;
60
61 if(defined $Cache{"getBaseType"}{$TypeId}{$LVer}) {
62 return $Cache{"getBaseType"}{$TypeId}{$LVer};
63 }
64 if(not $TypeInfo{$LVer}{$TypeId}) {
65 return {};
66 }
67 my $Type = $TypeInfo{$LVer}{$TypeId};
68 if(not $Type->{"BaseType"}) {
69 return $Type;
70 }
71 $Type = getBaseType($Type->{"BaseType"}, $LVer);
72 return ($Cache{"getBaseType"}{$TypeId}{$LVer} = $Type);
73 }
74
75 sub getOneStepBaseType($$)
76 {
77 my ($TypeId, $LVer) = @_;
78
79 if(not $TypeInfo{$LVer}{$TypeId}) {
80 return {};
81 }
82
83 my $Type = $TypeInfo{$LVer}{$TypeId};
84 if(not $Type->{"BaseType"}) {
85 return $Type;
86 }
87 return getType($Type->{"BaseType"}, $LVer);
88 }
89
90 sub getType($$)
91 {
92 my ($TypeId, $LVer) = @_;
93 if(not $TypeId or not $TypeInfo{$LVer}{$TypeId}) {
94 return {};
95 }
96 return $TypeInfo{$LVer}{$TypeId};
97 }
98
99 sub getGeneric($)
100 {
101 my $Name = $_[0];
102 $Name=~s/<.*>//g;
103 return $Name;
104 }
105
106 return 1;