diff options
author | Tristan Gingold <tgingold@free.fr> | 2023-01-27 08:16:42 +0100 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2023-01-27 08:16:42 +0100 |
commit | 6c7ecaa1e1489395e1df86a97d19edff22e1871b (patch) | |
tree | a6021dd9c084ae9461df727ef9e04d3e0966f932 /src/grt/grt-files.ads | |
parent | c81a49d8dfec4e648a7bbbcf2ee6cccca6bf95e1 (diff) | |
download | ghdl-6c7ecaa1e1489395e1df86a97d19edff22e1871b.tar.gz ghdl-6c7ecaa1e1489395e1df86a97d19edff22e1871b.tar.bz2 ghdl-6c7ecaa1e1489395e1df86a97d19edff22e1871b.zip |
src/grt: extract grt-files_lib from grt-files
Diffstat (limited to 'src/grt/grt-files.ads')
-rw-r--r-- | src/grt/grt-files.ads | 87 |
1 files changed, 22 insertions, 65 deletions
diff --git a/src/grt/grt-files.ads b/src/grt/grt-files.ads index da22f0c1d..2aba8ad1e 100644 --- a/src/grt/grt-files.ads +++ b/src/grt/grt-files.ads @@ -20,10 +20,11 @@ -- covered by the GNU General Public License. This exception does not -- however invalidate any other reasons why the executable file might be -- covered by the GNU Public License. -with Grt.Types; use Grt.Types; -with Grt.Vhdl_Types; use Grt.Vhdl_Types; with Interfaces; +with Grt.Types; use Grt.Types; +with Grt.Stdio; + package Grt.Files is type Ghdl_File_Index is new Interfaces.Integer_32; @@ -38,76 +39,32 @@ package Grt.Files is Name_Error : constant Ghdl_I32 := 2; Mode_Error : constant Ghdl_I32 := 3; - -- General files. - function Ghdl_File_Endfile (File : Ghdl_File_Index) return Boolean; - - -- Elaboration. - function Ghdl_Text_File_Elaborate return Ghdl_File_Index; - function Ghdl_File_Elaborate (Sig : Ghdl_C_String) return Ghdl_File_Index; - - -- Finalization. - procedure Ghdl_Text_File_Finalize (File : Ghdl_File_Index); - procedure Ghdl_File_Finalize (File : Ghdl_File_Index); - - -- Subprograms. - procedure Ghdl_Text_File_Open - (File : Ghdl_File_Index; Mode : Ghdl_I32; Str : Std_String_Ptr); - function Ghdl_Text_File_Open_Status - (File : Ghdl_File_Index; Mode : Ghdl_I32; Str : Std_String_Ptr) - return Ghdl_I32; - - procedure Ghdl_File_Open - (File : Ghdl_File_Index; Mode : Ghdl_I32; Str : Std_String_Ptr); - function Ghdl_File_Open_Status - (File : Ghdl_File_Index; Mode : Ghdl_I32; Str : Std_String_Ptr) - return Ghdl_I32; - - procedure Ghdl_Text_Write (File : Ghdl_File_Index; Str : Std_String_Ptr); - procedure Ghdl_Write_Scalar (File : Ghdl_File_Index; - Ptr : Ghdl_Ptr; - Length : Ghdl_Index_Type); - - procedure Ghdl_Read_Scalar (File : Ghdl_File_Index; - Ptr : Ghdl_Ptr; - Length : Ghdl_Index_Type); - - function Ghdl_Text_Read_Length - (File : Ghdl_File_Index; Str : Std_String_Ptr) return Std_Integer; - - procedure Ghdl_Untruncated_Text_Read - (File : Ghdl_File_Index; Str : Std_String_Ptr; Len : Std_Integer_Acc); - - procedure Ghdl_Text_File_Close (File : Ghdl_File_Index); - procedure Ghdl_File_Close (File : Ghdl_File_Index); - - procedure Ghdl_File_Flush (File : Ghdl_File_Index); -private - pragma Export (Ada, Ghdl_File_Endfile, "__ghdl_file_endfile"); + subtype C_Files is Grt.Stdio.FILEs; - pragma Export (C, Ghdl_Text_File_Elaborate, "__ghdl_text_file_elaborate"); - pragma Export (C, Ghdl_File_Elaborate, "__ghdl_file_elaborate"); + -- Create a file entry (add an entry to the table). + -- The file is not named and not opened. + function Create_File (Is_Text : Boolean; + Kind : Character; + Sig : Ghdl_C_String) return Ghdl_File_Index; - pragma Export (C, Ghdl_Text_File_Finalize, "__ghdl_text_file_finalize"); - pragma Export (C, Ghdl_File_Finalize, "__ghdl_file_finalize"); - pragma Export (C, Ghdl_Text_File_Open, "__ghdl_text_file_open"); - pragma Export (C, Ghdl_Text_File_Open_Status, - "__ghdl_text_file_open_status"); + -- Check INDEX is a valid index. + function Check_File_Index (Index : Ghdl_File_Index) return Boolean; - pragma Export (C, Ghdl_File_Open, "__ghdl_file_open"); - pragma Export (C, Ghdl_File_Open_Status, "__ghdl_file_open_status"); + -- Return the file for INDEX. + function Get_File_Stream (Index : Ghdl_File_Index) return C_Files; + procedure Set_File_Stream (Index : Ghdl_File_Index; + Stream : C_Files; Kind : Character); - pragma Export (C, Ghdl_Text_Write, "__ghdl_text_write"); - pragma Export (C, Ghdl_Write_Scalar, "__ghdl_write_scalar"); + -- Get the file signature. + function Get_File_Signature (Index : Ghdl_File_Index) return Ghdl_C_String; - pragma Export (C, Ghdl_Read_Scalar, "__ghdl_read_scalar"); + -- Return True iff file for INDEX is open. + function Is_Open (Index : Ghdl_File_Index) return Boolean; - pragma Export (C, Ghdl_Text_Read_Length, "__ghdl_text_read_length"); - pragma Export (C, Ghdl_Untruncated_Text_Read, - "std__textio__untruncated_text_read"); + function Get_Kind (Index : Ghdl_File_Index) return Character; - pragma Export (C, Ghdl_Text_File_Close, "__ghdl_text_file_close"); - pragma Export (C, Ghdl_File_Close, "__ghdl_file_close"); + function Is_Text_File (Index : Ghdl_File_Index) return Boolean; - pragma Export (C, Ghdl_File_Flush, "__ghdl_file_flush"); + procedure Destroy_File (Index : Ghdl_File_Index); end Grt.Files; |