On 08/05/14 20:38, Adriano dos Santos Fernandes wrote:
> On 05/08/2014 08:20, Alex Peshkoff wrote:
>> I want to suggest a first draft of [very restricted] IDL implementation
>> for firebird that should solve all mentioned problems. As an additional
>> non-mentioned before feature it solves the problem of making interface
>> version upgrade compiler independent and reliable.
>>
>>
> I tried to make some adjustments on the implementation part (to not need
> to #include file multiple times)

Using lo-o-o-ng macros instead? Definitely possible, not sure is it 
better or not. Long macro is well known debugging nightmare.

> , but I see a more big problem.
>
> The implementation rely on method shadowing.
>
> So if I have
>
> Impl : Interface
> {
>      void method1()
>      {
>          method2();
>      }
>
>      method2()
>      {
>      }
> }
>
> and
>
> ImplSpecialization : Impl    // Not supported by yours headers, but
> should be IMO
> {
>      method2()
>      {
>      }
> }
>
> When calling method1() from ImplSpecialization instance, it will call
> Impl::method2 instead of ImplSpecialization::method2. Do you have some
> suggestion for this?

I've tried to emulate it and see no problems.

#include <stdio.h>

class xxx
{
public:
         void fun() { printf("not get it - 1\n"); }
         void zz() { printf("not get it - 2\n"); }

         void (*statfun) (xxx*);
};

template <typename A>
class Base : public xxx
{
public:
         Base()
         {
                 statfun = sf;
         }

         void fun() { zz(); }
         void zz() { printf("Base\n"); }

         static void sf(xxx* ptr)
         {
                 ((Base*)ptr)->fun();
         }
};

template<>
void Base<char>::zz() { printf("Spec\n"); }

int main()
{
         Base<int> a;
         Base<char> b;

         printf("Direct:\n");
         a.fun();
         b.fun();

         printf("Using static function:\n");
         xxx* x = &a;
         x->statfun(x);
         x = &b;
         x->statfun(x);
}


> I also think the version checks must be automatic at least in the C++
> API, but calling getVersion in each call is not good. Maybe we can
> always insert 10 or so pointers to notImplemented() method in the end of
> each vtable.

In general it's a way to nowhere - time may come when you need 11 new 
methods.
In practice - each API has limited lifetime, memory is cheap, and if we 
put _really_ big number of barrier functions - may be we do not need 
getVersion() at all?


------------------------------------------------------------------------------
Infragistics Professional
Build stunning WinForms apps today!
Reboot your WinForms applications with our WinForms controls. 
Build a bridge from your legacy apps to the future.
http://pubads.g.doubleclick.net/gampad/clk?id=153845071&iu=/4140/ostg.clktrk
Firebird-Devel mailing list, web interface at 
https://lists.sourceforge.net/lists/listinfo/firebird-devel

Reply via email to