[niepce] engine+rust: only use the generated bindings for label



commit 40756a58329129fec913b7a913219b105a4a49ab
Author: Hubert Figuière <hub figuiere net>
Date:   Thu Sep 28 23:20:45 2017 -0400

    engine+rust: only use the generated bindings for label

 src/engine/db/label.cpp |    9 +++------
 src/engine/db/label.hpp |    6 ------
 src/engine/db/label.rs  |   16 ++++++++--------
 3 files changed, 11 insertions(+), 20 deletions(-)
---
diff --git a/src/engine/db/label.cpp b/src/engine/db/label.cpp
index 56d477b..ee68be3 100644
--- a/src/engine/db/label.cpp
+++ b/src/engine/db/label.cpp
@@ -19,20 +19,17 @@
 
 #include "label.hpp"
 
-extern "C" {
-void engine_db_label_delete(eng::Label*);
-eng::Label* engine_db_label_clone(const eng::Label*);
-}
+#include "rust_bindings.hpp"
 
 namespace eng {
 
 LabelPtr label_wrap(Label* l)
 {
-    return LabelPtr(l, &engine_db_label_delete);
+  return LabelPtr(l, &ffi::engine_db_label_delete);
 }
 
 LabelPtr label_clone(const Label* l)
 {
-    return label_wrap(engine_db_label_clone(l));
+  return label_wrap(ffi::engine_db_label_clone(l));
 }
 }
diff --git a/src/engine/db/label.hpp b/src/engine/db/label.hpp
index 2aa7b04..fe91595 100644
--- a/src/engine/db/label.hpp
+++ b/src/engine/db/label.hpp
@@ -41,12 +41,6 @@ LabelPtr label_wrap(Label*);
 LabelPtr label_clone(const Label*);
 }
 
-extern "C" {
-eng::library_id_t engine_db_label_id(const eng::Label*);
-const fwk::RgbColour* engine_db_label_colour(const eng::Label*);
-const char* engine_db_label_label(const eng::Label*);
-}
-
 /*
   Local Variables:
   mode:c++
diff --git a/src/engine/db/label.rs b/src/engine/db/label.rs
index 9a5a435..9f7159a 100644
--- a/src/engine/db/label.rs
+++ b/src/engine/db/label.rs
@@ -85,32 +85,32 @@ impl FromDb for Label {
 
 
 #[no_mangle]
-pub fn engine_db_label_delete(l: *mut Label) {
+pub extern fn engine_db_label_delete(l: *mut Label) {
     unsafe { Box::from_raw(l) };
 }
 
 #[no_mangle]
-pub fn engine_db_label_clone(l: &Label) -> *mut Label {
+pub extern fn engine_db_label_clone(l: &Label) -> *mut Label {
     Box::into_raw(Box::new(l.clone()))
 }
 
 #[no_mangle]
-pub fn engine_db_label_id(l: &Label) -> LibraryId {
+pub extern fn engine_db_label_id(l: &Label) -> LibraryId {
     l.id()
 }
 
 #[no_mangle]
-pub fn engine_db_label_label(this: &mut Label) -> *const c_char {
+pub extern fn engine_db_label_label(obj: &mut Label) -> *const c_char {
     let cstr;
     {
-        let s = this.label();
+        let s = obj.label();
         cstr = CString::new(s).unwrap();
     }
-    this.cstr = cstr;
-    this.cstr.as_ptr()
+    obj.cstr = cstr;
+    obj.cstr.as_ptr()
 }
 
 #[no_mangle]
-pub fn engine_db_label_colour(l: &Label) -> *const RgbColour {
+pub extern fn engine_db_label_colour(l: &Label) -> *const RgbColour {
     l.colour()
 }


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