| 1 |
(* @eladrion's example for issue #18212 *) |
| 2 |
|
| 3 |
From Corelib Require Extraction. |
| 4 |
|
| 5 |
(* Define an axiomatic function. *) |
| 6 |
Axiom ax_fun : nat -> nat. |
| 7 |
|
| 8 |
(* Define a fully specified function*) |
| 9 |
Definition exact_fun (a : nat) := (ax_fun a) + 1. |
| 10 |
|
| 11 |
(* Define duplicate of the fully specified function*) |
| 12 |
Definition exact_fun2 (a : nat) := (ax_fun a) + 1. |
| 13 |
|
| 14 |
(* before we give the directive axioms produce failwith "axiom to be realized" *) |
| 15 |
Extraction ax_fun. |
| 16 |
|
| 17 |
(* ax_fun shall be a FFI call to the C function my_c_fun *) |
| 18 |
Extract Foreign Constant ax_fun => "my_c_fun". |
| 19 |
Extraction ax_fun. |
| 20 |
|
| 21 |
(* Extract exact_fun *) |
| 22 |
Extraction exact_fun. |
| 23 |
|
| 24 |
(* exact_fun shall now be a FFI call to the C function my_c_fun *) |
| 25 |
Extract Foreign Constant exact_fun => "my_exact_c_fun". |
| 26 |
Extraction exact_fun. |
| 27 |
|
| 28 |
(* Now, exact_fun is an entry point exposed to C *) |
| 29 |
Extract Callback "call_exact_fun" exact_fun2. |
| 30 |
Extraction exact_fun2. |
| 31 |
|
| 32 |
(* Now we make sure that a callback registration can be reverted *) |
| 33 |
Reset Extraction Callback. |
| 34 |
Extraction exact_fun2. |