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