• [Ann] WinRt - version 3

    From AlexG@21:1/5 to All on Sat Aug 26 22:18:29 2023
    Dear Ada community

    I have created a new git repo for the Ada binding to WinRT (now version 3)
    This version is a cleaner implementation than the previous version and includes the following changes

    1) Wide strings are mapped to HStrings
    2) Async operations and actions are handled automatically
    3) code files now contain code at the Namespace level

    Git repo is located here https://github.com/Alex-Gamper/Ada-WinRt3

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From AlexG@21:1/5 to All on Sun Sep 3 02:07:04 2023
    Below is a simple example of the Api usage

    --------------------------------------------------------------------------------
    with Ada.Wide_Text_IO;
    with Ada.Strings.Wide_Unbounded;
    with WinRt;
    with WinRt.Windows.Foundation;
    with WinRt.Windows.Networking;
    with WinRt.Windows.Networking.Sockets;
    with WinRt.Windows.Storage.Streams;
    with WinRt.Windows.Web.Http; --------------------------------------------------------------------------------
    procedure WinRt3Test2 is

    use WinRt;
    use Ada.Strings.Wide_Unbounded;

    Hr : HResult := 0;

    function "+"(value : Wide_String) return Unbounded_Wide_String renames To_Unbounded_Wide_String;
    function "+"(value : Unbounded_Wide_String) return Wide_String renames To_Wide_String;

    begin
    Hr := RoInitialize;
    if Hr = 0 then

    declare
    Uri : Windows.Foundation.Uri := Windows.Foundation.Constructor (+"http://www.google.com");
    HttpClient : Windows.Web.Http.HttpClient := Windows.Web.Http.Constructor;
    Result : WString;
    begin
    Result := HttpClient.GetStringAsync (Uri);
    Ada.Wide_Text_IO.Put_Line (+Result);
    HttpClient.Close;
    end;

    declare
    Host : Windows.Networking.HostName := Windows.Networking.Constructor(+"www.google.com");
    Port : WString := +"80";
    Socket : Windows.Networking.Sockets.StreamSocket := Windows.Networking.Sockets.Constructor;
    DataWriter : Windows.Storage.Streams.DataWriter := Windows.Storage.Streams.Constructor (Socket.get_OutputStream);
    begin
    Socket.ConnectAsync (Host, Port);
    Socket.Close;
    end;

    RoUninitialize;
    end if;
    end;

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)