Refactoring streams and fixin various bugs
This commit is contained in:
@@ -45,6 +45,8 @@ type
|
||||
class function Intern(const AName: string): IKeyword; static;
|
||||
// Gets the name for a given keyword index.
|
||||
class function GetName(AIdx: Integer): string; static;
|
||||
// Gets the keyword for a given keyword index.
|
||||
class function GetKeyword(AIdx: Integer): IKeyword; static;
|
||||
end;
|
||||
|
||||
// Defines a mapping from Keywords to a generic value T
|
||||
@@ -144,6 +146,11 @@ begin
|
||||
FReverseMap.Free;
|
||||
end;
|
||||
|
||||
class function TKeywordRegistry.GetKeyword(AIdx: Integer): IKeyword;
|
||||
begin
|
||||
Result := FReverseMap[AIdx];
|
||||
end;
|
||||
|
||||
class function TKeywordRegistry.Intern(const AName: string): IKeyword;
|
||||
var
|
||||
idx: Integer;
|
||||
|
||||
@@ -333,7 +333,12 @@ end;
|
||||
function TDataValue.AsScalarRecord: IKeywordMapping<TScalar>;
|
||||
begin
|
||||
if (FKind <> vkScalarRecord) then
|
||||
raise EInvalidCast.Create('Cannot read value as Record.');
|
||||
begin
|
||||
if (FKind = vkRecord) then
|
||||
raise EInvalidCast.Create('Scalar record expected.')
|
||||
else
|
||||
raise EInvalidCast.Create('Cannot read value as Record.');
|
||||
end;
|
||||
Result := IKeywordMapping<TScalar>(FInterface);
|
||||
end;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user