diff --git a/src/workerd/jsg/jsg.h b/src/workerd/jsg/jsg.h index c0a17b604a5..0cdee03dc98 100644 --- a/src/workerd/jsg/jsg.h +++ b/src/workerd/jsg/jsg.h @@ -794,12 +794,12 @@ class Data { handle(isolate, handle) {} // Get the raw underlying v8 handle. - v8::Local getHandle(v8::Isolate* isolate) { + v8::Local getHandle(v8::Isolate* isolate) const { return handle.Get(isolate); } // Get the raw underlying v8 handle. - v8::Local getHandle(Lock& js); + v8::Local getHandle(Lock& js) const; Data addRef(v8::Isolate* isolate) { return Data(isolate, getHandle(isolate)); @@ -865,7 +865,7 @@ class V8Ref: private Data { } KJ_DISALLOW_COPY(V8Ref); - v8::Local getHandle(v8::Isolate* isolate) { + v8::Local getHandle(v8::Isolate* isolate) const { if constexpr (std::is_base_of()) { // V8 doesn't let us cast directly from v8::Data to subtypes of v8::Value, so we're forced to // use this double cast... Ech. @@ -874,7 +874,7 @@ class V8Ref: private Data { return Data::getHandle(isolate).template As(); } } - v8::Local getHandle(jsg::Lock& js); + v8::Local getHandle(jsg::Lock& js) const; V8Ref addRef(v8::Isolate* isolate) { return V8Ref(isolate, getHandle(isolate)); @@ -1749,10 +1749,10 @@ class JsContext { return object.get(); } - v8::Local getHandle(v8::Isolate* isolate) { + v8::Local getHandle(v8::Isolate* isolate) const { return handle.Get(isolate); } - v8::Local getHandle(Lock& js); + v8::Local getHandle(Lock& js) const; private: v8::Global handle; @@ -2780,16 +2780,16 @@ inline HashableV8Ref HashableV8Ref::addRef(jsg::Lock& js) { } template -inline v8::Local V8Ref::getHandle(jsg::Lock& js) { +inline v8::Local V8Ref::getHandle(jsg::Lock& js) const { return getHandle(js.v8Isolate); } -inline v8::Local Data::getHandle(jsg::Lock& js) { +inline v8::Local Data::getHandle(jsg::Lock& js) const { return getHandle(js.v8Isolate); } template -inline v8::Local JsContext::getHandle(Lock& js) { +inline v8::Local JsContext::getHandle(Lock& js) const { return handle.Get(js.v8Isolate); } diff --git a/src/workerd/jsg/jsvalue.h b/src/workerd/jsg/jsvalue.h index 86185ab2d7e..4391306f92a 100644 --- a/src/workerd/jsg/jsvalue.h +++ b/src/workerd/jsg/jsvalue.h @@ -498,7 +498,7 @@ class JsRef final { JsRef& operator=(JsRef& other) = delete; JsRef& operator=(JsRef&& other) = default; - T getHandle(Lock& js) KJ_WARN_UNUSED_RESULT { + T getHandle(Lock& js) const KJ_WARN_UNUSED_RESULT { JsValue handle(value.getHandle(js)); return KJ_ASSERT_NONNULL(handle.tryCast()); }