Giter Site home page Giter Site logo

odilia-app / atspi-rs Goto Github PK

View Code? Open in Web Editor NEW
5.0 2.0 0.0 684 KB

Gnome's at-spi (Assistive Technology Service Provider Interface) bindings for Rust.

License: GNU Lesser General Public License v2.1

Rust 93.49% C 6.51%
glib gobject introspection gir at-spi atspi screen reader accessibility wrapper

atspi-rs's People

Contributors

mcb2003 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

atspi-rs's Issues

How to get the inner AtspiRect in Rect?

In components.rs:

fn extents(&self, ctype: CoordType) -> Result<Rect, glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let ret = ffi::atspi_component_get_extents(self.as_ref().to_glib_none().0, ctype.into_glib(), &mut error);
if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) }
}
}

ret has type AtspiRect, which is defined in sys/lib.rs:

atspi-rs/sys/src/lib.rs

Lines 669 to 674 in 83c96bc

pub struct AtspiRect {
pub x: c_int,
pub y: c_int,
pub width: c_int,
pub height: c_int,
}

I want to get the fields and they're public, which is good. But ret is wrapped into type Rect, which is returned instead. Rect is defined in rect.rs:

glib::wrapper! {
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct Rect(Boxed<ffi::AtspiRect>);
match fn {
copy => |ptr| glib::gobject_ffi::g_boxed_copy(ffi::atspi_rect_get_type(), ptr as *mut _) as *mut ffi::AtspiRect,
free => |ptr| glib::gobject_ffi::g_boxed_free(ffi::atspi_rect_get_type(), ptr as *mut _),
type_ => || ffi::atspi_rect_get_type(),
}
}

The only field is private, and there are no methods to interact with the inner AtspiRect, according to https://gtk-rs.org/gtk-rs-core/stable/latest/docs/glib/macro.wrapper.html. cargo expand also shows that the copy method takes *const ffi::AtspiRect (but how do I get it?), and it is private anyway.

If the extents method directly returned ret, I could dereference it and then get the fields. Dereferencing a raw pointer is unsafe, because IIRC gtk is ref-counted so there is definitely a potential for memory safety issues. But how I am supposed to work with Rect, which seems to be a completely opaque type?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.