comp.lang.ada
 help / color / mirror / Atom feed
* Q re how to do pointer access in Ada (newbie)
@ 2007-11-26  8:35 axtens
  2007-11-26  9:17 ` Martin Krischik
  0 siblings, 1 reply; 2+ messages in thread
From: axtens @ 2007-11-26  8:35 UTC (permalink / raw)


G'day everyone!

In my current DLL project, I'm passing from VB6 to the Ada DLL a
variety of addresses: VARPTRs to LONG, to DOUBLE, to a TYPE which is
two LONGs, and a TYPE which is two DOUBLEs. Assuming these arrive in
to an Ada function with a parameter defined as Win32.LONG, what would
be the best way of converting that LONG to something which can be used
to extract the data to which it points?

The VB code below is conceptual, in the sense that I still don't have
a DLL to link it to. However, this is the direction I'm heading, and I
want to know if it's achievable, and how best to achieve it.

Kind regards,
Bruce.

Declare Function Distance Lib "IntervalComputations.dll" (ByVal iType
As Long, ByVal Left As Long, ByVal Right As Long) As Long 'other
interval functions similarly declared

Const LongIntervals = 0, FloatIntervals = 1
Const LeftIsInterval = 2, RightIsNumber = 0
Const RightIsInterval = 4, LeftIsNumber = 0

Dim LongIntervalInterval As Long
Dim LongIntervalNumber As Long
Dim LongNumberInterval As Long
Dim LongNumberNumber As Long

Dim FloatIntervalInterval As Double
Dim FloatIntervalNumber As Double
Dim FloatNumberInterval As Double
Dim FloatNumberNumber As Double

LongIntervalInterval = LongIntervals Or LeftIsInterval Or
RightIsInterval ' 000b or 010b or 100b = 110b = 6 LongIntervalNumber =
LongIntervals Or LeftIsInterval Or RightIsNumber ' 000b or 010b or
000b = 010b = 2 LongNumberInterval = LongIntervals Or LeftIsNumber Or
RightIsInterval ' 000b or 000b or 100b = 100b = 4 LongNumberNumber =
LongIntervals Or LeftIsNumber Or RightIsNumber 'error state ' 000b or
000b or 000b = 000b = 0

FloatIntervalInterval = FloatIntervals Or LeftIsInterval Or
RightIsInterval ' 001b or 010b or 100b = 111b = 7 FloatIntervalNumber
= FloatIntervals Or LeftIsInterval Or RightIsNumber ' 001b or 010b or
000b = 011b = 3 FloatNumberInterval = FloatIntervals Or LeftIsNumber
Or RightIsInterval ' 001b or 000b or 100b = 101b = 5 FloatNumberNumber
= FloatIntervals Or LeftIsNumber Or RightIsNumber 'error state ' 001b
or 000b or 000b = 001b = 1

Type LongInterval
    Dim LeftLong As Long
    Dim RightLong As Long
End Type

Dim FloatInterval
    Dim LeftFloat As Double
    Dim RightFloat As Double
End Type

Dim Result As Long
Dim li1 As LongInterval
Dim li2 As LongInterval
Dim l1 As Long
Dim l2 As Long

Result = Distance(LongIntervalInterval, VarPtr(li1), VarPtr(li2))
Result = Distance(LongIntervalNumber, VarPtr(li1), VarPtr(i1)) 'Result
points to Long or LongInterval or Double or DoubleInterval



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

* Re: Q re how to do pointer access in Ada (newbie)
  2007-11-26  8:35 Q re how to do pointer access in Ada (newbie) axtens
@ 2007-11-26  9:17 ` Martin Krischik
  0 siblings, 0 replies; 2+ messages in thread
From: Martin Krischik @ 2007-11-26  9:17 UTC (permalink / raw)


axtens schrieb:
> G'day everyone!
> 
> In my current DLL project, I'm passing from VB6 to the Ada DLL a
> variety of addresses: VARPTRs to LONG, to DOUBLE, to a TYPE which is
> two LONGs, and a TYPE which is two DOUBLEs. Assuming these arrive in
> to an Ada function with a parameter defined as Win32.LONG, what would
> be the best way of converting that LONG to something which can be used
> to extract the data to which it points?

You are aware that passing pointer as Win32.LONG might not work on
Windows 64?

Now, I would not pass the parameter as a "pointer" at all. I would use
"in", "out", "in out" and maybe "access" whatever is appropiate.

Suggested Reading:

http://en.wikibooks.org/wiki/Ada_Programming/Types/access#C_compatible_pointer

Martin
-- 
mailto://krischik@users.sourceforge.net
Ada programming at: http://ada.krischik.com



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

end of thread, other threads:[~2007-11-26  9:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-11-26  8:35 Q re how to do pointer access in Ada (newbie) axtens
2007-11-26  9:17 ` Martin Krischik

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