From 433068a5aee5053ccc174cefe6bdf9fd11031cdd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?joseLu=C3=ADs?= Date: Wed, 25 Nov 2020 14:01:25 +0100 Subject: [PATCH] rust: further types cleanup - made sigset_t private. - made FILE_LIBC & FILE_NC private. - add NCMETRIC_ prefix to the related constants. - Improve more comments. --- rust/src/bindings.rs | 6 ++++-- rust/src/types/cell.rs | 4 ++-- rust/src/types/misc.rs | 12 ++++++------ rust/src/types/mod.rs | 5 ++--- rust/src/types/plane.rs | 26 +++++++++++++------------- 5 files changed, 27 insertions(+), 26 deletions(-) diff --git a/rust/src/bindings.rs b/rust/src/bindings.rs index 2e0448f27..d8bf47f92 100644 --- a/rust/src/bindings.rs +++ b/rust/src/bindings.rs @@ -713,11 +713,13 @@ pub use bindgen::{ // sig ------------------------------------------------------------------------- -#[doc(inline)] -pub use bindgen::{ +pub(crate) use bindgen::{ // type definitions sigset_t, +}; +#[doc(inline)] +pub use bindgen::{ // structs //sigaction, diff --git a/rust/src/types/cell.rs b/rust/src/types/cell.rs index 95519e695..3a0d21de4 100644 --- a/rust/src/types/cell.rs +++ b/rust/src/types/cell.rs @@ -105,7 +105,7 @@ pub const NCCELL_BGDEFAULT_MASK: u32 = crate::bindings::CELL_BGDEFAULT_MASK; /// Extract these bits to get the background alpha mask pub const NCCELL_BG_ALPHA_MASK: u32 = crate::bindings::CELL_BG_ALPHA_MASK; -/// If this bit *and* CELL_BGDEFAULT_MASK are set, we're using a +/// If this bit *and* [`CELL_BGDEFAULT_MASK`] are set, we're using a /// palette-indexed background color pub const NCCELL_BG_PALETTE: u32 = crate::bindings::CELL_BG_PALETTE; @@ -118,7 +118,7 @@ pub const NCCELL_FGDEFAULT_MASK: u64 = crate::bindings::CELL_FGDEFAULT_MASK; /// Extract these bits to get the foreground alpha mask pub const NCCELL_FG_ALPHA_MASK: u64 = crate::bindings::CELL_FG_ALPHA_MASK; -/// If this bit *and* CELL_BGDEFAULT_MASK are set, we're using a +/// If this bit *and* [`CELL_BGDEFAULT_MASK`] are set, we're using a /// palette-indexed background color pub const NCCELL_FG_PALETTE: u64 = crate::bindings::CELL_FG_PALETTE; diff --git a/rust/src/types/misc.rs b/rust/src/types/misc.rs index 378d3de71..25bf3f801 100644 --- a/rust/src/types/misc.rs +++ b/rust/src/types/misc.rs @@ -21,27 +21,27 @@ pub type NcTime = crate::bindings::timespec; // // to set up a printf()-style maximum field width, // you should use [IB]PREFIXFMT (see below). -pub const PREFIXCOLUMNS: u32 = crate::bindings::PREFIXCOLUMNS; +pub const NCMETRIC_PREFIXCOLUMNS: u32 = crate::bindings::PREFIXCOLUMNS; // The maximum number of columns used by a mult == 1000 (standard) // ncmetric() call. -pub const BPREFIXCOLUMNS: u32 = crate::bindings::BPREFIXCOLUMNS; +pub const NCMETRIC_BPREFIXCOLUMNS: u32 = crate::bindings::BPREFIXCOLUMNS; // IPREFIXCOLUMNS is the maximum number of columns used by a mult == 1024 // (digital information) ncmetric(). -pub const IPREFIXCOLUMNS: u32 = crate::bindings::IPREFIXCOLUMNS; +pub const NCMETRIC_IPREFIXCOLUMNS: u32 = crate::bindings::IPREFIXCOLUMNS; // // Does not include a '\0' (xxx.xxU) -pub const PREFIXSTRLEN: u32 = crate::bindings::PREFIXSTRLEN; +pub const NCMETRIC_PREFIXSTRLEN: u32 = crate::bindings::PREFIXSTRLEN; // The maximum number of columns used by a mult == 1024 call making use of // the 'i' suffix. // Does not include a '\0' (xxxx.xxUi), i == prefix -pub const BPREFIXSTRLEN: u32 = crate::bindings::BPREFIXSTRLEN; +pub const NCMETRIC_BPREFIXSTRLEN: u32 = crate::bindings::BPREFIXSTRLEN; // Does not include a '\0' (xxxx.xxU) -pub const IPREFIXSTRLEN: u32 = crate::bindings::IPREFIXSTRLEN; +pub const NCMETRIC_IPREFIXSTRLEN: u32 = crate::bindings::IPREFIXSTRLEN; // TODO:? // WCHAR_MAX_UTF8BYTES diff --git a/rust/src/types/mod.rs b/rust/src/types/mod.rs index 23b2156ba..286d82ac8 100644 --- a/rust/src/types/mod.rs +++ b/rust/src/types/mod.rs @@ -31,10 +31,9 @@ pub use channel::{ NcAlphaBits, NcBlitSet, NcChannel, NcChannels, NcColor, NcFadeCtx, NcPalette, NcPaletteIndex, NcPixel, NcRgb, NCCHANNEL_ALPHA_MASK, }; -pub use file::{NcFile, FILE_LIBC, FILE_NC}; +pub use file::NcFile; pub use misc::{ - NcResult, BPREFIXCOLUMNS, BPREFIXSTRLEN, IPREFIXCOLUMNS, IPREFIXSTRLEN, PREFIXCOLUMNS, - PREFIXSTRLEN, + NcResult, NCMETRIC_BPREFIXCOLUMNS, NCMETRIC_BPREFIXSTRLEN, NCMETRIC_IPREFIXCOLUMNS, NCMETRIC_IPREFIXSTRLEN, NCMETRIC_PREFIXCOLUMNS, NCMETRIC_PREFIXSTRLEN, }; pub use plane::{ NCBLIT_1x1, NCBLIT_2x1, NCBLIT_2x2, NCBLIT_3x2, NCBLIT_4x1, NCBLIT_8x1, NcAlign, NcBlitter, diff --git a/rust/src/types/plane.rs b/rust/src/types/plane.rs index 12da23ad9..cf71004c9 100644 --- a/rust/src/types/plane.rs +++ b/rust/src/types/plane.rs @@ -32,16 +32,16 @@ pub type NcFdPlaneOptions = crate::ncfdplane_options; /// Left/right-justified, or centered. pub type NcAlign = crate::ncalign_e; -/// Align an NcPlane or NcTerm +/// Left alignment within an [`NcPlane`] or terminal. pub const NCALIGN_LEFT: NcAlign = crate::ncalign_e_NCALIGN_LEFT; -/// +/// Right alignment within an [`NcPlane`] or terminal. pub const NCALIGN_RIGHT: NcAlign = crate::ncalign_e_NCALIGN_RIGHT; -/// +/// Center alignment within an [`NcPlane`] or terminal. pub const NCALIGN_CENTER: NcAlign = crate::ncalign_e_NCALIGN_CENTER; -/// +/// Do not align an [`NcPlane`] or terminal. pub const NCALIGN_UNALIGNED: NcAlign = crate::ncalign_e_NCALIGN_UNALIGNED; /// Blitter Mode (`NCBLIT_*`) @@ -50,37 +50,37 @@ pub const NCALIGN_UNALIGNED: NcAlign = crate::ncalign_e_NCALIGN_UNALIGNED; /// background set to the desired foreground. pub type NcBlitter = crate::ncblitter_e; -/// space, compatible with ASCII +/// [`NcBlitter`] mode using: space, compatible with ASCII pub const NCBLIT_1x1: NcBlitter = crate::ncblitter_e_NCBLIT_1x1; -/// halves + 1x1 (space) +/// [`NcBlitter`] mode using: halves + 1x1 (space) /// ▄▀ pub const NCBLIT_2x1: NcBlitter = crate::ncblitter_e_NCBLIT_2x1; -/// quadrants + 2x1 +/// [`NcBlitter`] mode using: quadrants + 2x1 /// ▗▐ ▖▀▟▌▙ pub const NCBLIT_2x2: NcBlitter = crate::ncblitter_e_NCBLIT_2x2; -/// sextants (NOT 2x2) +/// [`NcBlitter`] mode using: sextants /// 🬀🬁🬂🬃🬄🬅🬆🬇🬈🬉🬊🬋🬌🬍🬎🬏🬐🬑🬒🬓🬔🬕🬖🬗🬘🬙🬚🬛🬜🬝🬞🬟🬠🬡🬢🬣🬤🬥🬦🬧🬨🬩🬪🬫🬬🬭🬮🬯🬰🬱🬲🬳🬴🬵🬶🬷🬸🬹🬺🬻 pub const NCBLIT_3x2: NcBlitter = crate::ncblitter_e_NCBLIT_3x2; -/// four vertical levels +/// [`NcBlitter`] mode using: four vertical levels /// █▆▄▂ pub const NCBLIT_4x1: NcBlitter = crate::ncblitter_e_NCBLIT_4x1; -/// eight vertical levels +/// [`NcBlitter`] mode using: eight vertical levels /// █▇▆▅▄▃▂▁ pub const NCBLIT_8x1: NcBlitter = crate::ncblitter_e_NCBLIT_8x1; -/// 4 rows, 2 cols (braille) +/// [`NcBlitter`] mode using: 4 rows, 2 cols (braille) /// ⡀⡄⡆⡇⢀⣀⣄⣆⣇⢠⣠⣤⣦⣧⢰⣰⣴⣶⣷⢸⣸⣼⣾⣿ pub const NCBLIT_BRAILLE: NcBlitter = crate::ncblitter_e_NCBLIT_BRAILLE; -/// the blitter is automatically chosen +/// [`NcBlitter`] mode where the blitter is automatically chosen pub const NCBLIT_DEFAULT: NcBlitter = crate::ncblitter_e_NCBLIT_DEFAULT; -/// not yet implemented +/// [`NcBlitter`] mode (not yet implemented) pub const NCBLIT_SIXEL: NcBlitter = crate::ncblitter_e_NCBLIT_SIXEL; /// How to scale an [`NcVisual`] during rendering