[niepce] npc-engine: bind LibMetadata with cxx
- From: Hubert Figuière <hub src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [niepce] npc-engine: bind LibMetadata with cxx
- Date: Sun, 16 Oct 2022 02:25:38 +0000 (UTC)
commit d32fbbafda03df55a6615c4f227590d58b34f607
Author: Hubert Figuière <hub figuiere net>
Date: Sat Oct 15 22:19:43 2022 -0400
npc-engine: bind LibMetadata with cxx
crates/npc-engine/build.rs | 1 +
crates/npc-engine/src/db/libmetadata.rs | 9 ++++-----
crates/npc-engine/src/lib.rs | 8 +++++++-
src/niepce/ui/gridviewmodule.cpp | 2 +-
src/rust_bindings.hpp | 2 +-
5 files changed, 14 insertions(+), 8 deletions(-)
---
diff --git a/crates/npc-engine/build.rs b/crates/npc-engine/build.rs
index 6ce29916..98867eda 100644
--- a/crates/npc-engine/build.rs
+++ b/crates/npc-engine/build.rs
@@ -33,6 +33,7 @@ fn main() {
.exclude_item("Keyword")
.exclude_item("Label")
.exclude_item("LibFile")
+ .exclude_item("LibMetadata")
// Ensure these are opaque as generics are still a problem.
.exclude_item("NiepcePropertySet")
.exclude_item("NiepcePropertyBag")
diff --git a/crates/npc-engine/src/db/libmetadata.rs b/crates/npc-engine/src/db/libmetadata.rs
index a61b4715..38642e9a 100644
--- a/crates/npc-engine/src/db/libmetadata.rs
+++ b/crates/npc-engine/src/db/libmetadata.rs
@@ -74,6 +74,10 @@ impl LibMetadata {
}
}
+ pub fn id(&self) -> LibraryId {
+ self.id
+ }
+
pub fn serialize_inline(&self) -> String {
self.xmp.serialize_inline()
}
@@ -292,11 +296,6 @@ impl FromDb for LibMetadata {
}
}
-#[no_mangle]
-pub extern "C" fn engine_libmetadata_get_id(meta: &LibMetadata) -> LibraryId {
- meta.id
-}
-
#[no_mangle]
pub extern "C" fn engine_libmetadata_to_properties(
meta: &LibMetadata,
diff --git a/crates/npc-engine/src/lib.rs b/crates/npc-engine/src/lib.rs
index 3e73af00..7cbad7ec 100644
--- a/crates/npc-engine/src/lib.rs
+++ b/crates/npc-engine/src/lib.rs
@@ -104,7 +104,7 @@ pub extern "C" fn eng_property_bag_set_value(
b.set_value(key.into(), v.clone())
}
-use crate::db::{Keyword, Label, LibFile};
+use crate::db::{Keyword, Label, LibFile, LibMetadata};
#[cxx::bridge(namespace = "eng")]
mod ffi {
@@ -161,4 +161,10 @@ mod ffi {
}
impl Box<LibFile> {}
+
+ extern "Rust" {
+ type LibMetadata;
+
+ fn id(&self) -> i64;
+ }
}
diff --git a/src/niepce/ui/gridviewmodule.cpp b/src/niepce/ui/gridviewmodule.cpp
index 1aef8204..1746291b 100644
--- a/src/niepce/ui/gridviewmodule.cpp
+++ b/src/niepce/ui/gridviewmodule.cpp
@@ -61,7 +61,7 @@ GridViewModule::on_lib_notification(const eng::LibNotification &ln)
auto lm = engine_library_notification_get_libmetadata(&ln);
DBG_OUT("received metadata");
if (lm) {
- m_metapanecontroller->display(engine_libmetadata_get_id(lm), lm);
+ m_metapanecontroller->display(lm->id(), lm);
} else {
ERR_OUT("Invalid LibMetadata (nullptr)");
}
diff --git a/src/rust_bindings.hpp b/src/rust_bindings.hpp
index 6608efa8..9539c612 100644
--- a/src/rust_bindings.hpp
+++ b/src/rust_bindings.hpp
@@ -38,6 +38,7 @@ typedef fwk::PropertyValue PropertyValue;
typedef fwk::RgbColour RgbColour;
typedef eng::Label Label;
typedef eng::LibFile LibFile;
+typedef eng::LibMetadata LibMetadata;
typedef eng::Keyword Keyword;
struct NiepcePropertyBag;
struct NiepcePropertySet;
@@ -69,7 +70,6 @@ using NiepcePropertyIdx = ffi::NiepcePropertyIdx;
typedef ffi::LibraryId library_id_t; // XXX change this to LibraryId
typedef ffi::FileStatus FileStatus;
typedef ffi::LibFolder LibFolder;
-typedef ffi::LibMetadata LibMetadata;
typedef ffi::Managed Managed;
typedef ffi::LibNotification LibNotification;
typedef ffi::NotificationType NotificationType;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]