diff options
| author | Teddy Wing | 2018-08-25 04:58:53 +0200 | 
|---|---|---|
| committer | Teddy Wing | 2018-08-25 05:03:46 +0200 | 
| commit | cdac4ed1ce81b76e6684f778fd07c8ebdacce556 (patch) | |
| tree | 3d40fd23cf36774b0368db32d48959da677b5f83 | |
| parent | 4b64b69e900e3eae5c410055c4c03a59c45419c2 (diff) | |
| download | dome-key-map-cdac4ed1ce81b76e6684f778fd07c8ebdacce556.tar.bz2 | |
Configure for importing from C/FFI
* Add `#[repr(C)]` on `HeadphoneButton` to hopefully be able to use it
  outside Rust
* Add `#[no_mangle]` to `run_key_action()`
* Export `run_key_action()` as a public function
* Build the crate as a static library
(But holy cow, a 19 MB library file?)
| -rw-r--r-- | Cargo.toml | 3 | ||||
| -rw-r--r-- | src/cocoa_bridge.rs | 1 | ||||
| -rw-r--r-- | src/lib.rs | 2 | ||||
| -rw-r--r-- | src/parser.rs | 1 | 
4 files changed, 7 insertions, 0 deletions
| @@ -5,3 +5,6 @@ version = "0.0.1"  [dependencies]  cocoa = "0.18.0"  combine = "3.4.0" + +[lib] +crate-type = ["staticlib"] diff --git a/src/cocoa_bridge.rs b/src/cocoa_bridge.rs index df144f1..d4749f0 100644 --- a/src/cocoa_bridge.rs +++ b/src/cocoa_bridge.rs @@ -44,6 +44,7 @@ pub struct KeyActionResult {      pub kind: MapKind,  } +#[no_mangle]  pub extern "C" fn run_key_action(      trigger: &[HeadphoneButton]  ) -> Option<KeyActionResult> { @@ -7,3 +7,5 @@ mod cocoa_bridge;  mod parser;  use parser::{HeadphoneButton, MapGroup, MapKind}; + +pub use cocoa_bridge::run_key_action; diff --git a/src/parser.rs b/src/parser.rs index d5cd860..c6c8cce 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -13,6 +13,7 @@ use combine::parser::char::{  use combine::parser::repeat::take_until;  use combine::stream::state::{SourcePosition, State}; +#[repr(C)]  #[derive(Debug, Hash, Eq, PartialEq)]  pub enum HeadphoneButton {      Play, | 
