Serenity Operating System
at master 32 lines 1.4 kB view raw view rendered
1# Adding a new IDL file 2 3Serenity'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. 4 5For the sake of example, let's say you're wanting to add the `HTMLDetailsElement`. 6 71. Create `LibWeb/HTML/HTMLDetailsElement.idl` with the contents of the IDL section of the spec. In this case, that would be: 8```webidl 9[Exposed=Window] 10interface HTMLDetailsElement : HTMLElement { 11 [HTMLConstructor] constructor(); 12 13 [CEReactions] attribute boolean open; 14}; 15``` 16 172. If the IDL refers to other IDL types, you need to import those. For example, `CSSRule` has an attribute that returns a `CSSStyleSheet`, so that needs to be imported: 18```webidl 19#import <CSS/CSSStyleSheet.idl> 20 21interface CSSRule { 22 readonly attribute CSSStyleSheet? parentStyleSheet; 23}; 24``` 25 263. Add a `libweb_js_bindings(HTML/HTMLDetailsElement)` call to [`LibWeb/idl_files.cmake`](../../Userland/Libraries/LibWeb/idl_files.cmake) 27 284. Forward declare the generated class in [`LibWeb/Forward.h`](../../Userland/Libraries/LibWeb/Forward.h): 29 - `HTMLDetailsElement` in its namespace. 30 315. If your type isn't an Event or Element, you will need to add it to [`is_platform_object()`](../../Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp) 32 so that it can be accepted as an IDL parameter, attribute or return type.