From d440873a85175bb26e0ada4bd6885241f8bbd218 Mon Sep 17 00:00:00 2001 From: mgrojo Date: Wed, 14 Feb 2024 20:42:39 +0100 Subject: [PATCH] Align with CSFML master branch after fix of #227 https://github.com/SFML/CSFML/issues/227 --- doc/index.js | 2 +- doc/srcs/sf-window-vulkan.ads.js | 86 ++------------------------------ include/sf-system-thread.ads | 2 +- include/sf-window-vulkan.adb | 44 +++++++--------- include/sf-window-vulkan.ads | 3 -- tests/vulkan/main.adb | 10 ++-- 6 files changed, 27 insertions(+), 120 deletions(-) diff --git a/doc/index.js b/doc/index.js index af18d6f..c986e4d 100644 --- a/doc/index.js +++ b/doc/index.js @@ -1,4 +1,4 @@ GNATdoc.Index = { "project": "ASFML", - "timestamp": "2024-02-11 18:20:10" + "timestamp": "2024-02-11 22:29:49" }; \ No newline at end of file diff --git a/doc/srcs/sf-window-vulkan.ads.js b/doc/srcs/sf-window-vulkan.ads.js index c8e232f..7320306 100644 --- a/doc/srcs/sf-window-vulkan.ads.js +++ b/doc/srcs/sf-window-vulkan.ads.js @@ -1491,89 +1491,11 @@ GNATdoc.SourceFile = { "kind": "line", "number": 74, "children": [ - { - "kind": "span", - "cssClass": "text", - "text": " " - }, - { - "kind": "span", - "cssClass": "keyword", - "text": "pragma" - }, - { - "kind": "span", - "cssClass": "text", - "text": " " - }, - { - "kind": "span", - "cssClass": "identifier", - "text": "Compile_Time_Warning" - } ] }, { "kind": "line", "number": 75, - "children": [ - { - "kind": "span", - "cssClass": "text", - "text": " " - }, - { - "kind": "span", - "cssClass": "identifier", - "text": "(" - }, - { - "kind": "span", - "cssClass": "identifier", - "text": "True" - }, - { - "kind": "span", - "cssClass": "identifier", - "text": "," - } - ] - }, - { - "kind": "line", - "number": 76, - "children": [ - { - "kind": "span", - "cssClass": "text", - "text": " " - }, - { - "kind": "span", - "cssClass": "string", - "text": "\"getGraphicsRequiredInstanceExtensions is broken; see https://github.com/SFML/CSFML/issues/227\"" - }, - { - "kind": "span", - "cssClass": "identifier", - "text": ")" - }, - { - "kind": "span", - "cssClass": "identifier", - "text": ";" - } - ] - }, - { - "kind": "line", - "number": 77, - "children": [ - ] - }, - { - "kind": "line", - "number": 78, "children": [ { "kind": "span", @@ -1584,13 +1506,13 @@ GNATdoc.SourceFile = { }, { "kind": "line", - "number": 79, + "number": 76, "children": [ ] }, { "kind": "line", - "number": 80, + "number": 77, "children": [ { "kind": "span", @@ -1657,7 +1579,7 @@ GNATdoc.SourceFile = { }, { "kind": "line", - "number": 81, + "number": 78, "children": [ { "kind": "span", @@ -1668,7 +1590,7 @@ GNATdoc.SourceFile = { }, { "kind": "line", - "number": 85, + "number": 82, "children": [ { "kind": "span", diff --git a/include/sf-system-thread.ads b/include/sf-system-thread.ads index 03427dd..a01f1d4 100644 --- a/include/sf-system-thread.ads +++ b/include/sf-system-thread.ads @@ -36,7 +36,7 @@ package Sf.System.Thread is --/ --////////////////////////////////////////////////////////// function create (func : sfThreadFunc_Ptr; - userData : Standard.System.Address) return sfThread_Ptr; + userData : Standard.System.Address) return sfThread_Ptr; --////////////////////////////////////////////////////////// --/ @brief Destroy a thread diff --git a/include/sf-window-vulkan.adb b/include/sf-window-vulkan.adb index 336a351..bfab96d 100644 --- a/include/sf-window-vulkan.adb +++ b/include/sf-window-vulkan.adb @@ -5,38 +5,30 @@ package body Sf.Window.Vulkan is function getGraphicsRequiredInstanceExtensions return sfArrayOfStrings is use Interfaces.C; - use Interfaces.C.Strings; - function Internal return Standard.System.Address; + function Internal (count : access sfSize_t) return Standard.System.Address; pragma Import (C, Internal, "sfVulkan_getGraphicsRequiredInstanceExtensions"); - - -- Arbitrary maximum - Maximum : constant := 256; - result : constant Standard.System.Address := Internal; - Last : sfSize_t; - subtype Sf_Chars_Ptr_Array is Strings.Chars_Ptr_Array (0 .. Maximum - 1); - cGraphicsRequiredInstanceExtensions : Sf_Chars_Ptr_Array; - pragma Import (Ada, cGraphicsRequiredInstanceExtensions); - for cGraphicsRequiredInstanceExtensions'Address use result; - AdaGraphicsRequiredInstanceExtensions : sfArrayOfStrings (0 .. Maximum - 1); - + count : aliased sfSize_t; + result : constant Standard.System.Address := Internal (count'access); + begin - -- Empty case - if cGraphicsRequiredInstanceExtensions (0) = Null_Ptr then - return AdaGraphicsRequiredInstanceExtensions (1 .. 0); - end if; + declare + subtype Array_Of_Strings_Type is Strings.Chars_Ptr_Array (0 .. size_t (count) - 1); + cArray_Of_Strings : Array_Of_Strings_Type; + pragma Import (Ada, cArray_Of_Strings); + for cArray_Of_Strings'Address use result; - for i in Sf_Chars_Ptr_Array'Range loop - exit when cGraphicsRequiredInstanceExtensions (i) = Null_Ptr; - Last := sfSize_t (i); - AdaGraphicsRequiredInstanceExtensions (Last) := - Ada.Strings.Unbounded.To_Unbounded_String - (Interfaces.C.Strings.Value (cGraphicsRequiredInstanceExtensions (i))); - end loop; + AdaArray_Of_Strings : sfArrayOfStrings (0 .. count - 1); - return AdaGraphicsRequiredInstanceExtensions (0 .. Last); - end getGraphicsRequiredInstanceExtensions; + begin + for i in Array_Of_Strings_Type'Range loop + AdaArray_Of_Strings(sfSize_t(i)) := Ada.Strings.Unbounded.To_Unbounded_String + (Interfaces.C.Strings.Value (cArray_Of_Strings(i))); + end loop; + return AdaArray_Of_Strings; + end; + end getGraphicsRequiredInstanceExtensions; end Sf.Window.Vulkan; diff --git a/include/sf-window-vulkan.ads b/include/sf-window-vulkan.ads index 8ffcc9d..80258f0 100644 --- a/include/sf-window-vulkan.ads +++ b/include/sf-window-vulkan.ads @@ -71,9 +71,6 @@ package Sf.Window.Vulkan is --/ --////////////////////////////////////////////////////////// function getGraphicsRequiredInstanceExtensions return sfArrayOfStrings; - pragma Compile_Time_Warning - (True, - "getGraphicsRequiredInstanceExtensions is broken; see https://github.com/SFML/CSFML/issues/227"); private diff --git a/tests/vulkan/main.adb b/tests/vulkan/main.adb index b4c6a7e..6b1ccb3 100644 --- a/tests/vulkan/main.adb +++ b/tests/vulkan/main.adb @@ -26,16 +26,15 @@ begin if Sf.Window.Vulkan.isAvailable (requireGraphics => sf.sfTrue) then Ada.Text_IO.Put_Line ("Vulkan with Graphics supported"); + for Extension of Sf.Window.Vulkan.getGraphicsRequiredInstanceExtensions loop + Ada.Strings.Unbounded.Text_IO.Put_Line (Extension); + end loop; else if Sf.Window.Vulkan.isAvailable (requireGraphics => sf.sfFalse) then Ada.Text_IO.Put_Line ("Vulkan without Graphics supported"); else Ada.Text_IO.Put_Line ("Vulkan not supported"); end if; - -- API with problems, see https://github.com/SFML/CSFML/issues/227 - -- for Extension of Sf.Window.Vulkan.getGraphicsRequiredInstanceExtensions loop - -- Ada.Strings.Unbounded.Text_IO.Put_Line (Extension); - -- end loop; end if; while IsOpen (Window) = sfTrue loop @@ -48,9 +47,6 @@ begin Put_Line ("Attempting to close"); end if; end loop; - - - end loop; Destroy (Window);