Skip to content

Commit a080069

Browse files
authored
Merge pull request #5597 from cloudflare/jasnell/simplify-some-wrapper-mixins
2 parents 4de51a6 + cf7fc3c commit a080069

File tree

4 files changed

+12
-24
lines changed

4 files changed

+12
-24
lines changed

src/workerd/jsg/buffersource.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,6 @@ class BufferSource {
462462
};
463463

464464
// TypeWrapper implementation for the BufferSource type.
465-
template <typename TypeWrapper>
466465
class BufferSourceWrapper {
467466
public:
468467
static constexpr const char* getName(BufferSource*) {

src/workerd/jsg/jsg.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1545,7 +1545,6 @@ class Name final {
15451545

15461546
kj::OneOf<kj::StringPtr, v8::Local<v8::Symbol>> getUnwrapped(v8::Isolate* isolate);
15471547

1548-
template <typename TypeWrapper>
15491548
friend class NameWrapper;
15501549

15511550
void visitForGc(GcVisitor& visitor);

src/workerd/jsg/type-wrapper.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ template <typename Self, typename... T>
386386
class TypeWrapper: public DynamicResourceTypeMap<Self>,
387387
public TypeWrapperBase<Self, T>...,
388388
public PrimitiveWrapper,
389-
public NameWrapper<Self>,
389+
public NameWrapper,
390390
public StringWrapper,
391391
public OptionalWrapper<Self>,
392392
public LenientOptionalWrapper<Self>,
@@ -396,16 +396,16 @@ class TypeWrapper: public DynamicResourceTypeMap<Self>,
396396
public SetWrapper<Self>,
397397
public SequenceWrapper<Self>,
398398
public GeneratorWrapper<Self>,
399-
public ArrayBufferWrapper<Self>,
399+
public ArrayBufferWrapper,
400400
public DictWrapper<Self>,
401-
public DateWrapper<Self>,
402-
public BufferSourceWrapper<Self>,
401+
public DateWrapper,
402+
public BufferSourceWrapper,
403403
public FunctionWrapper<Self>,
404404
public PromiseWrapper<Self>,
405405
public NonCoercibleWrapper<Self>,
406406
public MemoizedIdentityWrapper<Self>,
407407
public IdentifiedWrapper<Self>,
408-
public SelfRefWrapper<Self>,
408+
public SelfRefWrapper,
409409
public ExceptionWrapper<Self>,
410410
public ObjectWrapper<Self>,
411411
public V8HandleWrapper,
@@ -451,7 +451,7 @@ class TypeWrapper: public DynamicResourceTypeMap<Self>,
451451
using Name::tryUnwrap
452452

453453
USING_WRAPPER(PrimitiveWrapper);
454-
USING_WRAPPER(NameWrapper<Self>);
454+
USING_WRAPPER(NameWrapper);
455455
USING_WRAPPER(StringWrapper);
456456
USING_WRAPPER(OptionalWrapper<Self>);
457457
USING_WRAPPER(LenientOptionalWrapper<Self>);
@@ -461,16 +461,16 @@ class TypeWrapper: public DynamicResourceTypeMap<Self>,
461461
USING_WRAPPER(SetWrapper<Self>);
462462
USING_WRAPPER(SequenceWrapper<Self>);
463463
USING_WRAPPER(GeneratorWrapper<Self>);
464-
USING_WRAPPER(ArrayBufferWrapper<Self>);
464+
USING_WRAPPER(ArrayBufferWrapper);
465465
USING_WRAPPER(DictWrapper<Self>);
466-
USING_WRAPPER(DateWrapper<Self>);
467-
USING_WRAPPER(BufferSourceWrapper<Self>);
466+
USING_WRAPPER(DateWrapper);
467+
USING_WRAPPER(BufferSourceWrapper);
468468
USING_WRAPPER(FunctionWrapper<Self>);
469469
USING_WRAPPER(PromiseWrapper<Self>);
470470
USING_WRAPPER(NonCoercibleWrapper<Self>);
471471
USING_WRAPPER(MemoizedIdentityWrapper<Self>);
472472
USING_WRAPPER(IdentifiedWrapper<Self>);
473-
USING_WRAPPER(SelfRefWrapper<Self>);
473+
USING_WRAPPER(SelfRefWrapper);
474474
USING_WRAPPER(ExceptionWrapper<Self>);
475475
USING_WRAPPER(ObjectWrapper<Self>);
476476
USING_WRAPPER(V8HandleWrapper);

src/workerd/jsg/value.h

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,6 @@ class PrimitiveWrapper {
401401

402402
// =======================================================================================
403403
// Name
404-
template <typename TypeWrapper>
405404
class NameWrapper {
406405
public:
407406
static constexpr const char* getName(Name*) {
@@ -414,8 +413,7 @@ class NameWrapper {
414413
Name value) {
415414
KJ_SWITCH_ONEOF(value.getUnwrapped(js.v8Isolate)) {
416415
KJ_CASE_ONEOF(string, kj::StringPtr) {
417-
auto& wrapper = static_cast<TypeWrapper&>(*this);
418-
return wrapper.wrap(js.v8Isolate, creator, kj::str(string));
416+
return js.str(string);
419417
}
420418
KJ_CASE_ONEOF(symbol, v8::Local<v8::Symbol>) {
421419
return symbol;
@@ -435,12 +433,7 @@ class NameWrapper {
435433

436434
// Since most things are coercible to a string, this ought to catch pretty much
437435
// any value other than symbol
438-
auto& wrapper = static_cast<TypeWrapper&>(*this);
439-
KJ_IF_SOME(string, wrapper.tryUnwrap(js, context, handle, (kj::String*)nullptr, parentObject)) {
440-
return Name(kj::mv(string));
441-
}
442-
443-
return kj::none;
436+
return Name(js.toString(handle));
444437
}
445438
};
446439

@@ -1000,7 +993,6 @@ class SetWrapper {
1000993
// - use `jsg::asBytes()` as a quick way to get a `kj::ArrayPtr<kj::byte>` view onto it.
1001994
//
1002995
// 3. If a method returns an ArrayBuffer, create and return a `kj::Array<kj::byte>`.
1003-
template <typename TypeWrapper>
1004996
class ArrayBufferWrapper {
1005997
public:
1006998
static constexpr const char* getName(kj::ArrayPtr<byte>*) {
@@ -1183,7 +1175,6 @@ class DictWrapper {
11831175
// =======================================================================================
11841176
// Dates
11851177

1186-
template <typename TypeWrapper>
11871178
class DateWrapper {
11881179
public:
11891180
static constexpr const char* getName(kj::Date*) {
@@ -1383,7 +1374,6 @@ class IdentifiedWrapper {
13831374
// =======================================================================================
13841375
// SelfRef
13851376

1386-
template <typename TypeWrapper>
13871377
class SelfRefWrapper {
13881378
public:
13891379
static auto getName(SelfRef*) {

0 commit comments

Comments
 (0)