comp.lang.ada
 help / color / mirror / Atom feed
* Exporting generic's and tagged types
@ 2001-04-08  3:26 srini
  2001-04-09 16:47 ` Stephen Leake
  0 siblings, 1 reply; 6+ messages in thread
From: srini @ 2001-04-08  3:26 UTC (permalink / raw)


Some hopefully simple questions I cannot find answers for :

a) Is there a way to make generic packages preinstantiated exported to
"C" for example?

b) Is there a way to export a set of packages that declare/define a
family of base and derived data types and algorithms on these.

TIA



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Exporting generic's and tagged types
  2001-04-08  3:26 Exporting generic's and tagged types srini
@ 2001-04-09 16:47 ` Stephen Leake
  2001-04-10  1:13   ` srini
  2001-04-13  6:13   ` Simon Wright
  0 siblings, 2 replies; 6+ messages in thread
From: Stephen Leake @ 2001-04-09 16:47 UTC (permalink / raw)


srini <r.srinivasan@worldnet.att.net> writes:

> Some hopefully simple questions I cannot find answers for :
> 
> a) Is there a way to make generic packages preinstantiated exported to
> "C" for example?

You can put a "pragma Export (C, ...)" in the generic package itself,
so that when it is instantiated, the appropriate things are exported. 

Does that do what you want?

One problem with this scheme is the C name. If you specify it
explicitly in the pragma Export, you cannot instantiate the package
twice (you'll get link time collisions). On the other hand, if you do
not specify it explicitly, you have a compiler dependency.

> b) Is there a way to export a set of packages that declare/define a
> family of base and derived data types and algorithms on these.

Not clear what you mean by "export" here; pragma Export does not apply
to packages. 

Maybe you mean "automatically apply pragma Export to everything in
this set of packages". No way to do that. Might be a good application
for ASIS.

-- 
-- Stephe



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Exporting generic's and tagged types
  2001-04-09 16:47 ` Stephen Leake
@ 2001-04-10  1:13   ` srini
  2001-04-13 16:18     ` Tucker Taft
  2001-04-13  6:13   ` Simon Wright
  1 sibling, 1 reply; 6+ messages in thread
From: srini @ 2001-04-10  1:13 UTC (permalink / raw)




Stephen Leake wrote:
> 
> srini <r.srinivasan@worldnet.att.net> writes:
> 
> > Some hopefully simple questions I cannot find answers for :
> >
> > a) Is there a way to make generic packages preinstantiated exported to
> > "C" for example?
> 
> You can put a "pragma Export (C, ...)" in the generic package itself,
> so that when it is instantiated, the appropriate things are exported.
> 
> Does that do what you want?
> 
> One problem with this scheme is the C name. If you specify it
> explicitly in the pragma Export, you cannot instantiate the package
> twice (you'll get link time collisions). On the other hand, if you do
> not specify it explicitly, you have a compiler dependency.
> 
sounds like a problem to me........

> > b) Is there a way to export a set of packages that declare/define a
> > family of base and derived data types and algorithms on these.
> 
> Not clear what you mean by "export" here; pragma Export does not apply
> to packages.
> 
> Maybe you mean "automatically apply pragma Export to everything in
> this set of packages". No way to do that. Might be a good application
> for ASIS.
> 

well. I have such a family of such algorithms and data structures. work
quite well as long as i am within the Ada world. Now there is some
necessity to provide these facilities to VB. It would appear that there
is no easy way to accomplish this. Too bad. COM might be the way to do
it but I was hoping to avoid that.

thanks anyway

> --
> -- Stephe



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Exporting generic's and tagged types
  2001-04-09 16:47 ` Stephen Leake
  2001-04-10  1:13   ` srini
@ 2001-04-13  6:13   ` Simon Wright
  2001-04-13 22:51     ` Robert A Duff
  1 sibling, 1 reply; 6+ messages in thread
From: Simon Wright @ 2001-04-13  6:13 UTC (permalink / raw)


Stephen Leake <stephen.a.leake.1@gsfc.nasa.gov> writes:

> You can put a "pragma Export (C, ...)" in the generic package
> itself, so that when it is instantiated, the appropriate things are
> exported.
> 
> Does that do what you want?
> 
> One problem with this scheme is the C name. If you specify it
> explicitly in the pragma Export, you cannot instantiate the package
> twice (you'll get link time collisions). On the other hand, if you
> do not specify it explicitly, you have a compiler dependency.

You can (in GNAT, anyway) supply a computed string for pragma Import:

  -- This string is used to prefix the C names of system calls in the
  -- imported C functions below. If empty, you get the actual system call
  -- (open(), etc); you can set it to "bp_" to access the corresponding
  -- versions in the file bp.c, which either report the call and pass it on
  -- to the real system interface or (if compiled with SIMULATE_DEVICE
  -- defined) provide a simple simulation.
  Import_Prefix : constant String := "";

....

    function Open (Path : Interfaces.C.Strings.Chars_Ptr;
                   Oflag : Interfaces.C.Unsigned) return Interfaces.C.Int;
    pragma Import (C, Open, Import_Prefix & "open");



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Exporting generic's and tagged types
  2001-04-10  1:13   ` srini
@ 2001-04-13 16:18     ` Tucker Taft
  0 siblings, 0 replies; 6+ messages in thread
From: Tucker Taft @ 2001-04-13 16:18 UTC (permalink / raw)


srini wrote:
> 
> Stephen Leake wrote:
> ... 
> > > b) Is there a way to export a set of packages that declare/define a
> > > family of base and derived data types and algorithms on these.
> >
> > Not clear what you mean by "export" here; pragma Export does not apply
> > to packages.

Actually, that's not strictly true.  Pragma Export may
be applied to any entity, including a package, an exception,
a type, etc.  However, support for exporting some of these
kinds of entities is implementation-defined, and from
a practical point of view, not many compilers support
these kinds of exports.

> >
> > Maybe you mean "automatically apply pragma Export to everything in
> > this set of packages". No way to do that. Might be a good application
> > for ASIS.

This could be a legitimate interpretation for pragma Export
on a package.  Again, though, pragma Export is not
standardized once you go past the requirements given
in Annex B for particular languages.

> >
> 
> well. I have such a family of such algorithms and data structures. work
> quite well as long as i am within the Ada world. Now there is some
> necessity to provide these facilities to VB. It would appear that there
> is no easy way to accomplish this. Too bad. COM might be the way to do
> it but I was hoping to avoid that.
> 
> thanks anyway
> 
> > --
> > -- Stephe

-- 
-Tucker Taft   stt@avercom.net   http://www.averstar.com/~stt/
Chief Technology Officer, AverCom Corporation (A Titan Company) 
Burlington, MA  USA (AverCom was formerly the Commercial Division of AverStar:
http://www.averstar.com/services/ebusiness_applications.html)



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Exporting generic's and tagged types
  2001-04-13  6:13   ` Simon Wright
@ 2001-04-13 22:51     ` Robert A Duff
  0 siblings, 0 replies; 6+ messages in thread
From: Robert A Duff @ 2001-04-13 22:51 UTC (permalink / raw)


Simon Wright <simon@pushface.org> writes:

> You can (in GNAT, anyway) supply a computed string for pragma Import:

This is a standard feature of Ada -- not GNAT-specific.  You can give
any static string expression, including the one you showed:

>     pragma Import (C, Open, Import_Prefix & "open");

- Bob



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2001-04-13 22:51 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-04-08  3:26 Exporting generic's and tagged types srini
2001-04-09 16:47 ` Stephen Leake
2001-04-10  1:13   ` srini
2001-04-13 16:18     ` Tucker Taft
2001-04-13  6:13   ` Simon Wright
2001-04-13 22:51     ` Robert A Duff

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