Browse Source

Extend tppumodule so that it can be opened from a stream as well.

fppu.pas, tppumodule:
  * rename openppu() to openppufile()
  + new method openppustream() to open a module based on a stream
  + put the common part of openppufile() and openppustream() into a new method openppu()

git-svn-id: branches/svenbarth/packages@32305 -
svenbarth 9 years ago
parent
commit
9533f43fe9
1 changed files with 32 additions and 6 deletions
  1. 32 6
      compiler/fppu.pas

+ 32 - 6
compiler/fppu.pas

@@ -36,7 +36,7 @@ interface
 
 
     uses
     uses
       cmsgs,verbose,
       cmsgs,verbose,
-      cutils,cclasses,
+      cutils,cclasses,cstreams,
       globtype,globals,finput,fmodule,
       globtype,globals,finput,fmodule,
       symbase,ppu,symtype;
       symbase,ppu,symtype;
 
 
@@ -57,7 +57,8 @@ interface
           constructor create(LoadedFrom:TModule;const amodulename: string; const afilename:TPathStr;_is_unit:boolean);
           constructor create(LoadedFrom:TModule;const amodulename: string; const afilename:TPathStr;_is_unit:boolean);
           destructor destroy;override;
           destructor destroy;override;
           procedure reset;override;
           procedure reset;override;
-          function  openppu:boolean;
+          function  openppufile:boolean;
+          function  openppustream(strm:TCStream):boolean;
           procedure getppucrc;
           procedure getppucrc;
           procedure writeppu;
           procedure writeppu;
           procedure loadppu;
           procedure loadppu;
@@ -74,6 +75,7 @@ interface
            avoid endless resolving loops in case of cyclic dependencies. }
            avoid endless resolving loops in case of cyclic dependencies. }
           defsgeneration : longint;
           defsgeneration : longint;
 
 
+          function  openppu:boolean;
           function  search_unit_files(onlysource:boolean):boolean;
           function  search_unit_files(onlysource:boolean):boolean;
           function  search_unit(onlysource,shortname:boolean):boolean;
           function  search_unit(onlysource,shortname:boolean):boolean;
           function  loadfrompackage:boolean;
           function  loadfrompackage:boolean;
@@ -190,11 +192,12 @@ var
       until false;
       until false;
     end;
     end;
 
 
-    function tppumodule.openppu:boolean;
+
+    function tppumodule.openppufile:boolean;
       var
       var
         ppufiletime : longint;
         ppufiletime : longint;
       begin
       begin
-        openppu:=false;
+        openppufile:=false;
         Message1(unit_t_ppu_loading,ppufilename,@queuecomment);
         Message1(unit_t_ppu_loading,ppufilename,@queuecomment);
       { Get ppufile time (also check if the file exists) }
       { Get ppufile time (also check if the file exists) }
         ppufiletime:=getnamedfiletime(ppufilename);
         ppufiletime:=getnamedfiletime(ppufilename);
@@ -210,6 +213,29 @@ var
            Message(unit_u_ppu_file_too_short);
            Message(unit_u_ppu_file_too_short);
            exit;
            exit;
          end;
          end;
+        result:=openppu;
+      end;
+
+
+    function tppumodule.openppustream(strm:TCStream):boolean;
+      begin
+      { Open the ppufile }
+        Message1(unit_u_ppu_name,ppufilename);
+        ppufile:=tcompilerppufile.create(ppufilename);
+        if not ppufile.openstream(strm) then
+         begin
+           ppufile.free;
+           ppufile:=nil;
+           Message(unit_u_ppu_file_too_short);
+           exit;
+         end;
+        result:=openppu;
+      end;
+
+
+    function tppumodule.openppu:boolean;
+      begin
+        openppu:=false;
       { check for a valid PPU file }
       { check for a valid PPU file }
         if not ppufile.CheckPPUId then
         if not ppufile.CheckPPUId then
          begin
          begin
@@ -347,7 +373,7 @@ var
            if Found then
            if Found then
             Begin
             Begin
               SetFileName(hs,false);
               SetFileName(hs,false);
-              Found:=OpenPPU;
+              Found:=openppufile;
             End;
             End;
            PPUSearchPath:=Found;
            PPUSearchPath:=Found;
          end;
          end;
@@ -511,7 +537,7 @@ var
             if Found then
             if Found then
              Begin
              Begin
                SetFileName(hs,false);
                SetFileName(hs,false);
-               Found:=OpenPPU;
+               Found:=openppufile;
              End;
              End;
             PPUSearchPath:=Found;
             PPUSearchPath:=Found;
           end;
           end;