* Re: Generic and Access problem
@ 2003-01-09 10:10 Grein, Christoph
0 siblings, 0 replies; 4+ messages in thread
From: Grein, Christoph @ 2003-01-09 10:10 UTC (permalink / raw)
At least here, the attachment looks like:
>
> begin 600 generic_pool.ads
> M9V5N97)I8PT*("`@+2T@5&AI<R!I<R!T:&4@='EP92!F;W(@=&AE(&]B:F5C
> M=',@=&AA="!C;VUP<FES97,@=&AE('!O;VP-"B`@('1Y<&4@271E;5]4>7!E
Rest omitted.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Generic and Access problem
@ 2003-01-09 10:33 Sebastian Madunic
0 siblings, 0 replies; 4+ messages in thread
From: Sebastian Madunic @ 2003-01-09 10:33 UTC (permalink / raw)
[-- Attachment #1: Type: text/plain, Size: 446 bytes --]
Strange I didn't have any problems opening it, anyway here is another try...
/S
"Grein, Christoph" <christoph.grein@eurocopter.com> wrote in message
news:<mailman.1042107482.19914.comp.lang.ada@ada.eu.org>...
> At least here, the attachment looks like:
>
> >
> > begin 600 generic_pool.ads
> > M9V5N97)I8PT*("`@+2T@5&AI<R!I<R!T:&4@='EP92!F;W(@=&AE(&]B:F5C
> > M=',@=&AA="!C;VUP<FES97,@=&AE('!O;VP-"B`@('1Y<&4@271E;5]4>7!E
>
> Rest omitted.
[-- Attachment #2: generic_pool.adb --]
[-- Type: application/octet-stream, Size: 878 bytes --]
--with System.Address_To_Access_Conversions;
package body Generic_Pool is
------------------------------------------------------------------------
-- Public types and objects
Dummy_Item : aliased Item_Type;
-- create an access-to-variable view of the pool:
-- package Access_Conversions is new
-- System.Address_To_Access_Conversions (Id_Type);
------------------------------------------------------------------------
-- Returns a reference to the indexed item.
function Item (P : Id_Type; Ix : Index_Type) return Reference_Type is
-- create an access-to-variable view of the pool:
-- P_Ref : constant Access_Conversions.Object_Pointer :=
-- Access_Conversions.To_Pointer(P'Address);
begin
return P.Buf(Ix)'access;
end Item;
------------------------------------------------------------------------
end Generic_Pool;
[-- Attachment #3: generic_pool.ads --]
[-- Type: application/octet-stream, Size: 1000 bytes --]
generic
-- This is the type for the objects that comprises the pool
type Item_Type is private;
-- This is the type for the index that are used to access the objects
-- of the pool.
type Index_Type is (<>);
package Generic_Pool is
------------------------------------------------------------------------
-- Public types and objects
type Id_Type is private;
type Reference_Type is access all Item_Type;
------------------------------------------------------------------------
-- Returns a reference to the indexed item.
function Item (
P : Id_Type;
Ix : Index_Type)
return Reference_Type;
------------------------------------------------------------------------
-- Private types
private
type Buffer_Type is array (Index_Type) of aliased Item_Type;
type Id_Type is
record
Buf : Buffer_Type;
None_Allocated_Yet : Boolean := True;
Last_Used : Index_Type := Index_Type'First;
end record;
end Generic_Pool;
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Generic and Access problem
@ 2003-01-09 11:03 Grein, Christoph
0 siblings, 0 replies; 4+ messages in thread
From: Grein, Christoph @ 2003-01-09 11:03 UTC (permalink / raw)
generic
type Item_Type is private;
type Index_Type is (<>);
package Generic_Pool is
type Id_Type is private;
type Reference_Type is access all Item_Type;
-- There is no operation by which an object of type Id_Type
-- can get a value.
-- So how is an object of Item_Type supposed to be stored in Buf?
-- If you've solved this problem, perhaps your problem with pointer
-- lifetime is also solved.
function Item (P: Id_Type; Ix: Index_Type) return Reference_Type;
private
type Buffer_Type is array (Index_Type) of aliased Item_Type;
type Id_Type is
record
Buf : Buffer_Type;
None_Allocated_Yet: Boolean := True;
Last_Used : Index_Type := Index_Type'First;
end record;
end Generic_Pool;
Why don't you you use System.Storage_Pools RM 13.11?
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Generic and Access problem
[not found] <avjgbd$m7e$1@newstoo.ericsson.se>
@ 2003-01-09 14:13 ` David C. Hoos
0 siblings, 0 replies; 4+ messages in thread
From: David C. Hoos @ 2003-01-09 14:13 UTC (permalink / raw)
----- Original Message -----
From: "Sebastian" <sebastian.madunic@avionics.saab.se>
Newsgroups: comp.lang.ada
To: <comp.lang.ada@ada.eu.org>
Sent: Thursday, January 09, 2003 3:55 AM
Subject: Generic and Access problem
> Hi,
>
> I have a generic pool (attachment) that returns a pointer to an object.
The
> compiler doesn't agree with me
> it thinks that the object is an constant? I found a slolution using
> Access_To_Address_Conversion but
> I would prefere not to use it, is there another way to solve this
> problem....
The reason for the "access-to-variable designates constant" message
is that in - mode parameters are always considered constants -- i.e.,
subprograms are not allowed to modify them.
Returning an access to such a parameter implicitly grants the right to
modify the item designated by the access.
>
> Greatful for any suggestions....
The correct spelling of the first word of the above sentence fragment
is "Grateful"
>
> /S
>
>
>
>
>
----------------------------------------------------------------------------
----
>
> _______________________________________________
> comp.lang.ada mailing list
> comp.lang.ada@ada.eu.org
> http://ada.eu.org/mailman/listinfo/comp.lang.ada
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2003-01-09 14:13 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <avjgbd$m7e$1@newstoo.ericsson.se>
2003-01-09 14:13 ` Generic and Access problem David C. Hoos
2003-01-09 11:03 Grein, Christoph
-- strict thread matches above, loose matches on Subject: below --
2003-01-09 10:33 Sebastian Madunic
2003-01-09 10:10 Grein, Christoph
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox