-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a mechanism for testing whether feature is present #30
Comments
We already think to add this kind of support and I need to think more about that. The canisue json file seems very helpful for that. |
Ooer - that does sound like an interesting idea. One thing I have been contemplating lately is somehow injecting other sources of metadata into the generation pipeline. In particular I was thinking about ways of how we could read WebIDL and use that to enhance or replace the externs used as input to Elemental2. The advantage of that is that we could read WebIDL from either specs, Chrome and/of Firefox and generate a relatively maintenance free, accurate API for interacting with the browsers. There would still be some work due to differences between browsers (i.e. Chromes This would mean that we could throw away Anyhoo - something to consider when thinking about this. I don't know if the above is feasible with current architecture and I am not yet at work to eyeball the code. But I guess what I am asking that if you were to add plugins that could run at various stages. I would love to be able to write a plugin that ran on the MetaData model AST as well as plugins that ran on the Java model ;) |
jsinterop generator could generate the support calls while externally it could be provided by elemental2 for which APIs to generate it for. Being said that, in jsinterop-base we can probably just add the nestedHas utility (in analogy to nestedGet) so you can do
and elemental2 will put a nicer looking helper on
I think this will be good enough. |
The initial version of the jsinterop-generator was using WebIDL as input instead of extern files and we gave up.
The initial version of integer_entities.txt has been generated from WebIdl. We could do the same with name_mappings.txt
But then you are starting to generate code for them. With J2CL + closure-compiler, after compilation you don't have specific code for accessing the constant (other than the referring directly to the name of the constant). |
...snip...
That is certainly a better place than where we are now and would probably work in most cases. |
Interesting.
Interesting. I had not though about this for browser APIs. Handling
Yes - you would need to use a custom env and bring in the right externs but this I don't see as too much of an issue ... at least external to google. Part of the reason I was contemplating WebIDL was because it is taking a lot of effort to get closures externs to match the spec. Not so much because writing the code is hard but because I suspect a lot of google internal code relies on the existing definitions ;)
Yep. Or just use a process like read from closure externs first, then WebIDL second and thrdly use overrides if no other case covered.
I am not sure I understand. What I want to do (and what we have patched the tool to do locally) is to represent |
Sometimes a particular property/operator is only available on some browsers. The generator will generate the field/methods regardless and the downstream consumer is left to try and feature detect in some other way. The simplest approach may be to just generate a
@JsOverlay boolean supportsMyFeature()
method that will allow caller to detect whether a feature is supported.It would be too costly to generate
supports*()
methods for every feature so maybe the generator could load the canisue database and only generatesupports*()
methods if they are not supported compared to a particular base line (IE11?).See also #29 because these features could be combined and driven by the same data.
The text was updated successfully, but these errors were encountered: