dwsRTTIConnector/RTTIVariant fix

Issue #8 resolved
Алек Невашедело created an issue

Several tests fail because of mistakes in code

URTTIExposeTests.pas
***************
@@ -220,13 +220,13 @@
       public
          constructor Create(table : TSymbolTable; rttiType : TRttiType);
    end;

    TdwsRTTIMethodType = (mtMethod, mtPropertyGet, mtPropertySet);

-   TdwsRTTIConnectorCall = class(TInterfacedSelfObject, IUnknown, IConnectorCall)
+   TdwsRTTIConnectorCall = class(TInterfacedSelfObject, IUnknown, IConnectorCall, IConnectorArgsCall)
       private
          FMethodName : String;
          FMethodType : TdwsRTTIMethodType;

       protected
          function Call(const base : Variant; const args : TConnectorArgs) : TData;
@@ -234,24 +234,24 @@

       public
          constructor Create(const methodName : String; const params : TConnectorParamArray;
                             methodType : TdwsRTTIMethodType);
    end;

-   TdwsRTTIConnectorMember = class(TInterfacedSelfObject, IUnknown, IConnectorMember)
+   TdwsRTTIConnectorMember = class(TInterfacedSelfObject, IUnknown, IConnectorMember,IConnectorDataMember)
       protected
          FMemberName : String;

          function Read(const base : Variant) : TData;
          procedure Write(const base : Variant; const data : TData);

       public
          constructor Create(const memberName : String);
    end;

-   TdwsRTTIConnectorIndexedProperty = class(TInterfacedSelfObject, IUnknown, IConnectorCall)
+   TdwsRTTIConnectorIndexedProperty = class(TInterfacedSelfObject, IUnknown, IConnectorCall,IConnectorArgsCall)
       private
          FPropertyName : String;
          FMethodType : TdwsRTTIMethodType;

       protected
          function Call(const base : Variant; const args : TConnectorArgs) : TData;

additionally

URTTIExposeTests.pas    2015-04-07 21:31:40.000000000 +0300
@@ -885,13 +885,13 @@
    try
       form.Name:='ConnectorTestForm';

       prog:=FCompiler.Compile( 'var f := ConnectForm("ConnectorTestForm");'#13#10
                               +'Print(f.Name);'#13#10
                               +'f.Name := "Hello";'#13#10
-                              +'var lbl := CreateComponent(f, "StdCtrls.TLabel");'#13#10
+                              +'var lbl := CreateComponent(f, "Vcl.StdCtrls.TLabel");'#13#10
                               +'lbl.Caption := "World";'#13#10
                               +'CreateComponent(f, "TLabel").Caption := "Label2";'#13#10
                               );

       CheckEquals('', prog.Msgs.AsInfo, 'compile');

Comments (3)

  1. Eric Grange repo owner

    Merged, though be aware the connector is no longer maintained.

    The reason being that the Delphi RTTI is not safe, so scripts that rely on RTTI are not safe and can crash the host application in various ways, which makes the connector unsuitable for end-user scripting purposes.

  2. Eric Grange repo owner

    Vcl.StdCtrls.TLabel should be under an Delphi version ifdef, though I'm not sure which version changed the StdCtrls unit name.

  3. Log in to comment