Skip to content

Commit e2bb2ee

Browse files
Jake ChampionJakeChampion
authored andcommitted
chore: add ability to have static methods and properties on built-ins
1 parent 1da7ec9 commit e2bb2ee

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+298
-14
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ template <typename Impl> class BuiltinImpl {
186186
JS::HandleObject parent_proto = nullptr) {
187187
proto_obj.init(cx, JS_InitClass(cx, global, &class_, parent_proto, Impl::class_name,
188188
Impl::constructor, Impl::ctor_length, Impl::properties,
189-
Impl::methods, nullptr, nullptr));
189+
Impl::methods, Impl::static_properties, Impl::static_methods));
190190

191191
return proto_obj != nullptr;
192192
}

c-dependencies/js-compute-runtime/builtins/backend.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -832,6 +832,14 @@ bool Backend::toString(JSContext *cx, unsigned argc, JS::Value *vp) {
832832
return true;
833833
}
834834

835+
const JSFunctionSpec Backend::static_methods[] = {
836+
JS_FS_END,
837+
};
838+
839+
const JSPropertySpec Backend::static_properties[] = {
840+
JS_PS_END,
841+
};
842+
835843
const JSFunctionSpec Backend::methods[] = {JS_FN("toString", toString, 0, JSPROP_ENUMERATE),
836844
JS_FS_END};
837845

c-dependencies/js-compute-runtime/builtins/backend.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ class Backend : public BuiltinImpl<Backend> {
2828
Count
2929
};
3030

31+
static const JSFunctionSpec static_methods[];
32+
static const JSPropertySpec static_properties[];
33+
3134
static const JSFunctionSpec methods[];
3235
static const JSPropertySpec properties[];
3336

c-dependencies/js-compute-runtime/builtins/cache-override.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,8 @@ bool CacheOverride::accessor_set(JSContext *cx, unsigned argc, JS::Value *vp) {
304304
return accessor_fn(cx, self, args[0], args.rval());
305305
}
306306

307+
const JSFunctionSpec CacheOverride::static_methods[] = {JS_FS_END};
308+
const JSPropertySpec CacheOverride::static_properties[] = {JS_PS_END};
307309
const JSFunctionSpec CacheOverride::methods[] = {JS_FS_END};
308310

309311
const JSPropertySpec CacheOverride::properties[] = {

c-dependencies/js-compute-runtime/builtins/cache-override.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ class CacheOverride : public BuiltinImpl<CacheOverride> {
3030

3131
enum class CacheOverrideMode { None, Pass, Override };
3232

33+
static const JSFunctionSpec static_methods[];
34+
static const JSPropertySpec static_properties[];
3335
static const JSFunctionSpec methods[];
3436
static const JSPropertySpec properties[];
3537
static uint8_t abi_tag(JSObject *self);

c-dependencies/js-compute-runtime/builtins/client-info.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,14 @@ bool ClientInfo::geo_get(JSContext *cx, unsigned argc, JS::Value *vp) {
112112
return JS_ParseJSON(cx, geo_info_str, args.rval());
113113
}
114114

115+
const JSFunctionSpec ClientInfo::static_methods[] = {
116+
JS_FS_END,
117+
};
118+
119+
const JSPropertySpec ClientInfo::static_properties[] = {
120+
JS_PS_END,
121+
};
122+
115123
const JSFunctionSpec ClientInfo::methods[] = {
116124
JS_FS_END,
117125
};

c-dependencies/js-compute-runtime/builtins/client-info.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ class ClientInfo final : public BuiltinNoConstructor<ClientInfo> {
1717
GeoInfo,
1818
Count,
1919
};
20-
20+
static const JSFunctionSpec static_methods[];
21+
static const JSPropertySpec static_properties[];
2122
static const JSFunctionSpec methods[];
2223
static const JSPropertySpec properties[];
2324

c-dependencies/js-compute-runtime/builtins/compression-stream.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,14 @@ bool CompressionStream::writable_get(JSContext *cx, unsigned argc, JS::Value *vp
194194
return true;
195195
}
196196

197+
const JSFunctionSpec CompressionStream::static_methods[] = {
198+
JS_FS_END,
199+
};
200+
201+
const JSPropertySpec CompressionStream::static_properties[] = {
202+
JS_PS_END,
203+
};
204+
197205
const JSFunctionSpec CompressionStream::methods[] = {
198206
JS_FS_END,
199207
};

c-dependencies/js-compute-runtime/builtins/compression-stream.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ class CompressionStream : public BuiltinImpl<CompressionStream> {
2323

2424
enum Slots { Transform, Format, State, Buffer, Count };
2525

26+
static const JSFunctionSpec static_methods[];
27+
static const JSPropertySpec static_properties[];
2628
static const JSFunctionSpec methods[];
2729
static const JSPropertySpec properties[];
2830

c-dependencies/js-compute-runtime/builtins/config-store.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,14 @@ bool ConfigStore::get(JSContext *cx, unsigned argc, JS::Value *vp) {
5050
return true;
5151
}
5252

53+
const JSFunctionSpec ConfigStore::static_methods[] = {
54+
JS_FS_END,
55+
};
56+
57+
const JSPropertySpec ConfigStore::static_properties[] = {
58+
JS_PS_END,
59+
};
60+
5361
const JSFunctionSpec ConfigStore::methods[] = {JS_FN("get", get, 1, JSPROP_ENUMERATE), JS_FS_END};
5462

5563
const JSPropertySpec ConfigStore::properties[] = {JS_PS_END};

0 commit comments

Comments
 (0)