-
-
Notifications
You must be signed in to change notification settings - Fork 39
Expand file tree
/
Copy pathWeakRef.cpp
More file actions
32 lines (25 loc) · 1009 Bytes
/
WeakRef.cpp
File metadata and controls
32 lines (25 loc) · 1009 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include "WeakRef.h"
#include "Helpers.h"
using namespace v8;
namespace tns {
void WeakRef::Init(Local<Context> context) {
Isolate* isolate = context->GetIsolate();
std::string source = R"(
global.WeakRef.prototype.get = global.WeakRef.prototype.deref;
global.WeakRef.prototype.__hasWarnedAboutClear = false;
global.WeakRef.prototype.clear = () => {
if(global.WeakRef.prototype.__hasWarnedAboutClear) {
return;
}
global.WeakRef.prototype.__hasWarnedAboutClear = true;
console.warn('WeakRef.clear() is non-standard and has been deprecated. It does nothing and the call can be safely removed.');
}
)";
Local<Script> script;
bool success = Script::Compile(context, tns::ToV8String(isolate, source)).ToLocal(&script);
tns::Assert(success && !script.IsEmpty(), isolate);
Local<Value> result;
success = script->Run(context).ToLocal(&result);
tns::Assert(success, isolate);
}
}