Browse Source

* Fix forward class definition writing

git-svn-id: trunk@37140 -
michael 8 years ago
parent
commit
5f1ca4c1de

+ 2 - 2
packages/fcl-passrc/examples/pasrewrite.pp

@@ -247,7 +247,7 @@ begin
       FileResolver := TFileResolver.Create;
       FileResolver := TFileResolver.Create;
       FileResolver.UseStreams:=True;
       FileResolver.UseStreams:=True;
       Scanner := TPascalScanner.Create(FileResolver);
       Scanner := TPascalScanner.Create(FileResolver);
-      Scanner.Options:=[po_AsmWhole];
+      Scanner.Options:=[po_keepclassforward,po_AsmWhole];
       SCanner.LogEvents:=SE.ScannerLogEvents;
       SCanner.LogEvents:=SE.ScannerLogEvents;
       SCanner.OnLog:=SE.Onlog;
       SCanner.OnLog:=SE.Onlog;
       Scanner.AddDefine('FPK');
       Scanner.AddDefine('FPK');
@@ -316,7 +316,7 @@ begin
         raise Exception.Create(SErrNoSourceGiven);
         raise Exception.Create(SErrNoSourceGiven);
       FileResolver.AddIncludePath(ExtractFilePath(InputFileName));
       FileResolver.AddIncludePath(ExtractFilePath(InputFileName));
       Scanner.OpenFile(InputFilename);
       Scanner.OpenFile(InputFilename);
-      Parser.Options:=Parser.Options+[po_AsmWhole];
+      Parser.Options:=Parser.Options+[po_AsmWhole,po_KeepClassForward];
       Parser.ParseMain(Result);
       Parser.ParseMain(Result);
     finally
     finally
       Parser.Free;
       Parser.Free;

+ 7 - 2
packages/fcl-passrc/src/paswrite.pp

@@ -555,8 +555,11 @@ begin
       for i := 0 to ASection.UsesList.Count - 1 do
       for i := 0 to ASection.UsesList.Count - 1 do
         if AllowUnit(TPasElement(ASection.UsesList[i]).Name) then
         if AllowUnit(TPasElement(ASection.UsesList[i]).Name) then
           AddUnit(TPasElement(ASection.UsesList[i]).Name,Nil);
           AddUnit(TPasElement(ASection.UsesList[i]).Name,Nil);
-    AddLn(';');
-    AddLn;
+    if C>0 then
+      begin
+      AddLn(';');
+      AddLn;
+      end;
     end;
     end;
 end;
 end;
 
 
@@ -607,6 +610,8 @@ begin
     okRecordHelper: Add('record helper');
     okRecordHelper: Add('record helper');
     okClassHelper: Add('class helper');
     okClassHelper: Add('class helper');
   end;
   end;
+  if AClass.IsForward then
+    exit;
   if (AClass.ObjKind=okClass) and (ACLass.ExternalName<>'') and NotOption(woNoExternalClass) then
   if (AClass.ObjKind=okClass) and (ACLass.ExternalName<>'') and NotOption(woNoExternalClass) then
     Add(' external name ''%s'' ',[AClass.ExternalName]);
     Add(' external name ''%s'' ',[AClass.ExternalName]);
   if Assigned(AClass.AncestorType) then
   if Assigned(AClass.AncestorType) then