Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop renaming ffi crates #1423

Merged
merged 5 commits into from
Jun 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ gio-sys = { path = "gio/sys", version = "0.20" }
gio = { path = "gio", version = "0.20" }
pango-sys = { path = "pango/sys", version = "0.20" }
pango = { path = "pango", version = "0.20" }
pangocairo-sys = { path = "pangocairo/sys", version = "0.20" }
cairo-sys-rs = { path = "cairo/sys", version = "0.20" }
cairo-rs = { path = "cairo", version = "0.20" }
glib-macros = { path = "glib-macros", version = "0.20" }
gdk-pixbuf-sys = { path = "gdk-pixbuf/sys", version = "0.20" }
graphene-sys = { path = "graphene/sys", version = "0.20" }
26 changes: 13 additions & 13 deletions cairo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,26 @@ version.workspace = true
name = "cairo"

[features]
png = ["ffi/png"]
pdf = ["ffi/pdf"]
svg = ["ffi/svg"]
ps = ["ffi/ps"]
use_glib = ["glib", "ffi/use_glib"]
v1_16 = ["ffi/v1_16"]
v1_18 = ["v1_16", "ffi/v1_18"]
png = ["cairo-sys-rs/png"]
pdf = ["cairo-sys-rs/pdf"]
svg = ["cairo-sys-rs/svg"]
ps = ["cairo-sys-rs/ps"]
use_glib = ["glib", "cairo-sys-rs/use_glib"]
v1_16 = ["cairo-sys-rs/v1_16"]
v1_18 = ["v1_16", "cairo-sys-rs/v1_18"]
default = ["use_glib"]
freetype = ["ffi/freetype", "freetype-rs"]
script = ["ffi/script"]
xcb = ["ffi/xcb"]
xlib = ["ffi/xlib"]
win32-surface = ["ffi/win32-surface"]
freetype = ["cairo-sys-rs/freetype", "freetype-rs"]
script = ["cairo-sys-rs/script"]
xcb = ["cairo-sys-rs/xcb"]
xlib = ["cairo-sys-rs/xlib"]
win32-surface = ["cairo-sys-rs/win32-surface"]

[dependencies.glib]
optional = true
workspace = true

[dependencies]
ffi = { package = "cairo-sys-rs", path = "sys", version = "0.20" }
cairo-sys-rs.workspace = true
libc.workspace = true
bitflags.workspace = true
thiserror.workspace = true
Expand Down
15 changes: 7 additions & 8 deletions cairo/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,13 @@ use std::{ffi::CString, fmt, mem::MaybeUninit, ops, ptr, slice};
use glib::translate::*;

use crate::{
ffi::{cairo_rectangle_list_t, cairo_t},
utils::status_to_result,
Antialias, Content, Error, FillRule, FontExtents, FontFace, FontOptions, FontSlant, FontWeight,
Glyph, LineCap, LineJoin, Matrix, Operator, Path, Pattern, Rectangle, ScaledFont, Surface,
TextCluster, TextClusterFlags, TextExtents,
ffi, utils::status_to_result, Antialias, Content, Error, FillRule, FontExtents, FontFace,
FontOptions, FontSlant, FontWeight, Glyph, LineCap, LineJoin, Matrix, Operator, Path, Pattern,
Rectangle, ScaledFont, Surface, TextCluster, TextClusterFlags, TextExtents,
};

pub struct RectangleList {
ptr: *mut cairo_rectangle_list_t,
ptr: *mut ffi::cairo_rectangle_list_t,
}

impl ops::Deref for RectangleList {
Expand Down Expand Up @@ -55,7 +53,8 @@ impl fmt::Debug for RectangleList {

#[derive(Debug)]
#[repr(transparent)]
pub struct Context(ptr::NonNull<cairo_t>);
#[doc(alias = "cairo_t")]
pub struct Context(ptr::NonNull<ffi::cairo_t>);

#[cfg(feature = "use_glib")]
#[cfg_attr(docsrs, doc(cfg(feature = "use_glib")))]
Expand Down Expand Up @@ -112,7 +111,7 @@ impl FromGlibPtrFull<*mut ffi::cairo_t> for Context {
#[cfg(feature = "use_glib")]
gvalue_impl!(
Context,
cairo_t,
ffi::cairo_t,
ffi::gobject::cairo_gobject_context_get_type
);

Expand Down
2 changes: 1 addition & 1 deletion cairo/src/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use std::ptr;
#[cfg(feature = "use_glib")]
use glib::translate::*;

use crate::{utils::status_to_result, DeviceType, Error};
use crate::{ffi, utils::status_to_result, DeviceType, Error};
#[cfg(feature = "script")]
use crate::{Content, RecordingSurface, ScriptMode, Surface};

Expand Down
2 changes: 1 addition & 1 deletion cairo/src/enums.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::fmt::Debug;
#[cfg(feature = "use_glib")]
use glib::translate::*;

use crate::Error;
use crate::{ffi, Error};

// Helper macro for our GValue related trait impls
#[cfg(feature = "use_glib")]
Expand Down
1 change: 1 addition & 0 deletions cairo/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

use std::{fmt::Debug, io};

use crate::ffi;
use thiserror::Error;

#[derive(Error, Debug, Clone, PartialEq, Copy, Eq)]
Expand Down
1 change: 1 addition & 0 deletions cairo/src/font/font_extents.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Take a look at the license at the top of the repository in the LICENSE file.

use crate::ffi;
use std::fmt;

#[derive(Clone, Copy)]
Expand Down
2 changes: 1 addition & 1 deletion cairo/src/font/font_face.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use glib::translate::*;

#[cfg(feature = "freetype")]
use crate::FtSynthesize;
use crate::{utils::status_to_result, Error, FontSlant, FontType, FontWeight};
use crate::{ffi, utils::status_to_result, Error, FontSlant, FontType, FontWeight};

#[cfg(feature = "freetype")]
static FT_FACE_KEY: crate::UserDataKey<freetype::face::Face> = crate::UserDataKey::new();
Expand Down
4 changes: 3 additions & 1 deletion cairo/src/font/font_options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ use glib::translate::*;

#[cfg(feature = "v1_16")]
use crate::font::font_face::to_optional_string;
use crate::{utils::status_to_result, Antialias, Error, HintMetrics, HintStyle, SubpixelOrder};
use crate::{
ffi, utils::status_to_result, Antialias, Error, HintMetrics, HintStyle, SubpixelOrder,
};

#[cfg(feature = "use_glib")]
glib::wrapper! {
Expand Down
1 change: 1 addition & 0 deletions cairo/src/font/glyph.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Take a look at the license at the top of the repository in the LICENSE file.

use crate::ffi;
use std::fmt;

#[derive(Clone, Copy)]
Expand Down
4 changes: 2 additions & 2 deletions cairo/src/font/scaled_font.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ use std::{ffi::CString, mem::MaybeUninit, ptr};
use glib::translate::*;

use crate::{
utils::status_to_result, Error, FontExtents, FontFace, FontOptions, FontType, Glyph, Matrix,
TextCluster, TextExtents,
ffi, utils::status_to_result, Error, FontExtents, FontFace, FontOptions, FontType, Glyph,
Matrix, TextCluster, TextExtents,
};

#[cfg(feature = "use_glib")]
Expand Down
1 change: 1 addition & 0 deletions cairo/src/font/text_cluster.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Take a look at the license at the top of the repository in the LICENSE file.

use crate::ffi;
use std::fmt;

#[derive(Clone, Copy)]
Expand Down
1 change: 1 addition & 0 deletions cairo/src/font/text_extents.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Take a look at the license at the top of the repository in the LICENSE file.

use crate::ffi;
use std::fmt;

#[derive(Clone, Copy)]
Expand Down
2 changes: 1 addition & 1 deletion cairo/src/font/user_fonts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use std::sync::OnceLock;

use super::{FontExtents, FontFace, ScaledFont, TextCluster, TextClusterFlags, TextExtents};
use crate::{utils::status_to_result, Context, Error, Glyph};
use crate::{ffi, utils::status_to_result, Context, Error, Glyph};

type BoxInitFunc =
Box<dyn Fn(&ScaledFont, &Context, &mut FontExtents) -> Result<(), Error> + Send + Sync>;
Expand Down
2 changes: 1 addition & 1 deletion cairo/src/image_surface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use std::{
#[cfg(feature = "use_glib")]
use glib::translate::*;

use crate::{utils::status_to_result, BorrowError, Error, Format, Surface, SurfaceType};
use crate::{ffi, utils::status_to_result, BorrowError, Error, Format, Surface, SurfaceType};

declare_surface!(ImageSurface, SurfaceType::Image);

Expand Down
2 changes: 1 addition & 1 deletion cairo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#![allow(clippy::missing_safety_doc)]
#![doc = include_str!("../README.md")]

pub use ffi;
pub use cairo_sys as ffi;
#[cfg(feature = "freetype")]
#[cfg_attr(docsrs, doc(cfg(feature = "freetype")))]
pub use freetype;
Expand Down
2 changes: 1 addition & 1 deletion cairo/src/matrices.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::fmt;
#[cfg(feature = "use_glib")]
use std::marker::PhantomData;

use crate::{utils::status_to_result, Error};
use crate::{ffi, utils::status_to_result, Error};

#[repr(transparent)]
#[derive(Clone, Copy, PartialEq)]
Expand Down
11 changes: 6 additions & 5 deletions cairo/src/paths.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,20 @@

use std::{iter::FusedIterator, ptr};

use crate::{ffi::cairo_path_t, PathDataType};
use crate::{ffi, PathDataType};

#[derive(Debug)]
pub struct Path(ptr::NonNull<cairo_path_t>);
#[doc(alias = "cairo_path_t")]
pub struct Path(ptr::NonNull<ffi::cairo_path_t>);

impl Path {
#[inline]
pub fn as_ptr(&self) -> *mut cairo_path_t {
pub fn as_ptr(&self) -> *mut ffi::cairo_path_t {
self.0.as_ptr()
}

#[inline]
pub unsafe fn from_raw_full(pointer: *mut cairo_path_t) -> Path {
pub unsafe fn from_raw_full(pointer: *mut ffi::cairo_path_t) -> Path {
debug_assert!(!pointer.is_null());
Path(ptr::NonNull::new_unchecked(pointer))
}
Expand All @@ -23,7 +24,7 @@ impl Path {
use std::slice;

unsafe {
let ptr: *mut cairo_path_t = self.as_ptr();
let ptr: *mut ffi::cairo_path_t = self.as_ptr();
let length = (*ptr).num_data as usize;
let data_ptr = (*ptr).data;
let data_vec = if length != 0 && !data_ptr.is_null() {
Expand Down
15 changes: 7 additions & 8 deletions cairo/src/patterns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,14 @@ use std::{ops::Deref, ptr};
use libc::{c_double, c_int, c_uint};

use crate::{
ffi::{cairo_pattern_t, cairo_surface_t},
utils::status_to_result,
Error, Extend, Filter, Matrix, MeshCorner, Path, PatternType, Surface,
ffi, utils::status_to_result, Error, Extend, Filter, Matrix, MeshCorner, Path, PatternType,
Surface,
};

// See https://cairographics.org/manual/bindings-patterns.html for more info
#[derive(Debug)]
pub struct Pattern {
pointer: *mut cairo_pattern_t,
pointer: *mut ffi::cairo_pattern_t,
}

impl Pattern {
Expand All @@ -23,18 +22,18 @@ impl Pattern {
}

#[inline]
pub fn to_raw_none(&self) -> *mut cairo_pattern_t {
pub fn to_raw_none(&self) -> *mut ffi::cairo_pattern_t {
self.pointer
}

#[inline]
pub unsafe fn from_raw_none(pointer: *mut cairo_pattern_t) -> Pattern {
pub unsafe fn from_raw_none(pointer: *mut ffi::cairo_pattern_t) -> Pattern {
ffi::cairo_pattern_reference(pointer);
Self::from_raw_full(pointer)
}

#[inline]
pub unsafe fn from_raw_full(pointer: *mut cairo_pattern_t) -> Pattern {
pub unsafe fn from_raw_full(pointer: *mut ffi::cairo_pattern_t) -> Pattern {
Self { pointer }
}

Expand Down Expand Up @@ -384,7 +383,7 @@ impl SurfacePattern {
#[doc(alias = "get_surface")]
pub fn surface(&self) -> Result<Surface, Error> {
unsafe {
let mut surface_ptr: *mut cairo_surface_t = ptr::null_mut();
let mut surface_ptr: *mut ffi::cairo_surface_t = ptr::null_mut();
let status = ffi::cairo_pattern_get_surface(self.pointer, &mut surface_ptr);
status_to_result(status)?;
Ok(Surface::from_raw_none(surface_ptr))
Expand Down
2 changes: 1 addition & 1 deletion cairo/src/pdf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use std::{
#[cfg(feature = "use_glib")]
use glib::translate::*;

use crate::{Error, PdfVersion, Surface, SurfaceType};
use crate::{ffi, Error, PdfVersion, Surface, SurfaceType};
#[cfg(all(feature = "pdf", feature = "v1_16"))]
use crate::{PdfMetadata, PdfOutline};

Expand Down
2 changes: 1 addition & 1 deletion cairo/src/ps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use std::{
#[cfg(feature = "use_glib")]
use glib::translate::*;

use crate::{Error, PsLevel, Surface, SurfaceType};
use crate::{ffi, Error, PsLevel, Surface, SurfaceType};

impl PsLevel {
pub fn as_str(self) -> Option<&'static str> {
Expand Down
2 changes: 1 addition & 1 deletion cairo/src/quartz_surface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use ffi::CGContextRef;
#[cfg(feature = "use_glib")]
use glib::translate::*;

use crate::{Error, Format, Surface, SurfaceType};
use crate::{ffi, Error, Format, Surface, SurfaceType};

declare_surface!(QuartzSurface, SurfaceType::Quartz);

Expand Down
2 changes: 1 addition & 1 deletion cairo/src/recording_surface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::ops::Deref;
#[cfg(feature = "use_glib")]
use glib::translate::*;

use crate::{Content, Error, Rectangle, Surface, SurfaceType};
use crate::{ffi, Content, Error, Rectangle, Surface, SurfaceType};

declare_surface!(RecordingSurface, SurfaceType::Recording);
impl RecordingSurface {
Expand Down
1 change: 1 addition & 0 deletions cairo/src/rectangle.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Take a look at the license at the top of the repository in the LICENSE file.

use crate::ffi;
use std::fmt;
#[cfg(feature = "use_glib")]
use std::{marker::PhantomData, mem};
Expand Down
2 changes: 2 additions & 0 deletions cairo/src/rectangle_int.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Take a look at the license at the top of the repository in the LICENSE file.

use crate::ffi;
use std::fmt;

#[cfg(feature = "use_glib")]
use std::{marker::PhantomData, mem};

Expand Down
5 changes: 3 additions & 2 deletions cairo/src/region.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ use std::ptr;
#[cfg(feature = "use_glib")]
use glib::translate::*;

use crate::{ffi::cairo_region_t, utils::status_to_result, Error, RectangleInt, RegionOverlap};
use crate::{ffi, utils::status_to_result, Error, RectangleInt, RegionOverlap};

#[derive(Debug)]
#[repr(transparent)]
pub struct Region(ptr::NonNull<cairo_region_t>);
#[doc(alias = "cairo_region_t")]
pub struct Region(ptr::NonNull<ffi::cairo_region_t>);

#[cfg(feature = "use_glib")]
impl IntoGlibPtr<*mut ffi::cairo_region_t> for Region {
Expand Down
4 changes: 2 additions & 2 deletions cairo/src/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use std::{
rc::Rc,
};

use ffi::cairo_status_t;
use crate::ffi;
use libc::{c_double, c_uchar, c_uint, c_void};

use crate::{Error, Surface, UserDataKey};
Expand Down Expand Up @@ -202,7 +202,7 @@ extern "C" fn write_callback<W: io::Write + 'static>(
env: *mut c_void,
data: *mut c_uchar,
length: c_uint,
) -> cairo_status_t {
) -> ffi::cairo_status_t {
// This is consistent with the type of `env` in `Surface::_for_stream`.
let env: *const CallbackEnvironment = env as _;

Expand Down
4 changes: 2 additions & 2 deletions cairo/src/surface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ use glib::translate::*;
use libc::{c_ulong, c_void};

use crate::{
utils::status_to_result, Content, Device, Error, Format, ImageSurface, Rectangle, RectangleInt,
SurfaceType,
ffi, utils::status_to_result, Content, Device, Error, Format, ImageSurface, Rectangle,
RectangleInt, SurfaceType,
};

#[derive(Debug)]
Expand Down
Loading
Loading