From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII X-Google-Thread: 103376,a94db636886834db X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-10-06 12:17:24 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!canoe.uoregon.edu!arclight.uoregon.edu!newsfeed.mathworks.com!btnet-peer0!btnet-peer1!btnet!newsr1.ipcore.viaginterkom.de!newsfeed.stueberl.de!cox.net!newsfeed1.earthlink.net!newsfeed.earthlink.net!stamper.news.pas.earthlink.net!newsread1.prod.itd.earthlink.net.POSTED!not-for-mail Message-ID: <3DA08C2E.7040105@acm.org> From: Jeffrey Carter User-Agent: Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.0.0) Gecko/20020530 X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Mapping c++ type VARIANT to Ada References: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit Date: Sun, 06 Oct 2002 19:16:40 GMT NNTP-Posting-Host: 63.184.16.128 X-Complaints-To: abuse@earthlink.net X-Trace: newsread1.prod.itd.earthlink.net 1033931800 63.184.16.128 (Sun, 06 Oct 2002 12:16:40 PDT) NNTP-Posting-Date: Sun, 06 Oct 2002 12:16:40 PDT Organization: EarthLink Inc. -- http://www.EarthLink.net Xref: archiver1.google.com comp.lang.ada:29545 Date: 2002-10-06T19:16:40+00:00 List-Id: Bj�rn Lundin wrote: > 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? I could be more helpful if you included the definition of VARIANT. I would suggest that you use the types from Interfaces.C whenever possible. These are guaranteed to be C compatible. Instead of Byte_Array_Ptr, you should use Interfaces.C.Strings.Chars_Ptr. If you can't use Interfaces.C.Int, Interfaces.C.Short, or Interfaces.C.Long for D_Word, define it as type D_Word is mod 2 ** 16; for D_Word'Size use 16; pragma Convention (C, D_Word); Similarly, apply pragma Convention (C, File_Time_Type); Note that time stamp and quality are both passed as pointers. I'm not sure about a record, but an integer will be passed by copy. You need one of Quality : access D_Word); or type D_Word_Ptr is access all D_Word; pragma Convention (C, D_Word_Ptr); Quality : D_Word_Ptr); You may need something similar for the time stamp. Finally, C knows nothing about protected procedures. You probably should remove the "protected" from the type definition, and apply pragma Convention (C, Opc_Callback_Handler_Type); Finally, any procedure you pass using this type should be either Export or Convention C. Some of these may not be strictly necessary, but it's better to be safe than sorry. -- Jeff Carter "It's all right, Taggart. Just a man and a horse being hung out there." Blazing Saddles