1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 18:27:35 +00:00

LibWeb+LibJS: Add a naive way to check if a wrapper "is" a certain type

Instead of only checking the class_name(), we now generate an is_foo()
virtual in the wrapper generator. (It's currently something we override
on Bindings::Wrapper, which is not really scalable.)

Longer term we'll need to think up something smarter for verifying that
one wrapper "is" another type of wrapper.
This commit is contained in:
Andreas Kling 2020-06-20 22:19:29 +02:00
parent 1ffffa0053
commit 94fdf4fa5a
3 changed files with 19 additions and 4 deletions

View file

@ -37,11 +37,17 @@ namespace Bindings {
class Wrapper
: public JS::Object
, public Weakable<Wrapper> {
public:
virtual bool is_node_wrapper() const { return false; }
virtual bool is_document_wrapper() const { return false; }
protected:
explicit Wrapper(Object& prototype)
: Object(&prototype)
{
}
virtual bool is_web_wrapper() const final { return true; }
};
}