From cdac4ed1ce81b76e6684f778fd07c8ebdacce556 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Sat, 25 Aug 2018 04:58:53 +0200 Subject: 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?) --- src/cocoa_bridge.rs | 1 + src/lib.rs | 2 ++ src/parser.rs | 1 + 3 files changed, 4 insertions(+) (limited to 'src') 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 { diff --git a/src/lib.rs b/src/lib.rs index 7fb0b92..3127631 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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, -- cgit v1.2.3