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 Path: g2news1.google.com!news2.google.com!news4.google.com!news2.volia.net!news.ntu-kpi.kiev.ua!news.uran.net.ua!news.uar.net!news.nask.pl!news.nask.org.pl!newsfeed.atman.pl!not-for-mail From: sg Newsgroups: comp.lang.ada Subject: Re: ada binding Date: Thu, 09 Feb 2006 20:37:55 +0100 Organization: ATMAN Message-ID: References: <1142859.ZZbdis6YEU@linux1.krischik.com> <3220036.snWfkaaEov@linux1.krischik.com> NNTP-Posting-Host: staticline10528.toya.net.pl Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-2; format=flowed Content-Transfer-Encoding: quoted-printable X-Trace: node3.news.atman.pl 1139513877 13943 85.89.162.21 (9 Feb 2006 19:37:57 GMT) X-Complaints-To: abuse@atman.pl NNTP-Posting-Date: Thu, 9 Feb 2006 19:37:57 +0000 (UTC) User-Agent: Thunderbird 1.5 (Windows/20051201) In-Reply-To: <3220036.snWfkaaEov@linux1.krischik.com> Xref: g2news1.google.com comp.lang.ada:2828 Date: 2006-02-09T20:37:55+01:00 List-Id: Martin Krischik napisa=B3(a): > Szymon Guz wrote: >=20 >> Martin Krischik napisa?(a): >>> Szymon Guz wrote: >>> >>>> Maciej Sobczak napisa?(a): >>>>> 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 "clas= sic" >>>>> OO stuff, then you can write a wrapper around it in C, which will s= till >>>>> 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 =3D static_cast(vp); >>>>> mcp->myFun(); >>>>> } >>>>> >>>>> // and so on. >>>>> >>>>> Depending on the level of isolation that you want to achieve and th= e >>>>> level of type safety that you want to retain, hiding the object beh= ind >>>>> void* might or might not be the best choice, but this is to give yo= u >>>>> 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 sensibl= e >>>>> language in existence and from Ada in particular. >>>>> >>>>> >>>> OK, but what about using the class fields : >>>> >>>> class MyClass >>>> { >>>> public: >>>> int X; >>>> int *p_X; >>>> } >>>> >>>> and what about inheriting this from the class in Ada, is it possible= ? >>> If you are planning to inheriting then you need to directly bind to = the >>> C++ class. Only one compiler offers that (GNAT). Start reading here: >>> >>> http://gcc.gnu.org/onlinedocs/gcc-4.0.2/gnat_rm/Pragma-CPP_005fClass.= html >>> >>> Martin >> I know but I wander if I can do that using other compilers and with th= e >> middle layer written in C. >=20 > You would need to use proxy classes then. Just as much work :-( >=20 > Martin >=20 Well... if this is the only way, so I think that there a very little=20 chance for having the wxWindows Ada binding Szymon Guz