73
73
// Callback must outlive component.
74
74
F : FnMut ( zeroize:: Zeroizing < String > ) + ' a ,
75
75
{
76
- unsafe extern "C" fn c_confirm_callback < F2 > ( password : * const c_char , param : * mut c_void )
76
+ unsafe extern "C" fn c_confirm_callback < F2 > ( password : * const c_char , user_data : * mut c_void )
77
77
where
78
78
F2 : FnMut ( zeroize:: Zeroizing < String > ) ,
79
79
{
@@ -84,16 +84,16 @@ where
84
84
) ;
85
85
// The callback is dropped afterwards. This is safe because
86
86
// this C callback is guaranteed to be called only once.
87
- let mut callback = unsafe { Box :: from_raw ( param as * mut F2 ) } ;
87
+ let mut callback = unsafe { Box :: from_raw ( user_data as * mut F2 ) } ;
88
88
callback ( pw) ;
89
89
}
90
90
91
- unsafe extern "C" fn c_cancel_callback ( param : * mut c_void ) {
92
- let callback = param as * mut ContinueCancelCb ;
91
+ unsafe extern "C" fn c_cancel_callback ( user_data : * mut c_void ) {
92
+ let callback = user_data as * mut ContinueCancelCb ;
93
93
unsafe { ( * callback) ( ) } ;
94
94
}
95
95
96
- let ( cancel_cb, cancel_cb_param ) = match cancel_callback {
96
+ let ( cancel_cb, cancel_user_data ) = match cancel_callback {
97
97
None => ( None , core:: ptr:: null_mut ( ) ) ,
98
98
Some ( cb) => (
99
99
Some ( c_cancel_callback as _ ) ,
@@ -105,19 +105,19 @@ where
105
105
bitbox02_sys:: trinary_input_string_create (
106
106
& params. to_c_params ( & mut title_scratch) . data , // title copied in C
107
107
Some ( c_confirm_callback :: < F > ) ,
108
- // passed to c_confirm_callback as `param `.
108
+ // passed to c_confirm_callback as `user_data `.
109
109
Box :: into_raw ( Box :: new ( confirm_callback) ) as * mut _ ,
110
110
cancel_cb,
111
- cancel_cb_param ,
111
+ cancel_user_data ,
112
112
)
113
113
} ;
114
114
Component {
115
115
component,
116
116
is_pushed : false ,
117
117
on_drop : Some ( Box :: new ( move || unsafe {
118
118
// Drop all callbacks.
119
- if !cancel_cb_param . is_null ( ) {
120
- drop ( Box :: from_raw ( cancel_cb_param as * mut ContinueCancelCb ) ) ;
119
+ if !cancel_user_data . is_null ( ) {
120
+ drop ( Box :: from_raw ( cancel_user_data as * mut ContinueCancelCb ) ) ;
121
121
}
122
122
} ) ) ,
123
123
_p : PhantomData ,
@@ -131,13 +131,13 @@ where
131
131
// Callback must outlive component.
132
132
F : FnMut ( bool ) + ' a ,
133
133
{
134
- unsafe extern "C" fn c_callback < F2 > ( result : bool , param : * mut c_void )
134
+ unsafe extern "C" fn c_callback < F2 > ( result : bool , user_data : * mut c_void )
135
135
where
136
136
F2 : FnMut ( bool ) ,
137
137
{
138
138
// The callback is dropped afterwards. This is safe because
139
139
// this C callback is guaranteed to be called only once.
140
- let mut callback = unsafe { Box :: from_raw ( param as * mut F2 ) } ;
140
+ let mut callback = unsafe { Box :: from_raw ( user_data as * mut F2 ) } ;
141
141
callback ( result) ;
142
142
}
143
143
let mut title_scratch = Vec :: new ( ) ;
@@ -148,7 +148,7 @@ where
148
148
. to_c_params ( & mut title_scratch, & mut body_scratch)
149
149
. data ,
150
150
Some ( c_callback :: < F > ) ,
151
- // passed to the C callback as `param `
151
+ // passed to the C callback as `user_data `
152
152
Box :: into_raw ( Box :: new ( result_callback) ) as * mut _ ,
153
153
)
154
154
} ;
@@ -171,13 +171,13 @@ where
171
171
// Callback must outlive component.
172
172
F : FnMut ( ) + ' a ,
173
173
{
174
- unsafe extern "C" fn c_callback < F2 > ( param : * mut c_void )
174
+ unsafe extern "C" fn c_callback < F2 > ( user_data : * mut c_void )
175
175
where
176
176
F2 : FnMut ( ) ,
177
177
{
178
178
// The callback is dropped afterwards. This is safe because
179
179
// this C callback is guaranteed to be called only once.
180
- let mut callback = unsafe { Box :: from_raw ( param as * mut F2 ) } ;
180
+ let mut callback = unsafe { Box :: from_raw ( user_data as * mut F2 ) } ;
181
181
callback ( ) ;
182
182
}
183
183
@@ -186,7 +186,7 @@ where
186
186
crate :: util:: str_to_cstr_vec ( text) . unwrap ( ) . as_ptr ( ) , // copied in C
187
187
status_success,
188
188
Some ( c_callback :: < F > ) ,
189
- Box :: into_raw ( Box :: new ( callback) ) as * mut _ , // passed to c_callback as `param `.
189
+ Box :: into_raw ( Box :: new ( callback) ) as * mut _ , // passed to c_callback as `user_data `.
190
190
)
191
191
} ;
192
192
Component {
@@ -202,20 +202,20 @@ where
202
202
// Callback must outlive component.
203
203
F : FnMut ( bool ) + ' a ,
204
204
{
205
- unsafe extern "C" fn c_callback < F2 > ( sd_done : bool , param : * mut c_void )
205
+ unsafe extern "C" fn c_callback < F2 > ( sd_done : bool , user_data : * mut c_void )
206
206
where
207
207
F2 : FnMut ( bool ) ,
208
208
{
209
209
// The callback is dropped afterwards. This is safe because
210
210
// this C callback is guaranteed to be called only once.
211
- let mut callback = unsafe { Box :: from_raw ( param as * mut F2 ) } ;
211
+ let mut callback = unsafe { Box :: from_raw ( user_data as * mut F2 ) } ;
212
212
callback ( sd_done) ;
213
213
}
214
214
215
215
let component = unsafe {
216
216
bitbox02_sys:: sdcard_create (
217
217
Some ( c_callback :: < F > ) ,
218
- // passed to the C callback as `param `
218
+ // passed to the C callback as `user_data `
219
219
Box :: into_raw ( Box :: new ( callback) ) as * mut _ ,
220
220
)
221
221
} ;
@@ -228,13 +228,13 @@ where
228
228
}
229
229
230
230
pub fn menu_create ( params : MenuParams < ' _ > ) -> Component < ' _ > {
231
- unsafe extern "C" fn c_select_word_cb ( word_idx : u8 , param : * mut c_void ) {
232
- let callback = param as * mut SelectWordCb ;
231
+ unsafe extern "C" fn c_select_word_cb ( word_idx : u8 , user_data : * mut c_void ) {
232
+ let callback = user_data as * mut SelectWordCb ;
233
233
unsafe { ( * callback) ( word_idx) } ;
234
234
}
235
235
236
- unsafe extern "C" fn c_continue_cancel_cb ( param : * mut c_void ) {
237
- let callback = param as * mut ContinueCancelCb ;
236
+ unsafe extern "C" fn c_continue_cancel_cb ( user_data : * mut c_void ) {
237
+ let callback = user_data as * mut ContinueCancelCb ;
238
238
unsafe { ( * callback) ( ) } ;
239
239
}
240
240
@@ -252,23 +252,23 @@ pub fn menu_create(params: MenuParams<'_>) -> Component<'_> {
252
252
let c_words: Vec < * const core:: ffi:: c_char > =
253
253
words. iter ( ) . map ( |word| word. as_ptr ( ) as _ ) . collect ( ) ;
254
254
255
- let ( select_word_cb, select_word_cb_param ) = match params. select_word_cb {
255
+ let ( select_word_cb, select_word_user_data ) = match params. select_word_cb {
256
256
None => ( None , core:: ptr:: null_mut ( ) ) ,
257
257
Some ( cb) => (
258
258
Some ( c_select_word_cb as _ ) ,
259
259
Box :: into_raw ( Box :: new ( cb) ) as * mut c_void ,
260
260
) ,
261
261
} ;
262
262
263
- let ( continue_on_last_cb, continue_on_last_cb_param ) = match params. continue_on_last_cb {
263
+ let ( continue_on_last_cb, continue_on_last_user_data ) = match params. continue_on_last_cb {
264
264
None => ( None , core:: ptr:: null_mut ( ) ) ,
265
265
Some ( cb) => (
266
266
Some ( c_continue_cancel_cb as _ ) ,
267
267
Box :: into_raw ( Box :: new ( cb) ) as * mut c_void ,
268
268
) ,
269
269
} ;
270
270
271
- let ( cancel_cb, cancel_cb_param ) = match params. cancel_cb {
271
+ let ( cancel_cb, cancel_user_data ) = match params. cancel_cb {
272
272
None => ( None , core:: ptr:: null_mut ( ) ) ,
273
273
Some ( cb) => (
274
274
Some ( c_continue_cancel_cb as _ ) ,
@@ -282,16 +282,16 @@ pub fn menu_create(params: MenuParams<'_>) -> Component<'_> {
282
282
bitbox02_sys:: menu_create (
283
283
c_words. as_ptr ( ) ,
284
284
select_word_cb,
285
- select_word_cb_param ,
285
+ select_word_user_data ,
286
286
words. len ( ) as _ ,
287
287
// copied in C
288
288
title
289
289
. as_ref ( )
290
290
. map_or_else ( core:: ptr:: null, |title| title. as_ptr ( ) ) ,
291
291
continue_on_last_cb,
292
- continue_on_last_cb_param ,
292
+ continue_on_last_user_data ,
293
293
cancel_cb,
294
- cancel_cb_param ,
294
+ cancel_user_data ,
295
295
core:: ptr:: null_mut ( ) ,
296
296
)
297
297
} ;
@@ -300,16 +300,16 @@ pub fn menu_create(params: MenuParams<'_>) -> Component<'_> {
300
300
is_pushed : false ,
301
301
on_drop : Some ( Box :: new ( move || unsafe {
302
302
// Drop all callbacks.
303
- if !select_word_cb_param . is_null ( ) {
304
- drop ( Box :: from_raw ( select_word_cb_param as * mut SelectWordCb ) ) ;
303
+ if !select_word_user_data . is_null ( ) {
304
+ drop ( Box :: from_raw ( select_word_user_data as * mut SelectWordCb ) ) ;
305
305
}
306
- if !continue_on_last_cb_param . is_null ( ) {
306
+ if !continue_on_last_user_data . is_null ( ) {
307
307
drop ( Box :: from_raw (
308
- continue_on_last_cb_param as * mut ContinueCancelCb ,
308
+ continue_on_last_user_data as * mut ContinueCancelCb ,
309
309
) ) ;
310
310
}
311
- if !cancel_cb_param . is_null ( ) {
312
- drop ( Box :: from_raw ( cancel_cb_param as * mut ContinueCancelCb ) ) ;
311
+ if !cancel_user_data . is_null ( ) {
312
+ drop ( Box :: from_raw ( cancel_user_data as * mut ContinueCancelCb ) ) ;
313
313
}
314
314
} ) ) ,
315
315
_p : PhantomData ,
@@ -323,12 +323,12 @@ pub fn trinary_choice_create<'a>(
323
323
label_right : Option < & ' a str > ,
324
324
chosen_callback : TrinaryChoiceCb ,
325
325
) -> Component < ' a > {
326
- unsafe extern "C" fn c_chosen_cb ( choice : TrinaryChoice , param : * mut c_void ) {
327
- let callback = param as * mut TrinaryChoiceCb ;
326
+ unsafe extern "C" fn c_chosen_cb ( choice : TrinaryChoice , user_data : * mut c_void ) {
327
+ let callback = user_data as * mut TrinaryChoiceCb ;
328
328
unsafe { ( * callback) ( choice) } ;
329
329
}
330
330
331
- let chosen_cb_param = Box :: into_raw ( Box :: new ( chosen_callback) ) as * mut c_void ;
331
+ let chosen_user_data = Box :: into_raw ( Box :: new ( chosen_callback) ) as * mut c_void ;
332
332
333
333
let label_left = label_left. map ( |label| crate :: util:: str_to_cstr_vec ( label) . unwrap ( ) ) ;
334
334
let label_middle = label_middle. map ( |label| crate :: util:: str_to_cstr_vec ( label) . unwrap ( ) ) ;
@@ -350,7 +350,7 @@ pub fn trinary_choice_create<'a>(
350
350
. as_ref ( )
351
351
. map_or_else ( core:: ptr:: null, |label| label. as_ptr ( ) ) ,
352
352
Some ( c_chosen_cb as _ ) ,
353
- chosen_cb_param ,
353
+ chosen_user_data ,
354
354
core:: ptr:: null_mut ( ) , // parent component, there is no parent.
355
355
)
356
356
} ;
@@ -359,7 +359,7 @@ pub fn trinary_choice_create<'a>(
359
359
is_pushed : false ,
360
360
on_drop : Some ( Box :: new ( move || unsafe {
361
361
// Drop all callbacks.
362
- drop ( Box :: from_raw ( chosen_cb_param as * mut TrinaryChoiceCb ) ) ;
362
+ drop ( Box :: from_raw ( chosen_user_data as * mut TrinaryChoiceCb ) ) ;
363
363
} ) ) ,
364
364
_p : PhantomData ,
365
365
}
@@ -370,26 +370,26 @@ pub fn confirm_transaction_address_create<'a, 'b>(
370
370
address : & ' a str ,
371
371
callback : AcceptRejectCb < ' b > ,
372
372
) -> Component < ' b > {
373
- unsafe extern "C" fn c_callback ( result : bool , param : * mut c_void ) {
374
- let callback = param as * mut AcceptRejectCb ;
373
+ unsafe extern "C" fn c_callback ( result : bool , user_data : * mut c_void ) {
374
+ let callback = user_data as * mut AcceptRejectCb ;
375
375
unsafe { ( * callback) ( result) } ;
376
376
}
377
377
378
- let callback_param = Box :: into_raw ( Box :: new ( callback) ) as * mut c_void ;
378
+ let user_data = Box :: into_raw ( Box :: new ( callback) ) as * mut c_void ;
379
379
let component = unsafe {
380
380
bitbox02_sys:: confirm_transaction_address_create (
381
381
crate :: util:: str_to_cstr_vec ( amount) . unwrap ( ) . as_ptr ( ) , // copied in C
382
382
crate :: util:: str_to_cstr_vec ( address) . unwrap ( ) . as_ptr ( ) , // copied in C
383
383
Some ( c_callback as _ ) ,
384
- callback_param ,
384
+ user_data ,
385
385
)
386
386
} ;
387
387
Component {
388
388
component,
389
389
is_pushed : false ,
390
390
on_drop : Some ( Box :: new ( move || unsafe {
391
391
// Drop all callbacks.
392
- drop ( Box :: from_raw ( callback_param as * mut AcceptRejectCb ) ) ;
392
+ drop ( Box :: from_raw ( user_data as * mut AcceptRejectCb ) ) ;
393
393
} ) ) ,
394
394
_p : PhantomData ,
395
395
}
@@ -401,27 +401,27 @@ pub fn confirm_transaction_fee_create<'a, 'b>(
401
401
longtouch : bool ,
402
402
callback : AcceptRejectCb < ' b > ,
403
403
) -> Component < ' b > {
404
- unsafe extern "C" fn c_callback ( result : bool , param : * mut c_void ) {
405
- let callback = param as * mut AcceptRejectCb ;
404
+ unsafe extern "C" fn c_callback ( result : bool , user_data : * mut c_void ) {
405
+ let callback = user_data as * mut AcceptRejectCb ;
406
406
unsafe { ( * callback) ( result) } ;
407
407
}
408
408
409
- let callback_param = Box :: into_raw ( Box :: new ( callback) ) as * mut c_void ;
409
+ let user_data = Box :: into_raw ( Box :: new ( callback) ) as * mut c_void ;
410
410
let component = unsafe {
411
411
bitbox02_sys:: confirm_transaction_fee_create (
412
412
crate :: util:: str_to_cstr_vec ( amount) . unwrap ( ) . as_ptr ( ) , // copied in C
413
413
crate :: util:: str_to_cstr_vec ( fee) . unwrap ( ) . as_ptr ( ) , // copied in C
414
414
longtouch,
415
415
Some ( c_callback as _ ) ,
416
- callback_param ,
416
+ user_data ,
417
417
)
418
418
} ;
419
419
Component {
420
420
component,
421
421
is_pushed : false ,
422
422
on_drop : Some ( Box :: new ( move || unsafe {
423
423
// Drop all callbacks.
424
- drop ( Box :: from_raw ( callback_param as * mut AcceptRejectCb ) ) ;
424
+ drop ( Box :: from_raw ( user_data as * mut AcceptRejectCb ) ) ;
425
425
} ) ) ,
426
426
_p : PhantomData ,
427
427
}
0 commit comments