[niepce] fwk: bind PropertyBag and PropertySet with cxx



commit 51cac86eea694205a6e48716106d552b3ceb496d
Author: Hubert Figuière <hub figuiere net>
Date:   Sun Oct 16 22:03:02 2022 -0400

    fwk: bind PropertyBag and PropertySet with cxx

 crates/npc-engine/src/db/libmetadata.rs  |  20 ++--
 crates/npc-engine/src/lib.rs             | 158 +++++++++++++++++--------------
 crates/npc-fwk/src/base/propertybag.rs   |   6 +-
 crates/npc-fwk/src/base/propertyvalue.rs |  44 ++-------
 crates/npc-fwk/src/lib.rs                |  13 +--
 src/engine/db/libmetadata.cpp            |   6 --
 src/engine/db/libmetadata.hpp            |   3 -
 src/fwk/base/propertybag.cpp             |  45 ---------
 src/fwk/base/propertybag.hpp             |  24 -----
 src/fwk/cxx_prelude.hpp                  |   1 +
 src/niepce/modules/map/mapmodule.cpp     |  27 +++---
 src/niepce/ui/metadatapanecontroller.cpp |   4 +-
 src/niepce/ui/metadatapanecontroller.hpp |   1 -
 src/rust_bindings.hpp                    |   8 +-
 14 files changed, 127 insertions(+), 233 deletions(-)
---
diff --git a/crates/npc-engine/src/db/libmetadata.rs b/crates/npc-engine/src/db/libmetadata.rs
index f6bd50aa..13cff34e 100644
--- a/crates/npc-engine/src/db/libmetadata.rs
+++ b/crates/npc-engine/src/db/libmetadata.rs
@@ -17,6 +17,8 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
+use std::ops::DerefMut;
+
 use chrono::Utc;
 
 use super::libfile::FileType;
@@ -191,9 +193,10 @@ impl LibMetadata {
         false
     }
 
-    pub fn to_properties(&self, propset: &PropertySet<Np>) -> PropertyBag<Np> {
+    pub fn to_properties(&self, propset: &PropertySet<Np>) -> Box<NiepcePropertyBag> {
         use super::NiepcePropertyIdx::*;
-        let mut props = PropertyBag::new();
+        let mut property_bag = Box::new(NiepcePropertyBag::default());
+        let props = &mut property_bag.deref_mut().0;
         for prop_id in propset {
             match *prop_id {
                 Np::Index(NpXmpRatingProp) => {
@@ -256,7 +259,7 @@ impl LibMetadata {
                 }
             }
         }
-        props
+        property_bag
     }
 
     pub fn touch(&mut self) -> bool {
@@ -296,15 +299,6 @@ impl FromDb for LibMetadata {
     }
 }
 
-#[no_mangle]
-pub extern "C" fn engine_libmetadata_to_properties(
-    meta: &LibMetadata,
-    propset: &NiepcePropertySet,
-) -> *mut NiepcePropertyBag {
-    let result = Box::new(meta.to_properties(propset));
-    Box::into_raw(result)
-}
-
 use npc_fwk::toolkit::widgets::WrappedPropertyBag;
 
 fn into_u32(from: NiepcePropertyBag) -> PropertyBag<u32> {
@@ -324,7 +318,7 @@ pub extern "C" fn engine_libmetadata_to_wrapped_properties(
     propset: &NiepcePropertySet,
 ) -> *mut WrappedPropertyBag {
     let bag = meta.to_properties(propset);
-    let bag = into_u32(bag);
+    let bag = into_u32(*bag);
     let result = Box::new(WrappedPropertyBag(bag));
     Box::into_raw(result)
 }
diff --git a/crates/npc-engine/src/lib.rs b/crates/npc-engine/src/lib.rs
index 671f4971..ba761750 100644
--- a/crates/npc-engine/src/lib.rs
+++ b/crates/npc-engine/src/lib.rs
@@ -22,83 +22,27 @@ pub mod library;
 
 use std::ptr;
 
-use npc_fwk::base::PropertyIndex;
-use npc_fwk::PropertyValue;
-
-use db::{NiepceProperties, NiepcePropertyIdx};
-
-type NiepcePropertySet = npc_fwk::PropertySet<db::NiepceProperties>;
-type NiepcePropertyBag = npc_fwk::PropertyBag<db::NiepceProperties>;
-
-#[no_mangle]
-pub extern "C" fn eng_property_set_new() -> *mut NiepcePropertySet {
-    Box::into_raw(Box::new(NiepcePropertySet::new()))
-}
-
-/// Delete a %PropertySet
-///
-/// # Safety
-/// Dereference the pointer.
-#[no_mangle]
-pub unsafe extern "C" fn eng_property_set_delete(set: *mut NiepcePropertySet) {
-    drop(Box::from_raw(set));
-}
-
-#[no_mangle]
-pub extern "C" fn eng_property_set_add(set: &mut NiepcePropertySet, v: NiepcePropertyIdx) {
-    set.insert(NiepceProperties::Index(v));
-}
-
-/// Delete the %PropertyBag object
-///
-/// # Safety
-/// Dereference the raw pointer.
-#[no_mangle]
-pub unsafe extern "C" fn eng_property_bag_delete(bag: *mut NiepcePropertyBag) {
-    drop(Box::from_raw(bag));
-}
-
-#[no_mangle]
-pub extern "C" fn eng_property_bag_is_empty(b: &NiepcePropertyBag) -> bool {
-    b.is_empty()
-}
-
-#[no_mangle]
-pub extern "C" fn eng_property_bag_len(b: &NiepcePropertyBag) -> usize {
-    b.len()
-}
+use db::NiepceProperties;
 
-#[no_mangle]
-pub extern "C" fn eng_property_bag_key_by_index(
-    b: &NiepcePropertyBag,
-    idx: usize,
-) -> PropertyIndex {
-    b.bag[idx].into()
-}
+// must be a tuple for cxx
+#[derive(Default)]
+pub struct PropertySet(npc_fwk::PropertySet<db::NiepceProperties>);
 
-#[no_mangle]
-pub extern "C" fn eng_property_bag_value(
-    b: &NiepcePropertyBag,
-    key: PropertyIndex,
-) -> *mut PropertyValue {
-    let key: db::NiepceProperties = key.into();
-    if b.map.contains_key(&key) {
-        let value = Box::new(b.map[&key].clone());
-        Box::into_raw(value)
-    } else {
-        ptr::null_mut()
+impl PropertySet {
+    fn add(&mut self, v: u32) {
+        self.0.insert(NiepceProperties::from(v));
     }
 }
 
-#[no_mangle]
-pub extern "C" fn eng_property_bag_set_value(
-    b: &mut NiepcePropertyBag,
-    key: PropertyIndex,
-    v: &PropertyValue,
-) -> bool {
-    b.set_value(key.into(), v.clone())
+impl std::ops::Deref for PropertySet {
+    type Target = npc_fwk::PropertySet<db::NiepceProperties>;
+    fn deref(&self) -> &Self::Target {
+        &self.0
+    }
 }
 
+use npc_fwk::PropertyValue;
+use npc_fwk::base::PropertyIndex;
 use npc_fwk::toolkit::widgets::WrappedPropertyBag;
 
 /// Delete the %WrappedPropertyBag object
@@ -151,15 +95,67 @@ pub extern "C" fn fwk_property_bag_value(
     }
 }
 
+// must be a tuple for cxx
+#[derive(Default)]
+pub struct PropertyBag(npc_fwk::PropertyBag<db::NiepceProperties>);
+
+impl PropertyBag {
+    fn is_empty(&self) -> bool {
+        self.0.is_empty()
+    }
+
+    fn len(&self) -> usize {
+        self.0.len()
+    }
+
+    fn key_by_index(&self, idx: usize) -> u32 {
+        self.0.bag[idx].into()
+    }
+
+    fn contains_key(&self, key: &u32) -> bool {
+        let key = db::NiepceProperties::from(*key);
+        self.0.contains_key(&key)
+    }
+
+    fn value_unchecked(&self, key: u32) -> &PropertyValue {
+        self.0
+            .map
+            .get(&db::NiepceProperties::from(key))
+            .expect("no such value")
+    }
+}
+
+impl std::ops::Deref for PropertyBag {
+    type Target = npc_fwk::PropertyBag<db::NiepceProperties>;
+    fn deref(&self) -> &Self::Target {
+        &self.0
+    }
+}
+
+impl std::ops::DerefMut for PropertyBag {
+    fn deref_mut(&mut self) -> &mut Self::Target {
+        &mut self.0
+    }
+}
+
+pub fn property_set_new() -> Box<PropertySet> {
+    Box::new(PropertySet::default())
+}
+
+pub type NiepcePropertySet = PropertySet;
+pub type NiepcePropertyBag = PropertyBag;
+
 use crate::db::{Keyword, Label, LibFile, LibMetadata};
 
 #[cxx::bridge(namespace = "eng")]
 mod ffi {
     #[namespace = "fwk"]
     extern "C++" {
+        include!("fwk/cxx_prelude.hpp");
         include!("fwk/cxx_colour_bindings.hpp");
 
         type RgbColour = npc_fwk::base::rgbcolour::RgbColour;
+        type PropertyValue = npc_fwk::PropertyValue;
     }
 
     #[repr(i32)]
@@ -213,5 +209,27 @@ mod ffi {
         type LibMetadata;
 
         fn id(&self) -> i64;
+        fn to_properties(&self, propset: &PropertySet) -> Box<PropertyBag>;
+    }
+
+    #[namespace = "fwk"]
+    extern "Rust" {
+        type PropertyBag;
+
+        fn is_empty(&self) -> bool;
+        fn len(&self) -> usize;
+        fn contains_key(&self, key: &u32) -> bool;
+        #[cxx_name = "value"]
+        fn value_unchecked(&self, key: u32) -> &PropertyValue;
+        fn key_by_index(&self, idx: usize) -> u32;
+    }
+
+    #[namespace = "fwk"]
+    extern "Rust" {
+        type PropertySet;
+
+        #[cxx_name = "PropertySet_new"]
+        fn property_set_new() -> Box<PropertySet>;
+        fn add(&mut self, v: u32);
     }
 }
diff --git a/crates/npc-fwk/src/base/propertybag.rs b/crates/npc-fwk/src/base/propertybag.rs
index d71e9acd..40eceb37 100644
--- a/crates/npc-fwk/src/base/propertybag.rs
+++ b/crates/npc-fwk/src/base/propertybag.rs
@@ -1,7 +1,7 @@
 /*
  * niepce - fwk/base/propertybag.rs
  *
- * Copyright (C) 2017-2021 Hubert Figuière
+ * Copyright (C) 2017-2022 Hubert Figuière
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -53,6 +53,10 @@ impl<Index: Ord + Copy> PropertyBag<Index> {
         self.map.get(key)
     }
 
+    pub fn contains_key(&self, key: &Index) -> bool {
+        self.map.contains_key(key)
+    }
+
     pub fn set_value(&mut self, key: Index, value: PropertyValue) -> bool {
         let ret = self.map.insert(key, value);
         if ret.is_some() {
diff --git a/crates/npc-fwk/src/base/propertyvalue.rs b/crates/npc-fwk/src/base/propertyvalue.rs
index c10584f3..93e03444 100644
--- a/crates/npc-fwk/src/base/propertyvalue.rs
+++ b/crates/npc-fwk/src/base/propertyvalue.rs
@@ -31,6 +31,13 @@ pub enum PropertyValue {
 
 unsafe impl Send for PropertyValue {}
 
+use cxx::{type_id, ExternType};
+
+unsafe impl ExternType for PropertyValue {
+    type Id = type_id!("fwk::PropertyValue");
+    type Kind = cxx::kind::Opaque;
+}
+
 impl PropertyValue {
     pub fn is_empty(&self) -> bool {
         matches!(*self, PropertyValue::Empty)
@@ -55,13 +62,6 @@ impl PropertyValue {
         }
     }
 
-    pub fn integer_unchecked(&self) -> i32 {
-        match *self {
-            PropertyValue::Int(i) => i,
-            _ => panic!("value is not Int"),
-        }
-    }
-
     pub fn date(&self) -> Option<&Date> {
         match *self {
             PropertyValue::Date(ref d) => Some(d),
@@ -69,13 +69,6 @@ impl PropertyValue {
         }
     }
 
-    pub fn date_unchecked(&self) -> Box<Date> {
-        match *self {
-            PropertyValue::Date(ref d) => Box::new(*d),
-            _ => panic!("value is not Date"),
-        }
-    }
-
     pub fn string(&self) -> Option<&str> {
         match *self {
             PropertyValue::String(ref s) => Some(s),
@@ -90,37 +83,14 @@ impl PropertyValue {
         }
     }
 
-    /// Add a string a StringArray %PropertyValue
-    ///
-    /// Will panic if the type is incorrect.
-    pub fn add_string_unchecked(&mut self, string: &str) {
-        match *self {
-            PropertyValue::StringArray(ref mut sa) => {
-                sa.push(string.to_string());
-            }
-            _ => panic!("value is not a StringArray"),
-        }
-    }
-
     pub fn string_array(&self) -> Option<&[String]> {
         match *self {
             PropertyValue::StringArray(ref sa) => Some(sa),
             _ => None,
         }
     }
-
-    pub fn string_array_unchecked(&self) -> &[String] {
-        match *self {
-            PropertyValue::StringArray(ref sa) => sa,
-            _ => panic!("value is not a StringArray"),
-        }
-    }
 }
 
 pub fn property_value_new_int(v: i32) -> Box<PropertyValue> {
     Box::new(PropertyValue::Int(v))
 }
-
-pub fn property_value_new_string_array() -> Box<PropertyValue> {
-    Box::new(PropertyValue::StringArray(vec![]))
-}
diff --git a/crates/npc-fwk/src/lib.rs b/crates/npc-fwk/src/lib.rs
index 1fd94520..e63db0ac 100644
--- a/crates/npc-fwk/src/lib.rs
+++ b/crates/npc-fwk/src/lib.rs
@@ -52,7 +52,7 @@ use glib::translate::*;
 
 use self::base::rgbcolour::RgbColour;
 use crate::base::date::Date;
-use crate::base::propertyvalue::{property_value_new_int, property_value_new_string_array};
+use crate::base::propertyvalue::property_value_new_int;
 use crate::toolkit::thumbnail::Thumbnail;
 use crate::toolkit::widgets::MetadataWidget;
 use crate::toolkit::Configuration;
@@ -227,22 +227,11 @@ mod ffi {
         type PropertyValue;
 
         fn property_value_new_int(v: i32) -> Box<PropertyValue>;
-        fn property_value_new_string_array() -> Box<PropertyValue>;
 
         fn is_empty(&self) -> bool;
-        fn is_integer(&self) -> bool;
-        fn is_date(&self) -> bool;
         fn is_string(&self) -> bool;
-        #[cxx_name = "get_integer"]
-        fn integer_unchecked(&self) -> i32;
-        #[cxx_name = "get_date"]
-        fn date_unchecked(&self) -> Box<Date>;
         #[cxx_name = "get_string"]
         fn string_unchecked(&self) -> &str;
-        #[cxx_name = "add_string"]
-        fn add_string_unchecked(&mut self, string: &str);
-        #[cxx_name = "get_string_array"]
-        fn string_array_unchecked(&self) -> &[String];
     }
 
     extern "C++" {
diff --git a/src/engine/db/libmetadata.cpp b/src/engine/db/libmetadata.cpp
index 0537cc3f..24ce2b2b 100644
--- a/src/engine/db/libmetadata.cpp
+++ b/src/engine/db/libmetadata.cpp
@@ -21,12 +21,6 @@
 
 namespace eng {
 
-fwk::PropertyBagPtr libmetadata_to_properties(const LibMetadata* meta,
-                                              const fwk::PropertySet& propset)
-{
-    return fwk::property_bag_wrap(ffi::engine_libmetadata_to_properties(meta, &propset));
-}
-
 fwk::WrappedPropertyBagPtr libmetadata_to_wrapped_properties(const LibMetadata* meta,
                                               const fwk::PropertySet& propset)
 {
diff --git a/src/engine/db/libmetadata.hpp b/src/engine/db/libmetadata.hpp
index 22e347b9..169e4279 100644
--- a/src/engine/db/libmetadata.hpp
+++ b/src/engine/db/libmetadata.hpp
@@ -19,15 +19,12 @@
 
 #pragma once
 
-#include "engine/db/metadata.hpp"
 #include "fwk/base/propertybag.hpp"
 
 #include "rust_bindings.hpp"
 
 namespace eng {
 
-fwk::PropertyBagPtr libmetadata_to_properties(const LibMetadata *meta,
-                                              const fwk::PropertySet &propset);
 fwk::WrappedPropertyBagPtr libmetadata_to_wrapped_properties(const LibMetadata* meta,
                                                              const fwk::PropertySet& propset);
 
diff --git a/src/fwk/base/propertybag.cpp b/src/fwk/base/propertybag.cpp
index d7bf910a..2b1984c0 100644
--- a/src/fwk/base/propertybag.cpp
+++ b/src/fwk/base/propertybag.cpp
@@ -21,61 +21,16 @@
 
 namespace fwk {
 
-PropertySetPtr property_set_wrap(PropertySet* s)
-{
-    return PropertySetPtr(s, &ffi::eng_property_set_delete);
-}
-
-PropertySetPtr property_set_new()
-{
-    return property_set_wrap(ffi::eng_property_set_new());
-}
-
-PropertyValuePtr property_value_new(const std::vector<std::string>& sa)
-{
-    PropertyValuePtr value = fwk::property_value_new_string_array();
-    for (auto s : sa) {
-        value->add_string(s);
-    }
-    return value;
-}
-
-PropertyBagPtr property_bag_wrap(PropertyBag* bag)
-{
-    return PropertyBagPtr(bag, &ffi::eng_property_bag_delete);
-}
-
 WrappedPropertyBagPtr wrapped_property_bag_wrap(WrappedPropertyBag* bag)
 {
     return WrappedPropertyBagPtr(bag, &ffi::fwk_wrapped_property_bag_delete);
 }
 
-PropertyValuePtr property_bag_value(const PropertyBagPtr& bag, PropertyIndex idx)
-{
-    return PropertyValuePtr::from_raw(ffi::eng_property_bag_value(bag.get(), idx));
-}
-
 PropertyValuePtr wrapped_property_bag_value(const WrappedPropertyBagPtr& bag, PropertyIndex idx)
 {
     return PropertyValuePtr::from_raw(ffi::fwk_property_bag_value(bag.get(), idx));
 }
 
-bool set_value_for_property(PropertyBag& bag, ffi::NiepcePropertyIdx idx,
-                            const PropertyValue& value)
-{
-    return ffi::eng_property_bag_set_value(&bag, static_cast<uint32_t>(idx), &value);
-}
-
-std::optional<PropertyValuePtr> get_value_for_property(const PropertyBag& bag,
-                                                     ffi::NiepcePropertyIdx idx)
-{
-    auto value = ffi::eng_property_bag_value(&bag, static_cast<uint32_t>(idx));
-    if (!value) {
-        return std::nullopt;
-    }
-    return std::optional<PropertyValuePtr>(PropertyValuePtr::from_raw(value));
-}
-
 }
 /*
   Local Variables:
diff --git a/src/fwk/base/propertybag.hpp b/src/fwk/base/propertybag.hpp
index 7d3897d8..3c4a85e8 100644
--- a/src/fwk/base/propertybag.hpp
+++ b/src/fwk/base/propertybag.hpp
@@ -22,9 +22,6 @@
 #include <stdint.h>
 #include <string>
 #include <vector>
-#include <memory>
-
-#include <optional>
 
 #include "rust_bindings.hpp"
 
@@ -32,31 +29,10 @@ namespace fwk {
 
 typedef uint32_t PropertyIndex;
 
-PropertyValuePtr property_value_new(const std::vector<std::string>&);
-
-typedef std::shared_ptr<PropertySet> PropertySetPtr;
-
-PropertySetPtr property_set_new();
-
-/** a property bag
- * It is important that the values for PropertyIndex be properly name spaced
- * by the caller.
- */
-typedef std::shared_ptr<PropertyBag> PropertyBagPtr;
-
-PropertyBagPtr property_bag_wrap(PropertyBag*);
-PropertyValuePtr property_bag_value(const PropertyBagPtr& bag, PropertyIndex key);
-
 typedef std::shared_ptr<WrappedPropertyBag> WrappedPropertyBagPtr;
 
 WrappedPropertyBagPtr wrapped_property_bag_wrap(WrappedPropertyBag* bag);
 PropertyValuePtr wrapped_property_bag_value(const WrappedPropertyBagPtr& bag, PropertyIndex key);
-
-/** return true if a property was removed prior to insertion */
-bool set_value_for_property(PropertyBag&, ffi::NiepcePropertyIdx idx, const PropertyValue& value);
-/** return property or an empty option */
-std::optional<PropertyValuePtr> get_value_for_property(const PropertyBag&, ffi::NiepcePropertyIdx idx);
-
 }
 
 /*
diff --git a/src/fwk/cxx_prelude.hpp b/src/fwk/cxx_prelude.hpp
index 65283892..afd0fb2a 100644
--- a/src/fwk/cxx_prelude.hpp
+++ b/src/fwk/cxx_prelude.hpp
@@ -9,4 +9,5 @@
 // And that the implementation needs too.
 namespace fwk {
 class WrappedPropertyBag;
+class PropertyValue;
 }
diff --git a/src/niepce/modules/map/mapmodule.cpp b/src/niepce/modules/map/mapmodule.cpp
index 4cc6cd1e..8ee6f81f 100644
--- a/src/niepce/modules/map/mapmodule.cpp
+++ b/src/niepce/modules/map/mapmodule.cpp
@@ -23,7 +23,6 @@
 #include "fwk/utils/exempi.hpp"
 #include "fwk/toolkit/application.hpp"
 #include "engine/db/properties.hpp"
-#include "engine/db/libmetadata.hpp"
 #include "mapmodule.hpp"
 
 #include "rust_bindings.hpp"
@@ -80,27 +79,25 @@ MapModule::on_lib_notification(const eng::LibNotification &ln)
         DBG_OUT("received metadata in MapModule");
 
         if (lm) {
-            fwk::PropertySetPtr propset = fwk::property_set_new();
-            ffi::eng_property_set_add(propset.get(), ffi::NiepcePropertyIdx::NpExifGpsLongProp);
-            ffi::eng_property_set_add(propset.get(), ffi::NiepcePropertyIdx::NpExifGpsLatProp);
+            fwk::PropertySetPtr propset = fwk::PropertySet_new();
+            propset->add((uint32_t)ffi::NiepcePropertyIdx::NpExifGpsLongProp);
+            propset->add((uint32_t)ffi::NiepcePropertyIdx::NpExifGpsLatProp);
 
-            fwk::PropertyBagPtr properties = eng::libmetadata_to_properties(lm, *propset);
+            fwk::PropertyBagPtr properties = lm->to_properties(*propset);
             double latitude, longitude;
             latitude = longitude = NAN;
-            auto result = fwk::get_value_for_property(*properties, 
ffi::NiepcePropertyIdx::NpExifGpsLongProp);
-            if (result.has_value()) {
-                fwk::PropertyValuePtr val = std::move(result.value());
+            if (properties->contains_key((uint32_t)ffi::NiepcePropertyIdx::NpExifGpsLongProp)) {
+                const fwk::PropertyValue& val = 
properties->value((uint32_t)ffi::NiepcePropertyIdx::NpExifGpsLongProp);
                 // it is a string
-                if (val->is_string()) {
-                    longitude = fwk::gps_coord_from_xmp(val->get_string());
+                if (val.is_string()) {
+                    longitude = fwk::gps_coord_from_xmp(val.get_string());
                 }
             }
-            result = fwk::get_value_for_property(*properties, ffi::NiepcePropertyIdx::NpExifGpsLatProp);
-            if (result.has_value()) {
-                fwk::PropertyValuePtr val = std::move(result.value());
+            if (properties->contains_key((uint32_t)ffi::NiepcePropertyIdx::NpExifGpsLatProp)) {
+                const fwk::PropertyValue& val = 
properties->value((uint32_t)ffi::NiepcePropertyIdx::NpExifGpsLatProp);
                 // it is a string
-                if (val->is_string()) {
-                    latitude = fwk::gps_coord_from_xmp(val->get_string());
+                if (val.is_string()) {
+                    latitude = fwk::gps_coord_from_xmp(val.get_string());
                 }
             }
 
diff --git a/src/niepce/ui/metadatapanecontroller.cpp b/src/niepce/ui/metadatapanecontroller.cpp
index e8e56554..607a4ebe 100644
--- a/src/niepce/ui/metadatapanecontroller.cpp
+++ b/src/niepce/ui/metadatapanecontroller.cpp
@@ -38,14 +38,14 @@ const fwk::PropertySet* MetaDataPaneController::get_property_set()
 {
     static fwk::PropertySet* propset = nullptr;
     if(!propset) {
-        propset = ffi::eng_property_set_new();
+        propset = fwk::PropertySet_new().into_raw();
         rust::Slice<const fwk::MetadataSectionFormat> formats = npc::get_format();
 
         auto current = formats.begin();
         while (current != formats.end()) {
             auto format = current->formats.begin();
             while (format != current->formats.end()) {
-                ffi::eng_property_set_add(propset, (NiepcePropertyIdx)format->id);
+                propset->add(format->id);
                 format++;
             }
             current++;
diff --git a/src/niepce/ui/metadatapanecontroller.hpp b/src/niepce/ui/metadatapanecontroller.hpp
index f7eb9643..403c98f0 100644
--- a/src/niepce/ui/metadatapanecontroller.hpp
+++ b/src/niepce/ui/metadatapanecontroller.hpp
@@ -19,7 +19,6 @@
 
 #pragma once
 
-#include "engine/db/libmetadata.hpp"
 #include "fwk/base/propertybag.hpp"
 #include "fwk/utils/exempi.hpp"
 #include "fwk/toolkit/dockable.hpp"
diff --git a/src/rust_bindings.hpp b/src/rust_bindings.hpp
index a653285c..b77b656b 100644
--- a/src/rust_bindings.hpp
+++ b/src/rust_bindings.hpp
@@ -42,8 +42,8 @@ typedef eng::Label Label;
 typedef eng::LibFile LibFile;
 typedef eng::LibMetadata LibMetadata;
 typedef eng::Keyword Keyword;
-struct NiepcePropertyBag;
-struct NiepcePropertySet;
+typedef fwk::PropertyBag NiepcePropertyBag;
+typedef fwk::PropertySet NiepcePropertySet;
 }
 
 #include "target/eng_bindings.h"
@@ -57,8 +57,8 @@ typedef rust::Box<FileList> FileListPtr;
 typedef rust::Box<RgbColour> RgbColourPtr;
 typedef rust::Box<PropertyValue> PropertyValuePtr;
 
-typedef ffi::NiepcePropertyBag PropertyBag;
-typedef ffi::NiepcePropertySet PropertySet;
+typedef rust::Box<PropertyBag> PropertyBagPtr;
+typedef rust::Box<PropertySet> PropertySetPtr;
 }
 
 namespace eng {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]