From: Mats Weber <Mats.Weber@elca-matrix.ch>
Subject: win32ada design question/problem
Date: 1998/11/13
Date: 1998-11-13T00:00:00+00:00 [thread overview]
Message-ID: <364C5EDE.4F402D13@elca-matrix.ch> (raw)
I just had a look at the win32ada binding and found that I could not use
it as I would like. Lets take this function as an example:
> function WriteFile(hFile : Win32.Winnt.HANDLE;
> lpBuffer : Win32.LPCVOID;
> nNumberOfBytesToWrite : Win32.DWORD;
> lpNumberOfBytesWritten: Win32.LPDWORD;
> lpOverlapped : Win32.Winbase.LPOVERLAPPED)
> return Win32.BOOL;
> type DWORD is access all ULONG;
Now I want to call this from some procedure:
procedure P is
bytes_Written : aliased ULONG;
result : Win32.bool;
begin
result := WriteFile(...,
lpNumberOfBytesWritten => bytes_Written'Access,
...);
end P;
The problem is that this does not compile because of accessibility
checks (bytes_Written is less global than the access type).
Of course I can use 'Unchecked_Access to circumvent this, but then I
don't think that the binding is well designed if it requires
'Unchecked_Access all over the place in code that uses it.
The samples directory is full of examples that, in order to be able to
use'Access instead of 'Unchecked_Access, declare all parameters to Win32
as global variables, an approach that is totally incompatible with
multitasking programs.
Another problem is the use of the type
> type PCCH is access constant CHAR;
to pass pointers to strings (it is used in e.g. gethostbyname). Now if I
want to use this, what should I do ? Pass an 'Unchecked_Access to the
first element of the string, and the function is going to read the whole
string ? I don't think this is very clean.
Example:
declare
S : constant String := ...;
begin
x := gethostbyname(s(s'first'unchecked_access));
end;
or is there a better way ?
Does the win32ada binding really have the above problems, or am I
missing something ?
next reply other threads:[~1998-11-13 0:00 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
1998-11-13 0:00 Mats Weber [this message]
1998-11-13 0:00 ` win32ada design question/problem Tom Moran
1998-11-16 0:00 ` Mats Weber
1998-11-18 0:00 ` Tom Moran
1998-11-18 0:00 ` dennison
1998-11-19 0:00 ` Mats Weber
1998-11-19 0:00 ` David Botton
1998-11-19 0:00 ` Mats Weber
1998-11-23 0:00 ` Marin David Condic
1998-11-19 0:00 ` dennison
1998-11-19 0:00 ` David Botton
1998-11-19 0:00 ` Mats Weber
1998-11-27 0:00 ` Roga Danar
1998-11-13 0:00 ` dennison
1998-11-16 0:00 ` Stephen Leake
1998-11-16 0:00 ` Tucker Taft
1998-11-17 0:00 ` dennison
1998-11-17 0:00 ` Mats Weber
1998-11-17 0:00 ` dennison
1998-11-17 0:00 ` Mats Weber
1998-11-17 0:00 ` Tucker Taft
1998-11-18 0:00 ` Tom Moran
1998-11-18 0:00 ` dennison
-- strict thread matches above, loose matches on Subject: below --
1998-11-19 0:00 tmoran
1998-11-19 0:00 ` dennison
1998-11-19 0:00 ` Tom Moran
1998-11-20 0:00 ` dennison
1998-11-20 0:00 ` Tom Moran
1998-11-23 0:00 ` Marin David Condic
1998-11-23 0:00 ` Mats Weber
1998-11-24 0:00 ` dennison
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox