Skip to content

Commit 131e16f

Browse files
authored
Merge pull request #1714 from cloudflare/revert-1700-revert-1607-ggu/to-string-builtin-objects
Revert "Revert "Add toStringTag value on JSG resource types""
2 parents 2649b4a + 6aaf19a commit 131e16f

File tree

3 files changed

+5
-1
lines changed

3 files changed

+5
-1
lines changed

Diff for: src/workerd/jsg/jsg.h

+1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ namespace workerd::jsg {
4747
::workerd::jsg::JsgKind::RESOURCE; \
4848
using jsgSuper = jsgThis; \
4949
using jsgThis = Type; \
50+
static inline kj::StringPtr jsgGetName() { return #Type##_kjc; } \
5051
inline kj::StringPtr jsgGetMemoryName() const override { return #Type##_kjc; } \
5152
inline size_t jsgGetMemorySelfSize() const override { return sizeof(Type); } \
5253
inline void jsgGetMemoryInfo(jsg::MemoryTracker& tracker) const override { \

Diff for: src/workerd/jsg/resource.h

+3
Original file line numberDiff line numberDiff line change
@@ -712,6 +712,9 @@ struct ResourceTypeBuilder {
712712
inspectProperties = v8::ObjectTemplate::New(isolate);
713713
prototype->Set(symbol, inspectProperties, static_cast<v8::PropertyAttribute>(
714714
v8::PropertyAttribute::ReadOnly | v8::PropertyAttribute::DontEnum));
715+
716+
auto toStringTagSymbol = v8::Symbol::GetToStringTag(isolate);
717+
prototype->Set(toStringTagSymbol, v8StrIntern(isolate, Self::jsgGetName()), v8::PropertyAttribute::None);
715718
}
716719

717720
template <typename Type, typename GetNamedMethod, GetNamedMethod getNamedMethod>

Diff for: src/workerd/jsg/wrappable.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ class Wrappable: public kj::Refcounted {
118118
virtual void jsgVisitForGc(GcVisitor& visitor);
119119

120120
virtual kj::StringPtr jsgGetMemoryName() const {
121-
KJ_UNIMPLEMENTED("jsgGetTypeName is not implemented. "
121+
KJ_UNIMPLEMENTED("jsgGetMemoryName is not implemented. "
122122
"It must be overridden by subclasses");
123123
}
124124

0 commit comments

Comments
 (0)