-
-
Notifications
You must be signed in to change notification settings - Fork 59
Better support for PDF, SVG and PostScript. #165
Conversation
30aa165
to
acf1a4b
Compare
@GuillaumeGomez this is ready as far as I'm concerned. |
src/lib.rs
Outdated
@@ -125,9 +122,19 @@ mod rectangle; | |||
mod region; | |||
mod surface; | |||
mod matrices; | |||
mod support; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems this better have #[cfg(any(feature = "pdf", feature = "svg", feature = "ps", feature = "dox"))]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, commit incoming.
Second problem that all docs need moved to https://github.com/gtk-rs/lgpl-docs repo to |
@GuillaumeGomez there problem with regenerating stripped comments: in |
@EPashkin any direction to move them over without suffering too much? |
@meh Theoretically you just need run |
@EPashkin oh I see, yeah I'll wait, he's probably still traveling 🐼 |
Ok so, if docs issue you have, regen the docs ( If it wasn't the problem, then it just mean I need to sleep and I'll check this tomorrow. 😀 |
@GuillaumeGomez for tomorrow check: |
That's weird. I suppose it's a |
@meh, @GuillaumeGomez Found "solution": it restored right way if |
That's weird... |
Should I also purge the documentation from the git history? |
It depends if it's lgpl docs or not. |
I don't know, I wrote them 🤔 |
Then it's not lgpl. :) |
I think I did something wrong while generating the docs, see pull request on docs. |
#[derive(Clone, Copy, Debug, PartialEq, Eq)] | ||
pub enum PdfVersion { | ||
_1_4, | ||
_1_5, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See gtk-rs/gir#480
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do I need to do exactly here? Kind of unclear from the issue.
Should I just add an Unknown
variant?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the -sys crate you use an integer and constants, in the non-sys crate you have a real enum with the Unknown variant
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this still the case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes
#[cfg(feature = "use_glib")] | ||
use glib::translate::*; | ||
|
||
pub struct File { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see some potential of sharing code here (macro I guess?) between PDF and PS. It's basically the same except for the types and the functions called.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, there's a lot of code duplication between PDF, PS and SVG, I could add a macro to src/support.rs
that generates those, wasn't sure if that was wanted or not.
unsafe { | ||
let mut out = Box::from_raw(buffer); | ||
out.extend(data); | ||
Box::into_raw(out); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems dangerous. The buffer you store in Buffer could become invalid in theory. Box::from_raw() followed by Box::into_raw() could in theory move things to a different place on the heap.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm pretty sure that's safe, or stuff like owning_ref
and rental
would explode in really funny ways.
The part I'm unsure about is the story with aliasing which might be UB there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem with from_raw/into_raw() is that they operate on owned values. They could do whatever they want with them, including moving to different memory locations. The assumption is that nothing is borrowing the data currently (and nothing is as far as the compiler is concerned, otherwise into_raw() would not compile), and with all your pointers that still point to the data you're on your own and need to ensure correctness.
I would recommend to work directly on the pointers here: let out = &mut *buffer;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll look into it.
What's the status/plan here? |
I'll see @meh this week-end. I'll try to motivate him to finish it. :) |
It will happen, I believe. |
🎉 Finally! 🎉 Thanks! |
🎉 |
This is absolutely true. I am going to have to look for a simpler set of bindings :( |
Don't merge yet, just need some eyes on the unsafe part.