boa
boa copied to clipboard
Improve `ConstructorBuilder` and `ObjectInitializer`
I tried a V8 attempt on DOM crate this weekend. While it still has lots of different interfaces to work with. I found both engines still share some logic in defining custom types:
- There's ObjectTemplate which is similar to ObjectInitializer.
- There's FunctionTemplate which is similar to ConstructorBuilder.
ECMASCript feature
Sorry, I'm not sure if this is the correct comparison, but FunctionTemplate provides many flexibilities. It can get instance and prototype templates. It can not only get the JS function but also create the instance. While I don't believe we should totally follow its "template" design, I feel like maybe boa can provide methods and trait impls similar to this.
Example code I don't have exact example code, but ideally I think we should provide document example like V8's FunctionTemplate document.