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