From 3decba546e8eecfc70738ad708d7330d171045d3 Mon Sep 17 00:00:00 2001 From: Felix Krull Date: Tue, 21 May 2019 19:38:30 +0200 Subject: [PATCH] Switch to generated CollectionRef --- rust-bindings/rust/Makefile | 3 +- rust-bindings/rust/conf/ostree.toml | 3 +- .../rust/src/{ => auto}/collection_ref.rs | 29 +++++-------------- rust-bindings/rust/src/auto/deployment.rs | 4 +-- rust-bindings/rust/src/auto/mod.rs | 5 ++++ rust-bindings/rust/src/auto/repo.rs | 2 +- rust-bindings/rust/src/auto/se_policy.rs | 2 +- rust-bindings/rust/src/auto/sysroot.rs | 2 +- .../rust/src/auto/sysroot_upgrader.rs | 2 +- rust-bindings/rust/src/auto/versions.txt | 2 +- rust-bindings/rust/src/lib.rs | 6 +--- 11 files changed, 24 insertions(+), 36 deletions(-) rename rust-bindings/rust/src/{ => auto}/collection_ref.rs (60%) diff --git a/rust-bindings/rust/Makefile b/rust-bindings/rust/Makefile index 1bf5acda..5108e84b 100644 --- a/rust-bindings/rust/Makefile +++ b/rust-bindings/rust/Makefile @@ -5,7 +5,8 @@ all: gir/ostree gir/ostree-sys # -- gir generation -- target/tools/bin/gir: - cargo install --root target/tools --git https://github.com/gtk-rs/gir.git --rev fec179c697a03e4aa98c610f7b98fd1b0ceb9344 -- gir + #cargo install --root target/tools --git https://github.com/gtk-rs/gir.git --rev fec179c697a03e4aa98c610f7b98fd1b0ceb9344 -- gir + cargo install --root target/tools --git https://github.com/fkrull/gir.git --branch fixup-gconstpointer -- gir gir/%: target/tools/bin/gir target/tools/bin/gir -c conf/$*.toml diff --git a/rust-bindings/rust/conf/ostree.toml b/rust-bindings/rust/conf/ostree.toml index 514f4870..f8636fe0 100644 --- a/rust-bindings/rust/conf/ostree.toml +++ b/rust-bindings/rust/conf/ostree.toml @@ -66,8 +66,7 @@ os_tree = "ostree" [[object]] name = "OSTree.CollectionRef" -status = "manual" - # for reference: the settings used to generate the hand-tuned implementation +status = "generate" [[object.function]] # helper functions for NULL-terminated arrays pattern = "dupv|freev" diff --git a/rust-bindings/rust/src/collection_ref.rs b/rust-bindings/rust/src/auto/collection_ref.rs similarity index 60% rename from rust-bindings/rust/src/collection_ref.rs rename to rust-bindings/rust/src/auto/collection_ref.rs index c99542ea..b3c4c438 100644 --- a/rust-bindings/rust/src/collection_ref.rs +++ b/rust-bindings/rust/src/auto/collection_ref.rs @@ -1,4 +1,7 @@ -// Based on a file generated by gir. Changes are marked below. +// 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 + #[cfg(any(feature = "v2018_6", feature = "dox"))] use glib::translate::*; use glib_sys; @@ -21,34 +24,21 @@ impl CollectionRef { #[cfg(any(feature = "v2018_6", feature = "dox"))] pub fn new(collection_id: Option<&str>, ref_name: &str) -> Option { unsafe { - from_glib_full(ostree_sys::ostree_collection_ref_new( - collection_id.to_glib_none().0, - ref_name.to_glib_none().0, - )) + from_glib_full(ostree_sys::ostree_collection_ref_new(collection_id.to_glib_none().0, ref_name.to_glib_none().0)) } } #[cfg(any(feature = "v2018_6", feature = "dox"))] fn equal(&self, ref2: &CollectionRef) -> bool { unsafe { - // CHANGE: both instances of *mut to *const - from_glib(ostree_sys::ostree_collection_ref_equal( - ToGlibPtr::<*const ostree_sys::OstreeCollectionRef>::to_glib_none(self).0 - as glib_sys::gconstpointer, - ToGlibPtr::<*const ostree_sys::OstreeCollectionRef>::to_glib_none(ref2).0 - as glib_sys::gconstpointer, - )) + from_glib(ostree_sys::ostree_collection_ref_equal(ToGlibPtr::<*const ostree_sys::OstreeCollectionRef>::to_glib_none(self).0 as glib_sys::gconstpointer, ToGlibPtr::<*const ostree_sys::OstreeCollectionRef>::to_glib_none(ref2).0 as glib_sys::gconstpointer)) } } #[cfg(any(feature = "v2018_6", feature = "dox"))] fn hash(&self) -> u32 { unsafe { - // CHANGE: *mut to *const - ostree_sys::ostree_collection_ref_hash( - ToGlibPtr::<*const ostree_sys::OstreeCollectionRef>::to_glib_none(self).0 - as glib_sys::gconstpointer, - ) + ostree_sys::ostree_collection_ref_hash(ToGlibPtr::<*const ostree_sys::OstreeCollectionRef>::to_glib_none(self).0 as glib_sys::gconstpointer) } } } @@ -64,10 +54,7 @@ impl Eq for CollectionRef {} impl hash::Hash for CollectionRef { #[inline] - fn hash(&self, state: &mut H) - where - H: hash::Hasher, - { + fn hash(&self, state: &mut H) where H: hash::Hasher { hash::Hash::hash(&self.hash(), state) } } diff --git a/rust-bindings/rust/src/auto/deployment.rs b/rust-bindings/rust/src/auto/deployment.rs index e2ed855a..a8b4a7e3 100644 --- a/rust-bindings/rust/src/auto/deployment.rs +++ b/rust-bindings/rust/src/auto/deployment.rs @@ -35,7 +35,7 @@ impl Deployment { pub fn equal(&self, bp: &Deployment) -> bool { unsafe { - from_glib(ostree_sys::ostree_deployment_equal(ToGlibPtr::<*mut ostree_sys::OstreeDeployment>::to_glib_none(self).0 as glib_sys::gconstpointer, ToGlibPtr::<*mut ostree_sys::OstreeDeployment>::to_glib_none(bp).0 as glib_sys::gconstpointer)) + from_glib(ostree_sys::ostree_deployment_equal(ToGlibPtr::<*const ostree_sys::OstreeDeployment>::to_glib_none(self).0 as glib_sys::gconstpointer, ToGlibPtr::<*const ostree_sys::OstreeDeployment>::to_glib_none(bp).0 as glib_sys::gconstpointer)) } } @@ -140,7 +140,7 @@ impl Deployment { pub fn hash(&self) -> u32 { unsafe { - ostree_sys::ostree_deployment_hash(ToGlibPtr::<*mut ostree_sys::OstreeDeployment>::to_glib_none(self).0 as glib_sys::gconstpointer) + ostree_sys::ostree_deployment_hash(ToGlibPtr::<*const ostree_sys::OstreeDeployment>::to_glib_none(self).0 as glib_sys::gconstpointer) } } diff --git a/rust-bindings/rust/src/auto/mod.rs b/rust-bindings/rust/src/auto/mod.rs index 9afc9d78..5db35766 100644 --- a/rust-bindings/rust/src/auto/mod.rs +++ b/rust-bindings/rust/src/auto/mod.rs @@ -35,6 +35,11 @@ pub use self::sysroot::{Sysroot, SysrootClass}; mod sysroot_upgrader; pub use self::sysroot_upgrader::{SysrootUpgrader, SysrootUpgraderClass}; +#[cfg(any(feature = "v2018_6", feature = "dox"))] +mod collection_ref; +#[cfg(any(feature = "v2018_6", feature = "dox"))] +pub use self::collection_ref::CollectionRef; + #[cfg(any(feature = "v2018_6", feature = "dox"))] mod remote; #[cfg(any(feature = "v2018_6", feature = "dox"))] diff --git a/rust-bindings/rust/src/auto/repo.rs b/rust-bindings/rust/src/auto/repo.rs index 57531243..dfe9f3e4 100644 --- a/rust-bindings/rust/src/auto/repo.rs +++ b/rust-bindings/rust/src/auto/repo.rs @@ -31,7 +31,7 @@ use glib::GString; use glib::StaticType; use glib::Value; use glib::object::IsA; -use glib::object::ObjectType as _; +use glib::object::ObjectType as ObjectType_; use glib::signal::SignalHandlerId; use glib::signal::connect_raw; use glib::translate::*; diff --git a/rust-bindings/rust/src/auto/se_policy.rs b/rust-bindings/rust/src/auto/se_policy.rs index f52c9535..c930c5db 100644 --- a/rust-bindings/rust/src/auto/se_policy.rs +++ b/rust-bindings/rust/src/auto/se_policy.rs @@ -9,7 +9,7 @@ use glib::GString; use glib::StaticType; use glib::Value; use glib::object::IsA; -use glib::object::ObjectType as _; +use glib::object::ObjectType as ObjectType_; use glib::translate::*; use gobject_sys; use ostree_sys; diff --git a/rust-bindings/rust/src/auto/sysroot.rs b/rust-bindings/rust/src/auto/sysroot.rs index 60eae219..aee88eb7 100644 --- a/rust-bindings/rust/src/auto/sysroot.rs +++ b/rust-bindings/rust/src/auto/sysroot.rs @@ -16,7 +16,7 @@ use glib; use glib::GString; use glib::object::IsA; #[cfg(any(feature = "v2017_10", feature = "dox"))] -use glib::object::ObjectType as _; +use glib::object::ObjectType as ObjectType_; #[cfg(any(feature = "v2017_10", feature = "dox"))] use glib::signal::SignalHandlerId; #[cfg(any(feature = "v2017_10", feature = "dox"))] diff --git a/rust-bindings/rust/src/auto/sysroot_upgrader.rs b/rust-bindings/rust/src/auto/sysroot_upgrader.rs index 4e51db9c..4b95e1e9 100644 --- a/rust-bindings/rust/src/auto/sysroot_upgrader.rs +++ b/rust-bindings/rust/src/auto/sysroot_upgrader.rs @@ -15,7 +15,7 @@ use glib::GString; use glib::StaticType; use glib::Value; use glib::object::IsA; -use glib::object::ObjectType as _; +use glib::object::ObjectType as ObjectType_; use glib::translate::*; use gobject_sys; use ostree_sys; diff --git a/rust-bindings/rust/src/auto/versions.txt b/rust-bindings/rust/src/auto/versions.txt index be52760a..f51e58a2 100644 --- a/rust-bindings/rust/src/auto/versions.txt +++ b/rust-bindings/rust/src/auto/versions.txt @@ -1,2 +1,2 @@ -Generated by gir (https://github.com/gtk-rs/gir @ fec179c) +Generated by gir (https://github.com/gtk-rs/gir @ 1bff597) from gir-files (https://github.com/gtk-rs/gir-files @ ???) diff --git a/rust-bindings/rust/src/lib.rs b/rust-bindings/rust/src/lib.rs index 5ac6af24..b69a7018 100644 --- a/rust-bindings/rust/src/lib.rs +++ b/rust-bindings/rust/src/lib.rs @@ -19,12 +19,8 @@ pub use crate::auto::functions::*; pub use crate::auto::*; // handwritten code -#[cfg(any(feature = "v2018_6", feature = "dox"))] -mod collection_ref; -mod repo; -#[cfg(any(feature = "v2018_6", feature = "dox"))] -pub use crate::collection_ref::*; mod object_name; +mod repo; pub use crate::object_name::*; // tests