Fix in Scripting
This commit is contained in:
@@ -9,7 +9,8 @@ uses
|
||||
Myc.Data.Series;
|
||||
|
||||
type
|
||||
TDataValueKind = (vkVoid, vkScalar, vkText, vkSeries, vkRecordSeries, vkRecord, vkManagedObject, vkMethod, vkInterface, vkGeneric);
|
||||
TDataValueKind =
|
||||
(vkVoid, vkScalar, vkText, vkSeries, vkRecordSeries, vkRecord, vkManagedObject, vkMethod, vkInterface, vkPointer, vkGeneric);
|
||||
|
||||
TDataValue = record
|
||||
type
|
||||
@@ -64,6 +65,9 @@ type
|
||||
class function FromGeneric<T>(const [ref] AValue: T): TDataValue; static; inline;
|
||||
function AsGeneric<T>: T; inline;
|
||||
|
||||
class function FromPtr(const AValue: Pointer): TDataValue; static; inline;
|
||||
function AsPtr: Pointer; inline;
|
||||
|
||||
class function Defer(const Value: TDataValue; const Calc: TFunc): TDataValue; overload; static;
|
||||
|
||||
class function Map(const SourceSeries: ISeries; const MapperFunc: TFunc): ISeries; static;
|
||||
@@ -243,6 +247,15 @@ begin
|
||||
Result := (FInterface as TObjVal).Value;
|
||||
end;
|
||||
|
||||
function TDataValue.AsPtr: Pointer;
|
||||
begin
|
||||
if FKind = Ord(vkLazy) then
|
||||
exit(AsLazy.Value.AsPtr);
|
||||
if (FKind <> Ord(vkPointer)) then
|
||||
raise EInvalidCast.Create('Cannot read value as pointer.');
|
||||
Result := Pointer(FScalar.Value.AsInt64);
|
||||
end;
|
||||
|
||||
function TDataValue.AsRecord: TScalarRecord;
|
||||
begin
|
||||
if FKind = Ord(vkLazy) then
|
||||
@@ -320,6 +333,13 @@ begin
|
||||
Result.FInterface := TVal<T>.Create(AValue);
|
||||
end;
|
||||
|
||||
class function TDataValue.FromPtr(const AValue: Pointer): TDataValue;
|
||||
begin
|
||||
Assert(sizeof(Pointer) <= sizeof(Int64));
|
||||
Result.FKind := Ord(vkPointer);
|
||||
Result.FScalar.FromInt64(Int64(AValue));
|
||||
end;
|
||||
|
||||
class function TDataValue.FromSeries(const AValue: ISeries): TDataValue;
|
||||
begin
|
||||
Result.FKind := Ord(vkSeries);
|
||||
|
||||
Reference in New Issue
Block a user