[fpc-pascal] A list of CORBA interfaces - how?

2011-09-20 Thread Graeme Geldenhuys
Hi,

I'm porting some of my old Delphi code which used interfaces
extensively. Since I moved to FPC years ago, I liked the idea of
CORBA-style interfaces, and mostly use them under FPC projects.

Anyway, some of my code used IInterfaceList / TInterfaceList, but that
uses IIInterface, which is an alias for IUnknown, which is COM-style
interfaces only.

What is the equivalent for CORBA style interfaces?  Just a TList storing
pointers?

Regards,
  - Graeme -

-- 
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] problems with CORBA interfaces having no base type

2011-09-20 Thread Graeme Geldenhuys
Hi again,

Continuing my port of old Delphi code that used interfaces extensively.
Now that FPC 2.6.0 is nearing, I can play the with Interface
improvements it has.

In some of my old Delphi code, I created a generic class that takes a
generic interface via IInterface. This class was made to be reusable via
interface delegation, so I only need to implement a interface once and
use interface delegation in other classes to add that functionality. One
such example is the Observer design pattern

  IObserver = interface
  ['{7504BB57-65D8-4D5D-86F1-EC8FFED8ED5E}']
procedure Update(const Subject: IInterface);
  end;


How do I translate this to CORBA-style interfaces. CORBA interfaces
don't have a base type like all COM interfaces have (eg: IUnknown) or
objects have (eg: TObject).

Any ideas on how I should translate the above code? Must I use the
Pointer type again?  That just looks ugly, and gives no hint to the
developer that Update() can take any interface type.

Why couldn't CORBA interfaces also descend from IInterface, but in the
case of CORBA style interfaces that doesn't mean it's a IUnknown
descendant. That way we will have a generic interface type to use in
such generic code situations.

Regards,
  - Graeme -

-- 
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] problems with CORBA interfaces having no base type

2011-09-20 Thread Sven Barth

Am 20.09.2011 08:40, schrieb Graeme Geldenhuys:


   IObserver = interface
   ['{7504BB57-65D8-4D5D-86F1-EC8FFED8ED5E}']
 procedure Update(const Subject: IInterface);
   end;


How do I translate this to CORBA-style interfaces. CORBA interfaces
don't have a base type like all COM interfaces have (eg: IUnknown) or
objects have (eg: TObject).

Any ideas on how I should translate the above code? Must I use the
Pointer type again?  That just looks ugly, and gives no hint to the
developer that Update() can take any interface type.


I personally would declare my own basic interface class and derive all 
other interfaces from that... This of cours only works if anyone adheres 
/ can adhere to that rule.



Why couldn't CORBA interfaces also descend from IInterface, but in the
case of CORBA style interfaces that doesn't mean it's a IUnknown
descendant. That way we will have a generic interface type to use in
such generic code situations.


Because IInterface is designated as a COM-interface and you can't 
descend a CORBA-interface from a COM-interface or vice-versa. Also it's 
not possible to declare IInterface as a CORBA-interface, because another 
unit might use COM-interfaces and then the COM-style IInterface is needed.


Regards,
Sven
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] problems with CORBA interfaces having no base type

2011-09-20 Thread Graeme Geldenhuys
On 20/09/2011 09:31, Sven Barth wrote:
 
 I personally would declare my own basic interface class and derive all 
 other interfaces from that... This of cours only works if anyone adheres 
 / can adhere to that rule.

I thought of this, but then my code is not very reusable by other
developers. Everybody else would have to change there base interface
type for all there interfaces. Not viable at all.


 Because IInterface is designated as a COM-interface and you can't 
 descend a CORBA-interface from a COM-interface or vice-versa.

This is not what I meant. Just like the compiler has compiler modes, why
can't the {$interfaces corba} change the mode of IInterface. The name
also says it's a generic interface type, so maybe the compiler could
that inject the following

  IInterface = interface
  end;

...overriding (or better, hiding) the old COM declaration of...

  IInterface = IIUnkown


So then in CORBA style interfaces, the following two declarations mean
the same thing (just like they would if I used COM style interfaces)

{$interfaces corba}
...

  ISubject = interface
  end;

  ISubject = interface(IInterface)
  end;


Just like String can mean AnsiString or ShortString, based on a compiler
switch.


Regards,
  - Graeme -

-- 
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] problems with CORBA interfaces having no base type

2011-09-20 Thread Sven Barth

Am 20.09.2011 09:47, schrieb Graeme Geldenhuys:

Because IInterface is designated as a COM-interface and you can't
descend a CORBA-interface from a COM-interface or vice-versa.


This is not what I meant. Just like the compiler has compiler modes, why
can't the {$interfaces corba} change the mode of IInterface. The name
also says it's a generic interface type, so maybe the compiler could
that inject the following

   IInterface = interface
   end;

...overriding (or better, hiding) the old COM declaration of...

   IInterface = IIUnkown


So then in CORBA style interfaces, the following two declarations mean
the same thing (just like they would if I used COM style interfaces)

{$interfaces corba}
...

   ISubject = interface
   end;

   ISubject = interface(IInterface)
   end;


Just like String can mean AnsiString or ShortString, based on a compiler
switch.


1. Changing the meaning of IInterface based on $interfaces is not 
possible, because IInterface is located in System unit.


2. Hiding IInterface with a CORBA-based base type is a nice idea at the 
first glance, but you'll get trouble later, because the base object will 
be defined in the same unit as the derived symbol:


Imagine you have two units where both declare a CORBA-interface without 
a parent. Then both units will contain a definition of the basetype. Now 
you have a third unit that uses those two units and defines an interface 
that derives from one of the two previous interfaces. This interface 
won't be compatible then with the other one, from which you didn't derive.



So there are only two other possibilities left:
1. Add a new RTL unit that defines a base interface for CORBA and 
include that if {$interface corba} is encountered. Problem: I don't know 
whether $interface is a local or unit global switch (someone else needs 
to answer this).


2. Add a base type with a different name (e.g. ICORBAInterface) in the 
System unit and use that as base type.


I personally would suggest the latter.

Regards,
Sven
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] A list of CORBA interfaces - how?

2011-09-20 Thread Flávio Etrusco
On Tue, Sep 20, 2011 at 3:28 AM, Graeme Geldenhuys
graemeg.li...@gmail.com wrote:
 Hi,

 I'm porting some of my old Delphi code which used interfaces
 extensively. Since I moved to FPC years ago, I liked the idea of
 CORBA-style interfaces, and mostly use them under FPC projects.

 Anyway, some of my code used IInterfaceList / TInterfaceList, but that
 uses IIInterface, which is an alias for IUnknown, which is COM-style
 interfaces only.

 What is the equivalent for CORBA style interfaces?  Just a TList storing
 pointers?

 Regards,
  - Graeme -

 --

I've just found this: http://62.166.198.202/view.php?id=6036
And this really works! :) Even 'as' operator works (so the error
message in FPC 2.4.4 is misleading).
You can iterate over TClass.GetInferfaceTable, and if you declare an
interface name it'll appear there (I checked). Not sure whether
there's some way (or hack) to compare an (unnamed) interface with the
VMT pointer there...

Best regards,
Flávio

PS. A few days ago when Marcos Douglas was asking about CORBA vs COM I
didn't find this information :-/
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] A list of CORBA interfaces - how?

2011-09-20 Thread Flávio Etrusco
Oops, seems I completely misread your post.
The problem is cite is the kind of (or exactly) the one you're trying to fix :-$

Thanks for Marcos for pointing that out.

-Flávio

2011/9/20 Flávio Etrusco flavio.etru...@gmail.com:
 On Tue, Sep 20, 2011 at 3:28 AM, Graeme Geldenhuys
 graemeg.li...@gmail.com wrote:
 Hi,

 I'm porting some of my old Delphi code which used interfaces
 extensively. Since I moved to FPC years ago, I liked the idea of
 CORBA-style interfaces, and mostly use them under FPC projects.

 Anyway, some of my code used IInterfaceList / TInterfaceList, but that
 uses IIInterface, which is an alias for IUnknown, which is COM-style
 interfaces only.

 What is the equivalent for CORBA style interfaces?  Just a TList storing
 pointers?

 Regards,
  - Graeme -

 --

 I've just found this: http://62.166.198.202/view.php?id=6036
 And this really works! :) Even 'as' operator works (so the error
 message in FPC 2.4.4 is misleading).
 You can iterate over TClass.GetInferfaceTable, and if you declare an
 interface name it'll appear there (I checked). Not sure whether
 there's some way (or hack) to compare an (unnamed) interface with the
 VMT pointer there...

 Best regards,
 Flávio

 PS. A few days ago when Marcos Douglas was asking about CORBA vs COM I
 didn't find this information :-/

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal