Hi,
I've managed to set a COM interface property (tkInterface) through RTTI
using SetInterfaceProp.
But i could not find a way to set a CORBA interface property
(tkInterfaceRaw) since SetInterfaceProp expects IUnknown.
In the attached example, when i try to use SetInterfaceProp i get the
message "Incompatible type for arg no. 3: Got "IMyIntf", expected
"IUnknown"".
Is there a way to set a CORBA interface property through RTTI?
Luiz
program bugIntfRTTI;
{$mode objfpc}{$H+}
{$Define USE_CORBA}
uses
Classes, typinfo;
type
{$ifdef USE_CORBA}
{$INTERFACES CORBA}
{$endif}
IMyIntf = interface
procedure DoIt;
end;
{$ifdef USE_CORBA}
TMyIntfImpl = class(TObject, IMyIntf)
procedure DoIt;
end;
{$else}
TMyIntfImpl = class(TInterfacedObject, IMyIntf)
procedure DoIt;
end;
{$endif}
TMyObj = class(TComponent)
private
FIntf: IMyIntf;
procedure SetIntf(const Value: IMyIntf);
published
property Intf: IMyIntf read FIntf write SetIntf;
end;
procedure TMyObj.SetIntf(const Value: IMyIntf);
begin
FIntf := Value;
WriteLn('SetIntf: ' + hexStr(FIntf));
end;
procedure TMyIntfImpl.DoIt;
begin
WriteLn('DoIt - ', {$ifdef USE_CORBA}'CORBA'{$else}'COM'{$endif});
end;
var
Obj: TMyObj;
Impl: IMyIntf;
PropInfo: PPropInfo;
begin
Impl := TMyIntfImpl.Create;
Obj := TMyObj.Create(nil);
PropInfo := GetPropInfo(PTypeInfo(Obj.ClassInfo), 'Intf');
if PropInfo <> nil then
begin
WriteLn('PropInfo Found: ' + GetEnumName(TypeInfo(TTypeKind),
Integer(PropInfo^.PropType^.Kind)));
SetInterfaceProp(Obj, PropInfo, Impl);
Obj.Intf.DoIt;
end
else
WriteLn('PropInfo NOT Found');
Obj.Destroy;
end.
_______________________________________________
fpc-pascal maillist - fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal