comp.lang.ada
 help / color / mirror / Atom feed
* HOW? item_ptr := item'access
@ 2000-04-11  0:00 Al Johnston
  2000-04-12  0:00 ` Ted Dennison
  0 siblings, 1 reply; 2+ messages in thread
From: Al Johnston @ 2000-04-11  0:00 UTC (permalink / raw)


I am trying to get rid of some of are use of system.address/
unchecked_conversion as part of my port to ada95.  I have
run into a snag.  The line (full test case code follows this msg):
    t_DBase_Ptr : Database_Ptr_Typ := Database'access; <<< -----
compiler complans
causes a compiler error indicating that "database" must be
declare "aliased" that is
  database : aliased database_typ;
problem is that this object is never declared in
the ada code (it is created/destroyed in our c code) so there
is no place to do this.

Is there a way of doing the same thing useing "use"/"use at"?
what should I do to get this to work?

tnx,
         -al


package PDB is

  type Database_Typ  is limited private;

  type Database_Ptr_Typ  is access Database_Typ;

  procedure Close(Database : in out Database_Typ);

private

  type Database_Item;
  type Database_Typ is access Database_Item;

end PDB;

with PDB_C_Lib;
with system;

package body PDB is
  type Parameter_Item is new System.Address;
  type Database_Item  is new System.Address;

  procedure Close(Database : in out Database_Typ) is
    t_DBase_Ptr : Database_Ptr_Typ := Database'access; <<< -----
compiler complans
  begin
    PDB_C_Lib.pdb_close(t_DBase_Ptr);
  end Close;
end PDB;

package PDB_C_Lib is
  procedure pdb_close(Database_Ptr : PDB.Database_Ptr_Typ);
  pragma import(c,pdb_close,"pdb_close");
end PDB_C_Lib;

the c "pdb_close" routine sets the pointer (database_ptr) to null;






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

* Re: HOW? item_ptr := item'access
  2000-04-11  0:00 HOW? item_ptr := item'access Al Johnston
@ 2000-04-12  0:00 ` Ted Dennison
  0 siblings, 0 replies; 2+ messages in thread
From: Ted Dennison @ 2000-04-12  0:00 UTC (permalink / raw)


In article <38F34D00.FA32AC68@mindspring.com>,
  Al Johnston <sofeise@mindspring.com> wrote:

>   procedure Close(Database : in out Database_Typ) is
>     t_DBase_Ptr : Database_Ptr_Typ := Database'access; <<< -----
> compiler complans
>   begin
>     PDB_C_Lib.pdb_close(t_DBase_Ptr);
>   end Close;
> end PDB;


So "Close" is only ever called from C? In that case, why not change that
parameter to "Database_Ptr : in Database_Ptr_Typ"? It does the same
thing from the C side, but gives you the type you need to work with on
the Ada side.


--
T.E.D.

http://www.telepath.com/~dennison/Ted/TED.html


Sent via Deja.com http://www.deja.com/
Before you buy.




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

end of thread, other threads:[~2000-04-12  0:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-04-11  0:00 HOW? item_ptr := item'access Al Johnston
2000-04-12  0:00 ` Ted Dennison

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