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-Thread: 103376,bae62a394f8c9d83 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!news.glorb.com!koehntopp.de!newsfeed.freenet.de!newsfeed-0.progon.net!progon.net!news-zh.switch.ch!switch.ch!cernne03.cern.ch!cern.ch!news From: Maciej Sobczak Newsgroups: comp.lang.ada Subject: Re: ada binding Date: Thu, 09 Feb 2006 15:31:56 +0100 Organization: CERN - European Laboratory for Particle Physics Message-ID: References: NNTP-Posting-Host: abpc10883.cern.ch Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Trace: sunnews.cern.ch 1139495515 26113 (None) 137.138.37.241 X-Complaints-To: news@sunnews.cern.ch User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.12) Gecko/20060203 Red Hat/1.7.12-1.1.3.4 X-Accept-Language: en-us, en In-Reply-To: Xref: g2news1.google.com comp.lang.ada:2819 Date: 2006-02-09T15:31:56+01:00 List-Id: Szymon Guz wrote: > how to make an Ada binding for a "C++" class using this C layer ? Basically, if the C++ class is not a template, but just plain "classic" OO stuff, then you can write a wrapper around it in C, which will still be OO, but without the syntax sugar of real class. Something along this: // an existing C++ class: class MyClass { public: void myFun(); }; // a C wrapper: extern "C" void * MyClass_new() { return new MyClass; } extern "C" void MyClass_delete(void *p) { delete static_cast(p); } extern "C" void MyClass_myFun(void *vp) { MyClass *mcp = static_cast(vp); mcp->myFun(); } // and so on. Depending on the level of isolation that you want to achieve and the level of type safety that you want to retain, hiding the object behind void* might or might not be the best choice, but this is to give you the idea. Above, MyClass_new, MyClass_delete and MyClass_myFun are plain C functions (you can extract their declarations to separate header file) and you can interface them from just about any sensible language in existence and from Ada in particular. -- Maciej Sobczak : http://www.msobczak.com/ Programming : http://www.msobczak.com/prog/