Fucking whatever there you go
parent: tbd commit: 57c2ca5
1 | |
2 | |
3 | |
4 | use |
5 | , HashMap, Debug, PhantomData, transmute, | type_name
6 | , Arc, | null_mut
7 | ; |
8 | |
9 | use |
10 | , Instance, GiteratedObject, | OperationError
11 | , | GiteratedOperation
12 | ; |
13 | use Version; |
14 | use ; |
15 | |
16 | use crate:: |
17 | |
18 | OperationHandlerCallback, SettingChangeCallback, SettingGetterCallback, |
19 | ValueChangeCallback, ValueGetterCallback, |
20 | , |
21 | , |
22 | , |
23 | ; |
24 | |
25 | use OperationHandlerRules; |
26 | |
27 | ; |
28 | |
29 | |
30 | type Target = S; |
31 | |
32 | |
33 | &self.0 |
34 | |
35 | |
36 | |
37 | |
38 | pub our_instance: Instance, |
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 | |
164 | pub unsafe |
165 | Box from_raw |
166 | |
167 | |
168 | pub unsafe |
169 | let ptr: *const T = transmute; |
170 | |
171 | ptr.as_ref .unwrap |
172 | |
173 | |
174 | |
175 | |
176 | |
177 | Self |
178 | |
179 | |
180 | |
181 | |
182 | plugins: , |
183 | handlers: RuntimeHandlers, |
184 | _marker: , |
185 | |
186 | |
187 | |
188 | |
189 | Self |
190 | plugins: vec!, |
191 | handlers: default, |
192 | _marker: PhantomData, |
193 | |
194 | |
195 | |
196 | |
197 | let _guard = debug_span! .entered; |
198 | |
199 | for in &plugin.initialization.operation_handlers |
200 | let _guard = |
201 | trace_span! .entered; |
202 | |
203 | if self |
204 | .handlers |
205 | .operation_handlers |
206 | .insert |
207 | .is_some |
208 | |
209 | warn! |
210 | |
211 | |
212 | trace! |
213 | |
214 | |
215 | for in &plugin.initialization.value_getters |
216 | let _guard = |
217 | trace_span! .entered; |
218 | |
219 | if self |
220 | .handlers |
221 | .value_getters |
222 | .insert |
223 | .is_some |
224 | |
225 | warn! |
226 | |
227 | |
228 | trace! |
229 | |
230 | |
231 | for in &plugin.initialization.setting_getters |
232 | let _guard = |
233 | trace_span! .entered; |
234 | |
235 | if self |
236 | .handlers |
237 | .setting_getters |
238 | .insert |
239 | .is_some |
240 | |
241 | warn! |
242 | |
243 | |
244 | trace! |
245 | |
246 | |
247 | |
248 | |
249 | &self, |
250 | object_kind: &str, |
251 | operation_name: &str, |
252 | object: &str, |
253 | operation_payload: &[u8], |
254 | |
255 | // let rules = self.handlers.handle_operation(object_kind, operation_name); |
256 | |
257 | // rules.handle(object, operation_payload) |
258 | |
259 | todo! |
260 | |
261 | |
262 | |
263 | &self, |
264 | object: O, |
265 | operation: D, |
266 | |
267 | todo! |
268 | |
269 | |
270 | |
271 | |
272 | |
273 | operation_handlers: |
274 | , |
275 | value_getters: , |
276 | setting_getters: , |
277 | value_change: , |
278 | setting_change: , |
279 | |
280 | |
281 | unsafe |
282 | unsafe |
283 | |
284 | |
285 | |
286 | &mut self, |
287 | pair: , |
288 | handler: OperationHandlerCallback, |
289 | domain: RuntimeDomain, |
290 | |
291 | trace! |
292 | "Inserting operation handler for {}::{}", |
293 | pair.object_kind, |
294 | pair.operation_name |
295 | ; |
296 | |
297 | // There can only be one handler per operation (at least for now?), send a warning if |
298 | // a newly registered handler overwrites the previous handler. |
299 | if self |
300 | .operation_handlers |
301 | .insert |
302 | .is_some |
303 | |
304 | debug!; |
305 | |
306 | |
307 | |
308 | |
309 | &mut self, |
310 | pair: , |
311 | handler: ValueGetterCallback, |
312 | domain: RuntimeDomain, |
313 | |
314 | trace! |
315 | "Inserting value getter for {}::{}", |
316 | pair.object_kind, |
317 | pair.value_name |
318 | ; |
319 | |
320 | if self.value_getters.insert .is_some |
321 | debug! |
322 | "Warning! A newly inserted value getter for {}::{} overwrites a previous handler.", |
323 | pair.object_kind, pair.value_name |
324 | ; |
325 | |
326 | |
327 | |
328 | |
329 | &mut self, |
330 | pair: , |
331 | handler: SettingGetterCallback, |
332 | domain: RuntimeDomain, |
333 | |
334 | trace! |
335 | "Inserting setting getter for {}::{}", |
336 | pair.object_kind, |
337 | pair.setting_name |
338 | ; |
339 | |
340 | if self |
341 | .setting_getters |
342 | .insert |
343 | .is_some |
344 | |
345 | debug!; |
346 | |
347 | |
348 | |
349 | |
350 | &mut self, |
351 | pair: , |
352 | handler: ValueChangeCallback, |
353 | domain: RuntimeDomain, |
354 | |
355 | trace! |
356 | "Inserting value change handler for {}::{}", |
357 | pair.object_kind, |
358 | pair.value_name |
359 | ; |
360 | |
361 | if self.value_change.insert .is_some |
362 | debug!; |
363 | panic!; |
364 | |
365 | |
366 | |
367 | |
368 | &mut self, |
369 | pair: , |
370 | handler: SettingChangeCallback, |
371 | domain: RuntimeDomain, |
372 | |
373 | trace! |
374 | "Inserting setting change handler for {}::{}", |
375 | pair.object_kind, |
376 | pair.setting_name |
377 | ; |
378 | |
379 | if self |
380 | .setting_change |
381 | .insert |
382 | .is_some |
383 | |
384 | debug!; |
385 | panic!; |
386 | |
387 | |
388 | |
389 | |
390 | |
391 | |
392 | &'o self, |
393 | object_kind: &'o str, |
394 | operation_name: &'o str, |
395 | |
396 | new |
397 | |
398 | |
399 | |
400 | |
401 | plugin: PluginHandle, |
402 | |
403 | |
404 | |
405 | |
406 | Self |
407 | plugin: plugin.clone, |
408 | |
409 | |
410 | |
411 | |
412 | self.plugin |
413 | .initialization |
414 | .type_metadata |
415 | .objects |
416 | .get |
417 | .copied |
418 | |
419 | |
420 | |
421 | &self, |
422 | object_kind: &str, |
423 | operation_name: &str, |
424 | |
425 | self.plugin |
426 | .initialization |
427 | .type_metadata |
428 | .operations |
429 | .get |
430 | .copied |
431 | |
432 | |
433 | |
434 | self.plugin |
435 | .initialization |
436 | .type_metadata |
437 | .settings |
438 | .get |
439 | .copied |
440 | |
441 | |
442 | |
443 | self.plugin |
444 | .initialization |
445 | .type_metadata |
446 | .values |
447 | .get |
448 | .copied |
449 | |
450 | |
451 | |
452 | |
453 | |
454 | pub name: String, |
455 | pub version: Version, |
456 | |
457 | |
458 | |
459 | |
460 | pub name: *const u8, |
461 | pub name_len: usize, |
462 | pub version: *const u8, |
463 | pub version_len: usize, |
464 | |
465 | |
466 | |
467 | handle: PluginHandle, |
468 | type_metadata: , |
469 | |
470 | |
471 | |
472 | |
473 | let meta = unsafe ; |
474 | |
475 | let name = unsafe ; |
476 | let version = unsafe ; |
477 | |
478 | let name = from_utf8 .unwrap; |
479 | let version = from_utf8 .unwrap; |
480 | |
481 | PluginMeta |
482 | name: String from, |
483 | version: parse .unwrap, |
484 | |
485 | |
486 | |
487 | |
488 | |
489 | Failure, |
490 | Internal, |
491 | Unhandled, |
492 | |
493 |