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,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,3f2a5a3fc8bb8d4b X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,UTF8 Path: g2news1.google.com!news3.google.com!feeder.news-service.com!news.motzarella.org!motzarella.org!not-for-mail From: Ivan Levashew Newsgroups: comp.lang.ada Subject: Re: Interfacing with Objective-C or Python Date: Mon, 26 May 2008 15:25:15 +0700 Organization: A noiseless patient Spider Message-ID: References: <70ae8db4-60f1-4069-8ebc-94d5afe38eaa@x1g2000prh.googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Trace: feeder.motzarella.org U2FsdGVkX19h4Ajjyj55JU8snLmTKcQuzc+AAA+oZgJ70m5hAOimMoEShcLewolPM1MzcZWpv6h07ZmmedKnLJ+rfr4KfQKQDeTj751e25JyY28IBrYdGOXWU54Ljm52EhdlzC/1UjA= X-Complaints-To: Please send complaints to abuse@motzarella.org with full headers NNTP-Posting-Date: Mon, 26 May 2008 08:19:12 +0000 (UTC) In-Reply-To: X-Auth-Sender: U2FsdGVkX1+xSZZFf8fxLVYITKxrLM7MUiguXw0UutHxWFHW+7SINg== X-Image-URL: http://img220.echo.cx/img220/9664/111408397042725603791c71pb.gif Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAFVBMVEUAAAOZlpMaJz3/9fYs //8FP1E2M3Qbef+MAAACEklEQVQ4jZ2TTW7bMBCFJwO465B2uqZfS+4NnyBA7LXMerSPEPL+R+gb KqmTIAWKDiCCmo9v/kSJqGaVJCp/TLk3kbypSPmdX2QD2YikTUrAe6CqiWuCL/LR3Cfu/AJgbP4K Phtjfz77vwAfOv4XkNPXVSkqwZvmfTZMAriHMOGG1EOt7xw1Rli8hTIkV4DDTIFn6qqYZJ5JFLhT yIVnHAoIrlYTNGKf7yVMUS4yvYITdC8EMaZwHyX4t4ERnCv2uN+HGMFH4x2bHuDEahD1IUR18LAn mC3Jjork3Wny28Gp+h1pMhR08VV9s55hc/J08qrg90RHP15uXag4c1pYMFvVbHmBB3bFtVGBpVwe z+Hno7UyABU8yYEt1l5q+P54Mj8sM5dsVdRqu4RDCLvWGn2lj8pMJdC2BMdtCFG0L8rptiz6Y3s8 Hh1wjehXby133vRneo5hBSgvu+rfozdodnDYui6g7645m1jpVXELFUtnz6yo9MUKfo1YhzXF6WSc bu09Ax7rcGSsgNKezKggaDNGLH8icz80EsmlcwxOPMcBBJZd0VnWzOnSGbYUMEXNnqO00gvB4p1T gG7TUMydxjljz9xxAAyFzUvpfiEZLHD91iwNhVmvfXybYaksDioVlDh4JdqbwVYFyQ2Unq8EeQDr GDfcrS/ZUF8VJAtWUW8pPyFXr8oDMun4r0pHgiVMafoNgUqRDtakwdAAAAAASUVORK5CYII= X-Face: *tpB#/X3&Zh\?<4l;hAgY:m6lt6L]v#Udy\Xwy{@<'qP=9clA}kEbbSV1]B0a^O{|ibsNV~|zu.Da}V4*se@ns!8*Bt$9l-]nbD}o*7ml9J2)u:"!6P%_-`y9,'.L.Psp),njUf!=F5;kx%~\,'D$%{" Cancel-Lock: sha1:BuwLvAwNbwXPvVy8kg0VmDk8G0k= User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X; ru; rv:1.8.1.14) Gecko/20080421 Thunderbird/2.0.0.14 ThunderBrowse/3.2.1.3.1 Mnenhy/0.7.5.666 Xref: g2news1.google.com comp.lang.ada:352 Date: 2008-05-26T15:25:15+07:00 List-Id: Adrian Hoe пишет: > Is there any way to interface Ada with Objective-C (or Python) without > having a wrapper? Has anyone done this before? Objective-C from Apple and from FSF have different way of dispatching calls. Apple's one has objc_sendMsg varargs function. The best way is to have a C wrapper for every kind of varargs invokation since one can't be sure if passing some kind of argument is equivalent to passing it as a varargs argument. But if one is sure, one can completely eliminate ObjC wrapper. objc_sendMsg must be imported several times for every combination of arguments one is going to use it with. One will also need to map selectors' string representation to their integer representation with NSSelectorFromString. Frozen constant will do. Then one just calls objc_sendMsg (objc-class-or-object, selector, arg1, arg2, ...). And also reference counting: Controlled's Adjust/Finalize must be mapped to NeXTSTEP's retain/release. I don't know much about exception handling. > without having a wrapper? ObjectiveC is like C++. There are at least 3 incompatible implementations: Apple, FSF, POC*. One either make a wrapper or go into details and make implementation-dependent binding. Cocoa APIs are partially duplicated in GNUStep and Cocotron, and Apple is rumored to release Cocoa for Windows [1] currently being tested on Safari for Windows. So it's usually better to make portable bindings. Since Skype API on Mac OS X is likely to remain tied to Apple ObjC, Skype is an exception. What's the point in not having a wrapper? *) Portable Object Compiler [1]http://www.roughlydrafted.com/RD/RDM.Tech.Q2.07/A35C23B9-BD22-4478-BC30-4111CFC360B5.html -- If you want to get to the top, you have to start at the bottom