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