File: enum_self_flags.rs

package info (click to toggle)
rust-cbindgen 0.29.2-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,248 kB
  • sloc: ansic: 15; makefile: 11
file content (65 lines) | stat: -rw-r--r-- 2,015 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/// A three-bit value that represents the axis in which position-area operates on.
/// Represented as 3 bits: axis type (physical or logical), direction type (physical or logical),
/// axis value.
#[repr(u8)]
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
#[allow(missing_docs)]
pub enum PositionAreaAxis {
    Horizontal = 0b000,
    Vertical = 0b001,

    X = 0b010,
    Y = 0b011,

    Inline = 0b110,
    Block = 0b111,
}

/// Specifies which tracks(s) on the axis that the position-area span occupies.
/// Represented as 3 bits: start, center, end track.
#[repr(u8)]
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum PositionAreaTrack {
    /// First track
    Start = 0b001,
    /// First and center.
    SpanStart = 0b011,
    /// Last track.
    End = 0b100,
    /// Last and center.
    SpanEnd = 0b110,
    /// Center track.
    Center = 0b010,
    /// All tracks
    SpanAll = 0b111,
}

pub const AXIS_SHIFT: usize = 3;
pub const SELF_WM_SHIFT: usize = 6;
pub const SELF_WM: u8 = 1u8 << 6;

#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
#[allow(missing_docs)]
#[repr(u8)]
/// Possible values for the `position-area` property's keywords.
/// Represented by [0z xxx yyy], where z means "self wm resolution", xxx is the type (as in
/// PositionAreaAxis and yyy is the PositionAreaTrack
/// https://drafts.csswg.org/css-anchor-position-1/#propdef-position-area
pub enum PositionAreaKeyword {
    #[default]
    None = 0,

    Center = PositionAreaTrack::Center as u8,
    SpanAll = PositionAreaTrack::SpanAll as u8,

    Start = PositionAreaTrack::Start as u8,
    End = PositionAreaTrack::End as u8,
    SpanStart = PositionAreaTrack::SpanStart as u8,
    SpanEnd = PositionAreaTrack::SpanEnd as u8,

    Top = ((PositionAreaAxis::Vertical as u8) << AXIS_SHIFT) | PositionAreaTrack::Start as u8,
    Bottom = ((PositionAreaAxis::Vertical as u8) << AXIS_SHIFT) | PositionAreaTrack::End as u8,
}

#[no_mangle]
extern "C" fn root(_: PositionAreaKeyword, _: PositionAreaTrack, _: PositionAreaAxis) {}