redefined Object_String for simpler string handling and made other related changes
This commit is contained in:
@ -1,3 +1,4 @@
|
||||
|
||||
with H2.Scheme;
|
||||
with H2.Pool;
|
||||
with Storage;
|
||||
@ -5,6 +6,7 @@ with Stream;
|
||||
with Ada.Text_IO;
|
||||
with Ada.Unchecked_Deallocation;
|
||||
|
||||
|
||||
procedure scheme is
|
||||
--package S renames H2.Scheme;
|
||||
--package S is new H2.Scheme (Wide_Character, Wide_String);
|
||||
|
@ -1,9 +1,11 @@
|
||||
with H2.Pool;
|
||||
with Ada.Characters.Conversions;
|
||||
with Ada.Unchecked_Conversion;
|
||||
|
||||
package body Stream is
|
||||
|
||||
------------------------------------------------------------------
|
||||
use type S.Object_String_Size;
|
||||
|
||||
procedure Open (Stream: in out String_Input_Stream_Record) is
|
||||
begin
|
||||
@ -19,8 +21,8 @@ Ada.Wide_Text_IO.Put_Line ("****** CLOSE STRING STREAM ******");
|
||||
|
||||
procedure Read (Stream: in out String_Input_Stream_Record;
|
||||
Data: out S.Object_String;
|
||||
Last: out Standard.Natural) is
|
||||
Avail: Standard.Natural;
|
||||
Last: out S.Object_String_Size) is
|
||||
Avail: S.Object_String_Size;
|
||||
begin
|
||||
Avail := Stream.Str'Last - Stream.Pos;
|
||||
if Avail <= 0 then
|
||||
@ -39,7 +41,7 @@ Ada.Wide_Text_IO.Put_Line ("****** CLOSE STRING STREAM ******");
|
||||
|
||||
procedure Write (Stream: in out String_Input_Stream_Record;
|
||||
Data: out S.Object_String;
|
||||
Last: out Standard.Natural) is
|
||||
Last: out S.Object_String_Size) is
|
||||
begin
|
||||
--raise S.Stream_Error;
|
||||
Last := Data'First - 1;
|
||||
@ -48,20 +50,24 @@ Ada.Wide_Text_IO.Put_Line ("****** CLOSE STRING STREAM ******");
|
||||
------------------------------------------------------------------
|
||||
|
||||
procedure Open (Stream: in out File_Stream_Record) is
|
||||
subtype Wide_String is Standard.Wide_String(1 .. Standard.Natural(Stream.Name'Length));
|
||||
function To_Wide_String is new Ada.Unchecked_Conversion (S.Object_String, Wide_String);
|
||||
begin
|
||||
Ada.Wide_Text_IO.Put_Line (">>>>> OPEN File STREAM <<<<<");
|
||||
Ada.Wide_Text_IO.Open (Stream.Handle, Ada.Wide_Text_IO.In_File, Ada.Characters.Conversions.To_String(Stream.Name.all));
|
||||
Ada.Wide_Text_IO.Put_Line (">>>>> OPEN File STREAM <<<<< " & To_Wide_String(Stream.Name.all));
|
||||
Ada.Wide_Text_IO.Open (Stream.Handle, Ada.Wide_Text_IO.In_File, Ada.Characters.Conversions.To_String(To_Wide_String(Stream.Name.all)));
|
||||
end Open;
|
||||
|
||||
procedure Close (Stream: in out File_Stream_Record) is
|
||||
subtype Wide_String is Standard.Wide_String(1 .. Standard.Natural(Stream.Name'Length));
|
||||
function To_Wide_String is new Ada.Unchecked_Conversion (S.Object_String, Wide_String);
|
||||
begin
|
||||
Ada.Wide_Text_IO.Put_Line (">>>>> CLOSE File STREAM <<<<<");
|
||||
Ada.Wide_Text_IO.Put_Line (">>>>> CLOSE File STREAM <<<<< " & To_Wide_String(Stream.Name.all));
|
||||
Ada.Wide_Text_IO.Close (Stream.Handle);
|
||||
end Close;
|
||||
|
||||
procedure Read (Stream: in out File_Stream_Record;
|
||||
Data: out S.Object_String;
|
||||
Last: out Standard.Natural) is
|
||||
Last: out S.Object_String_Size) is
|
||||
begin
|
||||
for I in Data'First .. Data'Last loop
|
||||
begin
|
||||
@ -78,7 +84,7 @@ Ada.Wide_Text_IO.Put_Line (">>>>> CLOSE File STREAM <<<<<");
|
||||
|
||||
procedure Write (Stream: in out File_Stream_Record;
|
||||
Data: out S.Object_String;
|
||||
Last: out Standard.Natural) is
|
||||
Last: out S.Object_String_Size) is
|
||||
begin
|
||||
--raise S.Stream_Error;
|
||||
Last := Data'First - 1;
|
||||
|
@ -3,49 +3,39 @@ with Ada.Wide_Text_IO;
|
||||
|
||||
package Stream is
|
||||
|
||||
--package S renames H2.Scheme;
|
||||
package S is new H2.Scheme (Standard.Wide_Character, Standard.Wide_String);
|
||||
package S is new H2.Scheme (Standard.Wide_Character);
|
||||
|
||||
------------------------------------------------------------
|
||||
--type Object_String_Pointer is access all S.Object_String;
|
||||
type Object_String_Pointer is access constant S.Object_String;
|
||||
type String_Input_Stream_Record(Str: Object_String_Pointer) is new S.Stream_Record with record
|
||||
Pos: Standard.Natural := 0;
|
||||
Pos: S.Object_String_Size := 0;
|
||||
end record;
|
||||
|
||||
--type String_Input_Stream_Record(Len: Standard.Natural) is new S.Stream_Record with record
|
||||
-- Pos: Standard.Natural := 0;
|
||||
-- Str: S.Object_String (1 .. Len) := (others => ' ');
|
||||
--end record;
|
||||
|
||||
procedure Open (Stream: in out String_Input_Stream_Record);
|
||||
procedure Close (Stream: in out String_Input_Stream_Record);
|
||||
procedure Read (Stream: in out String_Input_Stream_Record;
|
||||
Data: out S.Object_String;
|
||||
Last: out Standard.Natural);
|
||||
Last: out S.Object_String_Size);
|
||||
procedure Write (Stream: in out String_Input_Stream_Record;
|
||||
Data: out S.Object_String;
|
||||
Last: out Standard.Natural);
|
||||
Last: out S.Object_String_Size);
|
||||
|
||||
------------------------------------------------------------
|
||||
--type File_Stream_Record(Name: Object_String_Pointer) is new S.Stream_Record with record
|
||||
-- Handle: H2.Text_IO.File_Type;
|
||||
--end record;
|
||||
|
||||
type File_Stream_Record is new S.Stream_Record with record
|
||||
Name: S.Constant_Object_String_Pointer;
|
||||
Handle: Ada.Wide_Text_IO.File_Type;
|
||||
end record;
|
||||
|
||||
|
||||
procedure Open (Stream: in out File_Stream_Record);
|
||||
procedure Close (Stream: in out File_Stream_Record);
|
||||
procedure Read (Stream: in out File_Stream_Record;
|
||||
Data: out S.Object_String;
|
||||
Last: out Standard.Natural);
|
||||
Last: out S.Object_String_Size);
|
||||
procedure Write (Stream: in out File_Stream_Record;
|
||||
Data: out S.Object_String;
|
||||
Last: out Standard.Natural);
|
||||
Last: out S.Object_String_Size);
|
||||
|
||||
------------------------------------------------------------
|
||||
procedure Allocate_Stream (Interp: in out S.Interpreter_Record;
|
||||
|
Reference in New Issue
Block a user