Re: [fpc-pascal] casting interfaces and objects
Marc Santhoff wrote: Am Sonntag, den 18.05.2008, 23:41 +0200 schrieb Graeme Geldenhuys: 2008/5/18 Marc Santhoff <[EMAIL PROTECTED]>: Since the compiler dod not warn about using the "as" operator I assume it is safe? Like this: procedure TObservable.DeRegister( obsv: IObserver ); var i: integer; begin if (fObservers.count<=0) then exit; for i:=0 to fObservers.count-1 do begin if ((fObservers[i] as IObserver)=obsv) then begin I'm not a big Interfaces expert, but as for as I know using 'as' like that with Interfaces actually translates to a QueryInterface() call internally, which is why it is allowed. I vaguely remember as issue between CORBA and COM interfaces and the 'as' call, because CORBA interfaces do not have a QueryInterface() implementation. Well, something like that... :-) Okay, so there are still some unknowns. CORBA interfaces do not include the following methods. These are only relevant to COM interfaces. function QueryInterface(const iid: tguid; out obj): longint; stdcall; function _AddRef: longint; stdcall; function _Release: longint; stdcall; Everybody I know uses COM interfaces, except for one developers - Martin from MSEgui project. FPC defaults to COM style interfaces as well. Regards, - Graeme - ___ fpGUI - a cross-platform GUI toolkit using Free Pascal http://opensoft.homeip.net/fpgui/ ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] casting interfaces and objects
Am Montag, den 19.05.2008, 09:16 +0200 schrieb Graeme Geldenhuys: > Marc Santhoff wrote: > > Am Sonntag, den 18.05.2008, 23:41 +0200 schrieb Graeme Geldenhuys: > >> 2008/5/18 Marc Santhoff <[EMAIL PROTECTED]>: > >>> Since the compiler dod not warn about using the "as" operator I assume > >>> it is safe? Like this: > >>> > >>> procedure TObservable.DeRegister( obsv: IObserver ); > >>> var > >>>i: integer; > >>> begin > >>>if (fObservers.count<=0) then exit; > >>>for i:=0 to fObservers.count-1 do begin > >>>if ((fObservers[i] as IObserver)=obsv) then begin > >> > >> I'm not a big Interfaces expert, but as for as I know using 'as' like > >> that with Interfaces actually translates to a QueryInterface() call > >> internally, which is why it is allowed. I vaguely remember as issue > >> between CORBA and COM interfaces and the 'as' call, because CORBA > >> interfaces do not have a QueryInterface() implementation. Well, > >> something like that... :-) > > > > Okay, so there are still some unknowns. > > CORBA interfaces do not include the following methods. These are only > relevant to COM interfaces. > > function QueryInterface(const iid: tguid; out obj): longint; stdcall; > function _AddRef: longint; stdcall; > function _Release: longint; stdcall; I know from compiling and the pdf docs. > Everybody I know uses COM interfaces, except for one developers - Martin > from MSEgui project. FPC defaults to COM style interfaces as well. I think that's a matter of the environment. I switched to CORBA too, because I wanted to get up a testing application fast. ;) But CORBA isn't that widely used, I think. Dunno what will happen on Windows when using corba for interfaces inside one application only, but I'm not sure if I can avoid using COM. At least driving some other apps like Winword or OO.o might come into play, but no export. Marc ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] casting interfaces and objects
On Monday 19 May 2008 00.02:55 Marc Santhoff wrote: > Am Sonntag, den 18.05.2008, 23:41 +0200 schrieb Graeme Geldenhuys: > > 2008/5/18 Marc Santhoff <[EMAIL PROTECTED]>: > > > Since the compiler dod not warn about using the "as" operator I assume > > > it is safe? Like this: > > > > > > procedure TObservable.DeRegister( obsv: IObserver ); > > > var > > >i: integer; > > > begin > > >if (fObservers.count<=0) then exit; > > >for i:=0 to fObservers.count-1 do begin > > >if ((fObservers[i] as IObserver)=obsv) then begin > > > > I'm not a big Interfaces expert, but as for as I know using 'as' like > > that with Interfaces actually translates to a QueryInterface() call > > internally, which is why it is allowed. I vaguely remember as issue > > between CORBA and COM interfaces and the 'as' call, because CORBA > > interfaces do not have a QueryInterface() implementation. Well, > > something like that... :-) > > Okay, so there are still some unknowns. > TObject.GetInterface does not work with corba style interfaces: http://bugs.freepascal.org/view.php?id=5800 http://bugs.freepascal.org/view.php?id=6798 http://bugs.freepascal.org/view.php?id=6036 For a workaround use "getcorbainterface" in lib/common/kernel/mseclasses.pas from MSEide+MSEgui: http://sourceforge.net/projects/mseide-msegui/ Martin ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal