wasmjob: added AllocJSValue

This commit is contained in:
mattias 2022-07-26 16:21:54 +02:00
parent 600c131157
commit 67ecbfcb0d

View File

@ -149,6 +149,7 @@ type
function AllocIntf(Intf: IJSObject): PByte;
function AllocObject(Obj: TJSObject): PByte;
function AllocObjId(ObjId: TJOBObjectID): PByte;
function AllocJSValue(Value: TJOB_JSValue): PByte;
end;
TJOBCallback = function(const aMethod: TMethod; var H: TJOBCallbackHelper): PByte;
@ -1363,6 +1364,21 @@ begin
PJOBObjectID(Result+1)^:=ObjId;
end;
function TJOBCallbackHelper.AllocJSValue(Value: TJOB_JSValue): PByte;
begin
if Value=nil then
exit(AllocUndefined);
case Value.Kind of
jjvkUndefined: Result:=AllocUndefined;
jjvkBoolean: Result:=AllocBool(TJOB_Boolean(Value).Value);
jjvkDouble: Result:=AllocDouble(TJOB_Double(Value).Value);
jjvkString: Result:=AllocString(TJOB_String(Value).Value);
jjvkObject: Result:=AllocIntf(TJOB_Object(Value).Value);
else
raise EJSArgParse.Create('AllocJSValue unsupported: '+JOB_JSValueKindNames[Value.Kind]);
end;
end;
{ TJOB_JSValue }
constructor TJOB_JSValue.Create(aKind: TJOB_JSValueKind);