I kept it building the most straight-forward way possible (pub use) because it
seems to me that bindings is not a bad name, and we should probably move
structs.rs to be bindings.rs rather than the other way around.
But that's a different bug in any case, need to think more about it.
Differential Revision: https://phabricator.services.mozilla.com/D24713
And make them actually sound. We're defining functions on Rust-land that get
structs as arguments, but declaring them in C++ as getting pointers.
This is another step in order to be able to autogenerate ServoBindings.h and
remove bindings.rs altogether.
We remove FooOwned in favor of Owned<Foo>, which is generated via cbindgen.
It'd be good to actually mark Owned and such as MOZ_MUST_USE_TYPE, so I sent
https://github.com/eqrion/cbindgen/pull/307 for that.
Differential Revision: https://phabricator.services.mozilla.com/D24681
This reduces a lot the boilerplate that's needed in order to add simple binding
functions.
This starts using &Foo and Option<&Foo> instead, and as a result we need to
remove the servo_function_signatures test, which is a bit unfortunate.
I think it's worth though, this causes problems on some platforms (see bug
1534844), and messing up the functions signature is not something that I've ever
seen (other than bug 1308234, which already had all the FooBorrowed mess which
I'm removing).
Also, cbindgen understands references and Option<&Foo>, so it will be the way to
go in the future.
After this patch we can also remove HasSimpleFFI, but I've kept it for now since
I still use it in a few places, and this patch is quite big on its own.
Differential Revision: https://phabricator.services.mozilla.com/D24092
Constified enums are default now. I think I want to introduce an option to
bindgen to allow setting the default enum behavior, but it doesn't need to block
this.
The ServoBindings.toml changes are somewhat hacky, but that's because of
https://github.com/rust-lang-nursery/rust-bindgen/issues/1125.
Also, the fixups now need to account for whitespace, since quote generates stuff
like root :: nsString, and we don't rustfmt the bindings if there's no rustfmt
installed.
Bug: 1412486
Reviewed-by: xidorn
MozReview-Commit-ID: EY5eNnCiTIw
This is only slightly more informative because it doesn't give
the filename, but I think it's an improvement on the simple
unwrap() panic when we try to read a file which isn't there.
See also [Gecko bug 1368083](https://bugzilla.mozilla.org/show_bug.cgi?id=1368083).
Bindgen needs some build-specific flags, like the -isysroot
passed to clang for the C++ compilation. Try to read
these from $objdir/layout/style/bindgen.toml which is
created by the Firefox build system, and merge them
into the config.
See also [Gecko bug 1368083](https://bugzilla.mozilla.org/show_bug.cgi?id=1368083).
provide more information when bindgen fails
Providing the flags we passed into clang can be informative for double-checking that we set everything up correctly.
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [ ] These changes fix #__ (github issue number if applicable).
<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/16880)
<!-- Reviewable:end -->