Subject Re: [Firebird-Architect] External Engines (and Plugins)
Author Adriano dos Santos Fernandes
Vlad Khorsun escreveu:
> Adriano dos Santos Fernandes :
>
>> Dmitry Yemanov escreveu:
>>
>>> Adriano dos Santos Fernandes wrote:
>>>
>>>
>>>> C++ libraries can throw exceptions and the plugin part (CppEngine.h)
>>>> embedded on them deal with exceptions and translate to the Error object.
>>>> There is no boundaries violation.
>>>>
>>>>
>>> Maybe Vlad meant to say that a properly implemented dynamic library
>>> should never throw exceptions to the caller process.
>>>
>
> Yes. More - one library must never throw exceptions even to caller library.
My first contribution to open source projects was a patch to GCC/MinGW
to allow exceptions throw/catch across EXE/DLLs boundaries. It was only
possible using dynamic library versions of libstd++, but such version
was not officially distributed as people worried about GPL issues. Also,
MSVC exceptions can be throw across MSVC EXE/DLLs.

> OS
> level exceptions can be handled correctly between different libraries compiled
> by different compilers but not "language" exceptions.
>
This is *not* true. It may cause incorrect stack unwind.

>
>> This is not always true, but...
>>
>
> This must be always true else we in trouble.
>
Error object was designed to not put we in trouble.

>
>>> As long as this rule is followed, you don't need to handle C++ and Delphi plugins
>>> differently in terms of exceptions.
>>>
>> CppEngine.h becomes part of user library. This header file was many
>> inline implementation just for it. Libraries could (and are encouraged
>> to) throw ThrowError::Exception (or use ThrowError::check) and the error
>> will be converted to status vector. Others (...) exceptions are just
>> caught as unrecognized. All done without cross library boundaries.
>>
>
> Then you mixed two layers (plugin itself and user library) in one header file.
>
Why? The header file is named CppEngine (CPP means C++, remember :-) ),
so the original idea was to use it for C++. I'll split it into two
header files. It declares macros, catch exceptions and transfer to Error
object. The macros will be used in user code, hence exception code is in
user code.

I suppose you didn't looked at it. There is no mixed/violation layers
there, sorry.


Adriano