You are not logged in.
Hi @ab, I try using nested expression helpers and I get an exception when last expression helper finalize. I can reproduce the issue with a modified version of sample "23 - Javascript Tests".
https://drive.google.com/file/d/0Bx7LPc … sp=sharing
Can you see the problem ? I need use this feature.
Thanks in advance.
Esteban.
Esteban
Offline
I cannot solve the problem yet, but I found a strange behavior. I changed the function FromBase64 and ToBase64.
...
class procedure TMainForm.FromBase64(const Value: variant; out result: variant);
var
lValue, lResp: RawByteString;
begin
VariantToRawByteString(Value, lValue);
lResp := SynCommons.Base64ToBin(lValue);
RawByteStringToVariant(lResp, result);
end;
...
class procedure TMainForm.ToBase64(const Value: variant; out result: variant);
var
lValue, lResp: RawByteString;
begin
VariantToRawByteString(Value, lValue);
lResp := SynCommons.BinToBase64(lValue);
RawByteStringToVariant(lResp, result);
end;
but the error continue, if I hardcoded in ToBase64 the result variable this works
...
class procedure TMainForm.FromBase64(const Value: variant; out result: variant);
var
lValue, lResp: RawByteString;
begin
VariantToRawByteString(Value, lValue);
lResp := SynCommons.Base64ToBin(lValue);
RawByteStringToVariant(lResp, result);
end;
...
class procedure TMainForm.ToBase64(const Value: variant; out result: variant);
var
lValue, lResp: RawByteString;
begin
VariantToRawByteString(Value, lValue);
lResp := SynCommons.BinToBase64(lValue);
// RawByteStringToVariant(lResp, result);
result := 'dGV4dCBlbmNvZGVkIHdpdGggYmFzZTY0IHVzaW5nIGJpbnRvYmFzZTY0IGZ1bmN0aW9u';
end;
or if I hardcode the lValue variable in FromBase64, too this works
...
class procedure TMainForm.FromBase64(const Value: variant; out result: variant);
var
lValue, lResp: RawByteString;
begin
lValue := 'dGV4dCBlbmNvZGVkIHdpdGggYmFzZTY0IHVzaW5nIGJpbnRvYmFzZTY0IGZ1bmN0aW9u';
// VariantToRawByteString(Value, lValue);
lResp := SynCommons.Base64ToBin(lValue);
RawByteStringToVariant(lResp, result);
end;
...
class procedure TMainForm.ToBase64(const Value: variant; out result: variant);
var
lValue, lResp: RawByteString;
begin
VariantToRawByteString(Value, lValue);
lResp := SynCommons.BinToBase64(lValue);
RawByteStringToVariant(lResp, result);
end;
I am very confused.
Any help is appreciated.
Esteban.
Esteban
Offline
I forgot to mention, in Delphi XE 10.1 Berlin the exception "Invalid Pointer Operation" is raised, in Delphi 7 the application it freezes.
Thanks.
Esteban.
Esteban
Offline
Because VariantToRawByteString are not true text variants which are compatible with JSON and mustache, but some custom variant types to be used internally for data transfert.
Offline
Ok, but in the sample application I am not using VariantToRawByteString, but direct use of Base64ToBin and BinToBase64.
Esteban
Offline
I found a solution, is not the better but works for me, I made a copy of "const Value: variant" param and I work with that copy.
class procedure TMainForm.FromBase64(const Value: variant; out result: variant);
var
lValue: RawByteString;
begin
lValue := Copy(Value, 1, Length(Value));
result := SynCommons.Base64ToBin(lValue);
end;
class procedure TMainForm.ToBase64(const Value: variant; out result: variant);
var
lValue: RawByteString;
begin
lValue := Copy(Value, 1, Length(Value));
result := SynCommons.BinToBase64(lValue);
end;
@ab, is there a better solution ?
Thanks.
Esteban
Esteban
Offline
Just for curiosity, is not this a bug ? I mean, the sample application fail but with this patch no.
Esteban.
Esteban
Offline