stefan-hoeck / idris2-webidl

Parsers and (eventually) Idris code generator for WebIDL documents
BSD 2-Clause "Simplified" License
13 stars 3 forks source link

[ WIP ] idris2-webidl: A Generator for Idris2 Web Bindings

Parsers and (eventually) Idris code generator for WebIDL documents

Progress

Codegen Notes

Transferring WebIDL types to Idris2 types

WebIDL types can be found in module Text.WebIDL.Types.Type. Here is an summary about how these types are being mapped to Idris2 types by the code generator. Eventually, the list below will also give additional information about functionality required from these bindings, but in a first step

Inheritance and Mixins

WebIDL specifies inheritance relations for interfaces and dictionaries. The code generator generates implementations for a JSType interface, listing a type's parent types and included mixins. The API supports then safe upcasting from a type to one of its parent types or mixins.

Downcasting is trickier, as it requires a way to inspect the type of a value at runtime. The web API should provide a SafeCast interface for types, which can be checked at runtime. This includes all Idris2 primitives, the external numeric types, String, Object, Symbol, Undefine, Boolean, and all interfaces and dictionary types, whose type can be inspected by traversing a value's prototype chain.