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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,d1533431e7e9d2eb X-Google-Attributes: gid103376,public From: tmoran@bix.com Subject: Re: Nontrivial examples of C interface with Ada Date: 2000/05/25 Message-ID: #1/1 X-Deja-AN: 627298160 References: <8gjjeb$eng$1@nnrp1.deja.com> X-Complaints-To: abuse@pacbell.net X-Trace: news.pacbell.net 959285012 206.170.2.15 (Thu, 25 May 2000 13:03:32 PDT) Organization: SBC Internet Services NNTP-Posting-Date: Thu, 25 May 2000 13:03:32 PDT Newsgroups: comp.lang.ada Date: 2000-05-25T00:00:00+00:00 List-Id: >For me, the really tricky ones are the routines that return a pointer to >an object whose type is specified by the return value of another >parameter. As near as I can tell, you have to either make a separate >subprogram for each type and force the user to know what type he's >receiving when he makes the call, or you just throw up your hands and >return an address. Usually the kinds of objects the returned pointer points to, are fairly highly related, in which case a return X'class may do the job nicely. In Claw, for instance, the different Device Independent Bitmaps (different color resolution, palette use) are descendants of a single type, so you can read an unknown .bmp file with function Read (Filename : in String) return Claw.Bitmaps.Root_DIBitmap_Type'class; Even more commonly, of course, an *input* parameter defines what kind of entity the output pointer points to. In that case, two different Ada procedures fills the bill quite nicely.