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.3 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,dbaf05888e191cb6 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-01-15 16:58:03 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news.uchicago.edu!newsswitch.lcs.mit.edu!newsfeed.cwix.com!newsfeed.icl.net!newsfeed.fjserv.net!oleane.net!oleane!freenix!enst.fr!not-for-mail From: sk Newsgroups: comp.lang.ada Subject: Re: Access to array slices? Date: Wed, 15 Jan 2003 19:00:19 -0600 Organization: ENST, France Sender: comp.lang.ada-admin@ada.eu.org Message-ID: References: Reply-To: comp.lang.ada@ada.eu.org NNTP-Posting-Host: marvin.enst.fr Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Trace: avanie.enst.fr 1042678682 49868 137.194.161.2 (16 Jan 2003 00:58:02 GMT) X-Complaints-To: usenet@enst.fr NNTP-Posting-Date: Thu, 16 Jan 2003 00:58:02 +0000 (UTC) Return-Path: User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0.1) Gecko/20020828 X-Accept-Language: en-us, en Errors-To: comp.lang.ada-admin@ada.eu.org X-BeenThere: comp.lang.ada@ada.eu.org X-Mailman-Version: 2.0.13 Precedence: bulk List-Unsubscribe: , List-Id: comp.lang.ada mail<->news gateway List-Post: List-Help: List-Subscribe: , Errors-To: comp.lang.ada-admin@ada.eu.org X-BeenThere: comp.lang.ada@ada.eu.org Xref: archiver1.google.com comp.lang.ada:33064 Date: 2003-01-15T19:00:19-06:00 Hi, >> I am curious as to whether you deliberately avoided >> Interfaces.C.Strings (ICS) or the not mentioning it was >> an oversight ? > Perhaps I misunderstood the original question. I was responding to: Sorry, wasn't trying to imply that ICS should have been used and I was not looking too closely at the OP. I was just curious if you had developed an interesting technique which would make interfacing more straight forward by using ... > type C_Char_Ptrs is access all Interfaces.C.Char; > > type C_String_Ptrs is access all > Interfaces.C.Char_Array(Interfaces.C.Size_T); > -- a pointer to a fixed size (albeit huge) char_array > > function Convert is new Ada.Unchecked_Conversion > (Source=>C_Char_Ptrs, Target=>C_String_Ptrs); From your expanded example, I see that you still need to determine the slice ranges. > You can't use an "access all Interfaces.C.Char_Array" because that's > unconstrained and the access value would need a place to store the > length. Yes, but you can do int readlink(const char *path, char *buf, size_t bufsiz); function Read_Link ( Path : ICS.Chars_Ptr; -- "in" paramater Buf : access IC.Char_Array; -- "in out" parameter Size : IC.Size_t -- "in" paramater (length) ) return IC.Int; The "Path" (ICS.New_String'("whatever")) involves the copying which the OP mentioned as wanting to avoid, but "Buf" is local, constrained and does not require copying ... and of course, the nature of "char *buf" seems to vary depending on which "C" functions you are interfacing to :-( All irrelevent to the OP, just curious and hoping that you had a technique which makes translation of "chars *buf" mindless (as in you don't have to RTFM to determine whether caller or callee allocates the memory :-) -- -- -- Merge vertically for real address -- ------------------------------------ -- s n p @ t . o -- k i e k c c m ------------------------------------