Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up after spontanious review by "pjljvandelaar". #18

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -10,3 +10,4 @@ cvg
messages.txt
*.cgpr

.clang-format
2 changes: 1 addition & 1 deletion dropin/src/yaml-destination-c_string.adb
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@ package body Yaml.Destination.C_String is
Size : Interfaces.C.size_t;
Size_Written : access Interfaces.C.size_t)
return Pointer is
Ret : constant access Instance :=
Ret : constant Instance_Access :=
new Instance'(Destination.Instance with
Raw => Raw, Size => Integer (Size),
Size_Written => Size_Written);
1 change: 1 addition & 0 deletions dropin/src/yaml-destination-c_string.ads
Original file line number Diff line number Diff line change
@@ -20,4 +20,5 @@ private
Size : Integer;
Size_Written : access Interfaces.C.size_t;
end record;
type Instance_Access is access all Instance'Class;
end Yaml.Destination.C_String;
1 change: 1 addition & 0 deletions libyaml_dropin-utils.ide.py
11 changes: 7 additions & 4 deletions libyaml_dropin.gpr
Original file line number Diff line number Diff line change
@@ -30,22 +30,25 @@ library project Libyaml_Dropin is
end Ide;

package Builder is
Default_Switches := ("-s", "-j0");
case Mode is
when "debug" =>
for Default_Switches ("ada") use ("-s", "-g");
for Default_Switches ("ada") use Default_Switches & ("-g");
when "release" =>
for Default_Switches ("ada") use ("-s");
for Default_Switches ("ada") use Default_Switches;
end case;
end Builder;

package Compiler is
Default_Switches := ("-gnat12", "-gnatwa", "-gnatwl", "-gnaty3abcefhiklmNprt", "-fstack-check");

case Mode is
when "debug" =>
for Default_Switches ("ada") use
("-gnat12", "-gnatwa", "-gnatwl", "-E", "-gnateE", "-gnaty3abcefhiklmNprt", "-g", "-fstack-check");
Default_Switches & ( "-E", "-gnateE" ,"-g");
when "release" =>
for Default_Switches ("ada") use
("-gnat12", "-gnatwa", "-gnatwl", "-O3", "-gnaty3abcefhiklmNprt", "-fstack-check", "-fno-strict-aliasing");
Default_Switches & ("-O3", "-fno-strict-aliasing");
end case;
end Compiler;
end Libyaml_Dropin;
1 change: 1 addition & 0 deletions libyaml_dropin.ide.py
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@
-- released under the terms of the MIT license, see the file "copying.txt"

with Yaml.Events.Context;
private with Yaml.Events.Store;

package body Yaml.Transformator.Annotation.Vars is
procedure Put (Object : in out Instance; E : Event) is
@@ -17,45 +18,45 @@ package body Yaml.Transformator.Annotation.Vars is
return (others => <>);
end Next;

function New_Vars (Pool : Text.Pool.Reference;
Node_Context : Node_Context_Type;
Processor_Context : Events.Context.Reference;
Swallows_Previous : out Boolean)
return not null Pointer is
function New_Vars
(Pool : Text.Pool.Reference; Node_Context : Node_Context_Type;
Processor_Context : Events.Context.Reference;
Swallows_Previous : out Boolean) return not null Pointer
is
pragma Unreferenced (Pool);
begin
if Node_Context /= Document_Root then
raise Annotation_Error with
"@@vars may only be applied to a document's root node";
raise Annotation_Error
with "@@vars may only be applied to a document's root node";
end if;
Swallows_Previous := True;
return new Instance'(Transformator.Instance with
Context => Processor_Context, others => <>);
return
new Instance'
(Transformator.Instance with Context => Processor_Context,
others => <>);
end New_Vars;

procedure Initial (Object : in out Instance; E : Event) is
begin
if E.Kind /= Annotation_Start then
raise Stream_Error with
"unexpected token (expected annotation start): " & E.Kind'Img;
raise Stream_Error
with "unexpected token (expected annotation start): " & E.Kind'Img;
end if;
Object.State := After_Annotation_Start'Access;
end Initial;

procedure After_Annotation_Start (Object : in out Instance; E : Event) is
begin
if E.Kind /= Annotation_End then
raise Annotation_Error with
"@@vars does not take any parameters.";
raise Annotation_Error with "@@vars does not take any parameters.";
end if;
Object.State := After_Annotation_End'Access;
end After_Annotation_Start;

procedure After_Annotation_End (Object : in out Instance; E : Event) is
begin
if E.Kind /= Mapping_Start then
raise Annotation_Error with
"@@vars must be applied on a mapping.";
raise Annotation_Error with "@@vars must be applied on a mapping.";
end if;
Object.State := At_Mapping_Level'Access;
end After_Annotation_End;
@@ -65,12 +66,12 @@ package body Yaml.Transformator.Annotation.Vars is
case E.Kind is
when Scalar =>
Object.Cur_Name := E.Content;
Object.State := Inside_Value'Access;
Object.State := Inside_Value'Access;
when Mapping_End =>
Object.State := After_Mapping_End'Access;
when others =>
raise Annotation_Error with
"mapping annotated with @@vars must only have scalar keys";
raise Annotation_Error
with "mapping annotated with @@vars must only have scalar keys";
end case;
end At_Mapping_Level;

@@ -90,17 +91,18 @@ package body Yaml.Transformator.Annotation.Vars is
Object.Cur_Name;
when Alias =>
declare
Pos : constant Events.Context.Cursor
:= Events.Context.Position (Object.Context, E.Target);
Pos : constant Events.Context.Cursor :=
Events.Context.Position (Object.Context, E.Target);
begin
if Events.Context.Location (Pos) = Events.Context.None then
raise Annotation_Error with
"unresolvable alias: *" & E.Target;
if Events.Context.Location (Pos) = Events.Context.None
then
raise Annotation_Error
with "unresolvable alias: *" & E.Target;
end if;
declare
Referenced_Events :
constant Events.Store.Stream_Reference :=
Events.Context.Retrieve (Pos);
Referenced_Events : constant Events.Store
.Stream_Reference :=
Events.Context.Retrieve (Pos);
Depth : Natural := 0;
begin
Modified_Event := Referenced_Events.Value.Next;
@@ -112,18 +114,20 @@ package body Yaml.Transformator.Annotation.Vars is
Modified_Event.Scalar_Properties.Anchor :=
Object.Cur_Name;
when others =>
raise Program_Error with
"alias referenced " & Modified_Event.Kind'Img;
raise Program_Error
with "alias referenced " &
Modified_Event.Kind'Img;
end case;
loop
Object.Context.Stream_Store.Memorize
(Modified_Event);
case Modified_Event.Kind is
when Mapping_Start | Sequence_Start =>
Depth := Depth + 1;
when Mapping_End | Sequence_End =>
Depth := Depth - 1;
when others => null;
when Mapping_Start | Sequence_Start =>
Depth := Depth + 1;
when Mapping_End | Sequence_End =>
Depth := Depth - 1;
when others =>
null;
end case;
exit when Depth = 0;
Modified_Event := Referenced_Events.Value.Next;
@@ -133,25 +137,25 @@ package body Yaml.Transformator.Annotation.Vars is
Object.State := At_Mapping_Level'Access;
return;
when others =>
raise Stream_Error with
"Unexpected event (expected node start): " & E.Kind'Img;
raise Stream_Error
with "Unexpected event (expected node start): " &
E.Kind'Img;
end case;
Object.Cur_Queue.Append (Modified_Event);
end;
elsif E.Kind = Alias then
declare
Pos : constant Events.Context.Cursor
:= Events.Context.Position (Object.Context, E.Target);
Pos : constant Events.Context.Cursor :=
Events.Context.Position (Object.Context, E.Target);
begin
if Events.Context.Location (Pos) = Events.Context.None then
raise Annotation_Error with
"unresolvable alias: *" & E.Target;
raise Annotation_Error with "unresolvable alias: *" & E.Target;
end if;
declare
Referenced_Events : constant Events.Store.Stream_Reference :=
Events.Context.Retrieve (Pos);
Depth : Natural := 0;
Cur_Event : Event := Referenced_Events.Value.Next;
Depth : Natural := 0;
Cur_Event : Event := Referenced_Events.Value.Next;
begin
loop
Object.Cur_Queue.Append (Cur_Event);
@@ -160,7 +164,8 @@ package body Yaml.Transformator.Annotation.Vars is
Depth := Depth + 1;
when Mapping_End | Sequence_End =>
Depth := Depth - 1;
when others => null;
when others =>
null;
end case;
exit when Depth = 0;
Cur_Event := Referenced_Events.Value.Next;
@@ -176,12 +181,12 @@ package body Yaml.Transformator.Annotation.Vars is
return;
when Mapping_End | Sequence_End =>
Object.Depth := Object.Depth - 1;
when others => null;
when others =>
null;
end case;
if Object.Depth = 0 then
loop
Object.Context.Stream_Store.Memorize
(Object.Cur_Queue.First);
Object.Context.Stream_Store.Memorize (Object.Cur_Queue.First);
Object.Cur_Queue.Dequeue;
exit when Object.Cur_Queue.Length = 0;
end loop;
@@ -191,8 +196,8 @@ package body Yaml.Transformator.Annotation.Vars is

procedure After_Mapping_End (Object : in out Instance; E : Event) is
begin
raise Constraint_Error with
"unexpected input to @@vars (already finished)";
raise Constraint_Error
with "unexpected input to @@vars (already finished)";
end After_Mapping_End;
begin
Map.Include ("vars", New_Vars'Access);
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
-- part of AdaYaml, (c) 2017 Felix Krause
-- released under the terms of the MIT license, see the file "copying.txt"

private with Yaml.Events.Store;
private with Yaml.Events.Queue;

package Yaml.Transformator.Annotation.Vars is
@@ -13,14 +12,13 @@ package Yaml.Transformator.Annotation.Vars is

overriding function Next (Object : in out Instance) return Event;

function New_Vars (Pool : Text.Pool.Reference;
Node_Context : Node_Context_Type;
Processor_Context : Events.Context.Reference;
Swallows_Previous : out Boolean)
return not null Pointer;
function New_Vars
(Pool : Text.Pool.Reference; Node_Context : Node_Context_Type;
Processor_Context : Events.Context.Reference;
Swallows_Previous : out Boolean) return not null Pointer;
private
type State_Type is not null access procedure (Object : in out Instance;
E : Event);
type State_Type is not null access procedure
(Object : in out Instance; E : Event);

procedure Initial (Object : in out Instance; E : Event);
procedure After_Annotation_Start (Object : in out Instance; E : Event);
@@ -30,10 +28,10 @@ private
procedure After_Mapping_End (Object : in out Instance; E : Event);

type Instance is limited new Transformator.Instance with record
Context : Events.Context.Reference;
Depth : Natural := 0;
State : State_Type := Initial'Access;
Context : Events.Context.Reference;
Depth : Natural := 0;
State : State_Type := Initial'Access;
Cur_Queue : Events.Queue.Instance;
Cur_Name : Text.Reference;
Cur_Name : Text.Reference;
end record;
end Yaml.Transformator.Annotation.Vars;
Loading