mirror of
https://gitlab.com/freepascal.org/fpc/pas2js.git
synced 2025-04-05 08:57:49 +02:00
* Fix releasobjectid
This commit is contained in:
parent
3670f8fec6
commit
d7ac63abd7
@ -74,7 +74,6 @@ Type
|
|||||||
FGlobalObjects: TJSArray; // id to TJSObject
|
FGlobalObjects: TJSArray; // id to TJSObject
|
||||||
FGlobalNames: TJSObject; // name to id
|
FGlobalNames: TJSObject; // name to id
|
||||||
FLocalObjects: TJSArray;
|
FLocalObjects: TJSArray;
|
||||||
FFreeLocalIds: TJSArray; // free positions in FLocalObjects
|
|
||||||
FOnCallBackJSError: TCallbackErrorJSEventHandler;
|
FOnCallBackJSError: TCallbackErrorJSEventHandler;
|
||||||
FOnCallBackPasError: TCallbackErrorPasEventHandler;
|
FOnCallBackPasError: TCallbackErrorPasEventHandler;
|
||||||
FStringResult: string;
|
FStringResult: string;
|
||||||
@ -251,7 +250,6 @@ begin
|
|||||||
RegisterGlobalObjects;
|
RegisterGlobalObjects;
|
||||||
FLocalObjects:=TJSArray.new;
|
FLocalObjects:=TJSArray.new;
|
||||||
FLocalObjects.push(nil); // allocate FLocalObjects[0]
|
FLocalObjects.push(nil); // allocate FLocalObjects[0]
|
||||||
FFreeLocalIds:=TJSArray.new;
|
|
||||||
FFactories:=TJSObject.New;
|
FFactories:=TJSObject.New;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -349,20 +347,10 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
function TJSObjectBridge.RegisterLocalObject(Obj: TJSObject): TJOBObjectID;
|
function TJSObjectBridge.RegisterLocalObject(Obj: TJSObject): TJOBObjectID;
|
||||||
var
|
|
||||||
NewId: JSValue;
|
|
||||||
begin
|
begin
|
||||||
NewId:=FFreeLocalIds.pop;
|
Result:=GetObjectID;
|
||||||
if isUndefined(NewId) then
|
RegisterLocalObjectAt(Obj,Result);
|
||||||
begin
|
|
||||||
NewId:=FLocalObjects.push(Obj)-1;
|
|
||||||
Result:=TJOBObjectID(NewId);
|
|
||||||
FLastAllocatedID:=Result;
|
|
||||||
end
|
|
||||||
else begin
|
|
||||||
Result:=TJOBObjectID(NewId);
|
|
||||||
FLocalObjects[Result]:=Obj;
|
|
||||||
end;
|
|
||||||
{$IFDEF VerboseJOB}
|
{$IFDEF VerboseJOB}
|
||||||
writeln('TJSObjectBridge.RegisterLocalObject ',Result);
|
writeln('TJSObjectBridge.RegisterLocalObject ',Result);
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
@ -814,7 +802,8 @@ begin
|
|||||||
if FLocalObjects[ObjId]=nil then
|
if FLocalObjects[ObjId]=nil then
|
||||||
raise EJOBBridge.Create('object already released');
|
raise EJOBBridge.Create('object already released');
|
||||||
FLocalObjects[ObjId]:=nil;
|
FLocalObjects[ObjId]:=nil;
|
||||||
FFreeLocalIds.push(ObjId);
|
ReleaseJobID(ObjID);
|
||||||
|
|
||||||
Result:=JOBResult_Success;
|
Result:=JOBResult_Success;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -1306,7 +1295,6 @@ end;
|
|||||||
function TJSObjectBridge.GetStats: TJSObjectBridgeStats;
|
function TJSObjectBridge.GetStats: TJSObjectBridgeStats;
|
||||||
begin
|
begin
|
||||||
Result.LastAllocatedID:=FLastAllocatedID;
|
Result.LastAllocatedID:=FLastAllocatedID;
|
||||||
Result.FreeIDCount:=FFreeLocalIds.Length;
|
|
||||||
Result.LiveObjectCount:=FLocalObjects.Length;
|
Result.LiveObjectCount:=FLocalObjects.Length;
|
||||||
Result.GlobalObjectCount:=FGlobalObjects.Length;
|
Result.GlobalObjectCount:=FGlobalObjects.Length;
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user