mirror of
https://gitlab.com/freepascal.org/fpc/pas2js.git
synced 2025-04-07 06:27:51 +02:00
Now the make function can create records.
This commit is contained in:
parent
038b896f03
commit
6ff4275792
@ -71,6 +71,7 @@ type
|
||||
generic function IsType<T>(const EmptyAsAnyType: Boolean = True): Boolean; overload;
|
||||
function GetArrayElement(aIndex: SizeInt): TValue;
|
||||
function GetArrayLength: SizeInt;
|
||||
function GetReferenceToRawData: Pointer;
|
||||
function IsArray: boolean;
|
||||
function IsClass: boolean;
|
||||
function IsObject: boolean;
|
||||
@ -833,8 +834,15 @@ end;
|
||||
|
||||
class procedure TValue.Make(const ABuffer: JSValue; const ATypeInfo: PTypeInfo; var Result: TValue);
|
||||
begin
|
||||
Result.FData := ABuffer;
|
||||
Result.FTypeInfo := ATypeInfo;
|
||||
|
||||
if Result.FTypeInfo.Kind = tkRecord then
|
||||
if Assigned(ABuffer) then
|
||||
Result.FData := TTypeInfoRecord(ATypeInfo).RecordInfo.Assign(ABuffer)
|
||||
else
|
||||
Result.FData := TTypeInfoRecord(ATypeInfo).RecordInfo.New
|
||||
else
|
||||
Result.FData := ABuffer;
|
||||
end;
|
||||
|
||||
generic class procedure TValue.Make<T>(const Value: T; var Result: TValue);
|
||||
@ -1175,6 +1183,11 @@ begin
|
||||
raise EInvalidCast.Create(SErrInvalidTypecast);
|
||||
end;
|
||||
|
||||
function TValue.GetReferenceToRawData: Pointer;
|
||||
begin
|
||||
Result := Pointer(GetData);
|
||||
end;
|
||||
|
||||
function TValue.IsType(ATypeInfo: TTypeInfo): boolean;
|
||||
begin
|
||||
Result := ATypeInfo = TypeInfo;
|
||||
|
@ -291,9 +291,17 @@ type
|
||||
|
||||
{ TTypeInfoRecord - Kind = tkRecord }
|
||||
|
||||
TRecordInfo = class external name 'Object'(TJSObject)
|
||||
public
|
||||
function Assign(Source: JSValue): JSValue; external name '$assign';
|
||||
function Clone(Source: JSValue): JSValue; external name '$clone';
|
||||
function Equals(Source: JSValue): Boolean; external name '$eq';
|
||||
function New: JSValue; external name '$new';
|
||||
end;
|
||||
|
||||
TTypeInfoRecord = class external name 'rtl.tTypeInfoRecord'(TTypeInfoStruct)
|
||||
public
|
||||
RecordType: TJSObject external name '$record'; // only records with class vars, else jsundefined
|
||||
RecordInfo: TRecordInfo external name '$record'; // only records with class vars, else jsundefined
|
||||
end;
|
||||
|
||||
{ TTypeInfoClass - Kind = tkClass }
|
||||
|
Loading…
Reference in New Issue
Block a user