Skip to content

Commit

Permalink
Migrate to doc_auto_cfg
Browse files Browse the repository at this point in the history
  • Loading branch information
qnighy committed Dec 22, 2024
1 parent 138cae9 commit eb99eb5
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 139 deletions.
4 changes: 2 additions & 2 deletions src/decode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@ cfg_if! {
}

#[cfg(feature = "extern-types")]
#[cfg_attr(feature = "__doc_cfg", doc(cfg(all())))]
extern "C" {
pub type WebPIDecoder;
}

#[cfg(not(feature = "extern-types"))]
#[cfg_attr(feature = "__doc_cfg", doc(cfg(all())))]
#[repr(C)]
pub struct WebPIDecoder(c_void);

Expand Down Expand Up @@ -278,11 +280,9 @@ pub struct WebPDecoderOptions {
pub dithering_strength: c_int,
/// if true, flip output vertically
#[cfg(feature = "0_5")]
#[cfg_attr(feature = "__doc_cfg", doc(cfg(feature = "0_5")))]
pub flip: c_int,
/// alpha dithering strength in [0..100]
#[cfg(feature = "0_5")]
#[cfg_attr(feature = "__doc_cfg", doc(cfg(feature = "0_5")))]
pub alpha_dithering_strength: c_int,
/// Unused for now. forced rotation (to be applied _last_)
#[cfg(not(feature = "0_5"))]
Expand Down
81 changes: 5 additions & 76 deletions src/demux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use std::ptr;
use crate::decode::*;
use crate::mux_types::*;

#[cfg_attr(feature = "__doc_cfg", doc(cfg(feature = "demux")))]
pub const WEBP_DEMUX_ABI_VERSION: c_int = WEBP_DEMUX_ABI_VERSION_INTERNAL;

cfg_if! {
Expand All @@ -17,8 +16,8 @@ cfg_if! {
}

#[cfg(feature = "extern-types")]
#[cfg_attr(feature = "__doc_cfg", doc(cfg(feature = "demux")))]
extern "C" {
#[cfg_attr(feature = "__doc_cfg", doc(cfg(feature = "demux")))]
pub type WebPDemuxer;
}

Expand All @@ -27,7 +26,6 @@ extern "C" {
#[repr(C)]
pub struct WebPDemuxer(c_void);

#[cfg_attr(feature = "__doc_cfg", doc(cfg(feature = "demux")))]
#[allow(non_camel_case_types)]
pub type WebPDemuxState = i32;

Expand All @@ -36,7 +34,6 @@ pub const WEBP_DEMUX_PARSING_HEADER: WebPDemuxState = 0;
pub const WEBP_DEMUX_PARSED_HEADER: WebPDemuxState = 1;
pub const WEBP_DEMUX_DONE: WebPDemuxState = 2;

#[cfg_attr(feature = "__doc_cfg", doc(cfg(feature = "demux")))]
#[allow(non_camel_case_types)]
pub type WebPFormatFeature = u32;

Expand All @@ -47,7 +44,6 @@ pub const WEBP_FF_LOOP_COUNT: WebPFormatFeature = 3;
pub const WEBP_FF_BACKGROUND_COLOR: WebPFormatFeature = 4;
pub const WEBP_FF_FRAME_COUNT: WebPFormatFeature = 5;

#[cfg_attr(feature = "__doc_cfg", doc(cfg(feature = "demux")))]
#[repr(C)]
#[derive(Debug, Clone, Copy)]
pub struct WebPIterator {
Expand Down Expand Up @@ -75,7 +71,6 @@ pub struct WebPIterator {
pub private_: *mut c_void,
}

#[cfg_attr(feature = "__doc_cfg", doc(cfg(feature = "demux")))]
#[repr(C)]
#[derive(Debug, Clone, Copy)]
pub struct WebPChunkIterator {
Expand All @@ -89,11 +84,11 @@ pub struct WebPChunkIterator {
}

#[cfg(all(feature = "0_5", feature = "extern-types"))]
#[cfg_attr(
feature = "__doc_cfg",
doc(cfg(all(feature = "demux", feature = "0_5")))
)]
extern "C" {
#[cfg_attr(
feature = "__doc_cfg",
doc(cfg(all(feature = "demux", feature = "0_5")))
)]
pub type WebPAnimDecoder;
}

Expand All @@ -106,10 +101,6 @@ extern "C" {
pub struct WebPAnimDecoder(c_void);

#[cfg(feature = "0_5")]
#[cfg_attr(
feature = "__doc_cfg",
doc(cfg(all(feature = "demux", feature = "0_5")))
)]
#[repr(C)]
#[derive(Debug, Clone, Copy)]
pub struct WebPAnimDecoderOptions {
Expand All @@ -120,10 +111,6 @@ pub struct WebPAnimDecoderOptions {
}

#[cfg(feature = "0_5")]
#[cfg_attr(
feature = "__doc_cfg",
doc(cfg(all(feature = "demux", feature = "0_5")))
)]
#[repr(C)]
#[derive(Debug, Clone, Copy)]
pub struct WebPAnimInfo {
Expand All @@ -137,9 +124,7 @@ pub struct WebPAnimInfo {
}

extern "C" {
#[cfg_attr(feature = "__doc_cfg", doc(cfg(feature = "demux")))]
pub fn WebPGetDemuxVersion() -> c_int;
#[cfg_attr(feature = "__doc_cfg", doc(cfg(feature = "demux")))]
#[doc(hidden)]
#[cfg_attr(feature = "must-use", must_use)]
pub fn WebPDemuxInternal(
Expand All @@ -148,61 +133,39 @@ extern "C" {
_: *mut WebPDemuxState,
_: c_int,
) -> *mut WebPDemuxer;
#[cfg_attr(feature = "__doc_cfg", doc(cfg(feature = "demux")))]
pub fn WebPDemuxDelete(dmux: *mut WebPDemuxer);
#[cfg_attr(feature = "__doc_cfg", doc(cfg(feature = "demux")))]
pub fn WebPDemuxGetI(dmux: *const WebPDemuxer, feature: WebPFormatFeature) -> u32;
#[cfg_attr(feature = "__doc_cfg", doc(cfg(feature = "demux")))]
#[cfg_attr(feature = "must-use", must_use)]
pub fn WebPDemuxGetFrame(
dmux: *const WebPDemuxer,
frame_number: c_int,
iter: *mut WebPIterator,
) -> c_int;
#[cfg_attr(feature = "__doc_cfg", doc(cfg(feature = "demux")))]
#[cfg_attr(feature = "must-use", must_use)]
pub fn WebPDemuxNextFrame(iter: *mut WebPIterator) -> c_int;
#[cfg_attr(feature = "__doc_cfg", doc(cfg(feature = "demux")))]
#[cfg_attr(feature = "must-use", must_use)]
pub fn WebPDemuxPrevFrame(iter: *mut WebPIterator) -> c_int;
#[cfg(not(feature = "0_5"))]
#[cfg_attr(
feature = "__doc_cfg",
doc(cfg(all(feature = "demux", feature = "0_5")))
)]
#[deprecated(note = "Removed as of libwebp 0.5.0")]
pub fn WebPDemuxSelectFragment(iter: *mut WebPIterator, fragment_num: c_int) -> c_int;
#[cfg_attr(feature = "__doc_cfg", doc(cfg(feature = "demux")))]
pub fn WebPDemuxReleaseIterator(iter: *mut WebPIterator);
#[cfg_attr(feature = "__doc_cfg", doc(cfg(feature = "demux")))]
#[cfg_attr(feature = "must-use", must_use)]
pub fn WebPDemuxGetChunk(
dmux: *const WebPDemuxer,
fourcc: *const c_char,
chunk_number: c_int,
iter: *mut WebPChunkIterator,
) -> c_int;
#[cfg_attr(feature = "__doc_cfg", doc(cfg(feature = "demux")))]
#[cfg_attr(feature = "must-use", must_use)]
pub fn WebPDemuxNextChunk(iter: *mut WebPChunkIterator) -> c_int;
#[cfg_attr(feature = "__doc_cfg", doc(cfg(feature = "demux")))]
#[cfg_attr(feature = "must-use", must_use)]
pub fn WebPDemuxPrevChunk(iter: *mut WebPChunkIterator) -> c_int;
#[cfg_attr(feature = "__doc_cfg", doc(cfg(feature = "demux")))]
pub fn WebPDemuxReleaseChunkIterator(iter: *mut WebPChunkIterator);
#[cfg(feature = "0_5")]
#[cfg_attr(
feature = "__doc_cfg",
doc(cfg(all(feature = "demux", feature = "0_5")))
)]
#[doc(hidden)]
#[cfg_attr(feature = "must-use", must_use)]
pub fn WebPAnimDecoderOptionsInitInternal(_: *mut WebPAnimDecoderOptions, _: c_int) -> c_int;
#[cfg(feature = "0_5")]
#[cfg_attr(
feature = "__doc_cfg",
doc(cfg(all(feature = "demux", feature = "0_5")))
)]
#[doc(hidden)]
#[cfg_attr(feature = "must-use", must_use)]
pub fn WebPAnimDecoderNewInternal(
Expand All @@ -211,60 +174,34 @@ extern "C" {
_: c_int,
) -> *mut WebPAnimDecoder;
#[cfg(feature = "0_5")]
#[cfg_attr(
feature = "__doc_cfg",
doc(cfg(all(feature = "demux", feature = "0_5")))
)]
#[cfg_attr(feature = "must-use", must_use)]
pub fn WebPAnimDecoderGetInfo(dec: *const WebPAnimDecoder, info: *mut WebPAnimInfo) -> c_int;
#[cfg(feature = "0_5")]
#[cfg_attr(
feature = "__doc_cfg",
doc(cfg(all(feature = "demux", feature = "0_5")))
)]
#[cfg_attr(feature = "must-use", must_use)]
pub fn WebPAnimDecoderGetNext(
dec: *mut WebPAnimDecoder,
buf: *mut *mut u8,
timestamp: *mut c_int,
) -> c_int;
#[cfg(feature = "0_5")]
#[cfg_attr(
feature = "__doc_cfg",
doc(cfg(all(feature = "demux", feature = "0_5")))
)]
#[cfg_attr(feature = "must-use", must_use)]
pub fn WebPAnimDecoderHasMoreFrames(dec: *const WebPAnimDecoder) -> c_int;
#[cfg(feature = "0_5")]
#[cfg_attr(
feature = "__doc_cfg",
doc(cfg(all(feature = "demux", feature = "0_5")))
)]
pub fn WebPAnimDecoderReset(dec: *mut WebPAnimDecoder);
#[cfg(feature = "0_5")]
#[cfg_attr(
feature = "__doc_cfg",
doc(cfg(all(feature = "demux", feature = "0_5")))
)]
#[cfg_attr(feature = "must-use", must_use)]
pub fn WebPAnimDecoderGetDemuxer(dec: *const WebPAnimDecoder) -> *const WebPDemuxer;
#[cfg(feature = "0_5")]
#[cfg_attr(
feature = "__doc_cfg",
doc(cfg(all(feature = "demux", feature = "0_5")))
)]
pub fn WebPAnimDecoderDelete(dec: *mut WebPAnimDecoder);
}

#[cfg_attr(feature = "__doc_cfg", doc(cfg(feature = "demux")))]
#[allow(non_snake_case)]
#[cfg_attr(feature = "must-use", must_use)]
#[inline]
pub unsafe extern "C" fn WebPDemux(data: *const WebPData) -> *mut WebPDemuxer {
WebPDemuxInternal(data, 0, ptr::null_mut(), WEBP_DEMUX_ABI_VERSION)
}

#[cfg_attr(feature = "__doc_cfg", doc(cfg(feature = "demux")))]
#[allow(non_snake_case)]
#[cfg_attr(feature = "must-use", must_use)]
#[inline]
Expand All @@ -276,10 +213,6 @@ pub unsafe extern "C" fn WebPDemuxPartial(
}

#[cfg(feature = "0_5")]
#[cfg_attr(
feature = "__doc_cfg",
doc(cfg(all(feature = "demux", feature = "0_5")))
)]
#[allow(non_snake_case)]
#[inline]
#[cfg_attr(feature = "must-use", must_use)]
Expand All @@ -290,10 +223,6 @@ pub unsafe extern "C" fn WebPAnimDecoderOptionsInit(
}

#[cfg(feature = "0_5")]
#[cfg_attr(
feature = "__doc_cfg",
doc(cfg(all(feature = "demux", feature = "0_5")))
)]
#[allow(non_snake_case)]
#[cfg_attr(feature = "must-use", must_use)]
#[inline]
Expand Down
14 changes: 0 additions & 14 deletions src/encode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,22 +51,16 @@ pub struct WebPConfig {
pub thread_level: c_int,
pub low_memory: c_int,
#[cfg(feature = "0_5")]
#[cfg_attr(feature = "__doc_cfg", doc(cfg(feature = "0_5")))]
pub near_lossless: c_int,
#[cfg(feature = "0_5")]
#[cfg_attr(feature = "__doc_cfg", doc(cfg(feature = "0_5")))]
pub exact: c_int,
#[cfg(feature = "0_6")]
#[cfg_attr(feature = "__doc_cfg", doc(cfg(feature = "0_6")))]
pub use_delta_palette: c_int,
#[cfg(feature = "0_6")]
#[cfg_attr(feature = "__doc_cfg", doc(cfg(feature = "0_6")))]
pub use_sharp_yuv: c_int,
#[cfg(feature = "1_2")]
#[cfg_attr(feature = "__doc_cfg", doc(cfg(feature = "1_2")))]
pub qmin: c_int,
#[cfg(feature = "1_2")]
#[cfg_attr(feature = "__doc_cfg", doc(cfg(feature = "1_2")))]
pub qmax: c_int,
#[cfg(not(feature = "0_5"))]
#[doc(hidden)]
Expand Down Expand Up @@ -110,13 +104,10 @@ pub struct WebPAuxStats {
pub palette_size: c_int,
pub lossless_size: c_int,
#[cfg(feature = "0_5")]
#[cfg_attr(feature = "__doc_cfg", doc(cfg(feature = "0_5")))]
pub lossless_hdr_size: c_int,
#[cfg(feature = "0_5")]
#[cfg_attr(feature = "__doc_cfg", doc(cfg(feature = "0_5")))]
pub lossless_data_size: c_int,
#[cfg(feature = "1_5")]
#[cfg_attr(feature = "__doc_cfg", doc(cfg(feature = "1_5")))]
pub cross_color_transform_bits: c_int,
#[cfg(not(feature = "0_5"))]
#[doc(hidden)]
Expand Down Expand Up @@ -282,14 +273,12 @@ extern "C" {
pub fn WebPConfigInitInternal(_: *mut WebPConfig, _: WebPPreset, _: c_float, _: c_int)
-> c_int;
#[cfg(feature = "0_5")]
#[cfg_attr(feature = "__doc_cfg", doc(cfg(feature = "0_5")))]
#[cfg_attr(feature = "must-use", must_use)]
pub fn WebPConfigLosslessPreset(config: *mut WebPConfig, level: c_int) -> c_int;
#[cfg_attr(feature = "must-use", must_use)]
pub fn WebPValidateConfig(config: *const WebPConfig) -> c_int;
pub fn WebPMemoryWriterInit(writer: *mut WebPMemoryWriter);
#[cfg(feature = "0_5")]
#[cfg_attr(feature = "__doc_cfg", doc(cfg(feature = "0_5")))]
pub fn WebPMemoryWriterClear(writer: *mut WebPMemoryWriter);
#[cfg_attr(feature = "must-use", must_use)]
pub fn WebPMemoryWrite(data: *const u8, data_size: usize, picture: *const WebPPicture)
Expand All @@ -303,7 +292,6 @@ extern "C" {
#[cfg_attr(feature = "must-use", must_use)]
pub fn WebPPictureCopy(src: *const WebPPicture, dst: *mut WebPPicture) -> c_int;
#[cfg(feature = "0_6")]
#[cfg_attr(feature = "__doc_cfg", doc(cfg(feature = "0_6")))]
#[cfg_attr(feature = "must-use", must_use)]
pub fn WebPPlaneDistortion(
src: *const u8,
Expand Down Expand Up @@ -389,11 +377,9 @@ extern "C" {
dithering: c_float,
) -> c_int;
#[cfg(feature = "0_6")]
#[cfg_attr(feature = "__doc_cfg", doc(cfg(feature = "0_6")))]
#[cfg_attr(feature = "must-use", must_use)]
pub fn WebPPictureSharpARGBToYUVA(picture: *mut WebPPicture) -> c_int;
#[cfg(feature = "0_5")]
#[cfg_attr(feature = "__doc_cfg", doc(cfg(feature = "0_5")))]
#[cfg_attr(feature = "must-use", must_use)]
pub fn WebPPictureSmartARGBToYUVA(picture: *mut WebPPicture) -> c_int;
#[cfg_attr(feature = "must-use", must_use)]
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#![cfg_attr(feature = "__doc_cfg", feature(doc_cfg))]
#![cfg_attr(feature = "__doc_cfg", feature(doc_auto_cfg))]
#![cfg_attr(feature = "extern-types", feature(extern_types))]

#[macro_use]
Expand Down
Loading

0 comments on commit eb99eb5

Please sign in to comment.