The problems with COM wrapper classes in BCB 3.0

Why is it that tlibimp generates such bad wrapper classes for COM interfaces
in C++Builder 3.0?

If you use Delphi or VC++ and import a type library, the compiler/IDE
generates a nice wrapper class which hides most of the required knowledge of
COM types e.g. a BSTR under Delphi is converted to a WideString, a DATE to a
TDateTime, etc.

The tlibimp that comes with BCB does no such thing. For a dual interface, it
generates a wrapper class which still uses all the COM types such as BSTR,
VARIANT_BOOL, etc. Even worse than this, is the fact that it calls the
methods using the IDispatch rather directly calling the methods by the
v-table interface.

Visual C++ is a good example of how COM objects can be wrapped in C++
classes and hide a lot of details from the user e.g. HRESULT are converted
into exceptions if they are failed ones, etc. Additionally, if an interface
is dual or just a straight v-table interface, the v-table is called
directly, giving performance benefits.

I therefore have two suggestions how tlibimp could be improved:
1) Generate a wrapper class that uses the VCL equivalents to the COM types
in the same way that Delphi does. The types are there so why not use them?
(Code bloat could be the only possible reason that I could think of)
2) Call the v-table interface directly rather than calling the IDispatch.
Calling an IDispatch seems like a leftover from the days when everyone used
to call CreateObject, etc and is highly inefficient, especially in a local
or remote server. Visual C++ seems to be able to do this, so why can't
C++Builder do it?

Is anyone else annoyed with the wrapper classes are they currently are?
Borland/Inprise, what do you think?

Mark

--------------------------------------------
Mark Sztainbok (mailto:s...@sausage.com.au)
Programmer, Sausage Software
150 Lonsdale Street
Melbourne VIC 3000
Australia

Ph:  +61-3-9662 2627
Fax: +61-3-9663 4030
--------------------------------------------