From 361dcac70cb4cb88622b8d1d2309157b33d38331 Mon Sep 17 00:00:00 2001 From: Vadim Godunko Date: Mon, 18 Dec 2023 12:44:33 +0400 Subject: [PATCH 01/12] Transformer API. --- source/text/implementation/vss-strings.adb | 24 ++++++++++++++++++++ source/text/vss-strings.ads | 12 ++++++++++ source/text/vss-transformers.ads | 26 ++++++++++++++++++++++ 3 files changed, 62 insertions(+) create mode 100644 source/text/vss-transformers.ads diff --git a/source/text/implementation/vss-strings.adb b/source/text/implementation/vss-strings.adb index 56775084..028926a5 100644 --- a/source/text/implementation/vss-strings.adb +++ b/source/text/implementation/vss-strings.adb @@ -17,6 +17,7 @@ with VSS.Strings.Cursors.Iterators.Grapheme_Clusters; with VSS.Strings.Cursors.Iterators.Lines; with VSS.Strings.Cursors.Iterators.Words; with VSS.String_Vectors.Internals; +with VSS.Transformers; package body VSS.Strings is @@ -1367,6 +1368,29 @@ package body VSS.Strings is end return; end To_Virtual_String; + --------------- + -- Transform -- + --------------- + + function Transform + (Self : Virtual_String'Class; + Transformer : VSS.Transformers.Abstract_Transformer'Class) + return Virtual_String is + begin + return Transformer.Transform (Self); + end Transform; + + --------------- + -- Transform -- + --------------- + + procedure Transform + (Self : in out Virtual_String'Class; + Transformer : VSS.Transformers.Abstract_Transformer'Class) is + begin + Transformer.Transform (Self); + end Transform; + ----------- -- Write -- ----------- diff --git a/source/text/vss-strings.ads b/source/text/vss-strings.ads index 69a824b6..40d3094f 100644 --- a/source/text/vss-strings.ads +++ b/source/text/vss-strings.ads @@ -19,6 +19,7 @@ limited with VSS.Strings.Cursors.Iterators.Characters; limited with VSS.Strings.Cursors.Iterators.Grapheme_Clusters; limited with VSS.Strings.Cursors.Iterators.Lines; limited with VSS.Strings.Cursors.Iterators.Words; +limited with VSS.Transformers; package VSS.Strings is @@ -469,6 +470,17 @@ package VSS.Strings is (Buffer : in out Ada.Strings.Text_Buffers.Root_Buffer_Type'Class; Item : Virtual_String); + function Transform + (Self : Virtual_String'Class; + Transformer : VSS.Transformers.Abstract_Transformer'Class) + return Virtual_String; + -- Transform given text using given text transformer. + + procedure Transform + (Self : in out Virtual_String'Class; + Transformer : VSS.Transformers.Abstract_Transformer'Class); + -- Transform given text using given text transformer. + private type Magic_String_Access is access all Virtual_String'Class; diff --git a/source/text/vss-transformers.ads b/source/text/vss-transformers.ads new file mode 100644 index 00000000..0a92cb48 --- /dev/null +++ b/source/text/vss-transformers.ads @@ -0,0 +1,26 @@ +-- +-- Copyright (C) 2023, AdaCore +-- +-- SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +-- + +-- Generic API to transform text data. + +with VSS.Strings; + +package VSS.Transformers is + + pragma Preelaborate; + + type Abstract_Transformer is limited interface; + + not overriding function Transform + (Self : Abstract_Transformer; + Item : VSS.Strings.Virtual_String'Class) + return VSS.Strings.Virtual_String is abstract; + + not overriding procedure Transform + (Self : Abstract_Transformer; + Item : in out VSS.Strings.Virtual_String'Class) is abstract; + +end VSS.Transformers; From 3b1f1f7c05711b1659e2314341e9ee0b233223c1 Mon Sep 17 00:00:00 2001 From: Vadim Godunko Date: Mon, 18 Dec 2023 13:08:58 +0400 Subject: [PATCH 02/12] Normalization forms text transformer. --- .../implementation/vss-strings-internals.adb | 15 +- .../implementation/vss-strings-internals.ads | 10 +- .../vss-transformers-normalization.adb | 185 ++++++++++++++++++ .../text/vss-transformers-normalization.ads | 86 ++++++++ testsuite/text/test_string_normalization.adb | 63 ++++-- 5 files changed, 335 insertions(+), 24 deletions(-) create mode 100644 source/text/implementation/vss-transformers-normalization.adb create mode 100644 source/text/vss-transformers-normalization.ads diff --git a/source/text/implementation/vss-strings-internals.adb b/source/text/implementation/vss-strings-internals.adb index 9b2c19c3..c6900412 100644 --- a/source/text/implementation/vss-strings-internals.adb +++ b/source/text/implementation/vss-strings-internals.adb @@ -1,5 +1,5 @@ -- --- Copyright (C) 2020-2022, AdaCore +-- Copyright (C) 2020-2023, AdaCore -- -- SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -- @@ -17,6 +17,19 @@ package body VSS.Strings.Internals is return Self.Data'Unchecked_Access; end Data_Access_Constant; + ----------------- + -- Set_By_Move -- + ----------------- + + procedure Set_By_Move + (Self : in out VSS.Strings.Virtual_String'Class; + To : in out VSS.Implementation.Strings.String_Data) is + begin + VSS.Implementation.Strings.Unreference (Self.Data); + Self.Data := To; + To := (others => <>); + end Set_By_Move; + ---------------------------- -- To_Magic_String_Access -- ---------------------------- diff --git a/source/text/implementation/vss-strings-internals.ads b/source/text/implementation/vss-strings-internals.ads index ded69e8b..bc7a1cc3 100644 --- a/source/text/implementation/vss-strings-internals.ads +++ b/source/text/implementation/vss-strings-internals.ads @@ -1,5 +1,5 @@ -- --- Copyright (C) 2020-2022, AdaCore +-- Copyright (C) 2020-2023, AdaCore -- -- SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -- @@ -33,6 +33,12 @@ package VSS.Strings.Internals is return not null VSS.Strings.Internals.String_Data_Constant_Access; -- Return access to string data member of the Virtual_String. + procedure Set_By_Move + (Self : in out VSS.Strings.Virtual_String'Class; + To : in out VSS.Implementation.Strings.String_Data); + -- Set given string to given data. Initial data of the Self is + -- unreferenced, given data is copied and given value is reset. + function To_Virtual_String_Access (Item : VSS.Implementation.Referrers.Magic_String_Access) return VSS.Implementation.Referrers.Virtual_String_Access with Inline; @@ -40,6 +46,6 @@ package VSS.Strings.Internals is (Item : VSS.Implementation.Referrers.Virtual_String_Access) return VSS.Implementation.Referrers.Magic_String_Access with Inline; -- Do type conversion. It is intended to be used inside the - -- VSS.Implementation.Refrrals package. + -- VSS.Implementation.Referrals package. end VSS.Strings.Internals; diff --git a/source/text/implementation/vss-transformers-normalization.adb b/source/text/implementation/vss-transformers-normalization.adb new file mode 100644 index 00000000..0825b3b3 --- /dev/null +++ b/source/text/implementation/vss-transformers-normalization.adb @@ -0,0 +1,185 @@ +-- +-- Copyright (C) 2023, AdaCore +-- +-- SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +-- + +with VSS.Implementation.Strings; +with VSS.Implementation.UTF8_Normalization; +with VSS.Strings.Internals; + +package body VSS.Transformers.Normalization is + + --------------- + -- Transform -- + --------------- + + overriding function Transform + (Self : Normalization_Form_C_Transformer; + Item : VSS.Strings.Virtual_String'Class) + return VSS.Strings.Virtual_String + is + Aux : VSS.Implementation.Strings.String_Data; + + begin + VSS.Implementation.UTF8_Normalization.Normalize + (VSS.Strings.Internals.Data_Access_Constant (Item).all, + VSS.Strings.Normalization_Form_C, + Aux); + + return Result : constant VSS.Strings.Virtual_String := + VSS.Strings.Internals.To_Virtual_String (Aux) + do + VSS.Implementation.Strings.Unreference (Aux); + end return; + end Transform; + + --------------- + -- Transform -- + --------------- + + overriding procedure Transform + (Self : Normalization_Form_C_Transformer; + Item : in out VSS.Strings.Virtual_String'Class) + is + Aux : VSS.Implementation.Strings.String_Data; + + begin + VSS.Implementation.UTF8_Normalization.Normalize + (VSS.Strings.Internals.Data_Access_Constant (Item).all, + VSS.Strings.Normalization_Form_C, + Aux); + + VSS.Strings.Internals.Set_By_Move (Item, Aux); + end Transform; + + --------------- + -- Transform -- + --------------- + + overriding function Transform + (Self : Normalization_Form_D_Transformer; + Item : VSS.Strings.Virtual_String'Class) + return VSS.Strings.Virtual_String + is + Aux : VSS.Implementation.Strings.String_Data; + + begin + VSS.Implementation.UTF8_Normalization.Normalize + (VSS.Strings.Internals.Data_Access_Constant (Item).all, + VSS.Strings.Normalization_Form_D, + Aux); + + return Result : constant VSS.Strings.Virtual_String := + VSS.Strings.Internals.To_Virtual_String (Aux) + do + VSS.Implementation.Strings.Unreference (Aux); + end return; + end Transform; + + --------------- + -- Transform -- + --------------- + + overriding procedure Transform + (Self : Normalization_Form_D_Transformer; + Item : in out VSS.Strings.Virtual_String'Class) + is + Aux : VSS.Implementation.Strings.String_Data; + + begin + VSS.Implementation.UTF8_Normalization.Normalize + (VSS.Strings.Internals.Data_Access_Constant (Item).all, + VSS.Strings.Normalization_Form_D, + Aux); + + VSS.Strings.Internals.Set_By_Move (Item, Aux); + end Transform; + + --------------- + -- Transform -- + --------------- + + overriding function Transform + (Self : Normalization_Form_KC_Transformer; + Item : VSS.Strings.Virtual_String'Class) + return VSS.Strings.Virtual_String + is + Aux : VSS.Implementation.Strings.String_Data; + + begin + VSS.Implementation.UTF8_Normalization.Normalize + (VSS.Strings.Internals.Data_Access_Constant (Item).all, + VSS.Strings.Normalization_Form_KC, + Aux); + + return Result : constant VSS.Strings.Virtual_String := + VSS.Strings.Internals.To_Virtual_String (Aux) + do + VSS.Implementation.Strings.Unreference (Aux); + end return; + end Transform; + + --------------- + -- Transform -- + --------------- + + overriding procedure Transform + (Self : Normalization_Form_KC_Transformer; + Item : in out VSS.Strings.Virtual_String'Class) + is + Aux : VSS.Implementation.Strings.String_Data; + + begin + VSS.Implementation.UTF8_Normalization.Normalize + (VSS.Strings.Internals.Data_Access_Constant (Item).all, + VSS.Strings.Normalization_Form_KC, + Aux); + + VSS.Strings.Internals.Set_By_Move (Item, Aux); + end Transform; + + --------------- + -- Transform -- + --------------- + + overriding function Transform + (Self : Normalization_Form_KD_Transformer; + Item : VSS.Strings.Virtual_String'Class) + return VSS.Strings.Virtual_String + is + Aux : VSS.Implementation.Strings.String_Data; + + begin + VSS.Implementation.UTF8_Normalization.Normalize + (VSS.Strings.Internals.Data_Access_Constant (Item).all, + VSS.Strings.Normalization_Form_KD, + Aux); + + return Result : constant VSS.Strings.Virtual_String := + VSS.Strings.Internals.To_Virtual_String (Aux) + do + VSS.Implementation.Strings.Unreference (Aux); + end return; + end Transform; + + --------------- + -- Transform -- + --------------- + + overriding procedure Transform + (Self : Normalization_Form_KD_Transformer; + Item : in out VSS.Strings.Virtual_String'Class) + is + Aux : VSS.Implementation.Strings.String_Data; + + begin + VSS.Implementation.UTF8_Normalization.Normalize + (VSS.Strings.Internals.Data_Access_Constant (Item).all, + VSS.Strings.Normalization_Form_KD, + Aux); + + VSS.Strings.Internals.Set_By_Move (Item, Aux); + end Transform; + +end VSS.Transformers.Normalization; diff --git a/source/text/vss-transformers-normalization.ads b/source/text/vss-transformers-normalization.ads new file mode 100644 index 00000000..568437fb --- /dev/null +++ b/source/text/vss-transformers-normalization.ads @@ -0,0 +1,86 @@ +-- +-- Copyright (C) 2023, AdaCore +-- +-- SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +-- + +-- Generic API to transform text data. + +with VSS.Strings; + +package VSS.Transformers.Normalization is + + pragma Preelaborate; + + To_Normalization_Form_D : constant Abstract_Transformer'Class; + -- Transform text to Normalization Form D. + + To_Normalization_Form_C : constant Abstract_Transformer'Class; + -- Transform text to Normalization Form C. + + To_Normalization_Form_KD : constant Abstract_Transformer'Class; + -- Transform text to Normalization Form KD. + + To_Normalization_Form_KC : constant Abstract_Transformer'Class; + -- Transform text to Normalization Form KC. + +private + + type Normalization_Form_D_Transformer is + limited new Abstract_Transformer with null record; + + overriding function Transform + (Self : Normalization_Form_D_Transformer; + Item : VSS.Strings.Virtual_String'Class) + return VSS.Strings.Virtual_String; + + overriding procedure Transform + (Self : Normalization_Form_D_Transformer; + Item : in out VSS.Strings.Virtual_String'Class); + + type Normalization_Form_C_Transformer is + limited new Abstract_Transformer with null record; + + overriding function Transform + (Self : Normalization_Form_C_Transformer; + Item : VSS.Strings.Virtual_String'Class) + return VSS.Strings.Virtual_String; + + overriding procedure Transform + (Self : Normalization_Form_C_Transformer; + Item : in out VSS.Strings.Virtual_String'Class); + + type Normalization_Form_KD_Transformer is + limited new Abstract_Transformer with null record; + + overriding function Transform + (Self : Normalization_Form_KD_Transformer; + Item : VSS.Strings.Virtual_String'Class) + return VSS.Strings.Virtual_String; + + overriding procedure Transform + (Self : Normalization_Form_KD_Transformer; + Item : in out VSS.Strings.Virtual_String'Class); + + type Normalization_Form_KC_Transformer is + limited new Abstract_Transformer with null record; + + overriding function Transform + (Self : Normalization_Form_KC_Transformer; + Item : VSS.Strings.Virtual_String'Class) + return VSS.Strings.Virtual_String; + + overriding procedure Transform + (Self : Normalization_Form_KC_Transformer; + Item : in out VSS.Strings.Virtual_String'Class); + + To_Normalization_Form_D : constant Abstract_Transformer'Class := + Normalization_Form_D_Transformer'(null record); + To_Normalization_Form_C : constant Abstract_Transformer'Class := + Normalization_Form_C_Transformer'(null record); + To_Normalization_Form_KD : constant Abstract_Transformer'Class := + Normalization_Form_KD_Transformer'(null record); + To_Normalization_Form_KC : constant Abstract_Transformer'Class := + Normalization_Form_KC_Transformer'(null record); + +end VSS.Transformers.Normalization; diff --git a/testsuite/text/test_string_normalization.adb b/testsuite/text/test_string_normalization.adb index f54a34fb..c2201b59 100644 --- a/testsuite/text/test_string_normalization.adb +++ b/testsuite/text/test_string_normalization.adb @@ -1,5 +1,5 @@ -- --- Copyright (C) 2021, AdaCore +-- Copyright (C) 2021-2023, AdaCore -- -- SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -- @@ -9,6 +9,7 @@ with Ada.Strings.UTF_Encoding.Wide_Wide_Strings; with VSS.Characters; with VSS.Strings; +with VSS.Transformers.Normalization; with UCD.Data_File_Loaders; @@ -79,15 +80,20 @@ begin declare C1N : constant VSS.Strings.Virtual_String := - C1.To_Normalized (VSS.Strings.Normalization_Form_C); + VSS.Transformers.Normalization.To_Normalization_Form_C + .Transform (C1); C2N : constant VSS.Strings.Virtual_String := - C2.To_Normalized (VSS.Strings.Normalization_Form_C); + VSS.Transformers.Normalization.To_Normalization_Form_C + .Transform (C2); C3N : constant VSS.Strings.Virtual_String := - C3.To_Normalized (VSS.Strings.Normalization_Form_C); + VSS.Transformers.Normalization.To_Normalization_Form_C + .Transform (C3); C4N : constant VSS.Strings.Virtual_String := - C4.To_Normalized (VSS.Strings.Normalization_Form_C); + VSS.Transformers.Normalization.To_Normalization_Form_C + .Transform (C4); C5N : constant VSS.Strings.Virtual_String := - C5.To_Normalized (VSS.Strings.Normalization_Form_C); + VSS.Transformers.Normalization.To_Normalization_Form_C + .Transform (C4); begin Test_Support.Assert (C2 = C1N); @@ -101,15 +107,20 @@ begin declare C1N : constant VSS.Strings.Virtual_String := - C1.To_Normalized (VSS.Strings.Normalization_Form_D); + VSS.Transformers.Normalization.To_Normalization_Form_D + .Transform (C1); C2N : constant VSS.Strings.Virtual_String := - C2.To_Normalized (VSS.Strings.Normalization_Form_D); + VSS.Transformers.Normalization.To_Normalization_Form_D + .Transform (C2); C3N : constant VSS.Strings.Virtual_String := - C3.To_Normalized (VSS.Strings.Normalization_Form_D); + VSS.Transformers.Normalization.To_Normalization_Form_D + .Transform (C3); C4N : constant VSS.Strings.Virtual_String := - C4.To_Normalized (VSS.Strings.Normalization_Form_D); + VSS.Transformers.Normalization.To_Normalization_Form_D + .Transform (C4); C5N : constant VSS.Strings.Virtual_String := - C5.To_Normalized (VSS.Strings.Normalization_Form_D); + VSS.Transformers.Normalization.To_Normalization_Form_D + .Transform (C5); begin Test_Support.Assert (C3 = C1N); @@ -123,15 +134,20 @@ begin declare C1N : constant VSS.Strings.Virtual_String := - C1.To_Normalized (VSS.Strings.Normalization_Form_KC); + VSS.Transformers.Normalization.To_Normalization_Form_KC + .Transform (C1); C2N : constant VSS.Strings.Virtual_String := - C2.To_Normalized (VSS.Strings.Normalization_Form_KC); + VSS.Transformers.Normalization.To_Normalization_Form_KC + .Transform (C2); C3N : constant VSS.Strings.Virtual_String := - C3.To_Normalized (VSS.Strings.Normalization_Form_KC); + VSS.Transformers.Normalization.To_Normalization_Form_KC + .Transform (C3); C4N : constant VSS.Strings.Virtual_String := - C4.To_Normalized (VSS.Strings.Normalization_Form_KC); + VSS.Transformers.Normalization.To_Normalization_Form_KC + .Transform (C4); C5N : constant VSS.Strings.Virtual_String := - C5.To_Normalized (VSS.Strings.Normalization_Form_KC); + VSS.Transformers.Normalization.To_Normalization_Form_KC + .Transform (C5); begin Test_Support.Assert (C4 = C1N); @@ -145,15 +161,20 @@ begin declare C1N : constant VSS.Strings.Virtual_String := - C1.To_Normalized (VSS.Strings.Normalization_Form_KD); + VSS.Transformers.Normalization.To_Normalization_Form_KD + .Transform (C1); C2N : constant VSS.Strings.Virtual_String := - C2.To_Normalized (VSS.Strings.Normalization_Form_KD); + VSS.Transformers.Normalization.To_Normalization_Form_KD + .Transform (C2); C3N : constant VSS.Strings.Virtual_String := - C3.To_Normalized (VSS.Strings.Normalization_Form_KD); + VSS.Transformers.Normalization.To_Normalization_Form_KD + .Transform (C3); C4N : constant VSS.Strings.Virtual_String := - C4.To_Normalized (VSS.Strings.Normalization_Form_KD); + VSS.Transformers.Normalization.To_Normalization_Form_KD + .Transform (C4); C5N : constant VSS.Strings.Virtual_String := - C5.To_Normalized (VSS.Strings.Normalization_Form_KD); + VSS.Transformers.Normalization.To_Normalization_Form_KD + .Transform (C5); begin Test_Support.Assert (C5 = C1N); From f5f85fc0d8ee5ff3bddc21499daf8be59b732cfa Mon Sep 17 00:00:00 2001 From: Vadim Godunko Date: Mon, 18 Dec 2023 18:43:28 +0400 Subject: [PATCH 03/12] Add text normalization transformation. Convert text normalization testsuite to XUnit format. --- Makefile | 2 +- gnat/tests/vss_text_tests.gpr | 2 +- .../text/vss-transformers-normalization.ads | 18 +++--- ...ransformer-test_ucd_normalizationtest.adb} | 55 ++++++++----------- testsuite/text/test_transformer.adb | 46 ++++++++++++++++ 5 files changed, 80 insertions(+), 43 deletions(-) rename testsuite/text/{test_string_normalization.adb => test_transformer-test_ucd_normalizationtest.adb} (74%) create mode 100644 testsuite/text/test_transformer.adb diff --git a/Makefile b/Makefile index 3c5710ec..78ca4064 100644 --- a/Makefile +++ b/Makefile @@ -87,13 +87,13 @@ check_text: .objs/tests/test_string_hash .objs/tests/test_string_insert .objs/tests/test_string_buffer - .objs/tests/test_string_normalization data/ucd .objs/tests/test_string_slice .objs/tests/test_string_split .objs/tests/test_string_split_lines .objs/tests/test_string .objs/tests/test_string_template .objs/tests/test_string_vector + .objs/tests/test_transformer data/ucd for f in testsuite/text/w3c-i18n-tests-casing/*.txt; do \ echo " $$f"; .objs/tests/test_string_casing_w3c_i18n $$f || return 1; \ done diff --git a/gnat/tests/vss_text_tests.gpr b/gnat/tests/vss_text_tests.gpr index 2ed44014..ce8b344e 100644 --- a/gnat/tests/vss_text_tests.gpr +++ b/gnat/tests/vss_text_tests.gpr @@ -35,12 +35,12 @@ project VSS_Text_Tests is "test_string_hash", "test_string_insert", "test_string_buffer", - "test_string_normalization", "test_string_slice", "test_string_split", "test_string_split_lines", "test_string_template", "test_string_vector", + "test_transformer", "test_word_iterators"); package Compiler is diff --git a/source/text/vss-transformers-normalization.ads b/source/text/vss-transformers-normalization.ads index 568437fb..fe1fa132 100644 --- a/source/text/vss-transformers-normalization.ads +++ b/source/text/vss-transformers-normalization.ads @@ -4,7 +4,7 @@ -- SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -- --- Generic API to transform text data. +-- Unicode Normalization transformations. with VSS.Strings; @@ -12,16 +12,16 @@ package VSS.Transformers.Normalization is pragma Preelaborate; - To_Normalization_Form_D : constant Abstract_Transformer'Class; + Normalization_Form_D : constant Abstract_Transformer'Class; -- Transform text to Normalization Form D. - To_Normalization_Form_C : constant Abstract_Transformer'Class; + Normalization_Form_C : constant Abstract_Transformer'Class; -- Transform text to Normalization Form C. - To_Normalization_Form_KD : constant Abstract_Transformer'Class; + Normalization_Form_KD : constant Abstract_Transformer'Class; -- Transform text to Normalization Form KD. - To_Normalization_Form_KC : constant Abstract_Transformer'Class; + Normalization_Form_KC : constant Abstract_Transformer'Class; -- Transform text to Normalization Form KC. private @@ -74,13 +74,13 @@ private (Self : Normalization_Form_KC_Transformer; Item : in out VSS.Strings.Virtual_String'Class); - To_Normalization_Form_D : constant Abstract_Transformer'Class := + Normalization_Form_D : constant Abstract_Transformer'Class := Normalization_Form_D_Transformer'(null record); - To_Normalization_Form_C : constant Abstract_Transformer'Class := + Normalization_Form_C : constant Abstract_Transformer'Class := Normalization_Form_C_Transformer'(null record); - To_Normalization_Form_KD : constant Abstract_Transformer'Class := + Normalization_Form_KD : constant Abstract_Transformer'Class := Normalization_Form_KD_Transformer'(null record); - To_Normalization_Form_KC : constant Abstract_Transformer'Class := + Normalization_Form_KC : constant Abstract_Transformer'Class := Normalization_Form_KC_Transformer'(null record); end VSS.Transformers.Normalization; diff --git a/testsuite/text/test_string_normalization.adb b/testsuite/text/test_transformer-test_ucd_normalizationtest.adb similarity index 74% rename from testsuite/text/test_string_normalization.adb rename to testsuite/text/test_transformer-test_ucd_normalizationtest.adb index c2201b59..a0cfb8ac 100644 --- a/testsuite/text/test_string_normalization.adb +++ b/testsuite/text/test_transformer-test_ucd_normalizationtest.adb @@ -4,18 +4,13 @@ -- SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -- -with Ada.Command_Line; -with Ada.Strings.UTF_Encoding.Wide_Wide_Strings; - with VSS.Characters; -with VSS.Strings; with VSS.Transformers.Normalization; with UCD.Data_File_Loaders; -with Test_Support; - -procedure Test_String_Normalization is +separate (Test_Transformer) +procedure Test_UCD_NormalizationTest is function Get_Field (Loader : UCD.Data_File_Loaders.File_Loader'Class; @@ -42,10 +37,6 @@ procedure Test_String_Normalization is end return; end Get_Field; - UCD_Root : constant Wide_Wide_String := - Ada.Strings.UTF_Encoding.Wide_Wide_Strings.Decode - (Ada.Command_Line.Argument (1)); - Loader : UCD.Data_File_Loaders.File_Loader; begin @@ -80,19 +71,19 @@ begin declare C1N : constant VSS.Strings.Virtual_String := - VSS.Transformers.Normalization.To_Normalization_Form_C + VSS.Transformers.Normalization.Normalization_Form_C .Transform (C1); C2N : constant VSS.Strings.Virtual_String := - VSS.Transformers.Normalization.To_Normalization_Form_C + VSS.Transformers.Normalization.Normalization_Form_C .Transform (C2); C3N : constant VSS.Strings.Virtual_String := - VSS.Transformers.Normalization.To_Normalization_Form_C + VSS.Transformers.Normalization.Normalization_Form_C .Transform (C3); C4N : constant VSS.Strings.Virtual_String := - VSS.Transformers.Normalization.To_Normalization_Form_C + VSS.Transformers.Normalization.Normalization_Form_C .Transform (C4); C5N : constant VSS.Strings.Virtual_String := - VSS.Transformers.Normalization.To_Normalization_Form_C + VSS.Transformers.Normalization.Normalization_Form_C .Transform (C4); begin @@ -107,19 +98,19 @@ begin declare C1N : constant VSS.Strings.Virtual_String := - VSS.Transformers.Normalization.To_Normalization_Form_D + VSS.Transformers.Normalization.Normalization_Form_D .Transform (C1); C2N : constant VSS.Strings.Virtual_String := - VSS.Transformers.Normalization.To_Normalization_Form_D + VSS.Transformers.Normalization.Normalization_Form_D .Transform (C2); C3N : constant VSS.Strings.Virtual_String := - VSS.Transformers.Normalization.To_Normalization_Form_D + VSS.Transformers.Normalization.Normalization_Form_D .Transform (C3); C4N : constant VSS.Strings.Virtual_String := - VSS.Transformers.Normalization.To_Normalization_Form_D + VSS.Transformers.Normalization.Normalization_Form_D .Transform (C4); C5N : constant VSS.Strings.Virtual_String := - VSS.Transformers.Normalization.To_Normalization_Form_D + VSS.Transformers.Normalization.Normalization_Form_D .Transform (C5); begin @@ -134,19 +125,19 @@ begin declare C1N : constant VSS.Strings.Virtual_String := - VSS.Transformers.Normalization.To_Normalization_Form_KC + VSS.Transformers.Normalization.Normalization_Form_KC .Transform (C1); C2N : constant VSS.Strings.Virtual_String := - VSS.Transformers.Normalization.To_Normalization_Form_KC + VSS.Transformers.Normalization.Normalization_Form_KC .Transform (C2); C3N : constant VSS.Strings.Virtual_String := - VSS.Transformers.Normalization.To_Normalization_Form_KC + VSS.Transformers.Normalization.Normalization_Form_KC .Transform (C3); C4N : constant VSS.Strings.Virtual_String := - VSS.Transformers.Normalization.To_Normalization_Form_KC + VSS.Transformers.Normalization.Normalization_Form_KC .Transform (C4); C5N : constant VSS.Strings.Virtual_String := - VSS.Transformers.Normalization.To_Normalization_Form_KC + VSS.Transformers.Normalization.Normalization_Form_KC .Transform (C5); begin @@ -161,19 +152,19 @@ begin declare C1N : constant VSS.Strings.Virtual_String := - VSS.Transformers.Normalization.To_Normalization_Form_KD + VSS.Transformers.Normalization.Normalization_Form_KD .Transform (C1); C2N : constant VSS.Strings.Virtual_String := - VSS.Transformers.Normalization.To_Normalization_Form_KD + VSS.Transformers.Normalization.Normalization_Form_KD .Transform (C2); C3N : constant VSS.Strings.Virtual_String := - VSS.Transformers.Normalization.To_Normalization_Form_KD + VSS.Transformers.Normalization.Normalization_Form_KD .Transform (C3); C4N : constant VSS.Strings.Virtual_String := - VSS.Transformers.Normalization.To_Normalization_Form_KD + VSS.Transformers.Normalization.Normalization_Form_KD .Transform (C4); C5N : constant VSS.Strings.Virtual_String := - VSS.Transformers.Normalization.To_Normalization_Form_KD + VSS.Transformers.Normalization.Normalization_Form_KD .Transform (C5); begin @@ -192,4 +183,4 @@ begin end loop; Loader.Close; -end Test_String_Normalization; +end Test_UCD_NormalizationTest; diff --git a/testsuite/text/test_transformer.adb b/testsuite/text/test_transformer.adb new file mode 100644 index 00000000..a823ff4e --- /dev/null +++ b/testsuite/text/test_transformer.adb @@ -0,0 +1,46 @@ +-- +-- Copyright (C) 2023, AdaCore +-- +-- SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +-- + +with VSS.Application; +with VSS.Strings.Conversions; + +with Test_Support; + +procedure Test_Transformer is + + UCD_Root : constant Wide_Wide_String := + VSS.Strings.Conversions.To_Wide_Wide_String + (VSS.Application.Arguments.Element (1)); + + -- Testsuites + + procedure Test_Normalization; + + -- Testcases + + procedure Test_UCD_NormalizationTest; + + ------------------------ + -- Test_Normalization -- + ------------------------ + + procedure Test_Normalization is + begin + Test_Support.Run_Testcase + (Test_UCD_NormalizationTest'Access, + "UCD NormalizationTest.txt"); + end Test_Normalization; + + -------------------------------- + -- Test_UCD_NormalizationTest -- + -------------------------------- + + procedure Test_UCD_NormalizationTest is separate; + +begin + Test_Support.Run_Testsuite + (Test_Normalization'Access, "Normalization Transformation"); +end Test_Transformer; From 89d3c73fcc4f0deb217fcda804642515ad55be64 Mon Sep 17 00:00:00 2001 From: Vadim Godunko Date: Mon, 18 Dec 2023 20:21:22 +0400 Subject: [PATCH 04/12] Case conversion as transformers. --- .../vss-transformers-casing.adb | 185 ++++++++++++++++++ source/text/vss-transformers-casing.ads | 88 +++++++++ 2 files changed, 273 insertions(+) create mode 100644 source/text/implementation/vss-transformers-casing.adb create mode 100644 source/text/vss-transformers-casing.ads diff --git a/source/text/implementation/vss-transformers-casing.adb b/source/text/implementation/vss-transformers-casing.adb new file mode 100644 index 00000000..ac5ca617 --- /dev/null +++ b/source/text/implementation/vss-transformers-casing.adb @@ -0,0 +1,185 @@ +-- +-- Copyright (C) 2023, AdaCore +-- +-- SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +-- + +with VSS.Implementation.Strings; +with VSS.Implementation.UTF8_Casing; +with VSS.Strings.Internals; + +package body VSS.Transformers.Casing is + + --------------- + -- Transform -- + --------------- + + overriding function Transform + (Self : Lowercase_Transformer; + Item : VSS.Strings.Virtual_String'Class) + return VSS.Strings.Virtual_String + is + Aux : VSS.Implementation.Strings.String_Data; + + begin + VSS.Implementation.UTF8_Casing.Convert_Case + (VSS.Strings.Internals.Data_Access_Constant (Item).all, + VSS.Implementation.UTF8_Casing.Lowercase, + Aux); + + return Result : constant VSS.Strings.Virtual_String := + VSS.Strings.Internals.To_Virtual_String (Aux) + do + VSS.Implementation.Strings.Unreference (Aux); + end return; + end Transform; + + --------------- + -- Transform -- + --------------- + + overriding procedure Transform + (Self : Lowercase_Transformer; + Item : in out VSS.Strings.Virtual_String'Class) + is + Aux : VSS.Implementation.Strings.String_Data; + + begin + VSS.Implementation.UTF8_Casing.Convert_Case + (VSS.Strings.Internals.Data_Access_Constant (Item).all, + VSS.Implementation.UTF8_Casing.Lowercase, + Aux); + + VSS.Strings.Internals.Set_By_Move (Item, Aux); + end Transform; + + --------------- + -- Transform -- + --------------- + + overriding function Transform + (Self : Simple_Lowercase_Transformer; + Item : VSS.Strings.Virtual_String'Class) + return VSS.Strings.Virtual_String + is + Aux : VSS.Implementation.Strings.String_Data; + + begin + VSS.Implementation.UTF8_Casing.Convert_Case + (VSS.Strings.Internals.Data_Access_Constant (Item).all, + VSS.Implementation.UTF8_Casing.Simple_Lowercase, + Aux); + + return Result : constant VSS.Strings.Virtual_String := + VSS.Strings.Internals.To_Virtual_String (Aux) + do + VSS.Implementation.Strings.Unreference (Aux); + end return; + end Transform; + + --------------- + -- Transform -- + --------------- + + overriding procedure Transform + (Self : Simple_Lowercase_Transformer; + Item : in out VSS.Strings.Virtual_String'Class) + is + Aux : VSS.Implementation.Strings.String_Data; + + begin + VSS.Implementation.UTF8_Casing.Convert_Case + (VSS.Strings.Internals.Data_Access_Constant (Item).all, + VSS.Implementation.UTF8_Casing.Simple_Lowercase, + Aux); + + VSS.Strings.Internals.Set_By_Move (Item, Aux); + end Transform; + + --------------- + -- Transform -- + --------------- + + overriding function Transform + (Self : Simple_Uppercase_Transformer; + Item : VSS.Strings.Virtual_String'Class) + return VSS.Strings.Virtual_String + is + Aux : VSS.Implementation.Strings.String_Data; + + begin + VSS.Implementation.UTF8_Casing.Convert_Case + (VSS.Strings.Internals.Data_Access_Constant (Item).all, + VSS.Implementation.UTF8_Casing.Simple_Uppercase, + Aux); + + return Result : constant VSS.Strings.Virtual_String := + VSS.Strings.Internals.To_Virtual_String (Aux) + do + VSS.Implementation.Strings.Unreference (Aux); + end return; + end Transform; + + --------------- + -- Transform -- + --------------- + + overriding procedure Transform + (Self : Simple_Uppercase_Transformer; + Item : in out VSS.Strings.Virtual_String'Class) + is + Aux : VSS.Implementation.Strings.String_Data; + + begin + VSS.Implementation.UTF8_Casing.Convert_Case + (VSS.Strings.Internals.Data_Access_Constant (Item).all, + VSS.Implementation.UTF8_Casing.Simple_Uppercase, + Aux); + + VSS.Strings.Internals.Set_By_Move (Item, Aux); + end Transform; + + --------------- + -- Transform -- + --------------- + + overriding function Transform + (Self : Uppercase_Transformer; + Item : VSS.Strings.Virtual_String'Class) + return VSS.Strings.Virtual_String + is + Aux : VSS.Implementation.Strings.String_Data; + + begin + VSS.Implementation.UTF8_Casing.Convert_Case + (VSS.Strings.Internals.Data_Access_Constant (Item).all, + VSS.Implementation.UTF8_Casing.Uppercase, + Aux); + + return Result : constant VSS.Strings.Virtual_String := + VSS.Strings.Internals.To_Virtual_String (Aux) + do + VSS.Implementation.Strings.Unreference (Aux); + end return; + end Transform; + + --------------- + -- Transform -- + --------------- + + overriding procedure Transform + (Self : Uppercase_Transformer; + Item : in out VSS.Strings.Virtual_String'Class) + is + Aux : VSS.Implementation.Strings.String_Data; + + begin + VSS.Implementation.UTF8_Casing.Convert_Case + (VSS.Strings.Internals.Data_Access_Constant (Item).all, + VSS.Implementation.UTF8_Casing.Uppercase, + Aux); + + VSS.Strings.Internals.Set_By_Move (Item, Aux); + end Transform; + +end VSS.Transformers.Casing; diff --git a/source/text/vss-transformers-casing.ads b/source/text/vss-transformers-casing.ads new file mode 100644 index 00000000..a2f4570a --- /dev/null +++ b/source/text/vss-transformers-casing.ads @@ -0,0 +1,88 @@ +-- +-- Copyright (C) 2023, AdaCore +-- +-- SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +-- + +-- Unicode default case conversion. +-- +-- For locale tailored case conversion see VSS.Locales. + +with VSS.Strings; + +package VSS.Transformers.Casing is + + pragma Preelaborate; + + Lowercase : constant Abstract_Transformer'Class; + -- Convert text to lowercase using default full case conversion. + + Uppercase : constant Abstract_Transformer'Class; + -- Convert text to uppercase using default full case conversion. + + Simple_Lowercase : constant Abstract_Transformer'Class; + -- Convert text to lowercase using default simple case conversion. + + Simple_Uppercase : constant Abstract_Transformer'Class; + -- Convert text to uppercase using default simple case conversion. + +private + + type Simple_Lowercase_Transformer is + limited new Abstract_Transformer with null record; + + overriding function Transform + (Self : Simple_Lowercase_Transformer; + Item : VSS.Strings.Virtual_String'Class) + return VSS.Strings.Virtual_String; + + overriding procedure Transform + (Self : Simple_Lowercase_Transformer; + Item : in out VSS.Strings.Virtual_String'Class); + + type Simple_Uppercase_Transformer is + limited new Abstract_Transformer with null record; + + overriding function Transform + (Self : Simple_Uppercase_Transformer; + Item : VSS.Strings.Virtual_String'Class) + return VSS.Strings.Virtual_String; + + overriding procedure Transform + (Self : Simple_Uppercase_Transformer; + Item : in out VSS.Strings.Virtual_String'Class); + + type Lowercase_Transformer is + limited new Abstract_Transformer with null record; + + overriding function Transform + (Self : Lowercase_Transformer; + Item : VSS.Strings.Virtual_String'Class) + return VSS.Strings.Virtual_String; + + overriding procedure Transform + (Self : Lowercase_Transformer; + Item : in out VSS.Strings.Virtual_String'Class); + + type Uppercase_Transformer is + limited new Abstract_Transformer with null record; + + overriding function Transform + (Self : Uppercase_Transformer; + Item : VSS.Strings.Virtual_String'Class) + return VSS.Strings.Virtual_String; + + overriding procedure Transform + (Self : Uppercase_Transformer; + Item : in out VSS.Strings.Virtual_String'Class); + + Lowercase : constant Abstract_Transformer'Class := + Lowercase_Transformer'(null record); + Simple_Lowercase : constant Abstract_Transformer'Class := + Simple_Lowercase_Transformer'(null record); + Simple_Uppercase : constant Abstract_Transformer'Class := + Simple_Uppercase_Transformer'(null record); + Uppercase : constant Abstract_Transformer'Class := + Uppercase_Transformer'(null record); + +end VSS.Transformers.Casing; From 6b30e0d9aa600e597b83efe01df536e74c5c1035 Mon Sep 17 00:00:00 2001 From: Vadim Godunko Date: Mon, 18 Dec 2023 20:31:01 +0400 Subject: [PATCH 05/12] Reorganize tests of case conversion. --- Makefile | 6 +-- gnat/tests/vss_text_tests.gpr | 2 - ... test_transformer-test_casing_minimal.adb} | 51 +++++++++++-------- ...test_transformer-test_casing_w3c_i18n.adb} | 20 ++++---- testsuite/text/test_transformer.adb | 49 +++++++++++++++++- 5 files changed, 88 insertions(+), 40 deletions(-) rename testsuite/text/{test_string_casing.adb => test_transformer-test_casing_minimal.adb} (58%) rename testsuite/text/{test_string_casing_w3c_i18n.adb => test_transformer-test_casing_w3c_i18n.adb} (75%) diff --git a/Makefile b/Makefile index 78ca4064..cc5f0622 100644 --- a/Makefile +++ b/Makefile @@ -80,7 +80,6 @@ check_text: .objs/tests/test_text_streams .objs/tests/test_file_text_streams testsuite/stream/test_file_text_stream/vss.197.in.txt /tmp/vss.197.out.txt && diff -u /tmp/vss.197.out.txt testsuite/stream/test_file_text_stream/vss.197.out.txt .objs/tests/test_string_append - .objs/tests/test_string_casing .objs/tests/test_string_compare .objs/tests/test_string_conversions .objs/tests/test_string_delete @@ -93,10 +92,7 @@ check_text: .objs/tests/test_string .objs/tests/test_string_template .objs/tests/test_string_vector - .objs/tests/test_transformer data/ucd - for f in testsuite/text/w3c-i18n-tests-casing/*.txt; do \ - echo " $$f"; .objs/tests/test_string_casing_w3c_i18n $$f || return 1; \ - done + .objs/tests/test_transformer data/ucd testsuite/text/w3c-i18n-tests-casing/*.txt .objs/tests/test_word_iterators data/ucd .objs/tests/test_standard_paths ifeq ($(OS),Windows_NT) diff --git a/gnat/tests/vss_text_tests.gpr b/gnat/tests/vss_text_tests.gpr index ce8b344e..b79bc2d4 100644 --- a/gnat/tests/vss_text_tests.gpr +++ b/gnat/tests/vss_text_tests.gpr @@ -26,8 +26,6 @@ project VSS_Text_Tests is "test_line_iterators.adb", "test_string", "test_string_append", - "test_string_casing.adb", - "test_string_casing_w3c_i18n.adb", "test_string_compare", "test_string_conversions.adb", "test_string_decoder.adb", diff --git a/testsuite/text/test_string_casing.adb b/testsuite/text/test_transformer-test_casing_minimal.adb similarity index 58% rename from testsuite/text/test_string_casing.adb rename to testsuite/text/test_transformer-test_casing_minimal.adb index 49896658..b27a838b 100644 --- a/testsuite/text/test_string_casing.adb +++ b/testsuite/text/test_transformer-test_casing_minimal.adb @@ -1,14 +1,13 @@ -- --- Copyright (C) 2021, AdaCore +-- Copyright (C) 2021-2023, AdaCore -- -- SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -- -with VSS.Strings; +with VSS.Transformers.Casing; -with Test_Support; - -procedure Test_String_Casing is +separate (Test_Transformer) +procedure Test_Casing_Minimal is use type VSS.Strings.Virtual_String; S1 : constant VSS.Strings.Virtual_String := "123ABCАБВ"; @@ -55,25 +54,35 @@ procedure Test_String_Casing is VSS.Strings.Empty_Virtual_String; begin - Test_Support.Assert (S1.To_Lowercase = E1); - Test_Support.Assert (S1S.To_Lowercase = S1E); - Test_Support.Assert (S2S.To_Lowercase = S2E); - Test_Support.Assert (S3S.To_Lowercase = S3E); - Test_Support.Assert (S4S.To_Lowercase = S4E); - Test_Support.Assert (S5S.To_Lowercase = S5E); - Test_Support.Assert (S6S.To_Lowercase = S6E); - - Test_Support.Assert (U1.To_Lowercase = L1); - Test_Support.Assert (L1.To_Uppercase = U1); + Test_Support.Assert (VSS.Transformers.Casing.Lowercase.Transform (S1) = E1); + Test_Support.Assert + (VSS.Transformers.Casing.Lowercase.Transform (S1S) = S1E); + Test_Support.Assert + (VSS.Transformers.Casing.Lowercase.Transform (S2S) = S2E); + Test_Support.Assert + (VSS.Transformers.Casing.Lowercase.Transform (S3S) = S3E); + Test_Support.Assert + (VSS.Transformers.Casing.Lowercase.Transform (S4S) = S4E); + Test_Support.Assert + (VSS.Transformers.Casing.Lowercase.Transform (S5S) = S5E); + Test_Support.Assert + (VSS.Transformers.Casing.Lowercase.Transform (S6S) = S6E); + + Test_Support.Assert (VSS.Transformers.Casing.Lowercase.Transform (U1) = L1); + Test_Support.Assert (VSS.Transformers.Casing.Uppercase.Transform (L1) = U1); -- Test for null string for code coverage of Null_String_Handler. - Test_Support.Assert (SN.To_Lowercase = SN); + Test_Support.Assert (VSS.Transformers.Casing.Lowercase.Transform (SN) = SN); -- Test of simple case conversion. - Test_Support.Assert (S1.To_Simple_Lowercase = E1); - Test_Support.Assert (E1.To_Simple_Uppercase = S1); - Test_Support.Assert (U1.To_Simple_Lowercase = L1); - Test_Support.Assert (L1.To_Simple_Uppercase = U1); -end Test_String_Casing; + Test_Support.Assert + (VSS.Transformers.Casing.Simple_Lowercase.Transform (S1) = E1); + Test_Support.Assert + (VSS.Transformers.Casing.Simple_Uppercase.Transform (E1) = S1); + Test_Support.Assert + (VSS.Transformers.Casing.Simple_Lowercase.Transform (U1) = L1); + Test_Support.Assert + (VSS.Transformers.Casing.Simple_Uppercase.Transform (L1) = U1); +end Test_Casing_Minimal; diff --git a/testsuite/text/test_string_casing_w3c_i18n.adb b/testsuite/text/test_transformer-test_casing_w3c_i18n.adb similarity index 75% rename from testsuite/text/test_string_casing_w3c_i18n.adb rename to testsuite/text/test_transformer-test_casing_w3c_i18n.adb index f8df7e0b..8a2c9b11 100644 --- a/testsuite/text/test_string_casing_w3c_i18n.adb +++ b/testsuite/text/test_transformer-test_casing_w3c_i18n.adb @@ -1,17 +1,15 @@ -- --- Copyright (C) 2021, AdaCore +-- Copyright (C) 2021-2023, AdaCore -- -- SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -- -with Ada.Command_Line; with Ada.Wide_Wide_Text_IO; -with VSS.Strings; +with VSS.Transformers.Casing; -with Test_Support; - -procedure Test_String_Casing_W3C_I18N is +separate (Test_Transformer) +procedure Test_Casing_W3C_I18N is use type VSS.Strings.Virtual_String; File : Ada.Wide_Wide_Text_IO.File_Type; @@ -25,7 +23,7 @@ begin Ada.Wide_Wide_Text_IO.Open (File, Ada.Wide_Wide_Text_IO.In_File, - Ada.Command_Line.Argument (1), + VSS.Strings.Conversions.To_UTF_8_String (W3C_I18N_File), "wcem=8"); -- Skip name of the test @@ -61,9 +59,11 @@ begin Ada.Wide_Wide_Text_IO.Close (File); if Lowercase then - Test_Support.Assert (Source.To_Lowercase = Expected); + Test_Support.Assert + (VSS.Transformers.Casing.Lowercase.Transform (Source) = Expected); else - Test_Support.Assert (Source.To_Uppercase = Expected); + Test_Support.Assert + (VSS.Transformers.Casing.Uppercase.Transform (Source) = Expected); end if; -end Test_String_Casing_W3C_I18N; +end Test_Casing_W3C_I18N; diff --git a/testsuite/text/test_transformer.adb b/testsuite/text/test_transformer.adb index a823ff4e..87c7650c 100644 --- a/testsuite/text/test_transformer.adb +++ b/testsuite/text/test_transformer.adb @@ -4,6 +4,10 @@ -- SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -- +-- Test driver requires command line parameters: +-- 1) Path to UCD database +-- 2..*) Paths to W3C I18N test files + with VSS.Application; with VSS.Strings.Conversions; @@ -11,17 +15,56 @@ with Test_Support; procedure Test_Transformer is - UCD_Root : constant Wide_Wide_String := + UCD_Root : constant Wide_Wide_String := VSS.Strings.Conversions.To_Wide_Wide_String (VSS.Application.Arguments.Element (1)); + W3C_I18N_File : VSS.Strings.Virtual_String; + -- Path to test data file. Used by Test_Casing_W3C_I18N subprogram. + -- Testsuites procedure Test_Normalization; + procedure Test_Casing; -- Testcases procedure Test_UCD_NormalizationTest; + procedure Test_Casing_Minimal; + procedure Test_Casing_W3C_I18N; + + ----------------- + -- Test_Casing -- + ----------------- + + procedure Test_Casing is + begin + Test_Support.Run_Testcase + (Test_Casing_Minimal'Access, + "Minimal case conversions"); + + for J in 2 .. VSS.Application.Arguments.Length loop + W3C_I18N_File := VSS.Application.Arguments.Element (J); + + Test_Support.Run_Testcase + (Test_Casing_Minimal'Access, + "W3C I18N case conversions (" + & VSS.Strings.Conversions.To_UTF_8_String (W3C_I18N_File) + & ")"); + end loop; + end Test_Casing; + + ------------------------- + -- Test_Casing_Minimal -- + ------------------------- + + procedure Test_Casing_Minimal is separate; + + -------------------------- + -- Test_Casing_W3C_I18N -- + -------------------------- + + procedure Test_Casing_W3C_I18N is separate; ------------------------ -- Test_Normalization -- @@ -31,7 +74,7 @@ procedure Test_Transformer is begin Test_Support.Run_Testcase (Test_UCD_NormalizationTest'Access, - "UCD NormalizationTest.txt"); + "UCD NormalizationTest.txt"); end Test_Normalization; -------------------------------- @@ -43,4 +86,6 @@ procedure Test_Transformer is begin Test_Support.Run_Testsuite (Test_Normalization'Access, "Normalization Transformation"); + Test_Support.Run_Testsuite + (Test_Casing'Access, "Case Conversion Transformation"); end Test_Transformer; From adf397b68aed9793e3401f523e18898a03b040b2 Mon Sep 17 00:00:00 2001 From: Vadim Godunko Date: Mon, 18 Dec 2023 20:42:26 +0400 Subject: [PATCH 06/12] Remove To_* subprograms. They are replaced by Transformer API --- source/text/implementation/vss-strings.adb | 102 --------------------- source/text/vss-strings.ads | 39 +------- 2 files changed, 4 insertions(+), 137 deletions(-) diff --git a/source/text/implementation/vss-strings.adb b/source/text/implementation/vss-strings.adb index 028926a5..80d143c7 100644 --- a/source/text/implementation/vss-strings.adb +++ b/source/text/implementation/vss-strings.adb @@ -1232,108 +1232,6 @@ package body VSS.Strings is end return; end Tail_From; - ------------------ - -- To_Lowercase -- - ------------------ - - function To_Lowercase (Self : Virtual_String'Class) return Virtual_String is - begin - return Result : Virtual_String do - VSS.Implementation.UTF8_Casing.Convert_Case - (Self.Data, - VSS.Implementation.UTF8_Casing.Lowercase, - Result.Data); - end return; - end To_Lowercase; - - ------------------- - -- To_Normalized -- - ------------------- - - function To_Normalized - (Self : Virtual_String'Class; - Form : Normalization_Form) return Virtual_String is - begin - return Result : Virtual_String do - VSS.Implementation.UTF8_Normalization.Normalize - (Self.Data, Form, Result.Data); - end return; - end To_Normalized; - - ------------------------- - -- To_Simple_Lowercase -- - ------------------------- - - function To_Simple_Lowercase - (Self : Virtual_String'Class) return Virtual_String is - begin - return Result : Virtual_String do - VSS.Implementation.UTF8_Casing.Convert_Case - (Self.Data, - VSS.Implementation.UTF8_Casing.Simple_Lowercase, - Result.Data); - end return; - end To_Simple_Lowercase; - - ------------------------- - -- To_Simple_Titlecase -- - ------------------------- - --- function To_Simple_Titlecase --- (Self : Virtual_String'Class) return Virtual_String is --- begin --- return Result : Virtual_String do --- VSS.Implementation.Strings.Handler (Self.Data).Convert_Case --- (Self.Data, --- VSS.Implementation.String_Handlers.Simple_Titlecase, --- Result.Data); --- end return; --- end To_Simple_Titlecase; - - ------------------------- - -- To_Simple_Uppercase -- - ------------------------- - - function To_Simple_Uppercase - (Self : Virtual_String'Class) return Virtual_String is - begin - return Result : Virtual_String do - VSS.Implementation.UTF8_Casing.Convert_Case - (Self.Data, - VSS.Implementation.UTF8_Casing.Simple_Uppercase, - Result.Data); - end return; - end To_Simple_Uppercase; - - ------------------ - -- To_Titlecase -- - ------------------ - --- function To_Titlecase --- (Self : Virtual_String'Class) return Virtual_String is --- begin --- return Result : Virtual_String do --- VSS.Implementation.Strings.Handler (Self.Data).Convert_Case --- (Self.Data, --- VSS.Implementation.String_Handlers.Titlecase, --- Result.Data); --- end return; --- end To_Titlecase; - - ------------------ - -- To_Uppercase -- - ------------------ - - function To_Uppercase (Self : Virtual_String'Class) return Virtual_String is - begin - return Result : Virtual_String do - VSS.Implementation.UTF8_Casing.Convert_Case - (Self.Data, - VSS.Implementation.UTF8_Casing.Uppercase, - Result.Data); - end return; - end To_Uppercase; - ----------------------- -- To_Virtual_String -- ----------------------- diff --git a/source/text/vss-strings.ads b/source/text/vss-strings.ads index 40d3094f..cdd5cc0b 100644 --- a/source/text/vss-strings.ads +++ b/source/text/vss-strings.ads @@ -389,6 +389,8 @@ package VSS.Strings is -- Return True when Self starts with Prefix. Case_Sensitivity defines -- whether search is case sensitive or not, and select algorithm for the -- last. + -- + -- XXX Don't use Case_Sensitivity parameter, it will be removed. function Ends_With (Self : Virtual_String'Class; @@ -398,6 +400,8 @@ package VSS.Strings is -- Return True when Self has given Suffix. Case_Sensitivity defines -- whether search is case sensitive or not, and select algorithm for the -- last. + -- + -- XXX Don't use Case_Sensitivity parameter, it will be removed. function Ends_With (Self : Virtual_String'Class; @@ -431,41 +435,6 @@ package VSS.Strings is Keep_Terminator : Boolean := False) return VSS.String_Vectors.Virtual_String_Vector; - function To_Lowercase (Self : Virtual_String'Class) return Virtual_String; - -- Convert string to lowercase form using default full case conversion. - -- - -- See VSS.Locales.To_Lowercase for case conversions with tailoring by - -- the locale. - --- function To_Titlecase (Self : Virtual_String'Class) return Virtual_String; --- -- Convert string to titlecase form using default full case conversion. --- -- --- -- See VSS.Locales.To_Titlecase for case conversions with tailoring by --- -- the locale. - - function To_Uppercase (Self : Virtual_String'Class) return Virtual_String; - -- Convert string to uppercase form using default full case conversion. - -- - -- See VSS.Locales.To_Uppercase for case conversions with tailoring by - -- the locale. - - function To_Simple_Lowercase - (Self : Virtual_String'Class) return Virtual_String; - -- Convert string to lowercase form using default simple case conversion. - --- function To_Simple_Titlecase --- (Self : Virtual_String'Class) return Virtual_String; --- -- Convert string to titlecase form using default simple case conversion. - - function To_Simple_Uppercase - (Self : Virtual_String'Class) return Virtual_String; - -- Convert string to uppercase form using default simple case conversion. - - function To_Normalized - (Self : Virtual_String'Class; - Form : Normalization_Form) return Virtual_String; - -- Convert string to given normalization form. - procedure Put_Image (Buffer : in out Ada.Strings.Text_Buffers.Root_Buffer_Type'Class; Item : Virtual_String); From 44a2f2f90ebc94c29d64d3dd723e4cf01beb8dae Mon Sep 17 00:00:00 2001 From: Vadim Godunko Date: Mon, 18 Dec 2023 20:44:50 +0400 Subject: [PATCH 07/12] Remove use of old API. --- .../implementation/vss-regular_expressions-name_sets.adb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/source/regexp/implementation/vss-regular_expressions-name_sets.adb b/source/regexp/implementation/vss-regular_expressions-name_sets.adb index 7633e89d..f6cc7748 100644 --- a/source/regexp/implementation/vss-regular_expressions-name_sets.adb +++ b/source/regexp/implementation/vss-regular_expressions-name_sets.adb @@ -4,6 +4,8 @@ -- SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -- +with VSS.Transformers.Casing; + with VSS.Regular_Expressions.Category_Maps; package body VSS.Regular_Expressions.Name_Sets is @@ -60,7 +62,9 @@ package body VSS.Regular_Expressions.Name_Sets is Initialize; end if; - Cursor := Map.Find (Name.To_Simple_Lowercase); + Cursor := + Map.Find + (VSS.Transformers.Casing.Simple_Lowercase.Transform (Name)); if Category_Maps.Maps.Has_Element (Cursor) then Value := Category_Maps.Maps.Element (Cursor); From 4dc3d1176c5c08594ab311606e4ea4555205d7ea Mon Sep 17 00:00:00 2001 From: Vadim Godunko Date: Wed, 10 Jan 2024 15:02:46 +0400 Subject: [PATCH 08/12] Workaround of compiler bug. --- source/text/vss-transformers-casing.ads | 45 ++++++++++++------- .../text/vss-transformers-normalization.ads | 45 ++++++++++++------- 2 files changed, 56 insertions(+), 34 deletions(-) diff --git a/source/text/vss-transformers-casing.ads b/source/text/vss-transformers-casing.ads index a2f4570a..5f324624 100644 --- a/source/text/vss-transformers-casing.ads +++ b/source/text/vss-transformers-casing.ads @@ -14,19 +14,21 @@ package VSS.Transformers.Casing is pragma Preelaborate; - Lowercase : constant Abstract_Transformer'Class; - -- Convert text to lowercase using default full case conversion. - - Uppercase : constant Abstract_Transformer'Class; - -- Convert text to uppercase using default full case conversion. - - Simple_Lowercase : constant Abstract_Transformer'Class; - -- Convert text to lowercase using default simple case conversion. - - Simple_Uppercase : constant Abstract_Transformer'Class; - -- Convert text to uppercase using default simple case conversion. - -private + -- XXX GNAT 20231112 All types need to be make publicaly declared and + -- constants are declared as constants of that type (not classwide type + -- of base type) + -- + -- Lowercase : constant Abstract_Transformer'Class; + -- -- Convert text to lowercase using default full case conversion. + -- + -- Uppercase : constant Abstract_Transformer'Class; + -- -- Convert text to uppercase using default full case conversion. + -- + -- Simple_Lowercase : constant Abstract_Transformer'Class; + -- -- Convert text to lowercase using default simple case conversion. + -- + -- Simple_Uppercase : constant Abstract_Transformer'Class; + -- -- Convert text to uppercase using default simple case conversion. type Simple_Lowercase_Transformer is limited new Abstract_Transformer with null record; @@ -76,13 +78,22 @@ private (Self : Uppercase_Transformer; Item : in out VSS.Strings.Virtual_String'Class); - Lowercase : constant Abstract_Transformer'Class := + Lowercase : constant Lowercase_Transformer := Lowercase_Transformer'(null record); - Simple_Lowercase : constant Abstract_Transformer'Class := + Simple_Lowercase : constant Simple_Lowercase_Transformer := Simple_Lowercase_Transformer'(null record); - Simple_Uppercase : constant Abstract_Transformer'Class := + Simple_Uppercase : constant Simple_Uppercase_Transformer := Simple_Uppercase_Transformer'(null record); - Uppercase : constant Abstract_Transformer'Class := + Uppercase : constant Uppercase_Transformer := Uppercase_Transformer'(null record); + -- Lowercase : constant Abstract_Transformer'Class := + -- Lowercase_Transformer'(null record); + -- Simple_Lowercase : constant Abstract_Transformer'Class := + -- Simple_Lowercase_Transformer'(null record); + -- Simple_Uppercase : constant Abstract_Transformer'Class := + -- Simple_Uppercase_Transformer'(null record); + -- Uppercase : constant Abstract_Transformer'Class := + -- Uppercase_Transformer'(null record); + end VSS.Transformers.Casing; diff --git a/source/text/vss-transformers-normalization.ads b/source/text/vss-transformers-normalization.ads index fe1fa132..3aed9933 100644 --- a/source/text/vss-transformers-normalization.ads +++ b/source/text/vss-transformers-normalization.ads @@ -12,19 +12,21 @@ package VSS.Transformers.Normalization is pragma Preelaborate; - Normalization_Form_D : constant Abstract_Transformer'Class; - -- Transform text to Normalization Form D. - - Normalization_Form_C : constant Abstract_Transformer'Class; - -- Transform text to Normalization Form C. - - Normalization_Form_KD : constant Abstract_Transformer'Class; - -- Transform text to Normalization Form KD. - - Normalization_Form_KC : constant Abstract_Transformer'Class; - -- Transform text to Normalization Form KC. - -private + -- XXX GNAT 20231112 All types need to be make publicaly declared and + -- constants are declared as constants of that type (not classwide type + -- of base type) + -- + -- Normalization_Form_D : constant Abstract_Transformer'Class; + -- -- Transform text to Normalization Form D. + -- + -- Normalization_Form_C : constant Abstract_Transformer'Class; + -- -- Transform text to Normalization Form C. + -- + -- Normalization_Form_KD : constant Abstract_Transformer'Class; + -- -- Transform text to Normalization Form KD. + -- + -- Normalization_Form_KC : constant Abstract_Transformer'Class; + -- -- Transform text to Normalization Form KC. type Normalization_Form_D_Transformer is limited new Abstract_Transformer with null record; @@ -74,13 +76,22 @@ private (Self : Normalization_Form_KC_Transformer; Item : in out VSS.Strings.Virtual_String'Class); - Normalization_Form_D : constant Abstract_Transformer'Class := + Normalization_Form_D : constant Normalization_Form_D_Transformer := Normalization_Form_D_Transformer'(null record); - Normalization_Form_C : constant Abstract_Transformer'Class := + Normalization_Form_C : constant Normalization_Form_C_Transformer := Normalization_Form_C_Transformer'(null record); - Normalization_Form_KD : constant Abstract_Transformer'Class := + Normalization_Form_KD : constant Normalization_Form_KD_Transformer := Normalization_Form_KD_Transformer'(null record); - Normalization_Form_KC : constant Abstract_Transformer'Class := + Normalization_Form_KC : constant Normalization_Form_KC_Transformer := Normalization_Form_KC_Transformer'(null record); + -- Normalization_Form_D : constant Abstract_Transformer'Class := + -- Normalization_Form_D_Transformer'(null record); + -- Normalization_Form_C : constant Abstract_Transformer'Class := + -- Normalization_Form_C_Transformer'(null record); + -- Normalization_Form_KD : constant Abstract_Transformer'Class := + -- Normalization_Form_KD_Transformer'(null record); + -- Normalization_Form_KC : constant Abstract_Transformer'Class := + -- Normalization_Form_KC_Transformer'(null record); + end VSS.Transformers.Normalization; From 8d9d7cdc60e7a88dd0ac4f4e29dc80d57ad8448a Mon Sep 17 00:00:00 2001 From: Vadim Godunko Date: Wed, 10 Jan 2024 15:18:59 +0400 Subject: [PATCH 09/12] Update to use latest CI --- .gitlab-ci.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f71bc11f..296a213a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -311,15 +311,14 @@ build_lsif: rules: - if: $CI_PIPELINE_SOURCE == 'merge_request_event' when: manual + allow_failure: true trigger: strategy: depend inherit: variables: false variables: - ACI_UPSTREAM_PROJECT_PATH: $CI_PROJECT_PATH - ACI_UPSTREAM_REF_NAME: $CI_COMMIT_REF_NAME - ACI_UPSTREAM_SOURCE_BRANCH: $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME - ACI_UPSTREAM_TARGET_BRANCH: $CI_MERGE_REQUEST_TARGET_BRANCH_NAME + ACI_UPSTREAM_PROJECT_ID: $CI_PROJECT_ID + ACI_UPSTREAM_MERGE_REQUEST_IID: $CI_MERGE_REQUEST_IID run_als_ci: <<: *run_ci_common From 09b58f57dbe5d407454a04fe4d36ceb98e273638 Mon Sep 17 00:00:00 2001 From: Vadim Godunko Date: Wed, 10 Jan 2024 15:53:22 +0400 Subject: [PATCH 10/12] Update copyright year. --- gnat/tests/vss_text_tests.gpr | 2 +- .../regexp/implementation/vss-regular_expressions-name_sets.adb | 2 +- source/text/implementation/vss-strings-internals.adb | 2 +- source/text/implementation/vss-strings-internals.ads | 2 +- source/text/implementation/vss-strings.adb | 2 +- source/text/implementation/vss-transformers-casing.adb | 2 +- source/text/implementation/vss-transformers-normalization.adb | 2 +- source/text/vss-strings.ads | 2 +- source/text/vss-transformers-casing.ads | 2 +- source/text/vss-transformers-normalization.ads | 2 +- source/text/vss-transformers.ads | 2 +- testsuite/text/test_transformer-test_casing_minimal.adb | 2 +- testsuite/text/test_transformer-test_casing_w3c_i18n.adb | 2 +- testsuite/text/test_transformer-test_ucd_normalizationtest.adb | 2 +- testsuite/text/test_transformer.adb | 2 +- 15 files changed, 15 insertions(+), 15 deletions(-) diff --git a/gnat/tests/vss_text_tests.gpr b/gnat/tests/vss_text_tests.gpr index b79bc2d4..e9655d03 100644 --- a/gnat/tests/vss_text_tests.gpr +++ b/gnat/tests/vss_text_tests.gpr @@ -1,5 +1,5 @@ -- --- Copyright (C) 2020-2023, AdaCore +-- Copyright (C) 2020-2024, AdaCore -- -- SPDX-License-Identifier: Apache-2.0 -- diff --git a/source/regexp/implementation/vss-regular_expressions-name_sets.adb b/source/regexp/implementation/vss-regular_expressions-name_sets.adb index f6cc7748..a20e3b23 100644 --- a/source/regexp/implementation/vss-regular_expressions-name_sets.adb +++ b/source/regexp/implementation/vss-regular_expressions-name_sets.adb @@ -1,5 +1,5 @@ -- --- Copyright (C) 2022-2023, AdaCore +-- Copyright (C) 2022-2024, AdaCore -- -- SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -- diff --git a/source/text/implementation/vss-strings-internals.adb b/source/text/implementation/vss-strings-internals.adb index c6900412..9739bb8f 100644 --- a/source/text/implementation/vss-strings-internals.adb +++ b/source/text/implementation/vss-strings-internals.adb @@ -1,5 +1,5 @@ -- --- Copyright (C) 2020-2023, AdaCore +-- Copyright (C) 2020-2024, AdaCore -- -- SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -- diff --git a/source/text/implementation/vss-strings-internals.ads b/source/text/implementation/vss-strings-internals.ads index bc7a1cc3..d2a351d2 100644 --- a/source/text/implementation/vss-strings-internals.ads +++ b/source/text/implementation/vss-strings-internals.ads @@ -1,5 +1,5 @@ -- --- Copyright (C) 2020-2023, AdaCore +-- Copyright (C) 2020-2024, AdaCore -- -- SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -- diff --git a/source/text/implementation/vss-strings.adb b/source/text/implementation/vss-strings.adb index 80d143c7..8d93e4cf 100644 --- a/source/text/implementation/vss-strings.adb +++ b/source/text/implementation/vss-strings.adb @@ -1,5 +1,5 @@ -- --- Copyright (C) 2020-2023, AdaCore +-- Copyright (C) 2020-2024, AdaCore -- -- SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -- diff --git a/source/text/implementation/vss-transformers-casing.adb b/source/text/implementation/vss-transformers-casing.adb index ac5ca617..c927cbcc 100644 --- a/source/text/implementation/vss-transformers-casing.adb +++ b/source/text/implementation/vss-transformers-casing.adb @@ -1,5 +1,5 @@ -- --- Copyright (C) 2023, AdaCore +-- Copyright (C) 2023-2024, AdaCore -- -- SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -- diff --git a/source/text/implementation/vss-transformers-normalization.adb b/source/text/implementation/vss-transformers-normalization.adb index 0825b3b3..cab49945 100644 --- a/source/text/implementation/vss-transformers-normalization.adb +++ b/source/text/implementation/vss-transformers-normalization.adb @@ -1,5 +1,5 @@ -- --- Copyright (C) 2023, AdaCore +-- Copyright (C) 2023-2024, AdaCore -- -- SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -- diff --git a/source/text/vss-strings.ads b/source/text/vss-strings.ads index cdd5cc0b..3620f1e2 100644 --- a/source/text/vss-strings.ads +++ b/source/text/vss-strings.ads @@ -1,5 +1,5 @@ -- --- Copyright (C) 2020-2023, AdaCore +-- Copyright (C) 2020-2024, AdaCore -- -- SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -- diff --git a/source/text/vss-transformers-casing.ads b/source/text/vss-transformers-casing.ads index 5f324624..3e237030 100644 --- a/source/text/vss-transformers-casing.ads +++ b/source/text/vss-transformers-casing.ads @@ -1,5 +1,5 @@ -- --- Copyright (C) 2023, AdaCore +-- Copyright (C) 2023-2024, AdaCore -- -- SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -- diff --git a/source/text/vss-transformers-normalization.ads b/source/text/vss-transformers-normalization.ads index 3aed9933..0b3ae8c4 100644 --- a/source/text/vss-transformers-normalization.ads +++ b/source/text/vss-transformers-normalization.ads @@ -1,5 +1,5 @@ -- --- Copyright (C) 2023, AdaCore +-- Copyright (C) 2023-2024, AdaCore -- -- SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -- diff --git a/source/text/vss-transformers.ads b/source/text/vss-transformers.ads index 0a92cb48..accf625f 100644 --- a/source/text/vss-transformers.ads +++ b/source/text/vss-transformers.ads @@ -1,5 +1,5 @@ -- --- Copyright (C) 2023, AdaCore +-- Copyright (C) 2023-2024, AdaCore -- -- SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -- diff --git a/testsuite/text/test_transformer-test_casing_minimal.adb b/testsuite/text/test_transformer-test_casing_minimal.adb index b27a838b..40931c72 100644 --- a/testsuite/text/test_transformer-test_casing_minimal.adb +++ b/testsuite/text/test_transformer-test_casing_minimal.adb @@ -1,5 +1,5 @@ -- --- Copyright (C) 2021-2023, AdaCore +-- Copyright (C) 2021-2024, AdaCore -- -- SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -- diff --git a/testsuite/text/test_transformer-test_casing_w3c_i18n.adb b/testsuite/text/test_transformer-test_casing_w3c_i18n.adb index 8a2c9b11..7059206d 100644 --- a/testsuite/text/test_transformer-test_casing_w3c_i18n.adb +++ b/testsuite/text/test_transformer-test_casing_w3c_i18n.adb @@ -1,5 +1,5 @@ -- --- Copyright (C) 2021-2023, AdaCore +-- Copyright (C) 2021-2024, AdaCore -- -- SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -- diff --git a/testsuite/text/test_transformer-test_ucd_normalizationtest.adb b/testsuite/text/test_transformer-test_ucd_normalizationtest.adb index a0cfb8ac..0b3ee91d 100644 --- a/testsuite/text/test_transformer-test_ucd_normalizationtest.adb +++ b/testsuite/text/test_transformer-test_ucd_normalizationtest.adb @@ -1,5 +1,5 @@ -- --- Copyright (C) 2021-2023, AdaCore +-- Copyright (C) 2021-2024, AdaCore -- -- SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -- diff --git a/testsuite/text/test_transformer.adb b/testsuite/text/test_transformer.adb index 87c7650c..3f0f4faa 100644 --- a/testsuite/text/test_transformer.adb +++ b/testsuite/text/test_transformer.adb @@ -1,5 +1,5 @@ -- --- Copyright (C) 2023, AdaCore +-- Copyright (C) 2023-2024, AdaCore -- -- SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -- From db8ef0c8163169caf2f580bb94f2be5bb4ed59db Mon Sep 17 00:00:00 2001 From: Vadim Godunko Date: Wed, 10 Jan 2024 18:17:45 +0400 Subject: [PATCH 11/12] Hide entities from documentation. They are provided temporary to workaround compiler's bug. --- source/text/vss-transformers-casing.ads | 12 ++++++++++++ source/text/vss-transformers-normalization.ads | 12 ++++++++++++ 2 files changed, 24 insertions(+) diff --git a/source/text/vss-transformers-casing.ads b/source/text/vss-transformers-casing.ads index 3e237030..0b95ba92 100644 --- a/source/text/vss-transformers-casing.ads +++ b/source/text/vss-transformers-casing.ads @@ -32,51 +32,63 @@ package VSS.Transformers.Casing is type Simple_Lowercase_Transformer is limited new Abstract_Transformer with null record; + -- @private overriding function Transform (Self : Simple_Lowercase_Transformer; Item : VSS.Strings.Virtual_String'Class) return VSS.Strings.Virtual_String; + -- @private overriding procedure Transform (Self : Simple_Lowercase_Transformer; Item : in out VSS.Strings.Virtual_String'Class); + -- @private type Simple_Uppercase_Transformer is limited new Abstract_Transformer with null record; + -- @private overriding function Transform (Self : Simple_Uppercase_Transformer; Item : VSS.Strings.Virtual_String'Class) return VSS.Strings.Virtual_String; + -- @private overriding procedure Transform (Self : Simple_Uppercase_Transformer; Item : in out VSS.Strings.Virtual_String'Class); + -- @private type Lowercase_Transformer is limited new Abstract_Transformer with null record; + -- @private overriding function Transform (Self : Lowercase_Transformer; Item : VSS.Strings.Virtual_String'Class) return VSS.Strings.Virtual_String; + -- @private overriding procedure Transform (Self : Lowercase_Transformer; Item : in out VSS.Strings.Virtual_String'Class); + -- @private type Uppercase_Transformer is limited new Abstract_Transformer with null record; + -- @private overriding function Transform (Self : Uppercase_Transformer; Item : VSS.Strings.Virtual_String'Class) return VSS.Strings.Virtual_String; + -- @private overriding procedure Transform (Self : Uppercase_Transformer; Item : in out VSS.Strings.Virtual_String'Class); + -- @private Lowercase : constant Lowercase_Transformer := Lowercase_Transformer'(null record); diff --git a/source/text/vss-transformers-normalization.ads b/source/text/vss-transformers-normalization.ads index 0b3ae8c4..e7f2ce03 100644 --- a/source/text/vss-transformers-normalization.ads +++ b/source/text/vss-transformers-normalization.ads @@ -30,51 +30,63 @@ package VSS.Transformers.Normalization is type Normalization_Form_D_Transformer is limited new Abstract_Transformer with null record; + -- @private overriding function Transform (Self : Normalization_Form_D_Transformer; Item : VSS.Strings.Virtual_String'Class) return VSS.Strings.Virtual_String; + -- @private overriding procedure Transform (Self : Normalization_Form_D_Transformer; Item : in out VSS.Strings.Virtual_String'Class); + -- @private type Normalization_Form_C_Transformer is limited new Abstract_Transformer with null record; + -- @private overriding function Transform (Self : Normalization_Form_C_Transformer; Item : VSS.Strings.Virtual_String'Class) return VSS.Strings.Virtual_String; + -- @private overriding procedure Transform (Self : Normalization_Form_C_Transformer; Item : in out VSS.Strings.Virtual_String'Class); + -- @private type Normalization_Form_KD_Transformer is limited new Abstract_Transformer with null record; + -- @private overriding function Transform (Self : Normalization_Form_KD_Transformer; Item : VSS.Strings.Virtual_String'Class) return VSS.Strings.Virtual_String; + -- @private overriding procedure Transform (Self : Normalization_Form_KD_Transformer; Item : in out VSS.Strings.Virtual_String'Class); + -- @private type Normalization_Form_KC_Transformer is limited new Abstract_Transformer with null record; + -- @private overriding function Transform (Self : Normalization_Form_KC_Transformer; Item : VSS.Strings.Virtual_String'Class) return VSS.Strings.Virtual_String; + -- @private overriding procedure Transform (Self : Normalization_Form_KC_Transformer; Item : in out VSS.Strings.Virtual_String'Class); + -- @private Normalization_Form_D : constant Normalization_Form_D_Transformer := Normalization_Form_D_Transformer'(null record); From 369c54ec4d40fca1ce73acf30e8375a4f84df385 Mon Sep 17 00:00:00 2001 From: Vadim Godunko Date: Wed, 10 Jan 2024 18:38:19 +0400 Subject: [PATCH 12/12] Rename global objects to have To_ prefix. --- .../vss-regular_expressions-name_sets.adb | 2 +- source/text/vss-transformers-casing.ads | 8 ++-- .../text/vss-transformers-normalization.ads | 8 ++-- .../test_transformer-test_casing_minimal.adb | 32 ++++++++------- .../test_transformer-test_casing_w3c_i18n.adb | 4 +- ...transformer-test_ucd_normalizationtest.adb | 40 +++++++++---------- 6 files changed, 49 insertions(+), 45 deletions(-) diff --git a/source/regexp/implementation/vss-regular_expressions-name_sets.adb b/source/regexp/implementation/vss-regular_expressions-name_sets.adb index a20e3b23..8166e43b 100644 --- a/source/regexp/implementation/vss-regular_expressions-name_sets.adb +++ b/source/regexp/implementation/vss-regular_expressions-name_sets.adb @@ -64,7 +64,7 @@ package body VSS.Regular_Expressions.Name_Sets is Cursor := Map.Find - (VSS.Transformers.Casing.Simple_Lowercase.Transform (Name)); + (VSS.Transformers.Casing.To_Simple_Lowercase.Transform (Name)); if Category_Maps.Maps.Has_Element (Cursor) then Value := Category_Maps.Maps.Element (Cursor); diff --git a/source/text/vss-transformers-casing.ads b/source/text/vss-transformers-casing.ads index 0b95ba92..4d121b3b 100644 --- a/source/text/vss-transformers-casing.ads +++ b/source/text/vss-transformers-casing.ads @@ -90,13 +90,13 @@ package VSS.Transformers.Casing is Item : in out VSS.Strings.Virtual_String'Class); -- @private - Lowercase : constant Lowercase_Transformer := + To_Lowercase : constant Lowercase_Transformer := Lowercase_Transformer'(null record); - Simple_Lowercase : constant Simple_Lowercase_Transformer := + To_Simple_Lowercase : constant Simple_Lowercase_Transformer := Simple_Lowercase_Transformer'(null record); - Simple_Uppercase : constant Simple_Uppercase_Transformer := + To_Simple_Uppercase : constant Simple_Uppercase_Transformer := Simple_Uppercase_Transformer'(null record); - Uppercase : constant Uppercase_Transformer := + To_Uppercase : constant Uppercase_Transformer := Uppercase_Transformer'(null record); -- Lowercase : constant Abstract_Transformer'Class := diff --git a/source/text/vss-transformers-normalization.ads b/source/text/vss-transformers-normalization.ads index e7f2ce03..fc146d30 100644 --- a/source/text/vss-transformers-normalization.ads +++ b/source/text/vss-transformers-normalization.ads @@ -88,13 +88,13 @@ package VSS.Transformers.Normalization is Item : in out VSS.Strings.Virtual_String'Class); -- @private - Normalization_Form_D : constant Normalization_Form_D_Transformer := + To_Normalization_Form_D : constant Normalization_Form_D_Transformer := Normalization_Form_D_Transformer'(null record); - Normalization_Form_C : constant Normalization_Form_C_Transformer := + To_Normalization_Form_C : constant Normalization_Form_C_Transformer := Normalization_Form_C_Transformer'(null record); - Normalization_Form_KD : constant Normalization_Form_KD_Transformer := + To_Normalization_Form_KD : constant Normalization_Form_KD_Transformer := Normalization_Form_KD_Transformer'(null record); - Normalization_Form_KC : constant Normalization_Form_KC_Transformer := + To_Normalization_Form_KC : constant Normalization_Form_KC_Transformer := Normalization_Form_KC_Transformer'(null record); -- Normalization_Form_D : constant Abstract_Transformer'Class := diff --git a/testsuite/text/test_transformer-test_casing_minimal.adb b/testsuite/text/test_transformer-test_casing_minimal.adb index 40931c72..af82dc92 100644 --- a/testsuite/text/test_transformer-test_casing_minimal.adb +++ b/testsuite/text/test_transformer-test_casing_minimal.adb @@ -54,35 +54,39 @@ procedure Test_Casing_Minimal is VSS.Strings.Empty_Virtual_String; begin - Test_Support.Assert (VSS.Transformers.Casing.Lowercase.Transform (S1) = E1); Test_Support.Assert - (VSS.Transformers.Casing.Lowercase.Transform (S1S) = S1E); + (VSS.Transformers.Casing.To_Lowercase.Transform (S1) = E1); Test_Support.Assert - (VSS.Transformers.Casing.Lowercase.Transform (S2S) = S2E); + (VSS.Transformers.Casing.To_Lowercase.Transform (S1S) = S1E); Test_Support.Assert - (VSS.Transformers.Casing.Lowercase.Transform (S3S) = S3E); + (VSS.Transformers.Casing.To_Lowercase.Transform (S2S) = S2E); Test_Support.Assert - (VSS.Transformers.Casing.Lowercase.Transform (S4S) = S4E); + (VSS.Transformers.Casing.To_Lowercase.Transform (S3S) = S3E); Test_Support.Assert - (VSS.Transformers.Casing.Lowercase.Transform (S5S) = S5E); + (VSS.Transformers.Casing.To_Lowercase.Transform (S4S) = S4E); Test_Support.Assert - (VSS.Transformers.Casing.Lowercase.Transform (S6S) = S6E); + (VSS.Transformers.Casing.To_Lowercase.Transform (S5S) = S5E); + Test_Support.Assert + (VSS.Transformers.Casing.To_Lowercase.Transform (S6S) = S6E); - Test_Support.Assert (VSS.Transformers.Casing.Lowercase.Transform (U1) = L1); - Test_Support.Assert (VSS.Transformers.Casing.Uppercase.Transform (L1) = U1); + Test_Support.Assert + (VSS.Transformers.Casing.To_Lowercase.Transform (U1) = L1); + Test_Support.Assert + (VSS.Transformers.Casing.To_Uppercase.Transform (L1) = U1); -- Test for null string for code coverage of Null_String_Handler. - Test_Support.Assert (VSS.Transformers.Casing.Lowercase.Transform (SN) = SN); + Test_Support.Assert + (VSS.Transformers.Casing.To_Lowercase.Transform (SN) = SN); -- Test of simple case conversion. Test_Support.Assert - (VSS.Transformers.Casing.Simple_Lowercase.Transform (S1) = E1); + (VSS.Transformers.Casing.To_Simple_Lowercase.Transform (S1) = E1); Test_Support.Assert - (VSS.Transformers.Casing.Simple_Uppercase.Transform (E1) = S1); + (VSS.Transformers.Casing.To_Simple_Uppercase.Transform (E1) = S1); Test_Support.Assert - (VSS.Transformers.Casing.Simple_Lowercase.Transform (U1) = L1); + (VSS.Transformers.Casing.To_Simple_Lowercase.Transform (U1) = L1); Test_Support.Assert - (VSS.Transformers.Casing.Simple_Uppercase.Transform (L1) = U1); + (VSS.Transformers.Casing.To_Simple_Uppercase.Transform (L1) = U1); end Test_Casing_Minimal; diff --git a/testsuite/text/test_transformer-test_casing_w3c_i18n.adb b/testsuite/text/test_transformer-test_casing_w3c_i18n.adb index 7059206d..aa7e2b3e 100644 --- a/testsuite/text/test_transformer-test_casing_w3c_i18n.adb +++ b/testsuite/text/test_transformer-test_casing_w3c_i18n.adb @@ -60,10 +60,10 @@ begin if Lowercase then Test_Support.Assert - (VSS.Transformers.Casing.Lowercase.Transform (Source) = Expected); + (VSS.Transformers.Casing.To_Lowercase.Transform (Source) = Expected); else Test_Support.Assert - (VSS.Transformers.Casing.Uppercase.Transform (Source) = Expected); + (VSS.Transformers.Casing.To_Uppercase.Transform (Source) = Expected); end if; end Test_Casing_W3C_I18N; diff --git a/testsuite/text/test_transformer-test_ucd_normalizationtest.adb b/testsuite/text/test_transformer-test_ucd_normalizationtest.adb index 0b3ee91d..b42e754c 100644 --- a/testsuite/text/test_transformer-test_ucd_normalizationtest.adb +++ b/testsuite/text/test_transformer-test_ucd_normalizationtest.adb @@ -71,19 +71,19 @@ begin declare C1N : constant VSS.Strings.Virtual_String := - VSS.Transformers.Normalization.Normalization_Form_C + VSS.Transformers.Normalization.To_Normalization_Form_C .Transform (C1); C2N : constant VSS.Strings.Virtual_String := - VSS.Transformers.Normalization.Normalization_Form_C + VSS.Transformers.Normalization.To_Normalization_Form_C .Transform (C2); C3N : constant VSS.Strings.Virtual_String := - VSS.Transformers.Normalization.Normalization_Form_C + VSS.Transformers.Normalization.To_Normalization_Form_C .Transform (C3); C4N : constant VSS.Strings.Virtual_String := - VSS.Transformers.Normalization.Normalization_Form_C + VSS.Transformers.Normalization.To_Normalization_Form_C .Transform (C4); C5N : constant VSS.Strings.Virtual_String := - VSS.Transformers.Normalization.Normalization_Form_C + VSS.Transformers.Normalization.To_Normalization_Form_C .Transform (C4); begin @@ -98,19 +98,19 @@ begin declare C1N : constant VSS.Strings.Virtual_String := - VSS.Transformers.Normalization.Normalization_Form_D + VSS.Transformers.Normalization.To_Normalization_Form_D .Transform (C1); C2N : constant VSS.Strings.Virtual_String := - VSS.Transformers.Normalization.Normalization_Form_D + VSS.Transformers.Normalization.To_Normalization_Form_D .Transform (C2); C3N : constant VSS.Strings.Virtual_String := - VSS.Transformers.Normalization.Normalization_Form_D + VSS.Transformers.Normalization.To_Normalization_Form_D .Transform (C3); C4N : constant VSS.Strings.Virtual_String := - VSS.Transformers.Normalization.Normalization_Form_D + VSS.Transformers.Normalization.To_Normalization_Form_D .Transform (C4); C5N : constant VSS.Strings.Virtual_String := - VSS.Transformers.Normalization.Normalization_Form_D + VSS.Transformers.Normalization.To_Normalization_Form_D .Transform (C5); begin @@ -125,19 +125,19 @@ begin declare C1N : constant VSS.Strings.Virtual_String := - VSS.Transformers.Normalization.Normalization_Form_KC + VSS.Transformers.Normalization.To_Normalization_Form_KC .Transform (C1); C2N : constant VSS.Strings.Virtual_String := - VSS.Transformers.Normalization.Normalization_Form_KC + VSS.Transformers.Normalization.To_Normalization_Form_KC .Transform (C2); C3N : constant VSS.Strings.Virtual_String := - VSS.Transformers.Normalization.Normalization_Form_KC + VSS.Transformers.Normalization.To_Normalization_Form_KC .Transform (C3); C4N : constant VSS.Strings.Virtual_String := - VSS.Transformers.Normalization.Normalization_Form_KC + VSS.Transformers.Normalization.To_Normalization_Form_KC .Transform (C4); C5N : constant VSS.Strings.Virtual_String := - VSS.Transformers.Normalization.Normalization_Form_KC + VSS.Transformers.Normalization.To_Normalization_Form_KC .Transform (C5); begin @@ -152,19 +152,19 @@ begin declare C1N : constant VSS.Strings.Virtual_String := - VSS.Transformers.Normalization.Normalization_Form_KD + VSS.Transformers.Normalization.To_Normalization_Form_KD .Transform (C1); C2N : constant VSS.Strings.Virtual_String := - VSS.Transformers.Normalization.Normalization_Form_KD + VSS.Transformers.Normalization.To_Normalization_Form_KD .Transform (C2); C3N : constant VSS.Strings.Virtual_String := - VSS.Transformers.Normalization.Normalization_Form_KD + VSS.Transformers.Normalization.To_Normalization_Form_KD .Transform (C3); C4N : constant VSS.Strings.Virtual_String := - VSS.Transformers.Normalization.Normalization_Form_KD + VSS.Transformers.Normalization.To_Normalization_Form_KD .Transform (C4); C5N : constant VSS.Strings.Virtual_String := - VSS.Transformers.Normalization.Normalization_Form_KD + VSS.Transformers.Normalization.To_Normalization_Form_KD .Transform (C5); begin