So. Much. Work.
parent: tbd commit: b05f964
1 | |
2 | |
3 | use |
4 | , HashMap, Debug, transmute, null_mut, Arc, | type_name
5 | ; |
6 | |
7 | use Version; |
8 | use ; |
9 | |
10 | use crate:: |
11 | |
12 | OperationHandlerCallback, SettingChangeCallback, SettingGetterCallback, |
13 | ValueChangeCallback, ValueGetterCallback, |
14 | , |
15 | , |
16 | AnyObject, AnyOperation, FFIBox, NewAnySetting, NewAnyValue, ObjectVtable, OperationVTable, |
17 | SettingVtable, ValueVTable, |
18 | ; |
19 | |
20 | use OperationHandlerRules; |
21 | |
22 | |
23 | |
24 | pub objects: , |
25 | pub operations: , |
26 | pub settings: , |
27 | pub values: , |
28 | |
29 | |
30 | |
31 | |
32 | trace!; |
33 | |
34 | self.objects.insert; |
35 | |
36 | |
37 | |
38 | &mut self, |
39 | object_kind: &'static str, |
40 | operation_name: &'static str, |
41 | vtable: OperationVTable, |
42 | |
43 | trace! |
44 | "Registering operation metadata for {}::{}", |
45 | object_kind, |
46 | operation_name |
47 | ; |
48 | |
49 | self.operations.insert |
50 | ObjectOperationPair |
51 | object_kind, |
52 | operation_name, |
53 | , |
54 | vtable, |
55 | ; |
56 | |
57 | |
58 | |
59 | &mut self, |
60 | object_kind: &'static str, |
61 | setting_name: &'static str, |
62 | vtable: SettingVtable, |
63 | |
64 | trace!; |
65 | |
66 | self.settings.insert |
67 | ObjectSettingPair |
68 | object_kind, |
69 | setting_name, |
70 | , |
71 | vtable, |
72 | ; |
73 | |
74 | |
75 | |
76 | &mut self, |
77 | object_kind: &'static str, |
78 | value_name: &'static str, |
79 | vtable: ValueVTable, |
80 | |
81 | trace!; |
82 | |
83 | self.values.insert |
84 | ObjectValuePair |
85 | object_kind, |
86 | value_name, |
87 | , |
88 | vtable, |
89 | ; |
90 | |
91 | |
92 | |
93 | |
94 | |
95 | pub object_kind: &'s str, |
96 | pub operation_name: &'s str, |
97 | |
98 | |
99 | |
100 | |
101 | Self |
102 | object_kind, |
103 | operation_name, |
104 | |
105 | |
106 | |
107 | |
108 | |
109 | |
110 | pub object_kind: &'s str, |
111 | pub setting_name: &'s str, |
112 | |
113 | |
114 | |
115 | |
116 | Self |
117 | object_kind, |
118 | setting_name, |
119 | |
120 | |
121 | |
122 | |
123 | |
124 | |
125 | pub object_kind: &'s str, |
126 | pub value_name: &'s str, |
127 | |
128 | |
129 | |
130 | |
131 | Self |
132 | object_kind, |
133 | value_name, |
134 | |
135 | |
136 | |
137 | |
138 | |
139 | |
140 | |
141 | pub inner: *mut (), |
142 | |
143 | |
144 | |
145 | pub unsafe |
146 | Box from_raw |
147 | |
148 | |
149 | pub unsafe |
150 | let ptr: *const T = transmute; |
151 | |
152 | ptr.as_ref .unwrap |
153 | |
154 | |
155 | |
156 | |
157 | |
158 | Self |
159 | |
160 | |
161 | |
162 | |
163 | |
164 | plugins: , |
165 | handlers: RuntimeHandlers, |
166 | |
167 | |
168 | |
169 | |
170 | let _guard = debug_span! .entered; |
171 | |
172 | for in &plugin.initialization.operation_handlers |
173 | let _guard = |
174 | trace_span! .entered; |
175 | |
176 | if self |
177 | .handlers |
178 | .operation_handlers |
179 | .insert |
180 | .is_some |
181 | |
182 | warn! |
183 | |
184 | |
185 | trace! |
186 | |
187 | |
188 | for in &plugin.initialization.value_getters |
189 | let _guard = |
190 | trace_span! .entered; |
191 | |
192 | if self |
193 | .handlers |
194 | .value_getters |
195 | .insert |
196 | .is_some |
197 | |
198 | warn! |
199 | |
200 | |
201 | trace! |
202 | |
203 | |
204 | for in &plugin.initialization.setting_getters |
205 | let _guard = |
206 | trace_span! .entered; |
207 | |
208 | if self |
209 | .handlers |
210 | .setting_getters |
211 | .insert |
212 | .is_some |
213 | |
214 | warn! |
215 | |
216 | |
217 | trace! |
218 | |
219 | |
220 | |
221 | |
222 | &self, |
223 | object_kind: &str, |
224 | operation_name: &str, |
225 | object: &str, |
226 | operation_payload: &[u8], |
227 | |
228 | let rules = self.handlers.handle_operation; |
229 | |
230 | rules.handle |
231 | |
232 | |
233 | |
234 | |
235 | |
236 | operation_handlers: |
237 | , |
238 | value_getters: , |
239 | setting_getters: , |
240 | value_change: , |
241 | setting_change: , |
242 | |
243 | |
244 | |
245 | |
246 | &mut self, |
247 | pair: , |
248 | handler: OperationHandlerCallback, |
249 | domain: RuntimeDomain, |
250 | |
251 | trace! |
252 | "Inserting operation handler for {}::{}", |
253 | pair.object_kind, |
254 | pair.operation_name |
255 | ; |
256 | |
257 | // There can only be one handler per operation (at least for now?), send a warning if |
258 | // a newly registered handler overwrites the previous handler. |
259 | if self |
260 | .operation_handlers |
261 | .insert |
262 | .is_some |
263 | |
264 | debug!; |
265 | |
266 | |
267 | |
268 | |
269 | &mut self, |
270 | pair: , |
271 | handler: ValueGetterCallback, |
272 | domain: RuntimeDomain, |
273 | |
274 | trace! |
275 | "Inserting value getter for {}::{}", |
276 | pair.object_kind, |
277 | pair.value_name |
278 | ; |
279 | |
280 | if self.value_getters.insert .is_some |
281 | debug! |
282 | "Warning! A newly inserted value getter for {}::{} overwrites a previous handler.", |
283 | pair.object_kind, pair.value_name |
284 | ; |
285 | |
286 | |
287 | |
288 | |
289 | &mut self, |
290 | pair: , |
291 | handler: SettingGetterCallback, |
292 | domain: RuntimeDomain, |
293 | |
294 | trace! |
295 | "Inserting setting getter for {}::{}", |
296 | pair.object_kind, |
297 | pair.setting_name |
298 | ; |
299 | |
300 | if self |
301 | .setting_getters |
302 | .insert |
303 | .is_some |
304 | |
305 | debug!; |
306 | |
307 | |
308 | |
309 | |
310 | &mut self, |
311 | pair: , |
312 | handler: ValueChangeCallback, |
313 | domain: RuntimeDomain, |
314 | |
315 | trace! |
316 | "Inserting value change handler for {}::{}", |
317 | pair.object_kind, |
318 | pair.value_name |
319 | ; |
320 | |
321 | if self.value_change.insert .is_some |
322 | debug!; |
323 | panic!; |
324 | |
325 | |
326 | |
327 | |
328 | &mut self, |
329 | pair: , |
330 | handler: SettingChangeCallback, |
331 | domain: RuntimeDomain, |
332 | |
333 | trace! |
334 | "Inserting setting change handler for {}::{}", |
335 | pair.object_kind, |
336 | pair.setting_name |
337 | ; |
338 | |
339 | if self |
340 | .setting_change |
341 | .insert |
342 | .is_some |
343 | |
344 | debug!; |
345 | panic!; |
346 | |
347 | |
348 | |
349 | |
350 | |
351 | |
352 | &'o self, |
353 | object_kind: &'o str, |
354 | operation_name: &'o str, |
355 | |
356 | new |
357 | |
358 | |
359 | |
360 | |
361 | plugin: PluginHandle, |
362 | |
363 | |
364 | |
365 | |
366 | Self |
367 | plugin: plugin.clone, |
368 | |
369 | |
370 | |
371 | |
372 | self.plugin |
373 | .initialization |
374 | .type_metadata |
375 | .objects |
376 | .get |
377 | .copied |
378 | |
379 | |
380 | |
381 | &self, |
382 | object_kind: &str, |
383 | operation_name: &str, |
384 | |
385 | self.plugin |
386 | .initialization |
387 | .type_metadata |
388 | .operations |
389 | .get |
390 | .copied |
391 | |
392 | |
393 | |
394 | self.plugin |
395 | .initialization |
396 | .type_metadata |
397 | .settings |
398 | .get |
399 | .copied |
400 | |
401 | |
402 | |
403 | self.plugin |
404 | .initialization |
405 | .type_metadata |
406 | .values |
407 | .get |
408 | .copied |
409 | |
410 | |
411 | |
412 | |
413 | |
414 | pub name: String, |
415 | pub version: Version, |
416 | |
417 | |
418 | |
419 | |
420 | pub name: *const u8, |
421 | pub name_len: usize, |
422 | pub version: *const u8, |
423 | pub version_len: usize, |
424 | |
425 | |
426 | |
427 | handle: PluginHandle, |
428 | type_metadata: , |
429 | |
430 | |
431 | |
432 | |
433 | let meta = unsafe ; |
434 | |
435 | let name = unsafe ; |
436 | let version = unsafe ; |
437 | |
438 | let name = from_utf8 .unwrap; |
439 | let version = from_utf8 .unwrap; |
440 | |
441 | PluginMeta |
442 | name: String from, |
443 | version: parse .unwrap, |
444 | |
445 | |
446 | |
447 | |
448 | |
449 | Failure, |
450 | Internal, |
451 | Unhandled, |
452 | |
453 |