Binder refactoring, Monster refactoring

This commit is contained in:
Michael Schimmel
2025-11-02 19:38:52 +01:00
parent 8f29212cba
commit ea39a57b77
22 changed files with 3061 additions and 2638 deletions
+19 -9
View File
@@ -62,7 +62,6 @@ type
class operator Implicit(const AValue: TDataValue): TScalar; overload; inline;
class operator Implicit(const AValue: String): TDataValue; overload; inline;
class operator Implicit(const AValue: TDataValue.TFunc): TDataValue; overload; inline;
class operator Implicit(const AValue: TObject): TDataValue; overload; inline;
// atomic operations
function CompareAndSet(const Expected, NewValue: TDataValue): Boolean;
@@ -77,6 +76,9 @@ type
class function FromPtr(const AValue: Pointer): TDataValue; static; inline;
function AsPtr: Pointer; inline;
// This take ownership of the object!
procedure FromObj(const AValue: TObject); inline;
class function Map(const SourceSeries: ISeries; const MapperFunc: TFunc): ISeries; static;
class function FromRecordSeries(const AValue: IRecordSeries): TDataValue; static; inline;
@@ -158,12 +160,17 @@ function TDataValue.AsGeneric<T>: T;
begin
if FKind <> vkGeneric then
raise EInvalidCast.Create('Cannot read value as generic of ' + String(PTypeInfo(TypeInfo(T)).Name) + '.');
if PTypeInfo(TypeInfo(T)).Kind <> tkInterface then
begin
{$ifdef DEBUG}
var val := TVal<T>(FInterface);
if val.TypeHandle <> TypeInfo(T) then
raise EInvalidCast.Create('Generic type is not a ' + String(PTypeInfo(TypeInfo(T)).Name) + '.');
var val := TVal<T>(FInterface);
if val.TypeHandle <> TypeInfo(T) then
raise EInvalidCast.Create('Generic type is not a ' + String(PTypeInfo(TypeInfo(T)).Name) + '.');
{$endif}
Result := TVal<T>(FInterface).Value;
Result := TVal<T>(FInterface).Value;
end
else
IInterface(Pointer(@Result)^) := FInterface
end;
function TDataValue.AsIntf<T>: T;
@@ -278,7 +285,10 @@ end;
class function TDataValue.FromGeneric<T>(const [ref] AValue: T): TDataValue;
begin
Result.FKind := vkGeneric;
Result.FInterface := TVal<T>.Create(AValue);
if PTypeInfo(TypeInfo(T)).Kind = tkInterface then
Result.FInterface := IInterface(Pointer(@AValue)^)
else
Result.FInterface := TVal<T>.Create(AValue);
end;
class function TDataValue.FromPtr(const AValue: Pointer): TDataValue;
@@ -473,10 +483,10 @@ begin
TFunc(Result.FInterface) := AValue;
end;
class operator TDataValue.Implicit(const AValue: TObject): TDataValue;
procedure TDataValue.FromObj(const AValue: TObject);
begin
Result.FKind := vkManagedObject;
Result.FInterface := TObjVal.Create(AValue);
FKind := vkManagedObject;
FInterface := TObjVal.Create(AValue);
end;
class operator TDataValue.Implicit(const AValue: TDataValue): TScalar;