Browse Source

--- Merging r16215 into '.':
U packages/fcl-passrc/src/pparser.pp
--- Merging r16217 into '.':
U utils/fpdoc/dglobals.pp
--- Merging r16266 into '.':
U utils/fpdoc/dw_htmlchm.inc
U utils/fpdoc/dw_html.pp
--- Merging r16285 into '.':
U utils/fpdoc/dw_latex.pp
--- Merging r16312 into '.':
G utils/fpdoc/dglobals.pp
--- Merging r16306 into '.':
U packages/fcl-passrc/src/pastree.pp
G packages/fcl-passrc/src/pparser.pp
--- Merging r16333 into '.':
U packages/fcl-passrc/src/pscanner.pp

# revisions: 16215,16217,16266,16285,16312,16306,16333
------------------------------------------------------------------------
r16215 | marco | 2010-10-24 22:12:44 +0200 (Sun, 24 Oct 2010) | 2 lines
Changed paths:
M /trunk/packages/fcl-passrc/src/pparser.pp

* fcl-passrc goto support (added to an empty command), mantis 16476

------------------------------------------------------------------------
------------------------------------------------------------------------
r16217 | marco | 2010-10-24 23:33:41 +0200 (Sun, 24 Oct 2010) | 3 lines
Changed paths:
M /trunk/utils/fpdoc/dglobals.pp

* fix for mantis 17597, aliastypes in inheritance chains of fpdoc.
Adds aliases to the content file, using alias(realtype) syntax.

------------------------------------------------------------------------
------------------------------------------------------------------------
r16266 | marco | 2010-10-30 18:52:37 +0200 (Sat, 30 Oct 2010) | 2 lines
Changed paths:
M /trunk/utils/fpdoc/dw_html.pp
M /trunk/utils/fpdoc/dw_htmlchm.inc

* --css-file now also for html (Mantis 17542)

------------------------------------------------------------------------
------------------------------------------------------------------------
r16285 | michael | 2010-11-01 10:55:54 +0100 (Mon, 01 Nov 2010) | 1 line
Changed paths:
M /trunk/utils/fpdoc/dw_latex.pp

* Replace strange characters with ! instead of dropping them (dropping causes duplicate labels)
------------------------------------------------------------------------
------------------------------------------------------------------------
r16312 | marco | 2010-11-06 21:46:46 +0100 (Sat, 06 Nov 2010) | 2 lines
Changed paths:
M /trunk/utils/fpdoc/dglobals.pp

* fixes for memory leaks by Vincent

------------------------------------------------------------------------
------------------------------------------------------------------------
r16306 | michael | 2010-11-05 18:14:04 +0100 (Fri, 05 Nov 2010) | 1 line
Changed paths:
M /trunk/packages/fcl-passrc/src/pastree.pp
M /trunk/packages/fcl-passrc/src/pparser.pp

* Some memory leak fixes from Vincent Snijders
------------------------------------------------------------------------
------------------------------------------------------------------------
r16333 | marco | 2010-11-13 12:30:29 +0100 (Sat, 13 Nov 2010) | 1 line
Changed paths:
M /trunk/packages/fcl-passrc/src/pscanner.pp

* fixed exceptionhandling scanner (2nd attempt to load file was not in an try..except). Bug reported on German laz forum
------------------------------------------------------------------------

git-svn-id: branches/fixes_2_4@16370 -

marco 14 years ago
parent
commit
ecb59a09c6

+ 2 - 0
packages/fcl-passrc/src/pastree.pp

@@ -1440,6 +1440,8 @@ begin
     (e.g. in Constants) }
   if Assigned(VarType) then
     VarType.Release;
+  if Assigned(Expr) then
+    Expr.Release;
   inherited Destroy;
 end;
 

+ 13 - 8
packages/fcl-passrc/src/pparser.pp

@@ -2728,6 +2728,12 @@ begin
         CreateBlock(CurBlock.AddWhileDo(Condition));
         ExpectToken(tkdo);
       end;
+    tkgoto:
+      begin
+        nexttoken;
+        curblock.AddCommand('goto '+curtokenstring);
+        expecttoken(tkSemiColon);
+      end;
     tkfor:
       begin
         // for VarName := StartValue to EndValue do
@@ -3087,16 +3093,15 @@ begin
       begin
         Variant := TPasVariant(CreateElement(TPasVariant, '', Parent));
         Parent.Variants.Add(Variant);
-        Variant.Values := TStringList.Create;
         while True do
         begin
-      Variant.Values.Add(ParseExpression(Parent));
-      NextToken;
-      if CurToken = tkColon then
-        break
-      else if CurToken <> tkComma then
-        ParseExc(SParserExpectedCommaColon);
-    end;
+          Variant.Values.Add(ParseExpression(Parent));
+          NextToken;
+          if CurToken = tkColon then
+            break
+          else if CurToken <> tkComma then
+            ParseExc(SParserExpectedCommaColon);
+        end;
         ExpectToken(tkBraceOpen);
     Variant.Members := TPasRecordType(CreateElement(TPasRecordType, '',
       Variant));

+ 5 - 1
packages/fcl-passrc/src/pscanner.pp

@@ -501,8 +501,12 @@ begin
     if BaseDirectory<>'' then
       begin
       FN:=SearchLowUpCase(BaseDirectory+AName);
-      If (FN<>'') then
+	  try
+      If (FN<>'') then   
         Result := TFileLineReader.Create(FN);
+      except 
+        Result:=nil;
+        end;		
       end;
     end;
 end;

+ 140 - 31
utils/fpdoc/dglobals.pp

@@ -694,26 +694,45 @@ var
      result:=Copy(AName, DotPos2 + 1, length(AName)-dotpos2);
   end;
 
+  function SearchInList(clslist:TList;s:string):TPasElement;
+  var i : integer;
+      ClassEl: TPasElement;
+  begin
+    result:=nil;
+    for i:=0 to clslist.count-1 do
+      begin
+        ClassEl := TPasElement(clslist[i]);
+        if CompareText(ClassEl.Name,s) =0 then
+          exit(Classel); 
+      end;
+  end;
+
   function ResolveClassType(AName:String):TPasClassType;
   var 
      pkg     : TPasPackage;
      module  : TPasModule;
      s       : string; 
-     clslist : TList;  
-     ClassEl : TPasClassType;
-     i       : Integer;
   begin
     Result:=nil;
     s:=ResolvePackageModule(AName,pkg,module,False);
     if not assigned(module) then
       exit;
-    clslist:=module.InterfaceSection.Classes;
-    for i:=0 to clslist.count-1 do
-      begin
-        ClassEl := TPasClassType(clslist[i]);
-        if CompareText(ClassEl.Name,s) =0 then
-          exit(Classel); 
-      end;
+    result:=TPasClassType(SearchInList(Module.InterfaceSection.Classes,s));
+  end;
+
+  function ResolveAliasType(AName:String):TPasAliasType;
+  var 
+     pkg     : TPasPackage;
+     module  : TPasModule;
+     s       : string; 
+  begin
+    Result:=nil;
+    s:=ResolvePackageModule(AName,pkg,module,False);
+    if not assigned(module) then
+      exit;
+    result:=TPasAliasType(SearchInList(Module.InterfaceSection.Types,s));
+    if not (result is TPasAliasType) then
+      result:=nil;
   end;
 
   procedure ReadClasses;
@@ -737,10 +756,81 @@ var
         InheritanceInfo.AddObject(Inheritancestr,result);
     end;
 
+   procedure splitalias(var instr:string;out outstr:string);
+   var i,j:integer;
+   begin 
+     if length(instr)=0 then exit;
+     instr:=trim(instr);
+     i:=pos('(',instr);
+     if i>0 then
+      begin 
+        j:=length(instr)-i;
+        if instr[length(instr)]=')' then
+          dec(j);
+        outstr:=copy(instr,i+1,j);
+        delete(instr,i,j+2);
+      end
+   end;
+
+   Function ResolveAndLinkClass(clname:String;IsClass:boolean;cls:TPasClassType):TPasClassType;
+   begin
+     result:=TPasClassType(ResolveClassType(clname)); 
+     if assigned(result) and not (cls=result) then  // save from tobject=implicit tobject
+       begin
+         result.addref;
+         if IsClass then
+           begin
+             cls.ancestortype:=result;
+//             writeln(cls.name, ' has as ancestor ',result.pathname);
+           end
+         else
+           begin    
+             cls.interfaces.add(result);
+//             writeln(cls.name, ' implements ',result.pathname);
+           end;
+       end
+     else
+       if cls<>result then
+         writeln(cls.name,'''s dependancy '  ,clname,' could not be resolved');
+end;
+
+function CreateAliasType (alname,clname : string;parentclass:TPasClassType; out cl2 :TPasClassType):TPasAliasType;
+// create alias clname =  alname
+var 
+  pkg     : TPasPackage;
+  module  : TPasModule; 
+  s       : string;  
+begin
+    Result:=nil;
+    s:=ResolvePackageModule(Alname,pkg,module,True);
+    if not assigned(module) then
+      exit;
+    cl2:=TPasClassType(ResolveClassType(alname));
+    if assigned( cl2) and not (parentclass=cl2) then  
+      begin
+        result:=ResolveAliasType(clname);
+        if assigned(result) then
+          begin
+            writeln('found alias ',clname,' (',s,') ',result.classname);  
+          end
+        else
+          begin
+            writeln('new alias ',clname,' (',s,') ');
+            cl2.addref;
+            Result := TPasAliasType(CreateElement(TPasAliasType,s,module.interfacesection,vispublic,'',0));
+            module.interfacesection.Declarations.Add(Result);
+            TPasAliasType(Result).DestType := cl2;
+          end
+      end
+end;
+
    procedure ProcessInheritanceStrings(inhInfo:TStringList);
+
    var i,j : integer;
        cls : TPasClassType;  
        cls2: TPasClassType;
+       clname,
+       alname : string;
        inhclass   : TStringList;
    begin
      inhclass:=TStringList.Create;
@@ -754,27 +844,21 @@ var
 
            for j:= 0 to inhclass.count-1 do
              begin
-               // writeln('processing',inhclass[j]);
-               cls2:=TPasClassType(ResolveClassType(inhclass[j])); 
-               if assigned(cls2) and not (cls=cls2) then  // save from tobject=implicit tobject
+               //writeln('processing',inhclass[j]);
+               clname:=inhclass[j];
+               splitalias(clname,alname);               
+               if alname<>'' then // the class//interface we refered to is an alias
                  begin
-                   cls2.addref;
-                   if j=0 then
-                     cls.ancestortype:=cls2
-                   else
-                     cls.interfaces.add(cls2);
-{                   if j=0 then
-                     writeln(cls.name, ' has as ancestor ',cls2.pathname)
-                   else
-                     writeln(cls.name, ' implements ',cls2.pathname)
-}
-                 end
+                   // writeln('Found alias pair ',clname,' = ',alname);   
+                   if not assigned(CreateAliasType(alname,clname,cls,cls2)) then
+                      writeln('creating alias failed!');
+                 end 
                else
-                if cls<>cls2 then
-                  writeln(cls.name,'''s dependancy '  ,inhclass[j],' ',j,' could not be resolved');
+                 cls2:=ResolveAndLinkClass(clname,j=0,cls);
              end;
          end;
-end;
+    inhclass.free;
+   end;
 
   var
     s, Name: String;
@@ -878,10 +962,18 @@ var
     end;
   end;
 
+  function CheckImplicitInterfaceLink(const s : String):String;
+  begin
+   if uppercase(s)='IUNKNOWN' then
+     Result:='#rtl.System.IUnknown'
+   else 
+     Result:=s;
+  end;
 var
   LinkNode: TLinkNode;
   i, j, k: Integer;
   Module: TPasModule;
+  Alias : TPasAliasType;
   ClassDecl: TPasClassType;
   Member: TPasElement;
   s: String;
@@ -911,9 +1003,18 @@ begin
       for j := 0 to Module.InterfaceSection.Classes.Count - 1 do
       begin
         ClassDecl := TPasClassType(Module.InterfaceSection.Classes[j]);
-        Write(ContentFile, ClassDecl.PathName, ' ');
-        if Assigned(ClassDecl.AncestorType) then
-          Write(ContentFile, ClassDecl.AncestorType.PathName)
+        Write(ContentFile, CheckImplicitInterfaceLink(ClassDecl.PathName), ' ');
+        if Assigned(ClassDecl.AncestorType) then 
+          begin
+             // simple aliases to class types are coded as "alias(classtype)"
+             Write(ContentFile, CheckImplicitInterfaceLink(ClassDecl.AncestorType.PathName));
+             if ClassDecl.AncestorType is TPasAliasType then
+               begin
+                 alias:= TPasAliasType(ClassDecl.AncestorType);
+                 if assigned(alias.desttype) and (alias.desttype is TPasClassType) then
+                   write(ContentFile,'(',alias.desttype.PathName,')');   
+               end;
+          end
         else if ClassDecl.ObjKind = okClass then
           Write(ContentFile, '#rtl.System.TObject')
         else if ClassDecl.ObjKind = okInterface then
@@ -921,7 +1022,15 @@ begin
         if ClassDecl.Interfaces.Count>0 then
           begin
             for k:=0 to ClassDecl.Interfaces.count-1 do
-              write(contentfile,',',TPasClassType(ClassDecl.Interfaces[k]).PathName);
+              begin
+                write(contentfile,',',CheckImplicitInterfaceLink(TPasClassType(ClassDecl.Interfaces[k]).PathName));
+                if TPasElement(ClassDecl.Interfaces[k]) is TPasAliasType then
+                  begin
+                    alias:= TPasAliasType(ClassDecl.Interfaces[k]);
+                    if assigned(alias.desttype) and (alias.desttype is TPasClassType) then
+                      write(ContentFile,'(',CheckImplicitInterfaceLink(alias.desttype.PathName),')');   
+                  end;
+              end;
           end;
         writeln(contentfile);
         for k := 0 to ClassDecl.Members.Count - 1 do

+ 19 - 0
utils/fpdoc/dw_html.pp

@@ -89,6 +89,7 @@ type
     function GetPageCount: Integer;
     procedure SetOnTest(const AValue: TNotifyEvent);
   protected
+    FCSSFile: String;
     FAllocator: TFileAllocator;
     CurDirectory: String;       // relative to curdir of process
     BaseDirectory: String;      // relative path to package base directory
@@ -722,6 +723,8 @@ var
   i: Integer;
   PageDoc: TXMLDocument;
   Filename: String;
+  TempStream: TMemoryStream;
+
 begin
   if Engine.Output <> '' then
     Engine.Output := IncludeTrailingBackSlash(Engine.Output);
@@ -742,6 +745,20 @@ begin
         PageDoc.Free;
       end;
     end;
+  
+  if FCSSFile <> '' then
+  begin
+    if not FileExists(FCSSFile) Then
+      begin
+        Writeln(stderr,'Can''t find CSS file "',FCSSFILE,'"');
+        halt(1);
+      end;
+    TempStream := TMemoryStream.Create;
+    TempStream.LoadFromFile(FCSSFile);
+    TempStream.Position := 0;
+    TempStream.SaveToFile(Engine.output+ExtractFileName(FCSSFile));
+    TempStream.Free;
+  end;
 end;
 
 procedure THTMLWriter.WriteXHTMLPages;
@@ -3363,6 +3380,8 @@ begin
     IndexColCount := StrToIntDef(Arg,IndexColCount)
   else if Cmd = '--image-url' then
     FBaseImageURL  := Arg
+  else if Cmd = '--css-file' then
+    FCSSFile := arg
   else if Cmd = '--footer-date' then
     begin
     FIDF:=True;

+ 0 - 3
utils/fpdoc/dw_htmlchm.inc

@@ -13,7 +13,6 @@ type
     FTOCName,
     FIndexName,
     FDefaultPage: String;
-    FCSSFile: String;
     FMakeSearchable,
     FNoBinToc,
     FNoBinIndex,
@@ -503,8 +502,6 @@ begin
     FDefaultPage := arg
   else if Cmd = '--other-files' then
     FOtherFiles := arg
-  else if Cmd = '--css-file' then
-    FCSSFile := arg
   else if Cmd = '--auto-index' then
     FAutoIndex := True
   else if Cmd = '--auto-toc' then

+ 3 - 1
utils/fpdoc/dw_latex.pp

@@ -187,7 +187,9 @@ begin
   SetLength(Result, 0);
   for i := 1 to Length(S) do
     If not (S[i] in ['&','{','}','#','_','$','%','''','~','^', '\']) then
-      Result := Result + S[i];
+      Result := Result + S[i]
+    else
+      Result:=result+'!'  
 end;