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=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,26aa6d7095c151 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-10-19 06:30:04 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!wn11feed!worldnet.att.net!204.127.198.204!attbi_feed4!attbi.com!sccrnsc02.POSTED!not-for-mail From: "SteveD" Newsgroups: comp.lang.ada References: <3DAFC542.152C0EE0@lml.ls.fi.upm.es> Subject: Re: Porting from Modula-2 to Ada X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 Message-ID: NNTP-Posting-Host: 12.211.13.75 X-Complaints-To: abuse@attbi.com X-Trace: sccrnsc02 1035034203 12.211.13.75 (Sat, 19 Oct 2002 13:30:03 GMT) NNTP-Posting-Date: Sat, 19 Oct 2002 13:30:03 GMT Organization: AT&T Broadband Date: Sat, 19 Oct 2002 13:30:04 GMT Xref: archiver1.google.com comp.lang.ada:29941 Date: 2002-10-19T13:30:04+00:00 List-Id: "Manuel Collado" wrote in message news:3DAFC542.152C0EE0@lml.ls.fi.upm.es... [snip] > So far, my only porting scheme is to replace ARRAY OF BYTE parameters by > the pair (address, size), as follows: > > procedure Xxx (Raw_Address: System.Address; Raw_Size: Integer) ... > > Num: Integer; > ... > Xxx (Num'Address, Num'Size); > ... > > But this requires recoding every call to the procedure. Is there another > way to pass raw data without having to recode every call? First: I have translated a significant amount of Pascal code to Ada. From this experience I would recommend producing a tool to do most of the translation. Making the mapping you just described should be fairly easy for such a tool. The only alternate for this implementation that comes to mind is to create arrays of bytes that alias each structure and passing the alias to Xxx. For example: with Interfaces; use interfaces; with Ada.Text_Io; procedure testconv is type byte_array is array( Natural range <> ) of Unsigned_8; type data_rec is record field_1 : Integer; field_2 : String( 1 .. 8 ); end record; procedure Xxx( raw : in out byte_array ) is begin raw( 0 ) := 2; raw( 1 ) := 0; raw( 2 ) := 0; raw( 3 ) := 0; end Xxx; data : data_rec; data_alias : byte_array( 0 .. data_rec'size / 8 - 1 ); for data_alias'address use data'address; begin data.field_1 := 1; Ada.Text_Io.Put_Line( "field_1 before: " & Integer'IMAGE( data.field_1 ) ); Xxx( data_alias ); Ada.Text_Io.Put_Line( "field_1 after: " & Integer'IMAGE( data.field_1 ) ); end testconv; This makes the code look more like the original source, but requires an additional declaration for each parameter passed to Xxx and still requires the calls to be modified. Sorry I don't have a better answer, SteveD > > Thanks. > -- > To reply by e-mail, please remove the extra dot > in the given address: m.collado -> mcollado