* Support for generics

git-svn-id: trunk@19622 -
This commit is contained in:
michael 2011-11-11 15:08:42 +00:00
parent 5ea8e65ea2
commit 91a2b7ae18
5 changed files with 52 additions and 20 deletions

View File

@ -2828,6 +2828,22 @@ var
AppendText(ParaEl, '] ');
end;
procedure AppendGenericTypes(CodeEl : TDomElement; AList : TList; isSpecialize : Boolean);
Var
I : integer;
begin
for I:=0 to AList.Count-1 do
begin
if I=0 then
AppendSym(CodeEl, '<')
else
AppendSym(CodeEl, ',');
AppendText(CodeEl,TPasGenericTemplateType(AList[i]).Name);
end;
AppendSym(CodeEl, '>');
end;
procedure CreateMainPage;
var
TableEl, TREl, TDEl, CodeEl: TDOMElement;
@ -2858,24 +2874,39 @@ var
TDEl := CreateTD(TREl);
CodeEl := CreateCode(CreatePara(TDEl));
AppendKw(CodeEl, 'type');
if AClass.ObjKind=okGeneric then
AppendKw(CodeEl, ' generic ');
AppendText(CodeEl, ' ' + AClass.Name + ' ');
if AClass.ObjKind=okGeneric then
AppendGenericTypes(CodeEl,AClass.GenericTemplateTypes,false);
AppendSym(CodeEl, '=');
AppendText(CodeEl, ' ');
AppendKw(CodeEl, ObjKindNames[AClass.ObjKind]);
if AClass.ObjKind<>okSpecialize then
AppendKw(CodeEl, ObjKindNames[AClass.ObjKind])
else
AppendKw(CodeEl, ' specialize ');
if Assigned(AClass.AncestorType) then
begin
AppendSym(CodeEl, '(');
AppendHyperlink(CodeEl, AClass.AncestorType);
if AClass.Interfaces.count>0 Then
if AClass.ObjKind=okSpecialize then
begin
for i:=0 to AClass.interfaces.count-1 do
begin
AppendSym(CodeEl, ', ');
AppendHyperlink(CodeEl,TPasClassType(AClass.Interfaces[i]));
end;
AppendHyperlink(CodeEl, AClass.AncestorType);
AppendGenericTypes(CodeEl,AClass.GenericTemplateTypes,true)
end
else
begin
AppendSym(CodeEl, '(');
AppendHyperlink(CodeEl, AClass.AncestorType);
if AClass.Interfaces.count>0 Then
begin
for i:=0 to AClass.interfaces.count-1 do
begin
AppendSym(CodeEl, ', ');
AppendHyperlink(CodeEl,TPasClassType(AClass.Interfaces[i]));
end;
end;
AppendSym(CodeEl, ')');
end;
AppendSym(CodeEl, ')');
end;
if AClass.Members.Count > 0 then
@ -2965,7 +2996,8 @@ var
end;
AppendText(CodeEl, ' '); // !!!: Dirty trick, necessary for current XML writer
AppendKw(CodeEl, 'end');
if not AClass.IsShortDefinition then
AppendKw(CodeEl, 'end');
AppendSym(CodeEl, ';');

View File

@ -35,7 +35,7 @@ resourcestring
Const
RootNames : Array[TPasObjKind] of string
= ('Objects', 'Classes', 'Interfaces');
= ('Objects', 'Classes', 'Interfaces','Generics','Specializations');
type

View File

@ -13,7 +13,6 @@
<Title Value="FPDoc Documentation generator"/>
<ResourceType Value="res"/>
<UseXPManifest Value="True"/>
<Icon Value="0"/>
</General>
<i18n>
<EnableI18N LFM="False"/>
@ -60,7 +59,7 @@
<Unit3>
<Filename Value="dw_html.pp"/>
<IsPartOfProject Value="True"/>
<UnitName Value="dw_html"/>
<UnitName Value="dw_HTML"/>
</Unit3>
<Unit4>
<Filename Value="dw_ipflin.pas"/>
@ -70,7 +69,7 @@
<Unit5>
<Filename Value="dw_latex.pp"/>
<IsPartOfProject Value="True"/>
<UnitName Value="dw_latex"/>
<UnitName Value="dw_LaTeX"/>
</Unit5>
<Unit6>
<Filename Value="dwlinear.pp"/>
@ -80,7 +79,7 @@
<Unit7>
<Filename Value="dw_linrtf.pp"/>
<IsPartOfProject Value="True"/>
<UnitName Value="dw_linrtf"/>
<UnitName Value="dw_LinRTF"/>
</Unit7>
<Unit8>
<Filename Value="dw_man.pp"/>
@ -90,7 +89,7 @@
<Unit9>
<Filename Value="dwriter.pp"/>
<IsPartOfProject Value="True"/>
<UnitName Value="dwriter"/>
<UnitName Value="dWriter"/>
</Unit9>
<Unit10>
<Filename Value="dw_txt.pp"/>
@ -100,7 +99,7 @@
<Unit11>
<Filename Value="dw_xml.pp"/>
<IsPartOfProject Value="True"/>
<UnitName Value="dw_xml"/>
<UnitName Value="dw_XML"/>
</Unit11>
<Unit12>
<Filename Value="fpdocproj.pas"/>
@ -115,7 +114,7 @@
</Units>
</ProjectOptions>
<CompilerOptions>
<Version Value="9"/>
<Version Value="10"/>
<Target>
<Filename Value="fpdoc"/>
</Target>

View File

@ -339,6 +339,7 @@ begin
end;
WriterClass:=GetWriterClass(Options.Backend);
Writer:=WriterClass.Create(Engine.Package,Engine);
Writeln('Writing doc');
With Writer do
Try
If Options.BackendOptions.Count>0 then

View File

@ -40,7 +40,7 @@ Type
2 : (phi,Omega : Real);
end;
// TADeprecatedType = Integer deprecated;
TADeprecatedType = Integer deprecated;
Var
ASimpleVar : Integer;