comp.lang.ada
 help / color / mirror / Atom feed
From: "ldries46" <bertus.dries@planet.nl>
Subject: Re: User defined type conversion
Date: Sun, 12 May 2013 09:04:36 +0200
Date: 2013-05-12T09:04:36+02:00	[thread overview]
Message-ID: <518f3dba$0$17523$703f8584@news.kpn.nl> (raw)
In-Reply-To: <c9c8b269-fb9e-4715-b48c-40047fff1658@googlegroups.com>

Is a variant record perhaps the solution for your problem.

type Rec = (bit16, bit 8);
type ABC is
   record
      Option : Rec;
      case Option
         when bit16 =>
              A16 : Unsigned_16;
              B16 : Unsigned_16;
        when bit8 =>
              A8 : Unsigned_8;
              B8 : Unsigned_8;
              C8 : Unsigned_8;
              D8 : Unsigned_8;
      end case;
   end record;
It seems to me yhat changing Option will change the output of the record.

L. Dries

"Vin�cius Franchini"  schreef in bericht 
news:c9c8b269-fb9e-4715-b48c-40047fff1658@googlegroups.com...

Hi Folks,
I have a problem with a type conversion. Hereby is what I'm trying to do:

type AB is tagged
  record
    A : Unsigned_16;
    B : Unsigned_16;
  end record;

type abcde is tagged
  record
    a: Unsigned_8;
    b: Unsigned_8;
    c: Unsigned_8;
    d: Unsigned_8;
  end record;

X : AB;
Y : abcd;

X := Y;

I'd like to do a direct conversion without creating a method for it. 




  parent reply	other threads:[~2013-05-12  7:04 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-09 14:07 User defined type conversion Vinícius Franchini
2013-05-09 14:50 ` Adam Beneschan
2013-05-09 16:12 ` Shark8
2013-05-09 16:50   ` Adam Beneschan
2013-05-09 18:24 ` Jeffrey Carter
2013-05-09 18:39   ` Vinícius Franchini
2013-05-09 19:15     ` Adam Beneschan
2013-05-09 20:00       ` Vinícius Franchini
2013-05-09 20:19     ` Jeffrey Carter
2013-05-12  7:04 ` ldries46 [this message]
2013-05-12 14:13   ` AdaMagica
2013-05-12 15:02 ` anon
replies disabled

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