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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
{
Copyright (c) 2013-2016 by Free Pascal Development Team
This unit implements basic parts of the package system
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
****************************************************************************
}
unit fpkg;
{$i fpcdefs.inc}
interface
uses
cclasses,
globtype,
finput;
type
tcontainedunit=record
module:tmodulebase;
ppufile:tpathstr;
offset:longint;
size:longint;
end;
pcontainedunit=^tcontainedunit;
tpackage=class
public
realpackagename,
packagename : pshortstring;
containedmodules : TFPHashList;
requiredpackages : TFPHashObjectList;
pcpfilename,
ppafilename,
pplfilename : tpathstr;
constructor create(const pn:string);
destructor destroy;override;
end;
tpackageentry=record
package : tpackage;
realpkgname : string;
usedunits : longint;
direct : boolean;
end;
ppackageentry=^tpackageentry;
implementation
uses
cutils,globals;
{ tpackage }
constructor tpackage.create(const pn: string);
begin
realpackagename:=stringdup(pn);
packagename:=stringdup(upper(pn));
containedmodules:=TFPHashList.Create;
requiredpackages:=TFPHashObjectList.Create(false);
end;
destructor tpackage.destroy;
var
p : pcontainedunit;
i : longint;
begin
if assigned(containedmodules) then
for i:=0 to containedmodules.count-1 do
begin
p:=pcontainedunit(containedmodules[i]);
dispose(p);
end;
containedmodules.free;
requiredpackages.free;
inherited destroy;
end;
procedure packageinit;
begin
packagelist:=TFPHashList.Create;
end;
procedure packagedone;
var
i : longint;
pkgentry : ppackageentry;
begin
if assigned(packagelist) then
begin
for i:=0 to packagelist.count-1 do
begin
pkgentry:=ppackageentry(packagelist[i]);
pkgentry^.package.free;
dispose(pkgentry);
end;
end;
packagelist.Free;
packagelist:=nil;
end;
initialization
register_initdone_proc(@packageinit,@packagedone);
end.
|