[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: dlsym() and C++
Bert Peers wrote:
> Jorrit Tyberghein wrote:
>
> > In Crystal Space we now use COM for integrating the several layers of
> > the engine (like 3D rasterizer, 2D driver, 3D engine, ...). This works very well and
> > we also ported this system to other OS'es (linux, OS/2, BeOS, Macintosh, DOS, ...)
> > so we can use COM everywhere now.
>
> This is interesting. How was it done ? Did you invent a completely
> new but functionally identical system, or is it somehow "just" a
> translation of the IUnknown, AddReference, Release, QueryInterface
> scheme ?
The system is compatible with COM (what we call COMpatible). On Windows
COM is used as such but on all other platforms our emulation layer is used.
We have three possible ways to use COM in our engine:
- Native COM support on OS'es that support it (currently only Windows)
- Emulated COM using dynamic libraries.
- Emulated COM using static libraries (for DOS).
The last approach is possible for those platforms that don't support dynamic
libraries. Of course you then loose the benefit of being able to add COM objects
dynamically. They all have to be linked into the application at compile time.
The emulated COM layer using dynamic libraries is functionally equivalent
to real COM. You can also add COM objects at run-time.
The emulation layers emulate only what we need for our project. More can
be added in principle but we have just written specific versions of functions
like:
CoCreateInstance
CoGetClassObject
and a few others...
We also created a utility 'regsvr' which registeres a COM object on non-Windows
platform. This is also needed on Windows for real COM objects. We simulate the
registry (where this happens on Windows) with a simple file on non-COM platforms.
> I've been playing with the idea to use a COM like separation to
> break the strong C++ interf/impl link too, but I wasn't too sure
> about portability or even the right one has to reimplement this
> (say you make a commercial app with the technique and then
> MS sues the hell out of you), so I'm very interested in this
> as some sort of case study...
Well, we don't actually use any Microsoft code in our COM emulation
so I doubt that we're doing something illegal here.
Greetings,
--
==============================================================================
Jorrit.Tyberghein@uz.kuleuven.ac.be, University Hospitals KU Leuven BELGIUM
Anathema didn't only believe in ley-lines, but in seals, whales, bicycles,
rainforests, whole grain in loves, recycled paper, white South Africans out
of South Africa, and Americans out of practically everywhere down to and
including Long Island.
-- (Terry Pratchett & Neil Gaiman, Good Omens)
==============================================================================