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