Closed Bug 1548691 Opened 5 years ago Closed 5 years ago

Use rust types for basic shapes.


(Core :: CSS Parsing and Computation, defect, P3)




Tracking Status
firefox68 --- fixed


(Reporter: emilio, Assigned: emilio)




(2 files)

This is the first step to use more complex rust types in cbindgen.

For now, we'll use just a replacement for a boxed slice.

Afterwards, we should be able to do Atom, Arc and Box, and I think that's all we need to remove all the custom glue code and have something sane :)

Passing these by value won't be ok of course, but that's fine.

I plan to combine this with to
actually be able to share representation for ~all the things, this is just the
first bit. Box<T>, Atom and Arc<T> will be much easier since those have defined
memory layouts.

It's boxed slices the only ones I should need something like this. I could avoid
it if I rely on Rust's internal representation, but I'd rather not, it didn't
end up being as much work to do it right.

This enables destructors for tagged unions in cbindgen, implemented in:

Which allow us to properly generate a destructor for the cbindgen-generated
StyleBasicShape (which now contains an OwnedSlice).

For now, we still use the glue code to go from Box<BasicShape> to
UniquePtr<BasicShape>. But that will change in the future when we generate even
more stuff and remove all the glue.

I could add support for copy-constructor generation to cbindgen for tagged
enums, but I'm not sure if it'll end up being needed, and copy-constructing
unions in C++ is always very tricky.

Depends on D29768

Depends on: 1525402
Blocks: 1549559
Blocks: 1549593
Attachment #9062369 - Attachment description: Bug 1548691 - Add an owned slice type with defined layout for FFI. r=heycam → Bug 1548691 - Add an owned slice type which cbindgen can understand. r=heycam
Pushed by
Add an owned slice type which cbindgen can understand. r=heycam
Use the owned slice type for basic shape polygon coordinates. r=TYLin,heycam
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla68
You need to log in before you can comment on or make changes to this bug.