texmacs-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Texmacs-dev] Re: Compiling TexMacs on OSX


From: Josef Weidendorfer
Subject: Re: [Texmacs-dev] Re: Compiling TexMacs on OSX
Date: Mon, 23 Jun 2008 14:43:32 +0200
User-agent: KMail/1.9.9

Hi,

from an outside view, I find this discussion quite interesting...
But IMHO the arguments about the need for C wrappers for plugins
is wrong.

On Monday 23 June 2008, Henri Lesourd wrote:
> > You can do that with C++, I am 100% sure of this.
> >
> Well, check your documentation. Mine says:
> [[
> C++'s greatest weaknesses in this area is the lack of
> a C++ ABI on some platforms and the lack of a native
> notion of a dynamically linked library.
> ]]
>   B. Stroustrup (interview): C++: past, present, and
>   future. Frontier Channels, September 2006.
> 
> 
> Thus yes you can do it: but only if you wrap your C++
> classes behind a C API.

When both a Texmacs binary and an independently compiled
plugin want to use a given class, it should be enough to
pass pointers between. For this, you use factory methods
in the plugin, and the created objects can be used in the
texmacs binary without any need for recompilation.

E.g. when texmacs defines a C++ class Button, the plugin is
free to derive from this class and define a MySuperButton,
and can pass such objects to the texmacs binary via a factory
method. As long as texmacs is only storing the object pointer
or calling methods from the base class Button, all goes well.
And when a method is virtual, you can call from texmacs directly
to a C++ method in the plugin without any need of MySuperButton
to be known at compile time of the texmacs binary. Magic
of virtual tables ;-)

So for sure, this has nothing to do with the need for
C wrappers around interfaces.

> Excuse me, but when I look at the dl_open() functions, I
> see absolutely *nothing* which would allow me to fetch a
> class contained inside a .so and call its constructor and
> methods.

No. For this, you have to use _one single_ C function which
can be searched for in dl_open. This C function can
return a function pointer to a C++ factory method, which itself
can pass created C++ objects around.

By the way, this is also the method used by Qt itself for its
plugins. But it is really simple to implement, and there is no
need to use Qt plugins for this. texmacs itself does not
need to be linked with Qt.

> Thus what you say seems interesting, but currently, it
> is a little bit too much fuzzy to be useable information.

Perhaps I am missing something here?

Cheers,
Josef




reply via email to

[Prev in Thread] Current Thread [Next in Thread]