1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/// Declare a newtype wrapper for a `fn` ptr
/// and define related, useful items for that `fn` ptr (see below).
/// Given a `fn` signature with no body,
/// this generates a `mod` with the name of the `fn` provided that contains:
///
/// * `type FnPtr`:
/// The raw, inner `fn` ptr (according to the provided signature) contained by `Fn`.
///
/// * `type Fn`:
/// A newtype wrapping `FnPtr`.
/// It defines `const fn new(FnPtr) -> Self` to construct it
/// and `const fn get(&self) -> &FnPtr` to read the `FnPtr`.
///
/// These methods are marked `pub(super)`
/// as they are meant to be used in the module calling [`wrap_fn_ptr!`].
///
/// It is meant for a `fn call` method to also be implemented
/// for this type to allow users to call the `fn`
/// in a type-safe (e.x. [`BitDepth`]-wise)
/// and generally safer (memory safety-wise) way.
///
/// * `impl ` [`DefaultValue`] ` for Fn`:
/// A `const`-compatible default implementation of `Fn`
/// that just calls [`unimplemented!`].
/// This lets `Fn` be used by [`enum_map!`] without wrapping it in an [`Option`],
/// and removes any need for an [`Option::unwrap`] check,
/// as the check is moved to inside the `fn` call.
///
/// * `decl_fn!`:
/// A macro that, given a `fn $fn_name:ident`,
/// declares an `extern "C" fn` with the `fn` signature provided.
/// This macro can and is meant to be used with [`bd_fn!`].
///
/// This ensures that the `fn` signature is consistent between all of these
/// and reduces the need to repeat the `fn` signature many times.
///
/// [`BitDepth`]: crate::include::common::bitdepth::BitDepth
/// [`DefaultValue`]: crate::src::enum_map::DefaultValue
/// [`enum_map!`]: crate::src::enum_map::enum_map
/// [`bd_fn!`]: crate::include::common::bitdepth::bd_fn
pub const
}
pub use decl_fn;
}
};
}
pub use wrap_fn_ptr;