Skip to content

Commit 4097d94

Browse files
committed
memory.exec added
1 parent 013469f commit 4097d94

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

Plugins/UnrealJS/Source/V8/Private/JavascriptIsolate_Private.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -827,9 +827,32 @@ class FJavascriptIsolateImplementation : public FJavascriptIsolate
827827
I.Throw(TEXT("memory.fork requires JavascriptMemoryObject"));
828828
});
829829

830+
add_fn("exec", [](const FunctionCallbackInfo<Value>& info)
831+
{
832+
FIsolateHelper I(info.GetIsolate());
833+
834+
if (info.Length() == 2 && info[0]->IsArrayBuffer() && info[1]->IsFunction())
835+
{
836+
auto arr = info[0].As<ArrayBuffer>();
837+
auto function = info[1].As<Function>();
838+
839+
GCurrentContents = arr->Externalize();
840+
function->Call(info.This(), 0, nullptr);
841+
arr->Neuter();
842+
GCurrentContents = v8::ArrayBuffer::Contents();
843+
}
844+
else
845+
{
846+
GCurrentContents = v8::ArrayBuffer::Contents();
847+
}
848+
849+
info.GetReturnValue().Set(info.Holder());
850+
});
851+
830852
// memory.bind
831853
add_fn("bind", [](const FunctionCallbackInfo<Value>& info)
832854
{
855+
UE_LOG(Javascript, Warning, TEXT("memory.bind is deprecated. use memory.exec(ab,fn) instead."));
833856
FIsolateHelper I(info.GetIsolate());
834857

835858
if (info.Length() == 1 && info[0]->IsArrayBuffer())

0 commit comments

Comments
 (0)