-
Notifications
You must be signed in to change notification settings - Fork 117
Clean up the glue #484
Comments
Cc @jdm @asajeffrey |
Well the big picture "why have a glue.cpp file at all" is because bindgen has a hard time with C++ APIs, especially on windows where the ABI is 🤷♂️. Since jsapi is very keen on C++ idioms we then have to put them back into C-like function calls that bindgen is happier with. That said, the split between the IIRC the So yes, it looks like we have let some technical debt accumulate here. |
I feel like this script using Would it really be that horrible if we just wrote such safe wrappers on demand, whenever we need a new API, rather than trying to mechanise that stuff weirdly? |
My experience updating spidermonkey with the checked in wrapper files is that the compiler complains when there are invalid wrappers, so there is not actually a risk of drift. |
Do you mean get rid of the macros, or get rid of the shell script? |
But those wrappers aren't actually idiomatic, so if we actually wanted to have bindings that don't lead to a miserable experience, we would still need to write code by hand, at which point why do this weird grep/sed stuff? I guess a good compromise would be to retcon the |
Doing the smup, I realise that all these wrappers are hindering me in CodegenRust.py, they are not helping. |
Like, wrappers for |
So this crate has a
jsglue.cpp
file, yet another one, with more stuff than the one inservo/mozjs
, but mostly duplicated stuff. It has corresponding bindings inglue.rs
, but this file is not generated by bindgen during the build, it's just sitting there in the repo, never regenerated, so it may not even be in sync anymore. The instructions to build it are a comment with hardcoded paths in the otherwise 8 years old filegen.py
.We then wrap those with additional Rust methods, through macro calls generated in
glue_wrappers.in
(andjsapi_wrappers.in
because, why not?). Those files are generated by the shell scriptgenerate_wrappers.sh
, which is just a sed script in disguise.Those two
.in
files aren't generated during build-time either, and the jsapi one is generated from the generated bindings fromservo/mozjs_sys
, but the script is hardcoded to read the debug bindings, so who knows if that's correct when building in release mode…How did we let things become that out of hand? What is actually relevant, and what is not?
The text was updated successfully, but these errors were encountered: