comp.lang.ada
 help / color / mirror / Atom feed
From: tmoran@bix.com
Subject: Re: C struct import
Date: 2000/01/27
Date: 2000-01-27T00:00:00+00:00	[thread overview]
Message-ID: <%hOj4.120$hb5.4849@nnrp3-w.snfc21.pbi.net> (raw)
In-Reply-To: vhi3drkqqo7.fsf@grotte.ifi.uio.no

Assuming the unused things are really unused, the 1 bit flags
are Booleans, and Uint32 and SDL_PixelFormat types are elsewhere
defined, you might say:

type Access_SDL_Pixel_Format is access all SDL_PixelFormat;

type SDL_VideoInfo is record
  hw_available,         -- Can you create hardware surfaces?
  wm_available,         -- Can you talk to a window manager?
  blit_hw,              -- Accelerated blits HW --> HW
  blit_hw_CC,           -- Accelerated blits with Colorkey
  blit_hw_A,            -- Accelerated blits with Alpha
  blit_sw,              -- Accelerated blits SW --> HW
  blit_sw_CC,           -- Accelerated blits with Colorkey
  blit_sw_A,            -- Accelerated blits with Alpha
  blit_fill : Boolean;  -- Accelerated color fill
  video_mem : Uint32;   -- The total amount of video memory (in K)
  vfmt : Access_SDL_Pixel_Format; -- Value: The format of the video surface
end record;

If you not only need a record with these things, but you need the bits
to occur at specific places in the bytes (if you're interfacing to
hardware or an OS, say), then you'll have to find out just where
your C compiler puts things (since that's implementation dependent)
and then include a record representation clause to ensure the Ada
compiler puts things in the same places.  My Microsoft VC++ says
that it allocates bit fields from the right.  My Windows targetted
Ada compilers label bit locations Low_Order_First.  So to make sure
the Ada structure, using such an Ada compiler, matches the C ordering,
using the Microsoft compiler, you would include:

for SDL_VideoInfo use record
  hw_available at 0 range 0 .. 0;
  wm_available at 0 range 1 .. 1;
  blit_hw      at 1 range 1 .. 1;
  blit_hw_CC   at 1 range 2 .. 2;
  blit_hw_A    at 1 range 3 .. 3;
  blit_sw      at 1 range 4 .. 4;
  blit_sw_CC   at 1 range 5 .. 5;
  blit_sw_A    at 1 range 6 .. 6;
  blit_fill    at 1 range 7 .. 7;
  video_mem    at 4 range 0 .. 31;
  vfmt         at 8 range 0 .. 31; -- Assuming Access types are 32 bits.
end record;




       reply	other threads:[~2000-01-27  0:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <vhi3drkqqo7.fsf@grotte.ifi.uio.no>
2000-01-27  0:00 ` tmoran [this message]
2000-01-27  0:00 ` C struct import David C. Hoos, Sr.
     [not found]   ` <vhi1z73r5cc.fsf@grotte.ifi.uio.no>
2000-01-30  0:00     ` Mario Klebsch
replies disabled

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