Skip to content

Commit

Permalink
Add jsg::Lock taking variant of tryGetHandle (#978)
Browse files Browse the repository at this point in the history
  • Loading branch information
jasnell authored Aug 7, 2023
1 parent 0b045d4 commit abea481
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/workerd/jsg/jsg.h
Original file line number Diff line number Diff line change
Expand Up @@ -1076,6 +1076,8 @@ class Ref {
return inner->tryGetHandle(isolate);
}

kj::Maybe<v8::Local<v8::Object>> tryGetHandle(Lock& js);

void attachWrapper(v8::Isolate* isolate, v8::Local<v8::Object> object) {
// Attach a JavaScript object which implements the JS interface for this C++ object. Normally,
// this happens automatically the first time the Ref is passed across the FFI barrier into JS.
Expand Down Expand Up @@ -2115,6 +2117,11 @@ inline Data Data::addRef(jsg::Lock& js) {
return Data(js.v8Isolate, getHandle(js.v8Isolate));
}

template <typename T>
kj::Maybe<v8::Local<v8::Object>> Ref<T>::tryGetHandle(Lock& js) {
return tryGetHandle(js.v8Isolate);
}

template <typename T>
inline V8Ref<T> V8Ref<T>::addRef(jsg::Lock& js) {
return js.v8Ref(getHandle(js.v8Isolate));
Expand Down

0 comments on commit abea481

Please sign in to comment.