diff options
| author | Yuval Adam <_@yuv.al> | 2018-07-06 15:20:57 +0300 |
|---|---|---|
| committer | Yuval Adam <_@yuv.al> | 2018-07-06 15:20:57 +0300 |
| commit | a984107f78fe827e6a1731bbd38c071acfaeaee7 (patch) | |
| tree | e42451d3e45808bb6db9e8bba7eb904a5303c1fa | |
| -rw-r--r-- | Cargo.toml | 21 | ||||
| -rw-r--r-- | build.rs | 62 | ||||
| -rw-r--r-- | src/lib.rs | 233 | ||||
| -rw-r--r-- | tests/abi.rs | 249 | ||||
| -rw-r--r-- | tests/constant.c | 27 | ||||
| -rw-r--r-- | tests/layout.c | 12 | ||||
| -rw-r--r-- | tests/manual.h | 2 | ||||
| -rw-r--r-- | versions.txt | 2 |
8 files changed, 608 insertions, 0 deletions
diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..7b6cc27 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,21 @@ +[build-dependencies] +pkg-config = "0.3.7" + +[dependencies] +libc = "0.2" + +[dev-dependencies] +shell-words = "0.1.0" +tempdir = "0.3" + +[features] +dox = [] + +[lib] +name = "gssdp_sys" + +[package] +build = "build.rs" +links = "gssdp" +name = "gssdp-sys" +version = "0.2.0" diff --git a/build.rs b/build.rs new file mode 100644 index 0000000..821125b --- /dev/null +++ b/build.rs @@ -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 = "gssdp-1.0"; + let shared_libs = ["gssdp-1.0"]; + let version = { + "1.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), + } +} + diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 0000000..805a7cd --- /dev/null +++ b/src/lib.rs @@ -0,0 +1,233 @@ +// 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 + +#![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 libc; + +#[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 GSSDPError = c_int; +pub const GSSDP_ERROR_NO_IP_ADDRESS: GSSDPError = 0; +pub const GSSDP_ERROR_FAILED: GSSDPError = 1; + +// Constants +pub const GSSDP_ALL_RESOURCES: *const c_char = b"ssdp:all\0" as *const u8 as *const c_char; + +// Records +#[repr(C)] +#[derive(Copy, Clone)] +pub struct GSSDPClientClass { + pub parent_class: gobject::GObjectClass, + pub _gssdp_reserved1: Option<unsafe extern "C" fn()>, + pub _gssdp_reserved2: Option<unsafe extern "C" fn()>, + pub _gssdp_reserved3: Option<unsafe extern "C" fn()>, + pub _gssdp_reserved4: Option<unsafe extern "C" fn()>, +} + +impl ::std::fmt::Debug for GSSDPClientClass { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("GSSDPClientClass @ {:?}", self as *const _)) + .field("parent_class", &self.parent_class) + .field("_gssdp_reserved1", &self._gssdp_reserved1) + .field("_gssdp_reserved2", &self._gssdp_reserved2) + .field("_gssdp_reserved3", &self._gssdp_reserved3) + .field("_gssdp_reserved4", &self._gssdp_reserved4) + .finish() + } +} + +#[repr(C)] +pub struct GSSDPClientPrivate(c_void); + +impl ::std::fmt::Debug for GSSDPClientPrivate { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("GSSDPClientPrivate @ {:?}", self as *const _)) + .finish() + } +} + +#[repr(C)] +#[derive(Copy, Clone)] +pub struct GSSDPResourceBrowserClass { + pub parent_class: gobject::GObjectClass, + pub resource_available: Option<unsafe extern "C" fn(*mut GSSDPResourceBrowser, *const c_char, *const glib::GList)>, + pub resource_unavailable: Option<unsafe extern "C" fn(*mut GSSDPResourceBrowser, *const c_char)>, + pub _gssdp_reserved1: Option<unsafe extern "C" fn()>, + pub _gssdp_reserved2: Option<unsafe extern "C" fn()>, + pub _gssdp_reserved3: Option<unsafe extern "C" fn()>, + pub _gssdp_reserved4: Option<unsafe extern "C" fn()>, +} + +impl ::std::fmt::Debug for GSSDPResourceBrowserClass { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("GSSDPResourceBrowserClass @ {:?}", self as *const _)) + .field("parent_class", &self.parent_class) + .field("resource_available", &self.resource_available) + .field("resource_unavailable", &self.resource_unavailable) + .field("_gssdp_reserved1", &self._gssdp_reserved1) + .field("_gssdp_reserved2", &self._gssdp_reserved2) + .field("_gssdp_reserved3", &self._gssdp_reserved3) + .field("_gssdp_reserved4", &self._gssdp_reserved4) + .finish() + } +} + +#[repr(C)] +pub struct GSSDPResourceBrowserPrivate(c_void); + +impl ::std::fmt::Debug for GSSDPResourceBrowserPrivate { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("GSSDPResourceBrowserPrivate @ {:?}", self as *const _)) + .finish() + } +} + +#[repr(C)] +#[derive(Copy, Clone)] +pub struct GSSDPResourceGroupClass { + pub parent_class: gobject::GObjectClass, + pub _gssdp_reserved1: Option<unsafe extern "C" fn()>, + pub _gssdp_reserved2: Option<unsafe extern "C" fn()>, + pub _gssdp_reserved3: Option<unsafe extern "C" fn()>, + pub _gssdp_reserved4: Option<unsafe extern "C" fn()>, +} + +impl ::std::fmt::Debug for GSSDPResourceGroupClass { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("GSSDPResourceGroupClass @ {:?}", self as *const _)) + .field("parent_class", &self.parent_class) + .field("_gssdp_reserved1", &self._gssdp_reserved1) + .field("_gssdp_reserved2", &self._gssdp_reserved2) + .field("_gssdp_reserved3", &self._gssdp_reserved3) + .field("_gssdp_reserved4", &self._gssdp_reserved4) + .finish() + } +} + +#[repr(C)] +pub struct GSSDPResourceGroupPrivate(c_void); + +impl ::std::fmt::Debug for GSSDPResourceGroupPrivate { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("GSSDPResourceGroupPrivate @ {:?}", self as *const _)) + .finish() + } +} + +// Classes +#[repr(C)] +#[derive(Copy, Clone)] +pub struct GSSDPClient { + pub parent: gobject::GObject, + pub priv_: *mut GSSDPClientPrivate, +} + +impl ::std::fmt::Debug for GSSDPClient { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("GSSDPClient @ {:?}", self as *const _)) + .field("parent", &self.parent) + .field("priv_", &self.priv_) + .finish() + } +} + +#[repr(C)] +#[derive(Copy, Clone)] +pub struct GSSDPResourceBrowser { + pub parent: gobject::GObject, + pub priv_: *mut GSSDPResourceBrowserPrivate, +} + +impl ::std::fmt::Debug for GSSDPResourceBrowser { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("GSSDPResourceBrowser @ {:?}", self as *const _)) + .field("parent", &self.parent) + .field("priv_", &self.priv_) + .finish() + } +} + +#[repr(C)] +#[derive(Copy, Clone)] +pub struct GSSDPResourceGroup { + pub parent: gobject::GObject, + pub priv_: *mut GSSDPResourceGroupPrivate, +} + +impl ::std::fmt::Debug for GSSDPResourceGroup { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("GSSDPResourceGroup @ {:?}", self as *const _)) + .field("parent", &self.parent) + .field("priv_", &self.priv_) + .finish() + } +} + +extern "C" { + + //========================================================================= + // GSSDPClient + //========================================================================= + pub fn gssdp_client_get_type() -> GType; + pub fn gssdp_client_new(main_context: *mut glib::GMainContext, iface: *const c_char, error: *mut *mut glib::GError) -> *mut GSSDPClient; + pub fn gssdp_client_new_with_port(iface: *const c_char, msearch_port: u16, error: *mut *mut glib::GError) -> *mut GSSDPClient; + pub fn gssdp_client_add_cache_entry(client: *mut GSSDPClient, ip_address: *const c_char, user_agent: *const c_char); + pub fn gssdp_client_append_header(client: *mut GSSDPClient, name: *const c_char, value: *const c_char); + pub fn gssdp_client_clear_headers(client: *mut GSSDPClient); + pub fn gssdp_client_get_active(client: *mut GSSDPClient) -> gboolean; + pub fn gssdp_client_get_host_ip(client: *mut GSSDPClient) -> *const c_char; + pub fn gssdp_client_get_interface(client: *mut GSSDPClient) -> *const c_char; + pub fn gssdp_client_get_main_context(client: *mut GSSDPClient) -> *mut glib::GMainContext; + pub fn gssdp_client_get_network(client: *mut GSSDPClient) -> *const c_char; + pub fn gssdp_client_get_server_id(client: *mut GSSDPClient) -> *const c_char; + pub fn gssdp_client_guess_user_agent(client: *mut GSSDPClient, ip_address: *const c_char) -> *const c_char; + pub fn gssdp_client_remove_header(client: *mut GSSDPClient, name: *const c_char); + pub fn gssdp_client_set_network(client: *mut GSSDPClient, network: *const c_char); + pub fn gssdp_client_set_server_id(client: *mut GSSDPClient, server_id: *const c_char); + + //========================================================================= + // GSSDPResourceBrowser + //========================================================================= + pub fn gssdp_resource_browser_get_type() -> GType; + pub fn gssdp_resource_browser_new(client: *mut GSSDPClient, target: *const c_char) -> *mut GSSDPResourceBrowser; + pub fn gssdp_resource_browser_get_active(resource_browser: *mut GSSDPResourceBrowser) -> gboolean; + pub fn gssdp_resource_browser_get_client(resource_browser: *mut GSSDPResourceBrowser) -> *mut GSSDPClient; + pub fn gssdp_resource_browser_get_mx(resource_browser: *mut GSSDPResourceBrowser) -> c_ushort; + pub fn gssdp_resource_browser_get_target(resource_browser: *mut GSSDPResourceBrowser) -> *const c_char; + pub fn gssdp_resource_browser_rescan(resource_browser: *mut GSSDPResourceBrowser) -> gboolean; + pub fn gssdp_resource_browser_set_active(resource_browser: *mut GSSDPResourceBrowser, active: gboolean); + pub fn gssdp_resource_browser_set_mx(resource_browser: *mut GSSDPResourceBrowser, mx: c_ushort); + pub fn gssdp_resource_browser_set_target(resource_browser: *mut GSSDPResourceBrowser, target: *const c_char); + + //========================================================================= + // GSSDPResourceGroup + //========================================================================= + pub fn gssdp_resource_group_get_type() -> GType; + pub fn gssdp_resource_group_new(client: *mut GSSDPClient) -> *mut GSSDPResourceGroup; + pub fn gssdp_resource_group_add_resource(resource_group: *mut GSSDPResourceGroup, target: *const c_char, usn: *const c_char, locations: *mut glib::GList) -> c_uint; + pub fn gssdp_resource_group_add_resource_simple(resource_group: *mut GSSDPResourceGroup, target: *const c_char, usn: *const c_char, location: *const c_char) -> c_uint; + pub fn gssdp_resource_group_get_available(resource_group: *mut GSSDPResourceGroup) -> gboolean; + pub fn gssdp_resource_group_get_client(resource_group: *mut GSSDPResourceGroup) -> *mut GSSDPClient; + pub fn gssdp_resource_group_get_max_age(resource_group: *mut GSSDPResourceGroup) -> c_uint; + pub fn gssdp_resource_group_get_message_delay(resource_group: *mut GSSDPResourceGroup) -> c_uint; + pub fn gssdp_resource_group_remove_resource(resource_group: *mut GSSDPResourceGroup, resource_id: c_uint); + pub fn gssdp_resource_group_set_available(resource_group: *mut GSSDPResourceGroup, available: gboolean); + pub fn gssdp_resource_group_set_max_age(resource_group: *mut GSSDPResourceGroup, max_age: c_uint); + pub fn gssdp_resource_group_set_message_delay(resource_group: *mut GSSDPResourceGroup, message_delay: c_uint); + + //========================================================================= + // Other functions + //========================================================================= + pub fn gssdp_error_quark() -> glib::GQuark; + +} diff --git a/tests/abi.rs b/tests/abi.rs new file mode 100644 index 0000000..05e7f5a --- /dev/null +++ b/tests/abi.rs @@ -0,0 +1,249 @@ +// 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 + +extern crate gssdp_sys; +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 gssdp_sys::*; + +static PACKAGES: &[&str] = &["gssdp-1.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)] = &[ + ("GSSDPClient", Layout {size: size_of::<GSSDPClient>(), alignment: align_of::<GSSDPClient>()}), + ("GSSDPClientClass", Layout {size: size_of::<GSSDPClientClass>(), alignment: align_of::<GSSDPClientClass>()}), + ("GSSDPError", Layout {size: size_of::<GSSDPError>(), alignment: align_of::<GSSDPError>()}), + ("GSSDPResourceBrowser", Layout {size: size_of::<GSSDPResourceBrowser>(), alignment: align_of::<GSSDPResourceBrowser>()}), + ("GSSDPResourceBrowserClass", Layout {size: size_of::<GSSDPResourceBrowserClass>(), alignment: align_of::<GSSDPResourceBrowserClass>()}), + ("GSSDPResourceGroup", Layout {size: size_of::<GSSDPResourceGroup>(), alignment: align_of::<GSSDPResourceGroup>()}), + ("GSSDPResourceGroupClass", Layout {size: size_of::<GSSDPResourceGroupClass>(), alignment: align_of::<GSSDPResourceGroupClass>()}), +]; + +const RUST_CONSTANTS: &[(&str, &str)] = &[ + ("GSSDP_ALL_RESOURCES", "ssdp:all"), + ("GSSDP_ERROR_FAILED", "1"), + ("GSSDP_ERROR_NO_IP_ADDRESS", "0"), +]; + + diff --git a/tests/constant.c b/tests/constant.c new file mode 100644 index 0000000..dcd45c5 --- /dev/null +++ b/tests/constant.c @@ -0,0 +1,27 @@ +// 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 + +#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; +} diff --git a/tests/layout.c b/tests/layout.c new file mode 100644 index 0000000..45f2ef4 --- /dev/null +++ b/tests/layout.c @@ -0,0 +1,12 @@ +// 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 + +#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; +} diff --git a/tests/manual.h b/tests/manual.h new file mode 100644 index 0000000..33968c2 --- /dev/null +++ b/tests/manual.h @@ -0,0 +1,2 @@ +// Feel free to edit this file, it won't be regenerated by gir generator unless removed. + diff --git a/versions.txt b/versions.txt new file mode 100644 index 0000000..9370acf --- /dev/null +++ b/versions.txt @@ -0,0 +1,2 @@ +Generated by gir (https://github.com/gtk-rs/gir @ 800fb8f) +from gir-files (https://github.com/gtk-rs/gir-files @ 317dd14) |
