contextfree / winrt-rust

Use and (eventually) make Windows Runtime APIs with Rust
Apache License 2.0
142 stars 10 forks source link

Some special cases are needed for the snake case conversion #65

Closed chris-morgan closed 5 years ago

chris-morgan commented 5 years ago

Specifically I have in mind “JavaScript” as in the IsJavaScriptEnabled property of Windows.Web.UI.WebViewControlSettings, which currently becomes is_java_script_enabled but should rather be is_javascript_enabled, that being idiomatic.

I’m then vaguely guessing that there will be other special cases too. If there is already something in place for special-casing things, then this property should be added to it, and if not then such a capability should be added.

chris-morgan commented 5 years ago

I might as well mention this case here too: a sibling property IsIndexedDBEnabled is rendered incorrectly as is_indexed_dbenabled rather than is_indexed_db_enabled (the straightforward translation) or is_indexeddb_enabled (which I’d mildly prefer, as a special case).

Boddlnagg commented 5 years ago

Thanks! There is currently no way to special case the conversion, and your second comment pointed out a flaw in the conversion that doesn't even relate to special cases. Having fixed that second issue, I have identified a few more names that are worth adding to a list of special cases:

And also sometimes there are interface names contained in method names:

Boddlnagg commented 5 years ago

I've now implemented a much better heuristic for detecting and splitting words/numbers, and also added a list of exceptions which will be left intact as single words.