comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: Private primitive operations available to entire package hierarchy. Can it be done?
Date: Tue, 19 Jul 2005 18:19:47 -0500
Date: 2005-07-19T18:19:47-05:00	[thread overview]
Message-ID: <iLadnZJJWoBEFEDfRVn-sA@megapath.net> (raw)
In-Reply-To: 1121269243.013754.57720@g14g2000cwa.googlegroups.com

"Lucretia" <lucretia9@lycos.co.uk> wrote in message
news:1121269243.013754.57720@g14g2000cwa.googlegroups.com...
> Although the factory that creates an Ada type from a C++ wxWidgets
> class name would possibly be ok in the private part of the root package
> (wx). Putting all the other primitives I need to be private from
> outside of (wx) in the root package isn't possible due to the fact that
> the root package (wx) doesn't know about types that those functions may
> need (wx.Window.Window_Type). i.e. I have another function which
> creates the correct window type from an access type which comes from
> the C side of the code, thus it's got an unknown type until it comes
> out of this function. This is a problem, and one I have no clue how to
> fix.

These things don't sound very primitive to me. If they don't need to be
dispatching, put them into the private part of the child packages. Another
possibility is to invert the structure, and put them into private child
packages of the root, along with a derived type (not intended to be used
externally). Then derive from that hidden type in a public child. (This also
would seem to require Ada 200Y features, but one that is available in the
newest GNATs). This would look like:

    package Root is
        type Root_Type is tagged ...
        procedure Root_Operation (Obj : in out Root_Operation; ...) is
abstract;
    end Root;

    private package Root.Private_Child is
        type Private_Version_of_Type is new Root_Type with ...
        procedure Private_Operation_1 (Obj : in out Private_Version_of_Type;
...);
        procedure Will_be_Public_Operation (Obj : in out
Private_Version_of_Type; ...);
        procedure Root_Operation (Obj : in out Private_Version_of_Type;
...);
   end Root_Private_Child;

    private with Root.Private_Child; -- Ada 200Y
    package Root.Public_Child is
       type Public_Type is new Root_Type with private;
       procedure Public_Operation (Obj : in out Public_Type; ...);
       -- Root_Operation is inherited, and the version in Private_Child will
be called when it
       -- is referenced or dispatched to. The other two operations are *not*
publically inherited.
    private
       type Public_Type is new Root.Private_Child.Private_Version_of_Type
with ...;
       -- The other two operations are inherited here.
       procedure Public_Operation (Obj : in out Public_Type; ...) renames
Will_be_Public_Operation;
       -- Connect the visible Public_Operation with
Will_be_Public_Operation.
    end Root.Public_Child;

If this doesn't work, then the structure of the system is just too
convoluted. (Which I realize is out of your control.)

> I'm not too sure I understand what you mean with respect to the
> registration packages. I've had to include the factory in wx.Object
> package as the registration package has to return a type of
> Object_Class and the Object also has to register itself although, I
> could possibly change that), thus cyclic dependency!

I don't think it is necessary to register the Object type itself, especially
as it will be abstract in the vast majority of systems. (Thus, there are no
objects.) Even if you do have to, you can special case that and do it at the
point of the registration package (clearly it knows about the type
"Object").

Hope this helps.

                    Randy.






  reply	other threads:[~2005-07-19 23:19 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-07-07 16:06 Private primitive operations available to entire package hierarchy. Can it be done? Lucretia
2005-07-07 16:17 ` OT: Joke Adrien Plisson
2005-07-07 16:24   ` Matthew Heaney
2005-07-07 19:10 ` Private primitive operations available to entire package hierarchy. Can it be done? Randy Brukardt
2005-07-13 15:40   ` Lucretia
2005-07-19 23:19     ` Randy Brukardt [this message]
2005-07-20 18:14       ` Lucretia
2005-07-21  3:10         ` Randy Brukardt
2005-07-25 18:14           ` Lucretia
2005-07-25 23:58             ` Randy Brukardt
2005-07-27 17:36               ` Lucretia
2005-07-27 21:28                 ` Randy Brukardt
2005-07-28 10:09                   ` Lucretia
2005-07-29  0:40                     ` Randy Brukardt
2005-08-02 15:55                       ` Lucretia
2005-08-03 18:26                         ` Lucretia
2005-08-03 20:04                           ` Randy Brukardt
2005-08-03 20:03                         ` Randy Brukardt
2005-08-08 18:04                           ` Lucretia
2005-08-08 20:47                             ` Randy Brukardt
replies disabled

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