aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJedidiah Barber <contact@jedbarber.id.au>2025-05-09 09:32:20 +1200
committerJedidiah Barber <contact@jedbarber.id.au>2025-05-09 09:32:20 +1200
commitb506d60f37c7bb5a870ca838072afe816fc7aa61 (patch)
tree482411cee5929bd730368716207b13dfbd91e9fb
parent8acdbfe2299ec7a96db69ee0b2ec298401c92ae8 (diff)
Constants marked constant, redundant with clauses no longer redundant
-rw-r--r--example/device_list.adb4
-rw-r--r--example/sine_block.adb2
-rw-r--r--src/portaudio-devices.adb2
-rw-r--r--src/portaudio-streams.adb44
-rw-r--r--src/portaudio-streams.ads36
-rw-r--r--src/portaudio.adb26
6 files changed, 57 insertions, 57 deletions
diff --git a/example/device_list.adb b/example/device_list.adb
index d92d2c4..329b29f 100644
--- a/example/device_list.adb
+++ b/example/device_list.adb
@@ -29,7 +29,7 @@ procedure Device_List is
(Num : in Integer)
return String
is
- Test_Out : String := Integer'Image (Num);
+ Test_Out : constant String := Integer'Image (Num);
begin
if Test_Out (Test_Out'First) = ' ' then
return Test_Out (Test_Out'First + 1 .. Test_Out'Last);
@@ -63,7 +63,7 @@ procedure Device_List is
(In_Params : access Paud.Streams.Parameters;
Out_Params : access Paud.Streams.Parameters)
is
- Standard_Sample_Rates : array (Positive range <>) of Paud.Hertz :=
+ Standard_Sample_Rates : constant array (Positive range <>) of Paud.Hertz :=
(8000.0, 9600.0, 11025.0, 12000.0, 16000.0, 22050.0, 24000.0,
32000.0, 44100.0, 48000.0, 88200.0, 96000.0, 192000.0);
Put_Counter : Natural := 0;
diff --git a/example/sine_block.adb b/example/sine_block.adb
index 538d1d9..e6d3d21 100644
--- a/example/sine_block.adb
+++ b/example/sine_block.adb
@@ -30,7 +30,7 @@ procedure Sine_Block is
-- Note how this array specifies the bounds in the initial value rather than the type.
-- This is important because otherwise the aliasing would cause subtype mismatch errors.
Sample_Array : aliased Pstm.Float_32_Array := (1 .. Natural (Per_Buffer) * Channels => 0.0);
- Sample_Buffer : Pstm.Buffer := Pstm.Wrap (Sample_Array, Per_Buffer, Channels);
+ Sample_Buffer : constant Pstm.Buffer := Pstm.Wrap (Sample_Array, Per_Buffer, Channels);
type Table_Index is mod 200;
Sine_Table : array (Table_Index) of Interfaces.IEEE_Float_32;
diff --git a/src/portaudio-devices.adb b/src/portaudio-devices.adb
index aa697ad..c123591 100644
--- a/src/portaudio-devices.adb
+++ b/src/portaudio-devices.adb
@@ -9,7 +9,7 @@ pragma Ada_2012;
with
- Interfaces.C.Strings,
+ Interfaces.C,
System;
use type
diff --git a/src/portaudio-streams.adb b/src/portaudio-streams.adb
index e067d24..d74fb08 100644
--- a/src/portaudio-streams.adb
+++ b/src/portaudio-streams.adb
@@ -266,13 +266,13 @@ package body Portaudio.Streams is
for Stream_Actual'Address use Storage.To_Address (Userdata);
pragma Import (Ada, Stream_Actual);
- Input_Buffer : Buffer :=
+ Input_Buffer : constant Buffer :=
(My_Sam_Code => Stream_Actual.Sin,
My_Channels => Natural (Stream_Actual.Chin),
My_Frames => Frame_Amount (Frame_Count),
My_Array => Storage.To_Address (Input_Ptr));
- Output_Buffer : Buffer :=
+ Output_Buffer : constant Buffer :=
(My_Sam_Code => Stream_Actual.Sout,
My_Channels => Natural (Stream_Actual.Chout),
My_Frames => Frame_Amount (Frame_Count),
@@ -494,9 +494,9 @@ package body Portaudio.Streams is
end Put;
function Wrap
- (Store : aliased in Float_32_Array;
- Frames : in Frame_Amount;
- Channels : in Natural)
+ (Store : aliased in out Float_32_Array;
+ Frames : in Frame_Amount;
+ Channels : in Natural)
return Buffer is
begin
return
@@ -507,9 +507,9 @@ package body Portaudio.Streams is
end Wrap;
function Wrap
- (Store : aliased in Int_32_Array;
- Frames : in Frame_Amount;
- Channels : in Natural)
+ (Store : aliased in out Int_32_Array;
+ Frames : in Frame_Amount;
+ Channels : in Natural)
return Buffer is
begin
return
@@ -520,9 +520,9 @@ package body Portaudio.Streams is
end Wrap;
function Wrap
- (Store : aliased in Int_24_Array;
- Frames : in Frame_Amount;
- Channels : in Natural)
+ (Store : aliased in out Int_24_Array;
+ Frames : in Frame_Amount;
+ Channels : in Natural)
return Buffer is
begin
return
@@ -533,9 +533,9 @@ package body Portaudio.Streams is
end Wrap;
function Wrap
- (Store : aliased in Int_16_Array;
- Frames : in Frame_Amount;
- Channels : in Natural)
+ (Store : aliased in out Int_16_Array;
+ Frames : in Frame_Amount;
+ Channels : in Natural)
return Buffer is
begin
return
@@ -546,9 +546,9 @@ package body Portaudio.Streams is
end Wrap;
function Wrap
- (Store : aliased in Int_8_Array;
- Frames : in Frame_Amount;
- Channels : in Natural)
+ (Store : aliased in out Int_8_Array;
+ Frames : in Frame_Amount;
+ Channels : in Natural)
return Buffer is
begin
return
@@ -559,9 +559,9 @@ package body Portaudio.Streams is
end Wrap;
function Wrap
- (Store : aliased in UInt_8_Array;
- Frames : in Frame_Amount;
- Channels : in Natural)
+ (Store : aliased in out UInt_8_Array;
+ Frames : in Frame_Amount;
+ Channels : in Natural)
return Buffer is
begin
return
@@ -623,9 +623,9 @@ package body Portaudio.Streams is
is
Code : Interfaces.C.int;
package Param_Conversions is new System.Address_To_Access_Conversions (Parameters);
- Input_Address : System.Address :=
+ Input_Address : constant System.Address :=
Param_Conversions.To_Address (Param_Conversions.Object_Pointer (Input));
- Output_Address : System.Address :=
+ Output_Address : constant System.Address :=
Param_Conversions.To_Address (Param_Conversions.Object_Pointer (Output));
begin
Code := pa_is_format_supported
diff --git a/src/portaudio-streams.ads b/src/portaudio-streams.ads
index 4a431b8..7c8c8b7 100644
--- a/src/portaudio-streams.ads
+++ b/src/portaudio-streams.ads
@@ -157,44 +157,44 @@ package Portaudio.Streams is
with Pre => Store.Kind = UInt_8_Format;
function Wrap
- (Store : aliased in Float_32_Array;
- Frames : in Frame_Amount;
- Channels : in Natural)
+ (Store : aliased in out Float_32_Array;
+ Frames : in Frame_Amount;
+ Channels : in Natural)
return Buffer
with Pre => Store'Length > 0 and Store'Length = Frames * Frame_Amount (Channels);
function Wrap
- (Store : aliased in Int_32_Array;
- Frames : in Frame_Amount;
- Channels : in Natural)
+ (Store : aliased in out Int_32_Array;
+ Frames : in Frame_Amount;
+ Channels : in Natural)
return Buffer
with Pre => Store'Length > 0 and Store'Length = Frames * Frame_Amount (Channels);
function Wrap
- (Store : aliased in Int_24_Array;
- Frames : in Frame_Amount;
- Channels : in Natural)
+ (Store : aliased in out Int_24_Array;
+ Frames : in Frame_Amount;
+ Channels : in Natural)
return Buffer
with Pre => Store'Length > 0 and Store'Length = Frames * Frame_Amount (Channels);
function Wrap
- (Store : aliased in Int_16_Array;
- Frames : in Frame_Amount;
- Channels : in Natural)
+ (Store : aliased in out Int_16_Array;
+ Frames : in Frame_Amount;
+ Channels : in Natural)
return Buffer
with Pre => Store'Length > 0 and Store'Length = Frames * Frame_Amount (Channels);
function Wrap
- (Store : aliased in Int_8_Array;
- Frames : in Frame_Amount;
- Channels : in Natural)
+ (Store : aliased in out Int_8_Array;
+ Frames : in Frame_Amount;
+ Channels : in Natural)
return Buffer
with Pre => Store'Length > 0 and Store'Length = Frames * Frame_Amount (Channels);
function Wrap
- (Store : aliased in UInt_8_Array;
- Frames : in Frame_Amount;
- Channels : in Natural)
+ (Store : aliased in out UInt_8_Array;
+ Frames : in Frame_Amount;
+ Channels : in Natural)
return Buffer
with Pre => Store'Length > 0 and Store'Length = Frames * Frame_Amount (Channels);
diff --git a/src/portaudio.adb b/src/portaudio.adb
index 1b23daa..d34817e 100644
--- a/src/portaudio.adb
+++ b/src/portaudio.adb
@@ -10,7 +10,7 @@ pragma Ada_2012;
with
Ada.Strings.Fixed,
- Interfaces.C.Strings;
+ Interfaces.C;
use type
@@ -477,9 +477,9 @@ package body Portaudio is
(Num : in Time)
return String
is
- Test_Out : String := Time'Image (Num);
- Mark_Start : Integer := Test_Out'First;
- Mark_End : Integer := Test_Out'Last;
+ Test_Out : constant String := Time'Image (Num);
+ Mark_Start : Integer := Test_Out'First;
+ Mark_End : Integer := Test_Out'Last;
begin
if Test_Out (Mark_Start) = ' ' then
Mark_Start := Mark_Start + 1;
@@ -499,14 +499,14 @@ package body Portaudio is
return String
is
type Large_Hack is delta 10.0**(-10) digits 30;
- Converted : Large_Hack := Large_Hack (Num);
- Prelim : String := Large_Hack'Image (Converted);
- Test_Out : String :=
+ Converted : constant Large_Hack := Large_Hack (Num);
+ Prelim : constant String := Large_Hack'Image (Converted);
+ Test_Out : constant String :=
(if Prelim (Prelim'Last) /= '9' then Prelim
elsif Prelim (Prelim'First) = '-' then Large_Hack'Image (Large_Hack'Pred (Converted))
else Large_Hack'Image (Large_Hack'Succ (Converted)));
- Mark_Start : Integer := Test_Out'First + 1;
- Mark_End : Integer := Test_Out'Last;
+ Mark_Start : constant Integer := Test_Out'First + 1;
+ Mark_End : Integer := Test_Out'Last;
begin
while Test_Out (Mark_End) = '0' loop
Mark_End := Mark_End - 1;
@@ -523,9 +523,9 @@ package body Portaudio is
return String
is
type Two_Digit_Hack is delta 10.0**(-2) digits 4;
- Test_Out : String := Two_Digit_Hack'Image (Two_Digit_Hack (Num));
- Mark_Start : Integer := Test_Out'First + 1;
- Mark_End : Integer := Test_Out'Last;
+ Test_Out : constant String := Two_Digit_Hack'Image (Two_Digit_Hack (Num));
+ Mark_Start : constant Integer := Test_Out'First + 1;
+ Mark_End : Integer := Test_Out'Last;
begin
while Test_Out (Mark_End) = '0' loop
Mark_End := Mark_End - 1;
@@ -546,7 +546,7 @@ package body Portaudio is
function Get_Version
return Version_Number
is
- Raw : Interfaces.Unsigned_32 := Interfaces.Unsigned_32 (pa_get_version);
+ Raw : constant Interfaces.Unsigned_32 := Interfaces.Unsigned_32 (pa_get_version);
Result : Version_Number;
begin
Result.Major := Natural (Interfaces.Shift_Right (Raw, 16) and 16#FF#);