diff --git a/.gitignore b/.gitignore index d4686c2..5de8ba5 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,4 @@ cvg messages.txt *.cgpr +.clang-format diff --git a/dropin/src/yaml-destination-c_string.adb b/dropin/src/yaml-destination-c_string.adb index fb6582f..33fc32f 100644 --- a/dropin/src/yaml-destination-c_string.adb +++ b/dropin/src/yaml-destination-c_string.adb @@ -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); diff --git a/dropin/src/yaml-destination-c_string.ads b/dropin/src/yaml-destination-c_string.ads index c1e2951..3e2fea2 100644 --- a/dropin/src/yaml-destination-c_string.ads +++ b/dropin/src/yaml-destination-c_string.ads @@ -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; diff --git a/libyaml_dropin-utils.ide.py b/libyaml_dropin-utils.ide.py new file mode 120000 index 0000000..bc3507c --- /dev/null +++ b/libyaml_dropin-utils.ide.py @@ -0,0 +1 @@ +yaml_all_ide.py \ No newline at end of file diff --git a/libyaml_dropin.gpr b/libyaml_dropin.gpr index f454a8c..425198d 100644 --- a/libyaml_dropin.gpr +++ b/libyaml_dropin.gpr @@ -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; diff --git a/libyaml_dropin.ide.py b/libyaml_dropin.ide.py new file mode 120000 index 0000000..bc3507c --- /dev/null +++ b/libyaml_dropin.ide.py @@ -0,0 +1 @@ +yaml_all_ide.py \ No newline at end of file diff --git a/src/annotation_processor/implementation/yaml-transformator-annotation-vars.adb b/src/annotation_processor/implementation/yaml-transformator-annotation-vars.adb index 6edcd94..c73437f 100644 --- a/src/annotation_processor/implementation/yaml-transformator-annotation-vars.adb +++ b/src/annotation_processor/implementation/yaml-transformator-annotation-vars.adb @@ -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,27 +18,29 @@ 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; @@ -45,8 +48,7 @@ package body Yaml.Transformator.Annotation.Vars is 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; @@ -54,8 +56,7 @@ package body Yaml.Transformator.Annotation.Vars is 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); diff --git a/src/annotation_processor/implementation/yaml-transformator-annotation-vars.ads b/src/annotation_processor/implementation/yaml-transformator-annotation-vars.ads index 168e8c4..7363472 100644 --- a/src/annotation_processor/implementation/yaml-transformator-annotation-vars.ads +++ b/src/annotation_processor/implementation/yaml-transformator-annotation-vars.ads @@ -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; diff --git a/src/interface/yaml.ads b/src/interface/yaml.ads index 820d922..aaaa741 100644 --- a/src/interface/yaml.ads +++ b/src/interface/yaml.ads @@ -32,28 +32,30 @@ package Yaml is -- the version of the library. major and minor version correspond to the -- YAML version, the patch version is local to this implementation. - function Version_Major return Natural with Inline; - function Version_Minor return Natural with Inline; - function Version_Patch return Natural with Inline; - - - -- all positions in a mark start at 1 + function Version_Major return Natural with + Inline; + function Version_Minor return Natural with + Inline; + function Version_Patch return Natural with + Inline; + + -- all positions in a mark start at 1 subtype Mark_Position is Positive; -- a position in the input stream. type Mark is record - Index, Line, Column : Mark_Position; + Index, Line, Column : Mark_Position := 1; end record; - type Event_Kind is (Stream_Start, Stream_End, Document_Start, Document_End, - Alias, Scalar, Sequence_Start, Sequence_End, - Mapping_Start, Mapping_End, Annotation_Start, - Annotation_End); + type Event_Kind is + (Stream_Start, Stream_End, Document_Start, Document_End, Alias, Scalar, + Sequence_Start, Sequence_End, Mapping_Start, Mapping_End, + Annotation_Start, Annotation_End); type Collection_Style_Type is (Any, Block, Flow) with - Convention => C; + Convention => C; type Scalar_Style_Type is (Any, Plain, Single_Quoted, Double_Quoted, Literal, Folded) with - Convention => C; + Convention => C; subtype Flow_Scalar_Style_Type is Scalar_Style_Type range Literal .. Folded; type Properties is record @@ -62,7 +64,8 @@ package Yaml is function Default_Properties return Properties; - function Is_Empty (Props : Properties) return Boolean with Inline; + function Is_Empty (Props : Properties) return Boolean with + Inline; type Event (Kind : Event_Kind := Stream_End) is record -- Start_Position is first character, End_Position is after last @@ -70,25 +73,26 @@ package Yaml is Start_Position, End_Position : Mark; case Kind is when Document_Start => - Version : Text.Reference; + Version : Text.Reference; Implicit_Start : Boolean := True; when Document_End => Implicit_End : Boolean; when Mapping_Start | Sequence_Start => - Collection_Style : Collection_Style_Type := Any; + Collection_Style : Collection_Style_Type := Any; Collection_Properties : Properties; when Annotation_Start => Annotation_Properties : Properties; - Namespace : Text.Reference; - Name : Text.Reference; + Namespace : Text.Reference; + Name : Text.Reference; when Scalar => Scalar_Properties : Properties; - Content : Text.Reference; - Scalar_Style : Scalar_Style_Type := Any; + Content : Text.Reference; + Scalar_Style : Scalar_Style_Type := Any; when Alias => Target : Text.Reference; when Mapping_End | Sequence_End | Annotation_End | Stream_Start | - Stream_End => null; + Stream_End => + null; end case; end record; @@ -96,19 +100,19 @@ package Yaml is Standard_Annotation_Namespace : constant Text.Reference; - -- base type for refcounted types (mainly event streams). all streams and - -- some other objects can be used with reference-counting smart pointers, so - -- this base type implements the reference counting. note that this type - -- does not have any stream semantic; that is to be implemented by child - -- types by providing a Stream_Concept instance (if they are streams). +-- base type for refcounted types (mainly event streams). all streams and +-- some other objects can be used with reference-counting smart pointers, so +-- this base type implements the reference counting. note that this type +-- does not have any stream semantic; that is to be implemented by child +-- types by providing a Stream_Concept instance (if they are streams). -- - -- beware that this type is only the vessel for the reference count and does - -- not do any reference counting itself; the reference-counting management - -- functions must be called from a smart pointer type. An object of a child - -- type can be used on the stack, in which case the reference count is not - -- used and instead the object just goes out of scope. - type Refcount_Base is abstract limited new - Ada.Finalization.Limited_Controlled with private; +-- beware that this type is only the vessel for the reference count and does +-- not do any reference counting itself; the reference-counting management +-- functions must be called from a smart pointer type. An object of a child +-- type can be used on the stack, in which case the reference count is not +-- used and instead the object just goes out of scope. + type Refcount_Base is + abstract limited new Ada.Finalization.Limited_Controlled with private; -- increases reference count. only call this explicitly when implementing -- a reference-counting smart pointer. @@ -123,11 +127,12 @@ private Standard_Annotation_Namespace_Holder : constant Text.Constant_Instance := Text.Hold ("@@"); - Standard_Annotation_Namespace : constant Text.Reference := Text.Held - (Standard_Annotation_Namespace_Holder); + Standard_Annotation_Namespace : constant Text.Reference := + Text.Held (Standard_Annotation_Namespace_Holder); - type Refcount_Base is abstract limited new - Ada.Finalization.Limited_Controlled with record + type Refcount_Base is abstract limited new Ada.Finalization + .Limited_Controlled with + record Refcount : Natural := 1; end record; end Yaml; diff --git a/yaml-annotation_processor.ide.py b/yaml-annotation_processor.ide.py new file mode 120000 index 0000000..bc3507c --- /dev/null +++ b/yaml-annotation_processor.ide.py @@ -0,0 +1 @@ +yaml_all_ide.py \ No newline at end of file diff --git a/yaml-server.ide.py b/yaml-server.ide.py new file mode 120000 index 0000000..bc3507c --- /dev/null +++ b/yaml-server.ide.py @@ -0,0 +1 @@ +yaml_all_ide.py \ No newline at end of file diff --git a/yaml-tests.ide.py b/yaml-tests.ide.py new file mode 120000 index 0000000..bc3507c --- /dev/null +++ b/yaml-tests.ide.py @@ -0,0 +1 @@ +yaml_all_ide.py \ No newline at end of file diff --git a/yaml-utils.ide.py b/yaml-utils.ide.py new file mode 120000 index 0000000..bc3507c --- /dev/null +++ b/yaml-utils.ide.py @@ -0,0 +1 @@ +yaml_all_ide.py \ No newline at end of file diff --git a/yaml.gpr b/yaml.gpr index b10b5fb..93b81ca 100644 --- a/yaml.gpr +++ b/yaml.gpr @@ -23,21 +23,23 @@ library project Yaml is when "debug" => for Default_Switches ("ada") use Builder'Default_Switches ("ada") & ("-g"); when "release" => - null; + for Default_Switches ("ada") use Builder'Default_Switches ("ada"); end case; end Builder; package Compiler is for Default_Switches ("ada") use - ("-gnat12", "-gnatwa", "-gnatwl", "-gnata", "-gnaty3abcefhiklmNprt", "-fstack-check"); + ("-gnat12", "-gnatwa", "-gnatwl", "-gnaty3abcefhiklmNprt"); case Mode is when "debug" => for Default_Switches ("ada") use Compiler'Default_Switches ("ada") & - ("-gnata", "-gnateE", "-E", "-g"); + ("-gnata", "-gnateE", "-g", "-fstack-check"); + when "release" => for Default_Switches ("ada") use - ("-O3" ); + Compiler'Default_Switches ("ada") & ("-O3" ); end case; end Compiler; + end Yaml; diff --git a/yaml.ide.py b/yaml.ide.py new file mode 120000 index 0000000..bc3507c --- /dev/null +++ b/yaml.ide.py @@ -0,0 +1 @@ +yaml_all_ide.py \ No newline at end of file diff --git a/yaml_all.ide.py b/yaml_all.ide.py new file mode 120000 index 0000000..bc3507c --- /dev/null +++ b/yaml_all.ide.py @@ -0,0 +1 @@ +yaml_all_ide.py \ No newline at end of file diff --git a/yaml_all_ide.py b/yaml_all_ide.py new file mode 100644 index 0000000..dac66ae --- /dev/null +++ b/yaml_all_ide.py @@ -0,0 +1,9 @@ +import GPS + + +def finalize_project_plugin(): + pass + + +def initialize_project_plugin(): + pass