diff --git a/build.rs b/build.rs index caf4e3c9bd..d50604b467 100644 --- a/build.rs +++ b/build.rs @@ -158,6 +158,7 @@ fn build_binding() { .allowlist_item("v8__.*") .allowlist_item("cppgc__.*") .allowlist_item("RustObj") + .allowlist_item("ExternalConstOneByteStringResource") .generate() .expect("Unable to generate bindings"); diff --git a/src/binding.cc b/src/binding.cc index 8eac7309ea..394ae71d2a 100644 --- a/src/binding.cc +++ b/src/binding.cc @@ -1124,31 +1124,6 @@ class ExternalStaticOneByteStringResource const int _length; }; -// NOTE: This class is never used and only serves as a reference for -// the OneByteConst struct created on Rust-side. -class ExternalConstOneByteStringResource - : public v8::String::ExternalOneByteStringResource { - public: - ExternalConstOneByteStringResource(int length) : _length(length) { - static_assert(offsetof(ExternalConstOneByteStringResource, _length) == - sizeof(size_t) * 2, - "ExternalConstOneByteStringResource's length was not at " - "offset of sizeof(size_t) * 2"); - static_assert( - sizeof(ExternalConstOneByteStringResource) == sizeof(size_t) * 3, - "ExternalConstOneByteStringResource size was not sizeof(size_t) * 3"); - static_assert( - alignof(ExternalConstOneByteStringResource) == sizeof(size_t), - "ExternalConstOneByteStringResource align was not sizeof(size_t)"); - } - const char* data() const override { return nullptr; } - size_t length() const override { return _length; } - void Dispose() override {} - - private: - const int _length; -}; - const v8::String* v8__String__NewExternalOneByteConst( v8::Isolate* isolate, v8::String::ExternalOneByteStringResource* resource) { return maybe_local_to_ptr(v8::String::NewExternalOneByte(isolate, resource)); diff --git a/src/binding.hpp b/src/binding.hpp index 2f27a6ed59..59f5c1acda 100644 --- a/src/binding.hpp +++ b/src/binding.hpp @@ -42,3 +42,28 @@ static uint32_t v8__MINOR_VERSION = V8_MINOR_VERSION; static uint32_t v8__BUILD_NUMBER = V8_BUILD_NUMBER; static uint32_t v8__PATCH_LEVEL = V8_PATCH_LEVEL; static const char* v8__VERSION_STRING = V8_VERSION_STRING; + +// NOTE: This class is never used and only serves as a reference for +// the OneByteConst struct created on Rust-side. +class ExternalConstOneByteStringResource + : public v8::String::ExternalOneByteStringResource { + public: + ExternalConstOneByteStringResource(int length) : _length(length) { + static_assert(offsetof(ExternalConstOneByteStringResource, _length) == + sizeof(size_t) * 2, + "ExternalConstOneByteStringResource's length was not at " + "offset of sizeof(size_t) * 2"); + static_assert( + sizeof(ExternalConstOneByteStringResource) == sizeof(size_t) * 3, + "ExternalConstOneByteStringResource size was not sizeof(size_t) * 3"); + static_assert( + alignof(ExternalConstOneByteStringResource) == sizeof(size_t), + "ExternalConstOneByteStringResource align was not sizeof(size_t)"); + } + const char* data() const override { return nullptr; } + size_t length() const override { return _length; } + void Dispose() override {} + + private: + const int _length; +}; diff --git a/src/string.rs b/src/string.rs index 99d92381c9..db3794e1a3 100644 --- a/src/string.rs +++ b/src/string.rs @@ -246,11 +246,13 @@ extern "C" fn one_byte_const_length(this: *const OneByteConst) -> usize { // SAFETY: Only called from C++ with a valid OneByteConst pointer. unsafe { (*this).length } } +extern "C" fn one_byte_const_unaccount(_isolate: *mut Isolate) {} type OneByteConstNoOp = extern "C" fn(*const OneByteConst); type OneByteConstIsCacheable = extern "C" fn(*const OneByteConst) -> bool; type OneByteConstData = extern "C" fn(*const OneByteConst) -> *const char; type OneByteConstLength = extern "C" fn(*const OneByteConst) -> usize; +type OneByteConstUnaccount = extern "C" fn(*mut Isolate); #[repr(C)] struct OneByteConstVtable { @@ -279,6 +281,7 @@ struct OneByteConstVtable { #[cfg(not(target_family = "windows"))] delete2: OneByteConstNoOp, is_cacheable: OneByteConstIsCacheable, + unaccount: OneByteConstUnaccount, dispose: OneByteConstNoOp, lock: OneByteConstNoOp, unlock: OneByteConstNoOp, @@ -294,6 +297,7 @@ const ONE_BYTE_CONST_VTABLE: OneByteConstVtable = OneByteConstVtable { #[cfg(not(target_family = "windows"))] delete2: one_byte_const_no_op, is_cacheable: one_byte_const_is_cacheable, + unaccount: one_byte_const_unaccount, dispose: one_byte_const_no_op, lock: one_byte_const_no_op, unlock: one_byte_const_no_op,