IsCompilation failed on Lazarus under Windows
There is a lot of small errors during compilation under Lazarus Windows, I started to correct them but have no idea how long it'll take to correct them all so I dropped it for now.
Yes, I had a go at it a couple years ago, but a major stumbling block was that FreePascal RTL doesn't fully support UnicodeString Variants, and the the RTL only has partial support for UnicodeString. This leads to a lot of glitching and test case failures. The issue is not solvable in the FPC RTL without breaking a lot of existing LCL code assumptions.
Only long term solution would probably be to implement a "DWSVariant" from scratch for FPC, so DWScript can get a Delphi-compatible Variant behavior under FPC, but this is a major undertaking with dubious benefits. Alternatively, it's possible to compile with UTF8Strings, which FPC Variants support, but this would fork the DWScript variant into a new dialect with incompatible behaviors.
Yes I see, different strings implementation on FPC and Delphi can cause a lot of pain. All right no problem, I don't think it's worth the time. BTW I placed some issues on the bitbucket.org.
BTW I placed some issues on the bitbucket.org
The bitbucket issue tracker is broken; You are probably the only one who can see the issues you posted.
:) didnt know that. So here are the issues: Delphi 11.3,
1) dwsRTTIExposer.pas (805)
tkEnumeration : if asType.Handle=TypeInfo(Boolean) then info.Value:=value.AsBoolean else info.Value:=value.AsInt64;
AsInt64here causes error, if you replace it with AsVariant it works.
- when exposing a method like this
procedure TSomeClass.DecodeActions(const sActions: string; var Actions: TArray
if you place here out instead of var the script always gets an empty array. Var works fine.
- The similar problem exists with enumeration parameters, but on the contrary, var doesn't return a changed value but out works fine
procedure TSomeClass.DecodeActions(const sActions: string; var Action: TSomeEnumeration);
- I have got different behavior on Linux and Windows while exposing methods with array parameters like in 2. dwsRTTIExposer.pas (881)
DynArraySetLength(PPointer(Result.GetReferenceToRawData)^, Result.TypeInfo, 1, @LLen)
The code causes range check error on Linux, while on Windows does not.
If you need to provide some tests I can do that. The 4) issue is the most essential
Yes, I saw your Issue on Bitbucket, but when trying to access it, I just get a 403 "under review" error.
For your 1, do you have an example of the Delphi-side code that triggers the issue ?
For 4, I do not have access to Linux for Delphi to test on :/
- Looks like the first problem is related to properties. Delphi code:
type
TSomeClass //class to be exposed
.....
private
FTestEnum: TSomeEnumeration;
published
property TestEnum: TSomeEnumeration read FTestEnum write FTestEnum;
function TestFunc2(ATestEnum: TSomeEnumeration ): Boolean;
end;
var
SomeClass :TSomeClass;//object to be exposed
Script code
var
TestEnum: TSomeEnumeration
SomeClass.TestFunc2(TestEnum);//works fine with internal variable
SomeClass.TestFunc2(SomeClass.TestEnum);//invalid class typecast with exposed property
- As per Linux I can offer you the remote access to my PC where you can test it
I have committed a test case in Test/URTTIExposeTests.pas based on your above snippet, but can't reproduce the issue (Delphi 12 / Win64). Does the test reproduce the issue on your side or do you have extra details that could help reproduce ?
thanks I will try to reproduce the issue on your test case and let you know
Yes I found why you didn't get the error.
- I tried to compile your test but failed to find TestUtils.pas, so I copied your code to my test unit and changed it to produce the error
- My test is more complicated than yours.
I expose not only
TClassWithEnumerationbut also thevar c:TClassWithEnumeration;like that:FUnit.ExposeInstanceToUnit('c', 'TClassWithEnumeration', c);and the script will be like that (cis not created but exposed):
c.TestFunc(seOne);//fine
c.TestFunc(c.EnumField);//bad
Hi Eric, I found some weird issue when exposing arrays. When you pass such property to another exposed method the script runs extremely slow and speed falls down exponentially with increasing size of the array (actually not very large) for example passing 10000 elements takes around 10 seconds of running when the program does absolutely nothing useful. 20000 elements takes around 40 seconds.
type
TTestScript = class
private
FResponseStream: TArray<Int64>;
published
property ResponseStream read FResponseStream write FResponseStream;
procedure Test;
procedure Test2(const ar:TArray<Int64>);
end;
implementation
procedure TTestScript.Test;
begin
SetLength(FResponseStream,10000);
end;
procedure TTestScript.Test2(const ar:TArray<Int64>);
begin
end;
Calling test and then test2 in the script when passing the ResponseStream to it causes the program to work very slow.
I managed to work around using variant properties instead of arrays. It works now fast on Windows. But on Linux I have got another problem - all array parameters of exposed class method cause a huge number of range check errors when Delphi tries to call the method from the script
Eric, I have made a test project, so this one can be closed