@@ -26,6 +26,7 @@ with LSP_Gen.String_Sets;
2626package body LSP_Gen.Inputs is
2727
2828 use type VSS.Strings.Virtual_String;
29+ use type VSS.Strings.Hash_Type;
2930 use all type LSP_Gen.Entities.Enum.AType_Variant;
3031 use all type LSP_Gen.Entities.Enum.BaseTypes;
3132
@@ -57,7 +58,8 @@ package body LSP_Gen.Inputs is
5758 Done : LSP_Gen.Dependencies.Dependency_Map;
5859 Name : VSS.Strings.Virtual_String;
5960 Tipe : LSP_Gen.Entities.AType;
60- Spec : Boolean);
61+ Spec : Boolean := False;
62+ Stub : Boolean := False);
6163
6264 function Get_Type_Map
6365 (Model : LSP_Gen.Meta_Models.Meta_Model;
@@ -589,10 +591,27 @@ package body LSP_Gen.Inputs is
589591
590592 procedure Write
591593 (Model : LSP_Gen.Meta_Models.Meta_Model;
592- Done : LSP_Gen.Dependencies.Dependency_Map) is
594+ Done : LSP_Gen.Dependencies.Dependency_Map)
595+ is
596+ function Filter_Message
597+ (Item : LSP_Gen.Dependencies.Dependency_Info) return Boolean is
598+ (Item.Is_Message
599+ or else Item.Short_Name = " ConfigurationParams"
600+ or else Item.Short_Name = " Integer_Or_Virtual_String" );
601+
602+ function Filter_Private
603+ (Tipe : LSP_Gen.Entities.AType;
604+ Item : LSP_Gen.Dependencies.Dependency_Info) return Boolean is
605+ (not Filter_Message (Item)
606+ and then Item.Owner.Is_Empty
607+ and then (Tipe.Union.Kind /= reference or else
608+ not Model.Is_Mixin (Tipe.Union.reference.name)));
609+
593610 begin
611+ -- Generating spec: LSP.Inputs
594612 Put_Lines (Model.License_Header, " -- " );
595613 New_Line;
614+ Put_Line (" with Interfaces;" );
596615 Put_Line (" with VSS.JSON.Pull_Readers;" );
597616 New_Line;
598617 Put_Line (" with LSP.Enumerations;" );
@@ -602,10 +621,7 @@ package body LSP_Gen.Inputs is
602621 -- Put_Line (" pragma Preelaborate;"); New_Line;
603622
604623 for Item of Done loop
605- if Item.Is_Message
606- or else Item.Short_Name = " ConfigurationParams"
607- or else Item.Short_Name = " Integer_Or_Virtual_String"
608- then
624+ if Filter_Message (Item) then
609625 Write_Subprogram_Definition
610626 (Item.Short_Name,
611627 (if Model.Is_Enumeration (Item.Short_Name)
@@ -616,21 +632,7 @@ package body LSP_Gen.Inputs is
616632 end if ;
617633 end loop ;
618634
619- Put_Line (" end LSP.Inputs;" );
620-
621- Put_Lines (Model.License_Header, " -- " );
622- New_Line;
623- Put_Line (" pragma Ada_2022;" );
624- Put_Line (" with Interfaces;" );
625- Put_Line (" with LSP.Input_Tools;" );
626- Put_Line (" with VSS.Strings;" );
627- Put_Line (" with VSS.JSON.Pull_Readers.Buffered;" );
628- Put_Line (" with Minimal_Perfect_Hash;" );
629- New_Line;
630-
631- Put_Line (" package body LSP.Inputs is" ); New_Line;
632- Put_Line (" pragma Warnings (Off, "" is not referenced"" );" );
633- Put_Line (" use type Interfaces.Integer_64;" ); New_Line;
635+ Put_Line (" private" );
634636
635637 for Cursor in Done.Iterate loop
636638 declare
@@ -639,59 +641,160 @@ package body LSP_Gen.Inputs is
639641 Item : constant LSP_Gen.Dependencies.Dependency_Info :=
640642 Done (Cursor);
641643 begin
642- if not Item.Is_Message
643- and then Item.Short_Name /= " ConfigurationParams"
644- and then Item.Short_Name /= " Integer_Or_Virtual_String"
645- and then Item.Owner.Is_Empty
646- and then (Tipe.Union.Kind /= reference or else
647- not Model.Is_Mixin (Tipe.Union.reference.name))
648- then
644+ if Filter_Private (Tipe, Item) then
649645 Write_Type (Model, Done, Item.Short_Name, Tipe, Spec => True);
650646 end if ;
651647 end ;
652648 end loop ;
653649
650+ Put (" function "" -"" (L, R : Interfaces.Integer_64) " );
651+ Put_Line (" return Interfaces.Integer_64" );
652+ Put_Line (" renames Interfaces."" -"" ;" ); New_Line;
653+
654+ Put (" function "" +"" (L, R : Interfaces.Integer_64) " );
655+ Put_Line (" return Interfaces.Integer_64" );
656+ Put_Line (" renames Interfaces."" +"" ;" ); New_Line;
657+
658+ Put_Line (" end LSP.Inputs;" );
659+
660+ -- Generating body: LSP.Inputs
661+
662+ Put_Lines (Model.License_Header, " -- " );
663+ New_Line;
664+
665+ for J in 1 .. Part_Count loop
666+ Put (" with LSP.Inputs.Part_" );
667+ Put (J);
668+ Put_Line (" ;" );
669+ end loop ;
670+
671+ New_Line;
672+ Put_Line (" package body LSP.Inputs is" );
673+
654674 for Cursor in Done.Iterate loop
655675 declare
656676 Tipe : constant LSP_Gen.Entities.AType :=
657677 LSP_Gen.Dependencies.Dependency_Maps.Key (Cursor);
658678 Item : constant LSP_Gen.Dependencies.Dependency_Info :=
659679 Done (Cursor);
660680 begin
661- if Tipe.Union.Kind = reference then
662- declare
663- Value : constant LSP_Gen.Meta_Models.Top_Type :=
664- Model.Get (Tipe.Union.reference.name);
665- begin
666- case Value.Kind is
667- when LSP_Gen.Meta_Models.Structure =>
668- if not Model.Is_Mixin (Tipe.Union.reference.name) then
669- Write_Type_Map (Model, Done, Tipe, Item.Short_Name);
670- Write_Structure
671- (Model, Done, Tipe.Union.reference.name);
672- end if ;
673- when LSP_Gen.Meta_Models.Type_Alias =>
674- Write_Type_Map
675- (Model,
676- Done,
677- Value.Type_Alias.a_type,
678- Item.Short_Name);
679-
680- Write_Type
681- (Model, Done, Tipe.Union.reference.name,
682- Value.Type_Alias.a_type, Spec => False);
683- when LSP_Gen.Meta_Models.Enumeration =>
684- Write_Enum (Value.Enumeration, Spec => False);
685- end case ;
686- end ;
687- elsif Item.Owner.Is_Empty then
688- Write_Type_Map (Model, Done, Tipe, Item.Short_Name);
689- Write_Type (Model, Done, Item.Short_Name, Tipe, Spec => False);
681+ if Filter_Message (Item) or else Filter_Private (Tipe, Item) then
682+ -- Generate procedure NAME renames Part_X.NAME;
683+ Write_Type (Model, Done, Item.Short_Name, Tipe, Stub => True);
690684 end if ;
691685 end ;
692686 end loop ;
693687
694688 Put_Line (" end LSP.Inputs;" );
689+
690+ -- Generating spec: LSP.Inputs.Part_X
691+ for J in 1 .. Part_Count loop
692+ Put_Lines (Model.License_Header, " -- " );
693+ New_Line;
694+ Put (" package LSP.Inputs.Part_" );
695+ Put (J);
696+ Put_Line (" is" ); New_Line;
697+
698+ for Cursor in Done.Iterate loop
699+ declare
700+ Tipe : constant LSP_Gen.Entities.AType :=
701+ LSP_Gen.Dependencies.Dependency_Maps.Key (Cursor);
702+ Item : constant LSP_Gen.Dependencies.Dependency_Info :=
703+ Done (Cursor);
704+ begin
705+ if Natural (Item.Short_Name.Hash mod Part_Count) = J - 1
706+ and then
707+ (Filter_Message (Item) or else Filter_Private (Tipe, Item))
708+ then
709+ Write_Type
710+ (Model, Done, Item.Short_Name, Tipe, Spec => True);
711+ end if ;
712+ end ;
713+ end loop ;
714+
715+ Put (" end LSP.Inputs.Part_" );
716+ Put (J);
717+ Put_Line (" ;" );
718+ end loop ;
719+
720+ -- Generating body: LSP.Inputs.Part_X
721+ for J in 1 .. Part_Count loop
722+ Put_Lines (Model.License_Header, " -- " );
723+ New_Line;
724+ Put_Line (" pragma Ada_2022;" );
725+ Put_Line (" pragma Warnings (Off, "" is not referenced"" );" );
726+ Put_Line (" with Interfaces;" );
727+ Put_Line (" with LSP.Input_Tools;" );
728+ Put_Line (" with VSS.Strings;" );
729+ Put_Line (" with VSS.JSON.Pull_Readers.Buffered;" );
730+ Put_Line (" with Minimal_Perfect_Hash;" );
731+ New_Line;
732+
733+ Put (" package body LSP.Inputs.Part_" );
734+ Put (J);
735+ Put_Line (" is" );
736+ New_Line;
737+
738+ for Cursor in Done.Iterate loop
739+ declare
740+ Tipe : constant LSP_Gen.Entities.AType :=
741+ LSP_Gen.Dependencies.Dependency_Maps.Key (Cursor);
742+ Item : constant LSP_Gen.Dependencies.Dependency_Info :=
743+ Done (Cursor);
744+ begin
745+ if Natural (Item.Short_Name.Hash mod Part_Count) /= J - 1
746+ or else
747+ (not Filter_Message (Item)
748+ and then not Filter_Private (Tipe, Item))
749+ then
750+ null ; -- Skip
751+
752+ elsif Tipe.Union.Kind = reference then
753+ declare
754+ Value : constant LSP_Gen.Meta_Models.Top_Type :=
755+ Model.Get (Tipe.Union.reference.name);
756+ begin
757+ case Value.Kind is
758+
759+ when LSP_Gen.Meta_Models.Structure =>
760+ if not
761+ Model.Is_Mixin (Tipe.Union.reference.name)
762+ then
763+ Write_Type_Map
764+ (Model, Done, Tipe, Item.Short_Name);
765+
766+ Write_Structure
767+ (Model, Done, Tipe.Union.reference.name);
768+ end if ;
769+
770+ when LSP_Gen.Meta_Models.Type_Alias =>
771+ Write_Type_Map
772+ (Model,
773+ Done,
774+ Value.Type_Alias.a_type,
775+ Item.Short_Name);
776+
777+ Write_Type
778+ (Model, Done, Tipe.Union.reference.name,
779+ Value.Type_Alias.a_type, Spec => False);
780+
781+ when LSP_Gen.Meta_Models.Enumeration =>
782+ Write_Enum (Value.Enumeration, Spec => False);
783+ end case ;
784+ end ;
785+ elsif Item.Owner.Is_Empty then
786+ Write_Type_Map (Model, Done, Tipe, Item.Short_Name);
787+
788+ Write_Type
789+ (Model, Done, Item.Short_Name, Tipe, Spec => False);
790+ end if ;
791+ end ;
792+ end loop ;
793+
794+ Put (" end LSP.Inputs.Part_" );
795+ Put (J);
796+ Put_Line (" ;" );
797+ end loop ;
695798 end Write ;
696799
697800 -- --------------
@@ -1574,7 +1677,8 @@ package body LSP_Gen.Inputs is
15741677 Done : LSP_Gen.Dependencies.Dependency_Map;
15751678 Name : VSS.Strings.Virtual_String;
15761679 Tipe : LSP_Gen.Entities.AType;
1577- Spec : Boolean)
1680+ Spec : Boolean := False;
1681+ Stub : Boolean := False)
15781682 is
15791683 use all type LSP_Gen.Mappings.Or_Mapping_Kind;
15801684
@@ -1606,6 +1710,13 @@ package body LSP_Gen.Inputs is
16061710
16071711 if Spec then
16081712 Put_Line (" ;" );
1713+ elsif Stub then
1714+ New_Line;
1715+ Put (" renames Part_" );
1716+ Put (Natural (Name.Hash mod Part_Count) + 1 );
1717+ Put (" .Read_" );
1718+ Put (Name);
1719+ Put_Line (" ;" );
16091720 elsif Tipe.Union.Kind = reference then
16101721 Put_Line (" renames" );
16111722 Write_Subprogram_Name (Done, Tipe);
0 commit comments