From: Bryan <brobinson.eng@gmail.com>
Subject: Encapsulating Ada.Direct_IO
Date: Tue, 16 Nov 2010 20:44:49 -0800 (PST)
Date: 2010-11-16T20:44:49-08:00 [thread overview]
Message-ID: <5ba4147a-6099-4a05-b548-09544f58247a@j18g2000yqd.googlegroups.com> (raw)
I'm trying to port some code to Ada for dealing with Big5-encoded
files. I realize that I might be able to use Ada.Wide_Text_IO, but I'm
trying to learn Ada and understand the language better. I'm still
working on wrapping my head around types and packages. My original
code in C++ opens a file as binary and parses it byte by byte and
breaking it into Big5 characters depending on the byte codes. I
thought I'd try to do something similar by encapsulating Ada.Direct_IO
into a package. I'm not having much luck, however.
Spec file:
======================
with Ada.Direct_IO;
package Big5_Text_IO is
type File_Type is limited private;
procedure Close( File : in out File_Type );
private
package Byte_IO is new Ada.Direct_IO(Character);
type File_Type is new Byte_IO.File_Type;
end Big5_Text_IO;
======================
Body file
======================
package body Big5_Text_IO is
procedure Close( File : in out File_Type ) is
begin
Byte_IO.Close(File);
end Close;
end Big5_Text_IO;
======================
Test driver:
======================
with Big5_Text_IO;
with Ada.Text_IO;
procedure Big5_Test is
Input_File : Big5_Text_IO.File_Type;
begin
Ada.Text_IO.Put_Line("OK?");
end Big5_Test;
======================
If I leave out the Close method and remove the body file, I can build
the test driver with no issues. Otherwise, I get the following from
GNAT:
======================
gcc -c big5_text_io.adb
big5_text_io.adb:6:23: expected private type "Ada.Direct_Io.File_Type"
from instance at big5_text_io.ads:11
big5_text_io.adb:6:23: found private type "Big5_Text_IO.File_Type"
defined at big5_text_io.ads:12
gnatmake: "big5_text_io.adb" compilation error
======================
I would *greatly* appreciate any tips in how I can better design my
package so that it can encapsulate Ada.Direct_IO or some other method
of binary I/O. I looked at the GNAT source and I'm hoping I won't
have to emulate what they have done...its a bit over my head at this
point.
next reply other threads:[~2010-11-17 4:44 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-11-17 4:44 Bryan [this message]
2010-11-17 5:20 ` Encapsulating Ada.Direct_IO Adam Beneschan
2010-11-26 15:31 ` Bryan
2010-11-17 12:25 ` Peter C. Chapin
2010-11-18 1:16 ` Randy Brukardt
2010-11-18 2:21 ` Peter C. Chapin
2010-11-18 16:36 ` Adam Beneschan
2010-11-18 18:21 ` Peter C. Chapin
2010-11-18 18:36 ` Randy Brukardt
2010-11-18 19:48 ` Adam Beneschan
2010-11-18 20:15 ` Dmitry A. Kazakov
2010-11-18 7:39 ` AdaMagica
2010-11-18 18:38 ` Randy Brukardt
2010-11-18 9:46 ` Maciej Sobczak
2010-11-18 16:31 ` Adam Beneschan
2010-11-18 17:05 ` Dmitry A. Kazakov
[not found] ` <ENidndoH8qoqjHvRnZ2dnUVZ_j-dnZ2d@earthlink.com>
2010-11-19 8:24 ` Dmitry A. Kazakov
2010-11-19 16:19 ` Adam Beneschan
2010-11-18 18:45 ` Randy Brukardt
2010-11-24 21:31 ` Warren
2010-11-17 22:32 ` Yannick Duchêne (Hibou57)
2010-11-17 23:03 ` Adam Beneschan
2010-11-17 23:11 ` Yannick Duchêne (Hibou57)
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox