comp.lang.ada
 help / color / mirror / Atom feed
* [Ann] WinRt - version 3
@ 2023-08-27  5:18 AlexG
  2023-09-03  9:07 ` AlexG
  0 siblings, 1 reply; 2+ messages in thread
From: AlexG @ 2023-08-27  5:18 UTC (permalink / raw)


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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Ann] WinRt - version 3
  2023-08-27  5:18 [Ann] WinRt - version 3 AlexG
@ 2023-09-03  9:07 ` AlexG
  0 siblings, 0 replies; 2+ messages in thread
From: AlexG @ 2023-09-03  9:07 UTC (permalink / raw)


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;

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-09-03  9:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-27  5:18 [Ann] WinRt - version 3 AlexG
2023-09-03  9:07 ` AlexG

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox