<div dir="ltr">Is there any reason why the late binding of properties and methods through of IDispatch interface with the Variant type is not working on Linux?<div><div><br></div><div>I am writing a cross platform embeddable JavaScript toolkit for Free Pascal. I wanted to use IDispatch with variants so that the experience with be more fluid for eventual end users. My goal of was to allow code like this to run:</div><div><br></div><div>var</div><div>  Script: IScript;</div></div><div>  V: Variant;</div><div>begin</div><div>  Script := NewScript('let person = {"name":  "James", age: 24}; let speak = () => log(<a href="http://person.name">person.name</a>)')</div><div>  V := Script.This;</div><div>  <a href="http://V.person.name">V.person.name</a> = 'Ralph';<br></div><div>  V.speak(); // writes out Ralph</div><div>  V := V.person;<br></div><div>  WriteLn(V.age); // write out 24<br></div><div>  V.address.street := '123 Skippy Lane'; // add address object with a street to person</div><div>  WriteLn(V.state); // writes out Undefined<br></div><div>end;</div><div><br></div><div>In the above code Script.This is a property returning an IDispatch interface holding an internal reference to the top level script object. The problem I am having with my current trunk version of fpc is that when I use a Variant that is assigned an IDispatch, no IDispatch methods to lookup and things like "person", "name", or "age" are ever evaluated.</div><div><br></div><div>Instead I get this:</div><div><br></div><div>Project dispatcher raised exception class 'External: SIGSEGV'.<br></div><div><br></div><div>Here is an example program. Not one WriteLn() in the example ever executes. Instead at runtime when V.Hello is evaluated I get the above exception. I believe fpc does support late time binding of IDispatch even on Linux as no inherent tie to Microsoft Windows functions are needed to make use of the IDispatch interface. So what is going on?</div><div><br></div><div>program Dispatcher;<br><br>{$mode delphi}<br><br>type<br>  TDispatcher = class(TInterfacedObject, IDispatch)<br>  public<br>    function GetTypeInfoCount(out Count: LongInt): HResult; stdcall;<br>    function GetTypeInfo(Index, LocaleID: LongInt; out TypeInfo): HResult; stdcall;<br>    function GetIDsOfNames(const IID: TGUID; Names: Pointer;<br>      NameCount, LocaleID: LongInt; DispIDs: Pointer): HResult; stdcall;<br>    function Invoke(DispID: LongInt;const IID: TGUID; LocaleID: LongInt;<br>      Flags: Word; var Params; VarResult, ExcepInfo, ArgErr: Pointer): HResult; stdcall;<br>  end;<br><br>function TDispatcher.GetTypeInfoCount(out Count: LongInt): HResult;<br>begin<br>  WriteLn('GetTypeInfoCount');<br>  Count := 0;<br>  Result := S_OK;<br>end;<br><br>function TDispatcher.GetTypeInfo(Index, LocaleID: LongInt; out TypeInfo): HResult;<br>begin<br>  WriteLn('GetTypeInfo');<br>  Result := E_NOTIMPL;<br>end;<br><br>function TDispatcher.GetIDsOfNames(const IID: TGUID; Names: Pointer; NameCount,<br>  LocaleID: LongInt; DispIDs: Pointer): HResult;<br>begin<br>  WriteLn('GetIDsOfNames');<br>  Result := S_OK;<br>end;<br><br>function TDispatcher.Invoke(DispID: LongInt; const IID: TGUID;<br>  LocaleID: LongInt; Flags: Word; var Params; VarResult, ExcepInfo,<br>  ArgErr: Pointer): HResult;<br>begin<br>  WriteLn('Invoke');<br>  Result := S_OK;<br>end;<br><br>procedure Test;<br>var<br>  D: IDispatch;<br>  V: Variant;<br>begin<br>  D := TDispatcher.Create;<br>  V := D;<br>  V.Hello();<br>end;<br><br>begin<br>  Test;<br>end.<br></div><div><br></div><div><br></div><div><br></div></div>