comp.lang.ada
 help / color / mirror / Atom feed
From: tmoran@acm.org
Subject: Re: Thick Ada bindings to C Win32
Date: Wed, 10 Nov 2004 04:36:36 GMT
Date: 2004-11-10T04:36:36+00:00	[thread overview]
Message-ID: <oVgkd.594232$8_6.104841@attbi_s04> (raw)
In-Reply-To: sa4y8haifwq.fsf@snoopy.apana.org.au

> procedure Put(Handle : Handle_Type; Item : in Byte_Array) is
>
>    ...
>
>    Buffer : aliased Byte_Array := Item;
>
>    A : Interfaces.C.Strings.Char_Array_Access
>         := Convert_Byte_Array_Ptr_To_Char_Array_Ptr(Buffer'Unchecked_Access);
>
>    B : Interfaces.C.Strings.Chars_Ptr
>         := Interfaces.C.Strings.To_Chars_Ptr(A,False);
>
>    Buffer_Ptr : Win32.Lpcvoid
>         := Convert_Chars_Ptr_To_Lpcvoid(B);
>
> begin
>    Bool_Result :=
>       Win32.Winbase.WriteFile
>       ( ...
>        lpBuffer => Buffer_Ptr,                              -- Win32.Lpcvoid
>        nNumberOfBytesToWrite => Win32.Dword(Item'Length),   -- Win32.Dword  => 1 bytes
>        ... )
>
> end Put;
>
> While the get function is OK, I think the put function is horrible.

Did you try:

  function WriteFile(...
                     Item : in Byte_Array;
                     nNumberOfBytesToWrite : in Win32.DWord,
                      ...) return c_bool;
  pragma Import(StdCall, WriteFile, "WriteFile");

  procedure Put(Handle : Handle_Type; Item : in Byte_Array) is
     ...
  begin
     Bool_Result :=
        Win32.Winbase.WriteFile
        ( ...
         Item => Item,
         nNumberOfBytesToWrite => Win32.Dword(Item'Length),
         ... )

  end Put;



  reply	other threads:[~2004-11-10  4:36 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-11-10  2:41 Thick Ada bindings to C Win32 Brian May
2004-11-10  4:36 ` tmoran [this message]
2004-11-10 19:31 ` Jeffrey Carter
2004-11-12  1:51   ` Brian May
2004-11-12 12:09 ` Nick Roberts
2004-11-12 17:57   ` tmoran
2004-11-12 18:50     ` Martin Krischik
2004-11-12 23:29   ` Brian May
2004-11-13  0:51     ` Jeffrey Carter
2004-11-25 23:19       ` Brian May
2004-11-26  9:50         ` Martin Krischik
2004-11-26 12:23           ` Frank J. Lhota
2004-11-26 19:19         ` Jeffrey Carter
2004-11-27 23:56           ` Brian May
2004-11-28 18:57             ` Jeffrey Carter
2004-11-28 23:45             ` Brian May
2004-11-29  7:50               ` Message-ID: <sa4vfbpzgfu.fsf@snoo tmoran
2004-11-29 14:34               ` Thick Ada bindings to C Win32 Frank J. Lhota
replies disabled

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