repo_name
stringlengths
9
74
language
stringclasses
1 value
length_bytes
int64
11
9.34M
extension
stringclasses
2 values
content
stringlengths
11
9.34M
Componolit/libsparkcrypto
Ada
58,079
adb
------------------------------------------------------------------------------- -- This file is part of libsparkcrypto. -- -- Copyright (C) 2018, Componolit GmbH -- Copyright (C) 2015, Stefan Berghofer -- Copyright (C) 2010, Alexander Senier -- Copyright (C) 2010, secunet Security Networks AG -- All rights reserved. -- -- Redistribution and use in source and binary forms, with or without -- modification, are permitted provided that the following conditions are met: -- -- * Redistributions of source code must retain the above copyright notice, -- this list of conditions and the following disclaimer. -- -- * Redistributions in binary form must reproduce the above copyright -- notice, this list of conditions and the following disclaimer in the -- documentation and/or other materials provided with the distribution. -- -- * Neither the name of the nor the names of its contributors may be used -- to endorse or promote products derived from this software without -- specific prior written permission. -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS -- BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -- POSSIBILITY OF SUCH DAMAGE. ------------------------------------------------------------------------------- with LSC.Internal.Types; with LSC.Internal.RIPEMD160; with LSC.Internal.SHA1; with LSC.Internal.SHA256; with LSC.Internal.SHA512; with LSC.Internal.AES.CBC; with LSC.Internal.HMAC_RIPEMD160; with LSC.Internal.HMAC_SHA1; with LSC.Internal.HMAC_SHA256; with LSC.Internal.HMAC_SHA384; with LSC.Internal.HMAC_SHA512; with LSC.Internal.Bignum; with OpenSSL; with AUnit.Assertions; use AUnit.Assertions; with Interfaces; use type LSC.Internal.Types.Word32_Array_Type; use type LSC.Internal.Types.Word64_Array_Type; use type LSC.Internal.AES.Message_Type; use type LSC.Internal.Bignum.Big_Int; use type Interfaces.Unsigned_32; pragma Style_Checks ("-s"); package body LSC_Internal_Benchmark is use Ada.Calendar; function Routine_Name (T : Test_Case) return Message_String is Ref_Time : constant Duration := T.Reference_Stop - T.Reference_Start; Test_Time : constant Duration := T.Test_Stop - T.Test_Start; Percent : constant Natural := Natural (Duration'(Test_Time / Ref_Time) * 100.0); begin return Format (AUnit.Test_Cases.Test_Case (T).Routine_Name.all & " ... [" & Percent'Img & "% ]"); end Routine_Name; --------------------------------------------------------------------------- procedure Benchmark_RIPEMD160 (T : in out Test_Case'Class) is Block1, Block2 : LSC.Internal.RIPEMD160.Block_Type; RIPEMD160_Context1 : OpenSSL.RIPEMD160_Context_Type; RIPEMD160_Context2 : LSC.Internal.RIPEMD160.Context_Type; H1, H2 : LSC.Internal.RIPEMD160.Hash_Type; begin Block1 := LSC.Internal.RIPEMD160.Block_Type'(others => 16#cafebabe#); Block2 := LSC.Internal.RIPEMD160.Block_Type'(others => 16#00636261#); T.Reference_Start := Clock; for I in Natural range 1 .. 200000 loop OpenSSL.RIPEMD160_Context_Init (RIPEMD160_Context1); OpenSSL.RIPEMD160_Context_Update (RIPEMD160_Context1, Block1); OpenSSL.RIPEMD160_Context_Finalize (RIPEMD160_Context1, Block2, 56); end loop; H1 := OpenSSL.RIPEMD160_Get_Hash (RIPEMD160_Context1); T.Reference_Stop := Clock; T.Test_Start := Clock; for I in Natural range 1 .. 200000 loop RIPEMD160_Context2 := LSC.Internal.RIPEMD160.Context_Init; LSC.Internal.RIPEMD160.Context_Update (RIPEMD160_Context2, Block1); LSC.Internal.RIPEMD160.Context_Finalize (RIPEMD160_Context2, Block2, 56); end loop; H2 := LSC.Internal.RIPEMD160.Get_Hash (RIPEMD160_Context2); T.Test_Stop := Clock; Assert (H1 = H2, "Invalid hash"); end Benchmark_RIPEMD160; --------------------------------------------------------------------------- procedure Benchmark_SHA1 (T : in out Test_Case'Class) is Block1, Block2 : LSC.Internal.SHA1.Block_Type; SHA1_Context1 : OpenSSL.SHA1_Context_Type; SHA1_Context2 : LSC.Internal.SHA1.Context_Type; H1, H2 : LSC.Internal.SHA1.Hash_Type; begin Block1 := LSC.Internal.SHA1.Block_Type'(others => 16#cafebabe#); Block2 := LSC.Internal.SHA1.Block_Type'(others => 16#00636261#); T.Reference_Start := Clock; for I in Natural range 1 .. 500000 loop OpenSSL.SHA1_Context_Init (SHA1_Context1); OpenSSL.SHA1_Context_Update (SHA1_Context1, Block1); OpenSSL.SHA1_Context_Finalize (SHA1_Context1, Block2, 56); end loop; H1 := OpenSSL.SHA1_Get_Hash (SHA1_Context1); T.Reference_Stop := Clock; T.Test_Start := Clock; for I in Natural range 1 .. 500000 loop SHA1_Context2 := LSC.Internal.SHA1.Context_Init; LSC.Internal.SHA1.Context_Update (SHA1_Context2, Block1); LSC.Internal.SHA1.Context_Finalize (SHA1_Context2, Block2, 56); end loop; H2 := LSC.Internal.SHA1.Get_Hash (SHA1_Context2); T.Test_Stop := Clock; Assert (H1 = H2, "Invalid hash"); end Benchmark_SHA1; --------------------------------------------------------------------------- procedure Benchmark_SHA256 (T : in out Test_Case'Class) is Block1, Block2 : LSC.Internal.SHA256.Block_Type; SHA256_Context1 : OpenSSL.SHA256_Context_Type; SHA256_Context2 : LSC.Internal.SHA256.Context_Type; H1, H2 : LSC.Internal.SHA256.SHA256_Hash_Type; begin Block1 := LSC.Internal.SHA256.Block_Type'(others => 16#cafebabe#); Block2 := LSC.Internal.SHA256.Block_Type'(others => 16#00636261#); T.Reference_Start := Clock; for I in Natural range 1 .. 500000 loop OpenSSL.SHA256_Context_Init (SHA256_Context1); OpenSSL.SHA256_Context_Update (SHA256_Context1, Block1); OpenSSL.SHA256_Context_Finalize (SHA256_Context1, Block2, 56); end loop; H1 := OpenSSL.SHA256_Get_Hash (SHA256_Context1); T.Reference_Stop := Clock; T.Test_Start := Clock; for I in Natural range 1 .. 500000 loop SHA256_Context2 := LSC.Internal.SHA256.SHA256_Context_Init; LSC.Internal.SHA256.Context_Update (SHA256_Context2, Block1); LSC.Internal.SHA256.Context_Finalize (SHA256_Context2, Block2, 56); end loop; H2 := LSC.Internal.SHA256.SHA256_Get_Hash (SHA256_Context2); T.Test_Stop := Clock; Assert (H1 = H2, "Invalid hash"); end Benchmark_SHA256; --------------------------------------------------------------------------- procedure Benchmark_SHA384 (T : in out Test_Case'Class) is Block1, Block2 : LSC.Internal.SHA512.Block_Type; SHA384_Context1 : OpenSSL.SHA384_Context_Type; SHA384_Context2 : LSC.Internal.SHA512.Context_Type; H1, H2 : LSC.Internal.SHA512.SHA384_Hash_Type; begin Block1 := LSC.Internal.SHA512.Block_Type'(others => 16#deadbeefcafebabe#); Block2 := LSC.Internal.SHA512.Block_Type'(others => 16#0000000000636261#); T.Reference_Start := Clock; for I in Natural range 1 .. 500000 loop OpenSSL.SHA384_Context_Init (SHA384_Context1); OpenSSL.SHA384_Context_Update (SHA384_Context1, Block1); OpenSSL.SHA384_Context_Finalize (SHA384_Context1, Block2, 56); end loop; H1 := OpenSSL.SHA384_Get_Hash (SHA384_Context1); T.Reference_Stop := Clock; T.Test_Start := Clock; for I in Natural range 1 .. 500000 loop SHA384_Context2 := LSC.Internal.SHA512.SHA384_Context_Init; LSC.Internal.SHA512.Context_Update (SHA384_Context2, Block1); LSC.Internal.SHA512.Context_Finalize (SHA384_Context2, Block2, 56); end loop; H2 := LSC.Internal.SHA512.SHA384_Get_Hash (SHA384_Context2); T.Test_Stop := Clock; Assert (H1 = H2, "Invalid hash"); end Benchmark_SHA384; --------------------------------------------------------------------------- procedure Benchmark_SHA512 (T : in out Test_Case'Class) is Block1, Block2 : LSC.Internal.SHA512.Block_Type; SHA512_Context1 : OpenSSL.SHA512_Context_Type; SHA512_Context2 : LSC.Internal.SHA512.Context_Type; H1, H2 : LSC.Internal.SHA512.SHA512_Hash_Type; begin Block1 := LSC.Internal.SHA512.Block_Type'(others => 16#deadbeefcafebabe#); Block2 := LSC.Internal.SHA512.Block_Type'(others => 16#0000000000636261#); T.Reference_Start := Clock; for I in Natural range 1 .. 500000 loop OpenSSL.SHA512_Context_Init (SHA512_Context1); OpenSSL.SHA512_Context_Update (SHA512_Context1, Block1); OpenSSL.SHA512_Context_Finalize (SHA512_Context1, Block2, 56); end loop; H1 := OpenSSL.SHA512_Get_Hash (SHA512_Context1); T.Reference_Stop := Clock; T.Test_Start := Clock; for I in Natural range 1 .. 500000 loop SHA512_Context2 := LSC.Internal.SHA512.SHA512_Context_Init; LSC.Internal.SHA512.Context_Update (SHA512_Context2, Block1); LSC.Internal.SHA512.Context_Finalize (SHA512_Context2, Block2, 56); end loop; H2 := LSC.Internal.SHA512.SHA512_Get_Hash (SHA512_Context2); T.Test_Stop := Clock; Assert (H1 = H2, "Invalid hash"); end Benchmark_SHA512; --------------------------------------------------------------------------- procedure Benchmark_AES128_Decrypt (T : in out Test_Case'Class) is subtype Message_Index is Natural range 1 .. 1000; subtype Message_Type is LSC.Internal.AES.Message_Type (Message_Index); Plain1, Plain2, Cipher : Message_Type; Key128 : LSC.Internal.AES.AES128_Key_Type; Context1 : OpenSSL.AES_Dec_Context_Type; Context2 : LSC.Internal.AES.AES_Dec_Context; begin Cipher := Message_Type' (others => LSC.Internal.AES.Block_Type'(16#33221100#, 16#77665544#, 16#bbaa9988#, 16#ffeeddcc#)); Key128 := LSC.Internal.AES.AES128_Key_Type'(16#03020100#, 16#07060504#, 16#0b0a0908#, 16#1f1e1d1c#); T.Reference_Start := Clock; Context1 := OpenSSL.Create_AES128_Dec_Context (Key128); for k in Natural range 1 .. 20 loop for I in Message_Index loop Plain1 (I) := OpenSSL.Decrypt (Context1, Cipher (I)); end loop; end loop; T.Reference_Stop := Clock; T.Test_Start := Clock; Context2 := LSC.Internal.AES.Create_AES128_Dec_Context (Key128); for k in Natural range 1 .. 20 loop for I in Message_Index loop Plain2 (I) := LSC.Internal.AES.Decrypt (Context2, Cipher (I)); end loop; end loop; T.Test_Stop := Clock; Assert (Plain1 = Plain2, "Invalid decryption"); end Benchmark_AES128_Decrypt; --------------------------------------------------------------------------- procedure Benchmark_AES128_CBC_Decrypt (T : in out Test_Case'Class) is subtype Message_Index is Natural range 1 .. 1000; subtype Message_Type is LSC.Internal.AES.Message_Type (Message_Index); Plain1, Plain2, Cipher : Message_Type; Key128 : LSC.Internal.AES.AES128_Key_Type; Context1 : OpenSSL.AES_Dec_Context_Type; Context2 : LSC.Internal.AES.AES_Dec_Context; IV : LSC.Internal.AES.Block_Type; begin IV := LSC.Internal.AES.Block_Type' (16#cafebabe#, 16#deadbeef#, 16#d00faffe#, 16#12345678#); Cipher := Message_Type' (others => LSC.Internal.AES.Block_Type'(16#33221100#, 16#77665544#, 16#bbaa9988#, 16#ffeeddcc#)); Key128 := LSC.Internal.AES.AES128_Key_Type'(16#03020100#, 16#07060504#, 16#0b0a0908#, 16#1f1e1d1c#); T.Reference_Start := Clock; Context1 := OpenSSL.Create_AES128_Dec_Context (Key128); for k in Natural range 1 .. 20 loop OpenSSL.CBC_Decrypt (Cipher, Plain1, Context1, IV); end loop; T.Reference_Stop := Clock; T.Test_Start := Clock; Context2 := LSC.Internal.AES.Create_AES128_Dec_Context (Key128); for k in Natural range 1 .. 20 loop LSC.Internal.AES.CBC.Decrypt (Context2, IV, Cipher, Cipher'Length, Plain2); end loop; T.Test_Stop := Clock; Assert (Plain1 = Plain2, "Invalid decryption"); end Benchmark_AES128_CBC_Decrypt; --------------------------------------------------------------------------- procedure Benchmark_AES128_Encrypt (T : in out Test_Case'Class) is subtype Message_Index is Natural range 1 .. 1000; subtype Message_Type is LSC.Internal.AES.Message_Type (Message_Index); Plain, Cipher1, Cipher2 : Message_Type; Key128 : LSC.Internal.AES.AES128_Key_Type; Context1 : OpenSSL.AES_Enc_Context_Type; Context2 : LSC.Internal.AES.AES_Enc_Context; begin Plain := Message_Type' (others => LSC.Internal.AES.Block_Type'(16#33221100#, 16#77665544#, 16#bbaa9988#, 16#ffeeddcc#)); Key128 := LSC.Internal.AES.AES128_Key_Type'(16#03020100#, 16#07060504#, 16#0b0a0908#, 16#0f0e0d0c#); T.Reference_Start := Clock; Context1 := OpenSSL.Create_AES128_Enc_Context (Key128); for k in Natural range 1 .. 20 loop for I in Message_Index loop Cipher1 (I) := OpenSSL.Encrypt (Context1, Plain (I)); end loop; end loop; T.Reference_Stop := Clock; T.Test_Start := Clock; Context2 := LSC.Internal.AES.Create_AES128_Enc_Context (Key128); for k in Natural range 1 .. 20 loop for I in Message_Index loop Cipher2 (I) := LSC.Internal.AES.Encrypt (Context2, Plain (I)); end loop; end loop; T.Test_Stop := Clock; Assert (Cipher1 = Cipher2, "Invalid encryption"); end Benchmark_AES128_Encrypt; --------------------------------------------------------------------------- procedure Benchmark_AES128_CBC_Encrypt (T : in out Test_Case'Class) is subtype Message_Index is Natural range 1 .. 1000; subtype Message_Type is LSC.Internal.AES.Message_Type (Message_Index); Plain, Cipher1, Cipher2 : Message_Type; Key128 : LSC.Internal.AES.AES128_Key_Type; Context1 : OpenSSL.AES_Enc_Context_Type; Context2 : LSC.Internal.AES.AES_Enc_Context; IV : LSC.Internal.AES.Block_Type; begin IV := LSC.Internal.AES.Block_Type' (16#cafebabe#, 16#deadbeef#, 16#d00faffe#, 16#12345678#); Plain := Message_Type' (others => LSC.Internal.AES.Block_Type'(16#33221100#, 16#77665544#, 16#bbaa9988#, 16#ffeeddcc#)); Key128 := LSC.Internal.AES.AES128_Key_Type'(16#03020100#, 16#07060504#, 16#0b0a0908#, 16#0f0e0d0c#); T.Reference_Start := Clock; Context1 := OpenSSL.Create_AES128_Enc_Context (Key128); for k in Natural range 1 .. 20 loop OpenSSL.CBC_Encrypt (Plain, Cipher1, Context1, IV); end loop; T.Reference_Stop := Clock; T.Test_Start := Clock; Context2 := LSC.Internal.AES.Create_AES128_Enc_Context (Key128); for k in Natural range 1 .. 20 loop LSC.Internal.AES.CBC.Encrypt (Context2, IV, Plain, Plain'Length, Cipher2); end loop; T.Test_Stop := Clock; Assert (Cipher1 = Cipher2, "Invalid decryption"); end Benchmark_AES128_CBC_Encrypt; --------------------------------------------------------------------------- procedure Benchmark_AES192_Decrypt (T : in out Test_Case'Class) is subtype Message_Index is Natural range 1 .. 1000; subtype Message_Type is LSC.Internal.AES.Message_Type (Message_Index); Plain1, Plain2, Cipher : Message_Type; Key192 : LSC.Internal.AES.AES192_Key_Type; Context1 : OpenSSL.AES_Dec_Context_Type; Context2 : LSC.Internal.AES.AES_Dec_Context; begin Cipher := Message_Type' (others => LSC.Internal.AES.Block_Type'(16#33221100#, 16#77665544#, 16#bbaa9988#, 16#ffeeddcc#)); Key192 := LSC.Internal.AES.AES192_Key_Type'(16#03020100#, 16#07060504#, 16#13121110#, 16#17161514#, 16#1b1a1918#, 16#1f1e1d1c#); T.Reference_Start := Clock; Context1 := OpenSSL.Create_AES192_Dec_Context (Key192); for k in Natural range 1 .. 20 loop for I in Message_Index loop Plain1 (I) := OpenSSL.Decrypt (Context1, Cipher (I)); end loop; end loop; T.Reference_Stop := Clock; T.Test_Start := Clock; Context2 := LSC.Internal.AES.Create_AES192_Dec_Context (Key192); for k in Natural range 1 .. 20 loop for I in Message_Index loop Plain2 (I) := LSC.Internal.AES.Decrypt (Context2, Cipher (I)); end loop; end loop; T.Test_Stop := Clock; Assert (Plain1 = Plain2, "Invalid decryption"); end Benchmark_AES192_Decrypt; --------------------------------------------------------------------------- procedure Benchmark_AES192_CBC_Decrypt (T : in out Test_Case'Class) is subtype Message_Index is Natural range 1 .. 1000; subtype Message_Type is LSC.Internal.AES.Message_Type (Message_Index); Plain1, Plain2, Cipher : Message_Type; Key192 : LSC.Internal.AES.AES192_Key_Type; Context1 : OpenSSL.AES_Dec_Context_Type; Context2 : LSC.Internal.AES.AES_Dec_Context; IV : LSC.Internal.AES.Block_Type; begin IV := LSC.Internal.AES.Block_Type' (16#cafebabe#, 16#deadbeef#, 16#d00faffe#, 16#12345678#); Cipher := Message_Type' (others => LSC.Internal.AES.Block_Type'(16#33221100#, 16#77665544#, 16#bbaa9988#, 16#ffeeddcc#)); Key192 := LSC.Internal.AES.AES192_Key_Type'(16#03020100#, 16#07060504#, 16#13121110#, 16#17161514#, 16#1b1a1918#, 16#1f1e1d1c#); T.Reference_Start := Clock; Context1 := OpenSSL.Create_AES192_Dec_Context (Key192); for k in Natural range 1 .. 20 loop OpenSSL.CBC_Decrypt (Cipher, Plain1, Context1, IV); end loop; T.Reference_Stop := Clock; T.Test_Start := Clock; Context2 := LSC.Internal.AES.Create_AES192_Dec_Context (Key192); for k in Natural range 1 .. 20 loop LSC.Internal.AES.CBC.Decrypt (Context2, IV, Cipher, Cipher'Length, Plain2); end loop; T.Test_Stop := Clock; Assert (Plain1 = Plain2, "Invalid decryption"); end Benchmark_AES192_CBC_Decrypt; --------------------------------------------------------------------------- procedure Benchmark_AES192_Encrypt (T : in out Test_Case'Class) is subtype Message_Index is Natural range 1 .. 1000; subtype Message_Type is LSC.Internal.AES.Message_Type (Message_Index); Plain, Cipher1, Cipher2 : Message_Type; Key192 : LSC.Internal.AES.AES192_Key_Type; Context1 : OpenSSL.AES_Enc_Context_Type; Context2 : LSC.Internal.AES.AES_Enc_Context; begin Plain := Message_Type' (others => LSC.Internal.AES.Block_Type'(16#33221100#, 16#77665544#, 16#bbaa9988#, 16#ffeeddcc#)); Key192 := LSC.Internal.AES.AES192_Key_Type'(16#03020100#, 16#07060504#, 16#07060504#, 16#0b0a0908#, 16#0b0a0908#, 16#0f0e0d0c#); T.Reference_Start := Clock; Context1 := OpenSSL.Create_AES192_Enc_Context (Key192); for k in Natural range 1 .. 20 loop for I in Message_Index loop Cipher1 (I) := OpenSSL.Encrypt (Context1, Plain (I)); end loop; end loop; T.Reference_Stop := Clock; T.Test_Start := Clock; Context2 := LSC.Internal.AES.Create_AES192_Enc_Context (Key192); for k in Natural range 1 .. 20 loop for I in Message_Index loop Cipher2 (I) := LSC.Internal.AES.Encrypt (Context2, Plain (I)); end loop; end loop; T.Test_Stop := Clock; Assert (Cipher1 = Cipher2, "Invalid encryption"); end Benchmark_AES192_Encrypt; --------------------------------------------------------------------------- procedure Benchmark_AES192_CBC_Encrypt (T : in out Test_Case'Class) is subtype Message_Index is Natural range 1 .. 1000; subtype Message_Type is LSC.Internal.AES.Message_Type (Message_Index); Plain, Cipher1, Cipher2 : Message_Type; Key192 : LSC.Internal.AES.AES192_Key_Type; Context1 : OpenSSL.AES_Enc_Context_Type; Context2 : LSC.Internal.AES.AES_Enc_Context; IV : LSC.Internal.AES.Block_Type; begin IV := LSC.Internal.AES.Block_Type' (16#cafebabe#, 16#deadbeef#, 16#d00faffe#, 16#12345678#); Plain := Message_Type' (others => LSC.Internal.AES.Block_Type'(16#33221100#, 16#77665544#, 16#bbaa9988#, 16#ffeeddcc#)); Key192 := LSC.Internal.AES.AES192_Key_Type'(16#03020100#, 16#07060504#, 16#07060504#, 16#0b0a0908#, 16#0b0a0908#, 16#0f0e0d0c#); T.Reference_Start := Clock; Context1 := OpenSSL.Create_AES192_Enc_Context (Key192); for k in Natural range 1 .. 20 loop OpenSSL.CBC_Encrypt (Plain, Cipher1, Context1, IV); end loop; T.Reference_Stop := Clock; T.Test_Start := Clock; Context2 := LSC.Internal.AES.Create_AES192_Enc_Context (Key192); for k in Natural range 1 .. 20 loop LSC.Internal.AES.CBC.Encrypt (Context2, IV, Plain, Plain'Length, Cipher2); end loop; T.Test_Stop := Clock; Assert (Cipher1 = Cipher2, "Invalid encryption"); end Benchmark_AES192_CBC_Encrypt; --------------------------------------------------------------------------- procedure Benchmark_AES256_Decrypt (T : in out Test_Case'Class) is subtype Message_Index is Natural range 1 .. 1000; subtype Message_Type is LSC.Internal.AES.Message_Type (Message_Index); Plain1, Plain2, Cipher : Message_Type; Key256 : LSC.Internal.AES.AES256_Key_Type; Context1 : OpenSSL.AES_Dec_Context_Type; Context2 : LSC.Internal.AES.AES_Dec_Context; begin Cipher := Message_Type' (others => LSC.Internal.AES.Block_Type'(16#33221100#, 16#77665544#, 16#bbaa9988#, 16#ffeeddcc#)); Key256 := LSC.Internal.AES.AES256_Key_Type'(16#03020100#, 16#07060504#, 16#0b0a0908#, 16#0f0e0d0c#, 16#13121110#, 16#17161514#, 16#1b1a1918#, 16#1f1e1d1c#); T.Reference_Start := Clock; Context1 := OpenSSL.Create_AES256_Dec_Context (Key256); for k in Natural range 1 .. 20 loop for I in Message_Index loop Plain1 (I) := OpenSSL.Decrypt (Context1, Cipher (I)); end loop; end loop; T.Reference_Stop := Clock; T.Test_Start := Clock; Context2 := LSC.Internal.AES.Create_AES256_Dec_Context (Key256); for k in Natural range 1 .. 20 loop for I in Message_Index loop Plain2 (I) := LSC.Internal.AES.Decrypt (Context2, Cipher (I)); end loop; end loop; T.Test_Stop := Clock; Assert (Plain1 = Plain2, "Invalid decryption"); end Benchmark_AES256_Decrypt; --------------------------------------------------------------------------- procedure Benchmark_AES256_CBC_Decrypt (T : in out Test_Case'Class) is subtype Message_Index is Natural range 1 .. 1000; subtype Message_Type is LSC.Internal.AES.Message_Type (Message_Index); Plain1, Plain2, Cipher : Message_Type; Key256 : LSC.Internal.AES.AES256_Key_Type; Context1 : OpenSSL.AES_Dec_Context_Type; Context2 : LSC.Internal.AES.AES_Dec_Context; IV : LSC.Internal.AES.Block_Type; begin IV := LSC.Internal.AES.Block_Type' (16#cafebabe#, 16#deadbeef#, 16#d00faffe#, 16#12345678#); Cipher := Message_Type' (others => LSC.Internal.AES.Block_Type'(16#33221100#, 16#77665544#, 16#bbaa9988#, 16#ffeeddcc#)); Key256 := LSC.Internal.AES.AES256_Key_Type'(16#03020100#, 16#07060504#, 16#0b0a0908#, 16#0f0e0d0c#, 16#13121110#, 16#17161514#, 16#1b1a1918#, 16#1f1e1d1c#); T.Reference_Start := Clock; Context1 := OpenSSL.Create_AES256_Dec_Context (Key256); for k in Natural range 1 .. 20 loop OpenSSL.CBC_Decrypt (Cipher, Plain1, Context1, IV); end loop; T.Reference_Stop := Clock; T.Test_Start := Clock; Context2 := LSC.Internal.AES.Create_AES256_Dec_Context (Key256); for k in Natural range 1 .. 20 loop LSC.Internal.AES.CBC.Decrypt (Context2, IV, Cipher, Cipher'Length, Plain2); end loop; T.Test_Stop := Clock; Assert (Plain1 = Plain2, "Invalid decryption"); end Benchmark_AES256_CBC_Decrypt; --------------------------------------------------------------------------- procedure Benchmark_AES256_Encrypt (T : in out Test_Case'Class) is subtype Message_Index is Natural range 1 .. 1000; subtype Message_Type is LSC.Internal.AES.Message_Type (Message_Index); Plain, Cipher1, Cipher2 : Message_Type; Key256 : LSC.Internal.AES.AES256_Key_Type; Context1 : OpenSSL.AES_Enc_Context_Type; Context2 : LSC.Internal.AES.AES_Enc_Context; begin Plain := Message_Type' (others => LSC.Internal.AES.Block_Type'(16#33221100#, 16#77665544#, 16#bbaa9988#, 16#ffeeddcc#)); Key256 := LSC.Internal.AES.AES256_Key_Type'(16#03020100#, 16#07060504#, 16#0b0a0908#, 16#0f0e0d0c#, 16#13121110#, 16#17161514#, 16#1b1a1918#, 16#1f1e1d1c#); T.Reference_Start := Clock; Context1 := OpenSSL.Create_AES256_Enc_Context (Key256); for k in Natural range 1 .. 20 loop for I in Message_Index loop Cipher1 (I) := OpenSSL.Encrypt (Context1, Plain (I)); end loop; end loop; T.Reference_Stop := Clock; T.Test_Start := Clock; Context2 := LSC.Internal.AES.Create_AES256_Enc_Context (Key256); for k in Natural range 1 .. 20 loop for I in Message_Index loop Cipher2 (I) := LSC.Internal.AES.Encrypt (Context2, Plain (I)); end loop; end loop; T.Test_Stop := Clock; Assert (Cipher1 = Cipher2, "Invalid encryption"); end Benchmark_AES256_Encrypt; --------------------------------------------------------------------------- procedure Benchmark_AES256_CBC_Encrypt (T : in out Test_Case'Class) is subtype Message_Index is Natural range 1 .. 1000; subtype Message_Type is LSC.Internal.AES.Message_Type (Message_Index); Plain, Cipher1, Cipher2 : Message_Type; Key256 : LSC.Internal.AES.AES256_Key_Type; Context1 : OpenSSL.AES_Enc_Context_Type; Context2 : LSC.Internal.AES.AES_Enc_Context; IV : LSC.Internal.AES.Block_Type; begin IV := LSC.Internal.AES.Block_Type' (16#cafebabe#, 16#deadbeef#, 16#d00faffe#, 16#12345678#); Plain := Message_Type' (others => LSC.Internal.AES.Block_Type'(16#33221100#, 16#77665544#, 16#bbaa9988#, 16#ffeeddcc#)); Key256 := LSC.Internal.AES.AES256_Key_Type'(16#03020100#, 16#07060504#, 16#0b0a0908#, 16#0f0e0d0c#, 16#13121110#, 16#17161514#, 16#1b1a1918#, 16#1f1e1d1c#); T.Reference_Start := Clock; Context1 := OpenSSL.Create_AES256_Enc_Context (Key256); for k in Natural range 1 .. 20 loop OpenSSL.CBC_Encrypt (Plain, Cipher1, Context1, IV); end loop; T.Reference_Stop := Clock; T.Test_Start := Clock; Context2 := LSC.Internal.AES.Create_AES256_Enc_Context (Key256); for k in Natural range 1 .. 20 loop LSC.Internal.AES.CBC.Encrypt (Context2, IV, Plain, Plain'Length, Cipher2); end loop; T.Test_Stop := Clock; Assert (Cipher1 = Cipher2, "Invalid encryption"); end Benchmark_AES256_CBC_Encrypt; --------------------------------------------------------------------------- procedure Benchmark_HMAC_RIPEMD160 (T : in out Test_Case'Class) is Message : constant OpenSSL.RMD160_Message_Type := OpenSSL.RMD160_Message_Type' (others => LSC.Internal.RIPEMD160.Block_Type'(others => 16#dead_beef#)); Key : constant LSC.Internal.RIPEMD160.Block_Type := LSC.Internal.RIPEMD160.Block_Type' (others => 16#c0deaffe#); H1 : LSC.Internal.RIPEMD160.Hash_Type; H2 : LSC.Internal.RIPEMD160.Hash_Type; begin T.Reference_Start := Clock; for I in Natural range 1 .. 50000 loop H1 := OpenSSL.Authenticate_RMD160 (Key, Message, 10000); end loop; T.Reference_Stop := Clock; T.Test_Start := Clock; for I in Natural range 1 .. 50000 loop H2 := LSC.Internal.HMAC_RIPEMD160.Authenticate (Key, Message, 10000); end loop; T.Test_Stop := Clock; Assert (H1 = H2, "Invalid encryption"); end Benchmark_HMAC_RIPEMD160; --------------------------------------------------------------------------- procedure Benchmark_HMAC_SHA1 (T : in out Test_Case'Class) is Message : constant OpenSSL.SHA1_Message_Type := OpenSSL.SHA1_Message_Type' (others => LSC.Internal.SHA1.Block_Type'(others => 16#dead_beef#)); Key : constant LSC.Internal.SHA1.Block_Type := LSC.Internal.SHA1.Block_Type'(others => 16#c0deaffe#); H1 : LSC.Internal.SHA1.Hash_Type; H2 : LSC.Internal.SHA1.Hash_Type; begin T.Reference_Start := Clock; for I in Natural range 1 .. 50000 loop H1 := OpenSSL.Authenticate_SHA1 (Key, Message, 10000); end loop; T.Reference_Stop := Clock; T.Test_Start := Clock; for I in Natural range 1 .. 50000 loop H2 := LSC.Internal.HMAC_SHA1.Authenticate (Key, Message, 10000); end loop; T.Test_Stop := Clock; Assert (H1 = H2, "Invalid encryption"); end Benchmark_HMAC_SHA1; --------------------------------------------------------------------------- procedure Benchmark_HMAC_SHA256 (T : in out Test_Case'Class) is use type LSC.Internal.SHA256.Message_Index; use type Interfaces.Unsigned_64; Message : constant OpenSSL.SHA256_Message_Type := OpenSSL.SHA256_Message_Type' (others => LSC.Internal.SHA256.Block_Type'(others => 16#dead_beef#)); Key : constant LSC.Internal.SHA256.Block_Type := LSC.Internal.SHA256.Block_Type' (others => 16#c0deaffe#); H1 : LSC.Internal.HMAC_SHA256.Auth_Type; H2 : LSC.Internal.HMAC_SHA256.Auth_Type; begin T.Reference_Start := Clock; for I in Natural range 1 .. 50000 loop H1 := OpenSSL.Authenticate_SHA256 (Key, Message, Message'Size / 8); end loop; T.Reference_Stop := Clock; T.Test_Start := Clock; for I in Natural range 1 .. 50000 loop H2 := LSC.Internal.HMAC_SHA256.Authenticate (Key, Message, Message'Size / 8); end loop; T.Test_Stop := Clock; Assert (H1 = H2, "Invalid encryption"); end Benchmark_HMAC_SHA256; --------------------------------------------------------------------------- procedure Benchmark_HMAC_SHA384 (T : in out Test_Case'Class) is use type LSC.Internal.SHA512.Message_Index; use type Interfaces.Unsigned_64; Message : constant OpenSSL.SHA512_Message_Type := OpenSSL.SHA512_Message_Type' (others => LSC.Internal.SHA512.Block_Type'(others => 16#dead_beef_dead_c0de#)); Key : constant LSC.Internal.SHA512.Block_Type := LSC.Internal.SHA512.Block_Type' (others => 16#c0de_affe_cafe_babe#); H1 : LSC.Internal.HMAC_SHA384.Auth_Type; H2 : LSC.Internal.HMAC_SHA384.Auth_Type; begin T.Reference_Start := Clock; for I in Natural range 1 .. 50000 loop H1 := OpenSSL.Authenticate_SHA384 (Key, Message, Message'Size / 8); end loop; T.Reference_Stop := Clock; T.Test_Start := Clock; for I in Natural range 1 .. 50000 loop H2 := LSC.Internal.HMAC_SHA384.Authenticate (Key, Message, Message'Size / 8); end loop; T.Test_Stop := Clock; Assert (H1 = H2, "Invalid encryption"); end Benchmark_HMAC_SHA384; --------------------------------------------------------------------------- procedure Benchmark_HMAC_SHA512 (T : in out Test_Case'Class) is use type LSC.Internal.SHA512.Message_Index; use type Interfaces.Unsigned_64; Message : constant OpenSSL.SHA512_Message_Type := OpenSSL.SHA512_Message_Type' (others => LSC.Internal.SHA512.Block_Type'(others => 16#dead_beef_dead_c0de#)); Key : constant LSC.Internal.SHA512.Block_Type := LSC.Internal.SHA512.Block_Type' (others => 16#c0de_affe_cafe_babe#); H1 : LSC.Internal.HMAC_SHA512.Auth_Type; H2 : LSC.Internal.HMAC_SHA512.Auth_Type; begin T.Reference_Start := Clock; for I in Natural range 1 .. 50000 loop H1 := OpenSSL.Authenticate_SHA512 (Key, Message, Message'Size / 8); end loop; T.Reference_Stop := Clock; T.Test_Start := Clock; for I in Natural range 1 .. 50000 loop H2 := LSC.Internal.HMAC_SHA512.Authenticate (Key, Message, Message'Size / 8); end loop; T.Test_Stop := Clock; Assert (H1 = H2, "Invalid encryption"); end Benchmark_HMAC_SHA512; --------------------------------------------------------------------------- procedure Benchmark_Bignum_RSA2048 (T : in out Test_Case'Class) is Window_Size : constant := 5; subtype Mod_Range_Small is Natural range 0 .. 63; subtype Mod_Range is Natural range 0 .. 127; subtype Pub_Exp_Range is Natural range 0 .. 0; subtype Window_Aux_Range is Natural range 0 .. 128 * (2 ** Window_Size) - 1; subtype LInt_Small is LSC.Internal.Bignum.Big_Int (Mod_Range_Small); subtype LInt is LSC.Internal.Bignum.Big_Int (Mod_Range); subtype SInt is LSC.Internal.Bignum.Big_Int (Pub_Exp_Range); subtype Window_Aux is LSC.Internal.Bignum.Big_Int (Window_Aux_Range); Pub_Exp : constant SInt := SInt'(0 => 16#00010001#); -- 2048 bit Modulus_Small : constant LInt_Small := LInt_Small' (16#e3855b7b#, 16#695e1d0c#, 16#2f3a389f#, 16#e4e8cfbc#, 16#366c3c0b#, 16#07f34b0d#, 16#a92ff519#, 16#566a909a#, 16#d79ecc36#, 16#e392c334#, 16#dbbb737f#, 16#80c97ddd#, 16#812a798c#, 16#0fdf31b2#, 16#c9c3978b#, 16#f526906b#, 16#cf23d190#, 16#ea1e08a2#, 16#08cf9c02#, 16#b3b794fb#, 16#7855c403#, 16#49b10dd8#, 16#6ca17d12#, 16#b069b1ab#, 16#b8d28b35#, 16#a08d0a13#, 16#1a1bf74d#, 16#30ca19b3#, 16#29e5abd7#, 16#4ccb0a06#, 16#7bae2533#, 16#fc040833#, 16#2c1c80c5#, 16#ea729a13#, 16#ac5ffd04#, 16#a2dcc2f9#, 16#c1f9c72c#, 16#f466adf6#, 16#ea152c47#, 16#42d76640#, 16#8b5c067a#, 16#8c870d16#, 16#d3dacf2f#, 16#df33c327#, 16#fdddf873#, 16#592c3110#, 16#a94e6415#, 16#6b0f63f4#, 16#84919783#, 16#da1672d1#, 16#6d2b736e#, 16#3c02711d#, 16#eba01b1d#, 16#04463ba8#, 16#a8f0f41b#, 16#d41c9a16#, 16#2e0a1c54#, 16#e8340e9b#, 16#0194cdee#, 16#4beacec6#, 16#e23ee4a4#, 16#ec602901#, 16#079751bd#, 16#Dad31766#); Priv_Exp_Small : constant LInt_Small := LInt_Small' (16#3fd9f299#, 16#64a02913#, 16#780db9d7#, 16#164c83cd#, 16#70ac88cc#, 16#14e9bfcc#, 16#bff4fa46#, 16#a2956db0#, 16#d5952d92#, 16#d8e23b1b#, 16#d252925c#, 16#f63f2570#, 16#1232a957#, 16#0ecdf6fc#, 16#23356dd5#, 16#6dfd8463#, 16#b88e9193#, 16#3e337443#, 16#c30bd004#, 16#f86471bc#, 16#26836b1f#, 16#36792ee7#, 16#fd7774c3#, 16#e947afe5#, 16#403e454e#, 16#60886c2f#, 16#7da04cab#, 16#0006c1c8#, 16#87bfa8cc#, 16#c644e026#, 16#8eea8cce#, 16#beca39f9#, 16#60c3808d#, 16#2faf499f#, 16#c81d0c50#, 16#ef2e6e1b#, 16#ae3dbc3f#, 16#54a6e7b8#, 16#efdc4e55#, 16#e0ed4e41#, 16#6ddee985#, 16#2c988959#, 16#2bdbffad#, 16#ec9c5635#, 16#a6ad3fef#, 16#5df1f2a6#, 16#e4ec57d3#, 16#1c823145#, 16#eecff08e#, 16#51b9f682#, 16#c8ec37a1#, 16#1212a615#, 16#9265aeed#, 16#4b4e2491#, 16#2b29d53a#, 16#2bd57be9#, 16#ffd21ce0#, 16#bccc6401#, 16#e2d6c019#, 16#c98b2771#, 16#4d4cde01#, 16#d507d875#, 16#886bab53#, 16#7cac4629#); Aux1, Aux2, Aux3, R : LInt; Aux4 : Window_Aux; M_Inv : LSC.Internal.Types.Word32; Plain1_Small, OpenSSL_Plain1_Small : LInt_Small; Plain2_Small, Plain3_Small, OpenSSL_Plain2_Small : LInt_Small; Cipher1_Small, Cipher2_Small, OpenSSL_Cipher_Small : LInt_Small; OpenSSL_Modulus_Small, OpenSSL_Priv_Exp_Small : LInt_Small; OpenSSL_Pub_Exp : SInt; Success_Enc, Success_Dec : Boolean; begin LSC.Internal.Bignum.Native_To_BE (Pub_Exp, Pub_Exp'First, Pub_Exp'Last, OpenSSL_Pub_Exp, OpenSSL_Pub_Exp'First); -- 2048 bit -- Create original data for I in Natural range Modulus_Small'Range loop Plain1_Small (I) := LSC.Internal.Types.Word32 (I); end loop; -- Convert modulus, exponent and plaintext to format expected by OpenSSL LSC.Internal.Bignum.Native_To_BE (Priv_Exp_Small, Priv_Exp_Small'First, Priv_Exp_Small'Last, OpenSSL_Priv_Exp_Small, OpenSSL_Priv_Exp_Small'First); LSC.Internal.Bignum.Native_To_BE (Modulus_Small, Modulus_Small'First, Modulus_Small'Last, OpenSSL_Modulus_Small, OpenSSL_Modulus_Small'First); LSC.Internal.Bignum.Native_To_BE (Plain1_Small, Plain1_Small'First, Plain1_Small'Last, OpenSSL_Plain1_Small, OpenSSL_Plain1_Small'First); T.Reference_Start := Clock; OpenSSL.RSA_Public_Encrypt (OpenSSL_Modulus_Small, OpenSSL_Pub_Exp, OpenSSL_Plain1_Small, OpenSSL_Cipher_Small, Success_Enc); OpenSSL.RSA_Private_Decrypt (OpenSSL_Modulus_Small, OpenSSL_Pub_Exp, OpenSSL_Priv_Exp_Small, OpenSSL_Cipher_Small, OpenSSL_Plain2_Small, Success_Dec); T.Reference_Stop := Clock; LSC.Internal.Bignum.Native_To_BE (OpenSSL_Cipher_Small, OpenSSL_Cipher_Small'First, OpenSSL_Cipher_Small'Last, Cipher2_Small, Cipher2_Small'First); LSC.Internal.Bignum.Native_To_BE (OpenSSL_Plain2_Small, OpenSSL_Plain2_Small'First, OpenSSL_Plain2_Small'Last, Plain3_Small, Plain3_Small'First); -- Precompute R^2 mod m LSC.Internal.Bignum.Size_Square_Mod (M => Modulus_Small, M_First => Modulus_Small'First, M_Last => Modulus_Small'Last, R => R, R_First => R'First); -- Precompute inverse M_Inv := LSC.Internal.Bignum.Word_Inverse (Modulus_Small (Modulus_Small'First)); T.Test_Start := Clock; -- Encrypt LSC.Internal.Bignum.Mont_Exp_Window (A => Cipher1_Small, A_First => Cipher1_Small'First, A_Last => Cipher1_Small'Last, X => Plain1_Small, X_First => Plain1_Small'First, E => Pub_Exp, E_First => Pub_Exp'First, E_Last => Pub_Exp'Last, M => Modulus_Small, M_First => Modulus_Small'First, K => Window_Size, Aux1 => Aux1, Aux1_First => Aux1'First, Aux2 => Aux2, Aux2_First => Aux2'First, Aux3 => Aux3, Aux3_First => Aux3'First, Aux4 => Aux4, Aux4_First => Aux4'First, R => R, R_First => R'First, M_Inv => M_Inv); -- Decrypt LSC.Internal.Bignum.Mont_Exp_Window (A => Plain2_Small, A_First => Plain2_Small'First, A_Last => Plain2_Small'Last, X => Cipher1_Small, X_First => Cipher1_Small'First, E => Priv_Exp_Small, E_First => Priv_Exp_Small'First, E_Last => Priv_Exp_Small'Last, M => Modulus_Small, M_First => Modulus_Small'First, K => Window_Size, Aux1 => Aux1, Aux1_First => Aux1'First, Aux2 => Aux2, Aux2_First => Aux2'First, Aux3 => Aux3, Aux3_First => Aux3'First, Aux4 => Aux4, Aux4_First => Aux4'First, R => R, R_First => R'First, M_Inv => M_Inv); T.Test_Stop := Clock; Assert (Success_Enc and then Success_Dec and then Cipher1_Small = Cipher2_Small and then Plain1_Small = Plain2_Small and then Plain2_Small = Plain3_Small, "Invalid RSA"); end Benchmark_Bignum_RSA2048; --------------------------------------------------------------------------- procedure Benchmark_Bignum_RSA4096 (T : in out Test_Case'Class) is Window_Size : constant := 5; subtype Mod_Range is Natural range 0 .. 127; subtype Pub_Exp_Range is Natural range 0 .. 0; subtype Window_Aux_Range is Natural range 0 .. 128 * (2 ** Window_Size) - 1; subtype LInt is LSC.Internal.Bignum.Big_Int (Mod_Range); subtype SInt is LSC.Internal.Bignum.Big_Int (Pub_Exp_Range); subtype Window_Aux is LSC.Internal.Bignum.Big_Int (Window_Aux_Range); Pub_Exp : constant SInt := SInt'(0 => 16#00010001#); Modulus : constant LInt := LInt' (16#27a3f371#, 16#f66dc29e#, 16#2c4cf251#, 16#0aa490b7#, 16#2eabfddb#, 16#4e6d1cc7#, 16#e67fc1bb#, 16#be3cc1e1#, 16#4338d3ae#, 16#372d809a#, 16#b9d33026#, 16#e3d05bff#, 16#886580b8#, 16#020b3b03#, 16#55c15179#, 16#a3c026b2#, 16#3e550dcb#, 16#821fcfee#, 16#4f44c3f9#, 16#25c8b0a5#, 16#30612a20#, 16#8c970432#, 16#32e395aa#, 16#1337a822#, 16#3db2c677#, 16#35a256d5#, 16#fcbf1cfc#, 16#6354fbe1#, 16#8d0874a2#, 16#a017fe19#, 16#07f415fc#, 16#e0a45678#, 16#c3e2f1c3#, 16#4b73d538#, 16#962f1c1c#, 16#448f15fb#, 16#d4ba9b05#, 16#9f6cc819#, 16#f36d2a06#, 16#d1c1d04a#, 16#efb31b76#, 16#c7cae1cf#, 16#e61520e4#, 16#984ec779#, 16#56f79b73#, 16#2f8ca314#, 16#a0c4e830#, 16#2e3eba5b#, 16#f739a437#, 16#7852b71e#, 16#aab09aa6#, 16#3d8dcdc3#, 16#f16ab197#, 16#8b3753d1#, 16#ec52c4e1#, 16#f70e4f7d#, 16#b4af5c60#, 16#82ae6ca4#, 16#fa6a8a1d#, 16#5655c33d#, 16#5096b17f#, 16#71c61b6a#, 16#28c84e83#, 16#07a0f985#, 16#b5523b0c#, 16#d31e75f6#, 16#c8139152#, 16#c94fb87f#, 16#d0d092c4#, 16#b5bae11d#, 16#3ebaa999#, 16#599cd667#, 16#a156c841#, 16#88a90d02#, 16#73e10c30#, 16#56b72050#, 16#1cb3c2d9#, 16#abef5973#, 16#8f42b61a#, 16#e54c7b3c#, 16#0b93bb83#, 16#5ca62bc2#, 16#1a9996a5#, 16#26b48d1b#, 16#98f932d1#, 16#3f56babe#, 16#dab5a0eb#, 16#4e0de31d#, 16#4bbe26d4#, 16#2812c4f8#, 16#f6d1866c#, 16#6800ef71#, 16#49cca290#, 16#aa1bbdee#, 16#ee8a75ea#, 16#4fc8516b#, 16#242c7f52#, 16#96df15ea#, 16#eaac1b33#, 16#c533d8fa#, 16#a649ef23#, 16#7d29eebb#, 16#8342ce68#, 16#36abe9c0#, 16#82adff4d#, 16#8fcc54b0#, 16#89144572#, 16#09dfcece#, 16#bcc22be3#, 16#b2184072#, 16#cf2cf6c3#, 16#dbb62eeb#, 16#9c44b29b#, 16#08dea7eb#, 16#8a92c57e#, 16#4ed90ea9#, 16#a73379d1#, 16#20767c8f#, 16#bcc1a56d#, 16#6fa7e726#, 16#d74d548d#, 16#ec21f388#, 16#a2344841#, 16#8b08a316#, 16#c99b8d76#, 16#d670befe#, 16#31a09763#, 16#d0055749#); Priv_Exp : constant LInt := LInt' (16#2e274601#, 16#8fab5c50#, 16#48b5239e#, 16#5a37865c#, 16#5670b41d#, 16#2da87796#, 16#3a82b988#, 16#7a7ce911#, 16#bd4e57b1#, 16#8f6d3da4#, 16#8669e6a0#, 16#3314c3e7#, 16#36248f99#, 16#4b3e25a7#, 16#600a6f7f#, 16#04eafed8#, 16#45050c07#, 16#f32daf96#, 16#6b6b4f21#, 16#cd177764#, 16#e4d13b46#, 16#80f34af3#, 16#1f601841#, 16#65bf67b8#, 16#33729106#, 16#56b14c9d#, 16#267c46be#, 16#d4acf88c#, 16#fc8ec97e#, 16#06d4df7e#, 16#198ec5fb#, 16#a098a033#, 16#c7dcc150#, 16#dc980d3f#, 16#29778f62#, 16#29f4cbca#, 16#e6d86584#, 16#9e366a7a#, 16#b39ab77a#, 16#1a956df3#, 16#da64c05b#, 16#6f4183a2#, 16#452ad7db#, 16#84d1f44e#, 16#88c4a697#, 16#d272546e#, 16#c0f5da10#, 16#dca7e68b#, 16#2316a1e5#, 16#93305fcd#, 16#10a0897b#, 16#e203fc89#, 16#163ef9fa#, 16#a3625c15#, 16#9719bace#, 16#c5bd6a66#, 16#466893e9#, 16#eb33cb36#, 16#ff6854e6#, 16#f8cf002f#, 16#5c84f1a6#, 16#f9d89029#, 16#a42c2f21#, 16#7c29e8b3#, 16#07188900#, 16#37a9da54#, 16#672715c3#, 16#ab9b69ac#, 16#2a32533c#, 16#592932ba#, 16#90843f00#, 16#4f540d7d#, 16#44f04b78#, 16#efeab1d4#, 16#bc5e76db#, 16#cd5bd78b#, 16#0eb2723f#, 16#bd633630#, 16#90bf30be#, 16#0023372e#, 16#5d50308b#, 16#4cbf539a#, 16#1abb5b44#, 16#30cc98de#, 16#869b24e0#, 16#78bda399#, 16#25e6f54c#, 16#96dac865#, 16#8db1dc73#, 16#770a4d97#, 16#31123fee#, 16#139ea6d0#, 16#786e32b2#, 16#f3998ab6#, 16#5fd4f43b#, 16#ae506344#, 16#797f633d#, 16#81682a87#, 16#9b5cb744#, 16#a40a97e5#, 16#e788eed8#, 16#5c2b1448#, 16#90780722#, 16#77af3218#, 16#66114d4f#, 16#8857c6c0#, 16#9899ef8a#, 16#dea4d612#, 16#f5986865#, 16#41b3caca#, 16#ebace112#, 16#1678338c#, 16#34e40889#, 16#3291e166#, 16#3f855200#, 16#e81eddcb#, 16#b08e2e77#, 16#238ac815#, 16#d2442787#, 16#bb20cea2#, 16#c4ae4e94#, 16#b575336a#, 16#cd55d286#, 16#e7387f77#, 16#a780f030#, 16#46526c31#, 16#0e4752a9#, 16#9b036fe1#); Aux1, Aux2, Aux3, R : LInt; Aux4 : Window_Aux; M_Inv : LSC.Internal.Types.Word32; Plain1, OpenSSL_Plain1 : LInt; Plain2, Plain3, OpenSSL_Plain2 : LInt; Cipher1, Cipher2, OpenSSL_Cipher : LInt; OpenSSL_Modulus, OpenSSL_Priv_Exp : LInt; OpenSSL_Pub_Exp : SInt; Success_Enc, Success_Dec : Boolean; begin LSC.Internal.Bignum.Native_To_BE (Pub_Exp, Pub_Exp'First, Pub_Exp'Last, OpenSSL_Pub_Exp, OpenSSL_Pub_Exp'First); -- Create original data for I in Natural range Modulus'Range loop Plain1 (I) := LSC.Internal.Types.Word32 (I); end loop; -- Convert modulus, exponent and plaintext to format expected by OpenSSL LSC.Internal.Bignum.Native_To_BE (Priv_Exp, Priv_Exp'First, Priv_Exp'Last, OpenSSL_Priv_Exp, OpenSSL_Priv_Exp'First); LSC.Internal.Bignum.Native_To_BE (Modulus, Modulus'First, Modulus'Last, OpenSSL_Modulus, OpenSSL_Modulus'First); LSC.Internal.Bignum.Native_To_BE (Plain1, Plain1'First, Plain1'Last, OpenSSL_Plain1, OpenSSL_Plain1'First); T.Reference_Start := Clock; OpenSSL.RSA_Public_Encrypt (OpenSSL_Modulus, OpenSSL_Pub_Exp, OpenSSL_Plain1, OpenSSL_Cipher, Success_Enc); OpenSSL.RSA_Private_Decrypt (OpenSSL_Modulus, OpenSSL_Pub_Exp, OpenSSL_Priv_Exp, OpenSSL_Cipher, OpenSSL_Plain2, Success_Dec); T.Reference_Stop := Clock; LSC.Internal.Bignum.Native_To_BE (OpenSSL_Cipher, OpenSSL_Cipher'First, OpenSSL_Cipher'Last, Cipher2, Cipher2'First); LSC.Internal.Bignum.Native_To_BE (OpenSSL_Plain2, OpenSSL_Plain2'First, OpenSSL_Plain2'Last, Plain3, Plain3'First); -- Precompute R^2 mod m LSC.Internal.Bignum.Size_Square_Mod (M => Modulus, M_First => Modulus'First, M_Last => Modulus'Last, R => R, R_First => R'First); -- Precompute inverse M_Inv := LSC.Internal.Bignum.Word_Inverse (Modulus (Modulus'First)); T.Test_Start := Clock; -- Encrypt LSC.Internal.Bignum.Mont_Exp_Window (A => Cipher1, A_First => Cipher1'First, A_Last => Cipher1'Last, X => Plain1, X_First => Plain1'First, E => Pub_Exp, E_First => Pub_Exp'First, E_Last => Pub_Exp'Last, M => Modulus, M_First => Modulus'First, K => Window_Size, Aux1 => Aux1, Aux1_First => Aux1'First, Aux2 => Aux2, Aux2_First => Aux2'First, Aux3 => Aux3, Aux3_First => Aux3'First, Aux4 => Aux4, Aux4_First => Aux4'First, R => R, R_First => R'First, M_Inv => M_Inv); -- Decrypt LSC.Internal.Bignum.Mont_Exp_Window (A => Plain2, A_First => Plain2'First, A_Last => Plain2'Last, X => Cipher1, X_First => Cipher1'First, E => Priv_Exp, E_First => Priv_Exp'First, E_Last => Priv_Exp'Last, M => Modulus, M_First => Modulus'First, K => Window_Size, Aux1 => Aux1, Aux1_First => Aux1'First, Aux2 => Aux2, Aux2_First => Aux2'First, Aux3 => Aux3, Aux3_First => Aux3'First, Aux4 => Aux4, Aux4_First => Aux4'First, R => R, R_First => R'First, M_Inv => M_Inv); T.Test_Stop := Clock; Assert (Success_Enc and then Success_Dec and then Cipher1 = Cipher2 and then Plain1 = Plain2 and then Plain2 = Plain3, "Invalid RSA"); end Benchmark_Bignum_RSA4096; --------------------------------------------------------------------------- procedure Register_Tests (T : in out Test_Case) is package Registration is new AUnit.Test_Cases.Specific_Test_Case_Registration (Test_Case); use Registration; begin Register_Wrapper (T, Benchmark_RIPEMD160'Access, "RIPEMD160"); Register_Wrapper (T, Benchmark_SHA1'Access, "SHA1"); Register_Wrapper (T, Benchmark_SHA256'Access, "SHA256"); Register_Wrapper (T, Benchmark_SHA384'Access, "SHA384"); Register_Wrapper (T, Benchmark_SHA512'Access, "SHA512"); Register_Wrapper (T, Benchmark_AES128_Decrypt'Access, "AES128 (decrypt)"); Register_Wrapper (T, Benchmark_AES128_CBC_Decrypt'Access, "AES128 CBC (decrypt)"); Register_Wrapper (T, Benchmark_AES128_Encrypt'Access, "AES128 (encrypt)"); Register_Wrapper (T, Benchmark_AES128_CBC_Encrypt'Access, "AES128 CBC (encrypt)"); Register_Wrapper (T, Benchmark_AES192_Decrypt'Access, "AES192 (decrypt)"); Register_Wrapper (T, Benchmark_AES192_CBC_Decrypt'Access, "AES192 CBC (decrypt)"); Register_Wrapper (T, Benchmark_AES192_Encrypt'Access, "AES192 (encrypt)"); Register_Wrapper (T, Benchmark_AES192_CBC_Encrypt'Access, "AES192 CBC (encrypt)"); Register_Wrapper (T, Benchmark_AES256_Decrypt'Access, "AES256 (decrypt)"); Register_Wrapper (T, Benchmark_AES256_CBC_Decrypt'Access, "AES256 CBC (decrypt)"); Register_Wrapper (T, Benchmark_AES256_Encrypt'Access, "AES256 (encrypt)"); Register_Wrapper (T, Benchmark_AES256_CBC_Encrypt'Access, "AES256 CBC (encrypt)"); Register_Wrapper (T, Benchmark_HMAC_RIPEMD160'Access, "HMAC (RIPEMD160)"); Register_Wrapper (T, Benchmark_HMAC_SHA1'Access, "HMAC (SHA1)"); Register_Wrapper (T, Benchmark_HMAC_SHA256'Access, "HMAC (SHA256)"); Register_Wrapper (T, Benchmark_HMAC_SHA384'Access, "HMAC (SHA384)"); Register_Wrapper (T, Benchmark_HMAC_SHA512'Access, "HMAC (SHA512)"); Register_Wrapper (T, Benchmark_Bignum_RSA2048'Access, "Bignum (2048)"); Register_Wrapper (T, Benchmark_Bignum_RSA4096'Access, "Bignum (4096)"); end Register_Tests; --------------------------------------------------------------------------- function Name (T : Test_Case) return Test_String is begin pragma Unreferenced (T); return Format ("Benchmark"); end Name; end LSC_Internal_Benchmark;
jorge-real/TTS-Ravenscar
Ada
291
adb
with TTS_Example2; with Ada.Exceptions; use Ada.Exceptions; with Ada.Real_Time; with Ada.Text_IO; use Ada.Text_IO; procedure Main2 is begin TTS_Example2.Main; delay until Ada.Real_Time.Time_Last; exception when E : others => Put_Line (Exception_Message (E)); end Main2;
ekoeppen/STM32_Generic_Ada_Drivers
Ada
2,445
ads
-- This spec has been automatically generated from STM32L0x1.svd pragma Restrictions (No_Elaboration_Code); pragma Ada_2012; pragma Style_Checks (Off); with System; package STM32_SVD.CRC is pragma Preelaborate; --------------- -- Registers -- --------------- -- Independent data register type IDR_Register is record -- General-purpose 8-bit data register bits IDR : STM32_SVD.Byte; -- unspecified Reserved_8_31 : STM32_SVD.UInt24; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for IDR_Register use record IDR at 0 range 0 .. 7; Reserved_8_31 at 0 range 8 .. 31; end record; -- Control register type CR_Register is record -- Write-only. RESET bit RESET : STM32_SVD.Bit; -- unspecified Reserved_1_2 : STM32_SVD.UInt2; -- Polynomial size POLYSIZE : STM32_SVD.UInt2; -- Reverse input data REV_IN : STM32_SVD.UInt2; -- Reverse output data REV_OUT : STM32_SVD.Bit; -- unspecified Reserved_8_31 : STM32_SVD.UInt24; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for CR_Register use record RESET at 0 range 0 .. 0; Reserved_1_2 at 0 range 1 .. 2; POLYSIZE at 0 range 3 .. 4; REV_IN at 0 range 5 .. 6; REV_OUT at 0 range 7 .. 7; Reserved_8_31 at 0 range 8 .. 31; end record; ----------------- -- Peripherals -- ----------------- -- Cyclic redundancy check calculation unit type CRC_Peripheral is record -- Data register DR : aliased STM32_SVD.UInt32; -- Independent data register IDR : aliased IDR_Register; -- Control register CR : aliased CR_Register; -- Initial CRC value INIT : aliased STM32_SVD.UInt32; -- polynomial POL : aliased STM32_SVD.UInt32; end record with Volatile; for CRC_Peripheral use record DR at 16#0# range 0 .. 31; IDR at 16#4# range 0 .. 31; CR at 16#8# range 0 .. 31; INIT at 16#10# range 0 .. 31; POL at 16#14# range 0 .. 31; end record; -- Cyclic redundancy check calculation unit CRC_Periph : aliased CRC_Peripheral with Import, Address => CRC_Base; end STM32_SVD.CRC;
FredPraca/Ada_Drivers_Library
Ada
3,544
ads
------------------------------------------------------------------------------ -- -- -- Copyright (C) 2015-2016, AdaCore -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions are -- -- met: -- -- 1. Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- 2. Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in -- -- the documentation and/or other materials provided with the -- -- distribution. -- -- 3. Neither the name of the copyright holder nor the names of its -- -- contributors may be used to endorse or promote products derived -- -- from this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -- -- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -- -- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -- -- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -- -- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ with Interfaces; use Interfaces; package HAL.Audio is type Audio_Buffer is array (Natural range <>) of Integer_16 with Component_Size => 16, Alignment => 2; type Audio_Volume is new Natural range 0 .. 100; type Audio_Frequency is (Audio_Freq_8kHz, Audio_Freq_11kHz, Audio_Freq_16kHz, Audio_Freq_22kHz, Audio_Freq_32kHz, Audio_Freq_44kHz, Audio_Freq_48kHz, Audio_Freq_96kHz) with Size => 32; for Audio_Frequency use (Audio_Freq_8kHz => 8_000, Audio_Freq_11kHz => 11_025, Audio_Freq_16kHz => 16_000, Audio_Freq_22kHz => 22_050, Audio_Freq_32kHz => 32_000, Audio_Freq_44kHz => 44_100, Audio_Freq_48kHz => 48_000, Audio_Freq_96kHz => 96_000); type Audio_Stream is limited interface; procedure Set_Frequency (This : in out Audio_Stream; Frequency : Audio_Frequency) is abstract; procedure Transmit (This : in out Audio_Stream; Data : Audio_Buffer) is abstract; procedure Receive (This : in out Audio_Stream; Data : out Audio_Buffer) is abstract; end HAL.Audio;
reznikmm/matreshka
Ada
4,768
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with Matreshka.DOM_Documents; with Matreshka.ODF_String_Constants; with ODF.DOM.Iterators; with ODF.DOM.Visitors; package body Matreshka.ODF_Style.Legend_Expansion_Aspect_Ratio_Attributes is ------------ -- Create -- ------------ overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Style_Legend_Expansion_Aspect_Ratio_Attribute_Node is begin return Self : Style_Legend_Expansion_Aspect_Ratio_Attribute_Node do Matreshka.ODF_Style.Constructors.Initialize (Self'Unchecked_Access, Parameters.Document, Matreshka.ODF_String_Constants.Style_Prefix); end return; end Create; -------------------- -- Get_Local_Name -- -------------------- overriding function Get_Local_Name (Self : not null access constant Style_Legend_Expansion_Aspect_Ratio_Attribute_Node) return League.Strings.Universal_String is pragma Unreferenced (Self); begin return Matreshka.ODF_String_Constants.Legend_Expansion_Aspect_Ratio_Attribute; end Get_Local_Name; begin Matreshka.DOM_Documents.Register_Attribute (Matreshka.ODF_String_Constants.Style_URI, Matreshka.ODF_String_Constants.Legend_Expansion_Aspect_Ratio_Attribute, Style_Legend_Expansion_Aspect_Ratio_Attribute_Node'Tag); end Matreshka.ODF_Style.Legend_Expansion_Aspect_Ratio_Attributes;
charlie5/aIDE
Ada
1,910
adb
with AdaM.Factory; package body AdaM.a_Type.tagged_record_type is -- Storage Pool -- record_Version : constant := 1; pool_Size : constant := 5_000; package Pool is new AdaM.Factory.Pools (storage_Folder => ".adam-store", pool_Name => "tagged_record_types", max_Items => pool_Size, record_Version => record_Version, Item => tagged_record_type.item, View => tagged_record_type.view); -- Forge -- procedure define (Self : in out Item; Name : in String) is begin Self.Name_is (Name); end define; overriding procedure destruct (Self : in out Item) is begin null; end destruct; function new_Type (Name : in String := "") return tagged_record_type.View is new_View : constant tagged_record_type.view := Pool.new_Item; begin define (tagged_record_type.item (new_View.all), Name); return new_View; end new_Type; procedure free (Self : in out tagged_record_type.view) is begin destruct (a_Type.item (Self.all)); Pool.free (Self); end free; -- Attributes -- overriding function Id (Self : access Item) return AdaM.Id is begin return Pool.to_Id (Self); end Id; -- Streams -- procedure View_write (Stream : not null access Ada.Streams.Root_Stream_Type'Class; Self : in View) renames Pool.View_write; procedure View_read (Stream : not null access Ada.Streams.Root_Stream_Type'Class; Self : out View) renames Pool.View_read; end AdaM.a_Type.tagged_record_type;
reznikmm/matreshka
Ada
3,603
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2011-2012, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ -- This file is generated, don't edit it. ------------------------------------------------------------------------------ with AMF.Elements.Generic_Hash; function AMF.UML.Value_Pins.Hash is new AMF.Elements.Generic_Hash (UML_Value_Pin, UML_Value_Pin_Access);
reznikmm/matreshka
Ada
11,096
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- XML Processor -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2012, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ -- This interface represents an XML Schema. ------------------------------------------------------------------------------ private with Ada.Finalization; with League.String_Vectors; with League.Strings; private with Matreshka.XML_Schema.AST; with XML.Schema.Attribute_Declarations; with XML.Schema.Attribute_Group_Definitions; with XML.Schema.Element_Declarations; with XML.Schema.Model_Group_Definitions; with XML.Schema.Named_Maps; with XML.Schema.Namespace_Item_Lists; with XML.Schema.Notation_Declarations; with XML.Schema.Object_Lists; with XML.Schema.Type_Definitions; package XML.Schema.Models is pragma Preelaborate; type XS_Model is tagged private; Null_Model : constant XS_Model; function Is_Null (Self : XS_Model) return Boolean; function Get_Namespaces (Self : XS_Model'Class) return League.String_Vectors.Universal_String_Vector; -- Convenience method. Returns a list of all namespaces that belong to this -- schema. The value null is not a valid namespace name, but if there are -- components that do not have a target namespace, null is included in this -- list. function Get_Namespace_Items (Self : XS_Model'Class) return XML.Schema.Namespace_Item_Lists.XS_Namespace_Item_List; -- A set of namespace schema information information items (of type -- XSNamespaceItem), one for each namespace name which appears as the -- target namespace of any schema component in the schema used for that -- assessment, and one for absent if any schema component in the schema had -- no target namespace. For more information see schema information. function Get_Components (Self : XS_Model'Class; Object_Type : Extended_XML_Schema_Component_Type) return XML.Schema.Named_Maps.XS_Named_Map; -- Returns a list of top-level components, i.e. element declarations, -- attribute declarations, etc. -- -- Parameters -- -- objectType of type unsigned short -- The type of the declaration, i.e. ELEMENT_DECLARATION. Note that -- XSTypeDefinition.SIMPLE_TYPE and XSTypeDefinition.COMPLEX_TYPE can -- also be used as the objectType to retrieve only complex types or -- simple types, instead of all types. -- -- Return Value -- -- A list of top-level definitions of the specified type in objectType or -- an empty XSNamedMap if no such definitions exist. function Get_Components_By_Namespace (Self : XS_Model'Class; Object_Type : Extended_XML_Schema_Component_Type; Namespace : League.Strings.Universal_String) return XML.Schema.Named_Maps.XS_Named_Map; -- Convenience method. Returns a list of top-level component declarations -- that are defined within the specified namespace, i.e. element -- declarations, attribute declarations, etc. -- -- Parameters -- -- objectType of type unsigned short -- The type of the declaration, i.e. ELEMENT_DECLARATION. -- -- namespace of type GenericString -- The namespace to which the declaration belongs or null (for -- components with no target namespace). -- -- Return Value -- -- A list of top-level definitions of the specified type in objectType -- and defined in the specified namespace or an empty XSNamedMap. function Get_Annotations (Self : XS_Model'Class) return XML.Schema.Object_Lists.XS_Object_List; -- [annotations]: a set of annotations if it exists, otherwise an empty -- XSObjectList. function Get_Element_Declaration (Self : XS_Model'Class; Name : League.Strings.Universal_String; Namespace : League.Strings.Universal_String) return XML.Schema.Element_Declarations.XS_Element_Declaration; -- Convenience method. Returns a top-level element declaration. -- -- Parameters -- -- name of type GenericString -- The name of the declaration. -- -- namespace of type GenericString -- The namespace of the declaration, otherwise null. -- -- Return Value -- -- A top-level element declaration or null if such a declaration does not -- exist. function Get_Attribute_Declaration (Self : XS_Model'Class; Name : League.Strings.Universal_String; Namespace : League.Strings.Universal_String) return XML.Schema.Attribute_Declarations.XS_Attribute_Declaration; -- Convenience method. Returns a top-level attribute declaration. -- -- Parameters -- -- name of type GenericString -- The name of the declaration. -- -- namespace of type GenericString -- The namespace of the declaration, otherwise null. -- -- Return Value -- -- A top-level attribute declaration or null if such a declaration does -- not exist. function Get_Type_Definition (Self : XS_Model'Class; Name : League.Strings.Universal_String; Namespace : League.Strings.Universal_String) return XML.Schema.Type_Definitions.XS_Type_Definition; -- Convenience method. Returns a top-level simple or complex type -- definition. -- -- Parameters -- -- name of type GenericString -- The name of the definition. -- -- namespace of type GenericString -- The namespace of the declaration, otherwise null. -- -- Return Value -- -- An XSTypeDefinition or null if such a definition does not exist. function Get_Attribute_Group (Self : XS_Model'Class; Name : League.Strings.Universal_String; Namespace : League.Strings.Universal_String) return XML.Schema.Attribute_Group_Definitions.XS_Attribute_Group_Definition; -- Convenience method. Returns a top-level attribute group definition. -- -- Parameters -- -- name of type GenericString -- The name of the definition. -- -- namespace of type GenericString -- The namespace of the definition, otherwise null. -- -- Return Value -- -- A top-level attribute group definition or null if such a definition -- does not exist. function Get_Model_Group_Definition (Self : XS_Model'Class; Name : League.Strings.Universal_String; Namespace : League.Strings.Universal_String) return XML.Schema.Model_Group_Definitions.XS_Model_Group_Definition; -- Convenience method. Returns a top-level model group definition. -- -- Parameters -- -- name of type GenericString -- The name of the definition. -- -- namespace of type GenericString -- The namespace of the definition, otherwise null. -- -- Return Value -- -- A top-level model group definition or null if such a definition does -- not exist. function Get_Notation_Declaration (Self : XS_Model'Class; Name : League.Strings.Universal_String; Namespace : League.Strings.Universal_String) return XML.Schema.Notation_Declarations.XS_Notation_Declaration; -- Convenience method. Returns a top-level notation declaration. -- -- Parameters -- -- name of type GenericString -- The name of the declaration. -- -- namespace of type GenericString -- The namespace of the declaration, otherwise null. -- -- Return Value -- -- A top-level notation declaration or null if such a declaration does -- not exist. private type XS_Model is new Ada.Finalization.Controlled with record Node : Matreshka.XML_Schema.AST.Model_Access; end record; Null_Model : constant XS_Model := (Ada.Finalization.Controlled with Node => null); end XML.Schema.Models;
laurentzh/CHIP-8
Ada
726
adb
with Last_Chance_Handler; pragma Unreferenced (Last_Chance_Handler); with STM32.Board; use STM32.Board; with Cpu; use Cpu; with Instruction; use Instruction; with Roms; use Roms; with Types; use Types; with Inputs; use Inputs; with Gfx; use Gfx; procedure Main is procedure Load_Rom(Cpu : in out Chip8; R : Rom) is begin for I in R'Range loop Cpu.Mem(I) := R(I); end loop; end Load_Rom; Op : Opcode; begin Init_Draw; Touch_Panel.Initialize; Clear_Layer(1); Clear_Layer(2); Draw_Keyboard(Global_Cpu.Mem); Load_Rom(Global_Cpu, BLINKY); loop Op := Fetch(Global_Cpu); Execute(Global_Cpu, Op); Update_Pressed_Keys(Global_Cpu.Keys); end loop; end Main;
reznikmm/matreshka
Ada
4,704
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with Matreshka.DOM_Documents; with Matreshka.ODF_String_Constants; with ODF.DOM.Iterators; with ODF.DOM.Visitors; package body Matreshka.ODF_Style.Border_Line_Width_Top_Attributes is ------------ -- Create -- ------------ overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Style_Border_Line_Width_Top_Attribute_Node is begin return Self : Style_Border_Line_Width_Top_Attribute_Node do Matreshka.ODF_Style.Constructors.Initialize (Self'Unchecked_Access, Parameters.Document, Matreshka.ODF_String_Constants.Style_Prefix); end return; end Create; -------------------- -- Get_Local_Name -- -------------------- overriding function Get_Local_Name (Self : not null access constant Style_Border_Line_Width_Top_Attribute_Node) return League.Strings.Universal_String is pragma Unreferenced (Self); begin return Matreshka.ODF_String_Constants.Border_Line_Width_Top_Attribute; end Get_Local_Name; begin Matreshka.DOM_Documents.Register_Attribute (Matreshka.ODF_String_Constants.Style_URI, Matreshka.ODF_String_Constants.Border_Line_Width_Top_Attribute, Style_Border_Line_Width_Top_Attribute_Node'Tag); end Matreshka.ODF_Style.Border_Line_Width_Top_Attributes;
edin/raytracer
Ada
2,761
adb
-- -- Raytracer implementation in Ada -- by John Perry (github: johnperry-math) -- 2021 -- -- implementation for Bitmap, a Bitmap of Color_With_Transparency_Type, -- along with a procedure to save the Bitmap to a BMP file -- pragma Ada_2020; -- use Ada_202x features -- Ada packages with Interfaces.C; use Interfaces.C; -- interface to C with Ada.Streams.Stream_IO; -- writing data to disk with Ada.Text_IO; use Ada.Text_IO; -- I/O -- local packages with RayTracing_Constants; use RayTracing_Constants; package body Bitmap is bi_rgb: constant := 0; -- whether the data is compressed procedure Save_RGB_Bitmap ( bits: Bitmap_Data; width, height: Int32; bits_per_pixel: UInt16; filename: String ) is type Bitmap_File_Header is record Header_Type: UInt16; Size: UInt32; Reserved1, Reserved2: UInt16 := 0; Off_Bits: UInt32; end record with Pack; -- header for file storing the bitmap type Bitmap_Info_Header is record size: UInt32; width, height: Int32; planes, bit_count: UInt16; compression, size_image: UInt32; xpels_per_meter, ypels_per_meter: Int32; clr_used, clr_important: UInt32; end record with Pack; -- header for bitmap within file info_size: UInt32 := UInt32( size_t( Bitmap_Info_Header'Size / CHAR_BIT ) ); -- size of bitmap header info_header: Bitmap_Info_Header := ( size => info_size, bit_count => bits_per_pixel, clr_important => 0, clr_used => 0, compression => bi_rgb, height => -height, width => width, planes => 1, size_image => UInt32( width * height * Int32( bits_per_pixel ) / 8 ), -- pixels => bits, others => 0 ); file_header: Bitmap_File_Header := ( Header_Type => Character'Pos('B') + ( Character'Pos('M') * UInt16( 2 ** 8 ) ), Off_Bits => Info_Size + UInt32( Size_T(Bitmap_File_Header'Size / CHAR_BIT) ), Size => Info_Size + UInt32( Size_T(Bitmap_File_Header'Size / CHAR_BIT) ) + Info_Header.Size_Image, others => 0 ); F: Ada.Streams.Stream_IO.File_Type; begin Ada.Streams.Stream_IO.Create(F, Name => filename); Bitmap_File_Header'Write( Ada.Streams.Stream_IO.Stream(F), File_Header ); Bitmap_Info_Header'Write( Ada.Streams.Stream_IO.Stream(F), Info_Header ); Bitmap_Data'Write( Ada.Streams.Stream_IO.Stream(F), Bits ); Ada.Streams.Stream_IO.Close(F); end Save_RGB_Bitmap; end Bitmap;
Gabriel-Degret/adalib
Ada
626
ads
-- Standard Ada library specification -- Copyright (c) 2003-2018 Maxim Reznik <[email protected]> -- Copyright (c) 2004-2016 AXE Consultants -- Copyright (c) 2004, 2005, 2006 Ada-Europe -- Copyright (c) 2000 The MITRE Corporation, Inc. -- Copyright (c) 1992, 1993, 1994, 1995 Intermetrics, Inc. -- SPDX-License-Identifier: BSD-3-Clause and LicenseRef-AdaReferenceManual --------------------------------------------------------------------------- with Ada.Numerics.Complex_Types; with Ada.Text_IO.Complex_IO; package Ada.Complex_Text_IO is new Ada.Text_IO.Complex_IO (Ada.Numerics.Complex_Types);
stcarrez/ada-util
Ada
70,105
adb
----------------------------------------------------------------------- -- util-beans-objects -- Generic Typed Data Representation -- Copyright (C) 2009, 2010, 2011, 2013, 2016, 2017, 2018, 2020, 2022 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.Characters.Conversions; with Ada.Tags; with Ada.Strings.UTF_Encoding.Wide_Wide_Strings; with Util.Beans.Basic; package body Util.Beans.Objects is use Util.Concurrent.Counters; use Ada.Characters.Conversions; function UTF8_Decode (S : in String) return Wide_Wide_String renames Ada.Strings.UTF_Encoding.Wide_Wide_Strings.Decode; -- Find the data type to be used for an arithmetic operation between two objects. function Get_Arithmetic_Type (Left, Right : Object) return Data_Type; -- Find the data type to be used for a composition operation between two objects. function Get_Compose_Type (Left, Right : Object) return Data_Type; -- Find the best type to be used to compare two operands. function Get_Compare_Type (Left, Right : Object) return Data_Type; Integer_Type : aliased constant Int_Type := Int_Type '(null record); Bool_Type : aliased constant Boolean_Type := Boolean_Type '(null record); Str_Type : aliased constant String_Type := String_Type '(null record); WString_Type : aliased constant Wide_String_Type := Wide_String_Type '(null record); Flt_Type : aliased constant Float_Type := Float_Type '(null record); Duration_Type : aliased constant Duration_Type_Def := Duration_Type_Def '(null record); Bn_Type : aliased constant Bean_Type := Bean_Type '(null record); Ar_Type : aliased constant Array_Type := Array_Type '(null record); Blob_Def : aliased constant Blob_Type := Blob_Type '(null record); -- ------------------------------ -- Convert the value into a wide string. -- ------------------------------ overriding function To_Wide_Wide_String (Type_Def : in Basic_Type; Value : in Object_Value) return Wide_Wide_String is begin return UTF8_Decode (Object_Type'Class (Type_Def).To_String (Value)); end To_Wide_Wide_String; -- ------------------------------ -- Convert the value into a float. -- ------------------------------ overriding function To_Long_Float (Type_Def : in Basic_Type; Value : in Object_Value) return Long_Long_Float is pragma Unreferenced (Type_Def, Value); begin return 0.0; end To_Long_Float; -- ------------------------------ -- Convert the value into a boolean. -- ------------------------------ overriding function To_Boolean (Type_Def : in Basic_Type; Value : in Object_Value) return Boolean is pragma Unreferenced (Type_Def, Value); begin return False; end To_Boolean; -- ------------------------------ -- Convert the value into a duration. -- ------------------------------ overriding function To_Duration (Type_Def : in Basic_Type; Value : in Object_Value) return Duration is pragma Unreferenced (Type_Def, Value); begin return 0.0; end To_Duration; -- ------------------------------ -- Returns False -- ------------------------------ overriding function Is_Empty (Type_Def : in Basic_Type; Value : in Object_Value) return Boolean is pragma Unreferenced (Type_Def, Value); begin return False; end Is_Empty; -- ------------------------------ -- Null Type -- ------------------------------ -- ------------------------------ -- Get the type name -- ------------------------------ overriding function Get_Name (Type_Def : Null_Type) return String is pragma Unreferenced (Type_Def); begin return "Null"; end Get_Name; -- ------------------------------ -- Get the base data type. -- ------------------------------ overriding function Get_Data_Type (Type_Def : Null_Type) return Data_Type is pragma Unreferenced (Type_Def); begin return TYPE_NULL; end Get_Data_Type; -- ------------------------------ -- Convert the value into a string. -- ------------------------------ overriding function To_String (Type_Def : in Null_Type; Value : in Object_Value) return String is pragma Unreferenced (Type_Def, Value); begin return "null"; end To_String; -- ------------------------------ -- Returns True -- ------------------------------ overriding function Is_Empty (Type_Def : in Null_Type; Value : in Object_Value) return Boolean is pragma Unreferenced (Type_Def, Value); begin return True; end Is_Empty; -- ------------------------------ -- Integer Type -- ------------------------------ -- ------------------------------ -- Get the type name -- ------------------------------ overriding function Get_Name (Type_Def : Int_Type) return String is pragma Unreferenced (Type_Def); begin return "Integer"; end Get_Name; -- ------------------------------ -- Get the base data type. -- ------------------------------ overriding function Get_Data_Type (Type_Def : Int_Type) return Data_Type is pragma Unreferenced (Type_Def); begin return TYPE_INTEGER; end Get_Data_Type; -- ------------------------------ -- Convert the value into a string. -- ------------------------------ overriding function To_String (Type_Def : in Int_Type; Value : in Object_Value) return String is pragma Unreferenced (Type_Def); S : constant String := Long_Long_Integer'Image (Value.Int_Value); begin if Value.Int_Value >= 0 then return S (S'First + 1 .. S'Last); else return S; end if; end To_String; -- ------------------------------ -- Convert the value into an integer. -- ------------------------------ overriding function To_Long_Long (Type_Def : in Int_Type; Value : in Object_Value) return Long_Long_Integer is pragma Unreferenced (Type_Def); begin return Value.Int_Value; end To_Long_Long; -- ------------------------------ -- Convert the value into a float. -- ------------------------------ overriding function To_Long_Float (Type_Def : in Int_Type; Value : in Object_Value) return Long_Long_Float is pragma Unreferenced (Type_Def); begin return Long_Long_Float (Value.Int_Value); end To_Long_Float; -- ------------------------------ -- Convert the value into a boolean. -- ------------------------------ overriding function To_Boolean (Type_Def : in Int_Type; Value : in Object_Value) return Boolean is pragma Unreferenced (Type_Def); begin return Value.Int_Value /= 0; end To_Boolean; -- ------------------------------ -- Convert the value into a duration. -- ------------------------------ overriding function To_Duration (Type_Def : in Int_Type; Value : in Object_Value) return Duration is pragma Unreferenced (Type_Def); begin return Duration (Value.Int_Value); end To_Duration; -- ------------------------------ -- Float Type -- ------------------------------ -- ------------------------------ -- Get the type name -- ------------------------------ overriding function Get_Name (Type_Def : in Float_Type) return String is pragma Unreferenced (Type_Def); begin return "Float"; end Get_Name; -- ------------------------------ -- Get the base data type. -- ------------------------------ overriding function Get_Data_Type (Type_Def : in Float_Type) return Data_Type is pragma Unreferenced (Type_Def); begin return TYPE_FLOAT; end Get_Data_Type; -- ------------------------------ -- Convert the value into a string. -- ------------------------------ overriding function To_String (Type_Def : in Float_Type; Value : in Object_Value) return String is pragma Unreferenced (Type_Def); begin return Long_Long_Float'Image (Value.Float_Value); end To_String; -- ------------------------------ -- Convert the value into an integer. -- ------------------------------ overriding function To_Long_Long (Type_Def : in Float_Type; Value : in Object_Value) return Long_Long_Integer is pragma Unreferenced (Type_Def); begin return Long_Long_Integer (Value.Float_Value); end To_Long_Long; -- ------------------------------ -- Convert the value into a float. -- ------------------------------ overriding function To_Long_Float (Type_Def : in Float_Type; Value : in Object_Value) return Long_Long_Float is pragma Unreferenced (Type_Def); begin return Value.Float_Value; end To_Long_Float; -- ------------------------------ -- Convert the value into a boolean. -- ------------------------------ overriding function To_Boolean (Type_Def : in Float_Type; Value : in Object_Value) return Boolean is pragma Unreferenced (Type_Def); begin return Value.Float_Value /= 0.0; end To_Boolean; -- ------------------------------ -- Convert the value into a duration. -- ------------------------------ overriding function To_Duration (Type_Def : in Float_Type; Value : in Object_Value) return Duration is pragma Unreferenced (Type_Def); begin return Duration (Value.Float_Value); end To_Duration; -- ------------------------------ -- String Type -- ------------------------------ -- ------------------------------ -- Get the type name -- ------------------------------ overriding function Get_Name (Type_Def : in String_Type) return String is pragma Unreferenced (Type_Def); begin return "String"; end Get_Name; -- ------------------------------ -- Get the base data type. -- ------------------------------ overriding function Get_Data_Type (Type_Def : in String_Type) return Data_Type is pragma Unreferenced (Type_Def); begin return TYPE_STRING; end Get_Data_Type; -- ------------------------------ -- Convert the value into a string. -- ------------------------------ overriding function To_String (Type_Def : in String_Type; Value : in Object_Value) return String is pragma Unreferenced (Type_Def); Proxy : constant String_Proxy_Access := Value.String_Proxy; begin if Proxy = null then return "null"; else return Proxy.Value; end if; end To_String; -- ------------------------------ -- Convert the value into an integer. -- ------------------------------ overriding function To_Long_Long (Type_Def : in String_Type; Value : in Object_Value) return Long_Long_Integer is pragma Unreferenced (Type_Def); Proxy : constant String_Proxy_Access := Value.String_Proxy; begin if Proxy = null then return 0; else return Long_Long_Integer'Value (Proxy.Value); end if; end To_Long_Long; -- ------------------------------ -- Convert the value into a float. -- ------------------------------ overriding function To_Long_Float (Type_Def : in String_Type; Value : in Object_Value) return Long_Long_Float is pragma Unreferenced (Type_Def); Proxy : constant String_Proxy_Access := Value.String_Proxy; begin if Proxy = null then return 0.0; else return Long_Long_Float'Value (Proxy.Value); end if; end To_Long_Float; -- ------------------------------ -- Convert the value into a boolean. -- ------------------------------ overriding function To_Boolean (Type_Def : in String_Type; Value : in Object_Value) return Boolean is pragma Unreferenced (Type_Def); Proxy : constant String_Proxy_Access := Value.String_Proxy; begin return Proxy /= null and then (Proxy.Value = "true" or else Proxy.Value = "TRUE" or else Proxy.Value = "1"); end To_Boolean; -- ------------------------------ -- Returns True if the value is empty. -- ------------------------------ overriding function Is_Empty (Type_Def : in String_Type; Value : in Object_Value) return Boolean is pragma Unreferenced (Type_Def); Proxy : constant String_Proxy_Access := Value.String_Proxy; begin return Proxy = null or else Proxy.Value = ""; end Is_Empty; -- ------------------------------ -- Convert the value into a duration. -- ------------------------------ overriding function To_Duration (Type_Def : in String_Type; Value : in Object_Value) return Duration is pragma Unreferenced (Type_Def); Proxy : constant String_Proxy_Access := Value.String_Proxy; begin if Proxy = null then return 0.0; else return Duration'Value (Proxy.Value); end if; end To_Duration; -- ------------------------------ -- Wide String Type -- ------------------------------ -- ------------------------------ -- Get the type name -- ------------------------------ overriding function Get_Name (Type_Def : in Wide_String_Type) return String is pragma Unreferenced (Type_Def); begin return "WideString"; end Get_Name; -- ------------------------------ -- Get the base data type. -- ------------------------------ overriding function Get_Data_Type (Type_Def : in Wide_String_Type) return Data_Type is pragma Unreferenced (Type_Def); begin return TYPE_WIDE_STRING; end Get_Data_Type; -- ------------------------------ -- Convert the value into a string. -- ------------------------------ overriding function To_String (Type_Def : in Wide_String_Type; Value : in Object_Value) return String is pragma Unreferenced (Type_Def); Proxy : constant Wide_String_Proxy_Access := Value.Wide_Proxy; begin if Proxy = null then return "null"; else return To_String (Proxy.Value); end if; end To_String; -- ------------------------------ -- Convert the value into a wide string. -- ------------------------------ overriding function To_Wide_Wide_String (Type_Def : in Wide_String_Type; Value : in Object_Value) return Wide_Wide_String is pragma Unreferenced (Type_Def); Proxy : constant Wide_String_Proxy_Access := Value.Wide_Proxy; begin if Proxy = null then return "null"; else return Proxy.Value; end if; end To_Wide_Wide_String; -- ------------------------------ -- Convert the value into an integer. -- ------------------------------ overriding function To_Long_Long (Type_Def : in Wide_String_Type; Value : in Object_Value) return Long_Long_Integer is pragma Unreferenced (Type_Def); Proxy : constant Wide_String_Proxy_Access := Value.Wide_Proxy; begin if Proxy = null then return 0; else return Long_Long_Integer'Value (To_String (Proxy.Value)); end if; end To_Long_Long; -- ------------------------------ -- Convert the value into a float. -- ------------------------------ overriding function To_Long_Float (Type_Def : in Wide_String_Type; Value : in Object_Value) return Long_Long_Float is pragma Unreferenced (Type_Def); Proxy : constant Wide_String_Proxy_Access := Value.Wide_Proxy; begin if Proxy = null then return 0.0; else return Long_Long_Float'Value (To_String (Proxy.Value)); end if; end To_Long_Float; -- ------------------------------ -- Convert the value into a boolean. -- ------------------------------ overriding function To_Boolean (Type_Def : in Wide_String_Type; Value : in Object_Value) return Boolean is pragma Unreferenced (Type_Def); Proxy : constant Wide_String_Proxy_Access := Value.Wide_Proxy; begin return Proxy /= null and then (Proxy.Value = "true" or else Proxy.Value = "TRUE" or else Proxy.Value = "1"); end To_Boolean; -- ------------------------------ -- Convert the value into a duration. -- ------------------------------ overriding function To_Duration (Type_Def : in Wide_String_Type; Value : in Object_Value) return Duration is pragma Unreferenced (Type_Def); Proxy : constant Wide_String_Proxy_Access := Value.Wide_Proxy; begin if Proxy = null then return 0.0; else return Duration'Value (To_String (Proxy.Value)); end if; end To_Duration; -- ------------------------------ -- Returns True if the value is empty. -- ------------------------------ overriding function Is_Empty (Type_Def : in Wide_String_Type; Value : in Object_Value) return Boolean is pragma Unreferenced (Type_Def); Proxy : constant Wide_String_Proxy_Access := Value.Wide_Proxy; begin return Proxy = null or else Proxy.Value = ""; end Is_Empty; -- ------------------------------ -- Boolean Type -- ------------------------------ -- ------------------------------ -- Get the type name -- ------------------------------ overriding function Get_Name (Type_Def : in Boolean_Type) return String is pragma Unreferenced (Type_Def); begin return "Boolean"; end Get_Name; -- ------------------------------ -- Get the base data type. -- ------------------------------ overriding function Get_Data_Type (Type_Def : in Boolean_Type) return Data_Type is pragma Unreferenced (Type_Def); begin return TYPE_BOOLEAN; end Get_Data_Type; -- ------------------------------ -- Convert the value into a string. -- ------------------------------ overriding function To_String (Type_Def : in Boolean_Type; Value : in Object_Value) return String is pragma Unreferenced (Type_Def); begin if Value.Bool_Value then return "TRUE"; else return "FALSE"; end if; end To_String; -- ------------------------------ -- Convert the value into an integer. -- ------------------------------ overriding function To_Long_Long (Type_Def : in Boolean_Type; Value : in Object_Value) return Long_Long_Integer is pragma Unreferenced (Type_Def); begin if Value.Bool_Value then return 1; else return 0; end if; end To_Long_Long; -- ------------------------------ -- Convert the value into a float. -- ------------------------------ overriding function To_Long_Float (Type_Def : in Boolean_Type; Value : in Object_Value) return Long_Long_Float is pragma Unreferenced (Type_Def); begin if Value.Bool_Value then return 1.0; else return 0.0; end if; end To_Long_Float; -- ------------------------------ -- Convert the value into a boolean. -- ------------------------------ overriding function To_Boolean (Type_Def : in Boolean_Type; Value : in Object_Value) return Boolean is pragma Unreferenced (Type_Def); begin return Value.Bool_Value; end To_Boolean; -- ------------------------------ -- Duration Type -- ------------------------------ -- ------------------------------ -- Get the type name -- ------------------------------ overriding function Get_Name (Type_Def : in Duration_Type_Def) return String is pragma Unreferenced (Type_Def); begin return "Duration"; end Get_Name; -- ------------------------------ -- Get the base data type. -- ------------------------------ overriding function Get_Data_Type (Type_Def : in Duration_Type_Def) return Data_Type is pragma Unreferenced (Type_Def); begin return TYPE_TIME; end Get_Data_Type; -- ------------------------------ -- Convert the value into a string. -- ------------------------------ overriding function To_String (Type_Def : in Duration_Type_Def; Value : in Object_Value) return String is pragma Unreferenced (Type_Def); begin return Duration'Image (Value.Time_Value); end To_String; -- ------------------------------ -- Convert the value into an integer. -- ------------------------------ overriding function To_Long_Long (Type_Def : in Duration_Type_Def; Value : in Object_Value) return Long_Long_Integer is pragma Unreferenced (Type_Def); begin return Long_Long_Integer (Value.Time_Value); end To_Long_Long; -- ------------------------------ -- Convert the value into a float. -- ------------------------------ overriding function To_Long_Float (Type_Def : in Duration_Type_Def; Value : in Object_Value) return Long_Long_Float is pragma Unreferenced (Type_Def); begin return Long_Long_Float (Value.Time_Value); end To_Long_Float; -- ------------------------------ -- Convert the value into a boolean. -- ------------------------------ overriding function To_Boolean (Type_Def : in Duration_Type_Def; Value : in Object_Value) return Boolean is pragma Unreferenced (Type_Def); begin return Value.Time_Value > 0.0; end To_Boolean; -- ------------------------------ -- Convert the value into a duration. -- ------------------------------ overriding function To_Duration (Type_Def : in Duration_Type_Def; Value : in Object_Value) return Duration is pragma Unreferenced (Type_Def); begin return Value.Time_Value; end To_Duration; -- ------------------------------ -- Bean Type -- ------------------------------ -- ------------------------------ -- Get the type name -- ------------------------------ overriding function Get_Name (Type_Def : in Bean_Type) return String is pragma Unreferenced (Type_Def); begin return "Bean"; end Get_Name; -- ------------------------------ -- Get the base data type. -- ------------------------------ overriding function Get_Data_Type (Type_Def : in Bean_Type) return Data_Type is pragma Unreferenced (Type_Def); begin return TYPE_BEAN; end Get_Data_Type; -- ------------------------------ -- Convert the value into a string. -- ------------------------------ overriding function To_String (Type_Def : in Bean_Type; Value : in Object_Value) return String is pragma Unreferenced (Type_Def); begin if Value.Proxy = null or else Value.Proxy.Bean = null then return "<null bean>"; else return "<" & Ada.Tags.Expanded_Name (Value.Proxy.Bean'Tag) & ">"; end if; end To_String; -- ------------------------------ -- Convert the value into an integer. -- ------------------------------ overriding function To_Long_Long (Type_Def : in Bean_Type; Value : in Object_Value) return Long_Long_Integer is pragma Unreferenced (Type_Def, Value); begin return 0; end To_Long_Long; -- ------------------------------ -- Convert the value into a float. -- ------------------------------ overriding function To_Long_Float (Type_Def : in Bean_Type; Value : in Object_Value) return Long_Long_Float is pragma Unreferenced (Type_Def, Value); begin return 0.0; end To_Long_Float; -- ------------------------------ -- Convert the value into a boolean. -- ------------------------------ overriding function To_Boolean (Type_Def : in Bean_Type; Value : in Object_Value) return Boolean is pragma Unreferenced (Type_Def); Proxy : constant Bean_Proxy_Access := Value.Proxy; begin return Proxy /= null; end To_Boolean; -- ------------------------------ -- Returns True if the value is empty. -- ------------------------------ overriding function Is_Empty (Type_Def : in Bean_Type; Value : in Object_Value) return Boolean is pragma Unreferenced (Type_Def); Proxy : constant Bean_Proxy_Access := Value.Proxy; begin if Proxy = null then return True; end if; if not (Proxy.all in Bean_Proxy'Class) then return False; end if; if not (Proxy.Bean.all in Util.Beans.Basic.List_Bean'Class) then return False; end if; declare L : constant Util.Beans.Basic.List_Bean_Access := Beans.Basic.List_Bean'Class (Proxy.Bean.all)'Unchecked_Access; begin return L.Get_Count = 0; end; end Is_Empty; -- ------------------------------ -- Blob Type -- ------------------------------ -- ------------------------------ -- Get the type name -- ------------------------------ overriding function Get_Name (Type_Def : in Blob_Type) return String is pragma Unreferenced (Type_Def); begin return "Blob"; end Get_Name; -- ------------------------------ -- Get the base data type. -- ------------------------------ overriding function Get_Data_Type (Type_Def : in Blob_Type) return Data_Type is pragma Unreferenced (Type_Def); begin return TYPE_BLOB; end Get_Data_Type; -- ------------------------------ -- Convert the value into a string. -- ------------------------------ overriding function To_String (Type_Def : in Blob_Type; Value : in Object_Value) return String is pragma Unreferenced (Type_Def); begin if Value.Blob_Proxy = null then return "<null array>"; else return "<array>"; end if; end To_String; -- ------------------------------ -- Convert the value into an integer. -- ------------------------------ overriding function To_Long_Long (Type_Def : in Blob_Type; Value : in Object_Value) return Long_Long_Integer is pragma Unreferenced (Type_Def, Value); begin return 0; end To_Long_Long; -- ------------------------------ -- Convert the value into a float. -- ------------------------------ overriding function To_Long_Float (Type_Def : in Blob_Type; Value : in Object_Value) return Long_Long_Float is pragma Unreferenced (Type_Def, Value); begin return 0.0; end To_Long_Float; -- ------------------------------ -- Convert the value into a boolean. -- ------------------------------ overriding function To_Boolean (Type_Def : in Blob_Type; Value : in Object_Value) return Boolean is pragma Unreferenced (Type_Def); Proxy : constant Blob_Proxy_Access := Value.Blob_Proxy; begin return Proxy /= null; end To_Boolean; -- ------------------------------ -- Returns True if the value is empty. -- ------------------------------ overriding function Is_Empty (Type_Def : in Blob_Type; Value : in Object_Value) return Boolean is pragma Unreferenced (Type_Def); begin if Value.Blob_Proxy = null then return True; else return Value.Blob_Proxy.Blob.Is_Null; end if; end Is_Empty; -- ------------------------------ -- Array Type -- ------------------------------ -- ------------------------------ -- Get the type name -- ------------------------------ overriding function Get_Name (Type_Def : in Array_Type) return String is pragma Unreferenced (Type_Def); begin return "Array"; end Get_Name; -- ------------------------------ -- Get the base data type. -- ------------------------------ overriding function Get_Data_Type (Type_Def : in Array_Type) return Data_Type is pragma Unreferenced (Type_Def); begin return TYPE_ARRAY; end Get_Data_Type; -- ------------------------------ -- Convert the value into a string. -- ------------------------------ overriding function To_String (Type_Def : in Array_Type; Value : in Object_Value) return String is pragma Unreferenced (Type_Def); begin if Value.Array_Proxy = null then return "<null array>"; else return "<array>"; end if; end To_String; -- ------------------------------ -- Convert the value into an integer. -- ------------------------------ overriding function To_Long_Long (Type_Def : in Array_Type; Value : in Object_Value) return Long_Long_Integer is pragma Unreferenced (Type_Def, Value); begin return 0; end To_Long_Long; -- ------------------------------ -- Convert the value into a float. -- ------------------------------ overriding function To_Long_Float (Type_Def : in Array_Type; Value : in Object_Value) return Long_Long_Float is pragma Unreferenced (Type_Def, Value); begin return 0.0; end To_Long_Float; -- ------------------------------ -- Convert the value into a boolean. -- ------------------------------ overriding function To_Boolean (Type_Def : in Array_Type; Value : in Object_Value) return Boolean is pragma Unreferenced (Type_Def); Proxy : constant Array_Proxy_Access := Value.Array_Proxy; begin return Proxy /= null; end To_Boolean; -- ------------------------------ -- Returns True if the value is empty. -- ------------------------------ overriding function Is_Empty (Type_Def : in Array_Type; Value : in Object_Value) return Boolean is pragma Unreferenced (Type_Def); begin if Value.Array_Proxy = null then return True; else return Value.Array_Proxy.Len = 0; end if; end Is_Empty; -- ------------------------------ -- Convert the value into a string. -- ------------------------------ overriding function To_Long_Long (Type_Def : in Basic_Type; Value : in Object_Value) return Long_Long_Integer is pragma Unreferenced (Type_Def, Value); begin return 0; end To_Long_Long; -- ------------------------------ -- Check whether the object contains a value. -- Returns true if the object does not contain a value. -- ------------------------------ function Is_Null (Value : in Object) return Boolean is begin return Value.V.Of_Type = TYPE_NULL; end Is_Null; -- ------------------------------ -- Check whether the object is empty. -- If the object is null, returns true. -- If the object is the empty string, returns true. -- If the object is a list bean whose Get_Count is 0, returns true. -- Otherwise returns false. -- ------------------------------ function Is_Empty (Value : in Object) return Boolean is begin return Value.Type_Def.Is_Empty (Value.V); end Is_Empty; function Get_Array_Bean (Value : in Object) return access Util.Beans.Basic.Array_Bean'Class is Bean : constant access Util.Beans.Basic.Readonly_Bean'Class := To_Bean (Value); begin if Bean = null or else not (Bean.all in Util.Beans.Basic.Array_Bean'Class) then return null; else return Util.Beans.Basic.Array_Bean'Class (Bean.all)'Unchecked_Access; end if; end Get_Array_Bean; -- ------------------------------ -- Returns True if the object is an array. -- ------------------------------ function Is_Array (Value : in Object) return Boolean is begin if Value.V.Of_Type = TYPE_ARRAY then return True; elsif Value.V.Of_Type /= TYPE_BEAN then return False; else return Get_Array_Bean (Value) /= null; end if; end Is_Array; -- ------------------------------ -- Generic Object holding a value -- ------------------------------ -- ------------------------------ -- Get the type name -- ------------------------------ function Get_Type_Name (Value : in Object) return String is begin return Value.Type_Def.Get_Name; end Get_Type_Name; -- ------------------------------ -- Get a type identification for the object value. -- ------------------------------ function Get_Type (Value : in Object) return Data_Type is begin return Value.V.Of_Type; end Get_Type; -- ------------------------------ -- Get the type definition of the object value. -- ------------------------------ function Get_Type (Value : Object) return Object_Type_Access is begin return Value.Type_Def; end Get_Type; -- ------------------------------ -- Get the value identified by the name in the bean object. -- If the value object is not a bean, returns the null object. -- ------------------------------ function Get_Value (Value : in Object; Name : in String) return Object is Bean : constant access Util.Beans.Basic.Readonly_Bean'Class := To_Bean (Value); begin if Bean = null then return Null_Object; else return Bean.Get_Value (Name); end if; end Get_Value; -- ------------------------------ -- Set into the target object a value identified by the name. -- The target object must be a <tt>Bean</tt> instance that implements the <tt>Set_Value</tt> -- procedure. The operation does nothing if this is not the case. -- ------------------------------ procedure Set_Value (Into : in Object; Name : in String; Value : in Object) is Bean : constant access Util.Beans.Basic.Readonly_Bean'Class := To_Bean (Into); begin if Bean /= null and then Bean.all in Util.Beans.Basic.Bean'Class then Util.Beans.Basic.Bean'Class (Bean.all).Set_Value (Name, Value); end if; end Set_Value; -- ------------------------------ -- Get the number of elements in the array object. -- Returns 0 if the object is not an array. -- ------------------------------ function Get_Count (From : in Object) return Natural is use type Util.Beans.Basic.Array_Bean_Access; Bean : Util.Beans.Basic.Array_Bean_Access; begin if From.V.Of_Type = TYPE_ARRAY then return From.V.Array_Proxy.Len; elsif From.V.Of_Type /= TYPE_BEAN or else From.V.Proxy = null then return 0; else Bean := Get_Array_Bean (From); if Bean = null then return 0; else return Bean.Get_Count; end if; end if; end Get_Count; -- ------------------------------ -- Get the array element at the given position. -- ------------------------------ function Get_Value (From : in Object; Position : in Positive) return Object is use type Util.Beans.Basic.Array_Bean_Access; Bean : Util.Beans.Basic.Array_Bean_Access; begin if From.V.Of_Type = TYPE_BEAN then Bean := Get_Array_Bean (From); if Bean /= null then return Bean.Get_Row (Position); else return Null_Object; end if; elsif From.V.Of_Type /= TYPE_ARRAY then return Null_Object; elsif From.V.Array_Proxy.Len < Position then return Null_Object; else return From.V.Array_Proxy.Values (Position); end if; end Get_Value; -- ------------------------------ -- Convert the object to the corresponding type. -- ------------------------------ function To_String (Value : Object) return String is begin return Value.Type_Def.To_String (Value.V); end To_String; -- ------------------------------ -- Convert the object to a wide string. -- ------------------------------ function To_Wide_Wide_String (Value : Object) return Wide_Wide_String is begin return Value.Type_Def.To_Wide_Wide_String (Value.V); end To_Wide_Wide_String; -- ------------------------------ -- Convert the object to an unbounded string. -- ------------------------------ function To_Unbounded_String (Value : Object) return Unbounded_String is begin case Value.V.Of_Type is when TYPE_STRING => if Value.V.String_Proxy = null then return To_Unbounded_String ("null"); end if; return To_Unbounded_String (Value.V.String_Proxy.Value); when others => return To_Unbounded_String (To_String (Value)); end case; end To_Unbounded_String; -- ------------------------------ -- Convert the object to an unbounded wide string. -- ------------------------------ function To_Unbounded_Wide_Wide_String (Value : Object) return Unbounded_Wide_Wide_String is begin case Value.V.Of_Type is when TYPE_WIDE_STRING => if Value.V.Wide_Proxy = null then return To_Unbounded_Wide_Wide_String ("null"); end if; return To_Unbounded_Wide_Wide_String (Value.V.Wide_Proxy.Value); when TYPE_STRING => if Value.V.String_Proxy = null then return To_Unbounded_Wide_Wide_String ("null"); end if; return To_Unbounded_Wide_Wide_String (UTF8_Decode (Value.V.String_Proxy.Value)); when others => return To_Unbounded_Wide_Wide_String (To_Wide_Wide_String (To_String (Value))); end case; end To_Unbounded_Wide_Wide_String; -- ------------------------------ -- Convert the object to an integer. -- ------------------------------ function To_Integer (Value : Object) return Integer is begin return Integer (Value.Type_Def.To_Long_Long (Value.V)); end To_Integer; -- ------------------------------ -- Convert the object to an integer. -- ------------------------------ function To_Long_Integer (Value : Object) return Long_Integer is begin return Long_Integer (Value.Type_Def.To_Long_Long (Value.V)); end To_Long_Integer; -- ------------------------------ -- Convert the object to a long integer. -- ------------------------------ function To_Long_Long_Integer (Value : Object) return Long_Long_Integer is begin return Value.Type_Def.To_Long_Long (Value.V); end To_Long_Long_Integer; -- ------------------------------ -- Convert the object to a duration. -- ------------------------------ function To_Duration (Value : in Object) return Duration is begin return Value.Type_Def.To_Duration (Value.V); end To_Duration; function To_Bean (Value : in Object) return access Util.Beans.Basic.Readonly_Bean'Class is begin if Value.V.Of_Type = TYPE_BEAN and then Value.V.Proxy /= null then return Value.V.Proxy.Bean; else return null; end if; end To_Bean; -- ------------------------------ -- Convert the object to a boolean. -- ------------------------------ function To_Boolean (Value : Object) return Boolean is begin return Value.Type_Def.To_Boolean (Value.V); end To_Boolean; -- ------------------------------ -- Convert the object to a float. -- ------------------------------ function To_Float (Value : Object) return Float is begin return Float (Value.Type_Def.To_Long_Float (Value.V)); end To_Float; -- ------------------------------ -- Convert the object to a long float. -- ------------------------------ function To_Long_Float (Value : Object) return Long_Float is begin return Long_Float (Value.Type_Def.To_Long_Float (Value.V)); end To_Long_Float; -- ------------------------------ -- Convert the object to a long float. -- ------------------------------ function To_Long_Long_Float (Value : Object) return Long_Long_Float is begin return Value.Type_Def.To_Long_Float (Value.V); end To_Long_Long_Float; -- ------------------------------ -- Convert the object to a long float. -- ------------------------------ function To_Blob (Value : Object) return Util.Blobs.Blob_Ref is begin if Value.V.Of_Type = TYPE_BLOB and then Value.V.Blob_Proxy /= null then return Value.V.Blob_Proxy.Blob; else return Util.Blobs.Null_Blob; end if; end To_Blob; -- ------------------------------ -- Convert an integer into a generic typed object. -- ------------------------------ function To_Object (Value : Integer) return Object is begin return Object '(Controlled with V => Object_Value '(Of_Type => TYPE_INTEGER, Int_Value => Long_Long_Integer (Value)), Type_Def => Integer_Type'Access); end To_Object; -- ------------------------------ -- Convert an integer into a generic typed object. -- ------------------------------ function To_Object (Value : Long_Integer) return Object is begin return Object '(Controlled with V => Object_Value '(Of_Type => TYPE_INTEGER, Int_Value => Long_Long_Integer (Value)), Type_Def => Integer_Type'Access); end To_Object; -- ------------------------------ -- Convert an integer into a generic typed object. -- ------------------------------ function To_Object (Value : Long_Long_Integer) return Object is begin return Object '(Controlled with V => Object_Value '(Of_Type => TYPE_INTEGER, Int_Value => Value), Type_Def => Integer_Type'Access); end To_Object; -- ------------------------------ -- Convert a boolean into a generic typed object. -- ------------------------------ function To_Object (Value : Boolean) return Object is begin return Object '(Controlled with V => Object_Value '(Of_Type => TYPE_BOOLEAN, Bool_Value => Value), Type_Def => Bool_Type'Access); end To_Object; -- ------------------------------ -- Convert a float into a generic typed object. -- ------------------------------ function To_Object (Value : Float) return Object is begin return Object '(Controlled with V => Object_Value '(Of_Type => TYPE_FLOAT, Float_Value => Long_Long_Float (Value)), Type_Def => Flt_Type'Access); end To_Object; -- ------------------------------ -- Convert a long float into a generic typed object. -- ------------------------------ function To_Object (Value : Long_Float) return Object is begin return Object '(Controlled with V => Object_Value '(Of_Type => TYPE_FLOAT, Float_Value => Long_Long_Float (Value)), Type_Def => Flt_Type'Access); end To_Object; -- ------------------------------ -- Convert a long long float into a generic typed object. -- ------------------------------ function To_Object (Value : Long_Long_Float) return Object is begin return Object '(Controlled with V => Object_Value '(Of_Type => TYPE_FLOAT, Float_Value => Value), Type_Def => Flt_Type'Access); end To_Object; -- ------------------------------ -- Convert a duration into a generic typed object. -- ------------------------------ function To_Object (Value : in Duration) return Object is begin return Object '(Controlled with V => Object_Value '(Of_Type => TYPE_TIME, Time_Value => Value), Type_Def => Duration_Type'Access); end To_Object; -- ------------------------------ -- Convert a string into a generic typed object. -- ------------------------------ function To_Object (Value : String) return Object is begin return Object '(Controlled with V => Object_Value '(Of_Type => TYPE_STRING, String_Proxy => new String_Proxy '(Ref_Counter => ONE, Len => Value'Length, Value => Value)), Type_Def => Str_Type'Access); end To_Object; -- ------------------------------ -- Convert a wide string into a generic typed object. -- ------------------------------ function To_Object (Value : Wide_Wide_String) return Object is begin return Object '(Controlled with V => Object_Value '(Of_Type => TYPE_WIDE_STRING, Wide_Proxy => new Wide_String_Proxy '(Ref_Counter => ONE, Len => Value'Length, Value => Value)), Type_Def => WString_Type'Access); end To_Object; -- ------------------------------ -- Convert an unbounded string into a generic typed object. -- ------------------------------ function To_Object (Value : Unbounded_String) return Object is Len : constant Natural := Length (Value); begin return Object '(Controlled with V => Object_Value '(Of_Type => TYPE_STRING, String_Proxy => new String_Proxy '(Ref_Counter => ONE, Len => Len, Value => To_String (Value))), Type_Def => Str_Type'Access); end To_Object; -- ------------------------------ -- Convert a unbounded wide string into a generic typed object. -- ------------------------------ function To_Object (Value : Unbounded_Wide_Wide_String) return Object is Len : constant Natural := Length (Value); begin return Object '(Controlled with V => Object_Value '(Of_Type => TYPE_WIDE_STRING, Wide_Proxy => new Wide_String_Proxy '(Ref_Counter => ONE, Len => Len, Value => To_Wide_Wide_String (Value))), Type_Def => WString_Type'Access); end To_Object; function To_Object (Value : access Util.Beans.Basic.Readonly_Bean'Class; Storage : in Storage_Type := DYNAMIC) return Object is begin if Value = null then return Object '(Controlled with V => Object_Value '(Of_Type => TYPE_BEAN, Proxy => null), Type_Def => Bn_Type'Access); else return Object '(Controlled with V => Object_Value '(Of_Type => TYPE_BEAN, Proxy => new Bean_Proxy '(Ref_Counter => ONE, Bean => Value, Storage => Storage)), Type_Def => Bn_Type'Access); end if; end To_Object; function To_Object (Value : in Object_Array) return Object is begin return Object '(Controlled with V => Object_Value '(Of_Type => TYPE_ARRAY, Array_Proxy => new Array_Proxy '(Ref_Counter => ONE, Len => Value'Length, Count => Value'Length, Values => Value)), Type_Def => Ar_Type'Access); end To_Object; function To_Object (Value : in Util.Blobs.Blob_Ref) return Object is begin return Object '(Controlled with V => Object_Value '(Of_Type => TYPE_BLOB, Blob_Proxy => new Blob_Proxy '(Ref_Counter => ONE, Blob => Value)), Type_Def => Blob_Def'Access); end To_Object; -- ------------------------------ -- Convert the object to an object of another time. -- Force the object to be an integer. -- ------------------------------ function Cast_Integer (Value : Object) return Object is begin return Object '(Controlled with V => Object_Value '(Of_Type => TYPE_INTEGER, Int_Value => Value.Type_Def.To_Long_Long (Value.V)), Type_Def => Integer_Type'Access); end Cast_Integer; -- ------------------------------ -- Force the object to be a float. -- ------------------------------ function Cast_Float (Value : Object) return Object is begin return Object '(Controlled with V => Object_Value '(Of_Type => TYPE_FLOAT, Float_Value => Value.Type_Def.To_Long_Float (Value.V)), Type_Def => Flt_Type'Access); end Cast_Float; -- ------------------------------ -- Convert the object to an object of another time. -- Force the object to be a duration. -- ------------------------------ function Cast_Duration (Value : Object) return Object is begin return Object '(Controlled with V => Object_Value '(Of_Type => TYPE_TIME, Time_Value => Value.Type_Def.To_Duration (Value.V)), Type_Def => Duration_Type'Access); end Cast_Duration; -- ------------------------------ -- Force the object to be a string. -- ------------------------------ function Cast_String (Value : Object) return Object is begin if Value.V.Of_Type = TYPE_STRING or else Value.V.Of_Type = TYPE_WIDE_STRING then return Value; else return To_Object (To_Wide_Wide_String (Value)); end if; end Cast_String; -- ------------------------------ -- Find the best type to be used to compare two operands. -- -- ------------------------------ function Get_Compare_Type (Left, Right : Object) return Data_Type is begin -- Operands are of the same type. if Left.V.Of_Type = Right.V.Of_Type then return Left.V.Of_Type; end if; -- 12 >= "23" -- if Left.Of_Type = TYPE_STRING or case Left.V.Of_Type is when TYPE_BOOLEAN => case Right.V.Of_Type is when TYPE_INTEGER | TYPE_BOOLEAN | TYPE_TIME => return TYPE_INTEGER; when TYPE_FLOAT | TYPE_STRING | TYPE_WIDE_STRING => return Right.V.Of_Type; when others => null; end case; when TYPE_INTEGER => case Right.V.Of_Type is when TYPE_BOOLEAN | TYPE_TIME => return TYPE_INTEGER; when TYPE_FLOAT => return TYPE_FLOAT; when others => null; end case; when TYPE_TIME => case Right.V.Of_Type is when TYPE_INTEGER | TYPE_BOOLEAN | TYPE_FLOAT => return TYPE_INTEGER; when others => null; end case; when TYPE_FLOAT => case Right.V.Of_Type is when TYPE_INTEGER | TYPE_BOOLEAN => return TYPE_FLOAT; when TYPE_TIME => return TYPE_INTEGER; when others => null; end case; when others => null; end case; return TYPE_STRING; end Get_Compare_Type; -- ------------------------------ -- Find the data type to be used for an arithmetic operation between two objects. -- ------------------------------ function Get_Arithmetic_Type (Left, Right : Object) return Data_Type is begin if Left.V.Of_Type = TYPE_FLOAT or else Right.V.Of_Type = TYPE_FLOAT then return TYPE_FLOAT; end if; if Left.V.Of_Type = TYPE_INTEGER or else Right.V.Of_Type = TYPE_INTEGER then return TYPE_INTEGER; end if; if Left.V.Of_Type = TYPE_BOOLEAN and then Right.V.Of_Type = TYPE_BOOLEAN then return TYPE_BOOLEAN; end if; return TYPE_FLOAT; end Get_Arithmetic_Type; -- ------------------------------ -- Find the data type to be used for a composition operation between two objects. -- ------------------------------ function Get_Compose_Type (Left, Right : Object) return Data_Type is begin if Left.V.Of_Type = Right.V.Of_Type then return Left.V.Of_Type; end if; if Left.V.Of_Type = TYPE_FLOAT or else Right.V.Of_Type = TYPE_FLOAT then return TYPE_FLOAT; end if; if Left.V.Of_Type = TYPE_INTEGER or else Right.V.Of_Type = TYPE_INTEGER then return TYPE_INTEGER; end if; if Left.V.Of_Type = TYPE_TIME or else Right.V.Of_Type = TYPE_TIME then return TYPE_TIME; end if; if Left.V.Of_Type = TYPE_BOOLEAN and then Right.V.Of_Type = TYPE_BOOLEAN then return TYPE_BOOLEAN; end if; return TYPE_FLOAT; end Get_Compose_Type; -- ------------------------------ -- Comparison of objects -- ------------------------------ generic with function Int_Comparator (Left, Right : Long_Long_Integer) return Boolean; with function Time_Comparator (Left, Right : Duration) return Boolean; with function Boolean_Comparator (Left, Right : Boolean) return Boolean; with function Float_Comparator (Left, Right : Long_Long_Float) return Boolean; with function String_Comparator (Left, Right : String) return Boolean; with function Wide_String_Comparator (Left, Right : Wide_Wide_String) return Boolean; function Compare (Left, Right : Object) return Boolean; -- ------------------------------ -- Comparison of objects -- ------------------------------ function Compare (Left, Right : Object) return Boolean is T : constant Data_Type := Get_Compare_Type (Left, Right); begin case T is when TYPE_BOOLEAN => return Boolean_Comparator (Left.Type_Def.To_Boolean (Left.V), Right.Type_Def.To_Boolean (Right.V)); when TYPE_INTEGER => return Int_Comparator (Left.Type_Def.To_Long_Long (Left.V), Right.Type_Def.To_Long_Long (Right.V)); when TYPE_TIME => return Time_Comparator (Left.Type_Def.To_Duration (Left.V), Right.Type_Def.To_Duration (Right.V)); when TYPE_FLOAT => return Float_Comparator (Left.Type_Def.To_Long_Float (Left.V), Right.Type_Def.To_Long_Float (Right.V)); when TYPE_STRING => return String_Comparator (To_String (Left), To_String (Right)); when TYPE_WIDE_STRING => return Wide_String_Comparator (To_Wide_Wide_String (Left), To_Wide_Wide_String (Right)); when others => return False; end case; end Compare; function ">" (Left, Right : Object) return Boolean is function Cmp is new Compare (Int_Comparator => ">", Time_Comparator => ">", Boolean_Comparator => ">", Float_Comparator => ">", String_Comparator => ">", Wide_String_Comparator => ">"); begin return Cmp (Left, Right); end ">"; function "<" (Left, Right : Object) return Boolean is function Cmp is new Compare (Int_Comparator => "<", Time_Comparator => "<", Boolean_Comparator => "<", Float_Comparator => "<", String_Comparator => "<", Wide_String_Comparator => "<"); begin return Cmp (Left, Right); end "<"; function "<=" (Left, Right : Object) return Boolean is function Cmp is new Compare (Int_Comparator => "<=", Time_Comparator => "<=", Boolean_Comparator => "<=", Float_Comparator => "<=", String_Comparator => "<=", Wide_String_Comparator => "<="); begin return Cmp (Left, Right); end "<="; function ">=" (Left, Right : Object) return Boolean is function Cmp is new Compare (Int_Comparator => ">=", Time_Comparator => ">=", Boolean_Comparator => ">=", Float_Comparator => ">=", String_Comparator => ">=", Wide_String_Comparator => ">="); begin return Cmp (Left, Right); end ">="; overriding function "=" (Left, Right : Object) return Boolean is function Cmp is new Compare (Int_Comparator => "=", Time_Comparator => "=", Boolean_Comparator => "=", Float_Comparator => "=", String_Comparator => "=", Wide_String_Comparator => "="); begin return Cmp (Left, Right); end "="; -- ------------------------------ -- Arithmetic operations of objects -- ------------------------------ generic with function Int_Operation (Left, Right : Long_Long_Integer) return Long_Long_Integer; with function Duration_Operation (Left, Right : Duration) return Duration; with function Float_Operation (Left, Right : Long_Long_Float) return Long_Long_Float; function Arith (Left, Right : Object) return Object; -- Comparison of objects function Arith (Left, Right : Object) return Object is begin -- If we have a time object, keep the time definition. if Left.V.Of_Type = TYPE_TIME then return Result : Object do Result.Type_Def := Left.Type_Def; Result.V := Object_Value '(Of_Type => TYPE_TIME, Time_Value => Duration_Operation (Left.Type_Def.To_Duration (Left.V), Right.Type_Def.To_Duration (Right.V))); end return; end if; if Right.V.Of_Type = TYPE_TIME then return Result : Object do Result.Type_Def := Right.Type_Def; Result.V := Object_Value '(Of_Type => TYPE_TIME, Time_Value => Duration_Operation (Left.Type_Def.To_Duration (Left.V), Right.Type_Def.To_Duration (Right.V))); end return; end if; declare T : constant Data_Type := Get_Arithmetic_Type (Left, Right); begin case T is when TYPE_INTEGER => return To_Object (Int_Operation (Left.Type_Def.To_Long_Long (Left.V), Right.Type_Def.To_Long_Long (Right.V))); when TYPE_FLOAT => return To_Object (Float_Operation (Left.Type_Def.To_Long_Float (Left.V), Right.Type_Def.To_Long_Float (Right.V))); when others => return Left; end case; end; end Arith; -- Arithmetic operations on objects function "+" (Left, Right : Object) return Object is function Operation is new Arith (Int_Operation => "+", Duration_Operation => "+", Float_Operation => "+"); begin return Operation (Left, Right); end "+"; function "-" (Left, Right : Object) return Object is function Operation is new Arith (Int_Operation => "-", Duration_Operation => "-", Float_Operation => "-"); begin return Operation (Left, Right); end "-"; function "-" (Left : Object) return Object is begin case Left.V.Of_Type is when TYPE_INTEGER => return To_Object (-Left.Type_Def.To_Long_Long (Left.V)); when TYPE_TIME => return To_Object (-Left.Type_Def.To_Duration (Left.V)); when TYPE_FLOAT => return To_Object (-(Left.Type_Def.To_Long_Float (Left.V))); when others => return Left; end case; end "-"; function "*" (Left, Right : Object) return Object is function Operation is new Arith (Int_Operation => "*", Duration_Operation => "+", Float_Operation => "*"); begin return Operation (Left, Right); end "*"; function "/" (Left, Right : Object) return Object is function Operation is new Arith (Int_Operation => "/", Duration_Operation => "-", Float_Operation => "/"); begin return Operation (Left, Right); end "/"; function "mod" (Left, Right : Object) return Object is function "mod" (Left, Right : Long_Long_Float) return Long_Long_Float; function "mod" (Left, Right : Long_Long_Float) return Long_Long_Float is L : constant Long_Long_Integer := Long_Long_Integer (Left); R : constant Long_Long_Integer := Long_Long_Integer (Right); begin return Long_Long_Float (L mod R); end "mod"; function Operation is new Arith (Int_Operation => "mod", Duration_Operation => "-", Float_Operation => "mod"); begin return Operation (Left, Right); end "mod"; function "&" (Left, Right : Object) return Object is T : constant Data_Type := Get_Compose_Type (Left, Right); begin case T is when TYPE_BOOLEAN => return To_Object (To_Boolean (Left) and then To_Boolean (Right)); when others => return To_Object (To_String (Left) & To_String (Right)); end case; end "&"; overriding procedure Adjust (Obj : in out Object) is begin case Obj.V.Of_Type is when TYPE_BEAN => if Obj.V.Proxy /= null then Util.Concurrent.Counters.Increment (Obj.V.Proxy.Ref_Counter); end if; when TYPE_ARRAY => if Obj.V.Array_Proxy /= null then Util.Concurrent.Counters.Increment (Obj.V.Array_Proxy.Ref_Counter); end if; when TYPE_STRING => if Obj.V.String_Proxy /= null then Util.Concurrent.Counters.Increment (Obj.V.String_Proxy.Ref_Counter); end if; when TYPE_WIDE_STRING => if Obj.V.Wide_Proxy /= null then Util.Concurrent.Counters.Increment (Obj.V.Wide_Proxy.Ref_Counter); end if; when TYPE_BLOB => if Obj.V.Blob_Proxy /= null then Util.Concurrent.Counters.Increment (Obj.V.Blob_Proxy.Ref_Counter); end if; when others => null; end case; end Adjust; procedure Free is new Ada.Unchecked_Deallocation (Object => Basic.Readonly_Bean'Class, Name => Basic.Readonly_Bean_Access); procedure Free is new Ada.Unchecked_Deallocation (Object => Array_Proxy, Name => Array_Proxy_Access); procedure Free is new Ada.Unchecked_Deallocation (Object => String_Proxy, Name => String_Proxy_Access); procedure Free is new Ada.Unchecked_Deallocation (Object => Wide_String_Proxy, Name => Wide_String_Proxy_Access); procedure Free is new Ada.Unchecked_Deallocation (Object => Blob_Proxy, Name => Blob_Proxy_Access); overriding procedure Finalize (Obj : in out Object) is Release : Boolean; begin case Obj.V.Of_Type is when TYPE_STRING => if Obj.V.String_Proxy /= null then Util.Concurrent.Counters.Decrement (Obj.V.String_Proxy.Ref_Counter, Release); if Release then Free (Obj.V.String_Proxy); else Obj.V.String_Proxy := null; end if; end if; when TYPE_WIDE_STRING => if Obj.V.Wide_Proxy /= null then Util.Concurrent.Counters.Decrement (Obj.V.Wide_Proxy.Ref_Counter, Release); if Release then Free (Obj.V.Wide_Proxy); else Obj.V.Wide_Proxy := null; end if; end if; when TYPE_BEAN => if Obj.V.Proxy /= null then Util.Concurrent.Counters.Decrement (Obj.V.Proxy.Ref_Counter, Release); if Release then Obj.V.Proxy.all.Release; Free (Obj.V.Proxy); else Obj.V.Proxy := null; end if; end if; when TYPE_ARRAY => if Obj.V.Array_Proxy /= null then Util.Concurrent.Counters.Decrement (Obj.V.Array_Proxy.Ref_Counter, Release); if Release then Free (Obj.V.Array_Proxy); else Obj.V.Array_Proxy := null; end if; end if; when TYPE_BLOB => if Obj.V.Blob_Proxy /= null then Util.Concurrent.Counters.Decrement (Obj.V.Blob_Proxy.Ref_Counter, Release); if Release then Free (Obj.V.Blob_Proxy); else Obj.V.Blob_Proxy := null; end if; end if; when others => null; end case; end Finalize; -- ------------------------------ -- Release the object pointed to by the proxy (if necessary). -- ------------------------------ overriding procedure Release (P : in out Bean_Proxy) is begin if P.Storage = DYNAMIC and then P.Bean /= null then declare Bean : Basic.Readonly_Bean_Access := P.Bean.all'Access; begin P.Bean := null; Free (Bean); end; end if; end Release; overriding procedure Finalize (Proxy : in out Proxy_Iterator) is Release : Boolean; begin if Proxy.Proxy /= null then Util.Concurrent.Counters.Decrement (Proxy.Proxy.Ref_Counter, Release); if Release then Free (Proxy.Proxy); else Proxy.Proxy := null; end if; end if; end Finalize; end Util.Beans.Objects;
AdaCore/gpr
Ada
2,249
adb
-- -- Copyright (C) 2021-2023, AdaCore -- -- SPDX-License-Identifier: Apache-2.0 -- with Ada.Text_IO; with Gpr_Parser_Support.Text; use Gpr_Parser_Support.Text; with Gpr_Parser_Support.Slocs; with Gpr_Parser.Basic_Ada_Parser; use Gpr_Parser.Basic_Ada_Parser; with Gpr_Parser.Analysis; use Gpr_Parser.Analysis; with Ada.Command_Line; procedure Main is use all type Gpr_Parser_Support.Text.Text_Type; procedure On_Error (Msg : String); procedure On_No_Body_CB; procedure Unit_Name_CB (Unit_Name : String; Separate_From : String := ""; Lib_Item_Type : Gpr_Parser.Basic_Ada_Parser.Library_Item_Type; Generic_Unit : Boolean); procedure With_Clause_CB (Unit_Name : String; Is_Limited : Boolean); procedure On_Error (Msg : String) is begin Ada.Text_IO.Put_Line ("Error during parsing: " & Msg); end On_Error; procedure On_No_Body_CB is begin Ada.Text_IO.Put_Line ("No body source file"); end On_No_Body_CB; procedure Unit_Name_CB (Unit_Name : String; Separate_From : String := ""; Lib_Item_Type : Gpr_Parser.Basic_Ada_Parser.Library_Item_Type; Generic_Unit : Boolean) is begin Ada.Text_IO.Put_Line ("Unit name: " & Unit_Name); if Separate_From /= "" then Ada.Text_IO.Put_Line ("Separate from: " & Separate_From); end if; end Unit_Name_CB; procedure With_Clause_CB (Unit_Name : String; Is_Limited : Boolean) is begin Ada.Text_IO.Put_Line ("Withed unit name: " & Unit_Name); end With_Clause_CB; Ctx : constant Analysis_Context := Create_Context; begin if Ada.Command_Line.Argument_Count /= 1 then Ada.Text_IO.Put_Line ("Invalid number of arguments. Usage: ./test <file to parse>"); return; end if; declare File : String := Ada.Command_Line.Argument (1); begin Ada.Text_IO.Put_Line ("Loading " & File); Parse_Context_Clauses (Filename => File, Context => Ctx, Log_Error => On_Error'Access, With_Clause_CB => With_Clause_CB'Access, Unit_Name_CB => Unit_Name_CB'Access, No_Body_CB => On_No_Body_CB'Access); end; end Main;
ytomino/gnat4drake
Ada
1,476
ads
pragma License (Unrestricted); with Ada.Directories; with Ada.Hierarchical_File_Names; package GNAT.Directory_Operations is subtype Dir_Name_Str is String; subtype Dir_Type is Ada.Directories.Search_Type; Directory_Error : exception; -- Basic Directory operations procedure Change_Dir (Dir_Name : Dir_Name_Str) renames Ada.Directories.Set_Directory; procedure Make_Dir (Dir_Name : Dir_Name_Str); procedure Remove_Dir ( Dir_Name : Dir_Name_Str; Recursive : Boolean := False); function Get_Current_Dir return Dir_Name_Str renames Ada.Directories.Current_Directory; -- Pathname Operations subtype Path_Name is String; function Dir_Name (Path : Path_Name) return Dir_Name_Str renames Ada.Hierarchical_File_Names.Containing_Directory; function Base_Name (Path : Path_Name; Suffix : String := "") return String; function File_Extension (Path : Path_Name) return String renames Ada.Hierarchical_File_Names.Extension; type Path_Style is (System_Default); function Format_Pathname ( Path : Path_Name; Style : Path_Style := System_Default) return Path_Name; -- Iterators procedure Open (Dir : in out Dir_Type; Dir_Name : Dir_Name_Str); procedure Close (Dir : in out Dir_Type) renames Ada.Directories.End_Search; procedure Read ( Dir : in out Dir_Type; Str : out String; Last : out Natural); end GNAT.Directory_Operations;
reznikmm/matreshka
Ada
4,187
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2013, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with Matreshka.DOM_Nodes; with XML.DOM.Elements.Internals; package body ODF.DOM.Elements.Office.Text.Internals is ------------ -- Create -- ------------ function Create (Node : Matreshka.ODF_Elements.Office.Text.Office_Text_Access) return ODF.DOM.Elements.Office.Text.ODF_Office_Text is begin return (XML.DOM.Elements.Internals.Create (Matreshka.DOM_Nodes.Element_Access (Node)) with null record); end Create; ---------- -- Wrap -- ---------- function Wrap (Node : Matreshka.ODF_Elements.Office.Text.Office_Text_Access) return ODF.DOM.Elements.Office.Text.ODF_Office_Text is begin return (XML.DOM.Elements.Internals.Wrap (Matreshka.DOM_Nodes.Element_Access (Node)) with null record); end Wrap; end ODF.DOM.Elements.Office.Text.Internals;
KipodAfterFree/KAF-2019-FireHog
Ada
3,389
adb
------------------------------------------------------------------------------ -- -- -- GNAT ncurses Binding Samples -- -- -- -- Status -- -- -- -- B O D Y -- -- -- ------------------------------------------------------------------------------ -- Copyright (c) 1998 Free Software Foundation, Inc. -- -- -- -- Permission is hereby granted, free of charge, to any person obtaining a -- -- copy of this software and associated documentation files (the -- -- "Software"), to deal in the Software without restriction, including -- -- without limitation the rights to use, copy, modify, merge, publish, -- -- distribute, distribute with modifications, sublicense, and/or sell -- -- copies of the Software, and to permit persons to whom the Software is -- -- furnished to do so, subject to the following conditions: -- -- -- -- The above copyright notice and this permission notice shall be included -- -- in all copies or substantial portions of the Software. -- -- -- -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -- -- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -- -- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -- -- IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -- -- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -- -- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR -- -- THE USE OR OTHER DEALINGS IN THE SOFTWARE. -- -- -- -- Except as contained in this notice, the name(s) of the above copyright -- -- holders shall not be used in advertising or otherwise to promote the -- -- sale, use or other dealings in this Software without prior written -- -- authorization. -- ------------------------------------------------------------------------------ -- Author: Juergen Pfeifer <[email protected]> 1996 -- Version Control -- $Revision: 1.3 $ -- Binding Version 00.93 ------------------------------------------------------------------------------ -- This package has been contributed by Laurent Pautet <[email protected]> -- -- -- package body Status is protected body Process is procedure Stop is begin Done := True; end Stop; function Continue return Boolean is begin return not Done; end Continue; end Process; end Status;
Rodeo-McCabe/orka
Ada
18,266
adb
-- SPDX-License-Identifier: Apache-2.0 -- -- Copyright (c) 2017 onox <[email protected]> -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. with System; with Ada.Exceptions; with Ada.Real_Time; with Ada.Unchecked_Deallocation; with GL.Low_Level.Enums; with GL.Pixels.Extensions; with GL.Types.Pointers; with Orka.Jobs; with Orka.Logging; with Orka.KTX; with Orka.Strings; package body Orka.Resources.Textures.KTX is use all type Orka.Logging.Source; use all type Orka.Logging.Severity; package Messages is new Orka.Logging.Messages (Resource_Loader); function Trim_Image (Value : Integer) return String is (Orka.Strings.Trim (Integer'Image (Value))); type KTX_Load_Job is new Jobs.Abstract_Job and Jobs.GPU_Job with record Data : Loaders.Resource_Data; Manager : Managers.Manager_Ptr; end record; overriding procedure Execute (Object : KTX_Load_Job; Context : Jobs.Execution_Context'Class); ----------------------------------------------------------------------------- use all type Ada.Real_Time.Time; function Read_Texture (Bytes : Byte_Array_Pointers.Constant_Reference; Path : String; Start : Ada.Real_Time.Time) return GL.Objects.Textures.Texture is T1 : Ada.Real_Time.Time renames Start; T2 : constant Ada.Real_Time.Time := Clock; use Ada.Streams; use GL.Low_Level.Enums; use type GL.Types.Size; T3, T4, T5, T6 : Ada.Real_Time.Time; begin if not Orka.KTX.Valid_Identifier (Bytes) then raise Texture_Load_Error with Path & " is not a KTX file"; end if; declare Header : constant Orka.KTX.Header := Orka.KTX.Get_Header (Bytes); Levels : constant GL.Types.Size := GL.Types.Size'Max (1, Header.Mipmap_Levels); Texture : GL.Objects.Textures.Texture (Header.Kind); Width : constant GL.Types.Size := Header.Width; Height : GL.Types.Size := Header.Height; Depth : GL.Types.Size := Header.Depth; begin T3 := Clock; if not Header.Compressed and then Header.Data_Type in GL.Pixels.Extensions.Packed_Data_Type then raise GL.Feature_Not_Supported_Exception with "Packed data type " & Header.Data_Type'Image & " is not supported yet"; end if; -- Allocate storage case Header.Kind is when Texture_2D_Array => Depth := Header.Array_Elements; when Texture_1D_Array => Height := Header.Array_Elements; pragma Assert (Depth = 0); when Texture_Cube_Map_Array => -- For a cube map array, depth is the number of layer-faces Depth := Header.Array_Elements * 6; when Texture_3D => null; when Texture_2D | Texture_Cube_Map => pragma Assert (Depth = 0); when Texture_1D => if Header.Compressed then raise Texture_Load_Error with Path & " has unknown 1D compressed format"; end if; pragma Assert (Height = 0); pragma Assert (Depth = 0); when others => raise Program_Error; end case; if Header.Compressed then Texture.Allocate_Storage (Levels, 1, Header.Compressed_Format, Width, Height, Depth); else Texture.Allocate_Storage (Levels, 1, Header.Internal_Format, Width, Height, Depth); end if; case Header.Kind is when Texture_1D => Height := 1; Depth := 1; when Texture_1D_Array | Texture_2D => Depth := 1; when Texture_2D_Array | Texture_3D => null; when Texture_Cube_Map | Texture_Cube_Map_Array => -- Texture_Cube_Map uses 2D storage, but 3D load operation -- according to table 8.15 of the OpenGL specification -- For a cube map, depth is the number of faces, for -- a cube map array, depth is the number of layer-faces Depth := GL.Types.Size'Max (1, Header.Array_Elements) * 6; when others => raise Program_Error; end case; T4 := Clock; -- TODO Handle KTXorientation key value pair declare procedure Iterate (Position : Orka.KTX.String_Maps.Cursor) is begin Messages.Log (Warning, "Metadata: " & Orka.KTX.String_Maps.Key (Position) & " = " & Orka.KTX.String_Maps.Element (Position)); end Iterate; begin Orka.KTX.Get_Key_Value_Map (Bytes, Header.Bytes_Key_Value).Iterate (Iterate'Access); end; -- Upload texture data declare Image_Size_Index : Stream_Element_Offset := Orka.KTX.Get_Data_Offset (Bytes, Header.Bytes_Key_Value); Cube_Map : constant Boolean := Header.Kind = Texture_Cube_Map; begin for Level in 0 .. Levels - 1 loop declare Face_Size : constant Natural := Orka.KTX.Get_Length (Bytes, Image_Size_Index); -- If not Cube_Map, then Face_Size is the size of the whole level Cube_Padding : constant Natural := 3 - ((Face_Size + 3) mod 4); Image_Size : constant Natural := (if Cube_Map then (Face_Size + Cube_Padding) * 6 else Face_Size); -- If Cube_Map then Levels = 1 so no need to add it to the expression -- Compute size of the whole mipmap level Mip_Padding : constant Natural := 3 - ((Image_Size + 3) mod 4); Mipmap_Size : constant Natural := 4 + Image_Size + Mip_Padding; Offset : constant Stream_Element_Offset := Image_Size_Index + 4; pragma Assert (Offset + Stream_Element_Offset (Image_Size) - 1 <= Bytes.Value'Last); Image_Data : constant System.Address := Bytes (Offset)'Address; -- TODO Unpack_Alignment must be 4, but Load_From_Data wants 1 | 2 | 4 -- depending on Header.Data_Type Level_Width : constant GL.Types.Size := Texture.Width (Level); Level_Height : constant GL.Types.Size := Texture.Height (Level); Level_Depth : constant GL.Types.Size := (if Cube_Map then 6 else Texture.Depth (Level)); begin if Header.Compressed then Texture.Load_From_Data (Level, 0, 0, 0, Level_Width, Level_Height, Level_Depth, Header.Compressed_Format, GL.Types.Int (Image_Size), Image_Data); else Texture.Load_From_Data (Level, 0, 0, 0, Level_Width, Level_Height, Level_Depth, Header.Format, Header.Data_Type, Image_Data); end if; Image_Size_Index := Image_Size_Index + Stream_Element_Offset (Mipmap_Size); end; end loop; end; T5 := Clock; -- Generate a full mipmap pyramid if Mipmap_Levels = 0 if Header.Mipmap_Levels = 0 then Texture.Generate_Mipmap; end if; T6 := Clock; Messages.Log (Info, "Loaded texture " & Path & " in " & Logging.Trim (Logging.Image (T6 - T1))); Messages.Log (Info, " dims: " & Logging.Trim (Width'Image) & " x " & Logging.Trim (Height'Image) & " x " & Logging.Trim (Depth'Image) & ", mipmap levels:" & Levels'Image); Messages.Log (Info, " size: " & Trim_Image (Bytes.Value'Length) & " bytes"); Messages.Log (Info, " kind: " & Header.Kind'Image); if Header.Compressed then Messages.Log (Info, " format: " & Header.Compressed_Format'Image); else Messages.Log (Info, " format: " & Header.Internal_Format'Image & " (" & Trim_Image (Integer (GL.Pixels.Extensions.Components (Header.Format))) & "x " & Header.Data_Type'Image & ")"); end if; Messages.Log (Info, " statistics:"); Messages.Log (Info, " reading file: " & Logging.Image (T2 - T1)); Messages.Log (Info, " parsing header: " & Logging.Image (T3 - T2)); Messages.Log (Info, " storage: " & Logging.Image (T4 - T3)); Messages.Log (Info, " buffers: " & Logging.Image (T5 - T4)); if Header.Mipmap_Levels = 0 then Messages.Log (Info, " generating mipmap:" & Logging.Image (T6 - T5)); end if; return Texture; end; exception when Error : Orka.KTX.Invalid_Enum_Error => declare Message : constant String := Ada.Exceptions.Exception_Message (Error); begin raise Texture_Load_Error with Path & " has " & Message; end; end Read_Texture; function Read_Texture (Location : Locations.Location_Ptr; Path : String) return GL.Objects.Textures.Texture is Start_Time : constant Ada.Real_Time.Time := Ada.Real_Time.Clock; begin return Read_Texture (Location.Read_Data (Path).Get, Path, Start_Time); end Read_Texture; overriding procedure Execute (Object : KTX_Load_Job; Context : Jobs.Execution_Context'Class) is Bytes : Byte_Array_Pointers.Constant_Reference := Object.Data.Bytes.Get; Path : String renames SU.To_String (Object.Data.Path); Resource : constant Texture_Ptr := new Texture'(others => <>); begin Resource.Texture.Replace_Element (Read_Texture (Bytes, Path, Object.Data.Start_Time)); -- Register resource at the resource manager Object.Manager.Add_Resource (Path, Resource_Ptr (Resource)); end Execute; ----------------------------------------------------------------------------- -- Loader -- ----------------------------------------------------------------------------- type KTX_Loader is limited new Loaders.Loader with record Manager : Managers.Manager_Ptr; end record; overriding function Extension (Object : KTX_Loader) return Loaders.Extension_String is ("ktx"); overriding procedure Load (Object : KTX_Loader; Data : Loaders.Resource_Data; Enqueue : not null access procedure (Element : Jobs.Job_Ptr); Location : Locations.Location_Ptr) is Job : constant Jobs.Job_Ptr := new KTX_Load_Job' (Jobs.Abstract_Job with Data => Data, Manager => Object.Manager); begin Enqueue (Job); end Load; function Create_Loader (Manager : Managers.Manager_Ptr) return Loaders.Loader_Ptr is (new KTX_Loader'(Manager => Manager)); ----------------------------------------------------------------------------- -- Writer -- ----------------------------------------------------------------------------- package Pointers is new GL.Objects.Textures.Texture_Pointers (Byte_Pointers); procedure Write_Texture (Texture : GL.Objects.Textures.Texture; Location : Locations.Writable_Location_Ptr; Path : String) is package Textures renames GL.Objects.Textures; Format : GL.Pixels.Format := GL.Pixels.RGBA; Data_Type : GL.Pixels.Data_Type := GL.Pixels.Float; -- Note: unused if texture is compressed Base_Level : constant := 0; use Ada.Streams; use all type GL.Low_Level.Enums.Texture_Kind; use type GL.Types.Size; Compressed : constant Boolean := Texture.Compressed; Header : Orka.KTX.Header (Compressed); function Convert (Bytes : in out GL.Types.Pointers.UByte_Array_Access) return Byte_Array_Pointers.Pointer is Pointer : Byte_Array_Pointers.Pointer; Result : constant Byte_Array_Access := new Byte_Array (1 .. Bytes'Length); procedure Free is new Ada.Unchecked_Deallocation (Object => GL.Types.UByte_Array, Name => GL.Types.Pointers.UByte_Array_Access); begin for Index in Bytes'Range loop declare Target_Index : constant Stream_Element_Offset := Stream_Element_Offset (Index - Bytes'First + 1); begin Result (Target_Index) := Stream_Element (Bytes (Index)); end; end loop; Free (Bytes); Pointer.Set (Result); return Pointer; end Convert; function Convert (Bytes : in out Pointers.Element_Array_Access) return Byte_Array_Pointers.Pointer is Pointer : Byte_Array_Pointers.Pointer; Result : constant Byte_Array_Access := new Byte_Array (1 .. Bytes'Length); begin Result.all := Bytes.all; Pointers.Free (Bytes); Pointer.Set (Result); return Pointer; end Convert; function Get_Data (Level : Textures.Mipmap_Level) return Byte_Array_Pointers.Pointer is Data : Pointers.Element_Array_Access; begin Data := Pointers.Get_Data (Texture, Level, 0, 0, 0, Texture.Width (Level), Texture.Height (Level), Texture.Depth (Level), Format, Data_Type); return Convert (Data); end Get_Data; function Get_Compressed_Data (Level : Textures.Mipmap_Level) return Byte_Array_Pointers.Pointer is Data : GL.Types.Pointers.UByte_Array_Access; begin Data := Textures.Get_Compressed_Data (Texture, Level, 0, 0, 0, Texture.Width (Level), Texture.Height (Level), Texture.Depth (Level), Texture.Compressed_Format); return Convert (Data); end Get_Compressed_Data; T1, T2, T3, T4 : Ada.Real_Time.Time; begin T1 := Clock; Header.Kind := Texture.Kind; Header.Width := Texture.Width (Base_Level); case Texture.Kind is when Texture_3D => Header.Height := Texture.Height (Base_Level); Header.Depth := Texture.Depth (Base_Level); when Texture_2D | Texture_2D_Array | Texture_Cube_Map | Texture_Cube_Map_Array => Header.Height := Texture.Height (Base_Level); Header.Depth := 0; when Texture_1D | Texture_1D_Array => Header.Height := 0; Header.Depth := 0; when others => raise Program_Error; end case; case Texture.Kind is when Texture_1D_Array => Header.Array_Elements := Texture.Height (Base_Level); when Texture_2D_Array => Header.Array_Elements := Texture.Depth (Base_Level); when Texture_Cube_Map_Array => Header.Array_Elements := Texture.Depth (Base_Level) / 6; when Texture_1D | Texture_2D | Texture_3D | Texture_Cube_Map => Header.Array_Elements := 0; when others => raise Program_Error; end case; Header.Mipmap_Levels := Texture.Mipmap_Levels; Header.Bytes_Key_Value := 0; if Compressed then Header.Compressed_Format := Texture.Compressed_Format; else declare Internal_Format : constant GL.Pixels.Internal_Format := Texture.Internal_Format; begin Format := GL.Pixels.Extensions.Texture_Format (Internal_Format); Data_Type := GL.Pixels.Extensions.Texture_Data_Type (Internal_Format); Header.Internal_Format := Internal_Format; Header.Format := Format; Header.Data_Type := Data_Type; end; end if; T2 := Clock; declare function Get_Level_Data (Level : Textures.Mipmap_Level) return Byte_Array_Pointers.Pointer is (if Compressed then Get_Compressed_Data (Level) else Get_Data (Level)); Bytes : constant Byte_Array_Pointers.Pointer := Orka.KTX.Create_KTX_Bytes (Header, Get_Level_Data'Access); begin T3 := Clock; Location.Write_Data (Path, Bytes.Get); T4 := Clock; Messages.Log (Info, "Saved texture " & Path & " in " & Logging.Trim (Logging.Image (T4 - T1))); Messages.Log (Info, " dims: " & Logging.Trim (Texture.Width (Base_Level)'Image) & " x " & Logging.Trim (Texture.Height (Base_Level)'Image) & " x " & Logging.Trim (Texture.Depth (Base_Level)'Image) & ", mipmap levels:" & Texture.Mipmap_Levels'Image); Messages.Log (Info, " size: " & Trim_Image (Bytes.Get.Value'Length) & " bytes"); Messages.Log (Info, " kind: " & Texture.Kind'Image); if Header.Compressed then Messages.Log (Info, " format: " & Texture.Compressed_Format'Image); else Messages.Log (Info, " format: " & Texture.Internal_Format'Image & " (" & Trim_Image (Integer (GL.Pixels.Extensions.Components (Header.Format))) & "x " & Header.Data_Type'Image & ")"); end if; Messages.Log (Info, " statistics:"); Messages.Log (Info, " creating header: " & Logging.Image (T2 - T1)); Messages.Log (Info, " retrieving data: " & Logging.Image (T3 - T2)); Messages.Log (Info, " writing file: " & Logging.Image (T4 - T3)); end; end Write_Texture; end Orka.Resources.Textures.KTX;
reznikmm/matreshka
Ada
4,001
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with ODF.DOM.Draw_Frame_Name_Attributes; package Matreshka.ODF_Draw.Frame_Name_Attributes is type Draw_Frame_Name_Attribute_Node is new Matreshka.ODF_Draw.Abstract_Draw_Attribute_Node and ODF.DOM.Draw_Frame_Name_Attributes.ODF_Draw_Frame_Name_Attribute with null record; overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Draw_Frame_Name_Attribute_Node; overriding function Get_Local_Name (Self : not null access constant Draw_Frame_Name_Attribute_Node) return League.Strings.Universal_String; end Matreshka.ODF_Draw.Frame_Name_Attributes;
reznikmm/matreshka
Ada
3,739
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with XML.DOM.Attributes; package ODF.DOM.Chart_Column_Mapping_Attributes is pragma Preelaborate; type ODF_Chart_Column_Mapping_Attribute is limited interface and XML.DOM.Attributes.DOM_Attribute; type ODF_Chart_Column_Mapping_Attribute_Access is access all ODF_Chart_Column_Mapping_Attribute'Class with Storage_Size => 0; end ODF.DOM.Chart_Column_Mapping_Attributes;
reznikmm/matreshka
Ada
3,749
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with XML.DOM.Attributes; package ODF.DOM.Form_Source_Cell_Range_Attributes is pragma Preelaborate; type ODF_Form_Source_Cell_Range_Attribute is limited interface and XML.DOM.Attributes.DOM_Attribute; type ODF_Form_Source_Cell_Range_Attribute_Access is access all ODF_Form_Source_Cell_Range_Attribute'Class with Storage_Size => 0; end ODF.DOM.Form_Source_Cell_Range_Attributes;
sf17k/sdlada
Ada
1,858
adb
-------------------------------------------------------------------------------------------------------------------- -- Copyright (c) 2014-2015 Luke A. Guest -- -- This software is provided 'as-is', without any express or implied -- warranty. In no event will the authors be held liable for any damages -- arising from the use of this software. -- -- Permission is granted to anyone to use this software for any purpose, -- including commercial applications, and to alter it and redistribute it -- freely, subject to the following restrictions: -- -- 1. The origin of this software must not be misrepresented; you must not -- claim that you wrote the original software. If you use this software -- in a product, an acknowledgment in the product documentation would be -- appreciated but is not required. -- -- 2. Altered source versions must be plainly marked as such, and must not be -- misrepresented as being the original software. -- -- 3. This notice may not be removed or altered from any source -- distribution. -------------------------------------------------------------------------------------------------------------------- with Interfaces.C; with Interfaces.C.Strings; package body SDL.Error is package C renames Interfaces.C; procedure Set (S : in String) is procedure SDL_Set_Error (C_Str : in C.char_array) with Import => True, Convention => C, External_Name => "SDL_SetError"; begin SDL_Set_Error (C.To_C (S)); end Set; function Get return String is function SDL_Get_Error return C.Strings.chars_ptr with Import => True, Convention => C, External_Name => "SDL_GetError"; C_Str : C.Strings.chars_ptr := SDL_Get_Error; begin return C.Strings.Value (C_Str); end Get; end SDL.Error;
reznikmm/matreshka
Ada
3,681
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Web Framework -- -- -- -- Tools Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2015, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with Asis; with Engines.Contexts; with League.Strings; package Properties.Expressions.Extension_Aggregate is function Code (Engine : access Engines.Contexts.Context; Element : Asis.Expression; Name : Engines.Text_Property) return League.Strings.Universal_String; end Properties.Expressions.Extension_Aggregate;
SietsevanderMolen/fly-thing
Ada
6,286
adb
with Ada.Numerics.Generic_Elementary_Functions; use Ada.Numerics; package body Generic_Vector_Math is package Float_Functions is new Generic_Elementary_Functions (Float); use Float_Functions; function Min (a, b : T) return T is begin if a < b then return a; else return b; end if; end Min; function Max (a, b : T) return T is begin if a >= b then return a; else return b; end if; end Max; function Min (a, b, c : T) return T is begin if a < b and a < c then return a; elsif b < c and b < a then return b; else return c; end if; end Min; function Max (a, b, c : T) return T is begin if a >= b and a >= c then return a; elsif b >= c and b >= a then return b; else return c; end if; end Max; function Clamp (x, a, b : T) return T is begin return Min (Max (x, a), b); end Clamp; function Sqr (x : T) return T is begin return x * x; end Sqr; function "+" (a, b : Vector4) return Vector4 is res : Vector4; begin res.x := a.x + b.x; res.y := a.y + b.y; res.z := a.z + b.z; res.w := a.w + b.w; return res; end "+"; function "+" (a, b : Vector3) return Vector3 is res : Vector3; begin res.x := a.x + b.x; res.y := a.y + b.y; res.z := a.z + b.z; return res; end "+"; function "-" (a, b : Vector3) return Vector3 is res : Vector3; begin res.x := a.x - b.x; res.y := a.y - b.y; res.z := a.z - b.z; return res; end "-"; function "*" (a, b : Vector3) return Vector3 is res : Vector3; begin res.x := a.x * b.x; res.y := a.y * b.y; res.z := a.z * b.z; return res; end "*"; function Dot (a, b : Vector3) return T is begin return a.x * b.x + a.y * b.y + a.z * b.z; end Dot; function Cross (a, b : Vector3) return Vector3 is res : Vector3; begin res.x := a.y * b.z - b.y * a.z; res.y := a.z * b.x - b.z * a.x; res.z := a.x * b.y - b.x * a.y; return res; end Cross; function Min (a, b : Vector3) return Vector3 is res : Vector3; begin res.x := Min (a.x, b.x); res.y := Min (a.y, b.y); res.z := Min (a.z, b.z); return res; end Min; function Max (a, b : Vector3) return Vector3 is begin return (Max (a.x, b.x), Max (a.y, b.y), Max (a.z, b.z)); end Max; function Clamp (x : Vector3; a, b : T) return Vector3 is begin return (Clamp (x.x, a, b), Clamp (x.y, a, b), Clamp (x.z, a, b)); end Clamp; function Clamp (x, a, b : Vector3) return Vector3 is begin return (Clamp (x.x, a.x, b.x), Clamp (x.y, a.y, b.y), Clamp (x.z, a.z, b.z)); end Clamp; function "*" (a : Vector3; k : T) return Vector3 is begin return (k * a.x, k * a.y, k * a.z); end "*"; function "*" (k : T; a : Vector3) return Vector3 is begin return (k * a.x, k * a.y, k * a.z); end "*"; function "*" (v : Vector3; m : Matrix4) return Vector3 is res : Vector3; begin res.x := v.x * m (0, 0) + v.y * m (1, 0) + v.z * m (2, 0) + m (3, 0); res.y := v.x * m (0, 1) + v.y * m (1, 1) + v.z * m (2, 1) + m (3, 1); res.z := v.x * m (0, 2) + v.y * m (1, 2) + v.z * m (2, 2) + m (3, 2); return res; end "*"; function "*" (v : Vector4; m : Matrix4) return Vector4 is res : Vector4; begin res.x := v.x * m (0, 0) + v.y * m (1, 0) + v.z * m (2, 0) + v.w * m (3, 0); res.y := v.x * m (0, 1) + v.y * m (1, 1) + v.z * m (2, 1) + v.w * m (3, 1); res.z := v.x * m (0, 2) + v.y * m (1, 2) + v.z * m (2, 2) + v.w * m (3, 2); res.w := v.x * m (0, 3) + v.y * m (1, 3) + v.z * m (2, 3) + v.w * m (3, 3); return res; end "*"; function "*" (m : Matrix4; v : Vector3) return Vector3 is res : Vector3; begin res.x := m (0, 0) * v.x + m (0, 1) * v.y + m (0, 2) * v.z + m (0, 3); res.y := m (1, 0) * v.x + m (1, 1) * v.y + m (1, 2) * v.z + m (1, 3); res.z := m (2, 0) * v.x + m (2, 1) * v.y + m (2, 2) * v.z + m (2, 3); return res; end "*"; function "*" (m : Matrix4; v : Vector4) return Vector4 is res : Vector4; begin res.x := m (0, 0) * v.x + m (0, 1) * v.y + m (0, 2) * v.z + m (0, 3) * v.w; res.y := m (1, 0) * v.x + m (1, 1) * v.y + m (1, 2) * v.z + m (1, 3) * v.w; res.z := m (2, 0) * v.x + m (2, 1) * v.y + m (2, 2) * v.z + m (2, 3) * v.w; res.w := m (3, 0) * v.x + m (3, 1) * v.y + m (3, 2) * v.z + m (3, 3) * v.w; return res; end "*"; function GetRow (m : Matrix4; i : Integer) return Vector4 is res : Vector4; begin res.x := m (i, 0); res.y := m (i, 1); res.z := m (i, 2); res.w := m (i, 3); return res; end GetRow; function GetCol (m : Matrix4; i : Integer) return Vector4 is res : Vector4; begin res.x := m (0, i); res.y := m (1, i); res.z := m (2, i); res.w := m (3, i); return res; end GetCol; procedure SetRow (m : in out Matrix4; i : in Integer; v : in Vector4) is begin m (i, 0) := v.x; m (i, 1) := v.y; m (i, 2) := v.z; m (i, 3) := v.w; end SetRow; procedure SetCol (m : in out Matrix4; i : in Integer; v : in Vector4) is begin m (0, i) := v.x; m (1, i) := v.y; m (2, i) := v.z; m (3, i) := v.w; end SetCol; function "*" (m1 : Matrix4; m2 : Matrix4) return Matrix4 is m : Matrix4; row : Vector4; begin for i in 0 .. 3 loop row := m1 * GetCol (m2, i); SetRow (m, i, row); end loop; return m; end "*"; end Generic_Vector_Math;
Componolit/libsparkcrypto
Ada
13,836
adb
------------------------------------------------------------------------------- -- This file is part of libsparkcrypto. -- -- Copyright (C) 2012, Stefan Berghofer -- Copyright (C) 2012, secunet Security Networks AG -- All rights reserved. -- -- Redistribution and use in source and binary forms, with or without -- modification, are permitted provided that the following conditions are met: -- -- * Redistributions of source code must retain the above copyright notice, -- this list of conditions and the following disclaimer. -- -- * Redistributions in binary form must reproduce the above copyright -- notice, this list of conditions and the following disclaimer in the -- documentation and/or other materials provided with the distribution. -- -- * Neither the name of the author nor the names of its contributors may be -- used to endorse or promote products derived from this software without -- specific prior written permission. -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS -- BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -- POSSIBILITY OF SUCH DAMAGE. ------------------------------------------------------------------------------- package body LSC.Internal.EC_Signature is pragma Warnings (Off, """V"" may be referenced before it has a value"); procedure Extract (X : in Bignum.Big_Int; X_First : in Natural; X_Last : in Natural; Z : in Bignum.Big_Int; Z_First : in Natural; V : out Bignum.Big_Int; V_First : in Natural; M : in Bignum.Big_Int; M_First : in Natural; M_Inv : in Types.Word32; RM : in Bignum.Big_Int; RM_First : in Natural; N : in Bignum.Big_Int; N_First : in Natural; N_Inv : in Types.Word32; RN : in Bignum.Big_Int; RN_First : in Natural) with Depends => (V =>+ (V_First, X, X_First, X_Last, Z, Z_First, M, M_First, M_Inv, RM, RM_First, N, N_First, N_Inv, RN, RN_First)), Pre => X_First in X'Range and then X_Last in X'Range and then X_First < X_Last and then X_Last - X_First < EC.Max_Coord_Length and then Z_First in Z'Range and then Z_First + (X_Last - X_First) in Z'Range and then V_First in V'Range and then V_First + (X_Last - X_First) in V'Range and then M_First in M'Range and then M_First + (X_Last - X_First) in M'Range and then RM_First in RM'Range and then RM_First + (X_Last - X_First) in RM'Range and then N_First in N'Range and then N_First + (X_Last - X_First) in N'Range and then RN_First in RN'Range and then RN_First + (X_Last - X_First) in RN'Range and then Bignum.Num_Of_Big_Int (X, X_First, X_Last - X_First + 1) < Bignum.Num_Of_Big_Int (M, M_First, X_Last - X_First + 1) and then Bignum.Num_Of_Big_Int (Z, Z_First, X_Last - X_First + 1) < Bignum.Num_Of_Big_Int (M, M_First, X_Last - X_First + 1) and then Math_Int.From_Word32 (1) < Bignum.Num_Of_Big_Int (M, M_First, X_Last - X_First + 1) and then 1 + M_Inv * M (M_First) = 0 and then Math_Int.From_Word32 (1) < Bignum.Num_Of_Big_Int (N, N_First, X_Last - X_First + 1) and then 1 + N_Inv * N (N_First) = 0 and then Bignum.Num_Of_Big_Int (RM, RM_First, X_Last - X_First + 1) = Bignum.Base ** (Math_Int.From_Integer (2) * Math_Int.From_Integer (X_Last - X_First + 1)) mod Bignum.Num_Of_Big_Int (M, M_First, X_Last - X_First + 1) and then Bignum.Num_Of_Big_Int (RN, RN_First, X_Last - X_First + 1) = Bignum.Base ** (Math_Int.From_Integer (2) * Math_Int.From_Integer (X_Last - X_First + 1)) mod Bignum.Num_Of_Big_Int (N, N_First, X_Last - X_First + 1), Post => Bignum.Num_Of_Big_Int (V, V_First, X_Last - X_First + 1) < Bignum.Num_Of_Big_Int (N, N_First, X_Last - X_First + 1); procedure Extract (X : in Bignum.Big_Int; X_First : in Natural; X_Last : in Natural; Z : in Bignum.Big_Int; Z_First : in Natural; V : out Bignum.Big_Int; V_First : in Natural; M : in Bignum.Big_Int; M_First : in Natural; M_Inv : in Types.Word32; RM : in Bignum.Big_Int; RM_First : in Natural; N : in Bignum.Big_Int; N_First : in Natural; N_Inv : in Types.Word32; RN : in Bignum.Big_Int; RN_First : in Natural) is L : Natural; H : EC.Coord; begin L := X_Last - X_First; EC.Invert (Z, Z_First, Z_First + L, H, H'First, RM, RM_First, M, M_First, M_Inv); Bignum.Mont_Mult (V, V_First, V_First + L, X, X_First, H, H'First, M, M_First, M_Inv); Bignum.Mont_Mult (H, H'First, H'First + L, V, V_First, EC.One, EC.One'First, N, N_First, N_Inv); Bignum.Mont_Mult (V, V_First, V_First + L, H, H'First, RN, RN_First, N, N_First, N_Inv); end Extract; pragma Warnings (On, """V"" may be referenced before it has a value"); ---------------------------------------------------------------------------- procedure Sign (Sign1 : out Bignum.Big_Int; Sign1_First : in Natural; Sign1_Last : in Natural; Sign2 : out Bignum.Big_Int; Sign2_First : in Natural; Hash : in Bignum.Big_Int; Hash_First : in Natural; Rand : in Bignum.Big_Int; Rand_First : in Natural; T : in Signature_Type; Priv : in Bignum.Big_Int; Priv_First : in Natural; BX : in Bignum.Big_Int; BX_First : in Natural; BY : in Bignum.Big_Int; BY_First : in Natural; A : in Bignum.Big_Int; A_First : in Natural; M : in Bignum.Big_Int; M_First : in Natural; M_Inv : in Types.Word32; RM : in Bignum.Big_Int; RM_First : in Natural; N : in Bignum.Big_Int; N_First : in Natural; N_Inv : in Types.Word32; RN : in Bignum.Big_Int; RN_First : in Natural; Success : out Boolean) is L : Natural; X, Y, Z, PrivR, H1, H2, H3 : EC.Coord; begin L := Sign1_Last - Sign1_First; Bignum.Mont_Mult (H1, H1'First, H1'First + L, Hash, Hash_First, EC.One, EC.One'First, N, N_First, N_Inv); Bignum.Mont_Mult (H3, H3'First, H3'First + L, H1, H1'First, RN, RN_First, N, N_First, N_Inv); pragma Warnings (Off, "unused assignment to ""Y"""); EC.Point_Mult (X1 => BX, X1_First => BX_First, X1_Last => BX_First + L, Y1 => BY, Y1_First => BY_First, Z1 => EC.One, Z1_First => EC.One'First, E => Rand, E_First => Rand_First, E_Last => Rand_First + L, X2 => X, X2_First => X'First, Y2 => Y, Y2_First => Y'First, Z2 => Z, Z2_First => Z'First, A => A, A_First => A_First, M => M, M_First => M_First, M_Inv => M_Inv); pragma Warnings (On, "unused assignment to ""Y"""); Extract (X, X'First, X'First + L, Z, Z'First, Sign1, Sign1_First, M, M_First, M_Inv, RM, RM_First, N, N_First, N_Inv, RN, RN_First); Bignum.Mont_Mult (PrivR, PrivR'First, PrivR'First + L, Priv, Priv_First, RN, RN_First, N, N_First, N_Inv); case T is when ECDSA => Bignum.Mont_Mult (H1, H1'First, H1'First + L, PrivR, PrivR'First, Sign1, Sign1_First, N, N_First, N_Inv); Bignum.Mod_Add_Inplace (H1, H1'First, H1'First + L, H3, H3'First, N, N_First); EC.Invert (Rand, Rand_First, Rand_First + L, H2, H2'First, RN, RN_First, N, N_First, N_Inv); Bignum.Mont_Mult (Sign2, Sign2_First, Sign2_First + L, H1, H1'First, H2, H2'First, N, N_First, N_Inv); when ECGDSA => Bignum.Mont_Mult (H1, H1'First, H1'First + L, Rand, Rand_First, RN, RN_First, N, N_First, N_Inv); Bignum.Mont_Mult (H2, H2'First, H2'First + L, H1, H1'First, Sign1, Sign1_First, N, N_First, N_Inv); Bignum.Mod_Sub_Inplace (H2, H2'First, H2'First + L, H3, H3'First, N, N_First); Bignum.Mont_Mult (Sign2, Sign2_First, Sign2_First + L, H2, H2'First, PrivR, PrivR'First, N, N_First, N_Inv); end case; Success := not Bignum.Is_Zero (Sign1, Sign1_First, Sign1_Last) and then not Bignum.Is_Zero (Sign2, Sign2_First, Sign2_First + L); end Sign; ---------------------------------------------------------------------------- function Verify (Sign1 : Bignum.Big_Int; Sign1_First : Natural; Sign1_Last : Natural; Sign2 : Bignum.Big_Int; Sign2_First : Natural; Hash : Bignum.Big_Int; Hash_First : Natural; T : Signature_Type; PubX : Bignum.Big_Int; PubX_First : Natural; PubY : Bignum.Big_Int; PubY_First : Natural; BX : Bignum.Big_Int; BX_First : Natural; BY : Bignum.Big_Int; BY_First : Natural; A : Bignum.Big_Int; A_First : Natural; M : Bignum.Big_Int; M_First : Natural; M_Inv : Types.Word32; RM : Bignum.Big_Int; RM_First : Natural; N : Bignum.Big_Int; N_First : Natural; N_Inv : Types.Word32; RN : Bignum.Big_Int; RN_First : Natural) return Boolean is L : Natural; Result : Boolean; H1, H2, H, X, Y, Z, V : EC.Coord; begin L := Sign1_Last - Sign1_First; if not Bignum.Is_Zero (Sign1, Sign1_First, Sign1_Last) and then Bignum.Less (Sign1, Sign1_First, Sign1_Last, N, N_First) and then not Bignum.Is_Zero (Sign2, Sign2_First, Sign2_First + L) and then Bignum.Less (Sign2, Sign2_First, Sign2_First + L, N, N_First) then case T is when ECDSA => EC.Invert (Sign2, Sign2_First, Sign2_First + L, H, H'First, RN, RN_First, N, N_First, N_Inv); Bignum.Mont_Mult (H2, H2'First, H2'First + L, Sign1, Sign1_First, H, H'First, N, N_First, N_Inv); when ECGDSA => EC.Invert (Sign1, Sign1_First, Sign1_Last, H, H'First, RN, RN_First, N, N_First, N_Inv); Bignum.Mont_Mult (H2, H2'First, H2'First + L, Sign2, Sign2_First, H, H'First, N, N_First, N_Inv); end case; Bignum.Mont_Mult (H1, H1'First, H1'First + L, Hash, Hash_First, H, H'First, N, N_First, N_Inv); pragma Warnings (Off, "unused assignment to ""Y"""); EC.Two_Point_Mult (X1 => BX, X1_First => BX_First, X1_Last => BX_First + L, Y1 => BY, Y1_First => BY_First, Z1 => EC.One, Z1_First => EC.One'First, E1 => H1, E1_First => H1'First, E1_Last => H1'First + L, X2 => PubX, X2_First => PubX_First, Y2 => PubY, Y2_First => PubY_First, Z2 => EC.One, Z2_First => EC.One'First, E2 => H2, E2_First => H2'First, X3 => X, X3_First => X'First, Y3 => Y, Y3_First => Y'First, Z3 => Z, Z3_First => Z'First, A => A, A_First => A_First, M => M, M_First => M_First, M_Inv => M_Inv); pragma Warnings (On, "unused assignment to ""Y"""); Extract (X, X'First, X'First + L, Z, Z'First, V, V'First, M, M_First, M_Inv, RM, RM_First, N, N_First, N_Inv, RN, RN_First); Result := Bignum.Equal (Sign1, Sign1_First, Sign1_Last, V, V'First); else Result := False; end if; return Result; end Verify; end LSC.Internal.EC_Signature;
reznikmm/matreshka
Ada
3,729
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with XML.DOM.Elements; package ODF.DOM.Table_Table_Header_Columns_Elements is pragma Preelaborate; type ODF_Table_Table_Header_Columns is limited interface and XML.DOM.Elements.DOM_Element; type ODF_Table_Table_Header_Columns_Access is access all ODF_Table_Table_Header_Columns'Class with Storage_Size => 0; end ODF.DOM.Table_Table_Header_Columns_Elements;
sungyeon/drake
Ada
23,221
adb
with Ada.Exception_Identification.From_Here; package body Ada.Hierarchical_File_Names is use Exception_Identification.From_Here; function Parent_Directory_Name ( Level : Positive; Path_Delimiter : Character) return String; function Parent_Directory_Name ( Level : Positive; Path_Delimiter : Character) return String is begin return Result : String (1 .. 3 * Level - 1) do Result (1) := '.'; Result (2) := '.'; for I in 2 .. Level loop Result (I * 3 - 3) := Path_Delimiter; Result (I * 3 - 2) := '.'; Result (I * 3 - 1) := '.'; end loop; end return; end Parent_Directory_Name; function Current_Directory_Name return String is ("."); procedure Containing_Root_Directory (Name : String; Last : out Natural); procedure Containing_Root_Directory (Name : String; Last : out Natural) is begin if Name'First > Name'Last then Last := Name'First - 1; elsif Is_Path_Delimiter (Name (Name'First)) then if Name'First < Name'Last and then Is_Path_Delimiter (Name (Name'First + 1)) then -- UNC \\HOST\SHARE\ Last := Name'First + 1; if Last < Name'Last then loop -- skip host-name Last := Last + 1; exit when Last = Name'Last; if Is_Path_Delimiter (Name (Last)) then loop -- skip share-name Last := Last + 1; exit when Last = Name'Last; exit when Is_Path_Delimiter (Name (Last)); end loop; exit; end if; end loop; end if; else Last := Name'First; -- no drive letter end if; elsif Name'First < Name'Last and then ( Name (Name'First) in 'A' .. 'Z' or else Name (Name'First) in 'a' .. 'z') and then Name (Name'First + 1) = ':' then if Name'First + 2 <= Name'Last and then Is_Path_Delimiter (Name (Name'First + 2)) then Last := Name'First + 2; -- "C:\" else Last := Name'First + 1; -- "C:" end if; else Last := Name'First - 1; -- relative end if; end Containing_Root_Directory; procedure Raw_Simple_Name (Name : String; First : out Positive); procedure Raw_Simple_Name (Name : String; First : out Positive) is begin First := Name'First; for I in reverse Name'Range loop if Is_Path_Delimiter (Name (I)) then First := I + 1; exit; -- found end if; end loop; end Raw_Simple_Name; procedure Exclude_Trailing_Directories ( Directory : String; Last : in out Natural; Level : in out Natural); procedure Exclude_Trailing_Directories ( Directory : String; Last : in out Natural; Level : in out Natural) is Root_Last : Natural; begin Exclude_Trailing_Path_Delimiter (Directory, Last); Containing_Root_Directory ( Directory (Directory'First .. Last), Last => Root_Last); -- First - 1 if not Is_Full_Name (...) while Last > Root_Last loop declare S_First : Positive; begin Raw_Simple_Name ( Directory (Root_Last + 1 .. Last), First => S_First); if Is_Current_Directory_Name (Directory (S_First .. Last)) then null; -- skip "./" elsif Is_Parent_Directory_Name (Directory (S_First .. Last)) then Level := Level + 1; elsif Level = 0 then exit; else Level := Level - 1; end if; -- Containing_Directory (Directory (First .. Last), ...) Last := S_First - 1; Exclude_Trailing_Path_Delimiter (Directory, Last); end; end loop; end Exclude_Trailing_Directories; -- path delimiter function Is_Path_Delimiter (Item : Character) return Boolean is begin return Item = '\' or else Item = '/'; end Is_Path_Delimiter; procedure Include_Trailing_Path_Delimiter ( S : in out String; Last : in out Natural; Path_Delimiter : Path_Delimiter_Type := Default_Path_Delimiter) is begin if not Is_Path_Delimiter (S (Last)) then Last := Last + 1; S (Last) := Path_Delimiter; end if; end Include_Trailing_Path_Delimiter; procedure Exclude_Trailing_Path_Delimiter ( S : String; Last : in out Natural) is begin while Last > S'First -- no removing root path delimiter and then Is_Path_Delimiter (S (Last)) loop Last := Last - 1; end loop; end Exclude_Trailing_Path_Delimiter; -- operations in Ada.Directories function Simple_Name (Name : String) return String is First : Positive; Last : Natural; begin Simple_Name (Name, First => First, Last => Last); if First > Last then Raise_Exception (Name_Error'Identity); -- CXAG002 end if; return Name (First .. Last); end Simple_Name; function Unchecked_Simple_Name (Name : String) return String is First : Positive; Last : Natural; begin Simple_Name (Name, First => First, Last => Last); return Name (First .. Last); end Unchecked_Simple_Name; function Containing_Directory (Name : String) return String is First : Positive; Last : Natural; Error : Boolean; begin Containing_Directory (Name, First => First, Last => Last); Error := First > Last; if not Error then -- ignore trailing delimiters on error-checking Error := True; for I in reverse Last + 1 .. Name'Last loop if not Is_Path_Delimiter (Name (I)) then Error := False; exit; end if; end loop; end if; if Error then Raise_Exception (Use_Error'Identity); -- RM A.16.1(38/3) end if; return Name (First .. Last); end Containing_Directory; function Unchecked_Containing_Directory (Name : String) return String is First : Positive; Last : Natural; begin Containing_Directory (Name, First => First, Last => Last); return Name (First .. Last); end Unchecked_Containing_Directory; function Extension (Name : String) return String is First : Positive; Last : Natural; begin Extension (Name, First => First, Last => Last); return Name (First .. Last); end Extension; function Base_Name (Name : String) return String is First : Positive; Last : Natural; begin Base_Name (Name, First => First, Last => Last); return Name (First .. Last); end Base_Name; procedure Simple_Name ( Name : String; First : out Positive; Last : out Natural) is Root_Last : Natural; begin Containing_Root_Directory (Name, Last => Root_Last); Raw_Simple_Name (Name (Root_Last + 1 .. Name'Last), First => First); Last := Name'Last; end Simple_Name; procedure Containing_Directory ( Name : String; First : out Positive; Last : out Natural) is Root_Last : Natural; begin Containing_Root_Directory (Name, Last => Root_Last); First := Name'First; Last := Root_Last; for I in reverse Last + 1 .. Name'Last loop if Is_Path_Delimiter (Name (I)) then if I > First then Last := I - 1; else Last := I; -- no removing root path delimiter end if; exit; -- found end if; end loop; end Containing_Directory; procedure Extension ( Name : String; First : out Positive; Last : out Natural) is Root_Last : Natural; begin Containing_Root_Directory (Name, Last => Root_Last); First := Name'Last + 1; Last := Name'Last; for I in reverse Root_Last + 2 .. -- >= Name'First + 1 Last loop if Is_Path_Delimiter (Name (I)) then exit; -- not found elsif Name (I) = '.' then -- Extension (".DOTFILE") = "" if not Is_Path_Delimiter (Name (I - 1)) then First := I + 1; end if; exit; -- found end if; end loop; end Extension; procedure Base_Name ( Name : String; First : out Positive; Last : out Natural) is begin Simple_Name (Name, First => First, Last => Last); if First > Last or else Name (Last) /= '.' then -- AA-A-16 79.a/2 for I in reverse First .. Last - 1 loop if Name (I) = '.' then -- Base_Name (".DOTFILE") = ".DOTFILE" if I > First then Last := I - 1; end if; exit; end if; end loop; end if; end Base_Name; -- operations in Ada.Directories.Hierarchical_File_Names function Is_Simple_Name (Name : String) return Boolean is begin for I in Name'Range loop if Is_Path_Delimiter (Name (I)) then return False; end if; end loop; return True; end Is_Simple_Name; function Is_Root_Directory_Name (Name : String) return Boolean is Last : Natural; begin Containing_Root_Directory (Name, Last => Last); return Name'First <= Last and then Last = Name'Last; end Is_Root_Directory_Name; function Is_Parent_Directory_Name (Name : String) return Boolean is begin return Name = ".."; end Is_Parent_Directory_Name; function Is_Current_Directory_Name (Name : String) return Boolean is begin return Name = "."; end Is_Current_Directory_Name; function Is_Full_Name (Name : String) return Boolean is Last : Natural; begin Containing_Root_Directory (Name, Last => Last); return Name'First <= Last; end Is_Full_Name; function Is_Relative_Name (Name : String) return Boolean is begin return not Is_Full_Name (Name); end Is_Relative_Name; function Initial_Directory (Name : String) return String is First : Positive; Last : Natural; begin Initial_Directory (Name, First => First, Last => Last); return Name (First .. Last); end Initial_Directory; function Relative_Name (Name : String) return String is First : Positive; Last : Natural; begin Relative_Name (Name, First => First, Last => Last); if First > Last then Raise_Exception (Name_Error'Identity); -- CXAG002 end if; return Name (First .. Last); end Relative_Name; function Unchecked_Relative_Name (Name : String) return String is First : Positive; Last : Natural; begin Relative_Name (Name, First => First, Last => Last); return Name (First .. Last); end Unchecked_Relative_Name; procedure Initial_Directory ( Name : String; First : out Positive; Last : out Natural) is begin Containing_Root_Directory (Name, Last => Last); First := Name'First; if First > Last then -- relative Last := Name'Last; for I in Name'Range loop if Is_Path_Delimiter (Name (I)) then Last := I - 1; exit; -- found end if; end loop; end if; end Initial_Directory; procedure Relative_Name ( Name : String; First : out Positive; Last : out Natural) is Root_Last : Natural; begin Containing_Root_Directory (Name, Last => Root_Last); Last := Name'Last; if Name'First <= Root_Last then -- full First := Root_Last + 1; -- skip root else -- relative First := Name'Last + 1; for I in Name'Range loop if Is_Path_Delimiter (Name (I)) then First := I + 1; exit; -- found end if; end loop; end if; end Relative_Name; function Compose ( Directory : String := ""; Relative_Name : String; Extension : String := ""; Path_Delimiter : Path_Delimiter_Type := Default_Path_Delimiter) return String is pragma Check (Pre, Check => Directory'Length = 0 or else Is_Relative_Name (Relative_Name) or else raise Name_Error); -- CXAG002 Directory_Length : constant Natural := Directory'Length; Relative_Name_Length : constant Natural := Relative_Name'Length; Extension_Length : constant Natural := Extension'Length; Result : String ( 1 .. Directory_Length + Relative_Name_Length + Extension_Length + 2); Last : Natural; begin -- append directory Last := Directory_Length; if Last > 0 then Result (1 .. Last) := Directory; Include_Trailing_Path_Delimiter ( Result, Last => Last, Path_Delimiter => Path_Delimiter); end if; -- append name Result (Last + 1 .. Last + Relative_Name_Length) := Relative_Name; Last := Last + Relative_Name_Length; -- append extension if Extension_Length /= 0 then Last := Last + 1; Result (Last) := '.'; Result (Last + 1 .. Last + Extension_Length) := Extension; Last := Last + Extension_Length; end if; return Result (1 .. Last); end Compose; function Normalized_Compose ( Directory : String := ""; Relative_Name : String; Extension : String := ""; Path_Delimiter : Path_Delimiter_Type := Default_Path_Delimiter) return String is Parent_Count : Natural := 0; C_D_Last : Natural; -- Containing_Directory (Directory) R_R_First : Positive; -- Relative_Name (Relative_Name) R_R_Last : Natural; begin R_R_First := Relative_Name'First; R_R_Last := Relative_Name'Last; while R_R_First <= R_R_Last loop declare I_R_First : Positive; -- Initial_Directory (Relative_Name) I_R_Last : Natural; begin Initial_Directory ( Relative_Name (R_R_First .. R_R_Last), First => I_R_First, Last => I_R_Last); if Is_Current_Directory_Name ( Relative_Name (I_R_First .. I_R_Last)) then Hierarchical_File_Names.Relative_Name ( Relative_Name (R_R_First .. R_R_Last), First => R_R_First, Last => R_R_Last); elsif Is_Parent_Directory_Name ( Relative_Name (I_R_First .. I_R_Last)) then Parent_Count := Parent_Count + 1; Hierarchical_File_Names.Relative_Name ( Relative_Name (R_R_First .. R_R_Last), First => R_R_First, Last => R_R_Last); else exit; end if; end; end loop; C_D_Last := Directory'Last; Exclude_Trailing_Directories ( Directory, Last => C_D_Last, Level => Parent_Count); if Parent_Count > 0 then return Compose ( Compose ( Directory (Directory'First .. C_D_Last), Parent_Directory_Name ( Parent_Count, Path_Delimiter => Path_Delimiter), Path_Delimiter => Path_Delimiter), Relative_Name (R_R_First .. R_R_Last), Extension, Path_Delimiter => Path_Delimiter); elsif Directory'First > C_D_Last and then R_R_First > R_R_Last and then (Directory'Length > 0 or else Relative_Name'Length > 0) and then Extension'Length = 0 then return Current_Directory_Name; else return Compose ( Directory (Directory'First .. C_D_Last), Relative_Name (R_R_First .. R_R_Last), Extension, Path_Delimiter => Path_Delimiter); end if; end Normalized_Compose; function Relative_Name ( Name : String; From : String; Path_Delimiter : Path_Delimiter_Type := Default_Path_Delimiter) return String is R_N_First : Positive := Name'First; R_N_Last : Natural := Name'Last; Parent_Count : Natural := 0; begin Relative_Name ( Name => Name, First => R_N_First, Last => R_N_Last, From => From, Parent_Count => Parent_Count); if Parent_Count > 0 then if R_N_First > R_N_Last then return Parent_Directory_Name ( Parent_Count, Path_Delimiter => Path_Delimiter); else return Compose ( Parent_Directory_Name ( Parent_Count, Path_Delimiter => Path_Delimiter), Name (R_N_First .. R_N_Last), Path_Delimiter => Path_Delimiter); end if; elsif R_N_First > R_N_Last then return Current_Directory_Name; else return Name (R_N_First .. R_N_Last); end if; end Relative_Name; procedure Relative_Name ( Name : String; First : out Positive; Last : out Natural; From : String; Parent_Count : out Natural) is Name_Root_Last : Natural; From_Root_Last : Natural; begin Containing_Root_Directory (Name, Last => Name_Root_Last); Containing_Root_Directory (From, Last => From_Root_Last); if (Name'First <= Name_Root_Last) /= (From'First <= From_Root_Last) then -- Relative_Name ("A", "/B") or reverse Raise_Exception (Use_Error'Identity); elsif Name'First <= Name_Root_Last and then Name (Name'First .. Name_Root_Last) /= From (From'First .. From_Root_Last) then -- full names and different drive letters First := Name'First; Last := Name'Last; Parent_Count := 0; else First := Name'First; Last := Name'Last; Parent_Count := 0; declare R_F_First : Positive := From'First; R_F_Last : Natural := From'Last; begin -- remove same part while First <= Last and then R_F_First <= R_F_Last loop declare I_N_First : Positive; -- Initial_Directory (Name) I_N_Last : Natural; I_F_First : Positive; -- Initial_Directory (From) I_F_Last : Natural; begin Initial_Directory ( Name (First .. Last), First => I_N_First, Last => I_N_Last); Initial_Directory ( From (R_F_First .. R_F_Last), First => I_F_First, Last => I_F_Last); if Name (I_N_First .. I_N_Last) = From (I_F_First .. I_F_Last) then Relative_Name ( Name (First .. Last), First => First, Last => Last); Relative_Name ( From (R_F_First .. R_F_Last), First => R_F_First, Last => R_F_Last); else exit; end if; end; end loop; -- strip "./" in remainder of Name while First <= Last loop declare I_N_First : Positive; -- Initial_Directory (Name) I_N_Last : Natural; begin Initial_Directory ( Name (First .. Last), First => I_N_First, Last => I_N_Last); exit when not Is_Current_Directory_Name ( Name (I_N_First .. I_N_Last)); Relative_Name ( Name (First .. Last), First => First, Last => Last); end; end loop; -- remainder of From while R_F_First <= R_F_Last loop declare I_F_First : Positive; -- Initial_Directory (From) I_F_Last : Natural; begin Initial_Directory ( From (R_F_First .. R_F_Last), First => I_F_First, Last => I_F_Last); if Is_Current_Directory_Name ( From (I_F_First .. I_F_Last)) then null; -- skip "./" of From elsif Is_Parent_Directory_Name ( From (I_F_First .. I_F_Last)) then if Parent_Count > 0 then Parent_Count := Parent_Count - 1; else -- Relative_Name ("A", "..") Raise_Exception (Use_Error'Identity); end if; else Parent_Count := Parent_Count + 1; end if; Relative_Name ( From (R_F_First .. R_F_Last), First => R_F_First, Last => R_F_Last); end; end loop; end; end if; end Relative_Name; function Parent_Directory ( Directory : String; Path_Delimiter : Path_Delimiter_Type := Default_Path_Delimiter) return String is First : Positive; Last : Natural; Parent_Count : Natural; begin Parent_Directory ( Directory, First => First, Last => Last, Parent_Count => Parent_Count); if Parent_Count > 0 then if First <= Last then -- Parent_Directory ("/") -- raise Use_Error ? return Compose ( Directory (First .. Last), Parent_Directory_Name ( Parent_Count, Path_Delimiter => Path_Delimiter), Path_Delimiter => Path_Delimiter); else return Parent_Directory_Name ( Parent_Count, Path_Delimiter => Path_Delimiter); end if; elsif First > Last then return Current_Directory_Name; else return Directory (First .. Last); end if; end Parent_Directory; procedure Parent_Directory ( Directory : String; First : out Positive; Last : out Natural; Parent_Count : out Natural) is begin First := Directory'First; Last := Directory'Last; Parent_Count := 1; Exclude_Trailing_Directories ( Directory, Last => Last, Level => Parent_Count); end Parent_Directory; end Ada.Hierarchical_File_Names;
reznikmm/matreshka
Ada
2,333
adb
with Ada.Wide_Wide_Text_IO; with League.Strings; with SQL.Databases; with SQL.Options; with Matreshka.Internals.SQL_Drivers.PostgreSQL.Factory; with OPM.Stores; with AWFC.Accounts.Users.Stores; with Forum.Categories.References; with Forum.Categories.Objects.Stores; with Forum.Forums; with Forum.Topics.References; with Forum.Topics.Objects.Stores; with Forum.Posts.References; procedure Tst is O : SQL.Options.SQL_Options; F : Forum.Forums.Forum; Aux : OPM.Stores.Store_Access; begin O.Set (League.Strings.To_Universal_String ("dbname"), League.Strings.To_Universal_String ("forum")); F.Initialize (League.Strings.To_Universal_String ("POSTGRESQL"), O); Aux := new AWFC.Accounts.Users.Stores.User_Store (F.Engine'Unchecked_Access); Aux.Initialize; declare User_Store : AWFC.Accounts.Users.Stores.User_Store'Class renames AWFC.Accounts.Users.Stores.User_Store'Class (F.Engine.Get_Store (AWFC.Accounts.Users.User'Tag).all); U : constant AWFC.Accounts.Users.User_Access := User_Store.Get_Anonymous_User; C : constant Forum.Categories.References.Category := F.Create_Category (League.Strings.To_Universal_String ("категория"), League.Strings.To_Universal_String ("пробная категория для тестирования")); T : constant Forum.Topics.References.Topic := F.Create_Topic (U, C, League.Strings.To_Universal_String ("тема 1"), League.Strings.To_Universal_String ("пробная тема для тестирования")); P : Forum.Posts.References.Post := F.Create_Post (U, T, League.Strings.To_Universal_String ("ТекСт В пробной теме тестированИя 1")); begin null; end; for C of F.Get_Categories loop Ada.Wide_Wide_Text_IO.Put_Line (C.Object.Get_Title.To_Wide_Wide_String); Ada.Wide_Wide_Text_IO.Put_Line (C.Object.Get_Description.To_Wide_Wide_String); end loop; -- ST.Initialize (D'Unchecked_Access); -- T.Initialize (ST'Unchecked_Access, 1); -- -- Ada.Wide_Wide_Text_IO.Put_Line (T.Object.Get_Title.To_Wide_Wide_String); end Tst;
reznikmm/matreshka
Ada
3,661
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2013, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with XML.DOM.Elements; package ODF.DOM.Elements.Office.Document_Content is type ODF_Office_Document_Content is new XML.DOM.Elements.DOM_Element with private; private type ODF_Office_Document_Content is new XML.DOM.Elements.DOM_Element with null record; end ODF.DOM.Elements.Office.Document_Content;
reznikmm/matreshka
Ada
3,694
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with XML.DOM.Attributes; package ODF.DOM.Db_Encoding_Attributes is pragma Preelaborate; type ODF_Db_Encoding_Attribute is limited interface and XML.DOM.Attributes.DOM_Attribute; type ODF_Db_Encoding_Attribute_Access is access all ODF_Db_Encoding_Attribute'Class with Storage_Size => 0; end ODF.DOM.Db_Encoding_Attributes;
AdaCore/Ada_Drivers_Library
Ada
4,267
ads
------------------------------------------------------------------------------ -- -- -- Copyright (C) 2015-2016, AdaCore -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions are -- -- met: -- -- 1. Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- 2. Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in -- -- the documentation and/or other materials provided with the -- -- distribution. -- -- 3. Neither the name of the copyright holder nor the names of its -- -- contributors may be used to endorse or promote products derived -- -- from this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -- -- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -- -- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -- -- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -- -- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ with HAL; use HAL; with HAL.Block_Drivers; use HAL.Block_Drivers; package Partitions is type Partition_Kind is new UInt8; Empty_Partition : constant Partition_Kind := 16#00#; Fat12_Parition : constant Partition_Kind := 16#01#; Fat16_Parition : constant Partition_Kind := 16#04#; Extended_Parition : constant Partition_Kind := 16#05#; Fat16B_Parition : constant Partition_Kind := 16#06#; NTFS_Partition : constant Partition_Kind := 16#07#; Fat32_CHS_Parition : constant Partition_Kind := 16#0B#; Fat32_LBA_Parition : constant Partition_Kind := 16#0C#; Fat16B_LBA_Parition : constant Partition_Kind := 16#0E#; Extended_LBA_Parition : constant Partition_Kind := 16#0F#; Linux_Swap_Partition : constant Partition_Kind := 16#82#; Linux_Partition : constant Partition_Kind := 16#83#; subtype Logical_Block_Address is UInt32; type CHS_Address is record C : UInt10; H : UInt8; S : UInt6; end record with Pack, Size => 24; type Partition_Entry is record Status : UInt8; First_Sector_CHS : CHS_Address; Kind : Partition_Kind; Last_Sector_CHS : CHS_Address; First_Sector_LBA : Logical_Block_Address; Number_Of_Sectors : UInt32; end record with Pack, Size => 16 * 8; type Status_Code is (Status_Ok, Disk_Error, Invalid_Parition); function Get_Partition_Entry (Disk : not null Any_Block_Driver; Entry_Number : Positive; P_Entry : out Partition_Entry) return Status_Code; function Number_Of_Partitions (Disk : Any_Block_Driver) return Natural; function Is_Valid (P_Entry : Partition_Entry) return Boolean is (P_Entry.Status = 16#00# or else P_Entry.Status = 16#80#); end Partitions;
AdaCore/gpr
Ada
61
adb
package body Pkg1 is procedure Sep is separate; end Pkg1;
egustafson/sandbox
Ada
2,275
adb
with Generic_AVL_Tree, Ada.Numerics.Discrete_Random; with Ada.Text_IO, Ada.Integer_Text_IO, Ada.Command_Line; use Ada.Text_IO, Ada.Integer_Text_IO, Ada.Command_Line; procedure Main is Num_Insertions : Integer := 0; Num_Queries : Integer; Scratch : Boolean; Rand : Integer; procedure Integer_Put( Item: Integer ) is begin Put( Item ); end Integer_Put; package Int_AVL_Tree is new Generic_AVL_Tree( Element_Type => Integer, Less_Than => "<", Greater_Than => ">", Put => Integer_Put ); package Random_Int is new Ada.Numerics.Discrete_Random(Integer); List : Int_AVL_Tree.T; G : Random_Int.Generator; -- Sequence_File : Ada.Text_IO.File_Type; procedure Print_Usage is begin New_Line; Put("Usage: " & Command_Name & " <number of insertions> <number of queries>"); New_Line; New_Line; end Print_Usage; begin if Argument_Count /= 2 then Print_Usage; else begin Num_Insertions := Positive'Value( Argument(1) ); Num_Queries := Natural'Value( Argument(2) ); exception when Constraint_Error => Print_Usage; raise; when others => raise; end; end if; if Num_Insertions > 0 then -- Put("Inserting 2^(" & Integer'Image(Num_Insertions)); -- Put(") elements and then making 2^(" & Integer'Image(Num_Queries)); -- Put_Line(") queries."); -- Open( Sequence_File, In_File, Name => "sequence.dat" ); Random_Int.Reset(G); begin for I in 1 .. 2**Num_Insertions loop Rand := Random_Int.Random(G); -- Put( Sequence_File, Rand ); New_Line( Sequence_File ); -- Get( Sequence_File, Rand ); Int_AVL_Tree.Insert( List, Rand ); end loop; exception when others => -- Close( Sequence_File ); raise; end; -- Close( Sequence_File ); for I in 1 .. 2**Num_Queries loop Scratch := Int_AVL_Tree.Is_In_Tree( List, Random_Int.Random(G) ); end loop; -- Put_Line("Done."); end if; end Main;
AdaCore/Ada_Drivers_Library
Ada
5,021
ads
------------------------------------------------------------------------------ -- -- -- Copyright (C) 2020, AdaCore -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions are -- -- met: -- -- 1. Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- 2. Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in -- -- the documentation and/or other materials provided with the -- -- distribution. -- -- 3. Neither the name of the copyright holder nor the names of its -- -- contributors may be used to endorse or promote products derived -- -- from this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -- -- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -- -- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -- -- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -- -- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ package FE310.Performance_Monitor is ----------------------------------- -- See FE310 Manual section 3.8 -- ----------------------------------- -- FE310 supports counters mhpmcounter3 and mhpmcounter4 only type Counter_Id is range 3 .. 4; -- Instruction Commit Events -- Note: position and order matter here. type Commit_Events is (Exception_Taken, Integer_Load, Integer_Store, Atomic_Operation, System_Instruction, Integer_Arithmetic, Conditional_Branch, JAL_Instruction, JALR_Instruction, Integer_Multiplication, Integer_Division); type Set_Of_Commit_Events is array (Commit_Events) of Boolean; No_Commit_Events : constant Set_Of_Commit_Events := (others => False); procedure Set_Commit_Events (C : in Counter_Id; S : in Set_Of_Commit_Events); -- Micro Architecture Events -- Note: position and order matter here. type Micro_Arch_Events is (Load_Use_Interlock, Long_Latency_Interlock, CSR_Read_Interlock, Instruction_Cache_Busy, Data_Cache_Busy, Branch_Direction_Misprediction, Branch_Target_Misprediction, Pipeline_Flush_From_CSR_Write, Pipeline_Flish_From_Other, Integer_Multiplication_Interlock); type Set_Of_Micro_Arch_Events is array (Micro_Arch_Events) of Boolean; No_Micro_Arch_Events : constant Set_Of_Micro_Arch_Events := (others => False); procedure Set_Micro_Arch_Events (C : in Counter_Id; S : in Set_Of_Micro_Arch_Events); -- Memory System Events type Memory_System_Events is (Instruction_Cache_Miss, Memory_Mapped_IO_Access); type Set_Of_Memory_System_Events is array (Memory_System_Events) of Boolean; No_Memory_System_Events : constant Set_Of_Memory_System_Events := (others => False); procedure Set_Memory_System_Events (C : in Counter_Id; S : in Set_Of_Memory_System_Events); -- Counter reading and reset procedure Zero_Counter (C : in Counter_Id); function Read_Counter (C : in Counter_Id) return UInt64; end FE310.Performance_Monitor;
reznikmm/gela
Ada
2,977
adb
package body Gela.Peristent_Lists is ------------ -- Delete -- ------------ procedure Delete (Self : in out Container; Input : List; Value : Element_Type; Output : out List) is procedure Count_Each (Item : Element_Type); Count : Natural := 0; Found : Boolean := False; procedure Count_Each (Item : Element_Type) is begin if Value = Item then Found := True; end if; Count := Count + 1; end Count_Each; begin For_Each (Self, Input, Count_Each'Access); if Found then declare procedure Fill_Each (Item : Element_Type); Data : array (1 .. Count) of Element_Type; procedure Fill_Each (Item : Element_Type) is begin if Value /= Item then Count := Count + 1; Data (Count) := Item; end if; end Fill_Each; begin Count := 0; For_Each (Self, Input, Fill_Each'Access); Output := 0; for J in 1 .. Count loop Prepend (Self, Data (J), Output, Output); end loop; end; else Output := Input; end if; end Delete; -------------- -- For_Each -- -------------- procedure For_Each (Self : Container; Input : List; Action : access procedure (Value : Element_Type)) is Index : List := Input; begin while Index /= 0 loop declare X : constant Link := Self.Links.Element (Index); begin Action (Self.Elements.Element (X.Value)); Index := X.Next; end; end loop; end For_Each; ---------- -- Head -- ---------- function Head (Self : Container; Index : List) return Element_Type is X : constant Link := Self.Links.Element (Index); begin return Self.Elements.Element (X.Value); end Head; ------------- -- Prepend -- ------------- procedure Prepend (Self : in out Container; Value : Element_Type; Input : List := Empty; Output : out List) is Value_Index : Natural := Self.Elements.Find_Index (Value); New_Link : Link; Result : List; begin if Value_Index = 0 then Self.Elements.Append (Value); Value_Index := Self.Elements.Last_Index; end if; New_Link := (Value => Value_Index, Next => Input); Result := Self.Links.Find_Index (New_Link); if Result = 0 then Self.Links.Append (New_Link); Output := Self.Links.Last_Index; else Output := Result; end if; end Prepend; ---------- -- Tail -- ---------- function Tail (Self : Container; Index : List) return List is begin return Self.Links.Element (Index).Next; end Tail; end Gela.Peristent_Lists;
sonneveld/adazmq
Ada
1,974
adb
-- Synchronized subscriber with Ada.Command_Line; with Ada.Text_IO; with GNAT.Formatted_String; with ZMQ; procedure SyncSub is use type GNAT.Formatted_String.Formatted_String; Subscribers_Expected : constant := 10; -- We wait for 10 subscribers function Main return Ada.Command_Line.Exit_Status is begin declare Context : ZMQ.Context_Type := ZMQ.New_Context; -- First, connect our subscriber socket Subscriber : constant ZMQ.Socket_Type'Class := Context.New_Socket (ZMQ.ZMQ_SUB); -- Second, synchronize with publisher Sync_Client : constant ZMQ.Socket_Type'Class := Context.New_Socket (ZMQ.ZMQ_REQ); begin -- First, connect our subscriber socket Subscriber.Connect ("tcp://localhost:5561"); Subscriber.Set_Sock_Opt (ZMQ.ZMQ_SUBSCRIBE, ""); -- 0MQ is so fast, we need to wait a while... delay 1.0; -- Second, synchronize with publisher Sync_Client.Connect ("tcp://localhost:5562"); -- - send a synchronization request Sync_Client.Send (""); -- - wait for synchronization reply declare Unused_Reply : String := Sync_Client.Recv; begin null; end; -- Third, get our updates and report how many we got declare Update_Nbr : Natural := 0; begin Recv_Loop : loop declare Msg : constant String := Subscriber.Recv; begin exit Recv_Loop when Msg = "END"; end; Update_Nbr := Update_Nbr + 1; end loop Recv_Loop; Ada.Text_IO.Put_Line (-(+"Received %d updates"&Update_Nbr)); end; Subscriber.Close; Sync_Client.Close; Context.Term; end; return 0; end Main; begin Ada.Command_Line.Set_Exit_Status (Main); end SyncSub;
apple-oss-distributions/old_ncurses
Ada
4,028
adb
------------------------------------------------------------------------------ -- -- -- GNAT ncurses Binding -- -- -- -- Terminal_Interface.Curses.PutWin -- -- -- -- B O D Y -- -- -- ------------------------------------------------------------------------------ -- Copyright (c) 2000 Free Software Foundation, Inc. -- -- -- -- Permission is hereby granted, free of charge, to any person obtaining a -- -- copy of this software and associated documentation files (the -- -- "Software"), to deal in the Software without restriction, including -- -- without limitation the rights to use, copy, modify, merge, publish, -- -- distribute, distribute with modifications, sublicense, and/or sell -- -- copies of the Software, and to permit persons to whom the Software is -- -- furnished to do so, subject to the following conditions: -- -- -- -- The above copyright notice and this permission notice shall be included -- -- in all copies or substantial portions of the Software. -- -- -- -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -- -- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -- -- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -- -- IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -- -- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -- -- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR -- -- THE USE OR OTHER DEALINGS IN THE SOFTWARE. -- -- -- -- Except as contained in this notice, the name(s) of the above copyright -- -- holders shall not be used in advertising or otherwise to promote the -- -- sale, use or other dealings in this Software without prior written -- -- authorization. -- ------------------------------------------------------------------------------ -- Author: Eugene V. Melaragno <[email protected]> 2000 -- Version Control: -- $Revision: 1.1.1.1 $ -- Binding Version 01.00 with Ada.Streams.Stream_IO.C_Streams; with Interfaces.C_Streams; with Terminal_Interface.Curses.Aux; use Terminal_Interface.Curses.Aux; package body Terminal_Interface.Curses.PutWin is package ICS renames Interfaces.C_Streams; package ACS renames Ada.Streams.Stream_IO.C_Streams; use type C_Int; procedure Put_Window (Win : Window; File : Ada.Streams.Stream_IO.File_Type) is function putwin (Win : Window; f : ICS.FILEs) return C_Int; pragma Import (C, putwin, "putwin"); R : constant C_Int := putwin (Win, ACS.C_Stream (File)); begin if R /= Curses_Ok then raise Curses_Exception; end if; end Put_Window; function Get_Window (File : Ada.Streams.Stream_IO.File_Type) return Window is function getwin (f : ICS.FILEs) return Window; pragma Import (C, getwin, "getwin"); W : constant Window := getwin (ACS.C_Stream (File)); begin if W = Null_Window then raise Curses_Exception; else return W; end if; end Get_Window; end Terminal_Interface.Curses.PutWin;
AdaCore/libadalang
Ada
107
adb
function Sum (A : Integer; B : Integer; C : Integer) return Integer is begin return A + B + C; end Sum;
ekoeppen/STM32_Generic_Ada_Drivers
Ada
254
ads
with STM32_SVD.TIM; with STM32_SVD; use STM32_SVD; package STM32GD.Timer is type Timer_Callback_Type is access procedure; type Timer_Type is (Timer_2, Timer_3, Timer_4, Timer_5, Timer_14, Timer_15, Timer_16, Timer_17); end STM32GD.Timer;
joelimgu/Lists_Ada_Package
Ada
6,230
adb
with Ada.Text_IO; use Ada.Text_IO; with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; with Ada.Strings.Unbounded.Text_IO; use Ada.Strings.Unbounded.Text_IO; with Unchecked_Deallocation; package body lists is procedure Free is new Unchecked_Deallocation(Element,P_List); function Create_List(Elements: Tab_Of_List_Type) return List is L :List := (First_Element => null); begin for i in Elements'Range loop --add every number of the array into the list L.Append(Elements(i)); end loop; return L; end Create_List; procedure Append(Self: in out List; Data: T_Data) is aux: P_List := Self.First_Element; begin if aux = null then --return a new list if its empty Self.First_Element := new Element'(info => Data, suiv => null); else --go to the last element (next element = null) and add a new wlement with the new data while aux.all.suiv /= null loop aux := aux.all.suiv; end loop; aux.all.suiv := new Element'(info => Data, suiv => null); end if; end Append; function Length(Self:in List) return Natural is len: Natural := 0; aux: P_List := Self.First_Element; begin if aux /= null then len := len + 1; while aux.all.suiv /= null loop aux:= aux.all.suiv; len := len + 1; end loop; end if; return len; end Length; function get(Self:in List; Index: Integer) return T_Data is begin return Self.get_pointer(Index => Index).all.info; end get; function Image(Self: in out List) return String is aux: P_List := Self.First_Element; img: Unbounded_String; index : Integer := 1; begin img := To_Unbounded_String("["); if aux /= null then while aux.all.suiv /= null loop img := img & To_Unbounded_String(Data_Image(aux.all.info) & ", "); aux := aux.all.suiv; end loop; img := img & To_Unbounded_String(Data_Image(aux.all.info)); end if; img := img & "]"; return To_String(img); end Image; procedure Set(Self:in out List; Index :Integer; New_Value: T_Data) is begin Self.get_pointer(Index => Index).all.info := New_Value; end Set; procedure Remove_Element(Self: in out List; Element: T_Data) is pre, aux, rec: P_List; begin if Self.First_Element = null then raise Element_not_in_the_list; elsif Self.First_Element.all.info = Element then rec:= Self.First_Element; Self.First_Element := Self.First_Element.all.suiv; Free(rec); else pre:= Self.First_Element; aux:=Self.First_Element.all.suiv; while aux /= null and then aux.all.info /= Element loop pre:= aux; aux:= aux.all.suiv; end loop; if aux /= null then rec := aux; pre.all.suiv:= aux.all.suiv; Free(rec); end if; end if; end Remove_Element; procedure Remove_Nth_Element(Self: in out List; Index: Integer) is aux : P_List := Self.First_Element; rec : P_List := null; begin if aux = null or Index > Self.Length then --the list is null raise Get_Index_Value_Outside_the_list; elsif Index = 1 then --its the firs element on the list Delete_Object(aux.all.info); Self.First_Element := aux.all.suiv; Free(aux); elsif Index = Self.Length then --its the last element on the list aux := Self.get_pointer(Index => Index - 1); Delete_Object(aux.all.suiv.all.info); Free(aux.all.suiv); aux.all.suiv := null; else -- its one element of the list, not ht efirst not the last aux := Self.get_pointer(Index - 1); rec := aux.all.suiv; aux.all.suiv := rec.all.suiv; Delete_Object(rec.all.info); Free(rec); end if; end Remove_Nth_Element; function get_pointer(Self: in List; Index: Integer) return P_List is aux : P_List := Self.First_Element; begin if Index > Self.Length then raise Get_Index_Value_Outside_the_list; elsif Index < 0 then raise Get_Index_value_negative_not_implemented_yet; end if; for i in 2..Index loop aux:= aux.all.suiv; end loop; return aux; end get_pointer; procedure Empty(Self: in out List) is --empties all the list and frees the memory mostly used to instance in a list which contains lists rec : P_List := null; aux : P_List := Self.First_Element; begin for i in 1..Self.Length loop rec := aux; aux := aux.all.suiv; Delete_Object(rec.all.info); Free (rec); end loop; end Empty; function "+"(L,R : List) return List is --appends the second list to the first and returns the whole list res: List := (First_Element => null); aux: P_List := L.First_Element; begin for i in 1..L.Length loop res.Append(L.get(i)); end loop; for i in 1..R.Length loop res.Append(R.get(i)); end loop; return res; end "+"; function "="(L,R: List) return Boolean is res: Boolean := False; auxL:P_List := L.First_Element; auxR: P_List := R.First_Element; begin if L.Length = R.Length then res := True; while res and auxL /= null loop res := auxL.all.info = auxR.all.info; auxL := auxL.all.suiv; auxR := auxR.all.suiv; end loop; end if; return res; end "="; function Index(Self: in List; Element : T_Data) return Integer is aux: P_List := Self.First_Element; Index : Integer := 1; begin while aux /= null and then aux.all.info /= Element loop aux := aux.all.suiv; index := Index + 1; end loop; if aux = null then raise Element_not_in_the_list; end if; return Index; end Index; end lists;
stcarrez/ada-util
Ada
4,413
ads
----------------------------------------------------------------------- -- util-strings-transforms -- Various Text Transformation Utilities -- Copyright (C) 2001, 2002, 2003, 2009, 2010, 2015, 2018 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Util.Texts.Transforms; with Ada.Strings.Unbounded; with Ada.Characters.Handling; package Util.Strings.Transforms is pragma Preelaborate; use Ada.Strings.Unbounded; package TR is new Util.Texts.Transforms (Stream => Unbounded_String, Char => Character, Input => String, Put => Ada.Strings.Unbounded.Append, To_Upper => Ada.Characters.Handling.To_Upper, To_Lower => Ada.Characters.Handling.To_Lower); -- Capitalize the string into the result stream. procedure Capitalize (Content : in String; Into : in out Unbounded_String) renames TR.Capitalize; function Capitalize (Content : String) return String renames TR.Capitalize; -- Translate the input string into an upper case string in the result stream. procedure To_Upper_Case (Content : in String; Into : in out Unbounded_String) renames TR.To_Upper_Case; function To_Upper_Case (Content : String) return String renames TR.To_Upper_Case; -- Translate the input string into a lower case string in the result stream. procedure To_Lower_Case (Content : in String; Into : in out Unbounded_String) renames TR.To_Lower_Case; function To_Lower_Case (Content : String) return String renames TR.To_Lower_Case; -- Write in the output stream the value as a \uNNNN encoding form. procedure To_Hex (Into : in out Unbounded_String; Value : in Character) renames TR.To_Hex; -- Escape the content into the result stream using the JavaScript -- escape rules. procedure Escape_Javascript (Content : in String; Into : in out Unbounded_String) renames TR.Escape_Java_Script; function Escape_Javascript (Content : String) return String; -- Escape the content into the result stream using the Java -- escape rules. procedure Escape_Java (Content : in String; Into : in out Unbounded_String) renames TR.Escape_Java; function Escape_Java (Content : String) return String; -- Escape the content into the result stream using the XML -- escape rules: -- '<' -> '&lt;' -- '>' -> '&gt;' -- ''' -> '&apos;' -- '&' -> '&amp;' -- -> '&#nnn;' if Character'Pos >= 128 procedure Escape_Xml (Content : in String; Into : in out Unbounded_String) renames TR.Escape_Xml; function Escape_Xml (Content : String) return String; procedure Translate_Xml_Entity (Entity : in String; Into : in out Unbounded_String) renames TR.Translate_Xml_Entity; procedure Unescape_Xml (Content : in String; Translator : not null access procedure (Entity : in String; Into : in out Unbounded_String) := Translate_Xml_Entity'Access; Into : in out Unbounded_String) renames TR.Unescape_Xml; end Util.Strings.Transforms;
ytomino/gnat4drake
Ada
302
ads
pragma License (Unrestricted); with GNAT.Traceback; with System; package Ada.Exceptions.Traceback is subtype Code_Loc is System.Address; subtype Tracebacks_Array is GNAT.Traceback.Tracebacks_Array; function Get_PC (TB_Entry : System.Address) return Code_Loc; end Ada.Exceptions.Traceback;
reznikmm/matreshka
Ada
2,275
ads
-- Copyright (c) 1990 Regents of the University of California. -- All rights reserved. -- -- This software was developed by John Self of the Arcadia project -- at the University of California, Irvine. -- -- Redistribution and use in source and binary forms are permitted -- provided that the above copyright notice and this paragraph are -- duplicated in all such forms and that any documentation, -- advertising materials, and other materials related to such -- distribution and use acknowledge that the software was developed -- by the University of California, Irvine. The name of the -- University may not be used to endorse or promote products derived -- from this software without specific prior written permission. -- THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR -- IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED -- WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. -- TITLE NFA construction routines -- AUTHOR: John Self (UCI) -- DESCRIPTION builds the NFA. -- NOTES this file mirrors flex as closely as possible. -- $Header: /co/ua/self/arcadia/aflex/ada/src/RCS/nfaS.a,v 1.4 90/01/12 15:20:30 self Exp Locker: self $ package NFA is procedure ADD_ACCEPT(MACH : in out INTEGER; ACCEPTING_NUMBER : in INTEGER); function COPYSINGL(SINGL, NUM : in INTEGER) return INTEGER; procedure DUMPNFA(STATE1 : in INTEGER); function DUPMACHINE(MACH : in INTEGER) return INTEGER; procedure FINISH_RULE(MACH : in INTEGER; VARIABLE_TRAIL_RULE : in BOOLEAN; HEADCNT, TRAILCNT : in INTEGER); function LINK_MACHINES(FIRST, LAST : in INTEGER) return INTEGER; procedure MARK_BEGINNING_AS_NORMAL(MACH : in INTEGER); function MKBRANCH(FIRST, SECOND : in INTEGER) return INTEGER; function MKCLOS(STATE : in INTEGER) return INTEGER; function MKOPT(MACH : in INTEGER) return INTEGER; function MKOR(FIRST, SECOND : in INTEGER) return INTEGER; function MKPOSCL(STATE : in INTEGER) return INTEGER; function MKREP(MACH, LB, UB : in INTEGER) return INTEGER; function MKSTATE(SYM : in INTEGER) return INTEGER; procedure MKXTION(STATEFROM, STATETO : in INTEGER); procedure NEW_RULE; end NFA;
reznikmm/matreshka
Ada
7,200
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with Matreshka.DOM_Documents; with Matreshka.ODF_String_Constants; with ODF.DOM.Iterators; with ODF.DOM.Visitors; package body Matreshka.ODF_Text.Bibliography_Entry_Template_Elements is ------------ -- Create -- ------------ overriding function Create (Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters) return Text_Bibliography_Entry_Template_Element_Node is begin return Self : Text_Bibliography_Entry_Template_Element_Node do Matreshka.ODF_Text.Constructors.Initialize (Self'Unchecked_Access, Parameters.Document, Matreshka.ODF_String_Constants.Text_Prefix); end return; end Create; ---------------- -- Enter_Node -- ---------------- overriding procedure Enter_Node (Self : not null access Text_Bibliography_Entry_Template_Element_Node; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control) is begin if Visitor in ODF.DOM.Visitors.Abstract_ODF_Visitor'Class then ODF.DOM.Visitors.Abstract_ODF_Visitor'Class (Visitor).Enter_Text_Bibliography_Entry_Template (ODF.DOM.Text_Bibliography_Entry_Template_Elements.ODF_Text_Bibliography_Entry_Template_Access (Self), Control); else Matreshka.DOM_Elements.Abstract_Element_Node (Self.all).Enter_Node (Visitor, Control); end if; end Enter_Node; -------------------- -- Get_Local_Name -- -------------------- overriding function Get_Local_Name (Self : not null access constant Text_Bibliography_Entry_Template_Element_Node) return League.Strings.Universal_String is pragma Unreferenced (Self); begin return Matreshka.ODF_String_Constants.Bibliography_Entry_Template_Element; end Get_Local_Name; ---------------- -- Leave_Node -- ---------------- overriding procedure Leave_Node (Self : not null access Text_Bibliography_Entry_Template_Element_Node; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control) is begin if Visitor in ODF.DOM.Visitors.Abstract_ODF_Visitor'Class then ODF.DOM.Visitors.Abstract_ODF_Visitor'Class (Visitor).Leave_Text_Bibliography_Entry_Template (ODF.DOM.Text_Bibliography_Entry_Template_Elements.ODF_Text_Bibliography_Entry_Template_Access (Self), Control); else Matreshka.DOM_Elements.Abstract_Element_Node (Self.all).Leave_Node (Visitor, Control); end if; end Leave_Node; ---------------- -- Visit_Node -- ---------------- overriding procedure Visit_Node (Self : not null access Text_Bibliography_Entry_Template_Element_Node; Iterator : in out XML.DOM.Visitors.Abstract_Iterator'Class; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control) is begin if Iterator in ODF.DOM.Iterators.Abstract_ODF_Iterator'Class then ODF.DOM.Iterators.Abstract_ODF_Iterator'Class (Iterator).Visit_Text_Bibliography_Entry_Template (Visitor, ODF.DOM.Text_Bibliography_Entry_Template_Elements.ODF_Text_Bibliography_Entry_Template_Access (Self), Control); else Matreshka.DOM_Elements.Abstract_Element_Node (Self.all).Visit_Node (Iterator, Visitor, Control); end if; end Visit_Node; begin Matreshka.DOM_Documents.Register_Element (Matreshka.ODF_String_Constants.Text_URI, Matreshka.ODF_String_Constants.Bibliography_Entry_Template_Element, Text_Bibliography_Entry_Template_Element_Node'Tag); end Matreshka.ODF_Text.Bibliography_Entry_Template_Elements;
reznikmm/matreshka
Ada
4,899
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2012-2013, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ -- This file is generated, don't edit it. ------------------------------------------------------------------------------ with AMF.Generic_Collections; package AMF.OCL.Any_Types.Collections is pragma Preelaborate; package OCL_Any_Type_Collections is new AMF.Generic_Collections (OCL_Any_Type, OCL_Any_Type_Access); type Set_Of_OCL_Any_Type is new OCL_Any_Type_Collections.Set with null record; Empty_Set_Of_OCL_Any_Type : constant Set_Of_OCL_Any_Type; type Ordered_Set_Of_OCL_Any_Type is new OCL_Any_Type_Collections.Ordered_Set with null record; Empty_Ordered_Set_Of_OCL_Any_Type : constant Ordered_Set_Of_OCL_Any_Type; type Bag_Of_OCL_Any_Type is new OCL_Any_Type_Collections.Bag with null record; Empty_Bag_Of_OCL_Any_Type : constant Bag_Of_OCL_Any_Type; type Sequence_Of_OCL_Any_Type is new OCL_Any_Type_Collections.Sequence with null record; Empty_Sequence_Of_OCL_Any_Type : constant Sequence_Of_OCL_Any_Type; private Empty_Set_Of_OCL_Any_Type : constant Set_Of_OCL_Any_Type := (OCL_Any_Type_Collections.Set with null record); Empty_Ordered_Set_Of_OCL_Any_Type : constant Ordered_Set_Of_OCL_Any_Type := (OCL_Any_Type_Collections.Ordered_Set with null record); Empty_Bag_Of_OCL_Any_Type : constant Bag_Of_OCL_Any_Type := (OCL_Any_Type_Collections.Bag with null record); Empty_Sequence_Of_OCL_Any_Type : constant Sequence_Of_OCL_Any_Type := (OCL_Any_Type_Collections.Sequence with null record); end AMF.OCL.Any_Types.Collections;
reznikmm/matreshka
Ada
3,704
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with XML.DOM.Attributes; package ODF.DOM.Draw_Distance_Attributes is pragma Preelaborate; type ODF_Draw_Distance_Attribute is limited interface and XML.DOM.Attributes.DOM_Attribute; type ODF_Draw_Distance_Attribute_Access is access all ODF_Draw_Distance_Attribute'Class with Storage_Size => 0; end ODF.DOM.Draw_Distance_Attributes;
zhmu/ananas
Ada
3,054
ads
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- A D A . D I R E C T _ I O . C _ S T R E A M S -- -- -- -- S p e c -- -- -- -- Copyright (C) 1992-2022, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- As a special exception under Section 7 of GPL version 3, you are granted -- -- additional permissions described in the GCC Runtime Library Exception, -- -- version 3.1, as published by the Free Software Foundation. -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ -- This package provides an interface between Ada.Direct_IO and the -- C streams. This allows sharing of a stream between Ada and C or C++, -- as well as allowing the Ada program to operate directly on the stream. with Interfaces.C_Streams; generic package Ada.Direct_IO.C_Streams is package ICS renames Interfaces.C_Streams; function C_Stream (F : File_Type) return ICS.FILEs; -- Obtain stream from existing open file procedure Open (File : in out File_Type; Mode : File_Mode; C_Stream : ICS.FILEs; Form : String := ""; Name : String := ""); -- Create new file from existing stream end Ada.Direct_IO.C_Streams;
optikos/oasis
Ada
1,574
ads
-- Copyright (c) 2019 Maxim Reznik <[email protected]> -- -- SPDX-License-Identifier: MIT -- License-Filename: LICENSE ------------------------------------------------------------- with Program.Elements.Defining_Names; with Program.Elements.Expressions; with Program.Lexical_Elements; with Program.Elements.Defining_Identifiers; package Program.Elements.Defining_Expanded_Names is pragma Pure (Program.Elements.Defining_Expanded_Names); type Defining_Expanded_Name is limited interface and Program.Elements.Defining_Names.Defining_Name; type Defining_Expanded_Name_Access is access all Defining_Expanded_Name'Class with Storage_Size => 0; not overriding function Prefix (Self : Defining_Expanded_Name) return not null Program.Elements.Expressions.Expression_Access is abstract; not overriding function Selector (Self : Defining_Expanded_Name) return not null Program.Elements.Defining_Identifiers .Defining_Identifier_Access is abstract; type Defining_Expanded_Name_Text is limited interface; type Defining_Expanded_Name_Text_Access is access all Defining_Expanded_Name_Text'Class with Storage_Size => 0; not overriding function To_Defining_Expanded_Name_Text (Self : aliased in out Defining_Expanded_Name) return Defining_Expanded_Name_Text_Access is abstract; not overriding function Dot_Token (Self : Defining_Expanded_Name_Text) return not null Program.Lexical_Elements.Lexical_Element_Access is abstract; end Program.Elements.Defining_Expanded_Names;
io7m/coreland-posix-ada
Ada
518
adb
with POSIX.Error; use type POSIX.Error.Error_t; with Test; procedure T_Error1 is package Error renames POSIX.Error; Fetched : Error.Error_t; Value : constant Error.Error_t := Error.Error_Access; begin Error.Set_Error (Value); Fetched := Error.Get_Error; Test.Assert (Check => Fetched = Value, Pass_Message => Error.Error_t'Image (Fetched) & " = " & Error.Error_t'Image (Value), Fail_Message => Error.Error_t'Image (Fetched) & " /= " & Error.Error_t'Image (Value)); end T_Error1;
MinimSecure/unum-sdk
Ada
848
adb
-- Copyright 2008-2016 Free Software Foundation, Inc. -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation; either version 3 of the License, or -- (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- -- You should have received a copy of the GNU General Public License -- along with this program. If not, see <http://www.gnu.org/licenses/>. with System; package body Pck is procedure Do_Nothing (A : System.Address) is begin null; end Do_Nothing; end Pck;
reznikmm/matreshka
Ada
4,271
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2011, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with Modeler.Diagram_Views.Moc; package body Modeler.Diagram_Views is ------------------ -- Constructors -- ------------------ package body Constructors is ------------ -- Create -- ------------ function Create (Parent : access Qt4.Widgets.Q_Widget'Class := null) return not null Diagram_View_Access is begin return Self : not null Diagram_View_Access := new Diagram_View do Qt4.Graphics_Views.Directors.Constructors.Initialize (Self, Parent); end return; end Create; end Constructors; --------------------- -- Draw_Background -- --------------------- overriding procedure Draw_Background (Self : not null access Diagram_View; Painter : in out Qt4.Painters.Q_Painter'Class; Rect : Qt4.Rect_Fs.Q_Rect_F) is begin null; end Draw_Background; end Modeler.Diagram_Views;
reznikmm/matreshka
Ada
6,718
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with Matreshka.DOM_Documents; with Matreshka.ODF_String_Constants; with ODF.DOM.Iterators; with ODF.DOM.Visitors; package body Matreshka.ODF_Db.Login_Elements is ------------ -- Create -- ------------ overriding function Create (Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters) return Db_Login_Element_Node is begin return Self : Db_Login_Element_Node do Matreshka.ODF_Db.Constructors.Initialize (Self'Unchecked_Access, Parameters.Document, Matreshka.ODF_String_Constants.Db_Prefix); end return; end Create; ---------------- -- Enter_Node -- ---------------- overriding procedure Enter_Node (Self : not null access Db_Login_Element_Node; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control) is begin if Visitor in ODF.DOM.Visitors.Abstract_ODF_Visitor'Class then ODF.DOM.Visitors.Abstract_ODF_Visitor'Class (Visitor).Enter_Db_Login (ODF.DOM.Db_Login_Elements.ODF_Db_Login_Access (Self), Control); else Matreshka.DOM_Elements.Abstract_Element_Node (Self.all).Enter_Node (Visitor, Control); end if; end Enter_Node; -------------------- -- Get_Local_Name -- -------------------- overriding function Get_Local_Name (Self : not null access constant Db_Login_Element_Node) return League.Strings.Universal_String is pragma Unreferenced (Self); begin return Matreshka.ODF_String_Constants.Login_Element; end Get_Local_Name; ---------------- -- Leave_Node -- ---------------- overriding procedure Leave_Node (Self : not null access Db_Login_Element_Node; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control) is begin if Visitor in ODF.DOM.Visitors.Abstract_ODF_Visitor'Class then ODF.DOM.Visitors.Abstract_ODF_Visitor'Class (Visitor).Leave_Db_Login (ODF.DOM.Db_Login_Elements.ODF_Db_Login_Access (Self), Control); else Matreshka.DOM_Elements.Abstract_Element_Node (Self.all).Leave_Node (Visitor, Control); end if; end Leave_Node; ---------------- -- Visit_Node -- ---------------- overriding procedure Visit_Node (Self : not null access Db_Login_Element_Node; Iterator : in out XML.DOM.Visitors.Abstract_Iterator'Class; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control) is begin if Iterator in ODF.DOM.Iterators.Abstract_ODF_Iterator'Class then ODF.DOM.Iterators.Abstract_ODF_Iterator'Class (Iterator).Visit_Db_Login (Visitor, ODF.DOM.Db_Login_Elements.ODF_Db_Login_Access (Self), Control); else Matreshka.DOM_Elements.Abstract_Element_Node (Self.all).Visit_Node (Iterator, Visitor, Control); end if; end Visit_Node; begin Matreshka.DOM_Documents.Register_Element (Matreshka.ODF_String_Constants.Db_URI, Matreshka.ODF_String_Constants.Login_Element, Db_Login_Element_Node'Tag); end Matreshka.ODF_Db.Login_Elements;
vikasbidhuri1995/DW1000
Ada
5,860
ads
------------------------------------------------------------------------------- -- Copyright (c) 2016 Daniel King -- -- Permission is hereby granted, free of charge, to any person obtaining a -- copy of this software and associated documentation files (the "Software"), -- to deal in the Software without restriction, including without limitation -- the rights to use, copy, modify, merge, publish, distribute, sublicense, -- and/or sell copies of the Software, and to permit persons to whom the -- Software is furnished to do so, subject to the following conditions: -- -- The above copyright notice and this permission notice shall be included in -- all copies or substantial portions of the Software. -- -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -- DEALINGS IN THE SOFTWARE. ------------------------------------------------------------------------------- with DW1000.BSP; with DW1000.Types; -- This package provides an octet-level interface to the DW1000's register -- set. package DW1000.Register_Driver with SPARK_Mode => On is type Operation_Type is (Read, Write) with Size => 1; for Operation_Type use (Read => 0, Write => 1); -- SPI transaction header Operation bit. type Sub_Index_Type is (Not_Present, Present) with Size => 1; for Sub_Index_Type use (Not_Present => 0, Present => 1); -- SPI transaction header Sub-Index presence bit. type Extended_Address_Type is (Not_Extended, Extended) with Size => 1; for Extended_Address_Type use (Not_Extended => 0, Extended => 1); -- SPI transaction header Extended address bit. -- -- This bit is only used for the 2 octet and 3 octet long headers. type Non_Indexed_Header is record Register_ID : DW1000.Types.Bits_6 := 0; Sub_Index : Sub_Index_Type := Not_Present; Operation : Operation_Type := Read; end record with Size => 8, Dynamic_Predicate => Non_Indexed_Header.Sub_Index = Not_Present; -- 1-octet SPI transaction header -- -- In this header the Sub_Index field must always be set to Not_Present. for Non_Indexed_Header use record Register_ID at 0 range 0 .. 5; Sub_Index at 0 range 6 .. 6; Operation at 0 range 7 .. 7; end record; type Short_Indexed_Header is record Register_ID : DW1000.Types.Bits_6 := 0; Sub_Index : Sub_Index_Type := Present; Operation : Operation_Type := Read; Register_Sub_Address : DW1000.Types.Bits_7 := 0; Extended_Address : Extended_Address_Type := Not_Extended; end record with Size => 16, Dynamic_Predicate => (Short_Indexed_Header.Sub_Index = Present and Short_Indexed_Header.Extended_Address = Not_Extended); -- 2-octet SPI transaction header -- -- In this header the Sub_Index field must always be set to Present -- and the Extended_Address field must always be set to Not_Extended. for Short_Indexed_Header use record Register_ID at 0 range 0 .. 5; Sub_Index at 0 range 6 .. 6; Operation at 0 range 7 .. 7; Register_Sub_Address at 0 range 8 .. 14; Extended_Address at 0 range 15 .. 15; end record; type Long_Indexed_Header is record Register_ID : DW1000.Types.Bits_6 := 0; Sub_Index : Sub_Index_Type := Present; Operation : Operation_Type := Read; Register_Sub_Address_LSB : DW1000.Types.Bits_7 := 0; Extended_Address : Extended_Address_Type := Extended; Register_Sub_Address_MSB : DW1000.Types.Bits_8 := 0; end record with Size => 24, Dynamic_Predicate => (Long_Indexed_Header.Sub_Index = Present and Long_Indexed_Header.Extended_Address = Extended); -- 3-octet SPI transaction header -- -- In this header the Sub_Index field must always be set to Present -- and the Extended_Address field must always be set to Extended. for Long_Indexed_Header use record Register_ID at 0 range 0 .. 5; Sub_Index at 0 range 6 .. 6; Operation at 0 range 7 .. 7; Register_Sub_Address_LSB at 0 range 8 .. 14; Extended_Address at 0 range 15 .. 15; Register_Sub_Address_MSB at 0 range 16 .. 23; end record; procedure Read_Register (Register_ID : in DW1000.Types.Bits_6; Sub_Address : in DW1000.Types.Bits_15; Data : out DW1000.Types.Byte_Array) with Global => (In_Out => DW1000.BSP.Device_State), Depends => (DW1000.BSP.Device_State =>+ (Register_ID, Sub_Address, Data), Data => (DW1000.BSP.Device_State, Register_ID, Sub_Address)), Pre => Data'Length > 0; -- Read a register on the DW1000. procedure Write_Register (Register_ID : in DW1000.Types.Bits_6; Sub_Address : in DW1000.Types.Bits_15; Data : in DW1000.Types.Byte_Array) with Global => (In_Out => DW1000.BSP.Device_State), Depends => (DW1000.BSP.Device_State =>+ (Register_ID, Sub_Address, Data)), Pre => Data'Length > 0; -- Write to a register on the DW1000. end DW1000.Register_Driver;
wookey-project/ewok-legacy
Ada
1,271
ads
-- -- Copyright 2018 The wookey project team <[email protected]> -- - Ryad Benadjila -- - Arnauld Michelizza -- - Mathieu Renard -- - Philippe Thierry -- - Philippe Trebuchet -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. -- -- with ewok.tasks_shared; use ewok.tasks_shared; package ewok.syscalls.rng with spark_mode => off is -- return a random content from the TRNG hardware (if there is one) or -- from a pseudorandom source into a given buffer. -- The length must not be greater than 16 bytes. procedure sys_get_random (caller_id : in ewok.tasks_shared.t_task_id; params : in out t_parameters; mode : in ewok.tasks_shared.t_task_mode); end ewok.syscalls.rng;
tum-ei-rcs/StratoX
Ada
80,260
ads
-- This spec has been automatically generated from STM32F427x.svd pragma Restrictions (No_Elaboration_Code); pragma Ada_2012; with System; with HAL; package STM32_SVD.USB_OTG_FS is pragma Preelaborate; --------------- -- Registers -- --------------- ------------------------- -- FS_GOTGCTL_Register -- ------------------------- -- OTG_FS control and status register (OTG_FS_GOTGCTL) type FS_GOTGCTL_Register is record -- Read-only. Session request success SRQSCS : Boolean := False; -- Session request SRQ : Boolean := False; -- unspecified Reserved_2_7 : HAL.UInt6 := 16#0#; -- Read-only. Host negotiation success HNGSCS : Boolean := False; -- HNP request HNPRQ : Boolean := False; -- Host set HNP enable HSHNPEN : Boolean := False; -- Device HNP enabled DHNPEN : Boolean := True; -- unspecified Reserved_12_15 : HAL.UInt4 := 16#0#; -- Read-only. Connector ID status CIDSTS : Boolean := False; -- Read-only. Long/short debounce time DBCT : Boolean := False; -- Read-only. A-session valid ASVLD : Boolean := False; -- Read-only. B-session valid BSVLD : Boolean := False; -- unspecified Reserved_20_31 : HAL.UInt12 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for FS_GOTGCTL_Register use record SRQSCS at 0 range 0 .. 0; SRQ at 0 range 1 .. 1; Reserved_2_7 at 0 range 2 .. 7; HNGSCS at 0 range 8 .. 8; HNPRQ at 0 range 9 .. 9; HSHNPEN at 0 range 10 .. 10; DHNPEN at 0 range 11 .. 11; Reserved_12_15 at 0 range 12 .. 15; CIDSTS at 0 range 16 .. 16; DBCT at 0 range 17 .. 17; ASVLD at 0 range 18 .. 18; BSVLD at 0 range 19 .. 19; Reserved_20_31 at 0 range 20 .. 31; end record; ------------------------- -- FS_GOTGINT_Register -- ------------------------- -- OTG_FS interrupt register (OTG_FS_GOTGINT) type FS_GOTGINT_Register is record -- unspecified Reserved_0_1 : HAL.UInt2 := 16#0#; -- Session end detected SEDET : Boolean := False; -- unspecified Reserved_3_7 : HAL.UInt5 := 16#0#; -- Session request success status change SRSSCHG : Boolean := False; -- Host negotiation success status change HNSSCHG : Boolean := False; -- unspecified Reserved_10_16 : HAL.UInt7 := 16#0#; -- Host negotiation detected HNGDET : Boolean := False; -- A-device timeout change ADTOCHG : Boolean := False; -- Debounce done DBCDNE : Boolean := False; -- unspecified Reserved_20_31 : HAL.UInt12 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for FS_GOTGINT_Register use record Reserved_0_1 at 0 range 0 .. 1; SEDET at 0 range 2 .. 2; Reserved_3_7 at 0 range 3 .. 7; SRSSCHG at 0 range 8 .. 8; HNSSCHG at 0 range 9 .. 9; Reserved_10_16 at 0 range 10 .. 16; HNGDET at 0 range 17 .. 17; ADTOCHG at 0 range 18 .. 18; DBCDNE at 0 range 19 .. 19; Reserved_20_31 at 0 range 20 .. 31; end record; ------------------------- -- FS_GAHBCFG_Register -- ------------------------- -- OTG_FS AHB configuration register (OTG_FS_GAHBCFG) type FS_GAHBCFG_Register is record -- Global interrupt mask GINT : Boolean := False; -- unspecified Reserved_1_6 : HAL.UInt6 := 16#0#; -- TxFIFO empty level TXFELVL : Boolean := False; -- Periodic TxFIFO empty level PTXFELVL : Boolean := False; -- unspecified Reserved_9_31 : HAL.UInt23 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for FS_GAHBCFG_Register use record GINT at 0 range 0 .. 0; Reserved_1_6 at 0 range 1 .. 6; TXFELVL at 0 range 7 .. 7; PTXFELVL at 0 range 8 .. 8; Reserved_9_31 at 0 range 9 .. 31; end record; ------------------------- -- FS_GUSBCFG_Register -- ------------------------- subtype FS_GUSBCFG_TOCAL_Field is HAL.UInt3; subtype FS_GUSBCFG_TRDT_Field is HAL.UInt4; -- OTG_FS USB configuration register (OTG_FS_GUSBCFG) type FS_GUSBCFG_Register is record -- FS timeout calibration TOCAL : FS_GUSBCFG_TOCAL_Field := 16#0#; -- unspecified Reserved_3_5 : HAL.UInt3 := 16#0#; -- Write-only. Full Speed serial transceiver select PHYSEL : Boolean := False; -- unspecified Reserved_7_7 : HAL.Bit := 16#0#; -- SRP-capable SRPCAP : Boolean := False; -- HNP-capable HNPCAP : Boolean := True; -- USB turnaround time TRDT : FS_GUSBCFG_TRDT_Field := 16#2#; -- unspecified Reserved_14_28 : HAL.UInt15 := 16#0#; -- Force host mode FHMOD : Boolean := False; -- Force device mode FDMOD : Boolean := False; -- Corrupt Tx packet CTXPKT : Boolean := False; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for FS_GUSBCFG_Register use record TOCAL at 0 range 0 .. 2; Reserved_3_5 at 0 range 3 .. 5; PHYSEL at 0 range 6 .. 6; Reserved_7_7 at 0 range 7 .. 7; SRPCAP at 0 range 8 .. 8; HNPCAP at 0 range 9 .. 9; TRDT at 0 range 10 .. 13; Reserved_14_28 at 0 range 14 .. 28; FHMOD at 0 range 29 .. 29; FDMOD at 0 range 30 .. 30; CTXPKT at 0 range 31 .. 31; end record; ------------------------- -- FS_GRSTCTL_Register -- ------------------------- subtype FS_GRSTCTL_TXFNUM_Field is HAL.UInt5; -- OTG_FS reset register (OTG_FS_GRSTCTL) type FS_GRSTCTL_Register is record -- Core soft reset CSRST : Boolean := False; -- HCLK soft reset HSRST : Boolean := False; -- Host frame counter reset FCRST : Boolean := False; -- unspecified Reserved_3_3 : HAL.Bit := 16#0#; -- RxFIFO flush RXFFLSH : Boolean := False; -- TxFIFO flush TXFFLSH : Boolean := False; -- TxFIFO number TXFNUM : FS_GRSTCTL_TXFNUM_Field := 16#0#; -- unspecified Reserved_11_30 : HAL.UInt20 := 16#40000#; -- Read-only. AHB master idle AHBIDL : Boolean := False; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for FS_GRSTCTL_Register use record CSRST at 0 range 0 .. 0; HSRST at 0 range 1 .. 1; FCRST at 0 range 2 .. 2; Reserved_3_3 at 0 range 3 .. 3; RXFFLSH at 0 range 4 .. 4; TXFFLSH at 0 range 5 .. 5; TXFNUM at 0 range 6 .. 10; Reserved_11_30 at 0 range 11 .. 30; AHBIDL at 0 range 31 .. 31; end record; ------------------------- -- FS_GINTSTS_Register -- ------------------------- -- OTG_FS core interrupt register (OTG_FS_GINTSTS) type FS_GINTSTS_Register is record -- Read-only. Current mode of operation CMOD : Boolean := False; -- Mode mismatch interrupt MMIS : Boolean := False; -- Read-only. OTG interrupt OTGINT : Boolean := False; -- Start of frame SOF : Boolean := False; -- Read-only. RxFIFO non-empty RXFLVL : Boolean := False; -- Read-only. Non-periodic TxFIFO empty NPTXFE : Boolean := True; -- Read-only. Global IN non-periodic NAK effective GINAKEFF : Boolean := False; -- Read-only. Global OUT NAK effective GOUTNAKEFF : Boolean := False; -- unspecified Reserved_8_9 : HAL.UInt2 := 16#0#; -- Early suspend ESUSP : Boolean := False; -- USB suspend USBSUSP : Boolean := False; -- USB reset USBRST : Boolean := False; -- Enumeration done ENUMDNE : Boolean := False; -- Isochronous OUT packet dropped interrupt ISOODRP : Boolean := False; -- End of periodic frame interrupt EOPF : Boolean := False; -- unspecified Reserved_16_17 : HAL.UInt2 := 16#0#; -- Read-only. IN endpoint interrupt IEPINT : Boolean := False; -- Read-only. OUT endpoint interrupt OEPINT : Boolean := False; -- Incomplete isochronous IN transfer IISOIXFR : Boolean := False; -- Incomplete periodic transfer(Host mode)/Incomplete isochronous OUT -- transfer(Device mode) IPXFR_INCOMPISOOUT : Boolean := False; -- unspecified Reserved_22_23 : HAL.UInt2 := 16#0#; -- Read-only. Host port interrupt HPRTINT : Boolean := False; -- Read-only. Host channels interrupt HCINT : Boolean := False; -- Read-only. Periodic TxFIFO empty PTXFE : Boolean := True; -- unspecified Reserved_27_27 : HAL.Bit := 16#0#; -- Connector ID status change CIDSCHG : Boolean := False; -- Disconnect detected interrupt DISCINT : Boolean := False; -- Session request/new session detected interrupt SRQINT : Boolean := False; -- Resume/remote wakeup detected interrupt WKUPINT : Boolean := False; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for FS_GINTSTS_Register use record CMOD at 0 range 0 .. 0; MMIS at 0 range 1 .. 1; OTGINT at 0 range 2 .. 2; SOF at 0 range 3 .. 3; RXFLVL at 0 range 4 .. 4; NPTXFE at 0 range 5 .. 5; GINAKEFF at 0 range 6 .. 6; GOUTNAKEFF at 0 range 7 .. 7; Reserved_8_9 at 0 range 8 .. 9; ESUSP at 0 range 10 .. 10; USBSUSP at 0 range 11 .. 11; USBRST at 0 range 12 .. 12; ENUMDNE at 0 range 13 .. 13; ISOODRP at 0 range 14 .. 14; EOPF at 0 range 15 .. 15; Reserved_16_17 at 0 range 16 .. 17; IEPINT at 0 range 18 .. 18; OEPINT at 0 range 19 .. 19; IISOIXFR at 0 range 20 .. 20; IPXFR_INCOMPISOOUT at 0 range 21 .. 21; Reserved_22_23 at 0 range 22 .. 23; HPRTINT at 0 range 24 .. 24; HCINT at 0 range 25 .. 25; PTXFE at 0 range 26 .. 26; Reserved_27_27 at 0 range 27 .. 27; CIDSCHG at 0 range 28 .. 28; DISCINT at 0 range 29 .. 29; SRQINT at 0 range 30 .. 30; WKUPINT at 0 range 31 .. 31; end record; ------------------------- -- FS_GINTMSK_Register -- ------------------------- -- OTG_FS interrupt mask register (OTG_FS_GINTMSK) type FS_GINTMSK_Register is record -- unspecified Reserved_0_0 : HAL.Bit := 16#0#; -- Mode mismatch interrupt mask MMISM : Boolean := False; -- OTG interrupt mask OTGINT : Boolean := False; -- Start of frame mask SOFM : Boolean := False; -- Receive FIFO non-empty mask RXFLVLM : Boolean := False; -- Non-periodic TxFIFO empty mask NPTXFEM : Boolean := False; -- Global non-periodic IN NAK effective mask GINAKEFFM : Boolean := False; -- Global OUT NAK effective mask GONAKEFFM : Boolean := False; -- unspecified Reserved_8_9 : HAL.UInt2 := 16#0#; -- Early suspend mask ESUSPM : Boolean := False; -- USB suspend mask USBSUSPM : Boolean := False; -- USB reset mask USBRST : Boolean := False; -- Enumeration done mask ENUMDNEM : Boolean := False; -- Isochronous OUT packet dropped interrupt mask ISOODRPM : Boolean := False; -- End of periodic frame interrupt mask EOPFM : Boolean := False; -- unspecified Reserved_16_16 : HAL.Bit := 16#0#; -- Endpoint mismatch interrupt mask EPMISM : Boolean := False; -- IN endpoints interrupt mask IEPINT : Boolean := False; -- OUT endpoints interrupt mask OEPINT : Boolean := False; -- Incomplete isochronous IN transfer mask IISOIXFRM : Boolean := False; -- Incomplete periodic transfer mask(Host mode)/Incomplete isochronous -- OUT transfer mask(Device mode) IPXFRM_IISOOXFRM : Boolean := False; -- unspecified Reserved_22_23 : HAL.UInt2 := 16#0#; -- Read-only. Host port interrupt mask PRTIM : Boolean := False; -- Host channels interrupt mask HCIM : Boolean := False; -- Periodic TxFIFO empty mask PTXFEM : Boolean := False; -- unspecified Reserved_27_27 : HAL.Bit := 16#0#; -- Connector ID status change mask CIDSCHGM : Boolean := False; -- Disconnect detected interrupt mask DISCINT : Boolean := False; -- Session request/new session detected interrupt mask SRQIM : Boolean := False; -- Resume/remote wakeup detected interrupt mask WUIM : Boolean := False; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for FS_GINTMSK_Register use record Reserved_0_0 at 0 range 0 .. 0; MMISM at 0 range 1 .. 1; OTGINT at 0 range 2 .. 2; SOFM at 0 range 3 .. 3; RXFLVLM at 0 range 4 .. 4; NPTXFEM at 0 range 5 .. 5; GINAKEFFM at 0 range 6 .. 6; GONAKEFFM at 0 range 7 .. 7; Reserved_8_9 at 0 range 8 .. 9; ESUSPM at 0 range 10 .. 10; USBSUSPM at 0 range 11 .. 11; USBRST at 0 range 12 .. 12; ENUMDNEM at 0 range 13 .. 13; ISOODRPM at 0 range 14 .. 14; EOPFM at 0 range 15 .. 15; Reserved_16_16 at 0 range 16 .. 16; EPMISM at 0 range 17 .. 17; IEPINT at 0 range 18 .. 18; OEPINT at 0 range 19 .. 19; IISOIXFRM at 0 range 20 .. 20; IPXFRM_IISOOXFRM at 0 range 21 .. 21; Reserved_22_23 at 0 range 22 .. 23; PRTIM at 0 range 24 .. 24; HCIM at 0 range 25 .. 25; PTXFEM at 0 range 26 .. 26; Reserved_27_27 at 0 range 27 .. 27; CIDSCHGM at 0 range 28 .. 28; DISCINT at 0 range 29 .. 29; SRQIM at 0 range 30 .. 30; WUIM at 0 range 31 .. 31; end record; -------------------------------- -- FS_GRXSTSR_Device_Register -- -------------------------------- subtype FS_GRXSTSR_Device_EPNUM_Field is HAL.UInt4; subtype FS_GRXSTSR_Device_BCNT_Field is HAL.UInt11; subtype FS_GRXSTSR_Device_DPID_Field is HAL.UInt2; subtype FS_GRXSTSR_Device_PKTSTS_Field is HAL.UInt4; subtype FS_GRXSTSR_Device_FRMNUM_Field is HAL.UInt4; -- OTG_FS Receive status debug read(Device mode) type FS_GRXSTSR_Device_Register is record -- Read-only. Endpoint number EPNUM : FS_GRXSTSR_Device_EPNUM_Field; -- Read-only. Byte count BCNT : FS_GRXSTSR_Device_BCNT_Field; -- Read-only. Data PID DPID : FS_GRXSTSR_Device_DPID_Field; -- Read-only. Packet status PKTSTS : FS_GRXSTSR_Device_PKTSTS_Field; -- Read-only. Frame number FRMNUM : FS_GRXSTSR_Device_FRMNUM_Field; -- unspecified Reserved_25_31 : HAL.UInt7; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for FS_GRXSTSR_Device_Register use record EPNUM at 0 range 0 .. 3; BCNT at 0 range 4 .. 14; DPID at 0 range 15 .. 16; PKTSTS at 0 range 17 .. 20; FRMNUM at 0 range 21 .. 24; Reserved_25_31 at 0 range 25 .. 31; end record; ------------------------------ -- FS_GRXSTSR_Host_Register -- ------------------------------ subtype FS_GRXSTSR_Host_EPNUM_Field is HAL.UInt4; subtype FS_GRXSTSR_Host_BCNT_Field is HAL.UInt11; subtype FS_GRXSTSR_Host_DPID_Field is HAL.UInt2; subtype FS_GRXSTSR_Host_PKTSTS_Field is HAL.UInt4; subtype FS_GRXSTSR_Host_FRMNUM_Field is HAL.UInt4; -- OTG_FS Receive status debug read(Host mode) type FS_GRXSTSR_Host_Register is record -- Read-only. Endpoint number EPNUM : FS_GRXSTSR_Host_EPNUM_Field; -- Read-only. Byte count BCNT : FS_GRXSTSR_Host_BCNT_Field; -- Read-only. Data PID DPID : FS_GRXSTSR_Host_DPID_Field; -- Read-only. Packet status PKTSTS : FS_GRXSTSR_Host_PKTSTS_Field; -- Read-only. Frame number FRMNUM : FS_GRXSTSR_Host_FRMNUM_Field; -- unspecified Reserved_25_31 : HAL.UInt7; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for FS_GRXSTSR_Host_Register use record EPNUM at 0 range 0 .. 3; BCNT at 0 range 4 .. 14; DPID at 0 range 15 .. 16; PKTSTS at 0 range 17 .. 20; FRMNUM at 0 range 21 .. 24; Reserved_25_31 at 0 range 25 .. 31; end record; ------------------------- -- FS_GRXFSIZ_Register -- ------------------------- subtype FS_GRXFSIZ_RXFD_Field is HAL.Short; -- OTG_FS Receive FIFO size register (OTG_FS_GRXFSIZ) type FS_GRXFSIZ_Register is record -- RxFIFO depth RXFD : FS_GRXFSIZ_RXFD_Field := 16#200#; -- unspecified Reserved_16_31 : HAL.Short := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for FS_GRXFSIZ_Register use record RXFD at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; ---------------------------------- -- FS_GNPTXFSIZ_Device_Register -- ---------------------------------- subtype FS_GNPTXFSIZ_Device_TX0FSA_Field is HAL.Short; subtype FS_GNPTXFSIZ_Device_TX0FD_Field is HAL.Short; -- OTG_FS non-periodic transmit FIFO size register (Device mode) type FS_GNPTXFSIZ_Device_Register is record -- Endpoint 0 transmit RAM start address TX0FSA : FS_GNPTXFSIZ_Device_TX0FSA_Field := 16#200#; -- Endpoint 0 TxFIFO depth TX0FD : FS_GNPTXFSIZ_Device_TX0FD_Field := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for FS_GNPTXFSIZ_Device_Register use record TX0FSA at 0 range 0 .. 15; TX0FD at 0 range 16 .. 31; end record; -------------------------------- -- FS_GNPTXFSIZ_Host_Register -- -------------------------------- subtype FS_GNPTXFSIZ_Host_NPTXFSA_Field is HAL.Short; subtype FS_GNPTXFSIZ_Host_NPTXFD_Field is HAL.Short; -- OTG_FS non-periodic transmit FIFO size register (Host mode) type FS_GNPTXFSIZ_Host_Register is record -- Non-periodic transmit RAM start address NPTXFSA : FS_GNPTXFSIZ_Host_NPTXFSA_Field := 16#200#; -- Non-periodic TxFIFO depth NPTXFD : FS_GNPTXFSIZ_Host_NPTXFD_Field := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for FS_GNPTXFSIZ_Host_Register use record NPTXFSA at 0 range 0 .. 15; NPTXFD at 0 range 16 .. 31; end record; -------------------------- -- FS_GNPTXSTS_Register -- -------------------------- subtype FS_GNPTXSTS_NPTXFSAV_Field is HAL.Short; subtype FS_GNPTXSTS_NPTQXSAV_Field is HAL.Byte; subtype FS_GNPTXSTS_NPTXQTOP_Field is HAL.UInt7; -- OTG_FS non-periodic transmit FIFO/queue status register -- (OTG_FS_GNPTXSTS) type FS_GNPTXSTS_Register is record -- Read-only. Non-periodic TxFIFO space available NPTXFSAV : FS_GNPTXSTS_NPTXFSAV_Field; -- Read-only. Non-periodic transmit request queue space available NPTQXSAV : FS_GNPTXSTS_NPTQXSAV_Field; -- Read-only. Top of the non-periodic transmit request queue NPTXQTOP : FS_GNPTXSTS_NPTXQTOP_Field; -- unspecified Reserved_31_31 : HAL.Bit; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for FS_GNPTXSTS_Register use record NPTXFSAV at 0 range 0 .. 15; NPTQXSAV at 0 range 16 .. 23; NPTXQTOP at 0 range 24 .. 30; Reserved_31_31 at 0 range 31 .. 31; end record; ----------------------- -- FS_GCCFG_Register -- ----------------------- -- OTG_FS general core configuration register (OTG_FS_GCCFG) type FS_GCCFG_Register is record -- unspecified Reserved_0_15 : HAL.Short := 16#0#; -- Power down PWRDWN : Boolean := False; -- unspecified Reserved_17_17 : HAL.Bit := 16#0#; -- Enable the VBUS sensing device VBUSASEN : Boolean := False; -- Enable the VBUS sensing device VBUSBSEN : Boolean := False; -- SOF output enable SOFOUTEN : Boolean := False; -- unspecified Reserved_21_31 : HAL.UInt11 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for FS_GCCFG_Register use record Reserved_0_15 at 0 range 0 .. 15; PWRDWN at 0 range 16 .. 16; Reserved_17_17 at 0 range 17 .. 17; VBUSASEN at 0 range 18 .. 18; VBUSBSEN at 0 range 19 .. 19; SOFOUTEN at 0 range 20 .. 20; Reserved_21_31 at 0 range 21 .. 31; end record; -------------------------- -- FS_HPTXFSIZ_Register -- -------------------------- subtype FS_HPTXFSIZ_PTXSA_Field is HAL.Short; subtype FS_HPTXFSIZ_PTXFSIZ_Field is HAL.Short; -- OTG_FS Host periodic transmit FIFO size register (OTG_FS_HPTXFSIZ) type FS_HPTXFSIZ_Register is record -- Host periodic TxFIFO start address PTXSA : FS_HPTXFSIZ_PTXSA_Field := 16#600#; -- Host periodic TxFIFO depth PTXFSIZ : FS_HPTXFSIZ_PTXFSIZ_Field := 16#200#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for FS_HPTXFSIZ_Register use record PTXSA at 0 range 0 .. 15; PTXFSIZ at 0 range 16 .. 31; end record; ------------------------- -- FS_DIEPTXF_Register -- ------------------------- subtype FS_DIEPTXF1_INEPTXSA_Field is HAL.Short; subtype FS_DIEPTXF1_INEPTXFD_Field is HAL.Short; -- OTG_FS device IN endpoint transmit FIFO size register (OTG_FS_DIEPTXF2) type FS_DIEPTXF_Register is record -- IN endpoint FIFO2 transmit RAM start address INEPTXSA : FS_DIEPTXF1_INEPTXSA_Field := 16#400#; -- IN endpoint TxFIFO depth INEPTXFD : FS_DIEPTXF1_INEPTXFD_Field := 16#200#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for FS_DIEPTXF_Register use record INEPTXSA at 0 range 0 .. 15; INEPTXFD at 0 range 16 .. 31; end record; ---------------------- -- FS_HCFG_Register -- ---------------------- subtype FS_HCFG_FSLSPCS_Field is HAL.UInt2; -- OTG_FS host configuration register (OTG_FS_HCFG) type FS_HCFG_Register is record -- FS/LS PHY clock select FSLSPCS : FS_HCFG_FSLSPCS_Field := 16#0#; -- Read-only. FS- and LS-only support FSLSS : Boolean := False; -- unspecified Reserved_3_31 : HAL.UInt29 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for FS_HCFG_Register use record FSLSPCS at 0 range 0 .. 1; FSLSS at 0 range 2 .. 2; Reserved_3_31 at 0 range 3 .. 31; end record; ------------------- -- HFIR_Register -- ------------------- subtype HFIR_FRIVL_Field is HAL.Short; -- OTG_FS Host frame interval register type HFIR_Register is record -- Frame interval FRIVL : HFIR_FRIVL_Field := 16#EA60#; -- unspecified Reserved_16_31 : HAL.Short := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for HFIR_Register use record FRIVL at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; ----------------------- -- FS_HFNUM_Register -- ----------------------- subtype FS_HFNUM_FRNUM_Field is HAL.Short; subtype FS_HFNUM_FTREM_Field is HAL.Short; -- OTG_FS host frame number/frame time remaining register (OTG_FS_HFNUM) type FS_HFNUM_Register is record -- Read-only. Frame number FRNUM : FS_HFNUM_FRNUM_Field; -- Read-only. Frame time remaining FTREM : FS_HFNUM_FTREM_Field; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for FS_HFNUM_Register use record FRNUM at 0 range 0 .. 15; FTREM at 0 range 16 .. 31; end record; ------------------------- -- FS_HPTXSTS_Register -- ------------------------- subtype FS_HPTXSTS_PTXFSAVL_Field is HAL.Short; subtype FS_HPTXSTS_PTXQSAV_Field is HAL.Byte; subtype FS_HPTXSTS_PTXQTOP_Field is HAL.Byte; -- OTG_FS_Host periodic transmit FIFO/queue status register -- (OTG_FS_HPTXSTS) type FS_HPTXSTS_Register is record -- Periodic transmit data FIFO space available PTXFSAVL : FS_HPTXSTS_PTXFSAVL_Field := 16#100#; -- Read-only. Periodic transmit request queue space available PTXQSAV : FS_HPTXSTS_PTXQSAV_Field := 16#8#; -- Read-only. Top of the periodic transmit request queue PTXQTOP : FS_HPTXSTS_PTXQTOP_Field := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for FS_HPTXSTS_Register use record PTXFSAVL at 0 range 0 .. 15; PTXQSAV at 0 range 16 .. 23; PTXQTOP at 0 range 24 .. 31; end record; -------------------- -- HAINT_Register -- -------------------- subtype HAINT_HAINT_Field is HAL.Short; -- OTG_FS Host all channels interrupt register type HAINT_Register is record -- Read-only. Channel interrupts HAINT : HAINT_HAINT_Field; -- unspecified Reserved_16_31 : HAL.Short; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for HAINT_Register use record HAINT at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; ----------------------- -- HAINTMSK_Register -- ----------------------- subtype HAINTMSK_HAINTM_Field is HAL.Short; -- OTG_FS host all channels interrupt mask register type HAINTMSK_Register is record -- Channel interrupt mask HAINTM : HAINTMSK_HAINTM_Field := 16#0#; -- unspecified Reserved_16_31 : HAL.Short := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for HAINTMSK_Register use record HAINTM at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; ---------------------- -- FS_HPRT_Register -- ---------------------- subtype FS_HPRT_PLSTS_Field is HAL.UInt2; subtype FS_HPRT_PTCTL_Field is HAL.UInt4; subtype FS_HPRT_PSPD_Field is HAL.UInt2; -- OTG_FS host port control and status register (OTG_FS_HPRT) type FS_HPRT_Register is record -- Read-only. Port connect status PCSTS : Boolean := False; -- Port connect detected PCDET : Boolean := False; -- Port enable PENA : Boolean := False; -- Port enable/disable change PENCHNG : Boolean := False; -- Read-only. Port overcurrent active POCA : Boolean := False; -- Port overcurrent change POCCHNG : Boolean := False; -- Port resume PRES : Boolean := False; -- Port suspend PSUSP : Boolean := False; -- Port reset PRST : Boolean := False; -- unspecified Reserved_9_9 : HAL.Bit := 16#0#; -- Read-only. Port line status PLSTS : FS_HPRT_PLSTS_Field := 16#0#; -- Port power PPWR : Boolean := False; -- Port test control PTCTL : FS_HPRT_PTCTL_Field := 16#0#; -- Read-only. Port speed PSPD : FS_HPRT_PSPD_Field := 16#0#; -- unspecified Reserved_19_31 : HAL.UInt13 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for FS_HPRT_Register use record PCSTS at 0 range 0 .. 0; PCDET at 0 range 1 .. 1; PENA at 0 range 2 .. 2; PENCHNG at 0 range 3 .. 3; POCA at 0 range 4 .. 4; POCCHNG at 0 range 5 .. 5; PRES at 0 range 6 .. 6; PSUSP at 0 range 7 .. 7; PRST at 0 range 8 .. 8; Reserved_9_9 at 0 range 9 .. 9; PLSTS at 0 range 10 .. 11; PPWR at 0 range 12 .. 12; PTCTL at 0 range 13 .. 16; PSPD at 0 range 17 .. 18; Reserved_19_31 at 0 range 19 .. 31; end record; ------------------------ -- FS_HCCHAR_Register -- ------------------------ subtype FS_HCCHAR0_MPSIZ_Field is HAL.UInt11; subtype FS_HCCHAR0_EPNUM_Field is HAL.UInt4; subtype FS_HCCHAR0_EPTYP_Field is HAL.UInt2; subtype FS_HCCHAR0_MCNT_Field is HAL.UInt2; subtype FS_HCCHAR0_DAD_Field is HAL.UInt7; -- OTG_FS host channel-0 characteristics register (OTG_FS_HCCHAR0) type FS_HCCHAR_Register is record -- Maximum packet size MPSIZ : FS_HCCHAR0_MPSIZ_Field := 16#0#; -- Endpoint number EPNUM : FS_HCCHAR0_EPNUM_Field := 16#0#; -- Endpoint direction EPDIR : Boolean := False; -- unspecified Reserved_16_16 : HAL.Bit := 16#0#; -- Low-speed device LSDEV : Boolean := False; -- Endpoint type EPTYP : FS_HCCHAR0_EPTYP_Field := 16#0#; -- Multicount MCNT : FS_HCCHAR0_MCNT_Field := 16#0#; -- Device address DAD : FS_HCCHAR0_DAD_Field := 16#0#; -- Odd frame ODDFRM : Boolean := False; -- Channel disable CHDIS : Boolean := False; -- Channel enable CHENA : Boolean := False; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for FS_HCCHAR_Register use record MPSIZ at 0 range 0 .. 10; EPNUM at 0 range 11 .. 14; EPDIR at 0 range 15 .. 15; Reserved_16_16 at 0 range 16 .. 16; LSDEV at 0 range 17 .. 17; EPTYP at 0 range 18 .. 19; MCNT at 0 range 20 .. 21; DAD at 0 range 22 .. 28; ODDFRM at 0 range 29 .. 29; CHDIS at 0 range 30 .. 30; CHENA at 0 range 31 .. 31; end record; ----------------------- -- FS_HCINT_Register -- ----------------------- -- OTG_FS host channel-0 interrupt register (OTG_FS_HCINT0) type FS_HCINT_Register is record -- Transfer completed XFRC : Boolean := False; -- Channel halted CHH : Boolean := False; -- unspecified Reserved_2_2 : HAL.Bit := 16#0#; -- STALL response received interrupt STALL : Boolean := False; -- NAK response received interrupt NAK : Boolean := False; -- ACK response received/transmitted interrupt ACK : Boolean := False; -- unspecified Reserved_6_6 : HAL.Bit := 16#0#; -- Transaction error TXERR : Boolean := False; -- Babble error BBERR : Boolean := False; -- Frame overrun FRMOR : Boolean := False; -- Data toggle error DTERR : Boolean := False; -- unspecified Reserved_11_31 : HAL.UInt21 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for FS_HCINT_Register use record XFRC at 0 range 0 .. 0; CHH at 0 range 1 .. 1; Reserved_2_2 at 0 range 2 .. 2; STALL at 0 range 3 .. 3; NAK at 0 range 4 .. 4; ACK at 0 range 5 .. 5; Reserved_6_6 at 0 range 6 .. 6; TXERR at 0 range 7 .. 7; BBERR at 0 range 8 .. 8; FRMOR at 0 range 9 .. 9; DTERR at 0 range 10 .. 10; Reserved_11_31 at 0 range 11 .. 31; end record; -------------------------- -- FS_HCINTMSK_Register -- -------------------------- -- OTG_FS host channel-0 mask register (OTG_FS_HCINTMSK0) type FS_HCINTMSK_Register is record -- Transfer completed mask XFRCM : Boolean := False; -- Channel halted mask CHHM : Boolean := False; -- unspecified Reserved_2_2 : HAL.Bit := 16#0#; -- STALL response received interrupt mask STALLM : Boolean := False; -- NAK response received interrupt mask NAKM : Boolean := False; -- ACK response received/transmitted interrupt mask ACKM : Boolean := False; -- response received interrupt mask NYET : Boolean := False; -- Transaction error mask TXERRM : Boolean := False; -- Babble error mask BBERRM : Boolean := False; -- Frame overrun mask FRMORM : Boolean := False; -- Data toggle error mask DTERRM : Boolean := False; -- unspecified Reserved_11_31 : HAL.UInt21 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for FS_HCINTMSK_Register use record XFRCM at 0 range 0 .. 0; CHHM at 0 range 1 .. 1; Reserved_2_2 at 0 range 2 .. 2; STALLM at 0 range 3 .. 3; NAKM at 0 range 4 .. 4; ACKM at 0 range 5 .. 5; NYET at 0 range 6 .. 6; TXERRM at 0 range 7 .. 7; BBERRM at 0 range 8 .. 8; FRMORM at 0 range 9 .. 9; DTERRM at 0 range 10 .. 10; Reserved_11_31 at 0 range 11 .. 31; end record; ------------------------ -- FS_HCTSIZ_Register -- ------------------------ subtype FS_HCTSIZ0_XFRSIZ_Field is HAL.UInt19; subtype FS_HCTSIZ0_PKTCNT_Field is HAL.UInt10; subtype FS_HCTSIZ0_DPID_Field is HAL.UInt2; -- OTG_FS host channel-0 transfer size register type FS_HCTSIZ_Register is record -- Transfer size XFRSIZ : FS_HCTSIZ0_XFRSIZ_Field := 16#0#; -- Packet count PKTCNT : FS_HCTSIZ0_PKTCNT_Field := 16#0#; -- Data PID DPID : FS_HCTSIZ0_DPID_Field := 16#0#; -- unspecified Reserved_31_31 : HAL.Bit := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for FS_HCTSIZ_Register use record XFRSIZ at 0 range 0 .. 18; PKTCNT at 0 range 19 .. 28; DPID at 0 range 29 .. 30; Reserved_31_31 at 0 range 31 .. 31; end record; ---------------------- -- FS_DCFG_Register -- ---------------------- subtype FS_DCFG_DSPD_Field is HAL.UInt2; subtype FS_DCFG_DAD_Field is HAL.UInt7; subtype FS_DCFG_PFIVL_Field is HAL.UInt2; -- OTG_FS device configuration register (OTG_FS_DCFG) type FS_DCFG_Register is record -- Device speed DSPD : FS_DCFG_DSPD_Field := 16#0#; -- Non-zero-length status OUT handshake NZLSOHSK : Boolean := False; -- unspecified Reserved_3_3 : HAL.Bit := 16#0#; -- Device address DAD : FS_DCFG_DAD_Field := 16#0#; -- Periodic frame interval PFIVL : FS_DCFG_PFIVL_Field := 16#0#; -- unspecified Reserved_13_31 : HAL.UInt19 := 16#1100#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for FS_DCFG_Register use record DSPD at 0 range 0 .. 1; NZLSOHSK at 0 range 2 .. 2; Reserved_3_3 at 0 range 3 .. 3; DAD at 0 range 4 .. 10; PFIVL at 0 range 11 .. 12; Reserved_13_31 at 0 range 13 .. 31; end record; ---------------------- -- FS_DCTL_Register -- ---------------------- subtype FS_DCTL_TCTL_Field is HAL.UInt3; -- OTG_FS device control register (OTG_FS_DCTL) type FS_DCTL_Register is record -- Remote wakeup signaling RWUSIG : Boolean := False; -- Soft disconnect SDIS : Boolean := False; -- Read-only. Global IN NAK status GINSTS : Boolean := False; -- Read-only. Global OUT NAK status GONSTS : Boolean := False; -- Test control TCTL : FS_DCTL_TCTL_Field := 16#0#; -- Set global IN NAK SGINAK : Boolean := False; -- Clear global IN NAK CGINAK : Boolean := False; -- Set global OUT NAK SGONAK : Boolean := False; -- Clear global OUT NAK CGONAK : Boolean := False; -- Power-on programming done POPRGDNE : Boolean := False; -- unspecified Reserved_12_31 : HAL.UInt20 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for FS_DCTL_Register use record RWUSIG at 0 range 0 .. 0; SDIS at 0 range 1 .. 1; GINSTS at 0 range 2 .. 2; GONSTS at 0 range 3 .. 3; TCTL at 0 range 4 .. 6; SGINAK at 0 range 7 .. 7; CGINAK at 0 range 8 .. 8; SGONAK at 0 range 9 .. 9; CGONAK at 0 range 10 .. 10; POPRGDNE at 0 range 11 .. 11; Reserved_12_31 at 0 range 12 .. 31; end record; ---------------------- -- FS_DSTS_Register -- ---------------------- subtype FS_DSTS_ENUMSPD_Field is HAL.UInt2; subtype FS_DSTS_FNSOF_Field is HAL.UInt14; -- OTG_FS device status register (OTG_FS_DSTS) type FS_DSTS_Register is record -- Read-only. Suspend status SUSPSTS : Boolean; -- Read-only. Enumerated speed ENUMSPD : FS_DSTS_ENUMSPD_Field; -- Read-only. Erratic error EERR : Boolean; -- unspecified Reserved_4_7 : HAL.UInt4; -- Read-only. Frame number of the received SOF FNSOF : FS_DSTS_FNSOF_Field; -- unspecified Reserved_22_31 : HAL.UInt10; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for FS_DSTS_Register use record SUSPSTS at 0 range 0 .. 0; ENUMSPD at 0 range 1 .. 2; EERR at 0 range 3 .. 3; Reserved_4_7 at 0 range 4 .. 7; FNSOF at 0 range 8 .. 21; Reserved_22_31 at 0 range 22 .. 31; end record; ------------------------- -- FS_DIEPMSK_Register -- ------------------------- -- OTG_FS device IN endpoint common interrupt mask register -- (OTG_FS_DIEPMSK) type FS_DIEPMSK_Register is record -- Transfer completed interrupt mask XFRCM : Boolean := False; -- Endpoint disabled interrupt mask EPDM : Boolean := False; -- unspecified Reserved_2_2 : HAL.Bit := 16#0#; -- Timeout condition mask (Non-isochronous endpoints) TOM : Boolean := False; -- IN token received when TxFIFO empty mask ITTXFEMSK : Boolean := False; -- IN token received with EP mismatch mask INEPNMM : Boolean := False; -- IN endpoint NAK effective mask INEPNEM : Boolean := False; -- unspecified Reserved_7_31 : HAL.UInt25 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for FS_DIEPMSK_Register use record XFRCM at 0 range 0 .. 0; EPDM at 0 range 1 .. 1; Reserved_2_2 at 0 range 2 .. 2; TOM at 0 range 3 .. 3; ITTXFEMSK at 0 range 4 .. 4; INEPNMM at 0 range 5 .. 5; INEPNEM at 0 range 6 .. 6; Reserved_7_31 at 0 range 7 .. 31; end record; ------------------------- -- FS_DOEPMSK_Register -- ------------------------- -- OTG_FS device OUT endpoint common interrupt mask register -- (OTG_FS_DOEPMSK) type FS_DOEPMSK_Register is record -- Transfer completed interrupt mask XFRCM : Boolean := False; -- Endpoint disabled interrupt mask EPDM : Boolean := False; -- unspecified Reserved_2_2 : HAL.Bit := 16#0#; -- SETUP phase done mask STUPM : Boolean := False; -- OUT token received when endpoint disabled mask OTEPDM : Boolean := False; -- unspecified Reserved_5_31 : HAL.UInt27 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for FS_DOEPMSK_Register use record XFRCM at 0 range 0 .. 0; EPDM at 0 range 1 .. 1; Reserved_2_2 at 0 range 2 .. 2; STUPM at 0 range 3 .. 3; OTEPDM at 0 range 4 .. 4; Reserved_5_31 at 0 range 5 .. 31; end record; ----------------------- -- FS_DAINT_Register -- ----------------------- subtype FS_DAINT_IEPINT_Field is HAL.Short; subtype FS_DAINT_OEPINT_Field is HAL.Short; -- OTG_FS device all endpoints interrupt register (OTG_FS_DAINT) type FS_DAINT_Register is record -- Read-only. IN endpoint interrupt bits IEPINT : FS_DAINT_IEPINT_Field; -- Read-only. OUT endpoint interrupt bits OEPINT : FS_DAINT_OEPINT_Field; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for FS_DAINT_Register use record IEPINT at 0 range 0 .. 15; OEPINT at 0 range 16 .. 31; end record; -------------------------- -- FS_DAINTMSK_Register -- -------------------------- subtype FS_DAINTMSK_IEPM_Field is HAL.Short; subtype FS_DAINTMSK_OEPINT_Field is HAL.Short; -- OTG_FS all endpoints interrupt mask register (OTG_FS_DAINTMSK) type FS_DAINTMSK_Register is record -- IN EP interrupt mask bits IEPM : FS_DAINTMSK_IEPM_Field := 16#0#; -- OUT endpoint interrupt bits OEPINT : FS_DAINTMSK_OEPINT_Field := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for FS_DAINTMSK_Register use record IEPM at 0 range 0 .. 15; OEPINT at 0 range 16 .. 31; end record; ----------------------- -- DVBUSDIS_Register -- ----------------------- subtype DVBUSDIS_VBUSDT_Field is HAL.Short; -- OTG_FS device VBUS discharge time register type DVBUSDIS_Register is record -- Device VBUS discharge time VBUSDT : DVBUSDIS_VBUSDT_Field := 16#17D7#; -- unspecified Reserved_16_31 : HAL.Short := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for DVBUSDIS_Register use record VBUSDT at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; ------------------------- -- DVBUSPULSE_Register -- ------------------------- subtype DVBUSPULSE_DVBUSP_Field is HAL.UInt12; -- OTG_FS device VBUS pulsing time register type DVBUSPULSE_Register is record -- Device VBUS pulsing time DVBUSP : DVBUSPULSE_DVBUSP_Field := 16#5B8#; -- unspecified Reserved_12_31 : HAL.UInt20 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for DVBUSPULSE_Register use record DVBUSP at 0 range 0 .. 11; Reserved_12_31 at 0 range 12 .. 31; end record; ------------------------- -- DIEPEMPMSK_Register -- ------------------------- subtype DIEPEMPMSK_INEPTXFEM_Field is HAL.Short; -- OTG_FS device IN endpoint FIFO empty interrupt mask register type DIEPEMPMSK_Register is record -- IN EP Tx FIFO empty interrupt mask bits INEPTXFEM : DIEPEMPMSK_INEPTXFEM_Field := 16#0#; -- unspecified Reserved_16_31 : HAL.Short := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for DIEPEMPMSK_Register use record INEPTXFEM at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; -------------------------- -- FS_DIEPCTL0_Register -- -------------------------- subtype FS_DIEPCTL0_MPSIZ_Field is HAL.UInt2; subtype FS_DIEPCTL0_EPTYP_Field is HAL.UInt2; subtype FS_DIEPCTL0_TXFNUM_Field is HAL.UInt4; -- OTG_FS device control IN endpoint 0 control register (OTG_FS_DIEPCTL0) type FS_DIEPCTL0_Register is record -- Maximum packet size MPSIZ : FS_DIEPCTL0_MPSIZ_Field := 16#0#; -- unspecified Reserved_2_14 : HAL.UInt13 := 16#0#; -- Read-only. USB active endpoint USBAEP : Boolean := False; -- unspecified Reserved_16_16 : HAL.Bit := 16#0#; -- Read-only. NAK status NAKSTS : Boolean := False; -- Read-only. Endpoint type EPTYP : FS_DIEPCTL0_EPTYP_Field := 16#0#; -- unspecified Reserved_20_20 : HAL.Bit := 16#0#; -- STALL handshake STALL : Boolean := False; -- TxFIFO number TXFNUM : FS_DIEPCTL0_TXFNUM_Field := 16#0#; -- Write-only. Clear NAK CNAK : Boolean := False; -- Write-only. Set NAK SNAK : Boolean := False; -- unspecified Reserved_28_29 : HAL.UInt2 := 16#0#; -- Read-only. Endpoint disable EPDIS : Boolean := False; -- Read-only. Endpoint enable EPENA : Boolean := False; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for FS_DIEPCTL0_Register use record MPSIZ at 0 range 0 .. 1; Reserved_2_14 at 0 range 2 .. 14; USBAEP at 0 range 15 .. 15; Reserved_16_16 at 0 range 16 .. 16; NAKSTS at 0 range 17 .. 17; EPTYP at 0 range 18 .. 19; Reserved_20_20 at 0 range 20 .. 20; STALL at 0 range 21 .. 21; TXFNUM at 0 range 22 .. 25; CNAK at 0 range 26 .. 26; SNAK at 0 range 27 .. 27; Reserved_28_29 at 0 range 28 .. 29; EPDIS at 0 range 30 .. 30; EPENA at 0 range 31 .. 31; end record; ---------------------- -- DIEPINT_Register -- ---------------------- -- device endpoint-x interrupt register type DIEPINT_Register is record -- XFRC XFRC : Boolean := False; -- EPDISD EPDISD : Boolean := False; -- unspecified Reserved_2_2 : HAL.Bit := 16#0#; -- TOC TOC : Boolean := False; -- ITTXFE ITTXFE : Boolean := False; -- unspecified Reserved_5_5 : HAL.Bit := 16#0#; -- INEPNE INEPNE : Boolean := False; -- Read-only. TXFE TXFE : Boolean := True; -- unspecified Reserved_8_31 : HAL.UInt24 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for DIEPINT_Register use record XFRC at 0 range 0 .. 0; EPDISD at 0 range 1 .. 1; Reserved_2_2 at 0 range 2 .. 2; TOC at 0 range 3 .. 3; ITTXFE at 0 range 4 .. 4; Reserved_5_5 at 0 range 5 .. 5; INEPNE at 0 range 6 .. 6; TXFE at 0 range 7 .. 7; Reserved_8_31 at 0 range 8 .. 31; end record; ------------------------ -- DIEPTSIZ0_Register -- ------------------------ subtype DIEPTSIZ0_XFRSIZ_Field is HAL.UInt7; subtype DIEPTSIZ0_PKTCNT_Field is HAL.UInt2; -- device endpoint-0 transfer size register type DIEPTSIZ0_Register is record -- Transfer size XFRSIZ : DIEPTSIZ0_XFRSIZ_Field := 16#0#; -- unspecified Reserved_7_18 : HAL.UInt12 := 16#0#; -- Packet count PKTCNT : DIEPTSIZ0_PKTCNT_Field := 16#0#; -- unspecified Reserved_21_31 : HAL.UInt11 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for DIEPTSIZ0_Register use record XFRSIZ at 0 range 0 .. 6; Reserved_7_18 at 0 range 7 .. 18; PKTCNT at 0 range 19 .. 20; Reserved_21_31 at 0 range 21 .. 31; end record; ---------------------- -- DTXFSTS_Register -- ---------------------- subtype DTXFSTS0_INEPTFSAV_Field is HAL.Short; -- OTG_FS device IN endpoint transmit FIFO status register type DTXFSTS_Register is record -- Read-only. IN endpoint TxFIFO space available INEPTFSAV : DTXFSTS0_INEPTFSAV_Field; -- unspecified Reserved_16_31 : HAL.Short; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for DTXFSTS_Register use record INEPTFSAV at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; ----------------------- -- DIEPCTL1_Register -- ----------------------- subtype DIEPCTL1_MPSIZ_Field is HAL.UInt11; subtype DIEPCTL1_EPTYP_Field is HAL.UInt2; subtype DIEPCTL1_TXFNUM_Field is HAL.UInt4; -- OTG device endpoint-1 control register type DIEPCTL1_Register is record -- MPSIZ MPSIZ : DIEPCTL1_MPSIZ_Field := 16#0#; -- unspecified Reserved_11_14 : HAL.UInt4 := 16#0#; -- USBAEP USBAEP : Boolean := False; -- Read-only. EONUM/DPID EONUM_DPID : Boolean := False; -- Read-only. NAKSTS NAKSTS : Boolean := False; -- EPTYP EPTYP : DIEPCTL1_EPTYP_Field := 16#0#; -- unspecified Reserved_20_20 : HAL.Bit := 16#0#; -- Stall Stall : Boolean := False; -- TXFNUM TXFNUM : DIEPCTL1_TXFNUM_Field := 16#0#; -- Write-only. CNAK CNAK : Boolean := False; -- Write-only. SNAK SNAK : Boolean := False; -- Write-only. SD0PID/SEVNFRM SD0PID_SEVNFRM : Boolean := False; -- Write-only. SODDFRM/SD1PID SODDFRM_SD1PID : Boolean := False; -- EPDIS EPDIS : Boolean := False; -- EPENA EPENA : Boolean := False; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for DIEPCTL1_Register use record MPSIZ at 0 range 0 .. 10; Reserved_11_14 at 0 range 11 .. 14; USBAEP at 0 range 15 .. 15; EONUM_DPID at 0 range 16 .. 16; NAKSTS at 0 range 17 .. 17; EPTYP at 0 range 18 .. 19; Reserved_20_20 at 0 range 20 .. 20; Stall at 0 range 21 .. 21; TXFNUM at 0 range 22 .. 25; CNAK at 0 range 26 .. 26; SNAK at 0 range 27 .. 27; SD0PID_SEVNFRM at 0 range 28 .. 28; SODDFRM_SD1PID at 0 range 29 .. 29; EPDIS at 0 range 30 .. 30; EPENA at 0 range 31 .. 31; end record; ----------------------- -- DIEPTSIZ_Register -- ----------------------- subtype DIEPTSIZ1_XFRSIZ_Field is HAL.UInt19; subtype DIEPTSIZ1_PKTCNT_Field is HAL.UInt10; subtype DIEPTSIZ1_MCNT_Field is HAL.UInt2; -- device endpoint-1 transfer size register type DIEPTSIZ_Register is record -- Transfer size XFRSIZ : DIEPTSIZ1_XFRSIZ_Field := 16#0#; -- Packet count PKTCNT : DIEPTSIZ1_PKTCNT_Field := 16#0#; -- Multi count MCNT : DIEPTSIZ1_MCNT_Field := 16#0#; -- unspecified Reserved_31_31 : HAL.Bit := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for DIEPTSIZ_Register use record XFRSIZ at 0 range 0 .. 18; PKTCNT at 0 range 19 .. 28; MCNT at 0 range 29 .. 30; Reserved_31_31 at 0 range 31 .. 31; end record; ---------------------- -- DIEPCTL_Register -- ---------------------- subtype DIEPCTL2_MPSIZ_Field is HAL.UInt11; subtype DIEPCTL2_EPTYP_Field is HAL.UInt2; subtype DIEPCTL2_TXFNUM_Field is HAL.UInt4; -- OTG device endpoint-2 control register type DIEPCTL_Register is record -- MPSIZ MPSIZ : DIEPCTL2_MPSIZ_Field := 16#0#; -- unspecified Reserved_11_14 : HAL.UInt4 := 16#0#; -- USBAEP USBAEP : Boolean := False; -- Read-only. EONUM/DPID EONUM_DPID : Boolean := False; -- Read-only. NAKSTS NAKSTS : Boolean := False; -- EPTYP EPTYP : DIEPCTL2_EPTYP_Field := 16#0#; -- unspecified Reserved_20_20 : HAL.Bit := 16#0#; -- Stall Stall : Boolean := False; -- TXFNUM TXFNUM : DIEPCTL2_TXFNUM_Field := 16#0#; -- Write-only. CNAK CNAK : Boolean := False; -- Write-only. SNAK SNAK : Boolean := False; -- Write-only. SD0PID/SEVNFRM SD0PID_SEVNFRM : Boolean := False; -- Write-only. SODDFRM SODDFRM : Boolean := False; -- EPDIS EPDIS : Boolean := False; -- EPENA EPENA : Boolean := False; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for DIEPCTL_Register use record MPSIZ at 0 range 0 .. 10; Reserved_11_14 at 0 range 11 .. 14; USBAEP at 0 range 15 .. 15; EONUM_DPID at 0 range 16 .. 16; NAKSTS at 0 range 17 .. 17; EPTYP at 0 range 18 .. 19; Reserved_20_20 at 0 range 20 .. 20; Stall at 0 range 21 .. 21; TXFNUM at 0 range 22 .. 25; CNAK at 0 range 26 .. 26; SNAK at 0 range 27 .. 27; SD0PID_SEVNFRM at 0 range 28 .. 28; SODDFRM at 0 range 29 .. 29; EPDIS at 0 range 30 .. 30; EPENA at 0 range 31 .. 31; end record; ----------------------- -- DOEPCTL0_Register -- ----------------------- subtype DOEPCTL0_MPSIZ_Field is HAL.UInt2; subtype DOEPCTL0_EPTYP_Field is HAL.UInt2; -- device endpoint-0 control register type DOEPCTL0_Register is record -- Read-only. MPSIZ MPSIZ : DOEPCTL0_MPSIZ_Field := 16#0#; -- unspecified Reserved_2_14 : HAL.UInt13 := 16#0#; -- Read-only. USBAEP USBAEP : Boolean := True; -- unspecified Reserved_16_16 : HAL.Bit := 16#0#; -- Read-only. NAKSTS NAKSTS : Boolean := False; -- Read-only. EPTYP EPTYP : DOEPCTL0_EPTYP_Field := 16#0#; -- SNPM SNPM : Boolean := False; -- Stall Stall : Boolean := False; -- unspecified Reserved_22_25 : HAL.UInt4 := 16#0#; -- Write-only. CNAK CNAK : Boolean := False; -- Write-only. SNAK SNAK : Boolean := False; -- unspecified Reserved_28_29 : HAL.UInt2 := 16#0#; -- Read-only. EPDIS EPDIS : Boolean := False; -- Write-only. EPENA EPENA : Boolean := False; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for DOEPCTL0_Register use record MPSIZ at 0 range 0 .. 1; Reserved_2_14 at 0 range 2 .. 14; USBAEP at 0 range 15 .. 15; Reserved_16_16 at 0 range 16 .. 16; NAKSTS at 0 range 17 .. 17; EPTYP at 0 range 18 .. 19; SNPM at 0 range 20 .. 20; Stall at 0 range 21 .. 21; Reserved_22_25 at 0 range 22 .. 25; CNAK at 0 range 26 .. 26; SNAK at 0 range 27 .. 27; Reserved_28_29 at 0 range 28 .. 29; EPDIS at 0 range 30 .. 30; EPENA at 0 range 31 .. 31; end record; ---------------------- -- DOEPINT_Register -- ---------------------- -- device endpoint-0 interrupt register type DOEPINT_Register is record -- XFRC XFRC : Boolean := False; -- EPDISD EPDISD : Boolean := False; -- unspecified Reserved_2_2 : HAL.Bit := 16#0#; -- STUP STUP : Boolean := False; -- OTEPDIS OTEPDIS : Boolean := False; -- unspecified Reserved_5_5 : HAL.Bit := 16#0#; -- B2BSTUP B2BSTUP : Boolean := False; -- unspecified Reserved_7_31 : HAL.UInt25 := 16#1#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for DOEPINT_Register use record XFRC at 0 range 0 .. 0; EPDISD at 0 range 1 .. 1; Reserved_2_2 at 0 range 2 .. 2; STUP at 0 range 3 .. 3; OTEPDIS at 0 range 4 .. 4; Reserved_5_5 at 0 range 5 .. 5; B2BSTUP at 0 range 6 .. 6; Reserved_7_31 at 0 range 7 .. 31; end record; ------------------------ -- DOEPTSIZ0_Register -- ------------------------ subtype DOEPTSIZ0_XFRSIZ_Field is HAL.UInt7; subtype DOEPTSIZ0_STUPCNT_Field is HAL.UInt2; -- device OUT endpoint-0 transfer size register type DOEPTSIZ0_Register is record -- Transfer size XFRSIZ : DOEPTSIZ0_XFRSIZ_Field := 16#0#; -- unspecified Reserved_7_18 : HAL.UInt12 := 16#0#; -- Packet count PKTCNT : Boolean := False; -- unspecified Reserved_20_28 : HAL.UInt9 := 16#0#; -- SETUP packet count STUPCNT : DOEPTSIZ0_STUPCNT_Field := 16#0#; -- unspecified Reserved_31_31 : HAL.Bit := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for DOEPTSIZ0_Register use record XFRSIZ at 0 range 0 .. 6; Reserved_7_18 at 0 range 7 .. 18; PKTCNT at 0 range 19 .. 19; Reserved_20_28 at 0 range 20 .. 28; STUPCNT at 0 range 29 .. 30; Reserved_31_31 at 0 range 31 .. 31; end record; ---------------------- -- DOEPCTL_Register -- ---------------------- subtype DOEPCTL1_MPSIZ_Field is HAL.UInt11; subtype DOEPCTL1_EPTYP_Field is HAL.UInt2; -- device endpoint-1 control register type DOEPCTL_Register is record -- MPSIZ MPSIZ : DOEPCTL1_MPSIZ_Field := 16#0#; -- unspecified Reserved_11_14 : HAL.UInt4 := 16#0#; -- USBAEP USBAEP : Boolean := False; -- Read-only. EONUM/DPID EONUM_DPID : Boolean := False; -- Read-only. NAKSTS NAKSTS : Boolean := False; -- EPTYP EPTYP : DOEPCTL1_EPTYP_Field := 16#0#; -- SNPM SNPM : Boolean := False; -- Stall Stall : Boolean := False; -- unspecified Reserved_22_25 : HAL.UInt4 := 16#0#; -- Write-only. CNAK CNAK : Boolean := False; -- Write-only. SNAK SNAK : Boolean := False; -- Write-only. SD0PID/SEVNFRM SD0PID_SEVNFRM : Boolean := False; -- Write-only. SODDFRM SODDFRM : Boolean := False; -- EPDIS EPDIS : Boolean := False; -- EPENA EPENA : Boolean := False; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for DOEPCTL_Register use record MPSIZ at 0 range 0 .. 10; Reserved_11_14 at 0 range 11 .. 14; USBAEP at 0 range 15 .. 15; EONUM_DPID at 0 range 16 .. 16; NAKSTS at 0 range 17 .. 17; EPTYP at 0 range 18 .. 19; SNPM at 0 range 20 .. 20; Stall at 0 range 21 .. 21; Reserved_22_25 at 0 range 22 .. 25; CNAK at 0 range 26 .. 26; SNAK at 0 range 27 .. 27; SD0PID_SEVNFRM at 0 range 28 .. 28; SODDFRM at 0 range 29 .. 29; EPDIS at 0 range 30 .. 30; EPENA at 0 range 31 .. 31; end record; ----------------------- -- DOEPTSIZ_Register -- ----------------------- subtype DOEPTSIZ1_XFRSIZ_Field is HAL.UInt19; subtype DOEPTSIZ1_PKTCNT_Field is HAL.UInt10; subtype DOEPTSIZ1_RXDPID_STUPCNT_Field is HAL.UInt2; -- device OUT endpoint-1 transfer size register type DOEPTSIZ_Register is record -- Transfer size XFRSIZ : DOEPTSIZ1_XFRSIZ_Field := 16#0#; -- Packet count PKTCNT : DOEPTSIZ1_PKTCNT_Field := 16#0#; -- Received data PID/SETUP packet count RXDPID_STUPCNT : DOEPTSIZ1_RXDPID_STUPCNT_Field := 16#0#; -- unspecified Reserved_31_31 : HAL.Bit := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for DOEPTSIZ_Register use record XFRSIZ at 0 range 0 .. 18; PKTCNT at 0 range 19 .. 28; RXDPID_STUPCNT at 0 range 29 .. 30; Reserved_31_31 at 0 range 31 .. 31; end record; ------------------------- -- FS_PCGCCTL_Register -- ------------------------- -- OTG_FS power and clock gating control register (OTG_FS_PCGCCTL) type FS_PCGCCTL_Register is record -- Stop PHY clock STPPCLK : Boolean := False; -- Gate HCLK GATEHCLK : Boolean := False; -- unspecified Reserved_2_3 : HAL.UInt2 := 16#0#; -- PHY Suspended PHYSUSP : Boolean := False; -- unspecified Reserved_5_31 : HAL.UInt27 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for FS_PCGCCTL_Register use record STPPCLK at 0 range 0 .. 0; GATEHCLK at 0 range 1 .. 1; Reserved_2_3 at 0 range 2 .. 3; PHYSUSP at 0 range 4 .. 4; Reserved_5_31 at 0 range 5 .. 31; end record; ----------------- -- Peripherals -- ----------------- type OTG_FS_GLOBAL_Disc is ( Device, Host); -- USB on the go full speed type OTG_FS_GLOBAL_Peripheral (Discriminent : OTG_FS_GLOBAL_Disc := Device) is record -- OTG_FS control and status register (OTG_FS_GOTGCTL) FS_GOTGCTL : FS_GOTGCTL_Register; -- OTG_FS interrupt register (OTG_FS_GOTGINT) FS_GOTGINT : FS_GOTGINT_Register; -- OTG_FS AHB configuration register (OTG_FS_GAHBCFG) FS_GAHBCFG : FS_GAHBCFG_Register; -- OTG_FS USB configuration register (OTG_FS_GUSBCFG) FS_GUSBCFG : FS_GUSBCFG_Register; -- OTG_FS reset register (OTG_FS_GRSTCTL) FS_GRSTCTL : FS_GRSTCTL_Register; -- OTG_FS core interrupt register (OTG_FS_GINTSTS) FS_GINTSTS : FS_GINTSTS_Register; -- OTG_FS interrupt mask register (OTG_FS_GINTMSK) FS_GINTMSK : FS_GINTMSK_Register; -- OTG_FS Receive FIFO size register (OTG_FS_GRXFSIZ) FS_GRXFSIZ : FS_GRXFSIZ_Register; -- OTG_FS non-periodic transmit FIFO/queue status register -- (OTG_FS_GNPTXSTS) FS_GNPTXSTS : FS_GNPTXSTS_Register; -- OTG_FS general core configuration register (OTG_FS_GCCFG) FS_GCCFG : FS_GCCFG_Register; -- core ID register FS_CID : HAL.Word; -- OTG_FS Host periodic transmit FIFO size register (OTG_FS_HPTXFSIZ) FS_HPTXFSIZ : FS_HPTXFSIZ_Register; -- OTG_FS device IN endpoint transmit FIFO size register -- (OTG_FS_DIEPTXF2) FS_DIEPTXF1 : FS_DIEPTXF_Register; -- OTG_FS device IN endpoint transmit FIFO size register -- (OTG_FS_DIEPTXF3) FS_DIEPTXF2 : FS_DIEPTXF_Register; -- OTG_FS device IN endpoint transmit FIFO size register -- (OTG_FS_DIEPTXF4) FS_DIEPTXF3 : FS_DIEPTXF_Register; case Discriminent is when Device => -- OTG_FS Receive status debug read(Device mode) FS_GRXSTSR_Device : FS_GRXSTSR_Device_Register; -- OTG_FS non-periodic transmit FIFO size register (Device mode) FS_GNPTXFSIZ_Device : FS_GNPTXFSIZ_Device_Register; when Host => -- OTG_FS Receive status debug read(Host mode) FS_GRXSTSR_Host : FS_GRXSTSR_Host_Register; -- OTG_FS non-periodic transmit FIFO size register (Host mode) FS_GNPTXFSIZ_Host : FS_GNPTXFSIZ_Host_Register; end case; end record with Unchecked_Union, Volatile; for OTG_FS_GLOBAL_Peripheral use record FS_GOTGCTL at 0 range 0 .. 31; FS_GOTGINT at 4 range 0 .. 31; FS_GAHBCFG at 8 range 0 .. 31; FS_GUSBCFG at 12 range 0 .. 31; FS_GRSTCTL at 16 range 0 .. 31; FS_GINTSTS at 20 range 0 .. 31; FS_GINTMSK at 24 range 0 .. 31; FS_GRXFSIZ at 36 range 0 .. 31; FS_GNPTXSTS at 44 range 0 .. 31; FS_GCCFG at 56 range 0 .. 31; FS_CID at 60 range 0 .. 31; FS_HPTXFSIZ at 256 range 0 .. 31; FS_DIEPTXF1 at 260 range 0 .. 31; FS_DIEPTXF2 at 264 range 0 .. 31; FS_DIEPTXF3 at 268 range 0 .. 31; FS_GRXSTSR_Device at 28 range 0 .. 31; FS_GNPTXFSIZ_Device at 40 range 0 .. 31; FS_GRXSTSR_Host at 28 range 0 .. 31; FS_GNPTXFSIZ_Host at 40 range 0 .. 31; end record; -- USB on the go full speed OTG_FS_GLOBAL_Periph : aliased OTG_FS_GLOBAL_Peripheral with Import, Address => OTG_FS_GLOBAL_Base; -- USB on the go full speed type OTG_FS_HOST_Peripheral is record -- OTG_FS host configuration register (OTG_FS_HCFG) FS_HCFG : FS_HCFG_Register; -- OTG_FS Host frame interval register HFIR : HFIR_Register; -- OTG_FS host frame number/frame time remaining register (OTG_FS_HFNUM) FS_HFNUM : FS_HFNUM_Register; -- OTG_FS_Host periodic transmit FIFO/queue status register -- (OTG_FS_HPTXSTS) FS_HPTXSTS : FS_HPTXSTS_Register; -- OTG_FS Host all channels interrupt register HAINT : HAINT_Register; -- OTG_FS host all channels interrupt mask register HAINTMSK : HAINTMSK_Register; -- OTG_FS host port control and status register (OTG_FS_HPRT) FS_HPRT : FS_HPRT_Register; -- OTG_FS host channel-0 characteristics register (OTG_FS_HCCHAR0) FS_HCCHAR0 : FS_HCCHAR_Register; -- OTG_FS host channel-0 interrupt register (OTG_FS_HCINT0) FS_HCINT0 : FS_HCINT_Register; -- OTG_FS host channel-0 mask register (OTG_FS_HCINTMSK0) FS_HCINTMSK0 : FS_HCINTMSK_Register; -- OTG_FS host channel-0 transfer size register FS_HCTSIZ0 : FS_HCTSIZ_Register; -- OTG_FS host channel-1 characteristics register (OTG_FS_HCCHAR1) FS_HCCHAR1 : FS_HCCHAR_Register; -- OTG_FS host channel-1 interrupt register (OTG_FS_HCINT1) FS_HCINT1 : FS_HCINT_Register; -- OTG_FS host channel-1 mask register (OTG_FS_HCINTMSK1) FS_HCINTMSK1 : FS_HCINTMSK_Register; -- OTG_FS host channel-1 transfer size register FS_HCTSIZ1 : FS_HCTSIZ_Register; -- OTG_FS host channel-2 characteristics register (OTG_FS_HCCHAR2) FS_HCCHAR2 : FS_HCCHAR_Register; -- OTG_FS host channel-2 interrupt register (OTG_FS_HCINT2) FS_HCINT2 : FS_HCINT_Register; -- OTG_FS host channel-2 mask register (OTG_FS_HCINTMSK2) FS_HCINTMSK2 : FS_HCINTMSK_Register; -- OTG_FS host channel-2 transfer size register FS_HCTSIZ2 : FS_HCTSIZ_Register; -- OTG_FS host channel-3 characteristics register (OTG_FS_HCCHAR3) FS_HCCHAR3 : FS_HCCHAR_Register; -- OTG_FS host channel-3 interrupt register (OTG_FS_HCINT3) FS_HCINT3 : FS_HCINT_Register; -- OTG_FS host channel-3 mask register (OTG_FS_HCINTMSK3) FS_HCINTMSK3 : FS_HCINTMSK_Register; -- OTG_FS host channel-3 transfer size register FS_HCTSIZ3 : FS_HCTSIZ_Register; -- OTG_FS host channel-4 characteristics register (OTG_FS_HCCHAR4) FS_HCCHAR4 : FS_HCCHAR_Register; -- OTG_FS host channel-4 interrupt register (OTG_FS_HCINT4) FS_HCINT4 : FS_HCINT_Register; -- OTG_FS host channel-4 mask register (OTG_FS_HCINTMSK4) FS_HCINTMSK4 : FS_HCINTMSK_Register; -- OTG_FS host channel-x transfer size register FS_HCTSIZ4 : FS_HCTSIZ_Register; -- OTG_FS host channel-5 characteristics register (OTG_FS_HCCHAR5) FS_HCCHAR5 : FS_HCCHAR_Register; -- OTG_FS host channel-5 interrupt register (OTG_FS_HCINT5) FS_HCINT5 : FS_HCINT_Register; -- OTG_FS host channel-5 mask register (OTG_FS_HCINTMSK5) FS_HCINTMSK5 : FS_HCINTMSK_Register; -- OTG_FS host channel-5 transfer size register FS_HCTSIZ5 : FS_HCTSIZ_Register; -- OTG_FS host channel-6 characteristics register (OTG_FS_HCCHAR6) FS_HCCHAR6 : FS_HCCHAR_Register; -- OTG_FS host channel-6 interrupt register (OTG_FS_HCINT6) FS_HCINT6 : FS_HCINT_Register; -- OTG_FS host channel-6 mask register (OTG_FS_HCINTMSK6) FS_HCINTMSK6 : FS_HCINTMSK_Register; -- OTG_FS host channel-6 transfer size register FS_HCTSIZ6 : FS_HCTSIZ_Register; -- OTG_FS host channel-7 characteristics register (OTG_FS_HCCHAR7) FS_HCCHAR7 : FS_HCCHAR_Register; -- OTG_FS host channel-7 interrupt register (OTG_FS_HCINT7) FS_HCINT7 : FS_HCINT_Register; -- OTG_FS host channel-7 mask register (OTG_FS_HCINTMSK7) FS_HCINTMSK7 : FS_HCINTMSK_Register; -- OTG_FS host channel-7 transfer size register FS_HCTSIZ7 : FS_HCTSIZ_Register; end record with Volatile; for OTG_FS_HOST_Peripheral use record FS_HCFG at 0 range 0 .. 31; HFIR at 4 range 0 .. 31; FS_HFNUM at 8 range 0 .. 31; FS_HPTXSTS at 16 range 0 .. 31; HAINT at 20 range 0 .. 31; HAINTMSK at 24 range 0 .. 31; FS_HPRT at 64 range 0 .. 31; FS_HCCHAR0 at 256 range 0 .. 31; FS_HCINT0 at 264 range 0 .. 31; FS_HCINTMSK0 at 268 range 0 .. 31; FS_HCTSIZ0 at 272 range 0 .. 31; FS_HCCHAR1 at 288 range 0 .. 31; FS_HCINT1 at 296 range 0 .. 31; FS_HCINTMSK1 at 300 range 0 .. 31; FS_HCTSIZ1 at 304 range 0 .. 31; FS_HCCHAR2 at 320 range 0 .. 31; FS_HCINT2 at 328 range 0 .. 31; FS_HCINTMSK2 at 332 range 0 .. 31; FS_HCTSIZ2 at 336 range 0 .. 31; FS_HCCHAR3 at 352 range 0 .. 31; FS_HCINT3 at 360 range 0 .. 31; FS_HCINTMSK3 at 364 range 0 .. 31; FS_HCTSIZ3 at 368 range 0 .. 31; FS_HCCHAR4 at 384 range 0 .. 31; FS_HCINT4 at 392 range 0 .. 31; FS_HCINTMSK4 at 396 range 0 .. 31; FS_HCTSIZ4 at 400 range 0 .. 31; FS_HCCHAR5 at 416 range 0 .. 31; FS_HCINT5 at 424 range 0 .. 31; FS_HCINTMSK5 at 428 range 0 .. 31; FS_HCTSIZ5 at 432 range 0 .. 31; FS_HCCHAR6 at 448 range 0 .. 31; FS_HCINT6 at 456 range 0 .. 31; FS_HCINTMSK6 at 460 range 0 .. 31; FS_HCTSIZ6 at 464 range 0 .. 31; FS_HCCHAR7 at 480 range 0 .. 31; FS_HCINT7 at 488 range 0 .. 31; FS_HCINTMSK7 at 492 range 0 .. 31; FS_HCTSIZ7 at 496 range 0 .. 31; end record; -- USB on the go full speed OTG_FS_HOST_Periph : aliased OTG_FS_HOST_Peripheral with Import, Address => OTG_FS_HOST_Base; -- USB on the go full speed type OTG_FS_DEVICE_Peripheral is record -- OTG_FS device configuration register (OTG_FS_DCFG) FS_DCFG : FS_DCFG_Register; -- OTG_FS device control register (OTG_FS_DCTL) FS_DCTL : FS_DCTL_Register; -- OTG_FS device status register (OTG_FS_DSTS) FS_DSTS : FS_DSTS_Register; -- OTG_FS device IN endpoint common interrupt mask register -- (OTG_FS_DIEPMSK) FS_DIEPMSK : FS_DIEPMSK_Register; -- OTG_FS device OUT endpoint common interrupt mask register -- (OTG_FS_DOEPMSK) FS_DOEPMSK : FS_DOEPMSK_Register; -- OTG_FS device all endpoints interrupt register (OTG_FS_DAINT) FS_DAINT : FS_DAINT_Register; -- OTG_FS all endpoints interrupt mask register (OTG_FS_DAINTMSK) FS_DAINTMSK : FS_DAINTMSK_Register; -- OTG_FS device VBUS discharge time register DVBUSDIS : DVBUSDIS_Register; -- OTG_FS device VBUS pulsing time register DVBUSPULSE : DVBUSPULSE_Register; -- OTG_FS device IN endpoint FIFO empty interrupt mask register DIEPEMPMSK : DIEPEMPMSK_Register; -- OTG_FS device control IN endpoint 0 control register -- (OTG_FS_DIEPCTL0) FS_DIEPCTL0 : FS_DIEPCTL0_Register; -- device endpoint-x interrupt register DIEPINT0 : DIEPINT_Register; -- device endpoint-0 transfer size register DIEPTSIZ0 : DIEPTSIZ0_Register; -- OTG_FS device IN endpoint transmit FIFO status register DTXFSTS0 : DTXFSTS_Register; -- OTG device endpoint-1 control register DIEPCTL1 : DIEPCTL1_Register; -- device endpoint-1 interrupt register DIEPINT1 : DIEPINT_Register; -- device endpoint-1 transfer size register DIEPTSIZ1 : DIEPTSIZ_Register; -- OTG_FS device IN endpoint transmit FIFO status register DTXFSTS1 : DTXFSTS_Register; -- OTG device endpoint-2 control register DIEPCTL2 : DIEPCTL_Register; -- device endpoint-2 interrupt register DIEPINT2 : DIEPINT_Register; -- device endpoint-2 transfer size register DIEPTSIZ2 : DIEPTSIZ_Register; -- OTG_FS device IN endpoint transmit FIFO status register DTXFSTS2 : DTXFSTS_Register; -- OTG device endpoint-3 control register DIEPCTL3 : DIEPCTL_Register; -- device endpoint-3 interrupt register DIEPINT3 : DIEPINT_Register; -- device endpoint-3 transfer size register DIEPTSIZ3 : DIEPTSIZ_Register; -- OTG_FS device IN endpoint transmit FIFO status register DTXFSTS3 : DTXFSTS_Register; -- device endpoint-0 control register DOEPCTL0 : DOEPCTL0_Register; -- device endpoint-0 interrupt register DOEPINT0 : DOEPINT_Register; -- device OUT endpoint-0 transfer size register DOEPTSIZ0 : DOEPTSIZ0_Register; -- device endpoint-1 control register DOEPCTL1 : DOEPCTL_Register; -- device endpoint-1 interrupt register DOEPINT1 : DOEPINT_Register; -- device OUT endpoint-1 transfer size register DOEPTSIZ1 : DOEPTSIZ_Register; -- device endpoint-2 control register DOEPCTL2 : DOEPCTL_Register; -- device endpoint-2 interrupt register DOEPINT2 : DOEPINT_Register; -- device OUT endpoint-2 transfer size register DOEPTSIZ2 : DOEPTSIZ_Register; -- device endpoint-3 control register DOEPCTL3 : DOEPCTL_Register; -- device endpoint-3 interrupt register DOEPINT3 : DOEPINT_Register; -- device OUT endpoint-3 transfer size register DOEPTSIZ3 : DOEPTSIZ_Register; end record with Volatile; for OTG_FS_DEVICE_Peripheral use record FS_DCFG at 0 range 0 .. 31; FS_DCTL at 4 range 0 .. 31; FS_DSTS at 8 range 0 .. 31; FS_DIEPMSK at 16 range 0 .. 31; FS_DOEPMSK at 20 range 0 .. 31; FS_DAINT at 24 range 0 .. 31; FS_DAINTMSK at 28 range 0 .. 31; DVBUSDIS at 40 range 0 .. 31; DVBUSPULSE at 44 range 0 .. 31; DIEPEMPMSK at 52 range 0 .. 31; FS_DIEPCTL0 at 256 range 0 .. 31; DIEPINT0 at 264 range 0 .. 31; DIEPTSIZ0 at 272 range 0 .. 31; DTXFSTS0 at 280 range 0 .. 31; DIEPCTL1 at 288 range 0 .. 31; DIEPINT1 at 296 range 0 .. 31; DIEPTSIZ1 at 304 range 0 .. 31; DTXFSTS1 at 312 range 0 .. 31; DIEPCTL2 at 320 range 0 .. 31; DIEPINT2 at 328 range 0 .. 31; DIEPTSIZ2 at 336 range 0 .. 31; DTXFSTS2 at 344 range 0 .. 31; DIEPCTL3 at 352 range 0 .. 31; DIEPINT3 at 360 range 0 .. 31; DIEPTSIZ3 at 368 range 0 .. 31; DTXFSTS3 at 376 range 0 .. 31; DOEPCTL0 at 768 range 0 .. 31; DOEPINT0 at 776 range 0 .. 31; DOEPTSIZ0 at 784 range 0 .. 31; DOEPCTL1 at 800 range 0 .. 31; DOEPINT1 at 808 range 0 .. 31; DOEPTSIZ1 at 816 range 0 .. 31; DOEPCTL2 at 832 range 0 .. 31; DOEPINT2 at 840 range 0 .. 31; DOEPTSIZ2 at 848 range 0 .. 31; DOEPCTL3 at 864 range 0 .. 31; DOEPINT3 at 872 range 0 .. 31; DOEPTSIZ3 at 880 range 0 .. 31; end record; -- USB on the go full speed OTG_FS_DEVICE_Periph : aliased OTG_FS_DEVICE_Peripheral with Import, Address => OTG_FS_DEVICE_Base; -- USB on the go full speed type OTG_FS_PWRCLK_Peripheral is record -- OTG_FS power and clock gating control register (OTG_FS_PCGCCTL) FS_PCGCCTL : FS_PCGCCTL_Register; end record with Volatile; for OTG_FS_PWRCLK_Peripheral use record FS_PCGCCTL at 0 range 0 .. 31; end record; -- USB on the go full speed OTG_FS_PWRCLK_Periph : aliased OTG_FS_PWRCLK_Peripheral with Import, Address => OTG_FS_PWRCLK_Base; end STM32_SVD.USB_OTG_FS;
msrLi/portingSources
Ada
1,008
adb
-- Copyright 2012-2014 Free Software Foundation, Inc. -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation; either version 3 of the License, or -- (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- -- You should have received a copy of the GNU General Public License -- along with this program. If not, see <http://www.gnu.org/licenses/>. With Classes; use Classes; procedure P is SP_Access : Shape_Access := new Circle'(My_Circle); DP_Access : Drawable_Access := new Circle'(My_Circle); SP_Array : Shape_Array := (others => S_Access); DP_Array : Drawable_Array := (others => D_Access); begin null; -- BREAK end P;
MinimSecure/unum-sdk
Ada
933
adb
-- Copyright 2013-2019 Free Software Foundation, Inc. -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation; either version 3 of the License, or -- (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- -- You should have received a copy of the GNU General Public License -- along with this program. If not, see <http://www.gnu.org/licenses/>. with Pck; use Pck; procedure Foo is begin while I <= 3 loop begin raise Constraint_Error; exception when others => null; end; I := I + 1; end loop; end Foo;
jrcarter/Ada_GUI
Ada
6,344
adb
-- Ada_GUI implementation based on Gnoga. Adapted 2021 -- -- -- GNOGA - The GNU Omnificent GUI for Ada -- -- -- -- G N O G A . S E R V E R . T E M P L A T E _ P A R S E R . S I M P L E -- -- -- -- B o d y -- -- -- -- -- -- Copyright (C) 2014 David Botton -- -- -- -- This library is free software; you can redistribute it and/or modify -- -- it under terms of the GNU General Public License as published by the -- -- Free Software Foundation; either version 3, or (at your option) any -- -- later version. This library is distributed in the hope that it will be -- -- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- As a special exception under Section 7 of GPL version 3, you are -- -- granted additional permissions described in the GCC Runtime Library -- -- Exception, version 3.1, as published by the Free Software Foundation. -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- As a special exception, if other files instantiate generics from this -- -- unit, or you link this unit with other files to produce an executable, -- -- this unit does not by itself cause the resulting executable to be -- -- covered by the GNU General Public License. This exception does not -- -- however invalidate any other reasons why the executable file might be -- -- covered by the GNU Public License. -- -- -- -- For more information please go to http://www.gnoga.com -- ------------------------------------------------------------------------------ with Ada.Text_IO; package body Ada_GUI.Gnoga.Server.Template_Parser.Simple is --------------- -- Load_View -- --------------- function Load_View (Name : String) return String is Empty_Data : View_Data; begin return Load_View (Name, Empty_Data); end Load_View; function Load_View (Name : String; Data_Map : Gnoga.Data_Map_Type; Var_Name : String := "data") return String is Data : View_Data; begin Data.Insert_Map (Data_Map); Data.Variable_Name (Var_Name); return Load_View (Name, Data); end Load_View; function Load_View (Name : String; Data : View_Data) return String is begin return Load_View (Name, Data_List => (1 => Data)); end Load_View; function Load_View (Name : String; Data_List : View_Data_Array) return String is use Ada.Strings.Unbounded; Error_Queue_Data : View_Data; Info_Queue_Data : View_Data; Parsed_File : Ada.Strings.Unbounded.Unbounded_String; procedure Load_File; procedure Parse_Data; procedure Replace_Values (D : View_Data); procedure Replace_In_String (S, M : String); procedure Load_File is use Ada.Text_IO; F : File_Type; begin Open (File => F, Mode => In_File, Name => Parse_Name (Name), Form => "shared=no"); while not End_Of_File (F) loop if Length (Parsed_File) > 0 then Parsed_File := Parsed_File & (Character'Val (10) & Get_Line (F)); else Parsed_File := To_Unbounded_String (Get_Line (F)); end if; end loop; Close (F); end Load_File; procedure Parse_Data is begin for i in Data_List'First .. Data_List'Last loop Replace_Values (Data_List (i)); end loop; Error_Queue_Data.Insert_Array (Error_Queue); Error_Queue_Data.Variable_Name ("gnoga_errors"); Replace_Values (Error_Queue_Data); Info_Queue_Data.Insert_Array (Info_Queue); Info_Queue_Data.Variable_Name ("gnoga_infos"); Replace_Values (Info_Queue_Data); end Parse_Data; procedure Replace_Values (D : View_Data) is use Gnoga.Data_Maps; use Gnoga.Maps_of_Data_Maps; Var_Name : constant String := To_String (D.Name); begin for C in D.String_Values.Iterate loop Replace_In_String ("@@" & Var_Name & "." & Key (C) & "@@", Element (C)); end loop; for M in D.Map_Values.Iterate loop for C in Element (M).Iterate loop Replace_In_String ("@@" & Var_Name & "." & Key (M) & "." & Key (C) & "@@", Element (C)); end loop; end loop; end Replace_Values; procedure Replace_In_String (S, M : String) is N : Natural := 0; begin loop N := Index (Parsed_File, S); if N > 0 then Replace_Slice (Parsed_File, N, N + S'Length - 1, M); end if; exit when N = 0; end loop; end Replace_In_String; begin Load_File; Parse_Data; return To_String (Parsed_File); end Load_View; end Ada_GUI.Gnoga.Server.Template_Parser.Simple;
persan/A-gst
Ada
14,753
ads
pragma Ada_2005; pragma Style_Checks (Off); pragma Warnings (Off); with Interfaces.C; use Interfaces.C; with glib; with glib.Values; with System; with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstobject_h; -- limited with GStreamer.GST_Low_Level.glib_2_0_glib_glist_h; with System; with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstplugin_h; with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpluginfeature_h; with glib; with GLIB; -- with GStreamer.GST_Low_Level.glibconfig_h; with Interfaces.C.Strings; package GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstregistry_h is -- unsupported macro: GST_TYPE_REGISTRY (gst_registry_get_type ()) -- arg-macro: function GST_REGISTRY (obj) -- return G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_REGISTRY, GstRegistry); -- arg-macro: function GST_IS_REGISTRY (obj) -- return G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_REGISTRY); -- arg-macro: function GST_REGISTRY_CLASS (klass) -- return G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_REGISTRY, GstRegistryClass); -- arg-macro: function GST_IS_REGISTRY_CLASS (klass) -- return G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_REGISTRY); -- arg-macro: function GST_REGISTRY_GET_CLASS (obj) -- return G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_REGISTRY, GstRegistryClass); -- arg-macro: procedure gst_default_registry_add_plugin (plugin) -- gst_registry_add_plugin (gst_registry_get_default(), plugin) -- arg-macro: procedure gst_default_registry_add_path (path) -- gst_registry_add_path (gst_registry_get_default(), path) -- arg-macro: procedure gst_default_registry_get_path_list () -- gst_registry_get_path_list (gst_registry_get_default()) -- arg-macro: procedure gst_default_registry_get_plugin_list () -- gst_registry_get_plugin_list (gst_registry_get_default()) -- arg-macro: procedure gst_default_registry_find_feature (name, type) -- gst_registry_find_feature (gst_registry_get_default(),name,type) -- arg-macro: procedure gst_default_registry_find_plugin (name) -- gst_registry_find_plugin (gst_registry_get_default(),name) -- arg-macro: procedure gst_default_registry_feature_filter (filter, first, user_data) -- gst_registry_feature_filter (gst_registry_get_default(),filter,first,user_data) -- arg-macro: procedure gst_default_registry_get_feature_list_cookie () -- gst_registry_get_feature_list_cookie (gst_registry_get_default()) -- GStreamer -- * Copyright (C) 1999,2000 Erik Walthinsen <[email protected]> -- * 2000 Wim Taymans <[email protected]> -- * -- * gstregistry.h: Header for registry handling -- * -- * This library is free software; you can redistribute it and/or -- * modify it under the terms of the GNU Library General Public -- * License as published by the Free Software Foundation; either -- * version 2 of the License, or (at your option) any later version. -- * -- * This library is distributed in the hope that it will be useful, -- * but WITHOUT ANY WARRANTY; without even the implied warranty of -- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- * Library General Public License for more details. -- * -- * You should have received a copy of the GNU Library General Public -- * License along with this library; if not, write to the -- * Free Software Foundation, Inc., 59 Temple Place - Suite 330, -- * Boston, MA 02111-1307, USA. -- type GstRegistry; type u_GstRegistry_u_gst_reserved_array is array (0 .. 0) of System.Address; --subtype GstRegistry is u_GstRegistry; -- gst/gstregistry.h:40 type GstRegistryClass; type u_GstRegistryClass_u_gst_reserved_array is array (0 .. 3) of System.Address; --subtype GstRegistryClass is u_GstRegistryClass; -- gst/gstregistry.h:41 -- skipped empty struct u_GstRegistryPrivate -- skipped empty struct GstRegistryPrivate --* -- * GstRegistry: -- * -- * Opaque #GstRegistry structure. -- type GstRegistry is record object : aliased GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstobject_h.GstObject; -- gst/gstregistry.h:50 plugins : access GStreamer.GST_Low_Level.glib_2_0_glib_glist_h.GList; -- gst/gstregistry.h:53 features : access GStreamer.GST_Low_Level.glib_2_0_glib_glist_h.GList; -- gst/gstregistry.h:54 paths : access GStreamer.GST_Low_Level.glib_2_0_glib_glist_h.GList; -- gst/gstregistry.h:56 cache_file : aliased int; -- gst/gstregistry.h:59 feature_hash : System.Address; -- gst/gstregistry.h:62 basename_hash : System.Address; -- gst/gstregistry.h:64 priv : System.Address; -- gst/gstregistry.h:66 u_gst_reserved : u_GstRegistry_u_gst_reserved_array; -- gst/gstregistry.h:69 end record; pragma Convention (C_Pass_By_Copy, GstRegistry); -- gst/gstregistry.h:49 --< private > -- FIXME move these elsewhere -- hash to speedup _lookup_feature_locked() -- hash to speedup _lookup --< private > type GstRegistryClass is record parent_class : aliased GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstobject_h.GstObjectClass; -- gst/gstregistry.h:73 plugin_added : access procedure (arg1 : access GstRegistry; arg2 : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstplugin_h.GstPlugin); -- gst/gstregistry.h:76 feature_added : access procedure (arg1 : access GstRegistry; arg2 : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpluginfeature_h.GstPluginFeature); -- gst/gstregistry.h:77 u_gst_reserved : u_GstRegistryClass_u_gst_reserved_array; -- gst/gstregistry.h:80 end record; pragma Convention (C_Pass_By_Copy, GstRegistryClass); -- gst/gstregistry.h:72 -- signals --< private > -- normal GObject stuff function gst_registry_get_type return GLIB.GType; -- gst/gstregistry.h:85 pragma Import (C, gst_registry_get_type, "gst_registry_get_type"); function gst_registry_get_default return access GstRegistry; -- gst/gstregistry.h:87 pragma Import (C, gst_registry_get_default, "gst_registry_get_default"); function gst_registry_scan_path (registry : access GstRegistry; path : access GLIB.gchar) return GLIB.gboolean; -- gst/gstregistry.h:89 pragma Import (C, gst_registry_scan_path, "gst_registry_scan_path"); procedure gst_registry_add_path (registry : access GstRegistry; path : access GLIB.gchar); -- gst/gstregistry.h:90 pragma Import (C, gst_registry_add_path, "gst_registry_add_path"); function gst_registry_get_path_list (registry : access GstRegistry) return access GStreamer.GST_Low_Level.glib_2_0_glib_glist_h.GList; -- gst/gstregistry.h:91 pragma Import (C, gst_registry_get_path_list, "gst_registry_get_path_list"); function gst_registry_add_plugin (registry : access GstRegistry; plugin : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstplugin_h.GstPlugin) return GLIB.gboolean; -- gst/gstregistry.h:93 pragma Import (C, gst_registry_add_plugin, "gst_registry_add_plugin"); procedure gst_registry_remove_plugin (registry : access GstRegistry; plugin : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstplugin_h.GstPlugin); -- gst/gstregistry.h:94 pragma Import (C, gst_registry_remove_plugin, "gst_registry_remove_plugin"); function gst_registry_add_feature (registry : access GstRegistry; feature : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpluginfeature_h.GstPluginFeature) return GLIB.gboolean; -- gst/gstregistry.h:95 pragma Import (C, gst_registry_add_feature, "gst_registry_add_feature"); procedure gst_registry_remove_feature (registry : access GstRegistry; feature : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpluginfeature_h.GstPluginFeature); -- gst/gstregistry.h:96 pragma Import (C, gst_registry_remove_feature, "gst_registry_remove_feature"); function gst_registry_get_plugin_list (registry : access GstRegistry) return access GStreamer.GST_Low_Level.glib_2_0_glib_glist_h.GList; -- gst/gstregistry.h:98 pragma Import (C, gst_registry_get_plugin_list, "gst_registry_get_plugin_list"); function gst_registry_plugin_filter (registry : access GstRegistry; filter : GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstplugin_h.GstPluginFilter; first : GLIB.gboolean; user_data : System.Address) return access GStreamer.GST_Low_Level.glib_2_0_glib_glist_h.GList; -- gst/gstregistry.h:99 pragma Import (C, gst_registry_plugin_filter, "gst_registry_plugin_filter"); function gst_registry_feature_filter (registry : access GstRegistry; filter : GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpluginfeature_h.GstPluginFeatureFilter; first : GLIB.gboolean; user_data : System.Address) return access GStreamer.GST_Low_Level.glib_2_0_glib_glist_h.GList; -- gst/gstregistry.h:103 pragma Import (C, gst_registry_feature_filter, "gst_registry_feature_filter"); function gst_registry_get_feature_list (registry : access GstRegistry; c_type : GLIB.GType) return access GStreamer.GST_Low_Level.glib_2_0_glib_glist_h.GList; -- gst/gstregistry.h:107 pragma Import (C, gst_registry_get_feature_list, "gst_registry_get_feature_list"); function gst_registry_get_feature_list_by_plugin (registry : access GstRegistry; name : access GLIB.gchar) return access GStreamer.GST_Low_Level.glib_2_0_glib_glist_h.GList; -- gst/gstregistry.h:109 pragma Import (C, gst_registry_get_feature_list_by_plugin, "gst_registry_get_feature_list_by_plugin"); function gst_registry_get_feature_list_cookie (registry : access GstRegistry) return GLIB.guint32; -- gst/gstregistry.h:110 pragma Import (C, gst_registry_get_feature_list_cookie, "gst_registry_get_feature_list_cookie"); function gst_registry_find_plugin (registry : access GstRegistry; name : access GLIB.gchar) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstplugin_h.GstPlugin; -- gst/gstregistry.h:112 pragma Import (C, gst_registry_find_plugin, "gst_registry_find_plugin"); function gst_registry_find_feature (registry : access GstRegistry; name : access GLIB.gchar; c_type : GLIB.GType) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpluginfeature_h.GstPluginFeature; -- gst/gstregistry.h:113 pragma Import (C, gst_registry_find_feature, "gst_registry_find_feature"); function gst_registry_lookup (registry : access GstRegistry; filename : Interfaces.C.Strings.chars_ptr) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstplugin_h.GstPlugin; -- gst/gstregistry.h:115 pragma Import (C, gst_registry_lookup, "gst_registry_lookup"); function gst_registry_lookup_feature (registry : access GstRegistry; name : Interfaces.C.Strings.chars_ptr) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpluginfeature_h.GstPluginFeature; -- gst/gstregistry.h:116 pragma Import (C, gst_registry_lookup_feature, "gst_registry_lookup_feature"); -- These are only here because at some point they were in a public header -- * (even though they should have been private) and we can't really remove -- * them now (FIXME: 0.11). They don't do anything other than return FALSE. function gst_registry_xml_read_cache (registry : access GstRegistry; location : Interfaces.C.Strings.chars_ptr) return GLIB.gboolean; -- gst/gstregistry.h:122 pragma Import (C, gst_registry_xml_read_cache, "gst_registry_xml_read_cache"); function gst_registry_xml_write_cache (registry : access GstRegistry; location : Interfaces.C.Strings.chars_ptr) return GLIB.gboolean; -- gst/gstregistry.h:123 pragma Import (C, gst_registry_xml_write_cache, "gst_registry_xml_write_cache"); -- convenience defines for the default registry --* -- * gst_default_registry_add_plugin: -- * @plugin: (transfer full): the plugin to add -- * -- * Add the plugin to the default registry. -- * The plugin-added signal will be emitted. -- * -- * Returns: TRUE on success. -- --* -- * gst_default_registry_add_path: -- * @path: the path to add to the registry -- * -- * Add the given path to the default registry. The syntax of the -- * path is specific to the registry. If the path has already been -- * added, do nothing. -- --* -- * gst_default_registry_get_path_list: -- * -- * Get the list of paths for the default registry. -- * -- * Returns: (transfer container) (element-type char*): a #GList of paths as -- * strings. g_list_free() after use. -- --* -- * gst_default_registry_get_plugin_list: -- * -- * Get a copy of all plugins registered in the default registry. -- * -- * Returns: (transfer full) (element-type Gst.Plugin): a copy of the list. -- * Free after use. -- --* -- * gst_default_registry_find_feature: -- * @name: the pluginfeature name to find -- * @type: the pluginfeature type to find -- * -- * Find the pluginfeature with the given name and type in the default registry. -- * -- * Returns: (transfer full): the pluginfeature with the given name and type or -- * NULL if the plugin was not found. -- --* -- * gst_default_registry_find_plugin: -- * @name: the plugin name to find -- * -- * Find the plugin with the given name in the default registry. -- * The plugin will be reffed; caller is responsible for unreffing. -- * -- * Returns: (transfer full): The plugin with the given name or NULL if the -- * plugin was not found. -- --* -- * gst_default_registry_feature_filter: -- * @filter: the filter to use -- * @first: only return first match -- * @user_data: user data passed to the filter function -- * -- * Runs a filter against all features of the plugins in the default registry -- * and returns a GList with the results. -- * If the first flag is set, only the first match is -- * returned (as a list with a single object). -- * -- * Returns: (transfer full) (element-type Gst.PluginFeature): a #GList of -- * plugin features, gst_plugin_feature_list_free after use. -- --* -- * gst_default_registry_get_feature_list_cookie: -- * -- * Returns the default registrys feature list cookie. This changes -- * every time a feature is added or removed from the registry. -- * -- * Returns: the feature list cookie. -- * -- * Since: 0.10.26 -- function gst_default_registry_check_feature_version (feature_name : access GLIB.gchar; min_major : GLIB.guint; min_minor : GLIB.guint; min_micro : GLIB.guint) return GLIB.gboolean; -- gst/gstregistry.h:229 pragma Import (C, gst_default_registry_check_feature_version, "gst_default_registry_check_feature_version"); end GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstregistry_h;
reznikmm/spawn
Ada
438
adb
-- -- Copyright (C) 2023, AdaCore -- -- SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -- package body Spawn.Windows_API is ---------------- -- MAKELANGID -- ---------------- function MAKELANGID (P : DWORD; S : DWORD) return DWORD is use type System.Win32.DWORD; begin return DWORD (Interfaces.Shift_Left (Interfaces.Unsigned_32 (S), 10)) or P; end MAKELANGID; end Spawn.Windows_API;
AdaCore/libadalang
Ada
259
adb
procedure Test_Binop_Res is package P is type A is private; private type A is range 1 .. 20; end P; package body P is C : A := 12; B : A := 12 * C; pragma Test_Statement; end P; begin null; end Test_Binop_Res;
emilybache/Parrot-Refactoring-Kata
Ada
589
adb
with AUnit.Reporter.Text; with AUnit.Run; with AUnit.Simple_Test_Cases; use AUnit.Simple_Test_Cases; with AUnit.Test_Suites; use AUnit.Test_Suites; with Parrot.Tests; procedure Run_Tests is function Collect_Tests return Access_Test_Suite is Suite : constant Access_Test_Suite := new Test_Suite; begin Suite.Add_Test (Test_Case_Access'(new Parrot.Tests.Parrot_Test)); return Suite; end Collect_Tests; procedure Runner is new AUnit.Run.Test_Runner (Collect_Tests); Reporter : AUnit.Reporter.Text.Text_Reporter; begin Runner (Reporter); end Run_Tests;
Sawchord/Ada_Drivers_Library
Ada
8,035
adb
------------------------------------------------------------------------------ -- -- -- Copyright (C) 2016-2017, AdaCore -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions are -- -- met: -- -- 1. Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- 2. Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in -- -- the documentation and/or other materials provided with the -- -- distribution. -- -- 3. Neither the name of the copyright holder nor the names of its -- -- contributors may be used to endorse or promote products derived -- -- from this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -- -- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -- -- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -- -- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -- -- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ with Last_Chance_Handler; pragma Unreferenced (Last_Chance_Handler); -- with Output_Utils; use Output_Utils; with Ada.Real_Time; use Ada.Real_Time; with HAL; use HAL; with HAL.SPI; use HAL.SPI; with HAL.UART; use HAL.UART; with HAL.I2C; use HAL.I2C; with STM32.Device; use STM32.Device; with STM32; use STM32; with STM32.GPIO; use STM32.GPIO; with STM32.SPI; use STM32.SPI; with STM32.I2C; use STM32.I2C; with STM32.USARTs; use STM32.USARTs; with STM32_SVD.I2C; with BMP280; use BMP280; with BMP280.SPI; with BMP280.I2C; with System.Machine_Code; procedure Demo_BMP280 is Clk_Pin : constant GPIO_Point := PB3; Miso_Pin : constant GPIO_Point := PB4; Mosi_Pin : constant GPIO_Point := PB5; SPI_Pins : constant GPIO_Points := (Clk_Pin, Miso_Pin, Mosi_Pin); Cs_Pin : GPIO_Point := PD7; Sca_Pin : GPIO_Point := PB10; Scl_Pin : GPIO_Point := PB11; --Sca_Pin : GPIO_Point := PC9; --Scl_Pin : GPIO_Point := PA8; I2C_Pins : constant GPIO_Points := (Sca_Pin, Scl_Pin); UART_Pins : constant GPIO_Points := (PA2, PA3); procedure Initialize_UART is begin Enable_Clock (UART_Pins); Enable_Clock (USART_2); Configure_IO(UART_Pins, (Mode => Mode_AF, AF => GPIO_AF_USART1_7, Resistors => Pull_Up, AF_Speed => Speed_50MHz, AF_Output_Type => Push_Pull)); Disable (USART_2); USART_2.Set_Baud_Rate(115200); USART_2.Set_Mode(Tx_Rx_Mode); USART_2.Set_Word_Length(Word_Length_9); USART_2.Set_Parity(No_Parity); USART_2.Set_Flow_Control(No_Flow_Control); Enable (USART_2); end Initialize_UART; procedure Initialize_I2C is begin Enable_Clock (I2C_Pins); Enable_Clock (I2C_2); Configure_IO(I2C_Pins, (Mode => Mode_AF, AF => GPIO_AF_I2C1_4, Resistors => Pull_Up, AF_Speed => Speed_50MHz, AF_Output_Type => Open_Drain)); Configure(I2C_2, ( Clock_Speed => 100_000, Mode => I2C_Mode, Duty_Cycle => DutyCycle_2, Addressing_Mode => Addressing_Mode_7bit, Own_Address => 0, others => <>)); I2C_2.Set_State (True); end Initialize_I2C; procedure Initialize_SPI is begin Enable_Clock (SPI_1); Enable_Clock (SPI_Pins); Enable_Clock (Cs_Pin); Configure_IO(SPI_Pins, (Mode => Mode_AF, AF => GPIO_AF_SPI1_5, Resistors => Pull_Up, AF_Speed => Speed_50MHz, AF_Output_Type => Push_Pull)); Configure_IO(Cs_Pin, (Mode => Mode_Out, Output_Type => Push_Pull, Speed => Speed_50MHz, Resistors => Floating)); Disable (SPI_1); Configure (SPI_1, ( Direction => D2Lines_FullDuplex, Mode => Master, Data_Size => Data_Size_8b, Clock_Polarity => Low, Clock_Phase => P1Edge, Slave_Management => Software_Managed, Baud_Rate_Prescaler => BRP_256, First_Bit => MSB, CRC_Poly => 0 )); Enable (SPI_1); end Initialize_SPI; procedure Await_Tx is begin while not USART_2.Tx_Ready loop null; end loop; end Await_Tx; procedure Put (s : String) is begin for I in s'First..s'Last loop Await_Tx; USART_2.Transmit(Uint9(Character'Pos(s(I)))); end loop; end Put; procedure New_Line is begin Await_Tx; USART_2.Transmit (UInt9(13)); Await_Tx; USART_2.Transmit (UInt9(10)); end New_Line; procedure Put_Line(s : String) is begin Put(s); New_Line; end Put_Line; function Height_From_Pressure(P : Float) return Float is begin return (101300.0 - P) / 11.7; end Height_From_Pressure; T : Time := Clock; Count : Integer := 0; package BMP280_SPI is new BMP280.SPI (BMP280_Device); Sensor1 : BMP280_SPI.SPI_BMP280_Device (SPI_1'Access, PD7'Access); package BMP280_I2C is new BMP280.I2C (BMP280_Device); Sensor2 : BMP280_I2C.I2C_BMP280_Device (I2C_2'Access, BMP280_I2C.Low); IData : SPI_Data_8b := (16#D0#, 0); begin Initialize_UART; T := T + Milliseconds (50); delay until T; Initialize_I2C; Initialize_SPI; Cs_Pin.Set; T := T + Milliseconds (50); delay until T; -- Configure the pressure sensor declare Conf : BMP280_Configuration := (Standby_Time => ms125, Temperature_Oversampling => x16, Pressure_Oversampling => x16, Filter_Coefficient => 0); begin Sensor1.Configure(Conf); Sensor2.Configure(Conf); null; end; loop declare Values : BMP280_Values_Float; begin Sensor1.Read_Values_Float(Values); Put_Line("Temp1: " & Values.Temperature'Img); Put_Line("Pres1: " & Values.Pressure'Img); Sensor2.Read_Values_Float(Values); Put_Line("Temp2: " & Values.Temperature'Img); Put_Line("Pres2: " & Values.Pressure'Img); --Put_Line("Height: " & Height_From_Pressure(Values.Pressure)'Img); null; end; Put_Line ("Hello " & Count'Img); Count := Count + 1; T := T + Milliseconds (200); delay until T; end loop; end Demo_BMP280;
DrenfongWong/tkm-rpc
Ada
1,413
ads
with Tkmrpc.Types; with Tkmrpc.Operations.Ike; package Tkmrpc.Response.Ike.Isa_Sign is Data_Size : constant := 388; type Data_Type is record Signature : Types.Signature_Type; end record; for Data_Type use record Signature at 0 range 0 .. (388 * 8) - 1; end record; for Data_Type'Size use Data_Size * 8; Padding_Size : constant := Response.Body_Size - Data_Size; subtype Padding_Range is Natural range 1 .. Padding_Size; subtype Padding_Type is Types.Byte_Sequence (Padding_Range); type Response_Type is record Header : Response.Header_Type; Data : Data_Type; Padding : Padding_Type; end record; for Response_Type use record Header at 0 range 0 .. (Response.Header_Size * 8) - 1; Data at Response.Header_Size range 0 .. (Data_Size * 8) - 1; Padding at Response.Header_Size + Data_Size range 0 .. (Padding_Size * 8) - 1; end record; for Response_Type'Size use Response.Response_Size * 8; Null_Response : constant Response_Type := Response_Type' (Header => Response.Header_Type'(Operation => Operations.Ike.Isa_Sign, Result => Results.Invalid_Operation, Request_Id => 0), Data => Data_Type'(Signature => Types.Null_Signature_Type), Padding => Padding_Type'(others => 0)); end Tkmrpc.Response.Ike.Isa_Sign;
ytomino/zlib-ada
Ada
8,920
ads
with Ada.Finalization; with Ada.IO_Exceptions; with Ada.Streams; private with C.zconf; private with C.zlib; package zlib is pragma Preelaborate; pragma Linker_Options ("-lz"); function Version return String; type Stream_Mode is (Deflating, Inflating); type Stream is limited private; -- subtype Open_Stream is Stream -- with -- Dynamic_Predicate => Is_Open (Open_Stream), -- Predicate_Failure => raise Status_Error; -- subtype Deflating_Stream is Open_Stream -- with -- Dynamic_Predicate => Mode (Deflating) = Deflating, -- Predicate_Failure => raise Mode_Error; -- subtype Inflating_Stream is Open_Stream -- with -- Dynamic_Predicate => Mode (Inflating_Stream) = Inflating, -- Predicate_Failure => raise Mode_Error; -- level type Compression_Level is range -1 .. 9; No_Compression : constant Compression_Level; Best_Speed : constant Compression_Level; Best_Compression : constant Compression_Level; Default_Compression : constant Compression_Level; -- method package Compression_Methods is type Compression_Method is (Deflated); private for Compression_Method'Size use C.signed_int'Size; for Compression_Method use (Deflated => C.zlib.Z_DEFLATED); end Compression_Methods; type Compression_Method is new Compression_Methods.Compression_Method; -- windowBits type Window_Bits is range 8 .. 15; Default_Window_Bits : constant Window_Bits := 15; type Inflation_Header is (None, Default, GZip, Auto); subtype Deflation_Header is Inflation_Header range None .. GZip; -- memLevel type Memory_Level is range 1 .. 9; Default_Memory_Level : constant Memory_Level := 8; -- stragegy package Strategies is type Strategy is ( Default_Strategy, Filtered, Huffman_Only, RLE, Fixed); private for Strategy'Size use C.signed_int'Size; for Strategy use ( Default_Strategy => C.zlib.Z_DEFAULT_STRATEGY, Filtered => C.zlib.Z_FILTERED, Huffman_Only => C.zlib.Z_HUFFMAN_ONLY, RLE => C.zlib.Z_RLE, Fixed => C.zlib.Z_FIXED); end Strategies; type Strategy is new Strategies.Strategy; function Deflate_Init ( Level : Compression_Level := Default_Compression; Method : Compression_Method := Deflated; Window_Bits : zlib.Window_Bits := Default_Window_Bits; Header : Deflation_Header := Default; Memory_Level : zlib.Memory_Level := Default_Memory_Level; Strategy : zlib.Strategy := Default_Strategy) return Stream; procedure Deflate ( Stream : in out zlib.Stream; -- Deflating_Stream In_Item : in Ada.Streams.Stream_Element_Array; In_Last : out Ada.Streams.Stream_Element_Offset; Out_Item : out Ada.Streams.Stream_Element_Array; Out_Last : out Ada.Streams.Stream_Element_Offset; Finish : in Boolean; Finished : out Boolean); procedure Deflate ( Stream : in out zlib.Stream; -- Deflating_Stream In_Item : in Ada.Streams.Stream_Element_Array; In_Last : out Ada.Streams.Stream_Element_Offset; Out_Item : out Ada.Streams.Stream_Element_Array; Out_Last : out Ada.Streams.Stream_Element_Offset); procedure Deflate ( Stream : in out zlib.Stream; -- Deflating_Stream Out_Item : out Ada.Streams.Stream_Element_Array; Out_Last : out Ada.Streams.Stream_Element_Offset; Finish : in Boolean; Finished : out Boolean); function Inflate_Init ( Window_Bits : zlib.Window_Bits := Default_Window_Bits; Header : Inflation_Header := Auto) return Stream; procedure Inflate ( Stream : in out zlib.Stream; -- Inflating_Stream In_Item : in Ada.Streams.Stream_Element_Array; In_Last : out Ada.Streams.Stream_Element_Offset; Out_Item : out Ada.Streams.Stream_Element_Array; Out_Last : out Ada.Streams.Stream_Element_Offset; Finish : in Boolean; Finished : out Boolean); procedure Inflate ( Stream : in out zlib.Stream; -- Inflating_Stream In_Item : in Ada.Streams.Stream_Element_Array; In_Last : out Ada.Streams.Stream_Element_Offset; Out_Item : out Ada.Streams.Stream_Element_Array; Out_Last : out Ada.Streams.Stream_Element_Offset); procedure Inflate ( Stream : in out zlib.Stream; -- Inflating_Stream Out_Item : out Ada.Streams.Stream_Element_Array; Out_Last : out Ada.Streams.Stream_Element_Offset; Finish : in Boolean; Finished : out Boolean); procedure Close (Stream : in out zlib.Stream); function Is_Open (Stream : zlib.Stream) return Boolean; function Mode ( Stream : zlib.Stream) -- Open_Stream return Stream_Mode; function Total_In ( Stream : zlib.Stream) -- Open_Stream return Ada.Streams.Stream_Element_Count; function Total_Out ( Stream : zlib.Stream) -- Open_Stream return Ada.Streams.Stream_Element_Count; Status_Error : exception renames Ada.IO_Exceptions.Status_Error; Mode_Error : exception renames Ada.IO_Exceptions.Mode_Error; Use_Error : exception renames Ada.IO_Exceptions.Use_Error; Data_Error : exception renames Ada.IO_Exceptions.Data_Error; -- compatibility with ZLib.Ada. subtype Count is Ada.Streams.Stream_Element_Count; subtype Filter_Type is Stream; subtype Header_Type is Inflation_Header; subtype Strategy_Type is Strategy; subtype Flush_Mode is Boolean; function No_Flush return Boolean renames False; function Finish return Boolean renames True; procedure Deflate_Init ( Filter : in out Filter_Type; Level : in Compression_Level := Default_Compression; Method : in Compression_Method := Deflated; Window_Bits : in zlib.Window_Bits := Default_Window_Bits; Header : in Deflation_Header := Default; Memory_Level : in zlib.Memory_Level := Default_Memory_Level; Strategy : in Strategy_Type := Default_Strategy); procedure Inflate_Init ( Filter : in out Filter_Type; Window_Bits : in zlib.Window_Bits := Default_Window_Bits; Header : in Header_Type := Auto); procedure Translate ( Filter : in out Filter_Type; In_Data : in Ada.Streams.Stream_Element_Array; In_Last : out Ada.Streams.Stream_Element_Offset; Out_Data : out Ada.Streams.Stream_Element_Array; Out_Last : out Ada.Streams.Stream_Element_Offset; Flush : in Flush_Mode); generic with procedure Data_In ( Item : out Ada.Streams.Stream_Element_Array; Last : out Ada.Streams.Stream_Element_Offset); with procedure Data_Out ( Item : in Ada.Streams.Stream_Element_Array); procedure Generic_Translate (Filter : in out Filter_Type); generic with procedure Write (Item : in Ada.Streams.Stream_Element_Array); procedure Write ( Filter : in out Filter_Type; Item : in Ada.Streams.Stream_Element_Array; Flush : in Flush_Mode := No_Flush); generic with procedure Read ( Item : out Ada.Streams.Stream_Element_Array; Last : out Ada.Streams.Stream_Element_Offset); Buffer : in out Ada.Streams.Stream_Element_Array; Rest_First, Rest_Last : in out Ada.Streams.Stream_Element_Offset; procedure Read ( Filter : in out Filter_Type; Item : out Ada.Streams.Stream_Element_Array; Last : out Ada.Streams.Stream_Element_Offset; Flush : in Flush_Mode := No_Flush); private use type Ada.Streams.Stream_Element_Offset; pragma Compile_Time_Error ( Window_Bits'Last /= C.zconf.MAX_WBITS, "MAX_WBITS is mismatch"); pragma Compile_Time_Error ( Memory_Level'Last /= C.zconf.MAX_MEM_LEVEL, "MAX_MEM_LEVEL is mismatch"); type Finalize_Type is access function (strm : access C.zlib.z_stream) return C.signed_int with Convention => C; type Non_Controlled_Stream is record Z_Stream : aliased C.zlib.z_stream; Finalize : Finalize_Type; Is_Open : Boolean; Mode : Stream_Mode; Stream_End : Boolean; end record; pragma Suppress_Initialization (Non_Controlled_Stream); package Controlled is type Stream is limited private; function Constant_Reference (Object : zlib.Stream) return not null access constant Non_Controlled_Stream; function Reference (Object : in out zlib.Stream) return not null access Non_Controlled_Stream; pragma Inline (Constant_Reference); pragma Inline (Reference); private type Stream is limited new Ada.Finalization.Limited_Controlled with record Variable_View : not null access Stream := Stream'Unchecked_Access; Data : aliased Non_Controlled_Stream := (Is_Open => False, others => <>); end record; overriding procedure Finalize (Object : in out Stream); end Controlled; type Stream is new Controlled.Stream; No_Compression : constant Compression_Level := C.zlib.Z_NO_COMPRESSION; Best_Speed : constant Compression_Level := C.zlib.Z_BEST_SPEED; Best_Compression : constant Compression_Level := C.zlib.Z_BEST_COMPRESSION; Default_Compression : constant Compression_Level := C.zlib.Z_DEFAULT_COMPRESSION; procedure Deflate_Or_Inflate ( Stream : in out zlib.Stream; In_Item : in Ada.Streams.Stream_Element_Array; In_Last : out Ada.Streams.Stream_Element_Offset; Out_Item : out Ada.Streams.Stream_Element_Array; Out_Last : out Ada.Streams.Stream_Element_Offset; Finish : in Boolean; Finished : out Boolean); end zlib;
Asier98/Control_IO_STM32F446
Ada
528
ads
with STM32.GPIO; use STM32.GPIO; with HAL.GPIO; package Digital is type Digital_Mode is (Input, Output); -- Input or Output type Signal_Mode is (HIGH,LOW); -- HIGH or LOW procedure Configure_Pin(Pin : GPIO_Point; Mode : Digital_Mode); -- Configure a channel as Output or Input procedure Set_Signal(Pin : GPIO_Point; Mode : Signal_Mode); -- Set a HIGH or LOW signal for a given channel function Read_Signal(Pin : GPIO_Point) return Signal_Mode; -- Read the given channel signal end Digital;
stcarrez/ada-mail
Ada
8,678
adb
----------------------------------------------------------------------- -- mail-parsers -- Parse mail content -- Copyright (C) 2020 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.IO_Exceptions; with Ada.Strings.Equal_Case_Insensitive; with Ada.Strings.Fixed; with Util.Strings.Builders; with Util.Encoders.Quoted_Printable; package body Mail.Parsers is use Ada.Strings; use Ada.Strings.Unbounded; use Util.Strings.Builders; use Util.Encoders.Quoted_Printable; HEADER_NAME_LENGTH : constant := 128; HEADER_CONTENT_LENGTH : constant := 512; function Is_Space (C : in Character) return Boolean is (C = ' ' or C = ASCII.HT); procedure Read_Line (Parser : in out Parser_Type) is C : Character; Pos : Natural := 0; begin while not Parser.Reader.Is_Eof and Pos < Parser.Line'Last loop Parser.Reader.Read (C); exit when C = ASCII.LF; if C /= ASCII.CR then Pos := Pos + 1; Parser.Line (Pos) := C; end if; end loop; Parser.Length := Pos; exception when Ada.IO_Exceptions.Data_Error => Parser.Length := Pos; Parser.Is_Eof := True; return; end Read_Line; procedure Parse_From (Parser : in out Parser_Type) is begin Parser.Read_Line; Parser.State := IN_HEADER; Parser.Content_Encoding := Null_Unbounded_String; end Parse_From; procedure Set_State (Parser : in out Parser_Type; State : in Parser_State) is begin if State /= IN_BODY then Parser.Content_Encoding := Null_Unbounded_String; Parser.State := State; elsif Equal_Case_Insensitive (To_String (Parser.Content_Encoding), "quoted-printable") then Parser.State := IN_BODY_QUOTED_PRINTABLE; elsif Fixed.Index (To_String (Parser.Content_Type), "multipart/") > 0 then Parser.State := IN_BODY_PART; else Parser.State := IN_BODY; end if; end Set_State; procedure Parse_Header (Parser : in out Parser_Type; Process : access Processor'Class) is C : Character; Pos : Natural; begin Parser.Read_Line; loop if Parser.Length = 0 then Parser.Set_State (IN_BODY); return; end if; C := Parser.Line (1); if not (C in 'A' .. 'Z') then Parser.Set_State (IN_BODY); return; end if; Pos := Util.Strings.Index (Parser.Line (1 .. Parser.Length), ':'); if Pos = 0 then Parser.Set_State (IN_BODY); return; end if; declare Header : Util.Strings.Builders.Builder (HEADER_NAME_LENGTH); Content : Util.Strings.Builders.Builder (HEADER_CONTENT_LENGTH); begin Append (Header, Parser.Line (1 .. Pos - 1)); Pos := Pos + 1; while Pos <= Parser.Length and then Is_Space (Parser.Line (Pos)) loop Pos := Pos + 1; end loop; Append (Content, Parser.Line (Pos .. Parser.Length)); -- Header continues on next line(s). loop Parser.Read_Line; exit when Parser.Length = 0 or else not Is_Space (Parser.Line (1)); Pos := 2; while Pos <= Parser.Length and then Is_Space (Parser.Line (Pos)) loop Pos := Pos + 1; end loop; Append (Content, Parser.Line (Pos .. Parser.Length)); end loop; declare Name : constant String := To_Array (Header); Data : constant String := To_Array (Content); begin if Ada.Strings.Equal_Case_Insensitive (Name, "Content-Type") then Parser.Content_Type := To_Unbounded_String (Data); elsif Ada.Strings.Equal_Case_Insensitive (Name, "Content-Transfer-Encoding") then Parser.Content_Encoding := To_Unbounded_String (Data); end if; Process.Read_Header (Name, Data); end; end; end loop; end Parse_Header; procedure Parse_Body (Parser : in out Parser_Type; Process : access Processor'Class) is Empty_Line : Boolean := False; begin while not Parser.Is_Eof loop Parser.Read_Line; if Empty_Line and then Parser.Length > 10 and then Parser.Line (1 .. 7) = "From - " then Parser.State := IN_FROM; return; end if; if Empty_Line then Process.Read_Body (""); end if; if Parser.Length = 0 then Empty_Line := True; else Empty_Line := False; if Parser.Length > 2 and then Parser.Line (1 .. 2) = "--" then null; end if; if Parser.State = IN_BODY_QUOTED_PRINTABLE then Process.Read_Body (Decode (Parser.Line (1 .. Parser.Length))); else Process.Read_Body (Parser.Line (1 .. Parser.Length)); end if; end if; end loop; end Parse_Body; function Get_Boundary (Parser : in Parser_Type) return String is Content_Type : constant String := To_String (Parser.Content_Type); Pos : Natural := Ada.Strings.Fixed.Index (Content_Type, "boundary="); Last : Natural; begin if Pos = 0 then return ""; end if; Pos := Pos + 9; if Pos > Content_Type'Last - 6 then return ""; end if; if Content_Type (Pos) = '"' then Last := Ada.Strings.Fixed.Index (Content_Type, """", Pos + 1); if Last = 0 then return ""; end if; return "--" & Content_Type (Pos + 1 .. Last - 1); else Last := Ada.Strings.Fixed.Index (Content_Type, " ", Pos); if Last = 0 then Last := Content_Type'Last; end if; return "--" & Content_Type (Pos .. Last); end if; end Get_Boundary; procedure Parse_Body_Part (Parser : in out Parser_Type; Process : access Processor'Class) is Boundary : constant String := Parser.Get_Boundary; begin while not Parser.Is_Eof loop Parser.Read_Line; exit when Parser.Line (1 .. Parser.Length) = Boundary; end loop; loop Parser.Set_State (IN_HEADER); while not Parser.Is_Eof loop Parser.Parse_Header (Process); exit when Parser.State /= IN_HEADER; end loop; while not Parser.Is_Eof loop Parser.Read_Line; exit when Parser.Line (1 .. Parser.Length) = Boundary; if Parser.Line (1 .. Parser.Length) = Boundary & "--" then Parser.Set_State (IN_START); return; end if; if Parser.State = IN_BODY_QUOTED_PRINTABLE then Process.Read_Body (Decode (Parser.Line (1 .. Parser.Length))); else Process.Read_Body (Parser.Line (1 .. Parser.Length)); end if; end loop; exit when Parser.Is_Eof; end loop; end Parse_Body_Part; procedure Parse (Parser : in out Parser_Type; Stream : in Util.Streams.Input_Stream_Access; Process : access Processor'Class) is begin Parser.Reader.Initialize (Stream, 128 * 1024); loop case Parser.State is when IN_START | IN_FROM => Parser.Parse_From; Process.New_Mail; when IN_HEADER => Parser.Parse_Header (Process); when IN_BODY | IN_BODY_QUOTED_PRINTABLE => Parser.Parse_Body (Process); when IN_BODY_PART => Parser.Parse_Body_Part (Process); end case; exit when Parser.Is_Eof; end loop; end Parse; end Mail.Parsers;
AdaCore/libadalang
Ada
1,141
adb
procedure Test is package Pkg is type A (X : Integer) is null record; --% node.p_discriminants_list() type B is new A; --% node.p_discriminants_list() type C (X : Integer) is new A (X); --% node.p_discriminants_list() type D (Y : Integer) is private; --% node.p_discriminants_list() type E (<>) is private; --% node.p_discriminants_list() type F (V : Integer) is limited private; --% node.p_discriminants_list() type G (W : Integer) is limited private; --% node.p_discriminants_list() type H is null record; --% node.p_discriminants_list() subtype I is E; --% node.p_discriminants_list() private type D (Y : Integer) is null record; type E (X : Integer) is null record; task type F (V : Integer) is end F; protected type G (W : Integer) is end G; end Pkg; package body Pkg is subtype J is E; --% node.p_discriminants_list() task body F is begin null; end F; protected body G is end G; end Pkg; begin null; end Test;
mgrojo/smk
Ada
6,156
adb
-- ----------------------------------------------------------------------------- -- smk, the smart make -- © 2018 Lionel Draghi <[email protected]> -- SPDX-License-Identifier: APSL-2.0 -- ----------------------------------------------------------------------------- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- http://www.apache.org/licenses/LICENSE-2.0 -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. -- ----------------------------------------------------------------------------- -- ----------------------------------------------------------------------------- -- Package: Smk.Run_Files body -- -- Implementation Notes: -- -- Portability Issues: -- -- Anticipated Changes: -- ----------------------------------------------------------------------------- with Ada.Directories; with Ada.Streams.Stream_IO; with Smk.IO; with Smk.Settings; package body Smk.Run_Files is Run_Fl : Ada.Streams.Stream_IO.File_Type; -- -------------------------------------------------------------------------- function "+" (Name : File_Name) return String is (To_String (Name)); function "+" (Name : String) return File_Name is (File_Name'(To_Unbounded_String (Name))); function "+" (Name : File_Name) return Unbounded_String is (Unbounded_String (Name)); -- -------------------------------------------------------------------------- procedure Dump (File_List : in File_Lists.Map; Filter_Sytem_Files : in Boolean) is use Run_Files.File_Lists; begin for C in File_List.Iterate loop declare Name : constant String := +Key (C); TT : constant Ada.Calendar.Time := Element (C); begin if not Filter_Sytem_Files or (Name (1 .. 4) /= "/usr" and Name (1 .. 4) /= "/lib" and Name (1 .. 4) /= "/opt" and Name (1 .. 4) /= "/etc" and Name (1 .. 5) /= "/proc" and Name (1 .. 4) /= "/sys") -- Fixme: filter processing to complete, and filtered -- directories should moved to Settings then IO.Put_Line (" - " & IO.Image (TT) & ":" & Name); end if; end; end loop; end Dump; -- -------------------------------------------------------------------------- procedure Update_Time_Tag (File_List : in out File_Lists.Map) is use Ada.Directories; use File_Lists; begin for C in File_List.Iterate loop declare Name : constant String := +Key (C); begin if Exists (Name) then File_List.Replace_Element (C, Ada.Directories.Modification_Time (Name)); -- Fixme : GNAT bug on this line: -- Element (C) := Ada.Directories.Modification_Time (Name); end if; end; end loop; end Update_Time_Tag; -- -------------------------------------------------------------------------- procedure Insert_Or_Update (The_Command : in Command_Lines; The_Run : in Run; In_Run_List : in out Run_Lists.Map) is begin if In_Run_List.Contains (The_Command) then In_Run_List.Replace (Key => The_Command, New_Item => The_Run); else In_Run_List.Insert (Key => The_Command, New_Item => The_Run); end if; end Insert_Or_Update; -- -------------------------------------------------------------------------- procedure Dump (Run_List : in Run_Lists.Map; Filter_Sytem_Files : in Boolean) is use Run_Lists; use Ada.Containers; begin for L in Run_List.Iterate loop declare Run : constant Run_Files.Run := Element (L); RT_Image : constant String := IO.Image (Run.Run_Time); Section : constant String := " [" & (+Run.Section) & "] "; SC : constant String := Count_Type'Image (Run.Sources.Length); TC : constant String := Count_Type'Image (Run.Targets.Length); begin IO.Put_Line (RT_Image & Section & (+Key (L))); IO.Put_Line (" Sources (" & SC (2 .. SC'Last) & ") :"); Dump (Run.Sources, Filter_Sytem_Files); IO.Put_Line (" Targets (" & TC (2 .. TC'Last) & ") :"); Dump (Run.Targets, Filter_Sytem_Files); IO.Put_Line (""); end; end loop; end Dump; -- -------------------------------------------------------------------------- function Saved_Run_Found return Boolean is begin return Ada.Directories.Exists (Settings.Previous_Run_File_Name); end Saved_Run_Found; -- -------------------------------------------------------------------------- function Get_Saved_Run return Run_Lists.Map is use Ada.Streams.Stream_IO; List : Run_Lists.Map; S : Stream_Access; begin Open (Name => Settings.Previous_Run_File_Name, File => Run_Fl, Mode => In_File); S := Stream (Run_Fl); List := Run_Lists.Map'Input (S); Close (Run_Fl); return List; end Get_Saved_Run; -- -------------------------------------------------------------------------- procedure Save_Run (The_Run : in Run_Lists.Map) is use Ada.Streams.Stream_IO; S : Stream_Access; begin Create (Name => Settings.Previous_Run_File_Name, File => Run_Fl, Mode => Out_File); S := Stream (Run_Fl); Run_Lists.Map'Output (S, The_Run); Close (Run_Fl); end Save_Run; end Smk.Run_Files;
coopht/axmpp
Ada
14,342
adb
------------------------------------------------------------------------------ -- -- -- AXMPP Project -- -- -- -- XMPP Library for Ada -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2011-2016, Alexander Basov <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Alexander Basov, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with Ada.Characters.Conversions; with Ada.Streams; with GNAT.MD5; with League.String_Vectors; with XMPP.Base64; with XMPP.Logger; with XMPP.Utils; package body XMPP.Challenges is use type Ada.Streams.Stream_Element_Offset; use League.Strings; package ACC renames Ada.Characters.Conversions; function Create return XMPP_Challenge_Access is begin return new XMPP_Challenge; end Create; ------------------------- -- Generate_Response -- ------------------------- function Generate_Response (Self : XMPP_Challenge) return League.Strings.Universal_String is function Hex_To_Oct (Sum : String) return String; ------------------ -- Hex_To_Oct -- ------------------ function Hex_To_Oct (Sum : String) return String is Result : String (Sum'First .. Sum'Last / 2); J : Integer := Sum'First; begin for Idx in Result'Range loop Result (Idx) := Character'Val (Integer'Value (("16#" & Sum (J .. J + 1) & "#"))); J := J + 2; end loop; return Result; end Hex_To_Oct; begin if not Self.RSP_Auth.Is_Empty then return League.Strings.To_Universal_String ("<response xmlns='urn:ietf:params:xml:ns:xmpp-sasl'/>"); else declare -- TODO: -- CNonce should not be hardcoded. C_Nonce : constant Wide_Wide_String := "1a2f0ee81279451956625d2368"; SY : constant String := Hex_To_Oct (GNAT.MD5.Digest (ACC.To_String (Self.JID.To_Wide_Wide_String & ":" & Self.Host.To_Wide_Wide_String & ":" & Self.Password.To_Wide_Wide_String))); HA1 : constant String := GNAT.MD5.Digest (SY & ":" & ACC.To_String (Self.Nonce.To_Wide_Wide_String) & ":" & ACC.To_String (C_Nonce)); HA2 : constant String := GNAT.MD5.Digest (ACC.To_String ("AUTHENTICATE:xmpp/" & Self.Host.To_Wide_Wide_String)); Z : constant String := GNAT.MD5.Digest (HA1 & ":" & ACC.To_String (Self.Nonce.To_Wide_Wide_String) & ":00000001:" & ACC.To_String (C_Nonce) & ":auth:" & HA2); Realm_Reply : constant Wide_Wide_String := "username=""" & Self.JID.To_Wide_Wide_String & """,realm=""" & Self.Host.To_Wide_Wide_String & """,nonce=""" & Self.Nonce.To_Wide_Wide_String & """,cnonce=""" & C_Nonce & """,nc=00000001" & ",qop=auth,digest-uri=""xmpp/" & Self.Host.To_Wide_Wide_String & """,response=" & ACC.To_Wide_Wide_String (Z) & ",charset=" & Self.Charset.To_Wide_Wide_String; -- Calculating buffer size for base64 encoded string X : constant Integer := 4 * (Realm_Reply'Length + 2) / 3; Y : constant Integer := X + 2 * (X / 76); Realm_Reply_Base_64 : String (Realm_Reply'First .. Y); Len : Natural; begin -- XMPP.Logger.Log ("SY:" & SY); -- XMPP.Logger.Log ("HA1:" & HA1); -- XMPP.Logger.Log ("HA2:" & HA2); -- XMPP.Logger.Log ("Z:" & Z); -- XMPP.Logger.Log ("Realm_Reply:" & ACC.To_String (Realm_Reply)); XMPP.Base64.Encode (XMPP.Utils.To_Stream_Element_Array (ACC.To_String (Realm_Reply)), Realm_Reply_Base_64, Len); -- XMPP.Logger.Log ("Realm_Reply_Base_64:" & Realm_Reply_Base_64); return League.Strings.To_Universal_String ("<response xmlns='urn:ietf:params:xml:ns:xmpp-sasl'>" & ACC.To_Wide_Wide_String (Realm_Reply_Base_64 (Realm_Reply_Base_64'First .. Len)) & "</response>"); end; end if; end Generate_Response; ---------------- -- Get_Kind -- ---------------- overriding function Get_Kind (Self : XMPP_Challenge) return XMPP.Object_Kind is pragma Unreferenced (Self); begin return XMPP.Challenge; end Get_Kind; ----------------------- -- Parse_Challenge -- ----------------------- procedure Parse_Challenge (Self : in out XMPP_Challenge; Challenge : String) is function Drop_Quotes (Str : String) return String; ------------------- -- Drop_Quotes -- ------------------- function Drop_Quotes (Str : String) return String is begin if Str (Str'First) = '"' and Str (Str'Last) = '"' then return Str (Str'First + 1 .. Str'Last - 1); else return Str; end if; end Drop_Quotes; Pos : Integer := Challenge'First; begin if Challenge (Challenge'First .. Challenge'First + 6) = "rspauth" then Self.Set_RSP_Auth (League.Strings.To_Universal_String (ACC.To_Wide_Wide_String (Challenge (Challenge'First + 8 .. Challenge'Last)))); return; end if; for J in Challenge'Range loop if Challenge (J) = ',' then declare T : constant String := Challenge (Pos .. J - 1); begin for X in T'Range loop if T (X) = '=' then declare Param : constant String := T (T'First .. X - 1); Val : constant String := T (X + 1 .. T'Last); begin if Param = "nonce" then Self.Set_Nonce (League.Strings.To_Universal_String (ACC.To_Wide_Wide_String (Drop_Quotes (Val)))); elsif Param = "qop" then Self.Set_Qop (League.Strings.To_Universal_String (ACC.To_Wide_Wide_String (Drop_Quotes (Val)))); elsif Param = "charset" then Self.Set_Charset (League.Strings.To_Universal_String (ACC.To_Wide_Wide_String (Drop_Quotes (Val)))); elsif Param = "algorithm" then Self.Set_Algorithm (League.Strings.To_Universal_String (ACC.To_Wide_Wide_String (Drop_Quotes (Val)))); else XMPP.Logger.Log ("unknown parameter : " & ACC.To_Wide_Wide_String (Param)); end if; end; end if; end loop; end; Pos := J + 1; end if; end loop; end Parse_Challenge; ----------------- -- Serialize -- ----------------- overriding procedure Serialize (Self : XMPP_Challenge; Writer : in out XML.SAX.Pretty_Writers.XML_Pretty_Writer'Class) is pragma Unreferenced (Self); pragma Unreferenced (Writer); begin raise Program_Error with "Not yet implemented"; end Serialize; --------------------- -- Set_Algorithm -- --------------------- procedure Set_Algorithm (Self : in out XMPP_Challenge; Algorithm : League.Strings.Universal_String) is begin Self.Algorithm := Algorithm; end Set_Algorithm; ------------------- -- Set_Charset -- ------------------- procedure Set_Charset (Self : in out XMPP_Challenge; Charset : League.Strings.Universal_String) is begin Self.Charset := Charset; end Set_Charset; ------------------- -- Set_Content -- ------------------- overriding procedure Set_Content (Self : in out XMPP_Challenge; Parameter : League.Strings.Universal_String; Value : League.Strings.Universal_String) is begin if Parameter.To_Wide_Wide_String = "challenge" then declare Buffer : Ada.Streams.Stream_Element_Array (0 .. 4096); Length : Ada.Streams.Stream_Element_Offset; begin XMPP.Base64.Decode (Ada.Characters.Conversions.To_String (Value.To_Wide_Wide_String), Buffer, Length); declare Result : String (1 .. Integer (Length)); begin for J in 1 .. Length loop Result (Integer (J)) := (Character'Val (Buffer (J - 1))); end loop; -- XMPP.Logger.Log ("Decoded challenge: " & Result); Self.Parse_Challenge (Result); end; end; else XMPP.Logger.Log ("Unknown parameter : " & Parameter); end if; end Set_Content; --------------- -- Set_JID -- --------------- procedure Set_JID (Self : in out XMPP_Challenge; JID : League.Strings.Universal_String) is Vec : constant League.String_Vectors.Universal_String_Vector := JID.Split ('@'); begin if Vec.Length /= 2 then raise Program_Error with "Wrong jid specfified"; else Self.JID := Vec.Element (1); Self.Host := Vec.Element (2); end if; end Set_JID; ----------------- -- Set_Nonce -- ----------------- procedure Set_Nonce (Self : in out XMPP_Challenge; Nonce : League.Strings.Universal_String) is begin Self.Nonce := Nonce; end Set_Nonce; -------------------- -- Set_Password -- -------------------- procedure Set_Password (Self : in out XMPP_Challenge; Password : League.Strings.Universal_String) is begin Self.Password := Password; end Set_Password; --------------- -- Set_Qop -- --------------- procedure Set_Qop (Self : in out XMPP_Challenge; Qop : League.Strings.Universal_String) is begin Self.Qop := Qop; end Set_Qop; ----------------- -- Set_Realm -- ----------------- procedure Set_Realm (Self : in out XMPP_Challenge; Realm : League.Strings.Universal_String) is begin Self.Realm := Realm; end Set_Realm; -------------------- -- Set_RSP_Auth -- -------------------- procedure Set_RSP_Auth (Self : in out XMPP_Challenge; RSP_Auth : League.Strings.Universal_String) is begin Self.RSP_Auth := RSP_Auth; end Set_RSP_Auth; end XMPP.Challenges;
MinimSecure/unum-sdk
Ada
850
ads
-- Copyright 2008-2016 Free Software Foundation, Inc. -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation; either version 3 of the License, or -- (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- -- You should have received a copy of the GNU General Public License -- along with this program. If not, see <http://www.gnu.org/licenses/>. with System; package Pck is function Ident (I : Integer) return Integer; procedure Do_Nothing (A : System.Address); end Pck;
reznikmm/matreshka
Ada
3,953
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with ODF.DOM.Meta_Name_Attributes; package Matreshka.ODF_Meta.Name_Attributes is type Meta_Name_Attribute_Node is new Matreshka.ODF_Meta.Abstract_Meta_Attribute_Node and ODF.DOM.Meta_Name_Attributes.ODF_Meta_Name_Attribute with null record; overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Meta_Name_Attribute_Node; overriding function Get_Local_Name (Self : not null access constant Meta_Name_Attribute_Node) return League.Strings.Universal_String; end Matreshka.ODF_Meta.Name_Attributes;
vasil-sd/ada-tlsf
Ada
103
ads
package TLSF.Proof.Test.Util with SPARK_Mode is procedure Test_Util; end TLSF.Proof.Test.Util;
AdaCore/libadalang
Ada
292
adb
procedure Array_Aggregate is type Integer is range 1 .. 1000; type A is array (Integer) of Integer; Inst : A; I : Integer := 30; begin Inst := (others => 12); pragma Test_Statement; Inst := (1 | 2 | 3 => I, others => 12); pragma Test_Statement; end Array_Aggregate;
damaki/libkeccak
Ada
4,453
ads
------------------------------------------------------------------------------- -- Copyright (c) 2019, Daniel King -- All rights reserved. -- -- Redistribution and use in source and binary forms, with or without -- modification, are permitted provided that the following conditions are met: -- * Redistributions of source code must retain the above copyright -- notice, this list of conditions and the following disclaimer. -- * Redistributions in binary form must reproduce the above copyright -- notice, this list of conditions and the following disclaimer in the -- documentation and/or other materials provided with the distribution. -- * The name of the copyright holder may not be used to endorse or promote -- Products derived from this software without specific prior written -- permission. -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY -- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -- ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ------------------------------------------------------------------------------- with Keccak.Keccak_1600.Rounds_24; with Keccak.Generic_Parallel_Sponge; with Keccak.Padding; pragma Elaborate_All (Keccak.Generic_Parallel_Sponge); package Keccak.Parallel_Keccak_1600.Rounds_24 with SPARK_Mode => On is procedure Permute_All_P2 is new KeccakF_1600_P2.Permute_All (Keccak.Keccak_1600.Rounds_24.Permute); procedure Permute_All_P4 is new KeccakF_1600_P4.Permute_All (Keccak.Keccak_1600.Rounds_24.Permute); procedure Permute_All_P8 is new KeccakF_1600_P8.Permute_All (Keccak.Keccak_1600.Rounds_24.Permute); package Parallel_Sponge_P2 is new Keccak.Generic_Parallel_Sponge (State_Size => 1600, State_Type => KeccakF_1600_P2.Parallel_State, Parallelism => 2, Init => KeccakF_1600_P2.Init, Permute_All => Permute_All_P2, XOR_Bits_Into_State_Separate => KeccakF_1600_P2.XOR_Bits_Into_State_Separate, XOR_Bits_Into_State_All => KeccakF_1600_P2.XOR_Bits_Into_State_All, Extract_Bytes => KeccakF_1600_P2.Extract_Bytes, Pad => Keccak.Padding.Pad101_Single_Block, Min_Padding_Bits => Keccak.Padding.Pad101_Min_Bits); package Parallel_Sponge_P4 is new Keccak.Generic_Parallel_Sponge (State_Size => 1600, State_Type => KeccakF_1600_P4.Parallel_State, Parallelism => 4, Init => KeccakF_1600_P4.Init, Permute_All => Permute_All_P4, XOR_Bits_Into_State_Separate => KeccakF_1600_P4.XOR_Bits_Into_State_Separate, XOR_Bits_Into_State_All => KeccakF_1600_P4.XOR_Bits_Into_State_All, Extract_Bytes => KeccakF_1600_P4.Extract_Bytes, Pad => Keccak.Padding.Pad101_Single_Block, Min_Padding_Bits => Keccak.Padding.Pad101_Min_Bits); package Parallel_Sponge_P8 is new Keccak.Generic_Parallel_Sponge (State_Size => 1600, State_Type => KeccakF_1600_P8.Parallel_State, Parallelism => 8, Init => KeccakF_1600_P8.Init, Permute_All => Permute_All_P8, XOR_Bits_Into_State_Separate => KeccakF_1600_P8.XOR_Bits_Into_State_Separate, XOR_Bits_Into_State_All => KeccakF_1600_P8.XOR_Bits_Into_State_All, Extract_Bytes => KeccakF_1600_P8.Extract_Bytes, Pad => Keccak.Padding.Pad101_Single_Block, Min_Padding_Bits => Keccak.Padding.Pad101_Min_Bits); end Keccak.Parallel_Keccak_1600.Rounds_24;
reznikmm/matreshka
Ada
4,019
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with ODF.DOM.Table_Source_Name_Attributes; package Matreshka.ODF_Table.Source_Name_Attributes is type Table_Source_Name_Attribute_Node is new Matreshka.ODF_Table.Abstract_Table_Attribute_Node and ODF.DOM.Table_Source_Name_Attributes.ODF_Table_Source_Name_Attribute with null record; overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Table_Source_Name_Attribute_Node; overriding function Get_Local_Name (Self : not null access constant Table_Source_Name_Attribute_Node) return League.Strings.Universal_String; end Matreshka.ODF_Table.Source_Name_Attributes;
stcarrez/dynamo
Ada
4,333
adb
----------------------------------------------------------------------- -- gen-commands -- Commands for dynamo -- Copyright (C) 2011, 2012, 2017, 2021 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.Text_IO; with Ada.Command_Line; with Gen.Configs; with Gen.Commands.Generate; with Gen.Commands.Project; with Gen.Commands.Page; with Gen.Commands.Layout; with Gen.Commands.Model; with Gen.Commands.Propset; with Gen.Commands.Database; with Gen.Commands.Info; with Gen.Commands.Distrib; with Gen.Commands.Plugins; with Gen.Commands.Docs; package body Gen.Commands is -- ------------------------------ -- Print dynamo short usage. -- ------------------------------ procedure Short_Help_Usage is use Ada.Text_IO; begin New_Line; Put ("Type '"); Put (Ada.Command_Line.Command_Name); Put_Line (" help' for the list of commands."); end Short_Help_Usage; -- Generate command. Generate_Cmd : aliased Gen.Commands.Generate.Command; -- Create project command. Create_Project_Cmd : aliased Gen.Commands.Project.Command; -- Add page command. Add_Page_Cmd : aliased Gen.Commands.Page.Command; -- Add layout command. Add_Layout_Cmd : aliased Gen.Commands.Layout.Command; -- Add model command. Add_Model_Cmd : aliased Gen.Commands.Model.Command; -- Sets a property on the dynamo.xml project. Propset_Cmd : aliased Gen.Commands.Propset.Command; -- Create database command. Database_Cmd : aliased Gen.Commands.Database.Command; -- Project information command. Info_Cmd : aliased Gen.Commands.Info.Command; -- Distrib command. Dist_Cmd : aliased Gen.Commands.Distrib.Command; -- Create plugin command. Create_Plugin_Cmd : aliased Gen.Commands.Plugins.Command; -- Documentation command. Doc_Plugin_Cmd : aliased Gen.Commands.Docs.Command; -- Help command. Help_Cmd : aliased Drivers.Help_Command_Type; begin Driver.Set_Description (Gen.Configs.RELEASE); Driver.Set_Usage ("[-v] [-o directory] [-t templates] {command} {arguments}" & ASCII.LF & "where:" & ASCII.LF & " -v Print the version, configuration and installation paths" & ASCII.LF & " -o directory Directory where the Ada mapping files are generated" & ASCII.LF & " -t templates Directory where the Ada templates are defined" & ASCII.LF & " -c dir Directory where the Ada templates " & "and configurations are defined"); Driver.Add_Command (Name => "help", Command => Help_Cmd'Access); Driver.Add_Command (Name => "generate", Command => Generate_Cmd'Access); Driver.Add_Command (Name => "create-project", Command => Create_Project_Cmd'Access); Driver.Add_Command (Name => "add-page", Command => Add_Page_Cmd'Access); Driver.Add_Command (Name => "add-layout", Command => Add_Layout_Cmd'Access); Driver.Add_Command (Name => "add-model", Command => Add_Model_Cmd'Access); Driver.Add_Command (Name => "propset", Command => Propset_Cmd'Access); Driver.Add_Command (Name => "create-database", Command => Database_Cmd'Access); Driver.Add_Command (Name => "create-plugin", Command => Create_Plugin_Cmd'Access); Driver.Add_Command (Name => "dist", Command => Dist_Cmd'Access); Driver.Add_Command (Name => "info", Command => Info_Cmd'Access); Driver.Add_Command (Name => "build-doc", Command => Doc_Plugin_Cmd'Access); end Gen.Commands;
reznikmm/matreshka
Ada
4,321
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with Matreshka.ODF_String_Constants; package body Matreshka.ODF_SMIL is ------------------ -- Constructors -- ------------------ package body Constructors is ---------------- -- Initialize -- ---------------- procedure Initialize (Self : not null access Abstract_SMIL_Attribute_Node'Class; Document : not null Matreshka.DOM_Nodes.Document_Access; Prefix : League.Strings.Universal_String) is begin Matreshka.DOM_Attributes.Constructors.Initialize (Self, Document); Self.Prefix := Prefix; end Initialize; end Constructors; ----------------------- -- Get_Namespace_URI -- ----------------------- overriding function Get_Namespace_URI (Self : not null access constant Abstract_SMIL_Attribute_Node) return League.Strings.Universal_String is begin return Matreshka.ODF_String_Constants.SMIL_URI; end Get_Namespace_URI; end Matreshka.ODF_SMIL;
kimtg/euler-ada
Ada
575
adb
with Ada.Text_IO; procedure Euler21 is function Dsum(N : Natural) return Natural is Sum : Natural := 0; begin for X in 1 .. N / 2 loop if N mod X = 0 then Sum := Sum + X; end if; end loop; return Sum; end; function Amicable(N : Natural) return Boolean is D : Natural := Dsum(N); begin return D /= N and then Dsum(D) = N; end; Sum : Natural := 0; begin for X in 0 .. 9999 loop if Amicable(X) then Sum := Sum + X; end if; end loop; Ada.Text_IO.Put_Line(Integer'Image(Sum)); end;
1Crazymoney/LearnAda
Ada
941
ads
generic type Elem is private; package Vermek is type Verem is limited private; Üres_A_Verem: exception; procedure Push( V: in out Verem; E: in Elem ); procedure Pop( V: in out Verem; E: out Elem ); -- kiválthat Üres_A_Verem kivételt function Top( V: Verem ) return Elem; -- kiválthat Üres_A_Verem kivételt function Is_Empty( V: Verem ) return Boolean; function Is_Full( V: Verem ) return Boolean; function Size( V: Verem ) return Natural; private type Csúcs; type Mutató is access Csúcs; type Csúcs is record Adat: Elem; Következő: Mutató := null; end record; type Verem is record Méret: Natural := 0; Veremtető: Mutató := null; end record; end Vermek;
onox/orka
Ada
9,989
ads
-- SPDX-License-Identifier: Apache-2.0 -- -- Copyright (c) 2012 Felix Krause <[email protected]> -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. with Interfaces.C.Pointers; private with GL.Enums; private with GL.Low_Level; package GL.Objects.Buffers is pragma Preelaborate; function Minimum_Alignment return Types.Size with Post => Minimum_Alignment'Result >= 64; -- Minimum byte alignment of pointers returned by Map_Range -- (at least 64 bytes to support SIMD CPU instructions) function Max_Shader_Storage_Buffer_Bindings return Size with Post => Max_Shader_Storage_Buffer_Bindings'Result >= 8; -- Maximum number of SSBO buffer bindings function Max_Shader_Storage_Block_Size return Size with Post => Max_Shader_Storage_Block_Size'Result >= 2 ** 27; -- Maximum total storage size of an SSBO in bytes function Max_Compute_Shader_Storage_Blocks return Size with Post => Max_Compute_Shader_Storage_Blocks'Result >= 8; -- Maximum number of SSBO blocks in a compute shader type Access_Bits is record Read : Boolean := False; Write : Boolean := False; Invalidate_Range : Boolean := False; Invalidate_Buffer : Boolean := False; Flush_Explicit : Boolean := False; Unsynchronized : Boolean := False; Persistent : Boolean := False; Coherent : Boolean := False; end record with Dynamic_Predicate => (Access_Bits.Read or Access_Bits.Write) and (if Access_Bits.Flush_Explicit then Access_Bits.Write) and (if Access_Bits.Invalidate_Range or Access_Bits.Invalidate_Buffer then not Access_Bits.Read); type Storage_Bits is record Read : Boolean := False; Write : Boolean := False; Persistent : Boolean := False; Coherent : Boolean := False; Dynamic_Storage : Boolean := False; Client_Storage : Boolean := False; end record with Dynamic_Predicate => (if Storage_Bits.Coherent then Storage_Bits.Persistent) and (if Storage_Bits.Persistent then Storage_Bits.Read or Storage_Bits.Write); type Buffer_Target (<>) is tagged limited private; type Indexed_Buffer_Target is (Shader_Storage, Uniform); function Kind (Target : Buffer_Target) return Indexed_Buffer_Target; type Buffer is new GL_Object with private; function Allocated (Object : Buffer) return Boolean; function Mapped (Object : Buffer) return Boolean; procedure Bind (Target : Buffer_Target; Object : Buffer'Class); -- Bind the buffer object to the target -- -- The target must not be one of the targets that should be used with -- Bind_Base or Bind_Range. procedure Bind_Base (Target : Buffer_Target; Object : Buffer'Class; Index : Natural); -- Bind the buffer object to the index of the target as well as to -- the target itself. -- -- Target must be one of the following: -- -- * Uniform_Buffer -- * Shader_Storage_Buffer procedure Allocate_Storage (Object : in out Buffer; Length : Long; Kind : Numeric_Type; Flags : Storage_Bits) with Pre => not Object.Allocated, Post => Object.Allocated; -- Use this instead of Allocate_And_Load_From_Data if you don't want -- to copy any data overriding procedure Initialize_Id (Object : in out Buffer); overriding procedure Delete_Id (Object : in out Buffer); overriding function Identifier (Object : Buffer) return Types.Debug.Identifier is (Types.Debug.Buffer); procedure Unmap (Object : in out Buffer); procedure Invalidate_Data (Object : in out Buffer); generic with package Pointers is new Interfaces.C.Pointers (<>); package Buffer_Pointers is subtype Pointer is Pointers.Pointer; procedure Bind_Range (Target : Buffer_Target; Object : Buffer'Class; Index : Natural; Offset, Length : Types.Size); -- Bind a part of the buffer object to the index of the target as -- well as to the target itself -- -- Target must be one of the following: -- -- * Uniform_Buffer -- * Shader_Storage_Buffer procedure Allocate_And_Load_From_Data (Object : in out Buffer; Data : Pointers.Element_Array; Flags : Storage_Bits) with Pre => not Object.Allocated, Post => Object.Allocated; procedure Map_Range (Object : in out Buffer; Flags : Access_Bits; Offset, Length : Types.Size; Pointer : out Pointers.Pointer) with Pre => Object.Allocated and not Object.Mapped and Length > 0; function Get_Mapped_Data (Pointer : not null Pointers.Pointer; Offset, Length : Types.Size) return Pointers.Element_Array with Pre => Length > 0, Post => Get_Mapped_Data'Result'Length = Length; procedure Set_Mapped_Data (Pointer : not null Pointers.Pointer; Offset : Types.Size; Data : Pointers.Element_Array) with Pre => Data'Length > 0; procedure Set_Mapped_Data (Pointer : not null Pointers.Pointer; Offset : Types.Size; Value : Pointers.Element); procedure Flush_Buffer_Range (Object : in out Buffer; Offset, Length : Types.Size); procedure Clear_Sub_Data (Object : Buffer; Kind : Numeric_Type; Offset, Length : Types.Size; Data : in out Pointers.Element_Array) with Pre => Data'Length <= 4 and then Kind /= Double_Type and then (if Data'Length = 3 then Kind not in Byte_Type | UByte_Type | Short_Type | UShort_Type | Half_Type); procedure Copy_Sub_Data (Object, Target_Object : Buffer; Read_Offset, Write_Offset, Length : Types.Size); procedure Set_Sub_Data (Object : Buffer; Offset : Types.Size; Data : Pointers.Element_Array); procedure Get_Sub_Data (Object : Buffer; Offset : Types.Size; Data : out Pointers.Element_Array); procedure Invalidate_Sub_Data (Object : Buffer; Offset, Length : Types.Size); end Buffer_Pointers; -- Array_Buffer, Texture_Buffer, -- Copy_Read_Buffer, and Copy_Write_Buffer are no longer needed -- since the GL.Objects.* packages use DSA -- Transform_Feedback_Buffer replaced by Shader_Storage_Buffer Element_Array_Buffer : aliased constant Buffer_Target; Pixel_Pack_Buffer : aliased constant Buffer_Target; Pixel_Unpack_Buffer : aliased constant Buffer_Target; Draw_Indirect_Buffer : aliased constant Buffer_Target; Parameter_Buffer : aliased constant Buffer_Target; Dispatch_Indirect_Buffer : aliased constant Buffer_Target; Query_Buffer : aliased constant Buffer_Target; -- Buffer targets that must be binded to a specific index -- (specified in shaders) -- Atomic_Counter_Buffer replaced by Shader_Storage_Buffer Uniform_Buffer : aliased constant Buffer_Target; Shader_Storage_Buffer : aliased constant Buffer_Target; private for Access_Bits use record Read at 0 range 0 .. 0; Write at 0 range 1 .. 1; Invalidate_Range at 0 range 2 .. 2; Invalidate_Buffer at 0 range 3 .. 3; Flush_Explicit at 0 range 4 .. 4; Unsynchronized at 0 range 5 .. 5; Persistent at 0 range 6 .. 6; Coherent at 0 range 7 .. 7; end record; for Access_Bits'Size use Low_Level.Bitfield'Size; for Storage_Bits use record Read at 0 range 0 .. 0; Write at 0 range 1 .. 1; Persistent at 0 range 6 .. 6; Coherent at 0 range 7 .. 7; Dynamic_Storage at 0 range 8 .. 8; Client_Storage at 0 range 9 .. 9; end record; for Storage_Bits'Size use Low_Level.Bitfield'Size; type Buffer_Target (Kind : Enums.Buffer_Kind) is tagged limited null record; type Buffer is new GL_Object with record Allocated, Mapped : Boolean := False; end record; Element_Array_Buffer : aliased constant Buffer_Target := Buffer_Target'(Kind => Enums.Element_Array_Buffer); Pixel_Pack_Buffer : aliased constant Buffer_Target := Buffer_Target'(Kind => Enums.Pixel_Pack_Buffer); Pixel_Unpack_Buffer : aliased constant Buffer_Target := Buffer_Target'(Kind => Enums.Pixel_Unpack_Buffer); Uniform_Buffer : aliased constant Buffer_Target := Buffer_Target'(Kind => Enums.Uniform_Buffer); Draw_Indirect_Buffer : aliased constant Buffer_Target := Buffer_Target'(Kind => Enums.Draw_Indirect_Buffer); Parameter_Buffer : aliased constant Buffer_Target := Buffer_Target'(Kind => Enums.Parameter_Buffer); Shader_Storage_Buffer : aliased constant Buffer_Target := Buffer_Target'(Kind => Enums.Shader_Storage_Buffer); Dispatch_Indirect_Buffer : aliased constant Buffer_Target := Buffer_Target'(Kind => Enums.Dispatch_Indirect_Buffer); Query_Buffer : aliased constant Buffer_Target := Buffer_Target'(Kind => Enums.Query_Buffer); end GL.Objects.Buffers;
AdaCore/libadalang
Ada
309
ads
with Vectors; generic type Value_Type is private; package Options is type T (Present : Boolean := False) is record case Present is when True => Value : Value_Type; when False => null; end case; end record; package Option_Vectors is new Vectors (T); end Options;
damaki/SPARKNaCl
Ada
229
adb
package body SPARKNaCl.Sign.Utils with SPARK_Mode => On is procedure Construct (X : in Bytes_64; Y : out Signing_SK) is begin Y.F := X; end Construct; end SPARKNaCl.Sign.Utils;
reznikmm/matreshka
Ada
4,576
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with Matreshka.DOM_Documents; with Matreshka.ODF_String_Constants; with ODF.DOM.Iterators; with ODF.DOM.Visitors; package body Matreshka.ODF_Style.Style_Attributes is ------------ -- Create -- ------------ overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Style_Style_Attribute_Node is begin return Self : Style_Style_Attribute_Node do Matreshka.ODF_Style.Constructors.Initialize (Self'Unchecked_Access, Parameters.Document, Matreshka.ODF_String_Constants.Style_Prefix); end return; end Create; -------------------- -- Get_Local_Name -- -------------------- overriding function Get_Local_Name (Self : not null access constant Style_Style_Attribute_Node) return League.Strings.Universal_String is pragma Unreferenced (Self); begin return Matreshka.ODF_String_Constants.Style_Attribute; end Get_Local_Name; begin Matreshka.DOM_Documents.Register_Attribute (Matreshka.ODF_String_Constants.Style_URI, Matreshka.ODF_String_Constants.Style_Attribute, Style_Style_Attribute_Node'Tag); end Matreshka.ODF_Style.Style_Attributes;
AaronC98/PlaneSystem
Ada
3,086
ads
------------------------------------------------------------------------------ -- Ada Web Server -- -- -- -- Copyright (C) 2007-2012, AdaCore -- -- -- -- This library is free software; you can redistribute it and/or modify -- -- it under terms of the GNU General Public License as published by the -- -- Free Software Foundation; either version 3, or (at your option) any -- -- later version. This library is distributed in the hope that it will be -- -- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- -- -- -- -- -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- ------------------------------------------------------------------------------ -- This package and children provide a number of types and subprograms for -- creating reponse text used in ESMTP authentication. package AWS.SMTP.Authentication is type Credential is abstract tagged private; -- Information needed by some authentication protocol procedure Before_Send (Credential : Authentication.Credential; Sock : in out Net.Socket_Type'Class; Status : out SMTP.Status) is null; -- Null default implementation procedure After_Send (Credential : Authentication.Credential; Sock : in out Net.Socket_Type'Class; Status : out SMTP.Status) is null; -- Null default implementation function Image (Info : Credential) return String is abstract; -- Response to be sent to the server private type Credential is abstract tagged null record; end AWS.SMTP.Authentication;
notdb/LC-Practice
Ada
296
adb
with Ada.Text_IO; use Ada.Text_IO; procedure Greet_5c is I : Integer := 1; begin -- Condition must be a Boolean value (no Integers) -- Operator "<=" returns a Boolean while I <= 5 loop Put_Line ("Hello, World!" & Integer'Image(I)); I := I + 1; end loop; end Greet_5c;
onox/orka
Ada
17,212
ads
-- SPDX-License-Identifier: BSD-3-Clause -- -- Copyright (c) 2017 Eric Bruneton -- All rights reserved. -- -- Redistribution and use in source and binary forms, with or without -- modification, are permitted provided that the following conditions -- are met: -- 1. Redistributions of source code must retain the above copyright -- notice, this list of conditions and the following disclaimer. -- 2. Redistributions in binary form must reproduce the above copyright -- notice, this list of conditions and the following disclaimer in the -- documentation and/or other materials provided with the distribution. -- 3. Neither the name of the copyright holders nor the names of its -- contributors may be used to endorse or promote products derived from -- this software without specific prior written permission. -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF -- THE POSSIBILITY OF SUCH DAMAGE. -- The shader returned by Get_Shader provides the following -- functions (that you need to forward declare in your own shaders to be able to -- compile them separately): -- -- // Returns the radiance of the Sun, outside the atmosphere. -- vec3 GetSolarRadiance(); -- -- // Returns the sky radiance along the segment from 'camera' to the nearest -- // atmosphere boundary in direction 'view_ray', as well as the transmittance -- // along this segment. -- vec3 GetSkyRadiance(vec3 camera, vec3 view_ray, double shadow_length, -- vec3 sun_direction, out vec3 transmittance, out bool intersects_ground); -- -- // Returns the sky radiance along the segment from 'camera' to 'p', as well as -- // the transmittance along this segment. -- vec3 GetSkyRadianceToPoint(vec3 camera, vec3 p, double shadow_length, -- vec3 sun_direction, out vec3 transmittance); -- -- // Returns the sun and sky irradiance received on a surface patch located at 'p' -- // and whose normal vector is 'normal'. -- vec3 GetSunAndSkyIrradiance(vec3 p, vec3 normal, vec3 sun_direction, -- out vec3 sky_irradiance); -- -- // Returns the luminance of the Sun, outside the atmosphere. -- vec3 GetSolarLuminance(); -- -- // Returns the sky luminance along the segment from 'camera' to the nearest -- // atmosphere boundary in direction 'view_ray', as well as the transmittance -- // along this segment. -- vec3 GetSkyLuminance(vec3 camera, vec3 view_ray, double shadow_length, -- vec3 sun_direction, out vec3 transmittance, out bool intersects_ground); -- -- // Returns the sky luminance along the segment from 'camera' to 'p', as well as -- // the transmittance along this segment. -- vec3 GetSkyLuminanceToPoint(vec3 camera, vec3 p, double shadow_length, -- vec3 sun_direction, out vec3 transmittance); -- -- // Returns the sun and sky illuminance received on a surface patch located at -- // 'p' and whose normal vector is 'normal'. -- vec3 GetSunAndSkyIlluminance(vec3 p, vec3 normal, vec3 sun_direction, -- out vec3 sky_illuminance); -- -- where -- -- - camera and p must be expressed in a reference frame where the planet center -- is at the origin, and measured in the unit passed to the constructor's -- length_unit_in_meters argument. camera can be in space, but p must be -- inside the atmosphere -- -- - view_ray, sun_direction and normal are unit direction vectors expressed -- in the same reference frame (with sun_direction pointing *towards* the Sun) -- -- - shadow_length is the length along the segment which is in shadow, measured -- in the unit passed to the constructor's length_unit_in_meters argument -- -- and where -- -- - the first 4 functions return spectral radiance and irradiance values -- (in $W.m^{-2}.sr^{-1}.nm^{-1}$ and $W.m^{-2}.nm^{-1}$), at the 3 wavelengths -- K_Lambda_R, K_Lambda_G, K_Lambda_B (in this order) -- -- - the other functions return luminance and illuminance values (in -- $cd.m^{-2}$ and $lx$) in linear [sRGB](https://en.wikipedia.org/wiki/SRGB) -- space (i.e. before adjustments for gamma correction) -- -- - all the functions return the (unitless) transmittance of the atmosphere -- along the specified segment at the 3 wavelengths K_Lambda_R, -- K_Lambda_G, K_Lambda_B (in this order) -- -- Note: The precomputed atmosphere textures can store either irradiance -- or illuminance values (see the Num_Precomputed_Wavelengths parameter): -- -- - when using irradiance values, the RGB channels of these textures contain -- spectral irradiance values, in $W.m^{-2}.nm^{-1}$, at the 3 wavelengths -- K_Lambda_R, K_Lambda_G, K_Lambda_B (in this order). The API functions -- returning radiance values return these precomputed values (times the -- phase functions), while the API functions returning luminance values use -- the approximation described in -- "A Qualitative and Quantitative Evaluation of 8 Clear Sky Models" [1], -- section 14.3, to convert 3 radiance values to linear sRGB luminance values -- -- - when using illuminance values, the RGB channels of these textures contain -- illuminance values, in $lx$, in linear sRGB space. These illuminance values -- are precomputed as described in -- "Real-time Spectral Scattering in Large-scale Natural Participating Media" [2], -- section 4.4 (i.e. Num_Precomputed_Wavelengths irradiance values are -- precomputed, and then converted to sRGB via a numerical integration of this -- spectrum with the CIE color matching functions). The API functions returning -- luminance values return these precomputed values (times the phase functions), -- while *the API functions returning radiance values are not provided* -- -- [1] https://arxiv.org/pdf/1612.04336.pdf -- [2] http://www.oskee.wz.cz/stranka/uploads/SCCG10ElekKmoch.pdf private with GL.Low_Level.Enums; private with GL.Objects.Textures; private with GL.Objects.Samplers; with Ada.Containers.Vectors; with Orka.Resources.Locations; with Orka.Rendering.Programs.Modules; package Orka.Features.Atmosphere is pragma Preelaborate; type Luminance_Type is (None, Approximate, Precomputed); type Density_Profile_Layer is record Width, Exp_Term, Exp_Scale, Linear_Term, Constant_Term : Float_64 := 0.0; end record; -- An atmosphere layer of Width (in m), and whose density is defined as -- Exp_Term * exp(Exp_Scale * h) + Linear_Term * h + Constant_Term, -- clamped to [0,1], and where h is the altitude (in m). Exp_Term and -- Constant_Term are unitless, while Exp_Scale and Linear_Term are in m^-1. use type Ada.Containers.Count_Type; package Double_Vectors is new Ada.Containers.Vectors (Natural, Float_64); package Density_Vectors is new Ada.Containers.Vectors (Natural, Density_Profile_Layer); type Model_Data (Samples : Ada.Containers.Count_Type) is record Luminance : Luminance_Type; Wavelengths : Double_Vectors.Vector; -- The wavelength values, in nanometers, and sorted in increasing order, for -- which the solar_irradiance, rayleigh_scattering, mie_scattering, -- mie_extinction and ground_albedo samples are provided. If your shaders -- use luminance values (as opposed to radiance values, see above), use a -- large number of wavelengths (e.g. between 15 and 50) to get accurate -- results (this number of wavelengths has absolutely no impact on the -- shader performance). Solar_Irradiance : Double_Vectors.Vector; -- Solar irradiance at the top of the atmosphere, in W/m^2/nm. This -- vector must have the same size as the wavelengths parameter. Sun_Angular_Radius : Float_64; -- Sun's angular radius in radians. Warning: the implementation uses -- approximations that are valid only if this value is smaller than 0.1. Bottom_Radius : Float_64; -- Distance between the planet center and the bottom of the atmosphere, in m Top_Radius : Float_64; -- Distance between the planet center and the top of the atmosphere, in m Rayleigh_Density : Density_Vectors.Vector; -- The density profile of air molecules, i.e. a function from altitude to -- dimensionless values between 0 (null density) and 1 (maximum density). -- Layers must be sorted from bottom to top. The width of the last layer is -- ignored, i.e. it always extend to the top atmosphere boundary. At most 2 -- layers can be specified. Rayleigh_Scattering : Double_Vectors.Vector; -- The scattering coefficient of air molecules at the altitude where their -- density is maximum (usually the bottom of the atmosphere), as a function -- of wavelength, in m^-1. The scattering coefficient at altitude h is equal -- to 'rayleigh_scattering' times 'rayleigh_density' at this altitude. This -- vector must have the same size as the wavelengths parameter. Mie_Density : Density_Vectors.Vector; -- The density profile of aerosols, i.e. a function from altitude to -- dimensionless values between 0 (null density) and 1 (maximum density). -- Layers must be sorted from bottom to top. The width of the last layer is -- ignored, i.e. it always extend to the top atmosphere boundary. At most 2 -- layers can be specified. Mie_Scattering : Double_Vectors.Vector; -- The scattering coefficient of aerosols at the altitude where their -- density is maximum (usually the bottom of the atmosphere), as a function -- of wavelength, in m^-1. The scattering coefficient at altitude h is equal -- to 'mie_scattering' times 'mie_density' at this altitude. This vector -- must have the same size as the wavelengths parameter. Mie_Extinction : Double_Vectors.Vector; -- The extinction coefficient of aerosols at the altitude where their -- density is maximum (usually the bottom of the atmosphere), as a function -- of wavelength, in m^-1. The extinction coefficient at altitude h is equal -- to 'mie_extinction' times 'mie_density' at this altitude. This vector -- must have the same size as the wavelengths parameter. Mie_Phase_Function_G : Float_64; -- The asymetry parameter for the Cornette-Shanks phase function for the -- aerosols. Absorption_Density : Density_Vectors.Vector; -- The density profile of air molecules that absorb light (e.g. ozone), i.e. -- a function from altitude to dimensionless values between 0 (null density) -- and 1 (maximum density). Layers must be sorted from bottom to top. The -- width of the last layer is ignored, i.e. it always extend to the top -- atmosphere boundary. At most 2 layers can be specified. Absorption_Extinction : Double_Vectors.Vector; -- The extinction coefficient of molecules that absorb light (e.g. ozone) at -- the altitude where their density is maximum, as a function of wavelength, -- in m^-1. The extinction coefficient at altitude h is equal to -- 'absorption_extinction' times 'absorption_density' at this altitude. This -- vector must have the same size as the wavelengths parameter. Ground_Albedo : Double_Vectors.Vector; -- The average albedo of the ground, as a function of wavelength. This -- vector must have the same size as the wavelengths parameter. Max_Sun_Zenith_Angle : Float_64; -- The maximum Sun zenith angle for which atmospheric scattering must be -- precomputed, in radians (for maximum precision, use the smallest Sun -- zenith angle yielding negligible sky light radiance values. For instance, -- for the Earth case, 102 degrees is a good choice for most cases (120 -- degrees is necessary for very high exposure values). Length_Unit_In_Meters : Float_64; -- The length unit used in your shaders and meshes. This is the length unit -- which must be used when calling the atmosphere model shader functions. Num_Precomputed_Wavelengths : Unsigned_32; -- The number of wavelengths for which atmospheric scattering must be -- precomputed (the temporary GPU memory used during precomputations, and -- the GPU memory used by the precomputed results, is independent of this -- number, but the precomputation time is directly proportional to this -- number): -- - if this number is less than or equal to 3, scattering is precomputed -- for 3 wavelengths, and stored as irradiance values. Then both the -- radiance-based and the luminance-based API functions are provided (see -- the above note). -- - otherwise, scattering is precomputed for this number of wavelengths -- (rounded up to a multiple of 3), integrated with the CIE color matching -- functions, and stored as illuminance values. Then only the -- luminance-based API functions are provided (see the above note). Combine_Scattering_Textures : Boolean; -- Whether to pack the (red component of the) single Mie scattering with the -- Rayleigh and multiple scattering in a single texture, or to store the -- (3 components of the) single Mie scattering in a separate texture. Half_Precision : Boolean; -- Whether to use half precision floats (16 bits) or single precision floats -- (32 bits) for the precomputed textures. Half precision is sufficient for -- most cases, except for very high exposure values. end record with Dynamic_Predicate => Model_Data.Rayleigh_Density.Length <= 2 and Model_Data.Absorption_Density.Length <= 2 and Model_Data.Sun_Angular_Radius < 0.1 and Model_Data.Wavelengths.Length = Model_Data.Samples and Model_Data.Solar_Irradiance.Length = Model_Data.Samples and Model_Data.Rayleigh_Scattering.Length = Model_Data.Samples and Model_Data.Mie_Scattering.Length = Model_Data.Samples and Model_Data.Mie_Extinction.Length = Model_Data.Samples and Model_Data.Absorption_Extinction.Length = Model_Data.Samples and Model_Data.Ground_Albedo.Length = Model_Data.Samples; type Precomputed_Textures is private; procedure Bind_Textures (Object : Precomputed_Textures); type Model (Data : not null access constant Model_Data) is tagged limited private; function Create_Model (Data : aliased Model_Data; Location : Resources.Locations.Location_Ptr) return Model; function Compute_Textures (Object : Model; Scattering_Orders : Natural := 4) return Precomputed_Textures; function Get_Shader (Object : Model) return Rendering.Programs.Modules.Module; procedure Convert_Spectrum_To_Linear_SRGB (Data : Model_Data; R, G, B : out Float_64); -- Utility method to convert a function of the wavelength to linear sRGB -- -- Wavelengths and solar irradiance must have the same size. The integral of -- Spectrum times each CIE_2_Deg_Color_Matching_Functions (and times -- Max_Luminous_Efficacy) is computed to get XYZ values, which are then -- converted to linear sRGB with the XYZ_To_SRGB matrix. -- -- For white balance, divide R, G, and B by the average of the three numbers private package Textures renames GL.Objects.Textures; package LE renames GL.Low_Level.Enums; type Precomputed_Textures is record Sampler : GL.Objects.Samplers.Sampler; Combine_Scattering : Boolean; Transmittance_Texture : Textures.Texture (LE.Texture_2D); Scattering_Texture : Textures.Texture (LE.Texture_3D); Irradiance_Texture : Textures.Texture (LE.Texture_2D); Optional_Single_Mie_Scattering_Texture : Textures.Texture (LE.Texture_3D); -- Unused if Combine_Scattering is True end record; type Model (Data : not null access constant Model_Data) is tagged limited record Data_Definitions : Resources.Byte_Array_Pointers.Pointer; Data_Functions : Resources.Byte_Array_Pointers.Pointer; Location : Resources.Locations.Location_Access; Sky_K_R, Sky_K_G, Sky_K_B : Float_64; Sun_K_R, Sun_K_G, Sun_K_B : Float_64; end record; function Create_Sampler return GL.Objects.Samplers.Sampler; K_Lambda_Min : constant Float_64 := 360.0; K_Lambda_Max : constant Float_64 := 830.0; end Orka.Features.Atmosphere;
pvrego/adaino
Ada
12,000
adb
with AVR.IO_PORTS; -- ============================================================================= -- Package body AVR.TWI -- ============================================================================= package body AVR.TWI is procedure Initialize (Address : Interfaces.Unsigned_8; Is_Slave: Boolean) is begin --PORTC := PORTC_PORTC4 or PORTC_PORTC5; -- for ATmega328P IO_PORTS.Reg_D.PORT (0) := TRUE; IO_PORTS.Reg_D.PORT (1) := TRUE; -- Init TWI prescaler and bitrate -- SCL_frequency := (CPU_Clock_frequency)/(16 + 2*(TWBR)*4^(TWPS) ) Reg_TWI.TWBR := 72; -- Interfaces.Unsigned_8 (((CPU_Speed / TWI_FREQ) - 16) / 2); -- Enable interrupts --pragma Compile_Time_Warning (True, "verificar se é necessário habilitar as interrupts aqui. Melhor postergar para o initialize_scheduler"); --AVR.INTERRUPTS.Enable; -- Enable TWI, ack and interrupt Reg_TWI.TWCR.TWEN := TRUE; Reg_TWI.TWCR.TWIE := TRUE; Reg_TWI.TWCR.TWEA := TRUE; if Is_Slave then Reg_TWI.TWAR.TWA := To_Bit_Array_7_Bit (Byte_Type (Address)).Bit_Array_7; -- (2 * Address) + 1; -- Respond to General Call Address Twi_Operation := TWI_SLAVE; else Twi_Operation := TWI_MASTER; end if; end Initialize; function Write_Data (Address : Interfaces.Unsigned_8; Data : Data_Buffer_Type) return Boolean is Request : constant Request_Type := TW_WRITE; begin if Twi_State = TWI_READY and Twi_TX_Trial_Flag = False then Twi_Data_Sent_Flag := False; Twi_TX_Trial_Flag := True; for Index in Data.Data_Buffer'Range loop Twi_Buffer.Data_Buffer (Index) := Data.Data_Buffer (Index); end loop; Twi_Buffer.Buffer_Size := Data.Buffer_Size; Twi_Buffer.Buffer_Index := Buffer_Range_Type'First; Twi_State := TWI_BUSY_MT; Twi_Error_State := TWI_NO_ERROR; -- Address is shifted to the left Twi_SLA_RW := (2 * Address) or Request_Type'Pos (Request); -- Send START condition Reg_TWI.TWCR.TWEN := TRUE; Reg_TWI.TWCR.TWIE := TRUE; Reg_TWI.TWCR.TWEA := TRUE; Reg_TWI.TWCR.TWINT := TRUE; Reg_TWI.TWCR.TWSTA := TRUE; pragma Compile_Time_Warning (TIME_WARNING_FLAG, "creio que o primeiro if fecha aqui, certo?"); end if; if Twi_State = TWI_READY then Twi_TX_Trial_Flag := False; return True; else return False; end if; exception when others => return False; end Write_Data; function Request_Data (Address : Interfaces.Unsigned_8; Size : Buffer_Range_Type) return Boolean is Request : constant Request_Type := TW_READ; begin if Twi_State = TWI_READY and Twi_RX_Trial_Flag = False then Twi_Buffer.Buffer_Index := Buffer_Range_Type'First; Twi_Buffer.Buffer_Size := Size; Twi_RX_Trial_Flag := True; Twi_Error_State := TWI_NO_ERROR; Twi_State := TWI_BUSY_MR; -- Address is shifted to the left Twi_SLA_RW := (2 * Address) or Request_Type'Pos (Request); -- Send START condition Reg_TWI.TWCR.TWEN := TRUE; Reg_TWI.TWCR.TWIE := TRUE; Reg_TWI.TWCR.TWEA := TRUE; Reg_TWI.TWCR.TWINT := TRUE; Reg_TWI.TWCR.TWSTA := TRUE; end if; if Twi_State = TWI_READY then Twi_RX_Trial_Flag := False; return True; else return False; end if; end Request_Data; procedure Handle_Interrupts is -- Curr_Status masks out bits 0 to 2 (they are not status code bits) Curr_Status_Only : constant TWI_Status_Register_Type := (TWS3 => Reg_TWI.TWSR.TWS3, TWS4 => Reg_TWI.TWSR.TWS4, TWS5 => Reg_TWI.TWSR.TWS5, TWS6 => Reg_TWI.TWSR.TWS6, TWS7 => Reg_TWI.TWSR.TWS7, TWPS => (others => FALSE), others => (others => 0)); Curr_Status : constant Interfaces.Unsigned_8 := Unsigned_8 (To_Byte (Curr_Status_Only)); procedure Reply (Ack : Boolean) is begin if Ack then Reg_TWI.TWCR.TWEN := TRUE; Reg_TWI.TWCR.TWIE := TRUE; Reg_TWI.TWCR.TWEA := TRUE; Reg_TWI.TWCR.TWINT := TRUE; else Reg_TWI.TWCR.TWEN := TRUE; Reg_TWI.TWCR.TWIE := TRUE; Reg_TWI.TWCR.TWINT := TRUE; end if; end Reply; procedure Stop is begin Reg_TWI.TWCR.TWEN := TRUE; Reg_TWI.TWCR.TWIE := TRUE; Reg_TWI.TWCR.TWEA := TRUE; Reg_TWI.TWCR.TWINT := TRUE; Reg_TWI.TWCR.TWSTO := TRUE; loop exit when not Reg_TWI.TWCR.TWSTO; end loop; Twi_State := TWI_READY; end Stop; procedure Release is begin Reg_TWI.TWCR.TWEN := TRUE; Reg_TWI.TWCR.TWIE := TRUE; Reg_TWI.TWCR.TWEA := TRUE; Reg_TWI.TWCR.TWINT := TRUE; Twi_State := TWI_READY; end Release; pragma Unreferenced (Release); Status : Boolean := False; pragma Unreferenced (Status); begin -- Status := USART.Put_Line_USART("I"); case Curr_Status is -- =================== Master Mode when START | REPEATED_START => -- Send SLA_RW Reg_TWI.TWDR := Byte_Type (Twi_SLA_RW); Reply (True); -- Status := USART.Put_Line_USART("S"); when MT_SLAW_ACK | MT_DATA_ACK => -- address/data acked by receiver if (not Twi_Data_Sent_Flag) then Reg_TWI.TWDR := Byte_Type (Twi_Buffer.Data_Buffer (Twi_Buffer.Buffer_Index)); Twi_Buffer.Buffer_Index := Twi_Buffer.Buffer_Index + 1; if Twi_Buffer.Buffer_Index > Twi_Buffer.Buffer_Size then -- if next free index is outside the size Twi_Data_Sent_Flag := True; -- Status := USART.Put_Line_USART("."); end if; Reply (True); -- Status := USART.Put_Line_USART("T_A"); else Stop; -- Status := USART.Put_Line_USART("T_St"); end if; when MT_SLAW_NACK | MT_DATA_NACK => -- address/data nacked Twi_Error_State := TWI_NACK; Stop; -- Status := USART.Put_Line_USART("T_N"); when MR_SLAR_ACK => -- SLA_R acked, nothing to do for master, just wait for data Reply (True); -- Status := USART.Put_Line_USART("R_Ad"); when MR_SLAR_NACK => -- SLA_R not acked, something went wrong Stop; -- Status := USART.Put_Line_USART("R_A_N"); when MR_DATA_ACK => -- non-last data acked (the last data byte has to be nacked) Twi_Buffer.Data_Buffer (Twi_Buffer.Buffer_Index) := Unsigned_8 (Reg_TWI.TWDR); Twi_Buffer.Buffer_Index := Twi_Buffer.Buffer_Index + 1; Twi_Buffer.Is_New_Data := True; -- Status := USART.Put_Line_USART("R_Dt"); if Twi_Buffer.Buffer_Index <= Twi_Buffer.Buffer_Size then Reply (True); else Reply (False); end if; when MR_DATA_NACK => -- last data nacked, as it should be Twi_Buffer.Data_Buffer (Twi_Buffer.Buffer_Index) := Unsigned_8 (Reg_TWI.TWDR); Twi_Buffer.Buffer_Index := Twi_Buffer.Buffer_Index + 1; Stop; -- Status := USART.Put_Line_USART("R_D_N"); when ERR_ARBIT_LOST => Twi_Error_State := TWI_LOST_ARBITRATION; -- Status := USART.Put_Line_USART("LOST"); -- =================== Slave Mode when SR_SLAW_ACK | SR_GCAW_ACK => --SLA_W received and acked, prepare for data receiving Twi_Buffer.Buffer_Index := 1; Twi_Buffer.Data_Buffer := (others => 0); Twi_Buffer.Is_New_Data := False; Reply (True); -- Status := USART.Put_Line_USART("S_R_A"); when SR_DATA_ACK | SR_DATA_GCA_ACK=> --a byte was received, store it and Twi_Buffer.Data_Buffer (Twi_Buffer.Buffer_Index) := Unsigned_8 (Reg_TWI.TWDR); Twi_Buffer.Buffer_Index := Twi_Buffer.Buffer_Index + 1; Twi_Buffer.Is_New_Data := True; -- Status := USART.Put_Line_USART("S_R_D"); if Twi_Buffer.Buffer_Index < MAX_BUFFER_RANGE then Reply (True); else Reply (False); end if; ---------------- error recovery ---------------------------------- when SR_DATA_NACK | SR_DATA_GCA_NACK => --data received but not acked --should not happen if the master is behaving as expected --switch to not adressed mode Reply (True); -- Status := USART.Put_Line_USART("S_N"); -----------------Slave Transmitter-------------------------------- when ST_DATA_ACK | ST_SLAW_ACK => --data transmitted and acked by master, load next if (not Twi_Data_Sent_Flag) then Reg_TWI.TWDR := Byte_Type (Twi_Buffer.Data_Buffer (Twi_Buffer.Buffer_Index)); Twi_Buffer.Buffer_Index := Twi_Buffer.Buffer_Index + 1; if Twi_Buffer.Buffer_Index > Twi_Buffer.Buffer_Size then -- if next free index is outside the size Twi_Data_Sent_Flag := True; end if; Reply (True); else Stop; end if; -- Status := USART.Put_Line_USART("S_T_A"); when ST_LAST_DATA_ACK => --last byte send and acked by master --last bytes should not be acked, ignore till start/stop --reset=1; Stop; -- Status := USART.Put_Line_USART("S_T_L"); when ST_DATA_NACK => --last byte send and nacked by master (as should be) Reply(True); -- Status := USART.Put_Line_USART("S_T_L_N"); ----------------- Others -------------------------------- when SR_SLAWR_ACK | SR_GCAWR_ACK | ST_SLAWR_ACK=>--adressed as slave while in master mode. --should never happen, better reset; -- reset=1; Stop; -- Status := USART.Put_Line_USART("S_E"); when STOP_REP_START => --Stop or rep start, reset state machine Reply(True); -- Status := USART.Put_Line_USART("S"); when others => null; -- Status := USART.Put_Line_USART("E!"); end case; exception when others => null; end Handle_Interrupts; function Get_Error return Error_State_Type is begin return Twi_Error_State; end Get_Error; function Is_Data_Available return Boolean is begin return Twi_Buffer.Is_New_Data; end Is_Data_Available; function Get_Last_Data return Interfaces.Unsigned_8 is begin if Twi_Buffer.Buffer_Index > 1 then Twi_Buffer.Is_New_Data := False; return Twi_Buffer.Data_Buffer (Twi_Buffer.Buffer_Index - 1); else return 0; end if; exception when others => return 0; end Get_Last_Data; function Get_Data (Prm_Index : Buffer_Range_Type) return Interfaces.Unsigned_8 is begin Twi_Buffer.Is_New_Data := False; return Twi_Buffer.Data_Buffer (Prm_Index); exception when others => return 0; end Get_Data; end AVR.TWI;
reznikmm/matreshka
Ada
4,699
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with XML.DOM.Visitors; with ODF.DOM.Office_Script_Elements; package Matreshka.ODF_Office.Script_Elements is type Office_Script_Element_Node is new Matreshka.ODF_Office.Abstract_Office_Element_Node and ODF.DOM.Office_Script_Elements.ODF_Office_Script with null record; overriding function Create (Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters) return Office_Script_Element_Node; overriding function Get_Local_Name (Self : not null access constant Office_Script_Element_Node) return League.Strings.Universal_String; overriding procedure Enter_Node (Self : not null access Office_Script_Element_Node; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control); overriding procedure Leave_Node (Self : not null access Office_Script_Element_Node; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control); overriding procedure Visit_Node (Self : not null access Office_Script_Element_Node; Iterator : in out XML.DOM.Visitors.Abstract_Iterator'Class; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control); end Matreshka.ODF_Office.Script_Elements;
zhmu/ananas
Ada
422
adb
-- { dg-do run } -- { dg-options "-O2" } with Unchecked_Conversion; procedure gnat_malloc is type int1 is new integer; type int2 is new integer; type a1 is access int1; type a2 is access int2; function to_a2 is new Unchecked_Conversion (a1, a2); v1 : a1 := new int1; v2 : a2 := to_a2 (v1); begin v1.all := 1; v2.all := 0; if v1.all /= 0 then raise Program_Error; end if; end;
PThierry/ewok-kernel
Ada
9,285
ads
-- -- Copyright 2018 The wookey project team <[email protected]> -- - Ryad Benadjila -- - Arnauld Michelizza -- - Mathieu Renard -- - Philippe Thierry -- - Philippe Trebuchet -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. -- -- with system; package soc.usart with spark_mode => off is -------------------------------- -- Status register (USART_SR) -- -------------------------------- type t_USART_SR is record PE : boolean; -- Parity error FE : boolean; -- Framing error NF : boolean; -- Noise detected flag ORE : boolean; -- Overrun error IDLE : boolean; -- IDLE line detected RXNE : boolean; -- Read data register not empty TC : boolean; -- Transmission complete TXE : boolean; -- Transmit data register empty LBD : boolean; -- LIN break detection flag CTS : boolean; -- CTS flag end record with volatile_full_access, size => 32; for t_USART_SR use record PE at 0 range 0 .. 0; FE at 0 range 1 .. 1; NF at 0 range 2 .. 2; ORE at 0 range 3 .. 3; IDLE at 0 range 4 .. 4; RXNE at 0 range 5 .. 5; TC at 0 range 6 .. 6; TXE at 0 range 7 .. 7; LBD at 0 range 8 .. 8; CTS at 0 range 9 .. 9; end record; ------------------------------ -- Data register (USART_DR) -- ------------------------------ type t_USART_DR is new bits_9 with volatile_full_access, size => 32; ------------------------------------ -- Baud rate register (USART_BRR) -- ------------------------------------ type t_USART_BRR is record DIV_FRACTION : bits_4; DIV_MANTISSA : bits_12; end record with volatile_full_access, size => 32; for t_USART_BRR use record DIV_FRACTION at 0 range 0 .. 3; DIV_MANTISSA at 0 range 4 .. 15; end record; ------------------------------------ -- Control register 1 (USART_CR1) -- ------------------------------------ type t_parity is (PARITY_EVEN, PARITY_ODD) with size => 1; for t_parity use (PARITY_EVEN => 0, PARITY_ODD => 1); type t_data_len is (DATA_8BITS, DATA_9BITS) with size => 1; for t_data_len use (DATA_8BITS => 0, DATA_9BITS => 1); type t_USART_CR1 is record SBK : boolean; -- Send break RWU : boolean; -- Receiver wakeup RE : boolean; -- Receiver enable TE : boolean; -- Transmitter enable IDLEIE : boolean; -- IDLE interrupt enable RXNEIE : boolean; -- RXNE interrupt enable TCIE : boolean; -- Transmission complete interrupt enable TXEIE : boolean; -- TXE interrupt enable PEIE : boolean; -- PE interrupt enable PS : t_parity; -- Parity selection PCE : boolean; -- Parity control enable WAKE : boolean; -- Wakeup method M : t_data_len; -- Word length UE : boolean; -- USART enable reserved_14_14 : bit; OVER8 : boolean; -- Oversampling mode end record with volatile_full_access, size => 32; for t_USART_CR1 use record SBK at 0 range 0 .. 0; RWU at 0 range 1 .. 1; RE at 0 range 2 .. 2; TE at 0 range 3 .. 3; IDLEIE at 0 range 4 .. 4; RXNEIE at 0 range 5 .. 5; TCIE at 0 range 6 .. 6; TXEIE at 0 range 7 .. 7; PEIE at 0 range 8 .. 8; PS at 0 range 9 .. 9; PCE at 0 range 10 .. 10; WAKE at 0 range 11 .. 11; M at 0 range 12 .. 12; UE at 0 range 13 .. 13; Reserved_14_14 at 0 range 14 .. 14; OVER8 at 0 range 15 .. 15; end record; ------------------------------------ -- Control register 2 (USART_CR2) -- ------------------------------------ type t_stop_bits is (STOP_1, STOP_0_dot_5, STOP_2, STOP_1_dot_5) with size => 2; for t_stop_bits use (STOP_1 => 2#00#, STOP_0_dot_5 => 2#01#, STOP_2 => 2#10#, STOP_1_dot_5 => 2#11#); type t_USART_CR2 is record ADD : bits_4; -- Address of the USART node reserved_4_4 : bit; LBDL : boolean; -- lin break detection length LBDIE : boolean; -- LIN break detection interrupt enable reserved_7_7 : bit; LBCL : boolean; -- Last bit clock pulse CPHA : boolean; -- Clock phase CPOL : boolean; -- Clock polarity CLKEN : boolean; -- Clock enable STOP : t_stop_bits; -- STOP bits LINEN : boolean; -- LIN mode enable end record with volatile_full_access, size => 32; for t_USART_CR2 use record ADD at 0 range 0 .. 3; reserved_4_4 at 0 range 4 .. 4; LBDL at 0 range 5 .. 5; LBDIE at 0 range 6 .. 6; reserved_7_7 at 0 range 7 .. 7; LBCL at 0 range 8 .. 8; CPHA at 0 range 9 .. 9; CPOL at 0 range 10 .. 10; CLKEN at 0 range 11 .. 11; STOP at 0 range 12 .. 13; LINEN at 0 range 14 .. 14; end record; ------------------------------------ -- Control register 3 (USART_CR3) -- ------------------------------------ type t_USART_CR3 is record EIE : boolean; -- Error interrupt enable IREN : boolean; -- IrDA mode enable IRLP : boolean; -- IrDA low-power HDSEL : boolean; -- Half-duplex selection NACK : boolean; -- Smartcard NACK enable SCEN : boolean; -- Smartcard mode enable DMAR : boolean; -- DMA enable receiver DMAT : boolean; -- DMA enable transmitter RTSE : boolean; -- RTS enable CTSE : boolean; -- CTS enable CTSIE : boolean; -- CTS interrupt enable ONEBIT : boolean; -- One sample bit method enable end record with volatile_full_access, size => 32; for t_USART_CR3 use record EIE at 0 range 0 .. 0; IREN at 0 range 1 .. 1; IRLP at 0 range 2 .. 2; HDSEL at 0 range 3 .. 3; NACK at 0 range 4 .. 4; SCEN at 0 range 5 .. 5; DMAR at 0 range 6 .. 6; DMAT at 0 range 7 .. 7; RTSE at 0 range 8 .. 8; CTSE at 0 range 9 .. 9; CTSIE at 0 range 10 .. 10; ONEBIT at 0 range 11 .. 11; end record; ---------------------------------------------------- -- Guard time and prescaler register (USART_GTPR) -- ---------------------------------------------------- type t_USART_GTPR is record PSC : unsigned_8; -- Prescaler value GT : unsigned_8; -- Guard time value end record with volatile_full_access, size => 32; for t_USART_GTPR use record PSC at 0 range 0 .. 7; GT at 0 range 8 .. 15; end record; ---------------------- -- USART peripheral -- ---------------------- type t_USART_peripheral is record SR : t_USART_SR; DR : t_USART_DR; BRR : t_USART_BRR; CR1 : t_USART_CR1; CR2 : t_USART_CR2; CR3 : t_USART_CR3; GTPR : t_USART_GTPR; end record with volatile; for t_USART_peripheral use record SR at 16#00# range 0 .. 31; DR at 16#04# range 0 .. 31; BRR at 16#08# range 0 .. 31; CR1 at 16#0C# range 0 .. 31; CR2 at 16#10# range 0 .. 31; CR3 at 16#14# range 0 .. 31; GTPR at 16#18# range 0 .. 31; end record; type t_USART_peripheral_access is access all t_USART_peripheral; USART1 : aliased t_USART_peripheral with import, volatile, address => system'to_address(16#4001_1000#); USART6 : aliased t_USART_peripheral with import, volatile, address => system'to_address(16#4001_1400#); UART4 : aliased t_USART_peripheral with import, volatile, address => system'to_address(16#4000_4C00#); procedure set_baudrate (usart : in t_USART_peripheral_access; baudrate : in unsigned_32); procedure transmit (usart : in t_USART_peripheral_access; data : in t_USART_DR); procedure receive (usart : in t_USART_peripheral_access; data : out t_USART_DR); end soc.usart;
zhmu/ananas
Ada
7,702
ads
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- E X P _ F I X D -- -- -- -- S p e c -- -- -- -- Copyright (C) 1992-2022, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -- -- for more details. You should have received a copy of the GNU General -- -- Public License distributed with GNAT; see file COPYING3. If not, go to -- -- http://www.gnu.org/licenses for a complete copy of the license. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ -- Expand routines for fixed-point convert, divide and multiply operations with Types; use Types; package Exp_Fixd is -- General note on universal fixed. In the routines below, a fixed-point -- type is always a specific fixed-point type or universal real, never -- universal fixed. Universal fixed only appears as the result type of a -- division or multiplication and in all such cases, the parent node, which -- must be either a conversion node or a 'Round attribute reference node, -- has the specific type information. In both cases, the parent node is -- removed from the tree, and the appropriate routine in this package is -- called with a multiply or divide node with all types (and also possibly -- the Rounded_Result flag) set. ---------------------------- -- Fixed-Point Conversion -- ---------------------------- procedure Expand_Convert_Fixed_To_Fixed (N : Node_Id); -- This routine expands the conversion of one fixed-point type to another, -- N is the N_Op_Conversion node with the result and expression types (and -- possibly the Rounded_Result flag) set. procedure Expand_Convert_Fixed_To_Float (N : Node_Id); -- This routine expands the conversion from a fixed-point type to a -- floating-point type. N is an N_Type_Conversion node with the result -- and expression types set. procedure Expand_Convert_Fixed_To_Integer (N : Node_Id); -- This routine expands the conversion from a fixed-point type to an -- integer type. N is an N_Type_Conversion node with the result and -- operand types set. procedure Expand_Convert_Float_To_Fixed (N : Node_Id); -- This routine expands the conversion from a floating-point type to -- a fixed-point type. N is an N_Type_Conversion node with the result -- and operand types (and possibly the Rounded_Result flag) set. procedure Expand_Convert_Integer_To_Fixed (N : Node_Id); -- This routine expands the conversion from an integer type to a -- fixed-point type. N is an N_Type_Conversion node with the result -- and operand types (and possibly the Rounded_Result flag) set. -------------------------- -- Fixed-Point Division -- -------------------------- procedure Expand_Decimal_Divide_Call (N : Node_Id); -- This routine expands a call to the procedure Decimal.Divide. The -- argument N is the N_Function_Call node. procedure Expand_Divide_Fixed_By_Fixed_Giving_Fixed (N : Node_Id); -- This routine expands the division between fixed-point types, with -- a fixed-point type result. N is an N_Op_Divide node with operand -- and result types (and possibly the Rounded_Result flag) set. Either -- (but not both) of the operands may be universal real. procedure Expand_Divide_Fixed_By_Fixed_Giving_Float (N : Node_Id); -- This routine expands the division between two fixed-point types with -- a floating-point result. N is an N_Op_Divide node with the result -- and operand types set. Either (but not both) of the operands may be -- universal real. procedure Expand_Divide_Fixed_By_Fixed_Giving_Integer (N : Node_Id); -- This routine expands the division between two fixed-point types with -- an integer type result. N is an N_Op_Divide node with the result and -- operand types set. Either (but not both) of the operands may be -- universal real. procedure Expand_Divide_Fixed_By_Integer_Giving_Fixed (N : Node_Id); -- This routine expands the division between a fixed-point type and -- standard integer type. The result type is the same fixed-point type -- as the operand type. N is an N_Op_Divide node with the result and -- left operand types being the fixed-point type, and the right operand -- type being standard integer (and possibly Rounded_Result set). -------------------------------- -- Fixed-Point Multiplication -- -------------------------------- procedure Expand_Multiply_Fixed_By_Fixed_Giving_Fixed (N : Node_Id); -- This routine expands the multiplication between fixed-point types -- with a fixed-point type result. N is an N_Op_Multiply node with the -- result and operand types set. Either (but not both) of the operands -- may be universal real. procedure Expand_Multiply_Fixed_By_Fixed_Giving_Float (N : Node_Id); -- This routine expands the multiplication between two fixed-point types -- with a floating-point result. N is an N_Op_Multiply node with the -- result and operand types set. Either (but not both) of the operands -- may be universal real. procedure Expand_Multiply_Fixed_By_Fixed_Giving_Integer (N : Node_Id); -- This routine expands the multiplication between two fixed-point types -- with an integer result. N is an N_Op_Multiply node with the result -- and operand types set. Either (but not both) of the operands may be -- be universal real. procedure Expand_Multiply_Fixed_By_Integer_Giving_Fixed (N : Node_Id); -- This routine expands the multiplication between a fixed-point type and -- a standard integer type. The result type is the same fixed-point type -- as the fixed operand type. N is an N_Op_Multiply node whose result type -- and left operand types are the fixed-point type, and whose right operand -- type is always standard integer. procedure Expand_Multiply_Integer_By_Fixed_Giving_Fixed (N : Node_Id); -- This routine expands the multiplication between standard integer and a -- fixed-point type. The result type is the same fixed-point type as the -- fixed operand type. N is an N_Op_Multiply node whose result type -- and right operand types are the fixed-point type, and whose left operand -- type is always standard integer. end Exp_Fixd;
jnguyen1098/legacy-programs
Ada
9,112
adb
----------------------------------------------------------------------- -- Word Scrambler -- -- By: Jason Nguyen (XXXXXXX) -- ----------------------------------------------------------------------- with Ada.Text_IO; use Ada.Text_IO; with Ada.Numerics.Discrete_Random; with Ada.Characters.Handling; use Ada.Characters.Handling; with Ada.Directories; use Ada.Directories; procedure Scramble is -------------------------- Main Subprograms --------------------------- procedure getFilename(File_Name : out String; Len : out Integer); function processText(File_Name : String) return Integer; procedure scrambleWord(Str : in out String); function randomInt(A : Integer; B : Integer) return Integer; function isWord(Str : String) return Boolean; ----------------------------------------------------------------------- -- Verifies a filename and returns it to main procedure getFilename(File_Name : out String; Len : out Integer) is begin File_Name_Check: loop -- Prompt user for filename Put("File name to open: "); Get_Line(File_Name, Len); -- Filename testing. Assumed to ask again if loop doesn't break if (File_Name(File_Name'First .. Len) = "" or else File_Name(File_Name'First .. File_Name'First) = "." or else File_Name(File_Name'First .. File_Name'First) = "/" or else exists(File_Name(File_Name'First .. Len)) = False) then Put_Line("Could not open file! Re-try."); New_Line; -- Loop will break and function will exit assuming all tests pass else exit File_Name_Check; end if; end loop File_Name_Check; end getFilename; ----------------------------------------------------------------------- -- Processes the words within a file function processText(File_Name : String) return Integer is Word_Count : Integer := 0; Fp : Ada.Text_IO.File_Type; begin -- Open the file for playback Open(File => Fp, Mode => In_File, Name => File_Name); -- Print every original line Put_Line(" O r i g i n a l T e x t"); Put_Line("--------------------------------------------------" & "----------------------"); while not End_Of_File(Fp) loop Put_Line(Get_Line(Fp)); end loop; New_Line; Close(Fp); -- Attempt to open the file again, this time for processing Open(File => Fp, Mode => In_File, Name => File_Name); -- Process file by iterating over every line Put_Line(" T r a n s p o s e d T e x t"); Put_Line("--------------------------------------------------" & "----------------------"); -- Like above, we iterate over the file while not End_Of_File(Fp) loop declare -- Left and Right represent slice/substring indices for parsing -- Line is the fixed string holding the line. Because it is within -- block scope with the loop, we do not have to use unbounded -- string. This is because we re-create it every loop iteration. Left : Integer := 1; Right : Integer := 1; Line : String := Get_Line(Fp); begin -- Parsing algorithm that aims to 'greedily' select the largest -- word using Left and Right to index potential substrings, and -- then moving to the next potential candidate. -- This algorithm will backtrack upon discovering a non-alpha -- character and use the backtracked 'word' as the scramble target. -- Otherwise, it will just print out, one-by-one, as many non- -- alpha characters as possible before returning to the greedy -- word building algorithm as mentioned earlier. -- This algorithm, as shown in this while loop, will only run for -- the length of the current line. This is for bounds-checking. while Left <= Line'Length and then Right <= Line'Length loop -- If current substring is a word... if isWord(Line(Left .. Right)) then -- ...then greedily grow it until it is no longer a word. while Right <= Line'Length and then isWord(Line(Left .. Right)) loop Right := Right + 1; end loop; -- Upon finding a non-alpha character, we backtrack 1 Right := Right - 1; -- We know that this backtracked word is the largest -- possible substring that satisfies isWord(), so we go on -- to scramble it in-place and then print it. scrambleWord(Line(Left .. Right)); Put(Line(Left .. Right)); -- In doing so, we increment the word count. Word_Count := Word_Count + 1; -- Then, we set both Left and Right indices into the first -- character following the word we just scrambled. Right := Right + 1; Left := Right; -- Otherwise, if the current substring is NOT a word... else -- ...we don't want to do anything else but print it. Put(Line(Left .. Right)); -- In fact, we print AS MANY non-alphabetic characters as -- possible. As long as there are more, it will always -- fall back to this else statement. Left := Left + 1; Right := Right + 1; end if; end loop; -- We are finished parsing the file New_Line; -- Putting a new line for cleanliness end; -- End loop scope end loop; -- End the actual loop -- Close the file when we are done and return word count Close(Fp); return Word_Count; end processText; ----------------------------------------------------------------------- -- Scramble a string / "word" in-place procedure scrambleWord(Str : in out String) is -- Copies the string not including first/last char. Copy : String := Str(Str'First + 1 .. Str'Last - 1); Rand : Integer; begin -- Only words 4 char. or greater will be scrambled if Str'Length > 3 then -- Iterate over the middle characters for i in 2 .. Str'Length - 1 loop -- Keep looping until we get a unique letter loop Rand := randomInt(A => Copy'First, B => Copy'Last + 1); exit when Copy(Rand) /= '.'; end loop; -- Copy this character over to the scrambled word Str(Str'First + i - 1) := Copy(Rand); -- Mark the original character spot as "used". -- This method only works because only true words -- are passed to scrambleWord(). Copy(Rand) := '.'; end loop; end if; end scrambleWord; ----------------------------------------------------------------------- -- Check if a string is completely alphabetic function isWord(Str : String) return Boolean is begin -- Check for empty string if Str = "" then return False; end if; -- Check if each character is alphabetic for i in Str'First .. Str'Last loop if not Is_Letter(Str(i)) then return False; end if; end loop; -- If we reach this point, it's a good string and we exit return true; end isWord; ----------------------------------------------------------------------- -- Generate a random number on the interval [A, B) (incl. - excl.) function randomInt(A : Integer; B : Integer) return Integer is subtype IntGen is Integer range A .. B - 1; package RandGen is new Ada.Numerics.Discrete_Random (IntGen); use RandGen; RandIntGen : Generator; begin -- Generate our number Reset(RandIntGen); return Random(RandIntGen); end randomInt; ------------------------------ Variables ------------------------------ File_Name_Len : Integer; File_Name : String(1..5000); Num_Words : Integer; -------------------------------- Main --------------------------------- begin getFilename(File_Name, File_Name_Len); New_Line; Num_Words := processText(File_Name(1..File_Name_Len)); New_Line; Put_Line("Word count: " & Integer'Image(Num_Words)); end Scramble; -----------------------------------------------------------------------
reznikmm/matreshka
Ada
3,699
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with XML.DOM.Attributes; package ODF.DOM.Form_Command_Attributes is pragma Preelaborate; type ODF_Form_Command_Attribute is limited interface and XML.DOM.Attributes.DOM_Attribute; type ODF_Form_Command_Attribute_Access is access all ODF_Form_Command_Attribute'Class with Storage_Size => 0; end ODF.DOM.Form_Command_Attributes;
AdaCore/training_material
Ada
6,903
adb
with Ada.Characters.Handling; with Except; with Ada.Text_IO; use Ada.Text_IO; package body Input is ---------------- -- Local Data -- ---------------- subtype Printable_Character is Character range '!' .. '~'; -- In ASCII the first printable non blank character is '!', the last one -- is '~'. Line_Size : constant := 1024; Line : String (1 .. Line_Size); -- Used to save the current input line. First_Char : Positive := 1; -- Indicates the position of the first character in Line that has not yet -- been read by the routine Get_Char below. Last_Char : Natural := 0; -- Gives the position of the last valid character in Line; Line_Num : Natural := 0; -- Keeps track of the number of lines read for the input. -------------------- -- Local Routines -- -------------------- function Get_Char return Character; -- Reads and returns the next character from the input. function End_Line (N : Positive := 1) return Boolean; -- Returns True if at least N characters can be read from Line, before -- reaching its end. If End_Line (1) returns True then all the available -- characters in Line have been read by the Get_Char. procedure Read_New_Line; -- Reads in Line a new input line. procedure Skip_Spaces; -- Skip all spaces, tabs and carriage returns from the input and advance -- the current character on the first non blank character. procedure Unread_Char (N : Positive := 1); -- If the last N characters read from the input did not contain a -- carriage return, unreads these N characters, ie it puts them back in -- the stream of input characters to read. Otherwise unread the last k < -- N characters that followed the last carriage return. ------------------- -- Column_Number -- ------------------- function Column_Number return Natural Col : Natural := 0; begin -- The column computation is complicated by the presence of TAB (HT) -- characters. In fact when you hit a TAB your next column is the -- closest multiple of 8 (so if you are in column 14 and you hit a -- TAB the column number becomes 16). for I in 1 .. First_Char - 1 loop if Line (I) /= ASCII.HT then Col := Col + 1; else Col := Col + 8 - (Col mod 8); end if; end loop; return Col; end Column_Number; ------------------ -- Current_Line -- ------------------ function Current_Line return String is begin return Line (Line'First .. Last_Char); end Current_Line; -------------- -- End_Line -- -------------- function End_Line (N : Positive := 1) return Boolean is begin return Last_Char < First_Char + (N - 1); end End_Line; -------------- -- Get_Char -- -------------- function Get_Char return Character is C : Character; begin -- First check if the line is empty or has been all read. if End_Line then Read_New_Line; end if; C := Line (First_Char); First_Char := First_Char + 1; return C; end Get_Char; ----------------- -- Line_Number -- ----------------- function Line_Number return Natural is begin return Line_Num; end Line_Number; ----------------- -- Next_Number -- ----------------- procedure Read_Number (S : in String; I : out Integer; R : out Float; K : out Number_Kind) is -- GNAT may complain that I and R are not always set by this -- procedure, so disable corresponding warnings. pragma Warnings (Off, I); pragma Warnings (Off, R); package Int_Io is new Ada.Text_IO.Integer_IO (Integer); package Real_Io is new Ada.Text_IO.Float_IO (Float); Last : Positive; begin K := No_Number; I := 0; R := 0.0; Try_Integer : declare begin Int_Io.Get (From => S, Item => I, Last => Last); if Last = S'Last then K := Int_Number; return; end if; exception when Ada.Text_IO.Data_Error => null; end Try_Integer; Try_Float : declare begin Real_Io.Get (From => S, Item => R, Last => Last); if Last = S'Last then K := Real_Number; return; end if; exception when Ada.Text_IO.Data_Error => null; end Try_Float; end Read_Number; --------------- -- Next_Word -- --------------- function Next_Word return String is Start : Natural; begin Input.Skip_Spaces; Start := First_Char; while Line (First_Char) in Printable_Character loop First_Char := First_Char + 1; end loop; -- Now convert the string to an upper case string of characters declare S : String := Line (Start .. First_Char - 1); begin for I in S'Range loop S (I) := Ada.Characters.Handling.To_Upper (S (I)); end loop; return S; end; end Next_Word; ------------------- -- Read_New_Line -- ------------------- procedure Read_New_Line is use type Ada.Text_IO.File_Access; begin First_Char := Line'First; if Ada.Text_IO.End_Of_File then raise Except.Exit_SDC; end if; -- Read a line from the standard input. Routine Text_Io.Get_Line -- reads all the input character up to (but not including) the next -- carriage return into Line. After this call Last_Char contains the -- number of characters read into Line. Ada.Text_IO.Get_Line (Line, Last_Char); if Ada.Text_IO.Current_Input /= Ada.Text_IO.Standard_Input then Ada.Text_IO.Put_Line (Line (Line'First .. Last_Char)); end if; -- Save a carriage return at the end of the Line and update the line -- count. Last_Char := Last_Char + 1; Line (Last_Char) := ASCII.CR; Line_Num := Line_Num + 1; end Read_New_Line; --------------- -- Skip_Line -- --------------- procedure Skip_Line is begin First_Char := Last_Char + 1; end Skip_Line; ----------------- -- Skip_Spaces -- ----------------- procedure Skip_Spaces is Current_Char : Character; begin loop Current_Char := Input.Get_Char; exit when Current_Char in Printable_Character; end loop; -- We must unread the non blank character just read. Input.Unread_Char; end Skip_Spaces; ----------------- -- Unread_Char -- ----------------- procedure Unread_Char (N : Positive := 1) is begin if First_Char - N >= Line'First then First_Char := First_Char - N; else First_Char := Line'First; end if; end Unread_Char; end Input;
zhmu/ananas
Ada
397
ads
-- { dg-do compile } package Volatile1 is C : Character; for C'Size use 32; pragma Volatile (C); type R1 is record C: Character; pragma Volatile (C); end record; for R1 use record C at 0 range 0 .. 31; end record; type R2 is record C: Character; pragma Volatile (C); end record; for R2 use record C at 0 range 0 .. 10; end record; end Volatile1;
pvrego/adaino
Ada
2,850
ads
-- ============================================================================= -- Package AVR.IO_MEMORY -- -- Handles the external memory. -- - EEPROM -- - GPIO -- - XMCR -- ============================================================================= package AVR.IO_MEMORY is type EEPROM_Address_Word_Type is new Byte_Array_Type (0 .. 1); Reg_EEAR : EEPROM_Address_Word_Type; for Reg_EEAR'Address use System'To_Address (16#41#); type EEPROM_Data_Register_Type is new Byte_Type; Reg_EEDR : EEPROM_Data_Register_Type; for Reg_EEDR'Address use System'To_Address (16#40#); type Eeprom_Control_Register_Type is record EERE : Boolean; -- EEPROM Read Enable EEPE : Boolean; -- EEPROM Programming Enable EEMPE : Boolean; -- EEPROM Master Programming Enable EERIE : Boolean; -- EEPROM Ready Interrupt Enable EEPM0 : Boolean; -- EEPROM Programming Mode Bit 0 EEPM1 : Boolean; -- EEPROM Programming Mode Bit 1 Spare : Spare_Type (0 .. 1); end record; pragma Pack (Eeprom_Control_Register_Type); for Eeprom_Control_Register_Type'Size use BYTE_SIZE; Reg_EECR : Eeprom_Control_Register_Type; for Reg_EECR'Address use System'To_Address (16#3F#); -- ============================= -- General Purpose I/O Registers -- ============================= type GPIO_Type is new Byte_Type; Reg_GPIOR0 : GPIO_Type; for Reg_GPIOR0'Address use System'To_Address (16#3E#); Reg_GPIOR1 : GPIO_Type; for Reg_GPIOR1'Address use System'To_Address (16#4A#); Reg_GPIOR2 : GPIO_Type; for Reg_GPIOR2'Address use System'To_Address (16#4B#); -- ========================= -- External Memory registers -- ========================= #if MCU="ATMEGA2560" then type External_Memory_Control_A_Type is record SRWL : Bit_Array_Type (0 .. 1); -- Wait-state Select Bits for Lower Sector SRWH : Bit_Array_Type (0 .. 1); -- Wait-state Select Bits for Upper Sector SRL0 : Bit_Array_Type (0 .. 2); -- Wait-state Sector Limit Bits SRE : Boolean; -- External SRAM/XMEM Enable end record; pragma Pack (External_Memory_Control_A_Type); for External_Memory_Control_A_Type'Size use BYTE_SIZE; type External_Memory_Control_B_Type is record XMM : Bit_Array_Type (0 .. 2); -- External Memory High Mask Bits Spare : Spare_Type (0 .. 3); XMBK : Boolean; -- External Memory Bus-keeper Enable end record; pragma Pack (External_Memory_Control_B_Type); for External_Memory_Control_B_Type'Size use BYTE_SIZE; #end if; Reg_XMCRA : External_Memory_Control_A_Type; for Reg_XMCRA'Address use System'To_Address (16#74#); Reg_XMCRB : External_Memory_Control_B_Type; for Reg_XMCRB'Address use System'To_Address (16#75#); end AVR.IO_MEMORY;
AdaCore/Ada_Drivers_Library
Ada
3,044
ads
------------------------------------------------------------------------------ -- -- -- Copyright (C) 2017, AdaCore -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions are -- -- met: -- -- 1. Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- 2. Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in -- -- the documentation and/or other materials provided with the -- -- distribution. -- -- 3. Neither the name of the copyright holder nor the names of its -- -- contributors may be used to endorse or promote products derived -- -- from this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -- -- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -- -- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -- -- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -- -- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ package Command_Line.Filesystem.Remove_Directory is type Rmdir_Cmd is new Command with private; overriding function Name (This : Rmdir_Cmd) return String is ("rmdir"); overriding procedure Execute (This : in out Rmdir_Cmd; Args : in out Arguments'Class; Put : Put_Procedure; Put_Line : Put_Line_Procedure); overriding procedure Help (This : in out Rmdir_Cmd; Put : Put_Procedure; Put_Line : Put_Line_Procedure); private type Rmdir_Cmd is new Command with null record; end Command_Line.Filesystem.Remove_Directory;
Asier98/AdaCar
Ada
1,784
ads
with System; package AdaCar.Parametros is Distancia_Minima: constant Unidades_Distancia:= 10.0; -------------- -- Unidades -- -------------- Factor_Distancia: constant Unidades_Distancia:= 0.0; function Convertidor_Distancia(Valor: Unidades_AI) return Unidades_Distancia; ------------- -- Canales -- ------------- Canal_DO_Trig: Canal_DO:= Pin_D8; Canal_DI_Echo: Canal_DI:= Pin_D6; -- Se han atribuido canales aleatorios. Se tienen que configurar más adelante. Canal_DO_Motor_Derecho_A: Canal_DO:= Pin_D2; Canal_DO_Motor_Derecho_B: Canal_DO:= Pin_D3; Canal_DO_Motor_Derecho_C: Canal_DO:= Pin_D4; Canal_DO_Motor_Derecho_D: Canal_DO:= Pin_D5; Canal_DO_Motor_Izquierdo_A: Canal_DO:= Pin_D10; Canal_DO_Motor_Izquierdo_B: Canal_DO:= Pin_D11; Canal_DO_Motor_Izquierdo_C: Canal_DO:= Pin_D12; Canal_DO_Motor_Izquierdo_D: Canal_DO:= Pin_D13; -------------- -- Periodos -- -------------- Periodo_Seguimiento_Task: constant Duration:= 0.1; Periodo_Alarmas_Task : constant Duration:= 0.1; ----------------- -- Prioridades -- ----------------- Prioridad_Seguimiento_Task: constant System.Priority:= System.Priority'Last; Prioridad_Alarmas_Task: constant System.Priority:= System.Priority'Last; Techo_Sensor_Proximidad_PO: constant System.Priority:= System.Priority'Last; Techo_Motores_PO: constant System.Priority:= System.Priority'Last; Techo_Alarmas_PO: constant System.Priority:= System.Priority'Last; Techo_Entrada_Salida_PO: constant System.Priority:= System.Priority'Last; Techo_Organizador_PO: constant System.Priority:= System.Priority'Last; end AdaCar.Parametros;
reznikmm/matreshka
Ada
4,775
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2012, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ -- This file is generated, don't edit it. ------------------------------------------------------------------------------ limited with AMF.UML.Invocation_Actions; limited with AMF.UML.Opaque_Actions; package AMF.Utp.Finish_Actions is pragma Preelaborate; type Utp_Finish_Action is limited interface; type Utp_Finish_Action_Access is access all Utp_Finish_Action'Class; for Utp_Finish_Action_Access'Storage_Size use 0; not overriding function Get_Base_Opaque_Action (Self : not null access constant Utp_Finish_Action) return AMF.UML.Opaque_Actions.UML_Opaque_Action_Access is abstract; -- Getter of FinishAction::base_OpaqueAction. -- not overriding procedure Set_Base_Opaque_Action (Self : not null access Utp_Finish_Action; To : AMF.UML.Opaque_Actions.UML_Opaque_Action_Access) is abstract; -- Setter of FinishAction::base_OpaqueAction. -- not overriding function Get_Base_Invocation_Action (Self : not null access constant Utp_Finish_Action) return AMF.UML.Invocation_Actions.UML_Invocation_Action_Access is abstract; -- Getter of FinishAction::base_InvocationAction. -- not overriding procedure Set_Base_Invocation_Action (Self : not null access Utp_Finish_Action; To : AMF.UML.Invocation_Actions.UML_Invocation_Action_Access) is abstract; -- Setter of FinishAction::base_InvocationAction. -- end AMF.Utp.Finish_Actions;