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
// Take a look at the license at the top of the repository in the LICENSE file.

use glib::translate::*;

/// A location in a parse buffer.
#[derive(Copy, Clone)]
#[repr(transparent)]
#[doc(alias = "GskParseLocation")]
pub struct ParseLocation(ffi::GskParseLocation);

impl ParseLocation {
    pub fn bytes(&self) -> usize {
        self.0.bytes
    }

    pub fn chars(&self) -> usize {
        self.0.chars
    }

    pub fn lines(&self) -> usize {
        self.0.lines
    }

    pub fn line_bytes(&self) -> usize {
        self.0.line_bytes
    }

    pub fn line_chars(&self) -> usize {
        self.0.line_chars
    }
}

#[doc(hidden)]
impl FromGlibPtrBorrow<*const ffi::GskParseLocation> for ParseLocation {
    unsafe fn from_glib_borrow(
        ptr: *const ffi::GskParseLocation,
    ) -> glib::translate::Borrowed<Self> {
        glib::translate::Borrowed::new(*(ptr as *const ParseLocation))
    }
}