DataMuseum.dkPresents historical artifacts from the history of: Rational R1000/400 Tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about Rational R1000/400 Tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - downloadIndex: ┃ B T ┃
Length: 8717 (0x220d) Types: TextFile Names: »B«
└─⟦a7d1ea751⟧ Bits:30000550 8mm tape, Rational 1000, !users!projects 94_04_11 └─ ⟦129cab021⟧ »DATA« └─⟦this⟧
with Bounded_String, Easy_X, Object, Message, Integer_Class, Symbol, String_Class, Counter, Text_Io, Bug; package body Pen_Class is package Bs renames Bounded_String; type Pen_Unary_Message is (Petit, Moyen, Large, Tonx, Tony, Clone, Entexte, Rentrecheztoi); type Pen_Keyword_Message is (Tonx, Tony, Ecris); type Pen_Object is record X : Easy_X.Coordinate; Y : Easy_X.Coordinate; Font : Easy_X.Fonts; end record; Void_Pen : constant Pen_Object := (0, 0, Easy_X.Small_Font); subtype Id_Pen_Table is Integer range 1 .. 100; Pen_Table : array (Id_Pen_Table) of Pen_Object; Default_Pen : Object.Reference := Object.Void_Reference; function Search_Empty return Id_Pen_Table is Id : Id_Pen_Table := 1; begin loop exit when Pen_Table (Id) = Void_Pen; if Id = 100 then raise Bug.Too_Many_Pens; end if; Id := Id + 1; end loop; return (Id); end Search_Empty; function Search (A_Pen : Object.Reference) return Id_Pen_Table is Id : Id_Pen_Table; begin Id := Id_Pen_Table (Object.Get_Value (A_Pen)); return (Id); end Search; function Create (Name : Message.Tiny_String) return Object.Reference is Id : Id_Pen_Table; Obj : Object.Reference; begin Id := Search_Empty; Obj := Object.Create (Object.Pen_Class, Id); Symbol.Insert (Name, Obj); return (Obj); end Create; procedure Create_Default is Default_Pen_Name : Message.Tiny_String; begin Bounded_String.Copy (Default_Pen_Name, "Stylo"); Default_Pen := Pen_Class.Create (Default_Pen_Name); end Create_Default; function Clone (The_Pen : Object.Reference) return Object.Reference is Id, New_Id : Id_Pen_Table; Result : Object.Reference; begin Id := Search (The_Pen); New_Id := Search_Empty; Result := Object.Create (Object.Pen_Class, New_Id); Pen_Table (New_Id) := Pen_Table (Id); return (Result); end Clone; procedure Refresh (This_Pen : Id_Pen_Table) is begin Easy_X.Set_Font (To => Pen_Table (This_Pen).Font); Easy_X.Move_To (X => Pen_Table (This_Pen).X, Y => Pen_Table (This_Pen).Y); end Refresh; procedure Init is begin for I in Id_Pen_Table loop Pen_Table (I) := Void_Pen; end loop; end Init; procedure Reset is begin Init; end Reset; procedure Go_Home (Pen : Object.Reference) is Id : Id_Pen_Table; begin Id := Search (Pen); Pen_Table (Id) := Void_Pen; end Go_Home; procedure In_Text (The_Pen : Object.Reference) is Id : Id_Pen_Table; begin Object.In_Text (The_Pen); Id := Search (The_Pen); Text_Io.Put_Line ("Coordonnees X:" & Integer'Image (Integer (Pen_Table (Id).X)) & " Y:" & Integer'Image (Integer (Pen_Table (Id).Y))); Text_Io.Put ("Font: "); case Pen_Table (Id).Font is when Easy_X.Small_Font => Text_Io.Put_Line ("petite."); when Easy_X.Medium_Font => Text_Io.Put_Line ("moyenne."); when Easy_X.Large_Font => Text_Io.Put_Line ("large."); end case; end In_Text; function Set_X (X, From_Pen : Object.Reference) return Object.Reference is Id : Id_Pen_Table; use Object; begin if (Object.Get_Class (X) /= Object.Integer_Class) then raise Bug.Mismatch_Type; end if; Id := Search (From_Pen); Pen_Table (Id).X := Easy_X.Coordinate (Object.Get_Value (X)); return From_Pen; end Set_X; function Set_Y (Y, From_Pen : Object.Reference) return Object.Reference is Id : Id_Pen_Table; use Object; begin if (Object.Get_Class (Y) /= Object.Integer_Class) then raise Bug.Mismatch_Type; end if; Id := Search (From_Pen); Pen_Table (Id).Y := Easy_X.Coordinate (Object.Get_Value (Y)); return From_Pen; end Set_Y; function Set_Font (Font : Pen_Unary_Message; From_Pen : Object.Reference) return Object.Reference is Id : Id_Pen_Table; begin Id := Search (From_Pen); case Font is when Petit => Pen_Table (Id).Font := Easy_X.Small_Font; when Moyen => Pen_Table (Id).Font := Easy_X.Medium_Font; when Large => Pen_Table (Id).Font := Easy_X.Large_Font; when others => raise Bug.Unknown_Pen_Message; end case; return From_Pen; end Set_Font; function Write (The_Text, Pen : Object.Reference) return Object.Reference is Text : Message.Tiny_String; Id : Id_Pen_Table; use Object; begin if (Object.Get_Class (The_Text) /= Object.String_Class) then raise Bug.Mismatch_Type; end if; Id := Search (Pen); Bounded_String.Copy (Text, String_Class.Get_String (The_Text)); Refresh (Id); Easy_X.Draw_String (Bounded_String.Image (Text)); return (The_Text); end Write; function Get_X (From_Pen : Object.Reference) return Object.Reference is Id : Id_Pen_Table; Result : Object.Reference; begin Id := Search (From_Pen); Result := Integer_Class.Create (Integer (Pen_Table (Id).X)); return Result; end Get_X; function Get_Y (From_Pen : Object.Reference) return Object.Reference is Id : Id_Pen_Table; Result : Object.Reference; begin Id := Search (From_Pen); Result := Integer_Class.Create (Integer (Pen_Table (Id).Y)); return Result; end Get_Y; function Send (To_Pen : Object.Reference; The_Message : Message.Tiny_String) return Object.Reference is Result : Object.Reference; The_Unary_Message : Pen_Unary_Message; begin The_Unary_Message := Pen_Unary_Message'Value (Bs.Image (The_Message)); Counter.Increase (Object.Pen_Class); case The_Unary_Message is when Petit | Moyen | Large => Result := Set_Font (Font => The_Unary_Message, From_Pen => To_Pen); when Tonx => Result := Get_X (From_Pen => To_Pen); when Tony => Result := Get_Y (From_Pen => To_Pen); when Clone => Result := Clone (The_Pen => To_Pen); when Entexte => In_Text (To_Pen); Result := To_Pen; when Rentrecheztoi => Go_Home (To_Pen); Result := To_Pen; end case; Counter.Stop_Time (Object.Pen_Class); return Result; exception when Constraint_Error => raise Bug.Unknown_Pen_Message; end Send; function Send (To_Pen : Object.Reference; The_Messages : Message.List; With_Arguments : Argument.List) return Object.Reference is Result : Object.Reference := Object.Void_Reference; A_Message : Message.Tiny_String; A_Argument : Object.Reference; The_Keyword : Pen_Keyword_Message; Mess : Message.List; Args : Argument.List; Nb_Message : Natural; begin Mess := The_Messages; Args := With_Arguments; Nb_Message := Message.How_Many (Mess); for I in 1 .. Nb_Message loop Counter.Increase (Object.Pen_Class); A_Message := Message.Get (Mess); The_Keyword := Pen_Keyword_Message'Value (Bs.Image (A_Message)); A_Argument := Argument.Get (Args); case The_Keyword is when Tonx => Result := Set_X (X => A_Argument, From_Pen => To_Pen); when Tony => Result := Set_Y (Y => A_Argument, From_Pen => To_Pen); when Ecris => Result := Write (The_Text => A_Argument, Pen => To_Pen); end case; Message.Next (Mess, A_Message); Argument.Next (Args, A_Argument); Counter.Stop_Time (Object.Pen_Class); end loop; return Result; exception when Constraint_Error => raise Bug.Unknown_Pen_Message; end Send; begin Init; end Pen_Class;