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