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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
//! Various derive macros for oxidd
//!
//! Note that the code generated by the macros depends on definitions in
//! `oxidd_core`, not their re-exports in `oxidd`. So in case you want to use
//! these macros as an "external" user, you may need to add `oxidd_core` to your
//! `Cargo.toml`.
pub
// The actual proc macros must reside at the root of the crate:
/// Derive the `Countable` trait from `oxidd_core`
///
/// The `Countable` trait can be derived for:
/// - Fieldless `enum`s with primitive representation (currently `repr(u8)`
/// only). Explicit discriminants are not yet supported.
/// - `struct`s with zero fields.
/// Derive the `ManagerEventSubscriber` trait from `oxidd_core::util`
///
/// # Example
///
/// ```
/// # use std::marker::PhantomData;
/// # use oxidd_core::{Manager, ManagerEventSubscriber};
/// # use oxidd_derive::ManagerEventSubscriber;
/// # struct ApplyCache<M>(PhantomData<M>);
/// # impl<M: Manager> ManagerEventSubscriber<M> for ApplyCache<M> {}
/// # struct ZBDDCache<M>(PhantomData<M>);
/// # impl<M: Manager> ManagerEventSubscriber<M> for ZBDDCache<M> {}
/// #[derive(ManagerEventSubscriber)]
/// #[subscribe(manager = M)]
/// struct ManagerData<M> {
/// apply_cache: ApplyCache<M>,
/// zbdd_cache: ZBDDCache<M>,
/// #[subscribe(skip)]
/// field_to_skip: bool,
/// }
/// ```
///
/// Specifying the manager type via `#[subscribe(manager = M)]` is mandatory (it
/// does not need to be a generic parameter, though). The generated
/// implementation will look like this:
///
/// ```
/// # use std::marker::PhantomData;
/// # use oxidd_core::{Manager, ManagerEventSubscriber};
/// # struct ApplyCache<M>(PhantomData<M>);
/// # impl<M: Manager> ManagerEventSubscriber<M> for ApplyCache<M> {}
/// # struct ZBDDCache<M>(PhantomData<M>);
/// # impl<M: Manager> ManagerEventSubscriber<M> for ZBDDCache<M> {}
/// # struct ManagerData<M> {
/// # apply_cache: ApplyCache<M>,
/// # zbdd_cache: ZBDDCache<M>,
/// # field_to_skip: bool,
/// # }
/// impl<M> ManagerEventSubscriber<M> for ManagerData<M>
/// where
/// M: Manager,
/// ApplyCache<M>: ManagerEventSubscriber<M>,
/// ZBDDCache<M>: ManagerEventSubscriber<M>,
/// {
/// fn pre_gc(&self, manager: &M) {
/// self.apply_cache.pre_gc(manager);
/// self.zbdd_cache.pre_gc(manager);
/// }
/// unsafe fn post_gc(&self, manager: &M) {
/// // SAFETY: since the caller ensures to call this method (only!) once
/// // after a GC, we call `post_gc` (only) once for each substructure.
/// unsafe {
/// self.apply_cache.post_gc(manager);
/// self.zbdd_cache.post_gc(manager);
/// }
/// }
/// // similar implementations for `pre_reorder` and `post_reorder` ...
/// fn pre_reorder_mut(manager: &mut M) {
/// ApplyCache::<M>::pre_reorder_mut(manager);
/// ZBDDCache::<M>::pre_reorder_mut(manager);
/// }
/// // similar implementation for `post_reorder_mut` ...
/// }
/// ```
///
/// Note that if you have two fields of the same type (and you do not use
/// `#[subscribe(skip)]` on either of these fields), the `pre_reorder_mut` and
/// `post_reorder_mut` implementation will call the method for that type twice
/// (with the same `manager` argument).
///
/// In some cases the trait bounds `M: Manager`,
/// `ApplyCache<M>: ManagerEventSubscriber<M>`, etc. can lead to undesired
/// self-references and cause the [compiler error
/// E0275](https://doc.rust-lang.org/stable/error_codes/E0275.html). To disable
/// the generation of those trait bounds, specify `no_trait_bounds` via a
/// struct-level `subscribe` attribute. (This will not affect trait bounds from
/// the struct declaration itself.)
/// Derive the `Function` trait from `oxidd_core::function`
///
/// This trait can be derived for `struct`s that wrap another `Function`
/// implementation. Currently, this macro is restricted to `struct`s with a
/// single field.
///
/// You may specify the associated `ManagerRef` type using an attribute
/// `#[use_manager_ref(YourManagerRefType)]`.
///
/// To influence the representation identifier, use the attribute
/// `#[repr_id = "MY_BDD"]`.
/// Derive the `FunctionSubst` trait from `oxidd_core::function`
///
/// This trait can be derived for `struct`s that wrap another `FunctionSubst`
/// implementation. The same restrictions apply as for deriving [`Function`].
/// Derive the `BooleanFunction` trait from `oxidd_core::function`
///
/// This trait can be derived for `struct`s that wrap another `BooleanFunction`
/// implementation. The same restrictions apply as for deriving [`Function`].
/// Derive the `BooleanFunctionQuant` trait from `oxidd_core::function`
///
/// This trait can be derived for `struct`s that wrap another
/// `BooleanFunctionQuant` implementation. The same restrictions apply as for
/// deriving [`Function`].
/// Derive the `BooleanVecSet` trait from `oxidd_core::function`
///
/// This trait can be derived for `struct`s that wrap another `BooleanVecSet`
/// implementation. The same restrictions apply as for deriving [`Function`].
/// Derive the `PseudoBooleanFunction` trait from `oxidd_core::function`
///
/// This trait can be derived for `struct`s that wrap another
/// `PseudoBooleanFunction` implementation. The same restrictions apply as for
/// deriving [`Function`].
/// Derive the `TVLFunction` trait from `oxidd_core::function`
///
/// This trait can be derived for `struct`s that wrap another `TVLFunction`
/// implementation. The same restrictions apply as for deriving [`Function`].