@@ -3899,14 +3899,24 @@ template <auto accessor_fn> bool accessor_set(JSContext *cx, unsigned argc, Valu
3899
3899
3900
3900
const unsigned ctor_length = 1 ;
3901
3901
3902
- JSObject *create (JSContext *cx);
3902
+ const JSFunctionSpec methods[] = {JS_FS_END};
3903
+
3904
+ const JSPropertySpec properties[] = {
3905
+ JS_PSGS (" mode" , accessor_get<mode_get>, accessor_set<mode_set>, JSPROP_ENUMERATE),
3906
+ JS_PSGS (" ttl" , accessor_get<ttl_get>, accessor_set<ttl_set>, JSPROP_ENUMERATE),
3907
+ JS_PSGS (" swr" , accessor_get<swr_get>, accessor_set<swr_set>, JSPROP_ENUMERATE),
3908
+ JS_PSGS (" surrogateKey" , accessor_get<surrogate_key_get>, accessor_set<surrogate_key_set>,
3909
+ JSPROP_ENUMERATE),
3910
+ JS_PSGS (" pci" , accessor_get<pci_get>, accessor_set<pci_set>, JSPROP_ENUMERATE),
3911
+ JS_PS_END};
3912
+
3913
+ bool constructor (JSContext *cx, unsigned argc, Value *vp);
3914
+ CLASS_BOILERPLATE (CacheOverride)
3903
3915
3904
3916
bool constructor (JSContext *cx, unsigned argc, Value *vp) {
3905
3917
CTOR_HEADER (" CacheOverride" , 1 );
3906
3918
3907
- RootedObject self (cx, create (cx));
3908
- if (!self)
3909
- return false ;
3919
+ RootedObject self (cx, JS_NewObjectForConstructor (cx, &class_, args));
3910
3920
3911
3921
RootedValue val (cx);
3912
3922
if (!mode_set (cx, self, args[0 ], &val))
@@ -3943,29 +3953,14 @@ bool constructor(JSContext *cx, unsigned argc, Value *vp) {
3943
3953
return true ;
3944
3954
}
3945
3955
3946
- const JSFunctionSpec methods[] = {JS_FS_END};
3947
-
3948
- const JSPropertySpec properties[] = {
3949
- JS_PSGS (" mode" , accessor_get<mode_get>, accessor_set<mode_set>, JSPROP_ENUMERATE),
3950
- JS_PSGS (" ttl" , accessor_get<ttl_get>, accessor_set<ttl_set>, JSPROP_ENUMERATE),
3951
- JS_PSGS (" swr" , accessor_get<swr_get>, accessor_set<swr_set>, JSPROP_ENUMERATE),
3952
- JS_PSGS (" surrogateKey" , accessor_get<surrogate_key_get>, accessor_set<surrogate_key_set>,
3953
- JSPROP_ENUMERATE),
3954
- JS_PSGS (" pci" , accessor_get<pci_get>, accessor_set<pci_set>, JSPROP_ENUMERATE),
3955
- JS_PS_END};
3956
-
3957
- CLASS_BOILERPLATE (CacheOverride)
3958
-
3959
- JSObject *create (JSContext *cx) { return JS_NewObjectWithGivenProto (cx, &class_, proto_obj); }
3960
-
3961
3956
/* *
3962
3957
* Clone a CacheOverride instance by copying all its reserved slots.
3963
3958
*
3964
3959
* This works because CacheOverride slots only contain primitive values.
3965
3960
*/
3966
3961
JSObject *clone (JSContext *cx, HandleObject self) {
3967
3962
MOZ_ASSERT (is_instance (self));
3968
- RootedObject result (cx, create (cx));
3963
+ RootedObject result (cx, JS_NewObjectWithGivenProto (cx, &class_, proto_obj ));
3969
3964
if (!result) {
3970
3965
return nullptr ;
3971
3966
}
0 commit comments