Skip to content

Commit

Permalink
remove g_param_spec_types link alltogether
Browse files Browse the repository at this point in the history
  • Loading branch information
eerii committed Sep 19, 2024
1 parent df58d90 commit d77be04
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 88 deletions.
2 changes: 1 addition & 1 deletion glib/gobject-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ v2_82 = ["v2_80"]
name = "gobject_sys"

[package]
build = "build_manual.rs"
build = "build.rs"
description = "FFI bindings to libgobject-2.0"
keywords = ["gobject", "ffi", "gtk-rs", "gnome"]
name = "gobject-sys"
Expand Down
23 changes: 0 additions & 23 deletions glib/gobject-sys/build_manual.rs

This file was deleted.

4 changes: 0 additions & 4 deletions glib/gobject-sys/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@

use glib_sys as glib;

mod manual;

pub use manual::*;

#[allow(unused_imports)]
use libc::{
c_char, c_double, c_float, c_int, c_long, c_short, c_uchar, c_uint, c_ulong, c_ushort, c_void,
Expand Down
31 changes: 0 additions & 31 deletions glib/gobject-sys/src/manual.rs

This file was deleted.

89 changes: 60 additions & 29 deletions glib/src/param_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -297,13 +297,12 @@ pub unsafe trait ParamSpecType:
}

macro_rules! define_param_spec {
($rust_type:ident, $ffi_type:path, $rust_type_offset:expr) => {
($rust_type:ident, $ffi_type:path, $type_name:literal) => {
impl StaticType for $rust_type {
#[inline]
fn static_type() -> Type {
unsafe {
from_glib(gobject_sys::g_param_spec_types_get_type($rust_type_offset))
}
const NAME: &CStr = unsafe { std::ffi::CStr::from_bytes_with_nul_unchecked(concat!($type_name, "\0").as_bytes()) };
unsafe { from_glib(gobject_ffi::g_type_from_name(NAME.as_ptr())) }
}
}

Expand Down Expand Up @@ -551,8 +550,8 @@ macro_rules! define_param_spec_min_max {
}

macro_rules! define_param_spec_numeric {
($rust_type:ident, $ffi_type:path, $value_type:ty, $rust_type_offset:expr, $ffi_fun:ident) => {
define_param_spec!($rust_type, $ffi_type, $rust_type_offset);
($rust_type:ident, $ffi_type:path, $value_type:ty, $type_name:literal, $ffi_fun:ident) => {
define_param_spec!($rust_type, $ffi_type, $type_name);
define_param_spec_default!($rust_type, $ffi_type, $value_type, |x| x);
define_param_spec_min_max!($rust_type, $ffi_type, $value_type);

Expand Down Expand Up @@ -782,7 +781,7 @@ define_param_spec_numeric!(
ParamSpecChar,
gobject_ffi::GParamSpecChar,
i8,
0,
"GParamChar",
g_param_spec_char
);

Expand All @@ -802,7 +801,7 @@ define_param_spec_numeric!(
ParamSpecUChar,
gobject_ffi::GParamSpecUChar,
u8,
1,
"GParamUChar",
g_param_spec_uchar
);

Expand All @@ -823,7 +822,11 @@ wrapper! {
unref => |ptr| gobject_ffi::g_param_spec_unref(ptr as *mut gobject_ffi::GParamSpec),
}
}
define_param_spec!(ParamSpecBoolean, gobject_ffi::GParamSpecBoolean, 2);
define_param_spec!(
ParamSpecBoolean,
gobject_ffi::GParamSpecBoolean,
"GParamBoolean"
);

define_param_spec_default!(
ParamSpecBoolean,
Expand Down Expand Up @@ -874,7 +877,7 @@ define_param_spec_numeric!(
ParamSpecInt,
gobject_ffi::GParamSpecInt,
i32,
3,
"GParamInt",
g_param_spec_int
);

Expand All @@ -894,7 +897,7 @@ define_param_spec_numeric!(
ParamSpecUInt,
gobject_ffi::GParamSpecUInt,
u32,
4,
"GParamUInt",
g_param_spec_uint
);

Expand All @@ -919,7 +922,7 @@ define_param_spec_numeric!(
ParamSpecLong,
gobject_ffi::GParamSpecLong,
libc::c_long,
5,
"GParamLong",
g_param_spec_long
);

Expand All @@ -944,7 +947,7 @@ define_param_spec_numeric!(
ParamSpecULong,
gobject_ffi::GParamSpecULong,
libc::c_ulong,
6,
"GParamULong",
g_param_spec_ulong
);

Expand All @@ -969,7 +972,7 @@ define_param_spec_numeric!(
ParamSpecInt64,
gobject_ffi::GParamSpecInt64,
i64,
7,
"GParamInt64",
g_param_spec_int64
);

Expand All @@ -994,7 +997,7 @@ define_param_spec_numeric!(
ParamSpecUInt64,
gobject_ffi::GParamSpecUInt64,
u64,
8,
"GParamUInt64",
g_param_spec_uint64
);

Expand All @@ -1015,7 +1018,11 @@ wrapper! {
unref => |ptr| gobject_ffi::g_param_spec_unref(ptr as *mut gobject_ffi::GParamSpec),
}
}
define_param_spec!(ParamSpecUnichar, gobject_ffi::GParamSpecUnichar, 9);
define_param_spec!(
ParamSpecUnichar,
gobject_ffi::GParamSpecUnichar,
"GParamUnichar"
);
define_param_spec_default!(ParamSpecUnichar, gobject_ffi::GParamSpecUnichar, Result<char, CharTryFromError>, TryFrom::try_from);

impl ParamSpecUnichar {
Expand Down Expand Up @@ -1057,7 +1064,7 @@ wrapper! {
unref => |ptr| gobject_ffi::g_param_spec_unref(ptr as *mut gobject_ffi::GParamSpec),
}
}
define_param_spec!(ParamSpecEnum, gobject_ffi::GParamSpecEnum, 10);
define_param_spec!(ParamSpecEnum, gobject_ffi::GParamSpecEnum, "GParamEnum");

impl ParamSpecEnum {
unsafe fn new_unchecked<'a>(
Expand Down Expand Up @@ -1201,7 +1208,7 @@ wrapper! {
unref => |ptr| gobject_ffi::g_param_spec_unref(ptr as *mut gobject_ffi::GParamSpec),
}
}
define_param_spec!(ParamSpecFlags, gobject_ffi::GParamSpecFlags, 11);
define_param_spec!(ParamSpecFlags, gobject_ffi::GParamSpecFlags, "GParamFlags");

impl ParamSpecFlags {
unsafe fn new_unchecked<'a>(
Expand Down Expand Up @@ -1344,7 +1351,7 @@ define_param_spec_numeric!(
ParamSpecFloat,
gobject_ffi::GParamSpecFloat,
f32,
12,
"GParamFloat",
g_param_spec_float
);

Expand All @@ -1369,7 +1376,7 @@ define_param_spec_numeric!(
ParamSpecDouble,
gobject_ffi::GParamSpecDouble,
f64,
13,
"GParamDouble",
g_param_spec_double
);

Expand All @@ -1390,7 +1397,11 @@ wrapper! {
unref => |ptr| gobject_ffi::g_param_spec_unref(ptr as *mut gobject_ffi::GParamSpec),
}
}
define_param_spec!(ParamSpecString, gobject_ffi::GParamSpecString, 14);
define_param_spec!(
ParamSpecString,
gobject_ffi::GParamSpecString,
"GParamString"
);

define_param_spec_default!(
ParamSpecString,
Expand Down Expand Up @@ -1499,7 +1510,7 @@ wrapper! {
unref => |ptr| gobject_ffi::g_param_spec_unref(ptr as *mut gobject_ffi::GParamSpec),
}
}
define_param_spec!(ParamSpecParam, gobject_ffi::GParamSpecParam, 15);
define_param_spec!(ParamSpecParam, gobject_ffi::GParamSpecParam, "GParamParam");

impl ParamSpecParam {
unsafe fn new_unchecked<'a>(
Expand Down Expand Up @@ -1541,7 +1552,7 @@ wrapper! {
unref => |ptr| gobject_ffi::g_param_spec_unref(ptr as *mut gobject_ffi::GParamSpec),
}
}
define_param_spec!(ParamSpecBoxed, gobject_ffi::GParamSpecBoxed, 16);
define_param_spec!(ParamSpecBoxed, gobject_ffi::GParamSpecBoxed, "GParamBoxed");

impl ParamSpecBoxed {
unsafe fn new_unchecked<'a>(
Expand Down Expand Up @@ -1629,7 +1640,11 @@ wrapper! {
unref => |ptr| gobject_ffi::g_param_spec_unref(ptr as *mut gobject_ffi::GParamSpec),
}
}
define_param_spec!(ParamSpecPointer, gobject_ffi::GParamSpecPointer, 17);
define_param_spec!(
ParamSpecPointer,
gobject_ffi::GParamSpecPointer,
"GParamPointer"
);

impl ParamSpecPointer {
unsafe fn new_unchecked<'a>(
Expand Down Expand Up @@ -1665,7 +1680,11 @@ wrapper! {
unref => |ptr| gobject_ffi::g_param_spec_unref(ptr as *mut gobject_ffi::GParamSpec),
}
}
define_param_spec!(ParamSpecValueArray, gobject_ffi::GParamSpecValueArray, 18);
define_param_spec!(
ParamSpecValueArray,
gobject_ffi::GParamSpecValueArray,
"GParamValueArray"
);

impl ParamSpecValueArray {
unsafe fn new_unchecked<'a>(
Expand Down Expand Up @@ -1785,7 +1804,11 @@ wrapper! {
unref => |ptr| gobject_ffi::g_param_spec_unref(ptr as *mut gobject_ffi::GParamSpec),
}
}
define_param_spec!(ParamSpecObject, gobject_ffi::GParamSpecObject, 19);
define_param_spec!(
ParamSpecObject,
gobject_ffi::GParamSpecObject,
"GParamObject"
);

impl ParamSpecObject {
unsafe fn new_unchecked<'a>(
Expand Down Expand Up @@ -1873,7 +1896,11 @@ wrapper! {
unref => |ptr| gobject_ffi::g_param_spec_unref(ptr as *mut gobject_ffi::GParamSpec),
}
}
define_param_spec!(ParamSpecOverride, gobject_ffi::GParamSpecOverride, 20);
define_param_spec!(
ParamSpecOverride,
gobject_ffi::GParamSpecOverride,
"GParamOverride"
);

impl ParamSpecOverride {
unsafe fn new_unchecked(name: &str, overridden: impl AsRef<ParamSpec>) -> ParamSpec {
Expand Down Expand Up @@ -1981,7 +2008,7 @@ wrapper! {
unref => |ptr| gobject_ffi::g_param_spec_unref(ptr as *mut gobject_ffi::GParamSpec),
}
}
define_param_spec!(ParamSpecGType, gobject_ffi::GParamSpecGType, 21);
define_param_spec!(ParamSpecGType, gobject_ffi::GParamSpecGType, "GParamGType");

impl ParamSpecGType {
unsafe fn new_unchecked<'a>(
Expand Down Expand Up @@ -2021,7 +2048,11 @@ wrapper! {
unref => |ptr| gobject_ffi::g_param_spec_unref(ptr as *mut gobject_ffi::GParamSpec),
}
}
define_param_spec!(ParamSpecVariant, gobject_ffi::GParamSpecVariant, 22);
define_param_spec!(
ParamSpecVariant,
gobject_ffi::GParamSpecVariant,
"GParamVariant"
);

define_param_spec_default!(
ParamSpecVariant,
Expand Down

0 comments on commit d77be04

Please sign in to comment.