comp.lang.ada
 help / color / mirror / Atom feed
From: "Björn Lundin" <bjorn.lundin.nospam@swipnet.se>
Subject: Mapping c++ type VARIANT to Ada
Date: Sun, 06 Oct 2002 20:27:48 +0200
Date: 2002-10-06T20:27:48+02:00	[thread overview]
Message-ID: <cf%n9.1730$hT3.5616@nntpserver.swip.net> (raw)

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=us-ascii, Size: 1606 bytes --]

Hello!
I'm trying to interface to an OPC Dll on W2k, which uses callbacks.

What I've done successfully do far is to set up a procedure to be runned by 
the dll, as a callback. I get the callback, and can interpret some of its 
contents, but I fail when I map a c++ VARIANT type.

The dll looks like this:

void CALLBACK EXPORT OPCUpdateCallback (HANDLE hGroup, HANDLE hItem, VARIANT 
*pVar, FILETIME *pTimeStamp, DWORD *pQuality)

I mapped it like this to a procedure like this:

  type Opc_Callback_Handler_Type is access protected
          procedure(Group     : Group_Handle_Type;
                    Item      : Item_Handle_Type;
                    Value     : Byte_Array_Ptr;
                    Timestamp : File_Time_Type;
                    Quality   : D_Word);

where I also have these definitions

  package C renames Interfaces.C;

  type Byte is range 0..255;
  for Byte'Size use 8;
  type Byte_Array is array (Natural range <>) of aliased Byte;

  type Byte_Array_Ptr is access all Byte_Array(1..16);

  type Server_Handle_Type is new C.Long;
  type Group_Handle_Type  is new C.Long;
  type Item_Handle_Type   is new C.Long;
  type D_Word is range 0 .. 2**16 -1;
  for D_Word'Size use 16;

  type File_Time_Type is record
      Low_Date_Time  : C.Long := C.Long'First;
      High_Date_Time : C.Long := C.Long'First;
  end record;



I get the Group and the Item and something in the byte_array, that seems to 
change fairly ok accordingly to the callback, but the filetime and quality 
is not reported, which makes me thing that my VARIANT mapping is wrong?

Any suggestions?

/Bj�rn
  



             reply	other threads:[~2002-10-06 18:27 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-10-06 18:27 Björn Lundin [this message]
2002-10-06 19:16 ` Mapping c++ type VARIANT to Ada Jeffrey Carter
2002-10-07 16:10   ` Björn Lundin
2002-10-07  3:21 ` SteveD
2002-10-07 16:00   ` Björn Lundin
replies disabled

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