Skip to content

Commit 7c6df77

Browse files
elliotttJakeChampion
authored andcommitted
Move URL related namespaces out of js-compute-builtins.cpp
1 parent 3ddd2c5 commit 7c6df77

File tree

6 files changed

+900
-800
lines changed

6 files changed

+900
-800
lines changed

c-dependencies/js-compute-runtime/builtin.h

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@
3030
}
3131

3232
#define CLASS_BOILERPLATE_CUSTOM_INIT(cls) \
33-
static constexpr const JSClassOps class_ops = {}; \
34-
static const uint32_t class_flags = 0; \
33+
constexpr const JSClassOps class_ops = {}; \
34+
const uint32_t class_flags = 0; \
3535
\
3636
const JSClass class_ = {#cls, JSCLASS_HAS_RESERVED_SLOTS(Slots::Count) | class_flags, \
3737
&class_ops}; \
38-
static JS::PersistentRooted<JSObject *> proto_obj; \
38+
JS::PersistentRooted<JSObject *> proto_obj; \
3939
\
4040
bool is_instance(JSObject *obj) { return !!obj && JS::GetClass(obj) == &class_; } \
4141
\
@@ -123,6 +123,15 @@
123123
return false; \
124124
}
125125

126+
inline bool ThrowIfNotConstructing(JSContext *cx, const JS::CallArgs &args,
127+
const char *builtinName) {
128+
if (args.isConstructing()) {
129+
return true;
130+
}
131+
132+
JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_BUILTIN_CTOR_NO_NEW, builtinName);
133+
return false;
134+
}
126135
namespace builtins {
127136

128137
template <typename Impl> class BuiltinImpl {

0 commit comments

Comments
 (0)