comp.lang.ada
 help / color / mirror / Atom feed
From: tmoran@bix.com
Subject: Re: friend classes in ada95 (long)
Date: 2000/04/18
Date: 2000-04-18T00:00:00+00:00	[thread overview]
Message-ID: <TSSK4.73$vE6.38666@news.pacbell.net> (raw)
In-Reply-To: KpLK4.3403$wy1.6682475@news-east.usenetserver.com

> -- Interface IUnknown
> ...

How about making a hidden MSWindows COM object to serve as the nucleus
of a higher level Ada object instead of adding syntax to tell the
Ada compiler to create today's low level MS Windows binary to
access COM objects.

with Interfaces.C;
package COM_Stuff is

end COM_Stuff;

private package COM_Stuff.Types is
  type Reference_Count_Type is new Interfaces.C.Unsigned;
  type HResult is new Interfaces.C.Long;
end COM_Stuff.Types;


with COM_Stuff.Types;
 use COM_Stuff.Types;
private package COM_Stuff.IUnknown_Interface is

  type IUnknown is abstract tagged null record;

  type Interface_Pointer is access IUnknown'class;

  function QueryInterface (This : IUnknown;
                           RIID : Integer;
                           ppvObject: access Interface_Pointer)
    return HResult is abstract;

  function AddRef (This : IUnknown) return Reference_Count_Type is abstract;

  function Release (This : IUnknown) return Reference_Count_Type is abstract;

end COM_Stuff.IUnknown_Interface;

with COM_Stuff.Types,
     COM_Stuff.IUnknown_Interface;
 use COM_Stuff.Types;
private package COM_Stuff.IBeep_Interface is

  type IBeep is abstract new COM_Stuff.IUnknown_Interface.IUnknown
  with null record;

  function Beep (This : IBeep) return HResult is abstract;

end COM_Stuff.IBeep_Interface;

with COM_Stuff.Types,
     COM_Stuff.IUnknown_Interface;
 use COM_Stuff.Types;
private package COM_Stuff.IMessage_Interface is

  type IMessage is abstract new COM_Stuff.IUnknown_Interface.IUnknown
  with null record;

  function Message (This : IMessage) return HResult is abstract;

end COM_Stuff.IMessage_Interface;



with COM_Stuff.Types,
     COM_Stuff.IUnknown_Interface,
     COM_Stuff.IBeep_Interface,
     COM_Stuff.IMessage_Interface;
 use COM_Stuff.Types;
private package COM_Stuff.Beeper is

  type Beep_Interface_Part is new COM_Stuff.IBeep_Interface.IBeep
  with null record;
  function QueryInterface (This : Beep_Interface_Part;
                           RIID : Integer;
                           ppvObject: access Interface_Pointer)
    return HResult;
  function AddRef (This : Beep_Interface_Part) return Reference_Count_Type;
  function Release (This : Beep_Interface_Part) return Reference_Count_Type;
  function Beep (This : Beep_Interface_Part) return HResult;


  type Message_Interface_Part is new IMessage_Interface.IMessage with null record;
  function QueryInterface (This : Message_Interface_Part;
                           RIID : Integer;
                           ppvObject: access Interface_Pointer)
    return HResult;
  function AddRef (This : Message_Interface_Part) return Reference_Count_Type;
  function Release (This : Message_Interface_Part) return Reference_Count_Type;
  function Message (This : Message_Interface_Part) return HResult is abstract;

  type Beeper_Type is new COM_Stuff.IUnknown_Interface.IUnknown with record
    Beeper : aliased Beep_Interface_Part;
    Message: aliased Message_Interface_Part;
    Ref_Count : Reference_Count_Type := 0;
  end record;
  function QueryInterface (This : Beeper_Type;
                           RIID : Integer;
                           ppvObject: access Interface_Pointer)
    return HResult;
  function AddRef (This : Beeper_Type) return Reference_Count_Type;
  function Release (This : Beeper_Type) return Reference_Count_Type;

end COM_Stuff.Beeper;


-- package body COM_Stuff.Beeper;  -- TBD


---------- All the above to aid implementation of the Ada style:

with Ada.Finalization;
package COM_Stuff.Public_Beeper is

  type Beeper_Type is new Ada.Finalization.Limited_Controlled with private;

  procedure Beep(This : in out Beeper_Type);

  procedure Message(This : in out Beeper_Type);

private
  type Beeper_Type is new Ada.Finalization.Limited_Controlled with null record;
  -- encapsulate and hide the stuff to Create/Reference count/Destroy
  -- and handle thread safety for COM_Stuff.Beeper.Beeper_Type

  procedure Initialize(This : in out Beeper_Type);
  procedure Finalize(This : in out Beeper_Type);
end COM_Stuff.Public_Beeper;



-- allowing the programmer using this to write things like:

with COM_Stuff.Public_Beeper;
procedure Main is
begin
  if 2+2 = 4 then
    declare
      use COM_Stuff.Public_Beeper;
      Beeper : Beeper_Type;
    begin
      Beep(Beeper);
      Message(Beeper);
    end;
  end if;
end Main;




  reply	other threads:[~2000-04-18  0:00 UTC|newest]

Thread overview: 91+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-04-14  0:00 friend classes in ada95 Stefan Folkesson
2000-04-14  0:00 ` Florian Weimer
2000-04-14  0:00   ` Stefan Folkesson
2000-04-14  0:00 ` Julian Day
2000-04-14  0:00   ` Steve Folly
2000-04-14  0:00     ` Robert A Duff
2000-04-17  0:00       ` John J. Rusnak
2000-04-18  0:00         ` Vincent Marciante
2000-04-18  0:00           ` John Rusnak
2000-04-18  0:00       ` Steve Folly
2000-04-14  0:00 ` swhalen
2000-04-14  0:00 ` John J. Rusnak
2000-04-15  0:00 ` Jeff Carter
2000-04-16  0:00   ` Robert Dewar
2000-04-16  0:00     ` Jeff Carter
2000-04-16  0:00       ` David Botton
2000-04-17  0:00         ` Robert Dewar
2000-04-17  0:00           ` Hyman Rosen
2000-04-17  0:00             ` Robert Dewar
2000-04-16  0:00     ` David Botton
2000-04-17  0:00       ` Robert Dewar
2000-04-17  0:00         ` David Botton
2000-04-18  0:00           ` tmoran [this message]
2000-04-18  0:00             ` friend classes in ada95 (long) David Botton
2000-04-18  0:00               ` friend classes in ada95 Stanley R. Allen
2000-04-19  0:00               ` friend classes in ada95 (long) Brian Rogoff
2000-04-19  0:00                 ` Hyman Rosen
2000-04-19  0:00                   ` Brian Rogoff
2000-04-23  0:00                     ` Hyman Rosen
2000-04-23  0:00                       ` Brian Rogoff
2000-04-24  0:00                         ` Hyman Rosen
2000-04-25  0:00                           ` Brian Rogoff
2000-04-25  0:00                             ` Ole-Hjalmar Kristensen
2000-04-19  0:00                 ` David Botton
2000-04-19  0:00               ` MI, was Re: friend classes in ada95 tmoran
2000-04-19  0:00                 ` David Botton
2000-04-17  0:00         ` David Botton
2000-04-18  0:00       ` Geoff Bull
2000-04-18  0:00         ` David Botton
2000-04-18  0:00         ` Jean-Pierre Rosen
2000-04-18  0:00           ` tmoran
2000-04-18  0:00             ` John J. Rusnak
2000-04-19  0:00               ` Jean-Pierre Rosen
2000-04-19  0:00               ` Geoff Bull
2000-04-19  0:00                 ` Jeff Susanj
2000-04-19  0:00                   ` tmoran
2000-04-19  0:00                   ` Bill Greene
2000-04-19  0:00                   ` Robert Dewar
2000-04-19  0:00                     ` Jeff Carter
2000-04-19  0:00                       ` Ray Blaak
2000-04-20  0:00                         ` Jean-Pierre Rosen
2000-04-20  0:00                           ` Robert Dewar
2000-04-20  0:00                             ` Jean-Pierre Rosen
2000-04-20  0:00                             ` BSCrawford
2000-04-20  0:00                             ` Brian Rogoff
2000-04-20  0:00                           ` Ray Blaak
2000-04-20  0:00                             ` Jean-Pierre Rosen
2000-04-24  0:00                               ` Ray Blaak
2000-04-20  0:00                         ` Robert Dewar
2000-04-20  0:00                           ` Ray Blaak
2000-04-20  0:00                             ` Charles Hixson
2000-04-21  0:00                               ` Jon S Anthony
2000-04-21  0:00                               ` Jean-Pierre Rosen
2000-04-29  0:00                                 ` Aidan Skinner
2000-04-29  0:00                                   ` Robert I. Eachus
2000-04-20  0:00                       ` Robert Dewar
2000-04-20  0:00                         ` Jeff Carter
2000-04-21  0:00                           ` Robert Dewar
2000-04-21  0:00                             ` Jon S Anthony
2000-04-22  0:00                               ` Robert Dewar
2000-04-21  0:00                             ` Ken Garlington
2000-04-19  0:00                 ` David Botton
2000-04-19  0:00                   ` Robert Dewar
2000-04-20  0:00                     ` Geoff Bull
2000-04-19  0:00                   ` Robert Dewar
2000-04-19  0:00                 ` Ehud Lamm
2000-04-19  0:00                 ` Robert Dewar
2000-04-19  0:00               ` Robert Dewar
2000-04-18  0:00           ` David Botton
2000-04-18  0:00           ` Pascal Obry
2000-04-18  0:00           ` John Rusnak
2000-04-19  0:00             ` Robert Dewar
2000-04-17  0:00     ` Robert I. Eachus
2000-04-18  0:00       ` Robert Dewar
2000-04-19  0:00         ` Robert I. Eachus
2000-04-20  0:00           ` Robert Dewar
2000-04-20  0:00             ` Ray Blaak
2000-04-23  0:00             ` Robert I. Eachus
2000-04-19  0:00     ` Alfred Hilscher
2000-04-19  0:00       ` Ray Blaak
2000-04-19  0:00         ` Robert Dewar
replies disabled

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