From 9469acaf915b28c2e8433c98df14bdad2ce0e989 Mon Sep 17 00:00:00 2001 From: Rod Kay Date: Sun, 21 Sep 2025 13:16:24 +1000 Subject: [PATCH] all: Fix unconstrained_Conversion's whose types have different sizes. --- .../private/freetype/source/freetype-face.adb | 6 +-- .../source/lean/shader/opengl-attribute.adb | 5 +- .../source/lean/shader/opengl-attribute.ads | 2 + 3-mid/opengl/source/lean/text/opengl-font.adb | 7 ++- .../text/private/opengl-fontimpl-texture.adb | 14 +++--- 4-high/gel/source/gel-sprite.adb | 48 ++----------------- 4-high/gel/source/world/gel-world.adb | 4 +- 7 files changed, 22 insertions(+), 64 deletions(-) diff --git a/3-mid/opengl/private/freetype/source/freetype-face.adb b/3-mid/opengl/private/freetype/source/freetype-face.adb index 419a05e..0c53655 100644 --- a/3-mid/opengl/private/freetype/source/freetype-face.adb +++ b/3-mid/opengl/private/freetype/source/freetype-face.adb @@ -6,7 +6,6 @@ with interfaces.C.Strings, - ada.unchecked_Conversion, ada.unchecked_Deallocation, ada.Finalization; @@ -23,7 +22,6 @@ is --- Utility -- - function to_Flag is new ada.unchecked_Conversion (FT_Kerning_Mode, C.unsigned); procedure deallocate is new ada.Unchecked_Deallocation (float_Array, float_Array_view); @@ -248,7 +246,7 @@ is Self.Err := FT_Get_Kerning (Self.ftFace, C.unsigned (index1), C.unsigned (index2), - to_Flag (ft_Kerning_unfitted), + ft_Kerning_unfitted'enum_Rep, kernAdvance'unchecked_Access); if Self.Err /= 0 then @@ -323,7 +321,7 @@ is loop Self.Err := FT_Get_Kerning (Self.ftFace, i, j, - to_Flag (ft_Kerning_unfitted), + ft_Kerning_unfitted'enum_Rep, kernAdvance'unchecked_Access); if Self.Err /= 0 then diff --git a/3-mid/opengl/source/lean/shader/opengl-attribute.adb b/3-mid/opengl/source/lean/shader/opengl-attribute.adb index aff888c..7bc0e81 100644 --- a/3-mid/opengl/source/lean/shader/opengl-attribute.adb +++ b/3-mid/opengl/source/lean/shader/opengl-attribute.adb @@ -99,8 +99,7 @@ is type GLvoid_access is access all GLvoid; - function to_GL is new ada.unchecked_Conversion (attribute.data_Kind, gl.GLenum); -- TODO: Address different sizes warning. - function to_GL is new ada.unchecked_Conversion (storage_Offset, GLvoid_access); + function to_GL is new ada.unchecked_Conversion (storage_Offset, GLvoid_access); begin Tasks.check; @@ -109,7 +108,7 @@ is glVertexAttribPointer (Index => Self.gl_Location, Size => Self.Size, - the_Type => to_GL (Self.data_Kind), + the_Type => Self.data_Kind'enum_Rep, Normalized => Self.Normalized, Stride => Self.vertex_Stride, Ptr => to_GL (Self.Offset)); diff --git a/3-mid/opengl/source/lean/shader/opengl-attribute.ads b/3-mid/opengl/source/lean/shader/opengl-attribute.ads index 0789af9..3e52392 100644 --- a/3-mid/opengl/source/lean/shader/opengl-attribute.ads +++ b/3-mid/opengl/source/lean/shader/opengl-attribute.ads @@ -2,6 +2,7 @@ with GL, system.storage_Elements; + package openGL.Attribute -- -- Models an openGL shader attribute. @@ -76,6 +77,7 @@ private Normalized : gl.GLboolean; end record; + for data_Kind use (GL_BYTE => 16#1400#, GL_UNSIGNED_BYTE => 16#1401#, GL_SHORT => 16#1402#, diff --git a/3-mid/opengl/source/lean/text/opengl-font.adb b/3-mid/opengl/source/lean/text/opengl-font.adb index 850fb38..ba05ff1 100644 --- a/3-mid/opengl/source/lean/text/opengl-font.adb +++ b/3-mid/opengl/source/lean/text/opengl-font.adb @@ -1,6 +1,6 @@ with - ada.unchecked_Deallocation, - ada.unchecked_Conversion; + ada.unchecked_Deallocation; + package body openGL.Font is @@ -232,13 +232,12 @@ is Spacing : in Vector_3 := Origin_3D; Mode : in fontImpl.RenderMode := fontImpl.RENDER_ALL) return Vector_3 is - function to_Integer is new ada.Unchecked_Conversion (fontImpl.RenderMode, Integer); begin return Self.impl.Render (Text, Length, Position, Spacing, - to_Integer (Mode)); + Mode'enum_Rep); end check_Glyphs; diff --git a/3-mid/opengl/source/lean/text/private/opengl-fontimpl-texture.adb b/3-mid/opengl/source/lean/text/private/opengl-fontimpl-texture.adb index e28a7b1..4acff0b 100644 --- a/3-mid/opengl/source/lean/text/private/opengl-fontimpl-texture.adb +++ b/3-mid/opengl/source/lean/text/private/opengl-fontimpl-texture.adb @@ -8,8 +8,8 @@ with GL.lean, GL.Pointers, - freetype_c.Binding, - ada.unchecked_Conversion; + freetype_c.Binding; + package body openGL.FontImpl.Texture is @@ -167,8 +167,6 @@ is use GL, GL.Binding; - function to_Integer is new ada.unchecked_Conversion (fontImpl.RenderMode, Integer); - Tmp : Vector_3; begin @@ -180,9 +178,11 @@ is GlyphImpl.texture.ResetActiveTexture; - Tmp := FontImpl.item (Self.all).Render (Text, Length, - Position, Spacing, - to_Integer (Mode)); + Tmp := FontImpl.item (Self.all).Render (Text, + Length, + Position, + Spacing, + Mode'enum_Rep); return Tmp; end Render; diff --git a/4-high/gel/source/gel-sprite.adb b/4-high/gel/source/gel-sprite.adb index 8c6ba4e..89c16b0 100644 --- a/4-high/gel/source/gel-sprite.adb +++ b/4-high/gel/source/gel-sprite.adb @@ -3,14 +3,13 @@ with gel. any_Joint, gel.World, - ada.Tags, - ada.unchecked_Deallocation, - ada.unchecked_Conversion; + ada.unchecked_Deallocation; + package body gel.Sprite is - use ada.Tags, - linear_Algebra_3D; + use linear_Algebra_3D; + procedure log (Message : in String) @@ -1149,43 +1148,4 @@ is end program_Parameters; - ----------- - --- Utility - -- - - function to_Hash (Self : in ada.Tags.Tag) return ada.Containers.Hash_type - is - function Converted is new ada.unchecked_Conversion (ada.Tags.Tag, ada.Containers.Hash_type); - begin - return Converted (Self); - end to_Hash; - pragma Unreferenced (to_Hash); - - - - -- protected - -- body safe_Matrix_4x4 - -- is - -- function Value return Matrix_4x4 - -- is - -- begin - -- return the_Value; - -- end Value; - -- - -- procedure Value_is (Now : in Matrix_4x4) - -- is - -- begin - -- the_Value := Now; - -- end Value_is; - -- - -- procedure Site_is (Now : in Vector_3) - -- is - -- begin - -- the_Value (4, 1) := Now (1); - -- the_Value (4, 2) := Now (2); - -- the_Value (4, 3) := Now (3); - -- end Site_is; - -- end safe_Matrix_4x4; - - end gel.Sprite; diff --git a/4-high/gel/source/world/gel-world.adb b/4-high/gel/source/world/gel-world.adb index 6c63f09..af69be5 100644 --- a/4-high/gel/source/world/gel-world.adb +++ b/4-high/gel/source/world/gel-world.adb @@ -1082,8 +1082,8 @@ is function to_Hash is new ada.unchecked_Conversion (impact_Filter, ada.Containers.Hash_type); function to_Hash is new ada.unchecked_Conversion (impact_Response, ada.Containers.Hash_type); begin - return to_Hash (Self.Filter) - + to_Hash (Self.Response); + return to_Hash (Self.Filter) / 2 + + to_Hash (Self.Response) / 2; end Hash;