diff options
| author | Teddy Wing | 2018-08-29 12:12:14 +0200 | 
|---|---|---|
| committer | Teddy Wing | 2018-08-29 12:12:14 +0200 | 
| commit | b8b09aa2ef1e945aaf7283de63d1d1f57585373b (patch) | |
| tree | 761befbd576cc9b302c21c63f6810360c0feca30 | |
| parent | 5d2685b89e891a8049fbbc635909b556c804eee7 (diff) | |
| download | dome-key-map-b8b09aa2ef1e945aaf7283de63d1d1f57585373b.tar.bz2 | |
c_run_key_action(): Make `trigger` argument nullable
Actually, now that I think about it, the trigger argument shouldn't be
nullable, since one should always be passed in. But this was really more
of a test to make sure we could do the same for a new `mode` argument,
which will also be a `Trigger`, but which might be null.
| -rw-r--r-- | dome_key_map.h | 2 | ||||
| -rw-r--r-- | includer.c | 2 | ||||
| -rw-r--r-- | src/cocoa_bridge.rs | 7 | 
3 files changed, 6 insertions, 5 deletions
| diff --git a/dome_key_map.h b/dome_key_map.h index f3c3f68..c6bf4c1 100644 --- a/dome_key_map.h +++ b/dome_key_map.h @@ -27,4 +27,4 @@ typedef struct {    size_t length;  } Trigger; -const CKeyActionResult *c_run_key_action(Trigger trigger); +const CKeyActionResult *c_run_key_action(const Trigger *trigger); @@ -9,7 +9,7 @@ int main() {  		.buttons = buttons,  		.length = SIZE  	}; -	const CKeyActionResult *result = c_run_key_action(trigger); +	const CKeyActionResult *result = c_run_key_action(&trigger);  	printf("%s", result->action);  	return 0; diff --git a/src/cocoa_bridge.rs b/src/cocoa_bridge.rs index 9392fcb..4d63c44 100644 --- a/src/cocoa_bridge.rs +++ b/src/cocoa_bridge.rs @@ -61,12 +61,13 @@ pub struct CKeyActionResult {  #[no_mangle]  pub extern "C" fn c_run_key_action( -    trigger: Trigger, +    trigger: *const Trigger,  ) -> *const CKeyActionResult {      let trigger = unsafe { -        assert!(!trigger.buttons.is_null()); +        assert!(!trigger.is_null()); +        assert!(!(*trigger).buttons.is_null()); -        slice::from_raw_parts(trigger.buttons, trigger.length as usize) +        slice::from_raw_parts((*trigger).buttons, (*trigger).length as usize)      };      let result = match run_key_action_for_mode(trigger, None) { | 
