aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>2022-03-17 18:12:19 +0900
committer坂本 貴史 <o-takashi@sakamocchi.jp>2022-03-18 11:17:29 +0900
commit1fc1ef09fe7c21a30012e5c49c58f401123bc59b (patch)
tree4e90b49984c8c738adce0476e98e48d66c350865
parent8f4c9616041743ddf52431fef78d3d88cc806be6 (diff)
downloadhinoko-rs-1fc1ef09fe7c21a30012e5c49c58f401123bc59b.tar.gz
hinoko-sys: regenerate FFI crate
This commit regenerates FFI crate. Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
-rw-r--r--README.rst5
-rw-r--r--hinoko-sys/Cargo.toml30
-rw-r--r--hinoko-sys/Gir.toml (renamed from conf/gir-hinoko-sys.toml)1
-rw-r--r--hinoko-sys/build.rs70
-rw-r--r--hinoko-sys/src/lib.rs416
-rw-r--r--hinoko-sys/tests/abi.rs348
-rw-r--r--hinoko-sys/tests/constant.c68
-rw-r--r--hinoko-sys/tests/layout.c19
-rw-r--r--hinoko-sys/tests/manual.h10
-rw-r--r--hinoko-sys/versions.txt4
10 files changed, 616 insertions, 355 deletions
diff --git a/README.rst b/README.rst
index 777b560..ab3f736 100644
--- a/README.rst
+++ b/README.rst
@@ -22,6 +22,11 @@ Dependencies
* Rust version 1.57 or later (edition 2021)
* `libhinoko <https://github.com/takaswie/libhinoko>`_
+* FFI crate (``hinoko-sys``)
+
+ * ``libc`` >= 0.2
+ * ``glib-sys`` >= 0.15
+ * ``gobject-sys`` >= 0.15
How to generate FFI and API crates
==================================
diff --git a/hinoko-sys/Cargo.toml b/hinoko-sys/Cargo.toml
index 2a03eec..f40e289 100644
--- a/hinoko-sys/Cargo.toml
+++ b/hinoko-sys/Cargo.toml
@@ -1,16 +1,16 @@
[package]
-name = "hinoko-sys"
-version = "0.1.0"
-description = "FFI bindings for libhinoko0 library"
authors = ["Takashi Sakamoto <o-takashi@sakamocchi.jp>"]
-links = "hinoko"
build = "build.rs"
+description = "FFI bindings for libhinoko0 library"
+edition = "2021"
license = "MIT"
+links = "hinoko"
+name = "hinoko-sys"
repository = "https://github.com/takaswie/hinoko-rs/"
-
+rust-version = "1.57"
+version = "0.1.0"
[package.metadata.docs.rs]
features = ["dox"]
-
[package.metadata.system-deps.hinoko]
name = "hinoko"
version = "0.6"
@@ -18,17 +18,23 @@ version = "0.6"
[lib]
name = "hinoko_sys"
+[build-dependencies]
+pkg-config = "0.3.7"
+system-deps = "6"
+
[dependencies]
libc = "0.2"
-glib-sys = "0.10"
-gobject-sys = "0.10"
-[build-dependencies]
-pkg-config = "0.3.7"
-system-deps = "3"
+[dependencies.glib]
+package = "glib-sys"
+version = "0.15"
+
+[dependencies.gobject]
+package = "gobject-sys"
+version = "0.15"
[dev-dependencies]
-shell-words = "0.1.0"
+shell-words = "1.0.0"
tempfile = "3"
[features]
diff --git a/conf/gir-hinoko-sys.toml b/hinoko-sys/Gir.toml
index 6aab9ee..65cbd93 100644
--- a/conf/gir-hinoko-sys.toml
+++ b/hinoko-sys/Gir.toml
@@ -1,4 +1,5 @@
[options]
+girs_directories = ["../gir-files", ".."]
work_mode = "sys"
library = "Hinoko"
version = "0.0"
diff --git a/hinoko-sys/build.rs b/hinoko-sys/build.rs
index aa24dc4..631008a 100644
--- a/hinoko-sys/build.rs
+++ b/hinoko-sys/build.rs
@@ -3,17 +3,6 @@
// DO NOT EDIT
#[cfg(not(feature = "dox"))]
-extern crate pkg_config;
-
-#[cfg(not(feature = "dox"))]
-use pkg_config::{Config, Error};
-#[cfg(not(feature = "dox"))]
-use std::env;
-#[cfg(not(feature = "dox"))]
-use std::io::prelude::*;
-#[cfg(not(feature = "dox"))]
-use std::io;
-#[cfg(not(feature = "dox"))]
use std::process;
#[cfg(feature = "dox")]
@@ -21,63 +10,8 @@ fn main() {} // prevent linking libraries to avoid documentation failure
#[cfg(not(feature = "dox"))]
fn main() {
- if let Err(s) = find() {
- let _ = writeln!(io::stderr(), "{}", s);
+ if let Err(s) = system_deps::Config::new().probe() {
+ println!("cargo:warning={}", s);
process::exit(1);
}
}
-
-#[cfg(not(feature = "dox"))]
-fn find() -> Result<(), Error> {
- let package_name = "hinoko";
- let shared_libs = ["hinoko"];
- let version = {
- "0.6"
- };
-
- if let Ok(inc_dir) = env::var("GTK_INCLUDE_DIR") {
- println!("cargo:include={}", inc_dir);
- }
- 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 let Ok(paths) = std::env::join_paths(library.include_paths) {
- println!("cargo:include={}", paths.to_string_lossy());
- }
- 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),
- }
-}
-
diff --git a/hinoko-sys/src/lib.rs b/hinoko-sys/src/lib.rs
index c99fc12..1f6f724 100644
--- a/hinoko-sys/src/lib.rs
+++ b/hinoko-sys/src/lib.rs
@@ -3,16 +3,19 @@
// DO NOT EDIT
#![allow(non_camel_case_types, non_upper_case_globals, non_snake_case)]
-#![allow(clippy::approx_constant, clippy::type_complexity, clippy::unreadable_literal)]
-
-extern crate libc;
-extern crate glib_sys as glib;
-extern crate gobject_sys as gobject;
+#![allow(
+ clippy::approx_constant,
+ clippy::type_complexity,
+ clippy::unreadable_literal,
+ clippy::upper_case_acronyms
+)]
+#![cfg_attr(feature = "dox", feature(doc_cfg))]
#[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};
+use libc::{
+ c_char, c_double, c_float, c_int, c_long, c_short, c_uchar, c_uint, c_ulong, c_ushort, c_void,
+ intptr_t, size_t, ssize_t, uintptr_t, FILE,
+};
#[allow(unused_imports)]
use glib::{gboolean, gconstpointer, gpointer, GType};
@@ -62,17 +65,20 @@ pub const HINOKO_FW_ISO_CTX_MATCH_FLAG_TAG3: HinokoFwIsoCtxMatchFlag = 8;
// Records
#[repr(C)]
-pub struct HinokoCycleTimer(c_void);
+pub struct HinokoCycleTimer {
+ _data: [u8; 0],
+ _marker: core::marker::PhantomData<(*mut u8, core::marker::PhantomPinned)>,
+}
impl ::std::fmt::Debug for HinokoCycleTimer {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
- f.debug_struct(&format!("HinokoCycleTimer @ {:?}", self as *const _))
- .finish()
+ f.debug_struct(&format!("HinokoCycleTimer @ {:p}", self))
+ .finish()
}
}
-#[repr(C)]
#[derive(Copy, Clone)]
+#[repr(C)]
pub struct HinokoFwIsoCtxClass {
pub parent_class: gobject::GObjectClass,
pub stopped: Option<unsafe extern "C" fn(*mut HinokoFwIsoCtx, *mut glib::GError)>,
@@ -80,62 +86,73 @@ pub struct HinokoFwIsoCtxClass {
impl ::std::fmt::Debug for HinokoFwIsoCtxClass {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
- f.debug_struct(&format!("HinokoFwIsoCtxClass @ {:?}", self as *const _))
- .field("parent_class", &self.parent_class)
- .field("stopped", &self.stopped)
- .finish()
+ f.debug_struct(&format!("HinokoFwIsoCtxClass @ {:p}", self))
+ .field("parent_class", &self.parent_class)
+ .field("stopped", &self.stopped)
+ .finish()
}
}
#[repr(C)]
-pub struct _HinokoFwIsoCtxPrivate(c_void);
+pub struct _HinokoFwIsoCtxPrivate {
+ _data: [u8; 0],
+ _marker: core::marker::PhantomData<(*mut u8, core::marker::PhantomPinned)>,
+}
pub type HinokoFwIsoCtxPrivate = *mut _HinokoFwIsoCtxPrivate;
-#[repr(C)]
#[derive(Copy, Clone)]
+#[repr(C)]
pub struct HinokoFwIsoResourceAutoClass {
pub parent_class: HinokoFwIsoResourceClass,
}
impl ::std::fmt::Debug for HinokoFwIsoResourceAutoClass {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
- f.debug_struct(&format!("HinokoFwIsoResourceAutoClass @ {:?}", self as *const _))
- .field("parent_class", &self.parent_class)
- .finish()
+ f.debug_struct(&format!("HinokoFwIsoResourceAutoClass @ {:p}", self))
+ .field("parent_class", &self.parent_class)
+ .finish()
}
}
#[repr(C)]
-pub struct _HinokoFwIsoResourceAutoPrivate(c_void);
+pub struct _HinokoFwIsoResourceAutoPrivate {
+ _data: [u8; 0],
+ _marker: core::marker::PhantomData<(*mut u8, core::marker::PhantomPinned)>,
+}
pub type HinokoFwIsoResourceAutoPrivate = *mut _HinokoFwIsoResourceAutoPrivate;
-#[repr(C)]
#[derive(Copy, Clone)]
+#[repr(C)]
pub struct HinokoFwIsoResourceClass {
pub parent_class: gobject::GObjectClass,
- pub allocated: Option<unsafe extern "C" fn(*mut HinokoFwIsoResource, c_uint, c_uint, *mut glib::GError)>,
- pub deallocated: Option<unsafe extern "C" fn(*mut HinokoFwIsoResource, c_uint, c_uint, *mut glib::GError)>,
+ pub allocated:
+ Option<unsafe extern "C" fn(*mut HinokoFwIsoResource, c_uint, c_uint, *mut glib::GError)>,
+ pub deallocated:
+ Option<unsafe extern "C" fn(*mut HinokoFwIsoResource, c_uint, c_uint, *mut glib::GError)>,
}
impl ::std::fmt::Debug for HinokoFwIsoResourceClass {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
- f.debug_struct(&format!("HinokoFwIsoResourceClass @ {:?}", self as *const _))
- .field("parent_class", &self.parent_class)
- .field("allocated", &self.allocated)
- .field("deallocated", &self.deallocated)
- .finish()
+ f.debug_struct(&format!("HinokoFwIsoResourceClass @ {:p}", self))
+ .field("parent_class", &self.parent_class)
+ .field("allocated", &self.allocated)
+ .field("deallocated", &self.deallocated)
+ .finish()
}
}
#[repr(C)]
-pub struct _HinokoFwIsoResourcePrivate(c_void);
+pub struct _HinokoFwIsoResourcePrivate {
+ _data: [u8; 0],
+ _marker: core::marker::PhantomData<(*mut u8, core::marker::PhantomPinned)>,
+}
pub type HinokoFwIsoResourcePrivate = *mut _HinokoFwIsoResourcePrivate;
-#[repr(C)]
#[derive(Copy, Clone)]
+#[repr(C)]
pub struct HinokoFwIsoRxMultipleClass {
pub parent_class: HinokoFwIsoCtxClass,
pub interrupted: Option<unsafe extern "C" fn(*mut HinokoFwIsoRxMultiple, c_uint)>,
@@ -143,63 +160,75 @@ pub struct HinokoFwIsoRxMultipleClass {
impl ::std::fmt::Debug for HinokoFwIsoRxMultipleClass {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
- f.debug_struct(&format!("HinokoFwIsoRxMultipleClass @ {:?}", self as *const _))
- .field("parent_class", &self.parent_class)
- .field("interrupted", &self.interrupted)
- .finish()
+ f.debug_struct(&format!("HinokoFwIsoRxMultipleClass @ {:p}", self))
+ .field("parent_class", &self.parent_class)
+ .field("interrupted", &self.interrupted)
+ .finish()
}
}
#[repr(C)]
-pub struct _HinokoFwIsoRxMultiplePrivate(c_void);
+pub struct _HinokoFwIsoRxMultiplePrivate {
+ _data: [u8; 0],
+ _marker: core::marker::PhantomData<(*mut u8, core::marker::PhantomPinned)>,
+}
pub type HinokoFwIsoRxMultiplePrivate = *mut _HinokoFwIsoRxMultiplePrivate;
-#[repr(C)]
#[derive(Copy, Clone)]
+#[repr(C)]
pub struct HinokoFwIsoRxSingleClass {
pub parent_class: HinokoFwIsoCtxClass,
- pub interrupted: Option<unsafe extern "C" fn(*mut HinokoFwIsoRxSingle, c_uint, c_uint, *const u8, c_uint, c_uint)>,
+ pub interrupted: Option<
+ unsafe extern "C" fn(*mut HinokoFwIsoRxSingle, c_uint, c_uint, *const u8, c_uint, c_uint),
+ >,
}
impl ::std::fmt::Debug for HinokoFwIsoRxSingleClass {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
- f.debug_struct(&format!("HinokoFwIsoRxSingleClass @ {:?}", self as *const _))
- .field("parent_class", &self.parent_class)
- .field("interrupted", &self.interrupted)
- .finish()
+ f.debug_struct(&format!("HinokoFwIsoRxSingleClass @ {:p}", self))
+ .field("parent_class", &self.parent_class)
+ .field("interrupted", &self.interrupted)
+ .finish()
}
}
#[repr(C)]
-pub struct _HinokoFwIsoRxSinglePrivate(c_void);
+pub struct _HinokoFwIsoRxSinglePrivate {
+ _data: [u8; 0],
+ _marker: core::marker::PhantomData<(*mut u8, core::marker::PhantomPinned)>,
+}
pub type HinokoFwIsoRxSinglePrivate = *mut _HinokoFwIsoRxSinglePrivate;
-#[repr(C)]
#[derive(Copy, Clone)]
+#[repr(C)]
pub struct HinokoFwIsoTxClass {
pub parent_class: HinokoFwIsoCtxClass,
- pub interrupted: Option<unsafe extern "C" fn(*mut HinokoFwIsoTx, c_uint, c_uint, *const u8, c_uint, c_uint)>,
+ pub interrupted:
+ Option<unsafe extern "C" fn(*mut HinokoFwIsoTx, c_uint, c_uint, *const u8, c_uint, c_uint)>,
}
impl ::std::fmt::Debug for HinokoFwIsoTxClass {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
- f.debug_struct(&format!("HinokoFwIsoTxClass @ {:?}", self as *const _))
- .field("parent_class", &self.parent_class)
- .field("interrupted", &self.interrupted)
- .finish()
+ f.debug_struct(&format!("HinokoFwIsoTxClass @ {:p}", self))
+ .field("parent_class", &self.parent_class)
+ .field("interrupted", &self.interrupted)
+ .finish()
}
}
#[repr(C)]
-pub struct _HinokoFwIsoTxPrivate(c_void);
+pub struct _HinokoFwIsoTxPrivate {
+ _data: [u8; 0],
+ _marker: core::marker::PhantomData<(*mut u8, core::marker::PhantomPinned)>,
+}
pub type HinokoFwIsoTxPrivate = *mut _HinokoFwIsoTxPrivate;
// Classes
-#[repr(C)]
#[derive(Copy, Clone)]
+#[repr(C)]
pub struct HinokoFwIsoCtx {
pub parent_instance: gobject::GObject,
pub priv_: *mut HinokoFwIsoCtxPrivate,
@@ -207,15 +236,15 @@ pub struct HinokoFwIsoCtx {
impl ::std::fmt::Debug for HinokoFwIsoCtx {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
- f.debug_struct(&format!("HinokoFwIsoCtx @ {:?}", self as *const _))
- .field("parent_instance", &self.parent_instance)
- .field("priv_", &self.priv_)
- .finish()
+ f.debug_struct(&format!("HinokoFwIsoCtx @ {:p}", self))
+ .field("parent_instance", &self.parent_instance)
+ .field("priv_", &self.priv_)
+ .finish()
}
}
-#[repr(C)]
#[derive(Copy, Clone)]
+#[repr(C)]
pub struct HinokoFwIsoResource {
pub parent_instance: gobject::GObject,
pub priv_: *mut HinokoFwIsoResourcePrivate,
@@ -223,15 +252,15 @@ pub struct HinokoFwIsoResource {
impl ::std::fmt::Debug for HinokoFwIsoResource {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
- f.debug_struct(&format!("HinokoFwIsoResource @ {:?}", self as *const _))
- .field("parent_instance", &self.parent_instance)
- .field("priv_", &self.priv_)
- .finish()
+ f.debug_struct(&format!("HinokoFwIsoResource @ {:p}", self))
+ .field("parent_instance", &self.parent_instance)
+ .field("priv_", &self.priv_)
+ .finish()
}
}
-#[repr(C)]
#[derive(Copy, Clone)]
+#[repr(C)]
pub struct HinokoFwIsoResourceAuto {
pub parent_instance: HinokoFwIsoResource,
pub priv_: *mut HinokoFwIsoResourceAutoPrivate,
@@ -239,15 +268,15 @@ pub struct HinokoFwIsoResourceAuto {
impl ::std::fmt::Debug for HinokoFwIsoResourceAuto {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
- f.debug_struct(&format!("HinokoFwIsoResourceAuto @ {:?}", self as *const _))
- .field("parent_instance", &self.parent_instance)
- .field("priv_", &self.priv_)
- .finish()
+ f.debug_struct(&format!("HinokoFwIsoResourceAuto @ {:p}", self))
+ .field("parent_instance", &self.parent_instance)
+ .field("priv_", &self.priv_)
+ .finish()
}
}
-#[repr(C)]
#[derive(Copy, Clone)]
+#[repr(C)]
pub struct HinokoFwIsoRxMultiple {
pub parent_instance: HinokoFwIsoCtx,
pub priv_: *mut HinokoFwIsoRxMultiplePrivate,
@@ -255,15 +284,15 @@ pub struct HinokoFwIsoRxMultiple {
impl ::std::fmt::Debug for HinokoFwIsoRxMultiple {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
- f.debug_struct(&format!("HinokoFwIsoRxMultiple @ {:?}", self as *const _))
- .field("parent_instance", &self.parent_instance)
- .field("priv_", &self.priv_)
- .finish()
+ f.debug_struct(&format!("HinokoFwIsoRxMultiple @ {:p}", self))
+ .field("parent_instance", &self.parent_instance)
+ .field("priv_", &self.priv_)
+ .finish()
}
}
-#[repr(C)]
#[derive(Copy, Clone)]
+#[repr(C)]
pub struct HinokoFwIsoRxSingle {
pub parent_instance: HinokoFwIsoCtx,
pub priv_: *mut HinokoFwIsoRxSinglePrivate,
@@ -271,15 +300,15 @@ pub struct HinokoFwIsoRxSingle {
impl ::std::fmt::Debug for HinokoFwIsoRxSingle {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
- f.debug_struct(&format!("HinokoFwIsoRxSingle @ {:?}", self as *const _))
- .field("parent_instance", &self.parent_instance)
- .field("priv_", &self.priv_)
- .finish()
+ f.debug_struct(&format!("HinokoFwIsoRxSingle @ {:p}", self))
+ .field("parent_instance", &self.parent_instance)
+ .field("priv_", &self.priv_)
+ .finish()
}
}
-#[repr(C)]
#[derive(Copy, Clone)]
+#[repr(C)]
pub struct HinokoFwIsoTx {
pub parent_instance: HinokoFwIsoCtx,
pub priv_: *mut HinokoFwIsoTxPrivate,
@@ -287,13 +316,14 @@ pub struct HinokoFwIsoTx {
impl ::std::fmt::Debug for HinokoFwIsoTx {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
- f.debug_struct(&format!("HinokoFwIsoTx @ {:?}", self as *const _))
- .field("parent_instance", &self.parent_instance)
- .field("priv_", &self.priv_)
- .finish()
+ f.debug_struct(&format!("HinokoFwIsoTx @ {:p}", self))
+ .field("parent_instance", &self.parent_instance)
+ .field("priv_", &self.priv_)
+ .finish()
}
}
+#[link(name = "hinoko")]
extern "C" {
//=========================================================================
@@ -335,50 +365,145 @@ extern "C" {
pub fn hinoko_cycle_timer_get_type() -> GType;
pub fn hinoko_cycle_timer_new() -> *mut HinokoCycleTimer;
pub fn hinoko_cycle_timer_get_clock_id(self_: *mut HinokoCycleTimer, clock_id: *mut c_int);
- pub fn hinoko_cycle_timer_get_cycle_timer(self_: *mut HinokoCycleTimer, cycle_timer: *mut [u16; 3]);
- pub fn hinoko_cycle_timer_get_timestamp(self_: *mut HinokoCycleTimer, tv_sec: *mut i64, tv_nsec: *mut i32);
+ pub fn hinoko_cycle_timer_get_cycle_timer(
+ self_: *mut HinokoCycleTimer,
+ cycle_timer: *mut [u16; 3],
+ );
+ pub fn hinoko_cycle_timer_get_timestamp(
+ self_: *mut HinokoCycleTimer,
+ tv_sec: *mut i64,
+ tv_nsec: *mut i32,
+ );
//=========================================================================
// HinokoFwIsoCtx
//=========================================================================
pub fn hinoko_fw_iso_ctx_get_type() -> GType;
- pub fn hinoko_fw_iso_ctx_create_source(self_: *mut HinokoFwIsoCtx, gsrc: *mut *mut glib::GSource, error: *mut *mut glib::GError);
- pub fn hinoko_fw_iso_ctx_flush_completions(self_: *mut HinokoFwIsoCtx, error: *mut *mut glib::GError);
- pub fn hinoko_fw_iso_ctx_get_cycle_timer(self_: *mut HinokoFwIsoCtx, clock_id: c_int, cycle_timer: *const *mut HinokoCycleTimer, error: *mut *mut glib::GError);
+ pub fn hinoko_fw_iso_ctx_create_source(
+ self_: *mut HinokoFwIsoCtx,
+ gsrc: *mut *mut glib::GSource,
+ error: *mut *mut glib::GError,
+ );
+ pub fn hinoko_fw_iso_ctx_flush_completions(
+ self_: *mut HinokoFwIsoCtx,
+ error: *mut *mut glib::GError,
+ );
+ pub fn hinoko_fw_iso_ctx_get_cycle_timer(
+ self_: *mut HinokoFwIsoCtx,
+ clock_id: c_int,
+ cycle_timer: *const *mut HinokoCycleTimer,
+ error: *mut *mut glib::GError,
+ );
//=========================================================================
// HinokoFwIsoResource
//=========================================================================
pub fn hinoko_fw_iso_resource_get_type() -> GType;
pub fn hinoko_fw_iso_resource_new() -> *mut HinokoFwIsoResource;
- pub fn hinoko_fw_iso_resource_calculate_bandwidth(bytes_per_payload: c_uint, scode: HinokoFwScode) -> c_uint;
- pub fn hinoko_fw_iso_resource_allocate_once_async(self_: *mut HinokoFwIsoResource, channel_candidates: *mut u8, channel_candidates_count: size_t, bandwidth: c_uint, error: *mut *mut glib::GError);
- pub fn hinoko_fw_iso_resource_allocate_once_sync(self_: *mut HinokoFwIsoResource, channel_candidates: *mut u8, channel_candidates_count: size_t, bandwidth: c_uint, error: *mut *mut glib::GError);
- pub fn hinoko_fw_iso_resource_create_source(self_: *mut HinokoFwIsoResource, gsrc: *mut *mut glib::GSource, error: *mut *mut glib::GError);
- pub fn hinoko_fw_iso_resource_deallocate_once_async(self_: *mut HinokoFwIsoResource, channel: c_uint, bandwidth: c_uint, error: *mut *mut glib::GError);
- pub fn hinoko_fw_iso_resource_deallocate_once_sync(self_: *mut HinokoFwIsoResource, channel: c_uint, bandwidth: c_uint, error: *mut *mut glib::GError);
- pub fn hinoko_fw_iso_resource_open(self_: *mut HinokoFwIsoResource, path: *const c_char, open_flag: c_int, error: *mut *mut glib::GError);
+ pub fn hinoko_fw_iso_resource_calculate_bandwidth(
+ bytes_per_payload: c_uint,
+ scode: HinokoFwScode,
+ ) -> c_uint;
+ pub fn hinoko_fw_iso_resource_allocate_once_async(
+ self_: *mut HinokoFwIsoResource,
+ channel_candidates: *mut u8,
+ channel_candidates_count: size_t,
+ bandwidth: c_uint,
+ error: *mut *mut glib::GError,
+ );
+ pub fn hinoko_fw_iso_resource_allocate_once_sync(
+ self_: *mut HinokoFwIsoResource,
+ channel_candidates: *mut u8,
+ channel_candidates_count: size_t,
+ bandwidth: c_uint,
+ error: *mut *mut glib::GError,
+ );
+ pub fn hinoko_fw_iso_resource_create_source(
+ self_: *mut HinokoFwIsoResource,
+ gsrc: *mut *mut glib::GSource,
+ error: *mut *mut glib::GError,
+ );
+ pub fn hinoko_fw_iso_resource_deallocate_once_async(
+ self_: *mut HinokoFwIsoResource,
+ channel: c_uint,
+ bandwidth: c_uint,
+ error: *mut *mut glib::GError,
+ );
+ pub fn hinoko_fw_iso_resource_deallocate_once_sync(
+ self_: *mut HinokoFwIsoResource,
+ channel: c_uint,
+ bandwidth: c_uint,
+ error: *mut *mut glib::GError,
+ );
+ pub fn hinoko_fw_iso_resource_open(
+ self_: *mut HinokoFwIsoResource,
+ path: *const c_char,
+ open_flag: c_int,
+ error: *mut *mut glib::GError,
+ );
//=========================================================================
// HinokoFwIsoResourceAuto
//=========================================================================
pub fn hinoko_fw_iso_resource_auto_get_type() -> GType;
pub fn hinoko_fw_iso_resource_auto_new() -> *mut HinokoFwIsoResourceAuto;
- pub fn hinoko_fw_iso_resource_auto_allocate_async(self_: *mut HinokoFwIsoResourceAuto, channel_candidates: *mut u8, channel_candidates_count: size_t, bandwidth: c_uint, error: *mut *mut glib::GError);
- pub fn hinoko_fw_iso_resource_auto_allocate_sync(self_: *mut HinokoFwIsoResourceAuto, channel_candidates: *mut u8, channel_candidates_count: size_t, bandwidth: c_uint, error: *mut *mut glib::GError);
- pub fn hinoko_fw_iso_resource_auto_deallocate_async(self_: *mut HinokoFwIsoResourceAuto, error: *mut *mut glib::GError);
- pub fn hinoko_fw_iso_resource_auto_deallocate_sync(self_: *mut HinokoFwIsoResourceAuto, error: *mut *mut glib::GError);
+ pub fn hinoko_fw_iso_resource_auto_allocate_async(
+ self_: *mut HinokoFwIsoResourceAuto,
+ channel_candidates: *mut u8,
+ channel_candidates_count: size_t,
+ bandwidth: c_uint,
+ error: *mut *mut glib::GError,
+ );
+ pub fn hinoko_fw_iso_resource_auto_allocate_sync(
+ self_: *mut HinokoFwIsoResourceAuto,
+ channel_candidates: *mut u8,
+ channel_candidates_count: size_t,
+ bandwidth: c_uint,
+ error: *mut *mut glib::GError,
+ );
+ pub fn hinoko_fw_iso_resource_auto_deallocate_async(
+ self_: *mut HinokoFwIsoResourceAuto,
+ error: *mut *mut glib::GError,
+ );
+ pub fn hinoko_fw_iso_resource_auto_deallocate_sync(
+ self_: *mut HinokoFwIsoResourceAuto,
+ error: *mut *mut glib::GError,
+ );
//=========================================================================
// HinokoFwIsoRxMultiple
//=========================================================================
pub fn hinoko_fw_iso_rx_multiple_get_type() -> GType;
pub fn hinoko_fw_iso_rx_multiple_new() -> *mut HinokoFwIsoRxMultiple;
- pub fn hinoko_fw_iso_rx_multiple_allocate(self_: *mut HinokoFwIsoRxMultiple, path: *const c_char, channels: *const u8, channels_length: c_uint, error: *mut *mut glib::GError);
- pub fn hinoko_fw_iso_rx_multiple_get_payload(self_: *mut HinokoFwIsoRxMultiple, index: c_uint, payload: *mut *const u8, length: *mut c_uint, error: *mut *mut glib::GError);
- pub fn hinoko_fw_iso_rx_multiple_map_buffer(self_: *mut HinokoFwIsoRxMultiple, bytes_per_chunk: c_uint, chunks_per_buffer: c_uint, error: *mut *mut glib::GError);
+ pub fn hinoko_fw_iso_rx_multiple_allocate(
+ self_: *mut HinokoFwIsoRxMultiple,
+ path: *const c_char,
+ channels: *const u8,
+ channels_length: c_uint,
+ error: *mut *mut glib::GError,
+ );
+ pub fn hinoko_fw_iso_rx_multiple_get_payload(
+ self_: *mut HinokoFwIsoRxMultiple,
+ index: c_uint,
+ payload: *mut *const u8,
+ length: *mut c_uint,
+ error: *mut *mut glib::GError,
+ );
+ pub fn hinoko_fw_iso_rx_multiple_map_buffer(
+ self_: *mut HinokoFwIsoRxMultiple,
+ bytes_per_chunk: c_uint,
+ chunks_per_buffer: c_uint,
+ error: *mut *mut glib::GError,
+ );
pub fn hinoko_fw_iso_rx_multiple_release(self_: *mut HinokoFwIsoRxMultiple);
- pub fn hinoko_fw_iso_rx_multiple_start(self_: *mut HinokoFwIsoRxMultiple, cycle_match: *const [u16; 2], sync: u32, tags: HinokoFwIsoCtxMatchFlag, chunks_per_irq: c_uint, error: *mut *mut glib::GError);
+ pub fn hinoko_fw_iso_rx_multiple_start(
+ self_: *mut HinokoFwIsoRxMultiple,
+ cycle_match: *const [u16; 2],
+ sync: u32,
+ tags: HinokoFwIsoCtxMatchFlag,
+ chunks_per_irq: c_uint,
+ error: *mut *mut glib::GError,
+ );
pub fn hinoko_fw_iso_rx_multiple_stop(self_: *mut HinokoFwIsoRxMultiple);
pub fn hinoko_fw_iso_rx_multiple_unmap_buffer(self_: *mut HinokoFwIsoRxMultiple);
@@ -387,12 +512,39 @@ extern "C" {
//=========================================================================
pub fn hinoko_fw_iso_rx_single_get_type() -> GType;
pub fn hinoko_fw_iso_rx_single_new() -> *mut HinokoFwIsoRxSingle;
- pub fn hinoko_fw_iso_rx_single_allocate(self_: *mut HinokoFwIsoRxSingle, path: *const c_char, channel: c_uint, header_size: c_uint, error: *mut *mut glib::GError);
- pub fn hinoko_fw_iso_rx_single_get_payload(self_: *mut HinokoFwIsoRxSingle, index: c_uint, payload: *mut *const u8, length: *mut c_uint, error: *mut *mut glib::GError);
- pub fn hinoko_fw_iso_rx_single_map_buffer(self_: *mut HinokoFwIsoRxSingle, maximum_bytes_per_payload: c_uint, payloads_per_buffer: c_uint, error: *mut *mut glib::GError);
- pub fn hinoko_fw_iso_rx_single_register_packet(self_: *mut HinokoFwIsoRxSingle, schedule_interrupt: gboolean, error: *mut *mut glib::GError);
+ pub fn hinoko_fw_iso_rx_single_allocate(
+ self_: *mut HinokoFwIsoRxSingle,
+ path: *const c_char,
+ channel: c_uint,
+ header_size: c_uint,
+ error: *mut *mut glib::GError,
+ );
+ pub fn hinoko_fw_iso_rx_single_get_payload(
+ self_: *mut HinokoFwIsoRxSingle,
+ index: c_uint,
+ payload: *mut *const u8,
+ length: *mut c_uint,
+ error: *mut *mut glib::GError,
+ );
+ pub fn hinoko_fw_iso_rx_single_map_buffer(
+ self_: *mut HinokoFwIsoRxSingle,
+ maximum_bytes_per_payload: c_uint,
+ payloads_per_buffer: c_uint,
+ error: *mut *mut glib::GError,
+ );
+ pub fn hinoko_fw_iso_rx_single_register_packet(
+ self_: *mut HinokoFwIsoRxSingle,
+ schedule_interrupt: gboolean,
+ error: *mut *mut glib::GError,
+ );
pub fn hinoko_fw_iso_rx_single_release(self_: *mut HinokoFwIsoRxSingle);
- pub fn hinoko_fw_iso_rx_single_start(self_: *mut HinokoFwIsoRxSingle, cycle_match: *const [u16; 2], sync: u32, tags: HinokoFwIsoCtxMatchFlag, error: *mut *mut glib::GError);
+ pub fn hinoko_fw_iso_rx_single_start(
+ self_: *mut HinokoFwIsoRxSingle,
+ cycle_match: *const [u16; 2],
+ sync: u32,
+ tags: HinokoFwIsoCtxMatchFlag,
+ error: *mut *mut glib::GError,
+ );
pub fn hinoko_fw_iso_rx_single_stop(self_: *mut HinokoFwIsoRxSingle);
pub fn hinoko_fw_iso_rx_single_unmap_buffer(self_: *mut HinokoFwIsoRxSingle);
@@ -401,18 +553,58 @@ extern "C" {
//=========================================================================
pub fn hinoko_fw_iso_tx_get_type() -> GType;
pub fn hinoko_fw_iso_tx_new() -> *mut HinokoFwIsoTx;
- pub fn hinoko_fw_iso_tx_allocate(self_: *mut HinokoFwIsoTx, path: *const c_char, scode: HinokoFwScode, channel: c_uint, header_size: c_uint, error: *mut *mut glib::GError);
- pub fn hinoko_fw_iso_tx_map_buffer(self_: *mut HinokoFwIsoTx, maximum_bytes_per_payload: c_uint, payloads_per_buffer: c_uint, error: *mut *mut glib::GError);
- pub fn hinoko_fw_iso_tx_register_packet(self_: *mut HinokoFwIsoTx, tags: HinokoFwIsoCtxMatchFlag, sy: c_uint, header: *const u8, header_length: c_uint, payload: *const u8, payload_length: c_uint, schedule_interrupt: gboolean, error: *mut *mut glib::GError);
+ pub fn hinoko_fw_iso_tx_allocate(
+ self_: *mut HinokoFwIsoTx,
+ path: *const c_char,
+ scode: HinokoFwScode,
+ channel: c_uint,
+ header_size: c_uint,
+ error: *mut *mut glib::GError,
+ );
+ pub fn hinoko_fw_iso_tx_map_buffer(
+ self_: *mut HinokoFwIsoTx,
+ maximum_bytes_per_payload: c_uint,
+ payloads_per_buffer: c_uint,
+ error: *mut *mut glib::GError,
+ );
+ pub fn hinoko_fw_iso_tx_register_packet(
+ self_: *mut HinokoFwIsoTx,
+ tags: HinokoFwIsoCtxMatchFlag,
+ sy: c_uint,
+ header: *const u8,
+ header_length: c_uint,
+ payload: *const u8,
+ payload_length: c_uint,
+ schedule_interrupt: gboolean,
+ error: *mut *mut glib::GError,
+ );
pub fn hinoko_fw_iso_tx_release(self_: *mut HinokoFwIsoTx);
- pub fn hinoko_fw_iso_tx_start(self_: *mut HinokoFwIsoTx, cycle_match: *const [u16; 2], error: *mut *mut glib::GError);
+ pub fn hinoko_fw_iso_tx_start(
+ self_: *mut HinokoFwIsoTx,
+ cycle_match: *const [u16; 2],
+ error: *mut *mut glib::GError,
+ );
pub fn hinoko_fw_iso_tx_stop(self_: *mut HinokoFwIsoTx);
pub fn hinoko_fw_iso_tx_unmap_buffer(self_: *mut HinokoFwIsoTx);
//=========================================================================
// Other functions
//=========================================================================
- pub fn hinoko_sigs_marshal_VOID__UINT_UINT_OBJECT(closure: *mut gobject::GClosure, return_value: *mut gobject::GValue, n_param_values: c_uint, param_values: *const gobject::GValue, invocation_hint: gpointer, marshal_data: gpointer);
- pub fn hinoko_sigs_marshal_VOID__UINT_UINT_POINTER_UINT_UINT(closure: *mut gobject::GClosure, return_value: *mut gobject::GValue, n_param_values: c_uint, param_values: *const gobject::GValue, invocation_hint: gpointer, marshal_data: gpointer);
+ pub fn hinoko_sigs_marshal_VOID__UINT_UINT_OBJECT(
+ closure: *mut gobject::GClosure,
+ return_value: *mut gobject::GValue,
+ n_param_values: c_uint,
+ param_values: *const gobject::GValue,
+ invocation_hint: gpointer,
+ marshal_data: gpointer,
+ );
+ pub fn hinoko_sigs_marshal_VOID__UINT_UINT_POINTER_UINT_UINT(
+ closure: *mut gobject::GClosure,
+ return_value: *mut gobject::GValue,
+ n_param_values: c_uint,
+ param_values: *const gobject::GValue,
+ invocation_hint: gpointer,
+ marshal_data: gpointer,
+ );
}
diff --git a/hinoko-sys/tests/abi.rs b/hinoko-sys/tests/abi.rs
index 4d93feb..4df3dd1 100644
--- a/hinoko-sys/tests/abi.rs
+++ b/hinoko-sys/tests/abi.rs
@@ -2,17 +2,15 @@
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT
-extern crate hinoko_sys;
-extern crate shell_words;
-extern crate tempfile;
+use hinoko_sys::*;
use std::env;
use std::error::Error;
-use std::path::Path;
+use std::ffi::OsString;
use std::mem::{align_of, size_of};
+use std::path::Path;
use std::process::Command;
use std::str;
use tempfile::Builder;
-use hinoko_sys::*;
static PACKAGES: &[&str] = &["hinoko"];
@@ -22,23 +20,17 @@ struct Compiler {
}
impl Compiler {
- pub fn new() -> Result<Compiler, Box<dyn Error>> {
+ pub fn new() -> Result<Self, Box<dyn Error>> {
let mut args = get_var("CC", "cc")?;
args.push("-Wno-deprecated-declarations".to_owned());
+ // For _Generic
+ args.push("-std=c11".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);
+ Ok(Self { args })
}
pub fn compile(&self, src: &Path, out: &Path) -> Result<(), Box<dyn Error>> {
@@ -48,8 +40,7 @@ impl Compiler {
cmd.arg(out);
let status = cmd.spawn()?.wait()?;
if !status.success() {
- return Err(format!("compilation command {:?} failed, {}",
- &cmd, status).into());
+ return Err(format!("compilation command {:?} failed, {}", &cmd, status).into());
}
Ok(())
}
@@ -73,19 +64,18 @@ fn pkg_config_cflags(packages: &[&str]) -> Result<Vec<String>, Box<dyn Error>> {
if packages.is_empty() {
return Ok(Vec::new());
}
- let mut cmd = Command::new("pkg-config");
+ let pkg_config = env::var_os("PKG_CONFIG").unwrap_or_else(|| OsString::from("pkg-config"));
+ 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());
+ 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,
@@ -98,8 +88,6 @@ struct Results {
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 {
@@ -109,16 +97,8 @@ impl Results {
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)
+ format!("{} passed; {} failed", self.passed, self.failed)
}
fn expect_total_success(&self) {
if self.failed == 0 {
@@ -131,132 +111,231 @@ impl Results {
#[test]
fn cross_validate_constants_with_c() {
- let tmpdir = Builder::new().prefix("abi").tempdir().expect("temporary directory");
- let cc = Compiler::new().expect("configured compiler");
+ let mut c_constants: Vec<(String, String)> = Vec::new();
- assert_eq!("1",
- get_c_value(tmpdir.path(), &cc, "1").expect("C constant"),
- "failed to obtain correct constant value for 1");
+ for l in get_c_output("constant").unwrap().lines() {
+ let mut words = l.trim().split(';');
+ let name = words.next().expect("Failed to parse name").to_owned();
+ let value = words
+ .next()
+ .and_then(|s| s.parse().ok())
+ .expect("Failed to parse value");
+ c_constants.push((name, value));
+ }
- 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());
+ let mut results = Results::default();
+
+ for ((rust_name, rust_value), (c_name, c_value)) in
+ RUST_CONSTANTS.iter().zip(c_constants.iter())
+ {
+ if rust_name != c_name {
+ results.record_failed();
+ eprintln!("Name mismatch:\nRust: {:?}\nC: {:?}", rust_name, c_name,);
+ continue;
}
+
+ if rust_value != c_value {
+ results.record_failed();
+ eprintln!(
+ "Constant value mismatch for {}\nRust: {:?}\nC: {:?}",
+ rust_name, rust_value, &c_value
+ );
+ continue;
+ }
+
+ results.record_passed();
}
+
results.expect_total_success();
}
#[test]
fn cross_validate_layout_with_c() {
- let tmpdir = Builder::new().prefix("abi").tempdir().expect("temporary directory");
- let cc = Compiler::new().expect("configured compiler");
+ let mut c_layouts = Vec::new();
- 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");
+ for l in get_c_output("layout").unwrap().lines() {
+ let mut words = l.trim().split(';');
+ let name = words.next().expect("Failed to parse name").to_owned();
+ let size = words
+ .next()
+ .and_then(|s| s.parse().ok())
+ .expect("Failed to parse size");
+ let alignment = words
+ .next()
+ .and_then(|s| s.parse().ok())
+ .expect("Failed to parse alignment");
+ c_layouts.push((name, Layout { size, alignment }));
+ }
- 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());
+ let mut results = Results::default();
+
+ for ((rust_name, rust_layout), (c_name, c_layout)) in RUST_LAYOUTS.iter().zip(c_layouts.iter())
+ {
+ if rust_name != c_name {
+ results.record_failed();
+ eprintln!("Name mismatch:\nRust: {:?}\nC: {:?}", rust_name, c_name,);
+ continue;
}
- }
- results.expect_total_success();
-}
-fn get_c_layout(dir: &Path, cc: &Compiler, name: &str) -> Result<Layout, Box<dyn 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)?;
+ if rust_layout != c_layout {
+ results.record_failed();
+ eprintln!(
+ "Layout mismatch for {}\nRust: {:?}\nC: {:?}",
+ rust_name, rust_layout, &c_layout
+ );
+ continue;
+ }
- 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());
+ results.record_passed();
}
- 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})
+ results.expect_total_success();
}
-fn get_c_value(dir: &Path, cc: &Compiler, name: &str) -> Result<String, Box<dyn 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)?;
+fn get_c_output(name: &str) -> Result<String, Box<dyn Error>> {
+ let tmpdir = Builder::new().prefix("abi").tempdir()?;
+ let exe = tmpdir.path().join(name);
+ let c_file = Path::new("tests").join(name).with_extension("c");
+
+ let cc = Compiler::new().expect("configured compiler");
+ cc.compile(&c_file, &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());
+ return Err(format!("command {:?} failed, {:?}", &abi_cmd, &output).into());
}
- let output = str::from_utf8(&output.stdout)?.trim();
- if !output.starts_with("###gir test###") ||
- !output.ends_with("###gir test###") {
- return Err(format!("command {:?} return invalid output, {:?}",
- &abi_cmd, &output).into());
- }
-
- Ok(String::from(&output[14..(output.len() - 14)]))
+ Ok(String::from_utf8(output.stdout)?)
}
const RUST_LAYOUTS: &[(&str, Layout)] = &[
- ("HinokoFwIsoCtx", Layout {size: size_of::<HinokoFwIsoCtx>(), alignment: align_of::<HinokoFwIsoCtx>()}),
- ("HinokoFwIsoCtxClass", Layout {size: size_of::<HinokoFwIsoCtxClass>(), alignment: align_of::<HinokoFwIsoCtxClass>()}),
- ("HinokoFwIsoCtxError", Layout {size: size_of::<HinokoFwIsoCtxError>(), alignment: align_of::<HinokoFwIsoCtxError>()}),
- ("HinokoFwIsoCtxMatchFlag", Layout {size: size_of::<HinokoFwIsoCtxMatchFlag>(), alignment: align_of::<HinokoFwIsoCtxMatchFlag>()}),
- ("HinokoFwIsoCtxMode", Layout {size: size_of::<HinokoFwIsoCtxMode>(), alignment: align_of::<HinokoFwIsoCtxMode>()}),
- ("HinokoFwIsoResource", Layout {size: size_of::<HinokoFwIsoResource>(), alignment: align_of::<HinokoFwIsoResource>()}),
- ("HinokoFwIsoResourceAuto", Layout {size: size_of::<HinokoFwIsoResourceAuto>(), alignment: align_of::<HinokoFwIsoResourceAuto>()}),
- ("HinokoFwIsoResourceAutoClass", Layout {size: size_of::<HinokoFwIsoResourceAutoClass>(), alignment: align_of::<HinokoFwIsoResourceAutoClass>()}),
- ("HinokoFwIsoResourceAutoError", Layout {size: size_of::<HinokoFwIsoResourceAutoError>(), alignment: align_of::<HinokoFwIsoResourceAutoError>()}),
- ("HinokoFwIsoResourceClass", Layout {size: size_of::<HinokoFwIsoResourceClass>(), alignment: align_of::<HinokoFwIsoResourceClass>()}),
- ("HinokoFwIsoResourceError", Layout {size: size_of::<HinokoFwIsoResourceError>(), alignment: align_of::<HinokoFwIsoResourceError>()}),
- ("HinokoFwIsoRxMultiple", Layout {size: size_of::<HinokoFwIsoRxMultiple>(), alignment: align_of::<HinokoFwIsoRxMultiple>()}),
- ("HinokoFwIsoRxMultipleClass", Layout {size: size_of::<HinokoFwIsoRxMultipleClass>(), alignment: align_of::<HinokoFwIsoRxMultipleClass>()}),
- ("HinokoFwIsoRxSingle", Layout {size: size_of::<HinokoFwIsoRxSingle>(), alignment: align_of::<HinokoFwIsoRxSingle>()}),
- ("HinokoFwIsoRxSingleClass", Layout {size: size_of::<HinokoFwIsoRxSingleClass>(), alignment: align_of::<HinokoFwIsoRxSingleClass>()}),
- ("HinokoFwIsoTx", Layout {size: size_of::<HinokoFwIsoTx>(), alignment: align_of::<HinokoFwIsoTx>()}),
- ("HinokoFwIsoTxClass", Layout {size: size_of::<HinokoFwIsoTxClass>(), alignment: align_of::<HinokoFwIsoTxClass>()}),
- ("HinokoFwScode", Layout {size: size_of::<HinokoFwScode>(), alignment: align_of::<HinokoFwScode>()}),
+ (
+ "HinokoFwIsoCtx",
+ Layout {
+ size: size_of::<HinokoFwIsoCtx>(),
+ alignment: align_of::<HinokoFwIsoCtx>(),
+ },
+ ),
+ (
+ "HinokoFwIsoCtxClass",
+ Layout {
+ size: size_of::<HinokoFwIsoCtxClass>(),
+ alignment: align_of::<HinokoFwIsoCtxClass>(),
+ },
+ ),
+ (
+ "HinokoFwIsoCtxError",
+ Layout {
+ size: size_of::<HinokoFwIsoCtxError>(),
+ alignment: align_of::<HinokoFwIsoCtxError>(),
+ },
+ ),
+ (
+ "HinokoFwIsoCtxMatchFlag",
+ Layout {
+ size: size_of::<HinokoFwIsoCtxMatchFlag>(),
+ alignment: align_of::<HinokoFwIsoCtxMatchFlag>(),
+ },
+ ),
+ (
+ "HinokoFwIsoCtxMode",
+ Layout {
+ size: size_of::<HinokoFwIsoCtxMode>(),
+ alignment: align_of::<HinokoFwIsoCtxMode>(),
+ },
+ ),
+ (
+ "HinokoFwIsoResource",
+ Layout {
+ size: size_of::<HinokoFwIsoResource>(),
+ alignment: align_of::<HinokoFwIsoResource>(),
+ },
+ ),
+ (
+ "HinokoFwIsoResourceAuto",
+ Layout {
+ size: size_of::<HinokoFwIsoResourceAuto>(),
+ alignment: align_of::<HinokoFwIsoResourceAuto>(),
+ },
+ ),
+ (
+ "HinokoFwIsoResourceAutoClass",
+ Layout {
+ size: size_of::<HinokoFwIsoResourceAutoClass>(),
+ alignment: align_of::<HinokoFwIsoResourceAutoClass>(),
+ },
+ ),
+ (
+ "HinokoFwIsoResourceAutoError",
+ Layout {
+ size: size_of::<HinokoFwIsoResourceAutoError>(),
+ alignment: align_of::<HinokoFwIsoResourceAutoError>(),
+ },
+ ),
+ (
+ "HinokoFwIsoResourceClass",
+ Layout {
+ size: size_of::<HinokoFwIsoResourceClass>(),
+ alignment: align_of::<HinokoFwIsoResourceClass>(),
+ },
+ ),
+ (
+ "HinokoFwIsoResourceError",
+ Layout {
+ size: size_of::<HinokoFwIsoResourceError>(),
+ alignment: align_of::<HinokoFwIsoResourceError>(),
+ },
+ ),
+ (
+ "HinokoFwIsoRxMultiple",
+ Layout {
+ size: size_of::<HinokoFwIsoRxMultiple>(),
+ alignment: align_of::<HinokoFwIsoRxMultiple>(),
+ },
+ ),
+ (
+ "HinokoFwIsoRxMultipleClass",
+ Layout {
+ size: size_of::<HinokoFwIsoRxMultipleClass>(),
+ alignment: align_of::<HinokoFwIsoRxMultipleClass>(),
+ },
+ ),
+ (
+ "HinokoFwIsoRxSingle",
+ Layout {
+ size: size_of::<HinokoFwIsoRxSingle>(),
+ alignment: align_of::<HinokoFwIsoRxSingle>(),
+ },
+ ),
+ (
+ "HinokoFwIsoRxSingleClass",
+ Layout {
+ size: size_of::<HinokoFwIsoRxSingleClass>(),
+ alignment: align_of::<HinokoFwIsoRxSingleClass>(),
+ },
+ ),
+ (
+ "HinokoFwIsoTx",
+ Layout {
+ size: size_of::<HinokoFwIsoTx>(),
+ alignment: align_of::<HinokoFwIsoTx>(),
+ },
+ ),
+ (
+ "HinokoFwIsoTxClass",
+ Layout {
+ size: size_of::<HinokoFwIsoTxClass>(),
+ alignment: align_of::<HinokoFwIsoTxClass>(),
+ },
+ ),
+ (
+ "HinokoFwScode",
+ Layout {
+ size: size_of::<HinokoFwScode>(),
+ alignment: align_of::<HinokoFwScode>(),
+ },
+ ),
];
const RUST_CONSTANTS: &[(&str, &str)] = &[
@@ -276,7 +355,10 @@ const RUST_CONSTANTS: &[(&str, &str)] = &[
("(gint) HINOKO_FW_ISO_CTX_MODE_TX", "0"),
("(gint) HINOKO_FW_ISO_RESOURCE_AUTO_ERROR_ALLOCATED", "1"),
("(gint) HINOKO_FW_ISO_RESOURCE_AUTO_ERROR_FAILED", "0"),
- ("(gint) HINOKO_FW_ISO_RESOURCE_AUTO_ERROR_NOT_ALLOCATED", "2"),
+ (
+ "(gint) HINOKO_FW_ISO_RESOURCE_AUTO_ERROR_NOT_ALLOCATED",
+ "2",
+ ),
("(gint) HINOKO_FW_ISO_RESOURCE_AUTO_ERROR_TIMEOUT", "3"),
("(gint) HINOKO_FW_ISO_RESOURCE_ERROR_EVENT", "4"),
("(gint) HINOKO_FW_ISO_RESOURCE_ERROR_FAILED", "0"),
@@ -290,5 +372,3 @@ const RUST_CONSTANTS: &[(&str, &str)] = &[
("(gint) HINOKO_FW_SCODE_S400", "2"),
("(gint) HINOKO_FW_SCODE_S800", "3"),
];
-
-
diff --git a/hinoko-sys/tests/constant.c b/hinoko-sys/tests/constant.c
index 9836428..774f65d 100644
--- a/hinoko-sys/tests/constant.c
+++ b/hinoko-sys/tests/constant.c
@@ -5,23 +5,57 @@
#include "manual.h"
#include <stdio.h>
+#define PRINT_CONSTANT(CONSTANT_NAME) \
+ printf("%s;", #CONSTANT_NAME); \
+ printf(_Generic((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", \
+ float: "%f", \
+ double: "%f", \
+ long double: "%ld"), \
+ CONSTANT_NAME); \
+ printf("\n");
+
int main() {
- printf(_Generic((ABI_CONSTANT_NAME),
- char *: "###gir test###%s###gir test###\n",
- const char *: "###gir test###%s###gir test###\n",
- char: "###gir test###%c###gir test###\n",
- signed char: "###gir test###%hhd###gir test###\n",
- unsigned char: "###gir test###%hhu###gir test###\n",
- short int: "###gir test###%hd###gir test###\n",
- unsigned short int: "###gir test###%hu###gir test###\n",
- int: "###gir test###%d###gir test###\n",
- unsigned int: "###gir test###%u###gir test###\n",
- long: "###gir test###%ld###gir test###\n",
- unsigned long: "###gir test###%lu###gir test###\n",
- long long: "###gir test###%lld###gir test###\n",
- unsigned long long: "###gir test###%llu###gir test###\n",
- double: "###gir test###%f###gir test###\n",
- long double: "###gir test###%ld###gir test###\n"),
- ABI_CONSTANT_NAME);
+ PRINT_CONSTANT((gint) HINOKO_FW_ISO_CTX_ERROR_ALLOCATED);
+ PRINT_CONSTANT((gint) HINOKO_FW_ISO_CTX_ERROR_CHUNK_UNREGISTERED);
+ PRINT_CONSTANT((gint) HINOKO_FW_ISO_CTX_ERROR_FAILED);
+ PRINT_CONSTANT((gint) HINOKO_FW_ISO_CTX_ERROR_MAPPED);
+ PRINT_CONSTANT((gint) HINOKO_FW_ISO_CTX_ERROR_NOT_ALLOCATED);
+ PRINT_CONSTANT((gint) HINOKO_FW_ISO_CTX_ERROR_NOT_MAPPED);
+ PRINT_CONSTANT((gint) HINOKO_FW_ISO_CTX_ERROR_NO_ISOC_CHANNEL);
+ PRINT_CONSTANT((guint) HINOKO_FW_ISO_CTX_MATCH_FLAG_TAG0);
+ PRINT_CONSTANT((guint) HINOKO_FW_ISO_CTX_MATCH_FLAG_TAG1);
+ PRINT_CONSTANT((guint) HINOKO_FW_ISO_CTX_MATCH_FLAG_TAG2);
+ PRINT_CONSTANT((guint) HINOKO_FW_ISO_CTX_MATCH_FLAG_TAG3);
+ PRINT_CONSTANT((gint) HINOKO_FW_ISO_CTX_MODE_RX_MULTIPLE);
+ PRINT_CONSTANT((gint) HINOKO_FW_ISO_CTX_MODE_RX_SINGLE);
+ PRINT_CONSTANT((gint) HINOKO_FW_ISO_CTX_MODE_TX);
+ PRINT_CONSTANT((gint) HINOKO_FW_ISO_RESOURCE_AUTO_ERROR_ALLOCATED);
+ PRINT_CONSTANT((gint) HINOKO_FW_ISO_RESOURCE_AUTO_ERROR_FAILED);
+ PRINT_CONSTANT((gint) HINOKO_FW_ISO_RESOURCE_AUTO_ERROR_NOT_ALLOCATED);
+ PRINT_CONSTANT((gint) HINOKO_FW_ISO_RESOURCE_AUTO_ERROR_TIMEOUT);
+ PRINT_CONSTANT((gint) HINOKO_FW_ISO_RESOURCE_ERROR_EVENT);
+ PRINT_CONSTANT((gint) HINOKO_FW_ISO_RESOURCE_ERROR_FAILED);
+ PRINT_CONSTANT((gint) HINOKO_FW_ISO_RESOURCE_ERROR_NOT_OPENED);
+ PRINT_CONSTANT((gint) HINOKO_FW_ISO_RESOURCE_ERROR_OPENED);
+ PRINT_CONSTANT((gint) HINOKO_FW_ISO_RESOURCE_ERROR_TIMEOUT);
+ PRINT_CONSTANT((gint) HINOKO_FW_SCODE_S100);
+ PRINT_CONSTANT((gint) HINOKO_FW_SCODE_S1600);
+ PRINT_CONSTANT((gint) HINOKO_FW_SCODE_S200);
+ PRINT_CONSTANT((gint) HINOKO_FW_SCODE_S3200);
+ PRINT_CONSTANT((gint) HINOKO_FW_SCODE_S400);
+ PRINT_CONSTANT((gint) HINOKO_FW_SCODE_S800);
return 0;
}
diff --git a/hinoko-sys/tests/layout.c b/hinoko-sys/tests/layout.c
index 45f2ef4..2d2826e 100644
--- a/hinoko-sys/tests/layout.c
+++ b/hinoko-sys/tests/layout.c
@@ -7,6 +7,23 @@
#include <stdio.h>
int main() {
- printf("%zu\n%zu", sizeof(ABI_TYPE_NAME), alignof(ABI_TYPE_NAME));
+ printf("%s;%zu;%zu\n", "HinokoFwIsoCtx", sizeof(HinokoFwIsoCtx), alignof(HinokoFwIsoCtx));
+ printf("%s;%zu;%zu\n", "HinokoFwIsoCtxClass", sizeof(HinokoFwIsoCtxClass), alignof(HinokoFwIsoCtxClass));
+ printf("%s;%zu;%zu\n", "HinokoFwIsoCtxError", sizeof(HinokoFwIsoCtxError), alignof(HinokoFwIsoCtxError));
+ printf("%s;%zu;%zu\n", "HinokoFwIsoCtxMatchFlag", sizeof(HinokoFwIsoCtxMatchFlag), alignof(HinokoFwIsoCtxMatchFlag));
+ printf("%s;%zu;%zu\n", "HinokoFwIsoCtxMode", sizeof(HinokoFwIsoCtxMode), alignof(HinokoFwIsoCtxMode));
+ printf("%s;%zu;%zu\n", "HinokoFwIsoResource", sizeof(HinokoFwIsoResource), alignof(HinokoFwIsoResource));
+ printf("%s;%zu;%zu\n", "HinokoFwIsoResourceAuto", sizeof(HinokoFwIsoResourceAuto), alignof(HinokoFwIsoResourceAuto));
+ printf("%s;%zu;%zu\n", "HinokoFwIsoResourceAutoClass", sizeof(HinokoFwIsoResourceAutoClass), alignof(HinokoFwIsoResourceAutoClass));
+ printf("%s;%zu;%zu\n", "HinokoFwIsoResourceAutoError", sizeof(HinokoFwIsoResourceAutoError), alignof(HinokoFwIsoResourceAutoError));
+ printf("%s;%zu;%zu\n", "HinokoFwIsoResourceClass", sizeof(HinokoFwIsoResourceClass), alignof(HinokoFwIsoResourceClass));
+ printf("%s;%zu;%zu\n", "HinokoFwIsoResourceError", sizeof(HinokoFwIsoResourceError), alignof(HinokoFwIsoResourceError));
+ printf("%s;%zu;%zu\n", "HinokoFwIsoRxMultiple", sizeof(HinokoFwIsoRxMultiple), alignof(HinokoFwIsoRxMultiple));
+ printf("%s;%zu;%zu\n", "HinokoFwIsoRxMultipleClass", sizeof(HinokoFwIsoRxMultipleClass), alignof(HinokoFwIsoRxMultipleClass));
+ printf("%s;%zu;%zu\n", "HinokoFwIsoRxSingle", sizeof(HinokoFwIsoRxSingle), alignof(HinokoFwIsoRxSingle));
+ printf("%s;%zu;%zu\n", "HinokoFwIsoRxSingleClass", sizeof(HinokoFwIsoRxSingleClass), alignof(HinokoFwIsoRxSingleClass));
+ printf("%s;%zu;%zu\n", "HinokoFwIsoTx", sizeof(HinokoFwIsoTx), alignof(HinokoFwIsoTx));
+ printf("%s;%zu;%zu\n", "HinokoFwIsoTxClass", sizeof(HinokoFwIsoTxClass), alignof(HinokoFwIsoTxClass));
+ printf("%s;%zu;%zu\n", "HinokoFwScode", sizeof(HinokoFwScode), alignof(HinokoFwScode));
return 0;
}
diff --git a/hinoko-sys/tests/manual.h b/hinoko-sys/tests/manual.h
index 042ee96..f0d2948 100644
--- a/hinoko-sys/tests/manual.h
+++ b/hinoko-sys/tests/manual.h
@@ -1,10 +1,2 @@
// Feel free to edit this file, it won't be regenerated by gir generator unless removed.
-#include <hinoko-0.0/cycle_timer.h>
-#include <hinoko-0.0/fw_iso_ctx.h>
-#include <hinoko-0.0/fw_iso_resource.h>
-#include <hinoko-0.0/fw_iso_resource_auto.h>
-#include <hinoko-0.0/fw_iso_rx_multiple.h>
-#include <hinoko-0.0/fw_iso_rx_single.h>
-#include <hinoko-0.0/fw_iso_tx.h>
-#include <hinoko-0.0/hinoko_enum_types.h>
-#include <hinoko-0.0/hinoko_enums.h>
+#include <hinoko.h>
diff --git a/hinoko-sys/versions.txt b/hinoko-sys/versions.txt
index f742b92..4c944e1 100644
--- a/hinoko-sys/versions.txt
+++ b/hinoko-sys/versions.txt
@@ -1,2 +1,2 @@
-Generated by gir (https://github.com/gtk-rs/gir @ 1f84b54)
-from gir-files (https://github.com/gtk-rs/gir-files @ c31e734)
+Generated by gir (https://github.com/gtk-rs/gir @ 78e3d3c22343)
+from gir-files (https://github.com/gtk-rs/gir-files @ c31e73452763)