More progress :)
parent: tbd commit: 92c3f32
1 | use Future; |
2 | |
3 | use |
4 | , | OperationError
5 | , | GiteratedObject
6 | , |
7 | ; |
8 | |
9 | use crate:: |
10 | , |
11 | , | PluginState
12 | AnyObject, NewAnySetting, |
13 | ; |
14 | |
15 | use ; |
16 | |
17 | |
18 | |
19 | pub callback_ptr: CallbackPtr, |
20 | pub func: unsafe extern "C" fn |
21 | CallbackPtr, |
22 | runtime_state: &RuntimeState, |
23 | &PluginState, |
24 | object: AnyObject, |
25 | , |
26 | |
27 | |
28 | |
29 | |
30 | Self |
31 | func: get_setting, |
32 | callback_ptr: callback.callback_ptr, |
33 | |
34 | |
35 | |
36 | |
37 | |
38 | unsafe extern "C" |
39 | callback_ptr: CallbackPtr, |
40 | runtime_state: &RuntimeState, |
41 | state: &PluginState, |
42 | object: AnyObject, |
43 | ; |
44 | |
45 | |
46 | unsafe |
47 | |
48 | |
49 | |
50 | |
51 | |
52 | Fut: + Send + Sync + 'static, |
53 | S: Clone + Send + Sync + 'static, |
54 | O: GiteratedObject + Send + Sync + 'static, |
55 | OS: Setting + Send + Sync + 'static, |
56 | F: Fn(S, O) -> Fut + Send + Sync + 'static, |
57 | |
58 | unsafe extern "C" |
59 | callback: CallbackPtr, |
60 | runtime_state: &RuntimeState, |
61 | state: &PluginState, |
62 | mut object: AnyObject, |
63 | |
64 | let _guard = trace_span! |
65 | "get_setting handler", |
66 | object = object_name, |
67 | setting = OS name |
68 | |
69 | .entered; |
70 | let state = unsafe ; |
71 | |
72 | let object = unsafe ; |
73 | |
74 | // Cast the callback ptr to ourselves |
75 | let callback: *const F = transmute; |
76 | let callback = callback.as_ref .unwrap; |
77 | |
78 | let state = state.clone; |
79 | runtime_state.spawn_future |
80 | let result = callback .await; |
81 | |
82 | match result |
83 | Ok => unsafe , |
84 | Err => match err |
85 | => todo!, | Operation
86 | => todo!, | Internal
87 | => todo!, | Unhandled
88 | , |
89 | |
90 | |
91 | |
92 | |
93 | |
94 | |
95 | unsafe extern "C" |
96 | callback_ptr: CallbackPtr, |
97 | state: &PluginState, |
98 | object: AnyObject, |
99 | setting: AnySetting, |
100 | ; |
101 | |
102 | |
103 | unsafe |
104 | |
105 | |
106 | |
107 | |
108 | |
109 | Fut: , |
110 | S: Clone, |
111 | O: GiteratedObject, |
112 | OS: Setting, |
113 | F: Fn(S, O, OS) -> Fut, |
114 | |
115 | unsafe extern "C" |
116 | callback: CallbackPtr, |
117 | state: &PluginState, |
118 | mut object: AnyObject, |
119 | _setting: AnySetting, |
120 | |
121 | let _guard = trace_span! |
122 | "get_setting handler", |
123 | object = object_name, |
124 | setting = OS name |
125 | |
126 | .entered; |
127 | let _state = unsafe ; |
128 | |
129 | let _object = unsafe ; |
130 | |
131 | // Cast the callback ptr to ourselves |
132 | let callback: *const F = transmute; |
133 | let _callback = callback.as_ref .unwrap; |
134 | |
135 | // let result = callback(state.clone(), *object); |
136 | |
137 | // match result { |
138 | // Ok(setting) => Ok(NewAnySetting::new(setting)), |
139 | // Err(_) => todo!(), |
140 | // } |
141 | todo! |
142 | |
143 | |
144 | |
145 | |
146 | func: unsafe extern "C" fn |
147 | &PluginState, |
148 | object: AnyObject, |
149 | setting_name: &str, |
150 | new_setting: NewAnySetting, |
151 | , |
152 | |
153 | |
154 | |
155 | unsafe extern "C" |
156 | state: &PluginState, |
157 | object: AnyObject, |
158 | setting_name: &str, |
159 | new_setting: NewAnySetting, |
160 | ; |
161 | |
162 | |
163 | |
164 | unsafe extern "C" |
165 | _state: &PluginState, |
166 | _object: AnyObject, |
167 | _setting_name: &str, |
168 | _new_setting: NewAnySetting, |
169 | |
170 | todo! |
171 | |
172 | |
173 | |
174 | |
175 | |
176 | Self |
177 | func: setting_changed, |
178 | |
179 | |
180 | |
181 |