Skip to content

Commit b933b55

Browse files
authored
Support passing null property descriptor to SetPropertyIgnoringNamedGetter. (#579)
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
1 parent f9e8942 commit b933b55

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

mozjs-sys/src/jsapi.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -295,15 +295,14 @@ bool JS_GetUCPropertyDescriptor(JSContext* cx, JS::HandleObject obj,
295295
return result;
296296
}
297297

298-
bool SetPropertyIgnoringNamedGetter(JSContext* cx, JS::HandleObject obj,
299-
JS::HandleId id, JS::HandleValue v,
300-
JS::HandleValue receiver,
301-
JS::Handle<JS::PropertyDescriptor> ownDesc,
302-
JS::ObjectOpResult& result) {
298+
bool SetPropertyIgnoringNamedGetter(
299+
JSContext* cx, JS::HandleObject obj, JS::HandleId id, JS::HandleValue v,
300+
JS::HandleValue receiver, const JS::Handle<JS::PropertyDescriptor>* ownDesc,
301+
JS::ObjectOpResult& result) {
303302
return js::SetPropertyIgnoringNamedGetter(
304303
cx, obj, id, v, receiver,
305304
JS::Rooted<mozilla::Maybe<JS::PropertyDescriptor>>(
306-
cx, mozilla::ToMaybe(&ownDesc)),
305+
cx, mozilla::ToMaybe(ownDesc)),
307306
result);
308307
}
309308

mozjs/src/jsapi_wrappers.in.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,6 @@ wrap!(jsapi: pub fn JS_GetOwnPropertyDescriptor(cx: *mut JSContext, obj: HandleO
358358
wrap!(jsapi: pub fn JS_GetOwnUCPropertyDescriptor(cx: *mut JSContext, obj: HandleObject, name: *const u16, namelen: usize, desc: MutableHandle<PropertyDescriptor>, isNone: *mut bool) -> bool);
359359
wrap!(jsapi: pub fn JS_GetPropertyDescriptorById(cx: *mut JSContext, obj: HandleObject, id: HandleId, desc: MutableHandle<PropertyDescriptor>, holder: MutableHandleObject, isNone: *mut bool) -> bool);
360360
wrap!(jsapi: pub fn JS_GetUCPropertyDescriptor(cx: *mut JSContext, obj: HandleObject, name: *const u16, namelen: usize, desc: MutableHandle<PropertyDescriptor>, holder: MutableHandleObject, isNone: *mut bool) -> bool);
361-
wrap!(jsapi: pub fn SetPropertyIgnoringNamedGetter(cx: *mut JSContext, obj: HandleObject, id: HandleId, v: HandleValue, receiver: HandleValue, ownDesc: Handle<PropertyDescriptor>, result: *mut ObjectOpResult) -> bool);
361+
wrap!(jsapi: pub fn SetPropertyIgnoringNamedGetter(cx: *mut JSContext, obj: HandleObject, id: HandleId, v: HandleValue, receiver: HandleValue, ownDesc: *const Handle<PropertyDescriptor>, result: *mut ObjectOpResult) -> bool);
362362
wrap!(jsapi: pub fn CreateError(cx: *mut JSContext, type_: JSExnType, stack: HandleObject, fileName: HandleString, lineNumber: u32, columnNumber: u32, report: *mut JSErrorReport, message: HandleString, cause: HandleValue, rval: MutableHandleValue) -> bool);
363363
wrap!(jsapi: pub fn GetExceptionCause(exc: *mut JSObject, dest: MutableHandleValue));

mozjs/src/rust.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1072,6 +1072,9 @@ pub mod wrappers {
10721072
// @inner (input args) <> (accumulator) <> unparsed tokens
10731073
// when `unparsed tokens == \eps`, accumulator contains the final result
10741074

1075+
(@inner $saved:tt <> ($($acc:expr,)*) <> $arg:ident: *const Handle<$gentype:ty>, $($rest:tt)*) => {
1076+
wrap!(@inner $saved <> ($($acc,)* if $arg.is_null() { std::ptr::null() } else { &(*$arg).into() },) <> $($rest)*);
1077+
};
10751078
(@inner $saved:tt <> ($($acc:expr,)*) <> $arg:ident: Handle<$gentype:ty>, $($rest:tt)*) => {
10761079
wrap!(@inner $saved <> ($($acc,)* $arg.into(),) <> $($rest)*);
10771080
};

0 commit comments

Comments
 (0)