So. Much. Work.
parent: tbd commit: b05f964
1 | use ; |
2 | |
3 | use Error; |
4 | use Container; |
5 | use Version; |
6 | use ; |
7 | |
8 | use crate:: |
9 | , |
10 | |
11 | ObjectOperationPair, ObjectSettingPair, ObjectValuePair, PluginMeta, PluginState, |
12 | RuntimeHandlers, TypeMetadata, |
13 | , |
14 | FFISettingMeta, FFIValueChangeHandler, FFIValueMeta, GiteratedPluginApi, InitializationVTable, |
15 | ObjectVtable, OperationVTable, SettingVtable, ValueVTable, |
16 | ; |
17 | |
18 | |
19 | |
20 | pub meta: PluginMeta, |
21 | pub raw: , |
22 | pub initialization: , |
23 | pub state: PluginState, |
24 | |
25 | |
26 | |
27 | |
28 | let mut handle = unsafe ?; |
29 | |
30 | // Initialize the raw handle |
31 | let init_state = Self initialize_raw_handle?; |
32 | |
33 | let metadata = Self get_meta?; |
34 | |
35 | let initalization = Self initialize_registration?; |
36 | |
37 | trace! |
38 | "Loaded plugin {} (Version: {})", |
39 | metadata.name, |
40 | metadata.version |
41 | ; |
42 | |
43 | Ok |
44 | raw: new, |
45 | meta: metadata, |
46 | initialization: new, |
47 | state: init_state, |
48 | |
49 | |
50 | |
51 | /// Builds the Plugin's Substack. |
52 | /// |
53 | /// Builds the Plugin into a substack, which can then be provided to the Giterated Runtime. |
54 | |
55 | todo! |
56 | |
57 | |
58 | |
59 | let meta = unsafe ; |
60 | |
61 | let name = unsafe ; |
62 | let version = unsafe ; |
63 | |
64 | let name = from_utf8 .unwrap; |
65 | let version = from_utf8 .unwrap; |
66 | |
67 | Ok |
68 | name: String from, |
69 | version: parse .unwrap, |
70 | |
71 | |
72 | |
73 | |
74 | handle: &mut , |
75 | |
76 | debug!; |
77 | let mut builder = default; |
78 | |
79 | // SAFETY: The lifetime of the returned type is only valid as long |
80 | // as the builder that returned it lives |
81 | let func_table = unsafe ; |
82 | |
83 | let state = Box new; |
84 | |
85 | unsafe ; |
86 | let state = unsafe ; |
87 | |
88 | debug!; |
89 | Ok |
90 | |
91 | |
92 | |
93 | handle: &mut , |
94 | |
95 | debug!; |
96 | |
97 | let state = unsafe ; |
98 | |
99 | debug!; |
100 | |
101 | Ok |
102 | |
103 | |
104 | |
105 | |
106 | |
107 | |
108 | LoadingLibrary, |
109 | |
110 | |
111 | |
112 | |
113 | |
114 | |
115 | pub type_metadata: TypeMetadata, |
116 | pub operation_handlers: , |
117 | pub value_getters: , |
118 | pub setting_getters: , |
119 | |
120 | |
121 | |
122 | |
123 | Self default |
124 | |
125 | |
126 | |
127 | |
128 | |
129 | _marker: , |
130 | |
131 | |
132 | |
133 | pub unsafe |
134 | InitializationVTable |
135 | register_value_change, |
136 | register_object, |
137 | register_operation, |
138 | register_setting, |
139 | register_value, |
140 | operation_handler, |
141 | value_getter, |
142 | setting_getter, |
143 | |
144 | |
145 | |
146 | |
147 | unsafe extern "C" |
148 | state: *mut PluginInitializationState, |
149 | object_kind: &str, |
150 | value_name: &str, |
151 | vtable: FFIValueChangeHandler, |
152 | |
153 | todo! |
154 | |
155 | |
156 | unsafe extern "C" |
157 | state: *mut PluginInitializationState, |
158 | object_kind: &'static str, |
159 | vtable: ObjectVtable, |
160 | |
161 | let mut state = Box from_raw; |
162 | |
163 | state.type_metadata.register_object; |
164 | |
165 | Box into_raw; |
166 | |
167 | |
168 | unsafe extern "C" |
169 | state: *mut PluginInitializationState, |
170 | object_kind: &'static str, |
171 | operation_name: &'static str, |
172 | vtable: OperationVTable, |
173 | |
174 | let mut state = Box from_raw; |
175 | |
176 | state |
177 | .type_metadata |
178 | .register_operation; |
179 | |
180 | Box into_raw; |
181 | |
182 | |
183 | unsafe extern "C" |
184 | state: *mut PluginInitializationState, |
185 | object_kind: &'static str, |
186 | setting_name: &'static str, |
187 | vtable: SettingVtable, |
188 | |
189 | let mut state = Box from_raw; |
190 | |
191 | state |
192 | .type_metadata |
193 | .register_setting; |
194 | |
195 | Box into_raw; |
196 | |
197 | |
198 | unsafe extern "C" |
199 | state: *mut PluginInitializationState, |
200 | object_kind: &'static str, |
201 | value_name: &'static str, |
202 | vtable: ValueVTable, |
203 | |
204 | let mut state = Box from_raw; |
205 | |
206 | state |
207 | .type_metadata |
208 | .register_value; |
209 | |
210 | Box into_raw; |
211 | |
212 | |
213 | unsafe extern "C" |
214 | state: *mut PluginInitializationState, |
215 | object_kind: &'static str, |
216 | operation_name: &'static str, |
217 | handler: OperationHandlerCallback, |
218 | |
219 | let mut state = Box from_raw; |
220 | |
221 | trace!; |
222 | |
223 | state.operation_handlers.insert |
224 | , | new
225 | handler, |
226 | ; |
227 | |
228 | Box into_raw; |
229 | |
230 | |
231 | unsafe extern "C" |
232 | state: *mut PluginInitializationState, |
233 | object_kind: &'static str, |
234 | value_name: &'static str, |
235 | handler: ValueGetterCallback, |
236 | |
237 | let mut state = Box from_raw; |
238 | |
239 | trace!; |
240 | |
241 | state |
242 | .value_getters |
243 | .insert; |
244 | |
245 | Box into_raw; |
246 | |
247 | |
248 | unsafe extern "C" |
249 | state: *mut PluginInitializationState, |
250 | object_kind: &'static str, |
251 | setting_name: &'static str, |
252 | handler: SettingGetterCallback, |
253 | |
254 | let mut state = Box from_raw; |
255 | |
256 | trace!; |
257 | |
258 | state |
259 | .setting_getters |
260 | .insert; |
261 | |
262 | Box into_raw; |
263 | |
264 |