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: Henri Lesourd
Subject: Re: [Texmacs-dev] Re: Compiling TexMacs on OSX
Date: Mon, 23 Jun 2008 14:58:09 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7) Gecko/20040616

Josef Weidendorfer wrote:

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.

[...]
When both a Texmacs binary and an independently compiled
plugin want to use a given class, it should be enough to
pass pointers between.

Not if you want to directly call the methods from
inside the surrounding code (i.e., the one which
loads the DLL).


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.

It seems to amount to the fact that any direct
method call should happen inside the plugin code,
thus it amounts to the need of exporting the C++
methods thru a C API (i.e.: wrapping each one of
the methods behind an exported C function).


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.

It seems to me that this technique would only work
if you use the same compiler for compiling TeXmacs
and the DLL.

Or am I wrong here ? How can you have a method call
using the dispatch of the compiler A, while having
the vtables and the body of the method using the
dispatch technique of the compiler B ?


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.

How do you do this with compilers which do not
generate compatible method dispatch code ?

Is there a standard for this (even if it is
only de-facto) ?




reply via email to

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