From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,6353697ffeb79d16,start X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!postnews.google.com!j18g2000yqd.googlegroups.com!not-for-mail From: Bryan Newsgroups: comp.lang.ada Subject: Encapsulating Ada.Direct_IO Date: Tue, 16 Nov 2010 20:44:49 -0800 (PST) Organization: http://groups.google.com Message-ID: <5ba4147a-6099-4a05-b548-09544f58247a@j18g2000yqd.googlegroups.com> NNTP-Posting-Host: 98.124.107.116 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: posting.google.com 1289969089 10148 127.0.0.1 (17 Nov 2010 04:44:49 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Wed, 17 Nov 2010 04:44:49 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: j18g2000yqd.googlegroups.com; posting-host=98.124.107.116; posting-account=kI3R0woAAAAkETUXcbnWjzzG0TUmJmXv User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.2.12) Gecko/20101026 Firefox/3.6.12,gzip(gfe) Xref: g2news2.google.com comp.lang.ada:16501 Date: 2010-11-16T20:44:49-08:00 List-Id: 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.