[Fwd: Re: [ooc-compiler] PROPOSAL: Interface to C++ objects and methods]
Brought to you by:
mva
|
From: Frank C. <fj...@th...> - 2006-01-17 10:58:28
|
-------- Original Message -------- Subject: Re: [ooc-compiler] PROPOSAL: Interface to C++ objects and methods Date: Tue, 17 Jan 2006 21:31:08 +1100 From: Frank Copeland <fj...@th...> To: Stewart Greenhill <sgr...@ii...> References: <43C...@ii...> Stewart Greenhill wrote: > I'm interested in being able to use existing C++ APIs from Oberon-2. It would certainly broaden the options available. There are some C++ APIs I have an interest in. > Currently, oo2c has a limited ability to call methods of C++ objects. > When one declares a record with the VTABLE flag, oo2c builds a C++-style > virtual method table for all instantiated objects, and calls methods of > that object via VTABLE dispatch. This means (for example) that you can > call methods of COM interfaces, and even implement your own COM objects. > > This is fine if one follows a design methodology like COM, which ensures > that there is a language-independent binary interface to your API. COM > uses abstract interfaces and VTABLE method dispatch. It also has a > language-independent type mechanism (ie. IUnknown::QueryInterface). > Unfortunately, most C++ coders seem completely uninterested in language > interoperability. The biggest obstacle with existing C++ APIs is the use > of static (ie. non-virtual) methods. Its only really possible to call > these methods from a C++ compiler, since the symbol names are mangled to > include type information. > > The approach that I'm proposing is to: > > 1) Introduce a [STATIC] method flag. This causes calls to methods to be > dispatched statically, rather than using type-descriptor lookup. > > 2) Write (by hand, or automatically) a FOREIGN implementation that can > be processed by the C++ compiler. This dispatches method calls to the > C++ objects. Would it not be simpler to have OOC mangle the symbol names the same way as the C++ compiler? I realise that is compiler-dependant and I believe g++ broke ABI recently by changing the mangling algorithm. Even so the algorithms should be reasonably easy to discover (especially for g++). There would remain the issue of telling OOC which algorithm to use. -- This sentence contradicts itself -- no actually it doesn't. -- Douglas Hofstadter -- Politics are almost as exciting as war, and quite as dangerous. In war, you can only be killed once. -- Winston Churchill |