comp.lang.ada
 help / color / mirror / Atom feed
From: "cl1" <charles.w.lambert@gmail.com>
Subject: generic package with procedure paramter gives "not subtype conformant with declaration"
Date: 30 Sep 2006 14:20:01 -0700
Date: 2006-09-30T14:20:01-07:00	[thread overview]
Message-ID: <1159651201.121690.130430@b28g2000cwb.googlegroups.com> (raw)

I don't understand why i can't pass Av_Param to the generic package (in
test_call_avcall_register_type.adb) and have its 'Access attribute used
in Concat (the offending code in avcall-register_type.adb)?

i'm getting the following error:
$ gnatmake -gnatc ./Ada_Source/test_avcall_register_type.adb
gcc -c -I./Ada_Source/ -gnatc -I-
./Ada_Source/test_avcall_register_type.adb
gcc -c -I./Ada_Source/ -gnatc -I- ./Ada_Source/avcall.adb
gcc -c -I./Ada_Source/ -gnatc -I- ./Ada_Source/avcall-register_type.adb
avcall-register_type.adb:13:34: not subtype conformant with declaration
at avcall.ads:37
avcall-register_type.adb:13:34: formal subprograms not allowed
gnatmake: "./Ada_Source/avcall-register_type.adb" compilation error

on this code:
<avcall.ads>
with System; use System;
package avcall is
	-- <snip>
	----------------------------------------------------------------------------
	-- This exeption is thrown when you try to add more than Max_Args to
the
	-- Var_Args type
	Max_Arg_Limit_Surpassed : exception;
	----------------------------------------------------------------------------
	-- The maximum number of arguments that can be used by avcall
	Max_Args : constant := 50;
	----------------------------------------------------------------------------
	-- this is the number of arguments in the Var_Args list
	subtype Arg_Count is Natural range 0..Max_Args;
	----------------------------------------------------------------------------
	-- This is the range used by the Var_Args list
	subtype Arg_Range is Natural range 1..Max_Args;
	----------------------------------------------------------------------------
	-- this represents an argument held in the Arg_List
	type Argument is tagged
		record
		------------------------------------------------------------------------
		-- This holds the correct av_<type> c function to call.
		Av_Param : access procedure(Av_List : System.Address;
									Value : System.Address);
		------------------------------------------------------------------------
		-- This holds the address of the value. This is assigned by the child
		-- type of this type in the Register_Type package during the
		-- Initialize procedure call of the child type.
		Value_Address : System.Address;
		------------------------------------------------------------------------
		end record;
	----------------------------------------------------------------------------
	-- This type is used by the Var_Args type to hold all of the
arguments.
	type Arg_List is array(Arg_Range range <>) of Argument;
	----------------------------------------------------------------------------
	-- This is the Var_Args type. This is used to hold all of the
arguments to
	-- the c function (the ... and all the arguments before that).
	-- The Start_Var_Args, "&", and Prepend methods and functions are used
to
	-- add arguments to Var_Args.
	type Var_Args is
		record
		------------------------------------------------------------------------
		-- this is a pointer to the c data type that makes this work.
		-- Av_List_Malloc and Av_List_Free (defined in the body) are used to
		-- obtain the reference and free it respectivly
		Av_List : System.Address;
		------------------------------------------------------------------------
		-- This is the number of arguments in the Arg_List
		Count : access Arg_Count;
		------------------------------------------------------------------------
		-- This is what holds all of the arguments.
		List : access Arg_List := new Arg_List(Arg_Range'Range);
		------------------------------------------------------------------------
		end record;
	----------------------------------------------------------------------------
	-- <snip>
end avcall;

<avcall-register_type.ads>
with System.Address_To_Access_Conversions;
with System; use System;
--------------------------------------------------------------------------------
generic
	type Any_Type is private;
	with procedure Av_Param_Instance(AList : System.Address; Value :
System.Address);
package avcall.register_type is
	----------------------------------------------------------------------------
	package Any_Type_Conversion is new
System.Address_To_Access_Conversions(Any_Type);
	----------------------------------------------------------------------------
	type Argument_Instance is new Argument with
		record
			Instance_Value : Any_Type_Conversion.Object_Pointer;
		end record;
	----------------------------------------------------------------------------
	function Concat(AList : Var_Args; Arg : Any_Type) return Var_Args;
	----------------------------------------------------------------------------
end avcall.register_type;

<avcall-register_type.adb>
package body avcall.register_type is
	----------------------------------------------------------------------------
	-- Adds the value in Arg to the next Var_Args.List
	function Concat(AList : Var_Args; Arg : Any_Type) return Var_Args is
		Info : Argument_Instance;
	begin
		Info.Av_Param := Av_Param_Instance'Access;
		Info.Instance_Value.all := Arg;
		Info.Value_Address :=
Any_Type_Conversion.To_Address(Info.Instance_Value);
		AList.Count.all := AList.Count.all + 1;
		AList.List(AList.Count.all) := Argument(Info);
		return AList;
	end Concat;
	----------------------------------------------------------------------------
end avcall.register_type;

<test_avcall_register_type.adb>
with avcall; use avcall;
with avcall.register_type;
with Ada.Text_IO; use Ada.Text_IO;
with System; use System;
--------------------------------------------------------------------------------
procedure test_avcall_register_type is
	procedure Av_Param(AList : System.Address; Value : System.Address) is
	begin
		null;
	end Av_Param;
	package Int_Registered is new avcall.register_type(Integer, Av_Param);
begin
	Put_Line("FOO");
end test_avcall_register_type;

<offending code>
--avcall-register_type.adb:13:34: not subtype conformant with
declaration at avcall.ads:37
--avcall-register_type.adb:13:34: formal subprograms not allowed
		Info.Av_Param := Av_Param_Instance'Access;
<end of code post>

I don't understand why i can't pass Av_Param to the generic package (in
test_call_avcall_register_type.adb) and have its 'Access attribute used
in Concat (the offending code in avcall-register_type.adb)?




             reply	other threads:[~2006-09-30 21:20 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-09-30 21:20 cl1 [this message]
2006-10-01  1:27 ` generic package with procedure paramter gives "not subtype conformant with declaration" Jeffrey R. Carter
2006-10-01  6:02   ` cl1
2006-10-01 19:43     ` Jeffrey R. Carter
2006-10-01 21:26       ` cl1
2006-10-01 23:17         ` tmoran
2006-10-02  4:46           ` cl1
2006-10-02  3:24         ` Jeffrey R. Carter
2006-10-02  4:31           ` cl1
2006-10-02  7:17             ` Alex R. Mosteo
2006-10-02 20:04             ` Jeffrey R. Carter
2006-10-03 18:49               ` cl1
2006-10-01  7:18 ` Simon Wright
2006-10-01 19:42   ` cl1
2006-10-01 20:18     ` Robert A Duff
2006-10-01 21:32       ` cl1
replies disabled

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