Skip to content

Commit 5a30360

Browse files
committed
Bug 2017797 - Part 2: Don't require bindings header for IS_INSTANCE_OF, r=smaug
The implementaion of IS_INSTANCE_OF previously specified the true native type T to UnwrapObjectInternal. This is unnecessary, as it is not part of the actual "IsInstanceOf" check, and is only used for a static cast (which is then discarded). This patch changes the passed-in type to be `void`. This change should have no runtime effect (the value was assigned into a void* immediately anyways), but avoids requiring callers which use IS_INSTANCE_OF to import the relevant bindings headers. Differential Revision: https://phabricator.services.mozilla.com/D284522
1 parent 5682b06 commit 5a30360

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

dom/bindings/BindingUtils.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -172,10 +172,8 @@ inline bool IsDOMObject(JSObject* obj) { return IsDOMClass(JS::GetClass(obj)); }
172172
obj, value, cx)
173173

174174
// Test whether the given object is an instance of the given interface.
175-
#define IS_INSTANCE_OF(Interface, obj) \
176-
mozilla::dom::IsInstanceOf<mozilla::dom::prototypes::id::Interface, \
177-
mozilla::dom::Interface##_Binding::NativeType>( \
178-
obj)
175+
#define IS_INSTANCE_OF(Interface, obj) \
176+
mozilla::dom::IsInstanceOf<mozilla::dom::prototypes::id::Interface>(obj)
179177

180178
// Unwrap the given non-wrapper object. This can be used with any obj that
181179
// converts to JSObject*; as long as that JSObject* is live the return value
@@ -422,11 +420,11 @@ MOZ_ALWAYS_INLINE nsresult UnwrapObjectWithCrossOriginAsserts(V&& obj,
422420
}
423421
} // namespace binding_detail
424422

425-
template <prototypes::ID PrototypeID, class T>
423+
template <prototypes::ID PrototypeID>
426424
MOZ_ALWAYS_INLINE bool IsInstanceOf(JSObject* obj) {
427425
AssertStaticUnwrapOK<PrototypeID>();
428426
void* ignored;
429-
nsresult unwrapped = binding_detail::UnwrapObjectInternal<T, true>(
427+
nsresult unwrapped = binding_detail::UnwrapObjectInternal<void, true>(
430428
obj, ignored, PrototypeID, PrototypeTraits<PrototypeID>::Depth, nullptr);
431429
return NS_SUCCEEDED(unwrapped);
432430
}

0 commit comments

Comments
 (0)