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,8b8748382fcfacc1 X-Google-Attributes: gid103376,public From: "David Botton" Subject: Re: friend classes in ada95 Date: 2000/04/17 Message-ID: #1/1 X-Deja-AN: 612411005 References: <38F6B617.34E216A7@emw.ericsson.se> <38F887AE.8CDA24E0@acm.org> <8dc8oi$kda$1@nnrp1.deja.com> <8df6fb$mm3$1@nnrp1.deja.com> X-Priority: 3 X-Mimeole: Produced By Microsoft MimeOLE V5.00.2314.1300 X-Abuse-Info: Otherwise we will be unable to process your complaint properly X-Complaints-To: support@usenetserver.com Organization: WebUseNet Corp http://www.usenetserver.com - Home of the fastest NNTP servers on the Net. X-MSMail-Priority: Normal NNTP-Posting-Date: Mon, 17 Apr 2000 17:32:26 EDT Newsgroups: comp.lang.ada Date: 2000-04-17T00:00:00+00:00 List-Id: The format / approach of the tagged type doesn't matter to me. It is the interfaces format that matters. What I would like to do would look something like this in today's Ada with a twist: -- Interface IUnknown type IUnknown is abstract tagged null record; -- I like the prefix idea so I would use: interface type IUnknown; type PUnknown is access all IUnknown; function QueryInterface (This : IUnknown, etc ...) return Interfaces.C.long is abstract; pragma Convention (C, QueryInterface); function AddRef (This : IUnknown) return Interfaces.C.unsigned is abstract; pragma Convention (C, AddRef); function Release (This : IUnknown) return Interfaces.C.unsigned is abstract; pragma Convention (C, Release); -- Interface IBeep type IBeep is new abstract IUnknown with null record; -- I want to be able to extend interface definitions so I need something that does this -- I would put here: interface type IBeep is new IUnknown; type PBeep is access all IBeep; function Beep (This : IBeep) return Interfaces.C.unsigned is abstract; pragma Convention (C, Beep); -- Interface IMessage type IMessage is new abstract IUnknown with null record; type PMessage is access all IMessage; function Message (This : IMessage) return Interfaces.C.unsigned is abstract; pragma Convention (C, Beep); type Beep_Class is tagged -- class type Beep_Class is would be so much nicer here. -- Some how designate that Beep_Class implements IBeep and IMessage say with the interface section I mentioned like: -- Interface -- IBeep, IMessage record Ref_Count : Interfaces.C.long; end record; -- Implements IUnknown for both IBeep and IMessage function QueryInterface (This : Beep_Class, etc ...) return Interfaces.C.long; function AddRef (This : Beep_Class) return Interfaces.C.unsigned; function Release (This : Beep_Class) return Interfaces.C.unsigned; -- Implements IBeep function Beep (This : Beep_Class) return Interfaces.C.unsigned; -- Implements IMessage function Message (This : IMessage) return Interfaces.C.unsigned; The I could do: P1 : PUnknown := new Beep_Class; P2 : PMessage := PMessage (P1); P3 : PBeep := PBeep (P1); hr := AddRef (P1); hr := Beep (P2); etc. I would then make P1 guts look like a pointer to: record QueryInterface : System.Address; AddRef : System.Address; Release : System.Address; Object : System.Address; end record; P2 like record QueryInterface : System.Address; AddRef : System.Address; Release : System.Address; Beep : System.Address; Object : System.Address; end record; etc. Or comething like that where I could pass a pointer to a clean table of functions. and still get back to my object when needed. The layout of Beep_Class doesn't matter to me. David Botton Robert Dewar wrote in message news:8df6fb$mm3$1@nnrp1.deja.com... > > On Win32 I would implement the interfaces using the same > > "vtbl" style used by MSVC++ and therefore COM. > > Well tagged types use this *identical* implementation approach > so I really can't understand the distinction you are trying > to make here.