Skip to content

Latest commit

History

History
31 lines (22 loc) 路 1.6 KB

AddNewIDLFile.md

File metadata and controls

31 lines (22 loc) 路 1.6 KB

Adding a new IDL file

Serenity's build system does a lot of work of turning the IDL from a Web spec into code, but there are a few things you'll need to do yourself.

For the sake of example, let's say you're wanting to add the HTMLDetailsElement.

  1. Create LibWeb/HTML/HTMLDetailsElement.idl with the contents of the IDL section of the spec. In this case, that would be:
[Exposed=Window]
interface HTMLDetailsElement : HTMLElement {
    [HTMLConstructor] constructor();

    [CEReactions] attribute boolean open;
};
  1. If the IDL starts with [Exposed=Window], remove that line from the .idl file, and add the following to LibWeb/Bindings/WindowObjectHelper.h:

    • #include <LibWeb/Bindings/HTMLDetailsElementConstructor.h> and
    • #include <LibWeb/Bindings/HTMLDetailsElementPrototype.h> to the includes list.
    • ADD_WINDOW_OBJECT_INTERFACE(HTMLDetailsElement) \ to the macro at the bottom.
  2. Add a libweb_js_wrapper() call to LibWeb/CMakeLists.txt

  3. Forward declare the generated classes in LibWeb/Forward.h:

    • HTMLDetailsElement in its namespace.
    • HTMLDetailsElementWrapper in the Web::Bindings namespace.
  4. If your interface is an Event type: