In the original version, I used 'number_of_bits' because Ada's 'Size returns the size in bits, not bytes. But the values (for objects) are always a multiple of 8. On the C++ side, performing size checks at the granularity of bits is just awkward. The term 'object size' is more natural.
26 lines
601 B
Ada
26 lines
601 B
Ada
pragma Ada_2012;
|
|
|
|
package body Machinery is
|
|
|
|
function Object_Size (Machinery : Machinery_Type) return Object_Size_Type is
|
|
begin
|
|
return Machinery'Size / 8;
|
|
end Object_Size;
|
|
|
|
procedure Initialize (Machinery : out Machinery_Type) is
|
|
begin
|
|
Machinery := ( Temperature => 25 );
|
|
end Initialize;
|
|
|
|
function Temperature (Machinery : Machinery_Type) return Temperature_Type is
|
|
begin
|
|
return Machinery.Temperature;
|
|
end Temperature;
|
|
|
|
procedure Heat_Up (Machinery : in out Machinery_Type) is
|
|
begin
|
|
Machinery.Temperature := 77;
|
|
end Heat_Up;
|
|
|
|
end Machinery;
|