Skip to content

Commit

Permalink
Moved silo to new da_common folder
Browse files Browse the repository at this point in the history
  • Loading branch information
Roger Mc Murtrie committed Nov 23, 2017
1 parent 5af40bf commit fd6284a
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 2 deletions.
4 changes: 2 additions & 2 deletions example_2.1/example_2_1_project.gpr
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
with "../../../../Ada_Source/OpenGLAda/examples/common/common.gpr";
with "/Ada_Source/OpenGLAda/examples/common/common.gpr";
limited with "/Ada_Source/OpenGLAda/opengl-glfw.gpr";

project Example_2_1_Project is

for Source_Dirs use ("src", "../Reference_Implementation/src", "../../../../Ada_Source/OpenGLAda/examples/common");
for Source_Dirs use ("src", "../Reference_Implementation/src", "../ga_common");
for Object_Dir use "obj";
for Exec_Dir use ".";
for Main use ("bivectors.adb");
Expand Down
58 changes: 58 additions & 0 deletions ga_common/silo.adb
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@

with Ada.Containers.Doubly_Linked_Lists;

package body Silo is
use Ada.Containers;

package Label_Container is new Doubly_Linked_Lists (Label_Data);
type Label_List is new Label_Container.List with null record;

theStack : Label_List;

procedure Push (Data : Label_Data) is
begin
Append (theStack, Data);
end Push;

-- -----------------------------------------------------------------

function Pull return Label_Data is
Data : Label_Data;
begin
if Is_Empty (theStack) then
raise Empty_Stack;
end if;

Data := First_Element (theStack);
Delete_First (theStack);
return Data;
end Pull;

-- -----------------------------------------------------------------

function Set_Data (Label_String : Unbounded_String;
Label_Position : GL.Types.Singles.Vector2)
return Label_Data is
begin
return (Label_String, Label_Position);
end Set_Data;

-- -----------------------------------------------------------------

procedure Get_Data (Label_String : out Unbounded_String;
Label_Position : out GL.Types.Singles.Vector2) is
theData : Label_Data := Pull;
begin
Label_String:= theData.Label_String;
Label_Position := theData.Label_Position;
end Get_Data;

-- -----------------------------------------------------------------
function Size return Integer is
begin
return Integer (Length (theStack));
end Size;

-- -----------------------------------------------------------------

end Silo;
27 changes: 27 additions & 0 deletions ga_common/silo.ads
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@

with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;

with GL.Types;

package Silo is

type Label_Data is private;

Empty_Stack : Exception;

procedure Get_Data (Label_String : out Unbounded_String;
Label_Position : out GL.Types.Singles.Vector2);
procedure Push (Data : Label_Data);
function Pull return Label_Data;
function Set_Data (Label_String : Unbounded_String;
Label_Position : GL.Types.Singles.Vector2)
return Label_Data;
function Size return Integer;

private
type Label_Data is record
Label_String : Unbounded_String;
Label_Position : GL.Types.Singles.Vector2;
end record;

end Silo;

0 comments on commit fd6284a

Please sign in to comment.