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