Merge branch 'regenerate-gir-code' into 'master'

Regenerate gir code

See merge request World/Rust/libhandy-rs!3
This commit is contained in:
Jordan Petridis 2018-11-15 08:27:12 +00:00
commit 543c859ada
16 changed files with 1041 additions and 88 deletions

View file

@ -1,31 +1,46 @@
[package]
name = "libhandy"
authors = ["Julian Sparber <julian@sparber.net>"]
keywords = ["handy", "gtk-rs", "gnome"]
version = "0.2.0"
description = "Rust bindings for the libhandy"
exclude = [
"gir-files/*",
]
[build-dependencies]
pkg-config = "0.3.7"
[dependencies]
libc = "0.2.43"
bitflags = "1.0.4"
lazy_static = "1.1.0"
send-cell = { version = "0.1.4", optional = true }
futures-core = { version = "0.2.1", optional = true }
failure = "0.1.2"
notify-rust = "3.4.2"
glib-sys = "0.7.0"
gdk = "0.9.0"
gdk-sys = "0.7.0"
gio = "0.5.0"
gio-sys = "0.7.0"
glib = "0.6.0"
glib-sys = "0.7.0"
gobject-sys = "0.7.0"
gtk = "0.5.0"
gtk-sys = "0.7.0"
gobject-sys = "0.7.0"
gio = "0.5.0"
gdk = "0.9.0"
gio-sys = "0.7.0"
gdk-sys = "0.7.0"
lazy_static = "1.1.0"
libc = "0.2"
notify-rust = "3.4.2"
[dependencies.futures-core]
optional = true
version = "0.2.1"
[dependencies.handy-sys]
version = "0.2.0"
git = "https://gitlab.gnome.org/jsparber/libhandy-sys-rs"
version = "0.2.0"
[dependencies.send-cell]
optional = true
version = "0.1.4"
[dev-dependencies]
shell-words = "0.1.0"
tempdir = "0.3"
[features]
dox = []
[package]
authors = ["Julian Sparber <julian@sparber.net>"]
build = "build.rs"
description = "Rust bindings for the libhandy"
exclude = ["gir-files/*"]
keywords = ["handy", "gtk-rs", "gnome"]
name = "libhandy"
version = "0.2.0"

View file

@ -21,9 +21,11 @@ generate = ["Handy.Column",
"Handy.Dialer",
"Handy.DialerCycleButton",
"Handy.Fold",
"Handy.HeaderGroup",
"Handy.Leaflet",
"Handy.LeafletChildTransitionType",
"Handy.LeafletModeTransitionType",
"Handy.TitleBar",
"Handy.ArrowsDirection",
"Handy.Arrows"
]

62
build.rs Normal file
View file

@ -0,0 +1,62 @@
extern crate pkg_config;
use pkg_config::{Config, Error};
use std::env;
use std::io::prelude::*;
use std::io;
use std::process;
fn main() {
if let Err(s) = find() {
let _ = writeln!(io::stderr(), "{}", s);
process::exit(1);
}
}
fn find() -> Result<(), Error> {
let package_name = "libhandy-0.0";
let shared_libs = ["handy-0.0"];
let version = {
"0.0"
};
if let Ok(lib_dir) = env::var("GTK_LIB_DIR") {
for lib_ in shared_libs.iter() {
println!("cargo:rustc-link-lib=dylib={}", lib_);
}
println!("cargo:rustc-link-search=native={}", lib_dir);
return Ok(())
}
let target = env::var("TARGET").expect("TARGET environment variable doesn't exist");
let hardcode_shared_libs = target.contains("windows");
let mut config = Config::new();
config.atleast_version(version);
config.print_system_libs(false);
if hardcode_shared_libs {
config.cargo_metadata(false);
}
match config.probe(package_name) {
Ok(library) => {
if hardcode_shared_libs {
for lib_ in shared_libs.iter() {
println!("cargo:rustc-link-lib=dylib={}", lib_);
}
for path in library.link_paths.iter() {
println!("cargo:rustc-link-search=native={}",
path.to_str().expect("library path doesn't exist"));
}
}
Ok(())
}
Err(Error::EnvNoPkgConfig(_)) | Err(Error::Command { .. }) => {
for lib_ in shared_libs.iter() {
println!("cargo:rustc-link-lib=dylib={}", lib_);
}
Ok(())
}
Err(err) => Err(err),
}
}

View file

@ -51,10 +51,14 @@ pub trait DialerExt {
fn get_number(&self) -> Option<String>;
//fn get_relief(&self) -> /*Ignored*/gtk::ReliefStyle;
fn get_show_action_buttons(&self) -> bool;
fn set_number(&self, number: &str);
//fn set_relief(&self, relief: /*Ignored*/gtk::ReliefStyle);
fn set_show_action_buttons(&self, show: bool);
fn get_property_column_spacing(&self) -> u32;
@ -75,6 +79,8 @@ pub trait DialerExt {
fn connect_property_number_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
fn connect_property_relief_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
fn connect_property_row_spacing_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
fn connect_property_show_action_buttons_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
@ -93,6 +99,10 @@ impl<O: IsA<Dialer> + IsA<glib::object::Object>> DialerExt for O {
}
}
//fn get_relief(&self) -> /*Ignored*/gtk::ReliefStyle {
// unsafe { TODO: call ffi::hdy_dialer_get_relief() }
//}
fn get_show_action_buttons(&self) -> bool {
unsafe {
from_glib(ffi::hdy_dialer_get_show_action_buttons(self.to_glib_none().0))
@ -105,6 +115,10 @@ impl<O: IsA<Dialer> + IsA<glib::object::Object>> DialerExt for O {
}
}
//fn set_relief(&self, relief: /*Ignored*/gtk::ReliefStyle) {
// unsafe { TODO: call ffi::hdy_dialer_set_relief() }
//}
fn set_show_action_buttons(&self, show: bool) {
unsafe {
ffi::hdy_dialer_set_show_action_buttons(self.to_glib_none().0, show.to_glib());
@ -179,6 +193,14 @@ impl<O: IsA<Dialer> + IsA<glib::object::Object>> DialerExt for O {
}
}
fn connect_property_relief_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe {
let f: Box_<Box_<Fn(&Self) + 'static>> = Box_::new(Box_::new(f));
connect(self.to_glib_none().0, "notify::relief",
transmute(notify_relief_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
}
}
fn connect_property_row_spacing_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe {
let f: Box_<Box_<Fn(&Self) + 'static>> = Box_::new(Box_::new(f));
@ -226,6 +248,12 @@ where P: IsA<Dialer> {
f(&Dialer::from_glib_borrow(this).downcast_unchecked())
}
unsafe extern "C" fn notify_relief_trampoline<P>(this: *mut ffi::HdyDialer, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer)
where P: IsA<Dialer> {
let f: &&(Fn(&P) + 'static) = transmute(f);
f(&Dialer::from_glib_borrow(this).downcast_unchecked())
}
unsafe extern "C" fn notify_row_spacing_trampoline<P>(this: *mut ffi::HdyDialer, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer)
where P: IsA<Dialer> {
let f: &&(Fn(&P) + 'static) = transmute(f);

View file

@ -30,12 +30,12 @@ glib_wrapper! {
}
impl DialerButton {
pub fn new<'a, P: Into<Option<&'a str>>>(digit: i32, letters: P) -> DialerButton {
pub fn new<'a, P: Into<Option<&'a str>>>(symbols: P) -> DialerButton {
assert_initialized_main_thread!();
let letters = letters.into();
let letters = letters.to_glib_none();
let symbols = symbols.into();
let symbols = symbols.to_glib_none();
unsafe {
gtk::Widget::from_glib_none(ffi::hdy_dialer_button_new(digit, letters.0)).downcast_unchecked()
gtk::Widget::from_glib_none(ffi::hdy_dialer_button_new(symbols.0)).downcast_unchecked()
}
}
}
@ -43,15 +43,13 @@ impl DialerButton {
pub trait DialerButtonExt {
fn get_digit(&self) -> i32;
fn get_letters(&self) -> Option<String>;
fn get_symbols(&self) -> Option<String>;
fn set_property_digit(&self, digit: i32);
fn set_property_letters(&self, letters: Option<&str>);
fn set_property_symbols<'a, P: Into<Option<&'a str>>>(&self, symbols: P);
fn connect_property_digit_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
fn connect_property_letters_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
fn connect_property_symbols_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
}
impl<O: IsA<DialerButton> + IsA<glib::object::Object>> DialerButtonExt for O {
@ -61,21 +59,16 @@ impl<O: IsA<DialerButton> + IsA<glib::object::Object>> DialerButtonExt for O {
}
}
fn get_letters(&self) -> Option<String> {
fn get_symbols(&self) -> Option<String> {
unsafe {
from_glib_none(ffi::hdy_dialer_button_get_letters(self.to_glib_none().0))
from_glib_none(ffi::hdy_dialer_button_get_symbols(self.to_glib_none().0))
}
}
fn set_property_digit(&self, digit: i32) {
fn set_property_symbols<'a, P: Into<Option<&'a str>>>(&self, symbols: P) {
let symbols = symbols.into();
unsafe {
gobject_ffi::g_object_set_property(self.to_glib_none().0, "digit".to_glib_none().0, Value::from(&digit).to_glib_none().0);
}
}
fn set_property_letters(&self, letters: Option<&str>) {
unsafe {
gobject_ffi::g_object_set_property(self.to_glib_none().0, "letters".to_glib_none().0, Value::from(letters).to_glib_none().0);
gobject_ffi::g_object_set_property(self.to_glib_none().0, "symbols".to_glib_none().0, Value::from(symbols).to_glib_none().0);
}
}
@ -87,11 +80,11 @@ impl<O: IsA<DialerButton> + IsA<glib::object::Object>> DialerButtonExt for O {
}
}
fn connect_property_letters_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
fn connect_property_symbols_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe {
let f: Box_<Box_<Fn(&Self) + 'static>> = Box_::new(Box_::new(f));
connect(self.to_glib_none().0, "notify::letters",
transmute(notify_letters_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
connect(self.to_glib_none().0, "notify::symbols",
transmute(notify_symbols_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
}
}
}
@ -102,7 +95,7 @@ where P: IsA<DialerButton> {
f(&DialerButton::from_glib_borrow(this).downcast_unchecked())
}
unsafe extern "C" fn notify_letters_trampoline<P>(this: *mut ffi::HdyDialerButton, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer)
unsafe extern "C" fn notify_symbols_trampoline<P>(this: *mut ffi::HdyDialerButton, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer)
where P: IsA<DialerButton> {
let f: &&(Fn(&P) + 'static) = transmute(f);
f(&DialerButton::from_glib_borrow(this).downcast_unchecked())

90
src/auto/header_group.rs Normal file
View file

@ -0,0 +1,90 @@
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT
use ffi;
use glib;
use glib::object::Downcast;
use glib::object::IsA;
use glib::signal::SignalHandlerId;
use glib::signal::connect;
use glib::translate::*;
use glib_ffi;
use gobject_ffi;
use std::boxed::Box as Box_;
use std::mem;
use std::mem::transmute;
use std::ptr;
glib_wrapper! {
pub struct HeaderGroup(Object<ffi::HdyHeaderGroup, ffi::HdyHeaderGroupClass>);
match fn {
get_type => || ffi::hdy_header_group_get_type(),
}
}
impl HeaderGroup {
pub fn new() -> HeaderGroup {
assert_initialized_main_thread!();
unsafe {
from_glib_full(ffi::hdy_header_group_new())
}
}
}
impl Default for HeaderGroup {
fn default() -> Self {
Self::new()
}
}
pub trait HeaderGroupExt {
//fn add_header_bar(&self, header_bar: /*Ignored*/&gtk::HeaderBar);
//fn get_focus(&self) -> /*Ignored*/Option<gtk::HeaderBar>;
//fn get_header_bars(&self) -> /*Ignored*/Vec<gtk::HeaderBar>;
//fn remove_header_bar(&self, header_bar: /*Ignored*/&gtk::HeaderBar);
//fn set_focus<'a, P: Into<Option<&'a /*Ignored*/gtk::HeaderBar>>>(&self, header_bar: P);
fn connect_property_focus_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
}
impl<O: IsA<HeaderGroup> + IsA<glib::object::Object>> HeaderGroupExt for O {
//fn add_header_bar(&self, header_bar: /*Ignored*/&gtk::HeaderBar) {
// unsafe { TODO: call ffi::hdy_header_group_add_header_bar() }
//}
//fn get_focus(&self) -> /*Ignored*/Option<gtk::HeaderBar> {
// unsafe { TODO: call ffi::hdy_header_group_get_focus() }
//}
//fn get_header_bars(&self) -> /*Ignored*/Vec<gtk::HeaderBar> {
// unsafe { TODO: call ffi::hdy_header_group_get_header_bars() }
//}
//fn remove_header_bar(&self, header_bar: /*Ignored*/&gtk::HeaderBar) {
// unsafe { TODO: call ffi::hdy_header_group_remove_header_bar() }
//}
//fn set_focus<'a, P: Into<Option<&'a /*Ignored*/gtk::HeaderBar>>>(&self, header_bar: P) {
// unsafe { TODO: call ffi::hdy_header_group_set_focus() }
//}
fn connect_property_focus_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe {
let f: Box_<Box_<Fn(&Self) + 'static>> = Box_::new(Box_::new(f));
connect(self.to_glib_none().0, "notify::focus",
transmute(notify_focus_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
}
}
}
unsafe extern "C" fn notify_focus_trampoline<P>(this: *mut ffi::HdyHeaderGroup, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer)
where P: IsA<HeaderGroup> {
let f: &&(Fn(&P) + 'static) = transmute(f);
f(&HeaderGroup::from_glib_borrow(this).downcast_unchecked())
}

View file

@ -85,6 +85,8 @@ pub trait LeafletExt {
fn set_visible_child_name(&self, name: &str);
fn get_property_folded(&self) -> bool;
fn get_property_hhomogeneous_folded(&self) -> bool;
fn set_property_hhomogeneous_folded(&self, hhomogeneous_folded: bool);
@ -109,6 +111,8 @@ pub trait LeafletExt {
fn connect_property_fold_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
fn connect_property_folded_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
fn connect_property_hhomogeneous_folded_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
fn connect_property_hhomogeneous_unfolded_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
@ -237,6 +241,14 @@ impl<O: IsA<Leaflet> + IsA<glib::object::Object>> LeafletExt for O {
}
}
fn get_property_folded(&self) -> bool {
unsafe {
let mut value = Value::from_type(<bool as StaticType>::static_type());
gobject_ffi::g_object_get_property(self.to_glib_none().0, "folded".to_glib_none().0, value.to_glib_none_mut().0);
value.get().unwrap()
}
}
fn get_property_hhomogeneous_folded(&self) -> bool {
unsafe {
let mut value = Value::from_type(<bool as StaticType>::static_type());
@ -325,6 +337,14 @@ impl<O: IsA<Leaflet> + IsA<glib::object::Object>> LeafletExt for O {
}
}
fn connect_property_folded_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe {
let f: Box_<Box_<Fn(&Self) + 'static>> = Box_::new(Box_::new(f));
connect(self.to_glib_none().0, "notify::folded",
transmute(notify_folded_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
}
}
fn connect_property_hhomogeneous_folded_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe {
let f: Box_<Box_<Fn(&Self) + 'static>> = Box_::new(Box_::new(f));
@ -422,6 +442,12 @@ where P: IsA<Leaflet> {
f(&Leaflet::from_glib_borrow(this).downcast_unchecked())
}
unsafe extern "C" fn notify_folded_trampoline<P>(this: *mut ffi::HdyLeaflet, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer)
where P: IsA<Leaflet> {
let f: &&(Fn(&P) + 'static) = transmute(f);
f(&Leaflet::from_glib_borrow(this).downcast_unchecked())
}
unsafe extern "C" fn notify_hhomogeneous_folded_trampoline<P>(this: *mut ffi::HdyLeaflet, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer)
where P: IsA<Leaflet> {
let f: &&(Fn(&P) + 'static) = transmute(f);

View file

@ -22,10 +22,18 @@ mod dialer_cycle_button;
pub use self::dialer_cycle_button::DialerCycleButton;
pub use self::dialer_cycle_button::DialerCycleButtonExt;
mod header_group;
pub use self::header_group::HeaderGroup;
pub use self::header_group::HeaderGroupExt;
mod leaflet;
pub use self::leaflet::Leaflet;
pub use self::leaflet::LeafletExt;
mod title_bar;
pub use self::title_bar::TitleBar;
pub use self::title_bar::TitleBarExt;
mod enums;
pub use self::enums::ArrowsDirection;
pub use self::enums::Fold;
@ -39,5 +47,7 @@ pub mod traits {
pub use super::DialerExt;
pub use super::DialerButtonExt;
pub use super::DialerCycleButtonExt;
pub use super::HeaderGroupExt;
pub use super::LeafletExt;
pub use super::TitleBarExt;
}

80
src/auto/title_bar.rs Normal file
View file

@ -0,0 +1,80 @@
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT
use ffi;
use glib;
use glib::object::Downcast;
use glib::object::IsA;
use glib::signal::SignalHandlerId;
use glib::signal::connect;
use glib::translate::*;
use glib_ffi;
use gobject_ffi;
use gtk;
use gtk_ffi;
use std::boxed::Box as Box_;
use std::mem;
use std::mem::transmute;
use std::ptr;
glib_wrapper! {
pub struct TitleBar(Object<ffi::HdyTitleBar, ffi::HdyTitleBarClass>): [
gtk::Widget => gtk_ffi::GtkWidget,
];
match fn {
get_type => || ffi::hdy_title_bar_get_type(),
}
}
impl TitleBar {
pub fn new() -> TitleBar {
assert_initialized_main_thread!();
unsafe {
from_glib_none(ffi::hdy_title_bar_new())
}
}
}
impl Default for TitleBar {
fn default() -> Self {
Self::new()
}
}
pub trait TitleBarExt {
fn get_selection_mode(&self) -> bool;
fn set_selection_mode(&self, selection_mode: bool);
fn connect_property_selection_mode_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
}
impl<O: IsA<TitleBar> + IsA<glib::object::Object>> TitleBarExt for O {
fn get_selection_mode(&self) -> bool {
unsafe {
from_glib(ffi::hdy_title_bar_get_selection_mode(self.to_glib_none().0))
}
}
fn set_selection_mode(&self, selection_mode: bool) {
unsafe {
ffi::hdy_title_bar_set_selection_mode(self.to_glib_none().0, selection_mode.to_glib());
}
}
fn connect_property_selection_mode_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe {
let f: Box_<Box_<Fn(&Self) + 'static>> = Box_::new(Box_::new(f));
connect(self.to_glib_none().0, "notify::selection-mode",
transmute(notify_selection_mode_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
}
}
}
unsafe extern "C" fn notify_selection_mode_trampoline<P>(this: *mut ffi::HdyTitleBar, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer)
where P: IsA<TitleBar> {
let f: &&(Fn(&P) + 'static) = transmute(f);
f(&TitleBar::from_glib_borrow(this).downcast_unchecked())
}

View file

@ -1,2 +1,2 @@
Generated by gir (https://github.com/gtk-rs/gir @ f5fca82)
from gir-files (https://github.com/gtk-rs/gir-files @ b8f5ef1)
Generated by gir (https://github.com/gtk-rs/gir @ b5ea065)
from gir-files (https://github.com/gtk-rs/gir-files @ c49dfc7)

View file

@ -1,46 +1,385 @@
// Copyright 2018, The Gtk-rs Project Developers.
// See the COPYRIGHT file at the top-level directory of this distribution.
// Licensed under the MIT license, see the LICENSE file or <http://opensource.org/licenses/MIT>
// This file was generated by gir (https://github.com/gtk-rs/gir @ b5ea065)
// from gir-files (https://github.com/gtk-rs/gir-files @ c49dfc7)
// DO NOT EDIT
#![allow(deprecated)]
#![allow(dead_code)]
#![allow(non_camel_case_types, non_upper_case_globals, non_snake_case)]
#![cfg_attr(feature = "cargo-clippy", allow(approx_constant, type_complexity, unreadable_literal))]
extern crate glib_sys as glib_ffi;
extern crate gobject_sys as gobject_ffi;
extern crate gtk_sys as gtk_ffi;
extern crate handy_sys as ffi;
#[macro_use]
extern crate glib;
extern crate bitflags;
extern crate gdk;
extern crate gdk_sys as gdk_ffi;
extern crate gio;
extern crate gio_sys as gio_ffi;
extern crate gtk;
extern crate lazy_static;
extern crate libc;
extern crate glib_sys as glib;
extern crate gobject_sys as gobject;
extern crate gtk_sys as gtk;
/// Asserts that this is the main thread and `gtk::init` has been called.
macro_rules! assert_initialized_main_thread {
() => {
if !::gtk::is_initialized_main_thread() {
if ::gtk::is_initialized() {
panic!("Libhandy may only be used from the main thread.");
} else {
panic!("Gtk has to be initialized before using libhandy.");
}
}
};
mod rt;
pub use rt::*;
#[allow(unused_imports)]
use libc::{c_int, c_char, c_uchar, c_float, c_uint, c_double,
c_short, c_ushort, c_long, c_ulong,
c_void, size_t, ssize_t, intptr_t, uintptr_t, time_t, FILE};
#[allow(unused_imports)]
use glib::{gboolean, gconstpointer, gpointer, GType};
// Enums
pub type HdyArrowsDirection = c_int;
pub const HDY_ARROWS_DIRECTION_UP: HdyArrowsDirection = 0;
pub const HDY_ARROWS_DIRECTION_DOWN: HdyArrowsDirection = 1;
pub const HDY_ARROWS_DIRECTION_LEFT: HdyArrowsDirection = 2;
pub const HDY_ARROWS_DIRECTION_RIGHT: HdyArrowsDirection = 3;
pub type HdyFold = c_int;
pub const HDY_FOLD_UNFOLDED: HdyFold = 0;
pub const HDY_FOLD_FOLDED: HdyFold = 1;
pub type HdyLeafletChildTransitionType = c_int;
pub const HDY_LEAFLET_CHILD_TRANSITION_TYPE_NONE: HdyLeafletChildTransitionType = 0;
pub const HDY_LEAFLET_CHILD_TRANSITION_TYPE_CROSSFADE: HdyLeafletChildTransitionType = 1;
pub const HDY_LEAFLET_CHILD_TRANSITION_TYPE_SLIDE: HdyLeafletChildTransitionType = 2;
pub const HDY_LEAFLET_CHILD_TRANSITION_TYPE_OVER: HdyLeafletChildTransitionType = 3;
pub type HdyLeafletModeTransitionType = c_int;
pub const HDY_LEAFLET_MODE_TRANSITION_TYPE_NONE: HdyLeafletModeTransitionType = 0;
pub const HDY_LEAFLET_MODE_TRANSITION_TYPE_SLIDE: HdyLeafletModeTransitionType = 1;
// Records
#[repr(C)]
#[derive(Copy, Clone)]
pub struct HdyArrowsClass {
pub parent_class: gtk::GtkDrawingAreaClass,
}
macro_rules! skip_assert_initialized {
() => {};
impl ::std::fmt::Debug for HdyArrowsClass {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("HdyArrowsClass @ {:?}", self as *const _))
.field("parent_class", &self.parent_class)
.finish()
}
}
pub use glib::Error;
#[cfg_attr(feature = "cargo-clippy", allow(too_many_arguments))]
#[cfg_attr(feature = "cargo-clippy", allow(useless_transmute))]
mod auto;
/*mod manual;*/
pub use auto::*;
/* pub use manual::*; */
#[repr(C)]
pub struct HdyColumnClass {
_truncated_record_marker: c_void,
// /*Ignored*/field parent_class has incomplete type
}
impl ::std::fmt::Debug for HdyColumnClass {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("HdyColumnClass @ {:?}", self as *const _))
.finish()
}
}
#[repr(C)]
pub struct HdyDialerButtonClass {
_truncated_record_marker: c_void,
// /*Ignored*/field parent_class has incomplete type
}
impl ::std::fmt::Debug for HdyDialerButtonClass {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("HdyDialerButtonClass @ {:?}", self as *const _))
.finish()
}
}
#[repr(C)]
pub struct HdyDialerClass {
_truncated_record_marker: c_void,
// /*Ignored*/field parent_class has incomplete type
}
impl ::std::fmt::Debug for HdyDialerClass {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("HdyDialerClass @ {:?}", self as *const _))
.finish()
}
}
#[repr(C)]
pub struct HdyDialerCycleButtonClass {
_truncated_record_marker: c_void,
// /*Ignored*/field parent_class has incomplete type
}
impl ::std::fmt::Debug for HdyDialerCycleButtonClass {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("HdyDialerCycleButtonClass @ {:?}", self as *const _))
.finish()
}
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct HdyHeaderGroupClass {
pub parent_class: gobject::GObjectClass,
}
impl ::std::fmt::Debug for HdyHeaderGroupClass {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("HdyHeaderGroupClass @ {:?}", self as *const _))
.field("parent_class", &self.parent_class)
.finish()
}
}
#[repr(C)]
pub struct HdyLeafletClass {
_truncated_record_marker: c_void,
// /*Ignored*/field parent_class has incomplete type
}
impl ::std::fmt::Debug for HdyLeafletClass {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("HdyLeafletClass @ {:?}", self as *const _))
.finish()
}
}
#[repr(C)]
pub struct HdyTitleBarClass {
_truncated_record_marker: c_void,
// /*Ignored*/field parent_class has incomplete type
}
impl ::std::fmt::Debug for HdyTitleBarClass {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("HdyTitleBarClass @ {:?}", self as *const _))
.finish()
}
}
// Classes
#[repr(C)]
#[derive(Copy, Clone)]
pub struct HdyArrows {
pub parent_instance: gtk::GtkDrawingArea,
}
impl ::std::fmt::Debug for HdyArrows {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("HdyArrows @ {:?}", self as *const _))
.field("parent_instance", &self.parent_instance)
.finish()
}
}
#[repr(C)]
pub struct HdyColumn(c_void);
impl ::std::fmt::Debug for HdyColumn {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("HdyColumn @ {:?}", self as *const _))
.finish()
}
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct HdyDialer {
pub parent_instance: gtk::GtkBin,
}
impl ::std::fmt::Debug for HdyDialer {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("HdyDialer @ {:?}", self as *const _))
.field("parent_instance", &self.parent_instance)
.finish()
}
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct HdyDialerButton {
pub parent_instance: gtk::GtkButton,
}
impl ::std::fmt::Debug for HdyDialerButton {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("HdyDialerButton @ {:?}", self as *const _))
.field("parent_instance", &self.parent_instance)
.finish()
}
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct HdyDialerCycleButton {
pub parent_instance: HdyDialerButton,
}
impl ::std::fmt::Debug for HdyDialerCycleButton {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("HdyDialerCycleButton @ {:?}", self as *const _))
.field("parent_instance", &self.parent_instance)
.finish()
}
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct HdyHeaderGroup {
pub parent_instance: gobject::GObject,
}
impl ::std::fmt::Debug for HdyHeaderGroup {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("HdyHeaderGroup @ {:?}", self as *const _))
.field("parent_instance", &self.parent_instance)
.finish()
}
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct HdyLeaflet {
pub parent_instance: gtk::GtkContainer,
}
impl ::std::fmt::Debug for HdyLeaflet {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("HdyLeaflet @ {:?}", self as *const _))
.field("parent_instance", &self.parent_instance)
.finish()
}
}
#[repr(C)]
pub struct HdyTitleBar(c_void);
impl ::std::fmt::Debug for HdyTitleBar {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("HdyTitleBar @ {:?}", self as *const _))
.finish()
}
}
extern "C" {
//=========================================================================
// HdyArrowsDirection
//=========================================================================
pub fn hdy_arrows_direction_get_type() -> GType;
//=========================================================================
// HdyFold
//=========================================================================
pub fn hdy_fold_get_type() -> GType;
//=========================================================================
// HdyLeafletChildTransitionType
//=========================================================================
pub fn hdy_leaflet_child_transition_type_get_type() -> GType;
//=========================================================================
// HdyLeafletModeTransitionType
//=========================================================================
pub fn hdy_leaflet_mode_transition_type_get_type() -> GType;
//=========================================================================
// HdyArrows
//=========================================================================
pub fn hdy_arrows_get_type() -> GType;
pub fn hdy_arrows_new() -> *mut gtk::GtkWidget;
pub fn hdy_arrows_animate(self_: *mut HdyArrows);
pub fn hdy_arrows_get_count(self_: *mut HdyArrows) -> c_uint;
pub fn hdy_arrows_get_direction(self_: *mut HdyArrows) -> HdyArrowsDirection;
pub fn hdy_arrows_get_duration(self_: *mut HdyArrows) -> c_uint;
pub fn hdy_arrows_set_count(self_: *mut HdyArrows, count: c_uint);
pub fn hdy_arrows_set_direction(self_: *mut HdyArrows, direction: HdyArrowsDirection);
pub fn hdy_arrows_set_duration(self_: *mut HdyArrows, duration: c_uint);
//=========================================================================
// HdyColumn
//=========================================================================
pub fn hdy_column_get_type() -> GType;
pub fn hdy_column_new() -> *mut HdyColumn;
pub fn hdy_column_get_linear_growth_width(self_: *mut HdyColumn) -> c_int;
pub fn hdy_column_get_maximum_width(self_: *mut HdyColumn) -> c_int;
pub fn hdy_column_set_linear_growth_width(self_: *mut HdyColumn, linear_growth_width: c_int);
pub fn hdy_column_set_maximum_width(self_: *mut HdyColumn, maximum_width: c_int);
//=========================================================================
// HdyDialer
//=========================================================================
pub fn hdy_dialer_get_type() -> GType;
pub fn hdy_dialer_new() -> *mut gtk::GtkWidget;
pub fn hdy_dialer_clear_number(self_: *mut HdyDialer);
pub fn hdy_dialer_get_number(self_: *mut HdyDialer) -> *const c_char;
pub fn hdy_dialer_get_relief(self_: *mut HdyDialer) -> gtk::GtkReliefStyle;
pub fn hdy_dialer_get_show_action_buttons(self_: *mut HdyDialer) -> gboolean;
pub fn hdy_dialer_set_number(self_: *mut HdyDialer, number: *const c_char);
pub fn hdy_dialer_set_relief(self_: *mut HdyDialer, relief: gtk::GtkReliefStyle);
pub fn hdy_dialer_set_show_action_buttons(self_: *mut HdyDialer, show: gboolean);
//=========================================================================
// HdyDialerButton
//=========================================================================
pub fn hdy_dialer_button_get_type() -> GType;
pub fn hdy_dialer_button_new(symbols: *const c_char) -> *mut gtk::GtkWidget;
pub fn hdy_dialer_button_get_digit(self_: *mut HdyDialerButton) -> c_int;
pub fn hdy_dialer_button_get_symbols(self_: *mut HdyDialerButton) -> *const c_char;
//=========================================================================
// HdyDialerCycleButton
//=========================================================================
pub fn hdy_dialer_cycle_button_get_type() -> GType;
pub fn hdy_dialer_cycle_button_new(symbols: *const c_char) -> *mut gtk::GtkWidget;
pub fn hdy_dialer_cycle_button_get_current_symbol(self_: *mut HdyDialerCycleButton) -> u32;
pub fn hdy_dialer_cycle_button_get_cycle_timeout(self_: *mut HdyDialerCycleButton) -> c_int;
pub fn hdy_dialer_cycle_button_is_cycling(self_: *mut HdyDialerCycleButton) -> gboolean;
pub fn hdy_dialer_cycle_button_set_cycle_timeout(self_: *mut HdyDialerCycleButton, timeout: c_int);
pub fn hdy_dialer_cycle_button_stop_cycle(self_: *mut HdyDialerCycleButton);
//=========================================================================
// HdyHeaderGroup
//=========================================================================
pub fn hdy_header_group_get_type() -> GType;
pub fn hdy_header_group_new() -> *mut HdyHeaderGroup;
pub fn hdy_header_group_add_header_bar(self_: *mut HdyHeaderGroup, header_bar: *mut gtk::GtkHeaderBar);
pub fn hdy_header_group_get_focus(self_: *mut HdyHeaderGroup) -> *mut gtk::GtkHeaderBar;
pub fn hdy_header_group_get_header_bars(self_: *mut HdyHeaderGroup) -> *mut glib::GSList;
pub fn hdy_header_group_remove_header_bar(self_: *mut HdyHeaderGroup, header_bar: *mut gtk::GtkHeaderBar);
pub fn hdy_header_group_set_focus(self_: *mut HdyHeaderGroup, header_bar: *mut gtk::GtkHeaderBar);
//=========================================================================
// HdyLeaflet
//=========================================================================
pub fn hdy_leaflet_get_type() -> GType;
pub fn hdy_leaflet_new() -> *mut gtk::GtkWidget;
pub fn hdy_leaflet_get_child_transition_duration(self_: *mut HdyLeaflet) -> c_uint;
pub fn hdy_leaflet_get_child_transition_running(self_: *mut HdyLeaflet) -> gboolean;
pub fn hdy_leaflet_get_child_transition_type(self_: *mut HdyLeaflet) -> HdyLeafletChildTransitionType;
pub fn hdy_leaflet_get_fold(self_: *mut HdyLeaflet) -> HdyFold;
pub fn hdy_leaflet_get_homogeneous(self_: *mut HdyLeaflet, fold: HdyFold, orientation: gtk::GtkOrientation) -> gboolean;
pub fn hdy_leaflet_get_interpolate_size(self_: *mut HdyLeaflet) -> gboolean;
pub fn hdy_leaflet_get_mode_transition_duration(self_: *mut HdyLeaflet) -> c_uint;
pub fn hdy_leaflet_get_mode_transition_type(self_: *mut HdyLeaflet) -> HdyLeafletModeTransitionType;
pub fn hdy_leaflet_get_visible_child(self_: *mut HdyLeaflet) -> *mut gtk::GtkWidget;
pub fn hdy_leaflet_get_visible_child_name(self_: *mut HdyLeaflet) -> *const c_char;
pub fn hdy_leaflet_set_child_transition_duration(self_: *mut HdyLeaflet, duration: c_uint);
pub fn hdy_leaflet_set_child_transition_type(self_: *mut HdyLeaflet, transition: HdyLeafletChildTransitionType);
pub fn hdy_leaflet_set_homogeneous(self_: *mut HdyLeaflet, fold: HdyFold, orientation: gtk::GtkOrientation, homogeneous: gboolean);
pub fn hdy_leaflet_set_interpolate_size(self_: *mut HdyLeaflet, interpolate_size: gboolean);
pub fn hdy_leaflet_set_mode_transition_duration(self_: *mut HdyLeaflet, duration: c_uint);
pub fn hdy_leaflet_set_mode_transition_type(self_: *mut HdyLeaflet, transition: HdyLeafletModeTransitionType);
pub fn hdy_leaflet_set_visible_child(self_: *mut HdyLeaflet, visible_child: *mut gtk::GtkWidget);
pub fn hdy_leaflet_set_visible_child_name(self_: *mut HdyLeaflet, name: *const c_char);
//=========================================================================
// HdyTitleBar
//=========================================================================
pub fn hdy_title_bar_get_type() -> GType;
pub fn hdy_title_bar_new() -> *mut HdyTitleBar;
pub fn hdy_title_bar_get_selection_mode(self_: *mut HdyTitleBar) -> gboolean;
pub fn hdy_title_bar_set_selection_mode(self_: *mut HdyTitleBar, selection_mode: gboolean);
//=========================================================================
// Other functions
//=========================================================================
pub fn hdy_init(argc: *mut c_int, argv: *mut *mut *mut c_char) -> gboolean;
pub fn hdy_string_utf8_len(string: *mut glib::GString) -> c_long;
pub fn hdy_string_utf8_truncate(string: *mut glib::GString, len: size_t) -> *mut glib::GString;
}

View file

@ -2,10 +2,13 @@
// See the COPYRIGHT file at the top-level directory of this distribution.
// Licensed under the MIT license, see the LICENSE file or <http://opensource.org/licenses/MIT>
use gdk;
use glib;
use glib::translate::*;
use gtk_ffi;
// lib.rs imports these under aliases
extern crate glib;
extern crate gdk;
use self::glib::translate::*;
// Re-alias from gtk_sys -> gtk -> gtk_ffi
use gtk as gtk_ffi;
use libc::{c_int, c_uint};
use std::cell::Cell;
use std::env;

263
tests/abi.rs Normal file
View file

@ -0,0 +1,263 @@
// This file was generated by gir (https://github.com/gtk-rs/gir @ b5ea065)
// from gir-files (https://github.com/gtk-rs/gir-files @ c49dfc7)
// DO NOT EDIT
extern crate libhandy;
extern crate shell_words;
extern crate tempdir;
use std::env;
use std::error::Error;
use std::path::Path;
use std::mem::{align_of, size_of};
use std::process::Command;
use std::str;
use libhandy::*;
static PACKAGES: &[&str] = &["libhandy-0.0"];
#[derive(Clone, Debug)]
struct Compiler {
pub args: Vec<String>,
}
impl Compiler {
pub fn new() -> Result<Compiler, Box<Error>> {
let mut args = get_var("CC", "cc")?;
args.push("-Wno-deprecated-declarations".to_owned());
// For %z support in printf when using MinGW.
args.push("-D__USE_MINGW_ANSI_STDIO".to_owned());
args.extend(get_var("CFLAGS", "")?);
args.extend(get_var("CPPFLAGS", "")?);
args.extend(pkg_config_cflags(PACKAGES)?);
Ok(Compiler { args })
}
pub fn define<'a, V: Into<Option<&'a str>>>(&mut self, var: &str, val: V) {
let arg = match val.into() {
None => format!("-D{}", var),
Some(val) => format!("-D{}={}", var, val),
};
self.args.push(arg);
}
pub fn compile(&self, src: &Path, out: &Path) -> Result<(), Box<Error>> {
let mut cmd = self.to_command();
cmd.arg(src);
cmd.arg("-o");
cmd.arg(out);
let status = cmd.spawn()?.wait()?;
if !status.success() {
return Err(format!("compilation command {:?} failed, {}",
&cmd, status).into());
}
Ok(())
}
fn to_command(&self) -> Command {
let mut cmd = Command::new(&self.args[0]);
cmd.args(&self.args[1..]);
cmd
}
}
fn get_var(name: &str, default: &str) -> Result<Vec<String>, Box<Error>> {
match env::var(name) {
Ok(value) => Ok(shell_words::split(&value)?),
Err(env::VarError::NotPresent) => Ok(shell_words::split(default)?),
Err(err) => Err(format!("{} {}", name, err).into()),
}
}
fn pkg_config_cflags(packages: &[&str]) -> Result<Vec<String>, Box<Error>> {
if packages.is_empty() {
return Ok(Vec::new());
}
let mut cmd = Command::new("pkg-config");
cmd.arg("--cflags");
cmd.args(packages);
let out = cmd.output()?;
if !out.status.success() {
return Err(format!("command {:?} returned {}",
&cmd, out.status).into());
}
let stdout = str::from_utf8(&out.stdout)?;
Ok(shell_words::split(stdout.trim())?)
}
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
struct Layout {
size: usize,
alignment: usize,
}
#[derive(Copy, Clone, Debug, Default, Eq, PartialEq)]
struct Results {
/// Number of successfully completed tests.
passed: usize,
/// Total number of failed tests (including those that failed to compile).
failed: usize,
/// Number of tests that failed to compile.
failed_to_compile: usize,
}
impl Results {
fn record_passed(&mut self) {
self.passed += 1;
}
fn record_failed(&mut self) {
self.failed += 1;
}
fn record_failed_to_compile(&mut self) {
self.failed += 1;
self.failed_to_compile += 1;
}
fn summary(&self) -> String {
format!(
"{} passed; {} failed (compilation errors: {})",
self.passed,
self.failed,
self.failed_to_compile)
}
fn expect_total_success(&self) {
if self.failed == 0 {
println!("OK: {}", self.summary());
} else {
panic!("FAILED: {}", self.summary());
};
}
}
#[test]
fn cross_validate_constants_with_c() {
let tmpdir = tempdir::TempDir::new("abi").expect("temporary directory");
let cc = Compiler::new().expect("configured compiler");
assert_eq!("1",
get_c_value(tmpdir.path(), &cc, "1").expect("C constant"),
"failed to obtain correct constant value for 1");
let mut results : Results = Default::default();
for (i, &(name, rust_value)) in RUST_CONSTANTS.iter().enumerate() {
match get_c_value(tmpdir.path(), &cc, name) {
Err(e) => {
results.record_failed_to_compile();
eprintln!("{}", e);
},
Ok(ref c_value) => {
if rust_value == c_value {
results.record_passed();
} else {
results.record_failed();
eprintln!("Constant value mismatch for {}\nRust: {:?}\nC: {:?}",
name, rust_value, c_value);
}
}
};
if (i + 1) % 25 == 0 {
println!("constants ... {}", results.summary());
}
}
results.expect_total_success();
}
#[test]
fn cross_validate_layout_with_c() {
let tmpdir = tempdir::TempDir::new("abi").expect("temporary directory");
let cc = Compiler::new().expect("configured compiler");
assert_eq!(Layout {size: 1, alignment: 1},
get_c_layout(tmpdir.path(), &cc, "char").expect("C layout"),
"failed to obtain correct layout for char type");
let mut results : Results = Default::default();
for (i, &(name, rust_layout)) in RUST_LAYOUTS.iter().enumerate() {
match get_c_layout(tmpdir.path(), &cc, name) {
Err(e) => {
results.record_failed_to_compile();
eprintln!("{}", e);
},
Ok(c_layout) => {
if rust_layout == c_layout {
results.record_passed();
} else {
results.record_failed();
eprintln!("Layout mismatch for {}\nRust: {:?}\nC: {:?}",
name, rust_layout, &c_layout);
}
}
};
if (i + 1) % 25 == 0 {
println!("layout ... {}", results.summary());
}
}
results.expect_total_success();
}
fn get_c_layout(dir: &Path, cc: &Compiler, name: &str) -> Result<Layout, Box<Error>> {
let exe = dir.join("layout");
let mut cc = cc.clone();
cc.define("ABI_TYPE_NAME", name);
cc.compile(Path::new("tests/layout.c"), &exe)?;
let mut abi_cmd = Command::new(exe);
let output = abi_cmd.output()?;
if !output.status.success() {
return Err(format!("command {:?} failed, {:?}",
&abi_cmd, &output).into());
}
let stdout = str::from_utf8(&output.stdout)?;
let mut words = stdout.trim().split_whitespace();
let size = words.next().unwrap().parse().unwrap();
let alignment = words.next().unwrap().parse().unwrap();
Ok(Layout {size, alignment})
}
fn get_c_value(dir: &Path, cc: &Compiler, name: &str) -> Result<String, Box<Error>> {
let exe = dir.join("constant");
let mut cc = cc.clone();
cc.define("ABI_CONSTANT_NAME", name);
cc.compile(Path::new("tests/constant.c"), &exe)?;
let mut abi_cmd = Command::new(exe);
let output = abi_cmd.output()?;
if !output.status.success() {
return Err(format!("command {:?} failed, {:?}",
&abi_cmd, &output).into());
}
Ok(str::from_utf8(&output.stdout)?.trim().to_owned())
}
const RUST_LAYOUTS: &[(&str, Layout)] = &[
("HdyArrows", Layout {size: size_of::<HdyArrows>(), alignment: align_of::<HdyArrows>()}),
("HdyArrowsClass", Layout {size: size_of::<HdyArrowsClass>(), alignment: align_of::<HdyArrowsClass>()}),
("HdyArrowsDirection", Layout {size: size_of::<HdyArrowsDirection>(), alignment: align_of::<HdyArrowsDirection>()}),
("HdyDialer", Layout {size: size_of::<HdyDialer>(), alignment: align_of::<HdyDialer>()}),
("HdyDialerButton", Layout {size: size_of::<HdyDialerButton>(), alignment: align_of::<HdyDialerButton>()}),
("HdyDialerCycleButton", Layout {size: size_of::<HdyDialerCycleButton>(), alignment: align_of::<HdyDialerCycleButton>()}),
("HdyFold", Layout {size: size_of::<HdyFold>(), alignment: align_of::<HdyFold>()}),
("HdyHeaderGroup", Layout {size: size_of::<HdyHeaderGroup>(), alignment: align_of::<HdyHeaderGroup>()}),
("HdyHeaderGroupClass", Layout {size: size_of::<HdyHeaderGroupClass>(), alignment: align_of::<HdyHeaderGroupClass>()}),
("HdyLeaflet", Layout {size: size_of::<HdyLeaflet>(), alignment: align_of::<HdyLeaflet>()}),
("HdyLeafletChildTransitionType", Layout {size: size_of::<HdyLeafletChildTransitionType>(), alignment: align_of::<HdyLeafletChildTransitionType>()}),
("HdyLeafletModeTransitionType", Layout {size: size_of::<HdyLeafletModeTransitionType>(), alignment: align_of::<HdyLeafletModeTransitionType>()}),
];
const RUST_CONSTANTS: &[(&str, &str)] = &[
("HDY_ARROWS_DIRECTION_DOWN", "1"),
("HDY_ARROWS_DIRECTION_LEFT", "2"),
("HDY_ARROWS_DIRECTION_RIGHT", "3"),
("HDY_ARROWS_DIRECTION_UP", "0"),
("HDY_FOLD_FOLDED", "1"),
("HDY_FOLD_UNFOLDED", "0"),
("HDY_LEAFLET_CHILD_TRANSITION_TYPE_CROSSFADE", "1"),
("HDY_LEAFLET_CHILD_TRANSITION_TYPE_NONE", "0"),
("HDY_LEAFLET_CHILD_TRANSITION_TYPE_OVER", "3"),
("HDY_LEAFLET_CHILD_TRANSITION_TYPE_SLIDE", "2"),
("HDY_LEAFLET_MODE_TRANSITION_TYPE_NONE", "0"),
("HDY_LEAFLET_MODE_TRANSITION_TYPE_SLIDE", "1"),
];

27
tests/constant.c Normal file
View file

@ -0,0 +1,27 @@
// This file was generated by gir (https://github.com/gtk-rs/gir @ b5ea065)
// from gir-files (https://github.com/gtk-rs/gir-files @ c49dfc7)
// DO NOT EDIT
#include "manual.h"
#include <stdio.h>
int main() {
printf(_Generic((ABI_CONSTANT_NAME),
char *: "%s",
const char *: "%s",
char: "%c",
signed char: "%hhd",
unsigned char: "%hhu",
short int: "%hd",
unsigned short int: "%hu",
int: "%d",
unsigned int: "%u",
long: "%ld",
unsigned long: "%lu",
long long: "%lld",
unsigned long long: "%llu",
double: "%f",
long double: "%ld"),
ABI_CONSTANT_NAME);
return 0;
}

12
tests/layout.c Normal file
View file

@ -0,0 +1,12 @@
// This file was generated by gir (https://github.com/gtk-rs/gir @ b5ea065)
// from gir-files (https://github.com/gtk-rs/gir-files @ c49dfc7)
// DO NOT EDIT
#include "manual.h"
#include <stdalign.h>
#include <stdio.h>
int main() {
printf("%zu\n%zu", sizeof(ABI_TYPE_NAME), alignof(ABI_TYPE_NAME));
return 0;
}

3
tests/manual.h Normal file
View file

@ -0,0 +1,3 @@
// Feel free to edit this file, it won't be regenerated by gir generator unless removed.
#define HANDY_USE_UNSTABLE_API
#include <handy.h>