[niepce] rust+engine: make the engine its own crate
- From: Hubert Figuière <hub src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [niepce] rust+engine: make the engine its own crate
- Date: Wed, 11 Dec 2019 01:18:32 +0000 (UTC)
commit 90cf74fde8af294bb54ae6492f2be41792ebd26b
Author: Hubert Figuière <hub figuiere net>
Date: Fri Oct 25 08:25:55 2019 -0400
rust+engine: make the engine its own crate
- move the bindings generation to the engine crate
.gitignore | 2 +-
Cargo.lock | 25 ++++---
Cargo.toml | 10 +--
build.rs | 52 --------------
crates/npc-engine/Cargo.toml | 22 ++++++
crates/npc-engine/build.rs | 82 ++++++++++++++++++++++
.../npc-engine/src}/db/filebundle.rs | 4 +-
{src/engine => crates/npc-engine/src}/db/fsfile.rs | 0
.../engine => crates/npc-engine/src}/db/keyword.rs | 0
{src/engine => crates/npc-engine/src}/db/label.rs | 0
.../engine => crates/npc-engine/src}/db/libfile.rs | 2 +-
.../npc-engine/src}/db/libfolder.rs | 0
.../npc-engine/src}/db/libmetadata.rs | 6 +-
.../engine => crates/npc-engine/src}/db/library.rs | 26 +++----
{src/engine => crates/npc-engine/src}/db/mod.rs | 0
src/engine/mod.rs => crates/npc-engine/src/lib.rs | 10 ++-
.../npc-engine/src}/library/commands.rs | 16 ++---
.../npc-engine/src}/library/mod.rs | 0
.../npc-engine/src}/library/notification.rs | 11 +--
.../engine => crates/npc-engine/src}/library/op.rs | 2 +-
crates/npc-fwk/src/toolkit/mod.rs | 5 ++
doc/code-organization.txt | 7 +-
src/Makefile.am | 29 ++++----
src/lib.rs | 12 +---
src/libraryclient/clientimpl.rs | 14 ++--
src/libraryclient/clientinterface.rs | 6 +-
src/libraryclient/mod.rs | 16 ++---
src/rust_bindings.hpp | 1 +
28 files changed, 207 insertions(+), 153 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index 9b2ca39..0c2cc8a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -110,4 +110,4 @@ po/quot.sed
po/remove-potcdate.s*
target/
**/*.rs.bk
-crates/npc-fwk/Cargo.lock
\ No newline at end of file
+crates/npc-*/Cargo.lock
\ No newline at end of file
diff --git a/Cargo.lock b/Cargo.lock
index 2b953b8..84b7e2d 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -493,23 +493,15 @@ dependencies = [
name = "niepce_rust"
version = "0.1.0"
dependencies = [
- "bindgen 0.37.4 (registry+https://github.com/rust-lang/crates.io-index)",
"cbindgen 0.8.3 (registry+https://github.com/rust-lang/crates.io-index)",
- "chrono 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)",
- "exempi 2.5.0 (git+https://github.com/hfiguiere/exempi-rs.git?rev=53cfc05)",
"gettext-rs 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"gio 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "gio-sys 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
"glib 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "glib-sys 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
"gtk 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
"gtk-sys 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)",
- "multimap 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "npc-engine 0.1.0",
"npc-fwk 0.1.0",
- "pkg-config 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
- "rusqlite 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "try_opt 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@@ -520,6 +512,21 @@ dependencies = [
"memchr 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
+[[package]]
+name = "npc-engine"
+version = "0.1.0"
+dependencies = [
+ "bindgen 0.37.4 (registry+https://github.com/rust-lang/crates.io-index)",
+ "cbindgen 0.8.3 (registry+https://github.com/rust-lang/crates.io-index)",
+ "chrono 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)",
+ "exempi 2.5.0 (git+https://github.com/hfiguiere/exempi-rs.git?rev=53cfc05)",
+ "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)",
+ "npc-fwk 0.1.0",
+ "pkg-config 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rusqlite 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "try_opt 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
[[package]]
name = "npc-fwk"
version = "0.1.0"
diff --git a/Cargo.toml b/Cargo.toml
index 481230d..79ae57e 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -5,27 +5,19 @@ authors = ["Hubert Figuière <hub figuiere net>"]
build = "build.rs"
[dependencies]
-chrono = "0.4.0"
-exempi = { version = "2.5.0", git = "https://github.com/hfiguiere/exempi-rs.git", rev="53cfc05" }
gettext-rs = "0.3.0"
-glib-sys = "*"
glib = { version = "^0.8.0", features = ["subclassing"] }
-gio-sys = "*"
gio = "^0.7.0"
gtk-sys = { version = "*", features = ["v3_16"] }
gtk = "^0.7.0"
libc = "0.2.39"
-multimap = "0.4.0"
-rusqlite = { version = "0.14.0", features = ["functions"] }
-try_opt = "0.1.1"
#gphoto = "0.1.1"
npc-fwk = { path = "crates/npc-fwk" }
+npc-engine = { path = "crates/npc-engine" }
[build-dependencies]
-bindgen = "0.37.0"
cbindgen = { version = "0.8.3" }
-pkg-config = "0.3.9"
[lib]
name = "niepce_rust"
diff --git a/build.rs b/build.rs
index fc801bb..15b01e2 100644
--- a/build.rs
+++ b/build.rs
@@ -1,61 +1,9 @@
-extern crate bindgen;
extern crate cbindgen;
-extern crate pkg_config;
use std::env;
use std::path::PathBuf;
fn main() {
- let exempi = pkg_config::Config::new()
- .print_system_libs(false)
- .probe("exempi-2.0")
- .unwrap();
- // The bindgen::Builder is the main entry point
- // to bindgen, and lets you build up options for
- // the resulting bindings.
- let mut builder = bindgen::Builder::default()
- .enable_cxx_namespaces()
- .generate_comments(false)
- .generate_inline_functions(true)
- // The input header we would like to generate
- // bindings for.
- .whitelist_type("eng::NiepceProperties")
- .rustified_enum("eng::NiepceProperties")
- .whitelist_type("eng::QueriedContent")
- .opaque_type("eng::QueriedContent")
- .opaque_type("std::.*")
- .whitelist_type("fwk::FileList")
- .whitelist_type("eng::IndexToXmp")
- .whitelist_function("eng::property_index_to_xmp")
- .header("src/engine/db/bindings.hpp")
- .clang_arg("--std=c++11")
- .clang_arg("-DRUST_BINDGEN=1")
- .clang_arg("-I./src");
-
- for include in exempi
- .include_paths
- .into_iter()
- .map(|path| format!("-I{}", path.to_str().unwrap_or(".")))
- {
- builder = builder.clang_arg(include);
- }
-
- builder
- .dump_preprocessed_input()
- .expect("Unable to dump preprocessed input");
- // Finish the builder and generate the bindings.
- let bindings = builder
- .rustfmt_bindings(true)
- .generate()
- // Unwrap the Result and panic on failure.
- .expect("Unable to generate bindings");
-
- // Write the bindings to the $OUT_DIR/bindings.rs file.
- let out_path = PathBuf::from(env::var("OUT_DIR").unwrap());
- bindings
- .write_to_file(out_path.join("bindings.rs"))
- .expect("Couldn't write bindings!");
-
if env::var("SKIP_CBINDINGS").is_err() {
// Use cbindgen to generate C bindings.
let crate_dir = env::var("CARGO_MANIFEST_DIR").unwrap();
diff --git a/crates/npc-engine/Cargo.toml b/crates/npc-engine/Cargo.toml
new file mode 100644
index 0000000..38dba5a
--- /dev/null
+++ b/crates/npc-engine/Cargo.toml
@@ -0,0 +1,22 @@
+[package]
+name = "npc-engine"
+version = "0.1.0"
+authors = ["Hubert Figuière <hub figuiere net>"]
+edition = "2018"
+build = "build.rs"
+
+# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
+
+[dependencies]
+chrono = "0.4.0"
+exempi = { version = "2.5.0", git = "https://github.com/hfiguiere/exempi-rs.git", rev="53cfc05" }
+libc = "0.2.39"
+rusqlite = { version = "0.14.0", features = ["functions"] }
+try_opt = "0.1.1"
+
+npc-fwk = { path = "../npc-fwk" }
+
+[build-dependencies]
+bindgen = "0.37.0"
+cbindgen = { version = "0.8.3" }
+pkg-config = "0.3.9"
diff --git a/crates/npc-engine/build.rs b/crates/npc-engine/build.rs
new file mode 100644
index 0000000..cdc6e7b
--- /dev/null
+++ b/crates/npc-engine/build.rs
@@ -0,0 +1,82 @@
+extern crate bindgen;
+extern crate pkg_config;
+
+use std::env;
+use std::path::PathBuf;
+
+fn main() {
+ let exempi = pkg_config::Config::new()
+ .print_system_libs(false)
+ .probe("exempi-2.0")
+ .unwrap();
+ // The bindgen::Builder is the main entry point
+ // to bindgen, and lets you build up options for
+ // the resulting bindings.
+ let mut builder = bindgen::Builder::default()
+ .enable_cxx_namespaces()
+ .generate_comments(false)
+ .generate_inline_functions(true)
+ // The input header we would like to generate
+ // bindings for.
+ .whitelist_type("eng::NiepceProperties")
+ .rustified_enum("eng::NiepceProperties")
+ .whitelist_type("eng::QueriedContent")
+ .opaque_type("eng::QueriedContent")
+ .opaque_type("std::.*")
+ .whitelist_type("fwk::FileList")
+ .whitelist_type("eng::IndexToXmp")
+ .whitelist_function("eng::property_index_to_xmp")
+ .header("../../src/engine/db/bindings.hpp")
+ .clang_arg("--std=c++11")
+ .clang_arg("-DRUST_BINDGEN=1")
+ .clang_arg("-I../../src");
+
+ for include in exempi
+ .include_paths
+ .into_iter()
+ .map(|path| format!("-I{}", path.to_str().unwrap_or(".")))
+ {
+ builder = builder.clang_arg(include);
+ }
+
+ builder
+ .dump_preprocessed_input()
+ .expect("Unable to dump preprocessed input");
+ // Finish the builder and generate the bindings.
+ let bindings = builder
+ .rustfmt_bindings(true)
+ .generate()
+ // Unwrap the Result and panic on failure.
+ .expect("Unable to generate bindings");
+
+ // Write the bindings to the $OUT_DIR/bindings.rs file.
+ let out_path = PathBuf::from(env::var("OUT_DIR").unwrap());
+ bindings
+ .write_to_file(out_path.join("bindings.rs"))
+ .expect("Couldn't write bindings!");
+
+ if env::var("SKIP_CBINDINGS").is_err() {
+ // Use cbindgen to generate C bindings.
+ let crate_dir = env::var("CARGO_MANIFEST_DIR").unwrap();
+ let target_dir = env::var("CARGO_TARGET_DIR").unwrap_or(String::from("./target"));
+ let mut target_file = PathBuf::from(target_dir);
+ target_file.push("eng_bindings.h");
+ let cbuilder = cbindgen::Builder::new()
+ .with_include_guard("niepce_rust_eng_bindings_h")
+ .with_namespace("ffi")
+ .with_language(cbindgen::Language::Cxx)
+ .with_parse_deps(true)
+ .with_parse_exclude(&["exempi", "chrono", "multimap"])
+ .exclude_item("GtkWindow")
+ .exclude_item("GtkToolbar")
+ .exclude_item("GFileInfo")
+ .exclude_item("RgbColour")
+ .with_crate(&crate_dir);
+
+ if let Ok(bindings) = cbuilder.generate() {
+ bindings.write_to_file(&*target_file.to_string_lossy());
+ } else {
+ println!("Couldn't generate bindings");
+ }
+ }
+}
diff --git a/src/engine/db/filebundle.rs b/crates/npc-engine/src/db/filebundle.rs
similarity index 99%
rename from src/engine/db/filebundle.rs
rename to crates/npc-engine/src/db/filebundle.rs
index cf02d38..7fa0cdb 100644
--- a/src/engine/db/filebundle.rs
+++ b/crates/npc-engine/src/db/filebundle.rs
@@ -20,7 +20,7 @@
use std::ffi::OsString;
use std::path::{Path, PathBuf};
-use engine::db::libfile::FileType;
+use crate::db::libfile::FileType;
use npc_fwk::MimeType;
use npc_fwk::toolkit::mimetype::{IsRaw, MType};
@@ -213,7 +213,7 @@ impl FileBundle {
#[cfg(test)]
mod test {
use super::{FileBundle, Sidecar};
- use engine::db::libfile::FileType;
+ use crate::db::libfile::FileType;
#[test]
fn test_filebundle() {
diff --git a/src/engine/db/fsfile.rs b/crates/npc-engine/src/db/fsfile.rs
similarity index 100%
rename from src/engine/db/fsfile.rs
rename to crates/npc-engine/src/db/fsfile.rs
diff --git a/src/engine/db/keyword.rs b/crates/npc-engine/src/db/keyword.rs
similarity index 100%
rename from src/engine/db/keyword.rs
rename to crates/npc-engine/src/db/keyword.rs
diff --git a/src/engine/db/label.rs b/crates/npc-engine/src/db/label.rs
similarity index 100%
rename from src/engine/db/label.rs
rename to crates/npc-engine/src/db/label.rs
diff --git a/src/engine/db/libfile.rs b/crates/npc-engine/src/db/libfile.rs
similarity index 99%
rename from src/engine/db/libfile.rs
rename to crates/npc-engine/src/db/libfile.rs
index b44b8fc..b081a9c 100644
--- a/src/engine/db/libfile.rs
+++ b/crates/npc-engine/src/db/libfile.rs
@@ -27,8 +27,8 @@ use rusqlite;
use super::FromDb;
use super::LibraryId;
use super::fsfile::FsFile;
+use crate::root::eng::NiepceProperties as Np;
use npc_fwk::base::PropertyIndex;
-use root::eng::NiepceProperties as Np;
use npc_fwk;
#[repr(i32)]
diff --git a/src/engine/db/libfolder.rs b/crates/npc-engine/src/db/libfolder.rs
similarity index 100%
rename from src/engine/db/libfolder.rs
rename to crates/npc-engine/src/db/libfolder.rs
diff --git a/src/engine/db/libmetadata.rs b/crates/npc-engine/src/db/libmetadata.rs
similarity index 98%
rename from src/engine/db/libmetadata.rs
rename to crates/npc-engine/src/db/libmetadata.rs
index 12c8a23..391bb6e 100644
--- a/src/engine/db/libmetadata.rs
+++ b/crates/npc-engine/src/db/libmetadata.rs
@@ -26,8 +26,8 @@ use exempi;
use npc_fwk::{xmp_date_from, PropertyBag, PropertySet, PropertyValue, XmpMeta};
use npc_fwk::utils::exempi::{NS_DC, NS_XAP};
use super::{FromDb, LibraryId};
-use root::eng::NiepceProperties as Np;
-use engine::db::libfile::FileType;
+use crate::root::eng::NiepceProperties as Np;
+use crate::db::libfile::FileType;
#[derive(Clone)]
pub struct LibMetadata {
@@ -45,7 +45,7 @@ struct IndexToXmp {
}
fn property_index_to_xmp(meta: Np) -> Option<IndexToXmp> {
- let index = unsafe { ::root::eng::property_index_to_xmp(meta as u32) };
+ let index = unsafe { crate::root::eng::property_index_to_xmp(meta as u32) };
if index.ns.is_null() || index.property.is_null() {
err_out!("property {} not found", meta as u32);
return None;
diff --git a/src/engine/db/library.rs b/crates/npc-engine/src/db/library.rs
similarity index 98%
rename from src/engine/db/library.rs
rename to crates/npc-engine/src/db/library.rs
index 849c45a..4184e5f 100644
--- a/src/engine/db/library.rs
+++ b/crates/npc-engine/src/db/library.rs
@@ -27,18 +27,18 @@ use chrono::Utc;
use rusqlite;
use super::{FromDb, LibraryId};
-use engine::db::filebundle::{FileBundle, Sidecar};
-use engine::db::keyword::Keyword;
-use engine::db::label::Label;
-use engine::db::libfile;
-use engine::db::libfile::LibFile;
-use engine::db::libfolder;
-use engine::db::libfolder::LibFolder;
-use engine::db::libmetadata::LibMetadata;
-use engine::library::notification::LibNotification;
+use crate::db::filebundle::{FileBundle, Sidecar};
+use crate::db::keyword::Keyword;
+use crate::db::label::Label;
+use crate::db::libfile;
+use crate::db::libfile::LibFile;
+use crate::db::libfolder;
+use crate::db::libfolder::LibFolder;
+use crate::db::libmetadata::LibMetadata;
+use crate::library::notification::LibNotification;
+use crate::root::eng::NiepceProperties as Np;
use npc_fwk;
use npc_fwk::PropertyValue;
-use root::eng::NiepceProperties as Np;
#[repr(i32)]
#[derive(PartialEq, Clone, Copy)]
@@ -73,7 +73,7 @@ pub struct Library {
dbpath: PathBuf,
dbconn: Option<rusqlite::Connection>,
inited: bool,
- sender: glib::Sender<LibNotification>,
+ sender: npc_fwk::toolkit::Sender<LibNotification>,
}
impl Library {
@@ -97,7 +97,7 @@ impl Library {
}
pub fn new(dir: &Path, name: Option<&str>,
- sender: glib::Sender<LibNotification>) -> Library {
+ sender: npc_fwk::toolkit::Sender<LibNotification>) -> Library {
let mut dbpath = PathBuf::from(dir);
if let Some(filename) = name {
dbpath.push(filename);
@@ -1074,7 +1074,7 @@ impl Library {
#[cfg(test)]
mod test {
- use engine::db::filebundle::FileBundle;
+ use crate::db::filebundle::FileBundle;
use super::{Library, Managed};
diff --git a/src/engine/db/mod.rs b/crates/npc-engine/src/db/mod.rs
similarity index 100%
rename from src/engine/db/mod.rs
rename to crates/npc-engine/src/db/mod.rs
diff --git a/src/engine/mod.rs b/crates/npc-engine/src/lib.rs
similarity index 80%
rename from src/engine/mod.rs
rename to crates/npc-engine/src/lib.rs
index dffa614..71bd899 100644
--- a/src/engine/mod.rs
+++ b/crates/npc-engine/src/lib.rs
@@ -1,7 +1,7 @@
/*
* niepce - engine/mod.rs
*
- * Copyright (C) 2017 Hubert Figuière
+ * Copyright (C) 2017-2019 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
@@ -17,5 +17,13 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#[macro_use]
+extern crate try_opt;
+
+#[macro_use]
+extern crate npc_fwk;
+
pub mod db;
pub mod library;
+
+include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
diff --git a/src/engine/library/commands.rs b/crates/npc-engine/src/library/commands.rs
similarity index 98%
rename from src/engine/library/commands.rs
rename to crates/npc-engine/src/library/commands.rs
index 78c9ec1..ee22ec5 100644
--- a/src/engine/library/commands.rs
+++ b/crates/npc-engine/src/library/commands.rs
@@ -20,16 +20,17 @@
use std::os::raw::c_void;
use npc_fwk::PropertyValue;
-use engine::db::LibraryId;
-use engine::db::library;
-use engine::db::library::{
+use crate::db::LibraryId;
+use crate::db::library;
+use crate::db::library::{
Library,
Managed
};
-use engine::db::filebundle::FileBundle;
-use engine::db::keyword::Keyword;
-use engine::db::label::Label;
-use engine::db::libfolder::LibFolder;
+use crate::db::filebundle::FileBundle;
+use crate::db::keyword::Keyword;
+use crate::db::label::Label;
+use crate::db::libfolder::LibFolder;
+use crate::root::eng::NiepceProperties as Np;
use super::notification::LibNotification;
use super::notification::{
Content,
@@ -37,7 +38,6 @@ use super::notification::{
FileMove,
MetadataChange,
};
-use root::eng::NiepceProperties as Np;
pub fn cmd_list_all_keywords(lib: &Library) -> bool {
match lib.get_all_keywords() {
diff --git a/src/engine/library/mod.rs b/crates/npc-engine/src/library/mod.rs
similarity index 100%
rename from src/engine/library/mod.rs
rename to crates/npc-engine/src/library/mod.rs
diff --git a/src/engine/library/notification.rs b/crates/npc-engine/src/library/notification.rs
similarity index 98%
rename from src/engine/library/notification.rs
rename to crates/npc-engine/src/library/notification.rs
index 8df6c26..de9f8c3 100644
--- a/src/engine/library/notification.rs
+++ b/crates/npc-engine/src/library/notification.rs
@@ -19,20 +19,23 @@
use npc_fwk::base::PropertyIndex;
use npc_fwk::PropertyValue;
-use engine::db::{
+use npc_fwk::toolkit::PortableChannel;
+use crate::db::{
LibraryId,
Label, LibFolder, LibMetadata, Keyword
};
-use engine::db::libfile::{
+use crate::db::libfile::{
FileStatus,
};
-use libraryclient::LcChannel;
+
#[cfg(not(test))]
-use root::eng::QueriedContent;
+use crate::root::eng::QueriedContent;
#[cfg(not(test))]
pub type Content = QueriedContent;
+pub type LcChannel = PortableChannel<LibNotification>;
+
// Content need to be stubbed for the test as it is a FFI struct
// and is missing the proper C++ code.
#[cfg(test)]
diff --git a/src/engine/library/op.rs b/crates/npc-engine/src/library/op.rs
similarity index 97%
rename from src/engine/library/op.rs
rename to crates/npc-engine/src/library/op.rs
index f444d3c..908e165 100644
--- a/src/engine/library/op.rs
+++ b/crates/npc-engine/src/library/op.rs
@@ -19,7 +19,7 @@
use std::sync::Arc;
-use engine::db::Library;
+use crate::db::Library;
// When we can use a FnOnce here, we should.
type Function = dyn Fn(&Library) -> bool + Send + Sync + 'static;
diff --git a/crates/npc-fwk/src/toolkit/mod.rs b/crates/npc-fwk/src/toolkit/mod.rs
index 75a93b8..45234c3 100644
--- a/crates/npc-fwk/src/toolkit/mod.rs
+++ b/crates/npc-fwk/src/toolkit/mod.rs
@@ -1,2 +1,7 @@
pub mod mimetype;
+
+pub type Sender<T> = glib::Sender<T>;
+
+/// Wrapper type for the channel tuple to get passed down to the unsafe C++ code.
+pub struct PortableChannel<T>(pub Sender<T>, pub glib::SourceId);
diff --git a/doc/code-organization.txt b/doc/code-organization.txt
index f7f8fa6..cd832dc 100644
--- a/doc/code-organization.txt
+++ b/doc/code-organization.txt
@@ -4,12 +4,9 @@ Code organization
Here are the different directories for the source code:
* crates - internal Rust crates.
- * npc-fwk - the framework in Rust. Replaces src/fwk.
+ * npc-fwk - the framework in Rust. Replaces C++ code in src/fwk.
+ * npc-engine - the engine in Rust. Replaces C++ code in src/engine.
* src
- * ext - external code
- * libgdl - "stolen" from Inkscape, a fork of libgdl
- from Anjuta. Has matching C++ code in
- the framework.
* fwk - the framework
* utils - utilities
* toolkit - the UI toolkit (Gtkmm based)
diff --git a/src/Makefile.am b/src/Makefile.am
index 267c6a7..039c2fc 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -8,20 +8,21 @@ RUST_SOURCES = \
@top_srcdir@/build.rs \
@top_srcdir@/Cargo.toml \
@top_srcdir@/Cargo.lock \
- @top_srcdir@/src/engine/db/filebundle.rs \
- @top_srcdir@/src/engine/db/fsfile.rs \
- @top_srcdir@/src/engine/db/keyword.rs \
- @top_srcdir@/src/engine/db/label.rs \
- @top_srcdir@/src/engine/db/libfile.rs \
- @top_srcdir@/src/engine/db/libfolder.rs \
- @top_srcdir@/src/engine/db/libmetadata.rs \
- @top_srcdir@/src/engine/db/library.rs \
- @top_srcdir@/src/engine/db/mod.rs \
- @top_srcdir@/src/engine/library/commands.rs \
- @top_srcdir@/src/engine/library/mod.rs \
- @top_srcdir@/src/engine/library/notification.rs \
- @top_srcdir@/src/engine/library/op.rs \
- @top_srcdir@/src/engine/mod.rs \
+ @top_srcdir@/crates/npc-engine/Cargo.toml \
+ @top_srcdir@/crates/npc-engine/src/db/filebundle.rs \
+ @top_srcdir@/crates/npc-engine/src/db/fsfile.rs \
+ @top_srcdir@/crates/npc-engine/src/db/keyword.rs \
+ @top_srcdir@/crates/npc-engine/src/db/label.rs \
+ @top_srcdir@/crates/npc-engine/src/db/libfile.rs \
+ @top_srcdir@/crates/npc-engine/src/db/libfolder.rs \
+ @top_srcdir@/crates/npc-engine/src/db/libmetadata.rs \
+ @top_srcdir@/crates/npc-engine/src/db/library.rs \
+ @top_srcdir@/crates/npc-engine/src/db/mod.rs \
+ @top_srcdir@/crates/npc-engine/src/library/commands.rs \
+ @top_srcdir@/crates/npc-engine/src/library/mod.rs \
+ @top_srcdir@/crates/npc-engine/src/library/notification.rs \
+ @top_srcdir@/crates/npc-engine/src/library/op.rs \
+ @top_srcdir@/crates/npc-engine/src/lib.rs \
@top_srcdir@/crates/npc-fwk/Cargo.toml \
@top_srcdir@/crates/npc-fwk/build.rs \
@top_srcdir@/crates/npc-fwk/src/capi.rs \
diff --git a/src/lib.rs b/src/lib.rs
index be9bd1a..55a5c68 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -17,31 +17,21 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-extern crate chrono;
-extern crate exempi;
extern crate gettextrs;
extern crate gio;
-extern crate gio_sys;
extern crate glib;
-extern crate glib_sys;
extern crate gtk;
extern crate gtk_sys;
extern crate libc;
-extern crate multimap;
-extern crate rusqlite;
-#[macro_use]
-extern crate try_opt;
// internal crates
#[macro_use]
extern crate npc_fwk;
+extern crate npc_engine;
-pub mod engine;
pub mod libraryclient;
pub mod niepce;
-include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
-
use std::sync::Once;
/// Call this to initialize npc-fwk the gtk-rs bindings
diff --git a/src/libraryclient/clientimpl.rs b/src/libraryclient/clientimpl.rs
index 1c5abdc..fba5caa 100644
--- a/src/libraryclient/clientimpl.rs
+++ b/src/libraryclient/clientimpl.rs
@@ -25,13 +25,13 @@ use std::sync::atomic;
use std::thread;
use npc_fwk::base::PropertyValue;
-use engine::db::{Library, LibraryId};
-use engine::db::library::Managed;
-use engine::library::op::Op;
-use engine::library::commands;
-use engine::library::notification::LibNotification;
+use npc_engine::db::{Library, LibraryId};
+use npc_engine::db::library::Managed;
+use npc_engine::library::op::Op;
+use npc_engine::library::commands;
+use npc_engine::library::notification::LibNotification;
use super::clientinterface::{ClientInterface,ClientInterfaceSync};
-use root::eng::NiepceProperties as Np;
+use npc_engine::root::eng::NiepceProperties as Np;
pub struct ClientImpl {
terminate: sync::Arc<atomic::AtomicBool>,
@@ -46,7 +46,7 @@ impl Drop for ClientImpl {
impl ClientImpl {
- pub fn new(dir: PathBuf, sender: glib::Sender<LibNotification>) -> ClientImpl {
+ pub fn new(dir: PathBuf, sender: npc_fwk::toolkit::Sender<LibNotification>) -> ClientImpl {
let tasks = sync::Arc::new((sync::Mutex::new(VecDeque::new()), sync::Condvar::new()));
let mut terminate = sync::Arc::new(atomic::AtomicBool::new(false));
let tasks2 = tasks.clone();
diff --git a/src/libraryclient/clientinterface.rs b/src/libraryclient/clientinterface.rs
index 0b35bcb..2372900 100644
--- a/src/libraryclient/clientinterface.rs
+++ b/src/libraryclient/clientinterface.rs
@@ -18,9 +18,9 @@
*/
use npc_fwk::base::PropertyValue;
-use engine::db::LibraryId;
-use engine::db::library::Managed;
-use root::eng::NiepceProperties as Np;
+use npc_engine::db::LibraryId;
+use npc_engine::db::library::Managed;
+use npc_engine::root::eng::NiepceProperties as Np;
/// Client interface.
pub trait ClientInterface {
diff --git a/src/libraryclient/mod.rs b/src/libraryclient/mod.rs
index 4596ed5..a3d0b3e 100644
--- a/src/libraryclient/mod.rs
+++ b/src/libraryclient/mod.rs
@@ -28,15 +28,13 @@ use std::path::PathBuf;
use std::sync::Arc;
use npc_fwk::base::PropertyValue;
+use npc_fwk::toolkit::PortableChannel;
use self::clientimpl::ClientImpl;
-use engine::db::LibraryId;
-use engine::db::library::Managed;
-use engine::library::notification::LibNotification;
-use root::fwk::FileList;
-use root::eng::NiepceProperties as Np;
-
-/// Wrapper type for the channel tuple to get passed down to the unsafe C++ code.
-pub struct LcChannel(pub glib::Sender<LibNotification>, glib::SourceId);
+use npc_engine::db::LibraryId;
+use npc_engine::db::library::Managed;
+use npc_engine::library::notification::{LibNotification, LcChannel};
+use npc_engine::root::fwk::FileList;
+use npc_engine::root::eng::NiepceProperties as Np;
/// Wrap the libclient Arc so that it can be passed around
/// Used in the ffi for example.
@@ -181,7 +179,7 @@ pub unsafe extern "C" fn lcchannel_new(cb: extern fn(n: *const LibNotification,
}
glib::Continue(continuation)
});
- Box::into_raw(Box::new(LcChannel(sender, source_id)))
+ Box::into_raw(Box::new(PortableChannel::<LibNotification>(sender, source_id)))
}
#[no_mangle]
diff --git a/src/rust_bindings.hpp b/src/rust_bindings.hpp
index 4c42a73..5c6def7 100644
--- a/src/rust_bindings.hpp
+++ b/src/rust_bindings.hpp
@@ -45,6 +45,7 @@ typedef fwk::FileList FileList;
}
#include "target/fwk_bindings.h"
+#include "target/eng_bindings.h"
#include "target/bindings.h"
namespace fwk {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]