From: Szymon Guz <alpha@skynet.org.pl_WITHOUT>
Subject: Re: ada binding
Date: Thu, 09 Feb 2006 16:56:32 +0100
Date: 2006-02-09T16:56:32+01:00 [thread overview]
Message-ID: <dsfonn$h74$1@node1.news.atman.pl> (raw)
In-Reply-To: <dsfjor$pg1$1@sunnews.cern.ch>
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 "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<MyClass*>(p);
> }
>
> extern "C"
> void MyClass_myFun(void *vp)
> {
> MyClass *mcp = static_cast<MyClass*>(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.
>
>
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 ?
regards
Szymon Guz
next prev parent reply other threads:[~2006-02-09 15:56 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-02-09 12:56 ada binding Szymon Guz
2006-02-09 14:31 ` Maciej Sobczak
2006-02-09 15:56 ` Szymon Guz [this message]
2006-02-09 16:39 ` Georg Bauhaus
2006-02-09 17:17 ` Martin Krischik
2006-02-09 18:05 ` Szymon Guz
2006-02-09 19:34 ` Martin Krischik
2006-02-09 19:37 ` sg
2006-02-11 6:52 ` Martin Krischik
2006-02-11 12:45 ` Lucretia
2006-02-09 19:28 ` Martin Dowie
2006-02-10 16:06 ` Lucretia
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox