Using operator= is not quite sound in presence of destructors and operator
overloading.
It's perfectly fine to assume that the left-hand-side of an operator= expression
is valid memory, however we're using uninitialized memory here, that may not be
the case.
Use placement new to properly construct tagged unions. I don't need this with
any urgency, but it's the right thing to do in presence of complex types, and
the current code seems a bomb waiting to explode :)
This trades the ABI-safety (making the struct potentially unsafe to pass by
value), thus the opt-in rather than auto-generating it.
The TL;DR is that I need a way to share types that contain boxed slices from the
style system. That's fine when they're inside regular structs, since C++ does
the right thing, but for unions you need to make it explicit like this.
The actual Gecko setup will hook into the leak logging machinery to avoid silly
leaks and such of course.
Fixes#123:
- Adds visibility check for module-level constants.
- Adds visibility check for associated constants.
- Fixes bitflags expansion to produce public associated constants (as the real expansion does).
In modern C (post-C99) it's common to just use `// double-slash comments`, but currently cbindgen provides only `/* block-comment */` and `/// triple-slash comment` variants.
* Ignoring IDE files.
* Addresses issue #302, also amends #59 insofar that vanilla C-style now does not prefix individual lines with `*` anymore.
* Removed Javadoc reference.
* Renamed `Doxylight` to `Doxy` and changed C default to that.
* Added documentation.
* Changed enum name and applied `fmt`.
* Fixed comment.
* Fixed match.
The static_cast is needed to avoid -Wnarrowing conversions, but I can also write
it like:
Foo ret;
ret.bits = bits | other.bits;
return ret;
if you prefer.
This fixes one of my pet-peeves. Without this patch, I need to add them manually
using the raw body stuff, or along the code that accesses the struct member,
none of those being ideal.
Opt-in since it uses a C++17 feature, but this allow exactly the same usage in
C++ and Rust, which I think is nice.
This also fixes constants of transparent structs in general, since the initial
version of this patch broke a test (associated constants in enums), so I added a
test for that too.
Fix#238
This ensures that constants of a struct type have their type and the
type of their underlying value expressions renamed in the case of a
prefix.
Fix for #232
This adds a type prefix for associated constants to avoid namespace
collisions. It also adds error invocation in the rare but existing
cases where an collisions still happens in the constant namespace.
Boris hit this because he used #[repr(C)] instead of #[repr(u8)].
We were incorrectly writing the generic arguments twice for those.
I missed this difference in #219.
Fixes#225.
I want this to move around slices and boxes across the style system, while
preserving the option size optimizations when they're fully in a repr(Rust)
data-structure.
This is sound because NonNull is repr(transparent):
https://doc.rust-lang.org/src/core/ptr.rs.html#2847
I renamed simplify_option_to_ptr to simplify_standard_types because that's what
it does now.
ABI-wise for NonNull<T> it's guaranteed via repr(transparent). For
Option<NonNull<T>> it is as well, though I've asked in #rustc to confirm.
The LLVM IR of:
```
pub extern "C" fn foo(ptr: Option<::std::ptr::NonNull<i32>>) {}
```
is:
```
define void @foo(i32*) unnamed_addr #0 !dbg !310 {
start:
%ptr = alloca i32*, align 8
store i32* %0, i32** %ptr, align 8
call void @llvm.dbg.declare(metadata i32** %ptr, metadata !327, metadata
!DIExpression()), !dbg !328
ret void, !dbg !329
}
```
Which is the same as for:
```
pub extern "C" fn foo(ptr: ::std::ptr::NonNull<i32>) {}
```
Except without the nonnull annotation.
And the same as for:
```
pub extern "C" fn foo(ptr: *mut i32) {}
```
Going to need this if I ever aim to generate TransformOperation bindings and
remove a bunch of slow and ugly Gecko code:
https://searchfox.org/mozilla-central/rev/80ac71c1c54af788b32e851192dfd2de2ec18e18/servo/components/style/values/generics/transform.rs#189
With the caveat that I'll need to remove the options, but I can manage to do
that.
This also fixes a bunch of renaming bugs that I found while at it.
This patch has the gotcha that we need to remove the assertion of no-underscores
in mangled names... But I think it should be fine, and I'd rather not do a more
breaking change.
You can generate conflicting names in C using enum variants with the same name
as a struct regardless, for example, so I don't think this is terribly
important.