File tree Expand file tree Collapse file tree 3 files changed +17
-2
lines changed Expand file tree Collapse file tree 3 files changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -2235,7 +2235,8 @@ class JsMessage;
22352235 V (Set) \
22362236 V (Promise) \
22372237 V (Proxy) \
2238- V (Function)
2238+ V (Function) \
2239+ V (Uint8Array)
22392240
22402241#define V (Name ) class Js ##Name;
22412242JS_TYPE_CLASSES (V)
Original file line number Diff line number Diff line change @@ -44,7 +44,6 @@ inline void requireOnStack(void* self) {
4444 V (ArrayBuffer) \
4545 V (ArrayBufferView) \
4646 V (TypedArray) \
47- V (Uint8Array) \
4847 V (Uint8ClampedArray) \
4948 V (Int8Array) \
5049 V (Uint16Array) \
@@ -230,6 +229,20 @@ class JsArray final: public JsBase<v8::Array, JsArray> {
230229 using JsBase<v8::Array, JsArray>::JsBase;
231230};
232231
232+ class JsUint8Array final : public JsBase<v8::Uint8Array, JsUint8Array> {
233+ public:
234+ template <typename T = kj::byte>
235+ kj::ArrayPtr<T> asArrayPtr () {
236+ v8::Local<v8::Uint8Array> inner = *this ;
237+ auto buf = inner->Buffer ();
238+ T* data = static_cast <T*>(buf->Data ()) + inner->ByteOffset ();
239+ size_t length = inner->ByteLength ();
240+ return kj::ArrayPtr (data, length);
241+ }
242+
243+ using JsBase<v8::Uint8Array, JsUint8Array>::JsBase;
244+ };
245+
233246class JsString final : public JsBase<v8::String, JsString> {
234247 public:
235248 int length (Lock& js) const KJ_WARN_UNUSED_RESULT;
Original file line number Diff line number Diff line change @@ -468,6 +468,7 @@ struct BuildRtti<Configuration, v8::Promise> {
468468 };
469469
470470#define FOR_EACH_BUILTIN_TYPE (F, ...) \
471+ F (jsg::JsUint8Array, BuiltinType::Type::V8_UINT8_ARRAY) \
471472 F(jsg::BufferSource, BuiltinType::Type::JSG_BUFFER_SOURCE) \
472473 F(kj::Date, BuiltinType::Type::KJ_DATE) \
473474 F(v8::ArrayBufferView, BuiltinType::Type::V8_ARRAY_BUFFER_VIEW) \
You can’t perform that action at this time.
0 commit comments