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