Line | Branch | Exec | Source |
---|---|---|---|
1 | /* GATE PROJECT LICENSE: | ||
2 | +----------------------------------------------------------------------------+ | ||
3 | | Copyright(c) 2018-2025, Stefan Meislinger <sm@opengate.at> | | ||
4 | | All rights reserved. | | ||
5 | | | | ||
6 | | Redistribution and use in source and binary forms, with or without | | ||
7 | | modification, are permitted provided that the following conditions are met:| | ||
8 | | | | ||
9 | | 1. Redistributions of source code must retain the above copyright notice, | | ||
10 | | this list of conditions and the following disclaimer. | | ||
11 | | 2. Redistributions in binary form must reproduce the above copyright | | ||
12 | | notice, this list of conditions and the following disclaimer in the | | ||
13 | | documentation and/or other materials provided with the distribution. | | ||
14 | | | | ||
15 | | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"| | ||
16 | | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | | ||
17 | | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | | ||
18 | | ARE DISCLAIMED.IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE | | ||
19 | | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | | ||
20 | | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | | ||
21 | | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | | ||
22 | | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | | ||
23 | | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | | ||
24 | | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF | | ||
25 | | THE POSSIBILITY OF SUCH DAMAGE. | | ||
26 | +----------------------------------------------------------------------------+ | ||
27 | */ | ||
28 | |||
29 | #include "gate/values.h" | ||
30 | #include "gate/memalloc.h" | ||
31 | #include "gate/results.h" | ||
32 | #include "gate/mathematics.h" | ||
33 | #include "gate/serializers.h" | ||
34 | |||
35 | |||
36 | 130 | gate_value_t* gate_value_create(gate_type_id_t value_type, void const* src, gate_value_t* dst) | |
37 | { | ||
38 | 130 | gate_value_t* ret = NULL; | |
39 | 130 | gate_size_t len = gate_type_length(value_type); | |
40 | 130 | gate_array_t const* const ptr_array = (gate_array_t const*)src; | |
41 | 130 | gate_string_t const* const ptr_string = (gate_string_t const*)src; | |
42 | 130 | gate_blob_t const* const ptr_blob = (gate_blob_t const*)src; | |
43 | |||
44 |
3/4✓ Branch 0 taken 10 times.
✓ Branch 1 taken 120 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 120 times.
|
130 | if ((len != 0) && (dst != NULL)) |
45 | { | ||
46 | /* plain copy of bits */ | ||
47 |
1/2✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
|
120 | if (len > 0) |
48 | { | ||
49 | 120 | gate_mem_copy(&dst->content.ptr_value, src, len); | |
50 | } | ||
51 | 120 | dst->value_type = value_type; | |
52 | 120 | ret = dst; | |
53 |
3/5✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 113 times.
|
120 | switch (value_type) |
54 | { | ||
55 | ✗ | case GATE_TYPE_ARRAY: | |
56 | { | ||
57 | ✗ | if (gate_array_duplicate(&dst->content.array_value, ptr_array) == NULL) | |
58 | { | ||
59 | ✗ | ret = NULL; | |
60 | } | ||
61 | ✗ | break; | |
62 | } | ||
63 | 3 | case GATE_TYPE_BLOB: | |
64 | { | ||
65 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
|
3 | if (gate_blob_create_duplicate(&dst->content.blob_value, ptr_blob) == NULL) |
66 | { | ||
67 | ✗ | ret = NULL; | |
68 | } | ||
69 | 3 | break; | |
70 | } | ||
71 | 4 | case GATE_TYPE_STRING: | |
72 | { | ||
73 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
|
4 | if (gate_string_clone(&dst->content.string_value, ptr_string) == NULL) |
74 | { | ||
75 | ✗ | ret = NULL; | |
76 | } | ||
77 | 4 | break; | |
78 | } | ||
79 | ✗ | case GATE_TYPE_OBJECT: | |
80 | { | ||
81 | ✗ | if (dst->content.object_value != NULL) | |
82 | { | ||
83 | ✗ | gate_object_retain(dst->content.object_value); | |
84 | } | ||
85 | ✗ | break; | |
86 | } | ||
87 | } | ||
88 | 10 | } | |
89 | 130 | return ret; | |
90 | } | ||
91 | 23 | gate_value_t* gate_value_clone(gate_value_t const* src, gate_value_t* dst) | |
92 | { | ||
93 | 23 | gate_value_t* ret = NULL; | |
94 |
2/4✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
|
23 | if ((src != NULL) && (dst != NULL)) |
95 | { | ||
96 | 23 | ret = gate_value_create(src->value_type, &src->content.address_value, dst); | |
97 | } | ||
98 | 23 | return ret; | |
99 | } | ||
100 | 133 | void gate_value_release(gate_value_t* dst) | |
101 | { | ||
102 |
1/2✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
|
133 | if (dst != NULL) |
103 | { | ||
104 |
3/5✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 126 times.
|
133 | switch (dst->value_type) |
105 | { | ||
106 | ✗ | case GATE_TYPE_ARRAY: | |
107 | { | ||
108 | ✗ | gate_array_release(&dst->content.array_value); | |
109 | ✗ | break; | |
110 | } | ||
111 | 4 | case GATE_TYPE_STRING: | |
112 | { | ||
113 | 4 | gate_string_release(&dst->content.string_value); | |
114 | 4 | break; | |
115 | } | ||
116 | 3 | case GATE_TYPE_BLOB: | |
117 | { | ||
118 | 3 | gate_blob_release(&dst->content.blob_value); | |
119 | 3 | break; | |
120 | } | ||
121 | ✗ | case GATE_TYPE_OBJECT: | |
122 | { | ||
123 | ✗ | if (dst->content.object_value != NULL) | |
124 | { | ||
125 | ✗ | gate_object_release(dst->content.object_value); | |
126 | } | ||
127 | ✗ | break; | |
128 | } | ||
129 | 126 | default: | |
130 | { | ||
131 | 126 | break; | |
132 | } | ||
133 | } | ||
134 | 133 | gate_mem_clear(dst, sizeof(gate_value_t)); | |
135 | 133 | dst->value_type = GATE_TYPE_EMPTY; | |
136 | } | ||
137 | 133 | } | |
138 | |||
139 | 24 | gate_result_t gate_value_get(gate_value_t const* src, void* ptrdst, gate_size_t dstlen) | |
140 | { | ||
141 | 24 | gate_result_t ret = GATE_RESULT_FAILED; | |
142 |
3/6✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 24 times.
|
24 | if ((src == NULL) || (ptrdst == NULL) || (dstlen == 0)) |
143 | { | ||
144 | ✗ | ret = GATE_RESULT_INVALIDARG; | |
145 | } | ||
146 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
|
24 | else if (gate_type_length(src->value_type) != dstlen) |
147 | { | ||
148 | ✗ | ret = GATE_RESULT_INCORRECTTYPE; | |
149 | } | ||
150 | else | ||
151 | { | ||
152 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
|
24 | if (gate_mem_copy(ptrdst, &src->content.ptr_value, dstlen) == NULL) |
153 | { | ||
154 | ✗ | ret = GATE_RESULT_FAILED; | |
155 | } | ||
156 | else | ||
157 | { | ||
158 | 24 | ret = GATE_RESULT_OK; | |
159 | } | ||
160 | } | ||
161 | 24 | return ret; | |
162 | } | ||
163 | |||
164 | 46 | void const* gate_value_get_ptr(gate_value_t const* src) | |
165 | { | ||
166 |
1/2✓ Branch 0 taken 46 times.
✗ Branch 1 not taken.
|
46 | return src ? &src->content.ptr_value : NULL; |
167 | } | ||
168 | |||
169 | 69 | gate_type_id_t gate_value_type(gate_value_t const* src) | |
170 | { | ||
171 |
1/2✓ Branch 0 taken 69 times.
✗ Branch 1 not taken.
|
69 | return src ? src->value_type : GATE_TYPE_EMPTY; |
172 | } | ||
173 | |||
174 | |||
175 | |||
176 | |||
177 | |||
178 | 239 | gate_result_t gate_value_load_int64(gate_type_id_t value_type, void const* src, gate_int64_t* dst) | |
179 | { | ||
180 | 239 | gate_datetime_t dt = GATE_DATETIME_INIT_EMPTY; | |
181 | 239 | gate_time_t tm = GATE_TIME_INIT; | |
182 | gate_result_t res; | ||
183 | |||
184 |
23/24✓ Branch 0 taken 12 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 12 times.
✓ Branch 4 taken 12 times.
✓ Branch 5 taken 12 times.
✓ Branch 6 taken 12 times.
✓ Branch 7 taken 12 times.
✓ Branch 8 taken 12 times.
✓ Branch 9 taken 9 times.
✓ Branch 10 taken 9 times.
✓ Branch 11 taken 10 times.
✓ Branch 12 taken 9 times.
✓ Branch 13 taken 10 times.
✓ Branch 14 taken 9 times.
✓ Branch 15 taken 9 times.
✓ Branch 16 taken 13 times.
✓ Branch 17 taken 9 times.
✓ Branch 18 taken 9 times.
✓ Branch 19 taken 9 times.
✓ Branch 20 taken 9 times.
✓ Branch 21 taken 9 times.
✓ Branch 22 taken 10 times.
✗ Branch 23 not taken.
|
239 | switch (value_type) |
185 | { | ||
186 | 12 | case GATE_TYPE_BOOL: *dst = (gate_int64_t) * ((gate_bool_t const*)src) ? 1 : 0; return GATE_RESULT_OK; | |
187 | 12 | case GATE_TYPE_I8: *dst = (gate_int64_t) * ((gate_int8_t const*)src); return GATE_RESULT_OK; | |
188 | 10 | case GATE_TYPE_UI8: *dst = (gate_int64_t) * ((gate_uint8_t const*)src); return GATE_RESULT_OK; | |
189 | 12 | case GATE_TYPE_I16: *dst = (gate_int64_t) * ((gate_int16_t const*)src); return GATE_RESULT_OK; | |
190 | 12 | case GATE_TYPE_UI16: *dst = (gate_int64_t) * ((gate_uint16_t const*)src); return GATE_RESULT_OK; | |
191 | 12 | case GATE_TYPE_I32: *dst = (gate_int64_t) * ((gate_int32_t const*)src); return GATE_RESULT_OK; | |
192 | 12 | case GATE_TYPE_UI32: *dst = (gate_int64_t) * ((gate_uint32_t const*)src); return GATE_RESULT_OK; | |
193 | 12 | case GATE_TYPE_I64: *dst = (gate_int64_t) * ((gate_int64_t const*)src); return GATE_RESULT_OK; | |
194 | 12 | case GATE_TYPE_UI64: *dst = (gate_int64_t) * ((gate_uint64_t const*)src); return GATE_RESULT_OK; | |
195 | 9 | case GATE_TYPE_R32: *dst = (gate_int64_t) * ((gate_real32_t const*)src); return GATE_RESULT_OK; | |
196 | 9 | case GATE_TYPE_R64: *dst = (gate_int64_t) * ((gate_real64_t const*)src); return GATE_RESULT_OK; | |
197 | 10 | case GATE_TYPE_ADDRESS: *dst = (gate_uintptr_t) * ((gate_uint64_t const*)src); return GATE_RESULT_OK; | |
198 | |||
199 | 9 | case GATE_TYPE_DATAPTR: *dst = (gate_int64_t)(gate_intptr_t) * ((void* const*)src); return GATE_RESULT_OK; | |
200 | 10 | case GATE_TYPE_FUNCPTR: *dst = (gate_intptr_t)(void*)(gate_funcptr_t) * (gate_funcptr_t const*)src; return GATE_RESULT_OK; | |
201 | 9 | case GATE_TYPE_CSTR: | |
202 | { | ||
203 | 9 | char const* const text = *((char const* const*)src); | |
204 | 9 | return gate_str_parse_int64(text, gate_str_length(text), dst) > 0 | |
205 | ? GATE_RESULT_OK | ||
206 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | : GATE_RESULT_FAILED; |
207 | } | ||
208 | 9 | case GATE_TYPE_WSTR: | |
209 | { | ||
210 | 9 | wchar_t const* const text = *((wchar_t const* const*)src); | |
211 | 9 | char buffer[64] = GATE_INIT_EMPTY; | |
212 | 9 | gate_size_t used = gate_str_print_wtext(buffer, sizeof(buffer), text, gate_wstr_length(text)); | |
213 | 9 | return gate_str_parse_int64(buffer, used, dst) > 0 | |
214 | ? GATE_RESULT_OK | ||
215 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | : GATE_RESULT_FAILED; |
216 | } | ||
217 | 13 | case GATE_TYPE_STRING: | |
218 | { | ||
219 | 13 | return gate_str_parse_int64(((gate_string_t const*)src)->str, ((gate_string_t const*)src)->length, dst) > 0 | |
220 | ? GATE_RESULT_OK | ||
221 |
1/2✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
|
13 | : GATE_RESULT_FAILED; |
222 | } | ||
223 | 9 | case GATE_TYPE_DATE: | |
224 | { | ||
225 | 9 | dt.date = *((gate_date_t const*)src); | |
226 | 9 | res = gate_date_to_time(&dt, &tm); | |
227 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | if (GATE_SUCCEEDED(res)) |
228 | { | ||
229 | 9 | res = gate_time_to_unix(tm.timestamp, dst); | |
230 | } | ||
231 | 9 | return res; | |
232 | } | ||
233 | 9 | case GATE_TYPE_DAYTIME: | |
234 | { | ||
235 | 9 | dt.date.year = 1601; | |
236 | 9 | dt.date.month = 1; | |
237 | 9 | dt.date.day = 1; | |
238 | 9 | dt.time = *((gate_daytime_t const*)src); | |
239 | 9 | res = gate_date_to_time(&dt, &tm); | |
240 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | if (GATE_SUCCEEDED(res)) |
241 | { | ||
242 | 9 | *dst = (gate_int64_t)tm.timestamp; | |
243 | } | ||
244 | 9 | return res; | |
245 | } | ||
246 | 9 | case GATE_TYPE_DATETIME: | |
247 | { | ||
248 | 9 | dt = *((gate_datetime_t const*)src); | |
249 | 9 | res = gate_date_to_time(&dt, &tm); | |
250 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | if (GATE_SUCCEEDED(res)) |
251 | { | ||
252 | 9 | res = gate_time_to_unix(tm.timestamp, dst); | |
253 | } | ||
254 | 9 | return res; | |
255 | } | ||
256 | 9 | case GATE_TYPE_TIME: | |
257 | { | ||
258 | 9 | tm = *((gate_time_t const*)src); | |
259 | 9 | res = gate_time_to_unix(tm.timestamp, dst); | |
260 | 9 | return res; | |
261 | } | ||
262 | 9 | case GATE_TYPE_GUID: | |
263 | { | ||
264 | 9 | gate_guid_t const* g = (gate_guid_t const*)src; | |
265 | 18 | gate_uint64_t a = (((gate_uint64_t)g->item1) << 32) | |
266 | 9 | | (((gate_uint64_t)g->item2) << 16) | |
267 | 9 | | (((gate_uint64_t)g->item3)); | |
268 | 18 | gate_uint64_t b = (((gate_uint64_t)g->item4[0]) << 56) | |
269 | 9 | | (((gate_uint64_t)g->item4[1]) << 48) | |
270 | 9 | | (((gate_uint64_t)g->item4[2]) << 40) | |
271 | 9 | | (((gate_uint64_t)g->item4[3]) << 32) | |
272 | 9 | | (((gate_uint64_t)g->item4[4]) << 24) | |
273 | 9 | | (((gate_uint64_t)g->item4[5]) << 16) | |
274 | 9 | | (((gate_uint64_t)g->item4[6]) << 8) | |
275 | 9 | | (((gate_uint64_t)g->item4[7])); | |
276 | 9 | *dst = (gate_int64_t)(a | b); | |
277 | 9 | return GATE_RESULT_OK; | |
278 | } | ||
279 | 10 | case GATE_TYPE_BLOB: | |
280 | { | ||
281 | 10 | gate_blob_t const* b = (gate_blob_t const*)src; | |
282 | 10 | *dst = (gate_int64_t)gate_blob_length(b); | |
283 | 10 | return GATE_RESULT_OK; | |
284 | } | ||
285 | } | ||
286 | ✗ | return GATE_RESULT_NOTSUPPORTED; | |
287 | } | ||
288 | 7 | gate_result_t gate_value_load_real64(gate_type_id_t value_type, void const* src, gate_real64_t* dst) | |
289 | { | ||
290 | gate_int64_t tmp; | ||
291 | gate_result_t res; | ||
292 |
3/5✓ Branch 0 taken 3 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
|
7 | switch (value_type) |
293 | { | ||
294 | 3 | case GATE_TYPE_R32: *dst = (gate_real64_t) * ((gate_real32_t const*)src); return GATE_RESULT_OK; | |
295 | 3 | case GATE_TYPE_R64: *dst = (gate_real64_t) * ((gate_real64_t const*)src); return GATE_RESULT_OK; | |
296 | ✗ | case GATE_TYPE_CSTR: | |
297 | { | ||
298 | ✗ | return gate_str_parse_real(*((char const* const*)src), gate_str_length(*((char const* const*)src)), dst) > 0 | |
299 | ? GATE_RESULT_OK | ||
300 | ✗ | : GATE_RESULT_FAILED; | |
301 | } | ||
302 | 1 | case GATE_TYPE_STRING: | |
303 | { | ||
304 | 1 | return gate_str_parse_real(((gate_string_t const*)src)->str, ((gate_string_t const*)src)->length, dst) > 0 | |
305 | ? GATE_RESULT_OK | ||
306 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | : GATE_RESULT_FAILED; |
307 | } | ||
308 | ✗ | default: | |
309 | { | ||
310 | ✗ | res = gate_value_load_int64(value_type, src, &tmp); | |
311 | ✗ | if (GATE_SUCCEEDED(res)) | |
312 | { | ||
313 | ✗ | *dst = (gate_real64_t)tmp; | |
314 | } | ||
315 | ✗ | return res; | |
316 | } | ||
317 | } | ||
318 | } | ||
319 | |||
320 | |||
321 | |||
322 | 25 | gate_result_t gate_value_load_bool(gate_type_id_t value_type, void const* src, gate_bool_t* dst) | |
323 | { | ||
324 | gate_result_t ret; | ||
325 | gate_int64_t tmp; | ||
326 | 25 | ret = gate_value_load_int64(value_type, src, &tmp); | |
327 |
1/2✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
|
25 | if (GATE_SUCCEEDED(ret)) *dst = (tmp != 0); |
328 | 25 | return ret; | |
329 | } | ||
330 | 24 | gate_result_t gate_value_load_int8(gate_type_id_t value_type, void const* src, gate_int8_t* dst) | |
331 | { | ||
332 | gate_result_t ret; | ||
333 | gate_int64_t tmp; | ||
334 | 24 | ret = gate_value_load_int64(value_type, src, &tmp); | |
335 |
1/2✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
|
24 | if (GATE_SUCCEEDED(ret)) *dst = (gate_int8_t)tmp; |
336 | 24 | return ret; | |
337 | } | ||
338 | 24 | gate_result_t gate_value_load_int16(gate_type_id_t value_type, void const* src, gate_int16_t* dst) | |
339 | { | ||
340 | gate_result_t ret; | ||
341 | gate_int64_t tmp; | ||
342 | 24 | ret = gate_value_load_int64(value_type, src, &tmp); | |
343 |
1/2✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
|
24 | if (GATE_SUCCEEDED(ret)) *dst = (gate_int16_t)tmp; |
344 | 24 | return ret; | |
345 | } | ||
346 | 26 | gate_result_t gate_value_load_int32(gate_type_id_t value_type, void const* src, gate_int32_t* dst) | |
347 | { | ||
348 | gate_result_t ret; | ||
349 | gate_int64_t tmp; | ||
350 | 26 | ret = gate_value_load_int64(value_type, src, &tmp); | |
351 |
1/2✓ Branch 0 taken 26 times.
✗ Branch 1 not taken.
|
26 | if (GATE_SUCCEEDED(ret)) *dst = (gate_int32_t)tmp; |
352 | 26 | return ret; | |
353 | } | ||
354 | 23 | gate_result_t gate_value_load_uint8(gate_type_id_t value_type, void const* src, gate_uint8_t* dst) | |
355 | { | ||
356 | gate_result_t ret; | ||
357 | gate_int64_t tmp; | ||
358 | 23 | ret = gate_value_load_int64(value_type, src, &tmp); | |
359 |
1/2✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
|
23 | if (GATE_SUCCEEDED(ret)) *dst = (gate_uint8_t)tmp; |
360 | 23 | return ret; | |
361 | } | ||
362 | 24 | gate_result_t gate_value_load_uint16(gate_type_id_t value_type, void const* src, gate_uint16_t* dst) | |
363 | { | ||
364 | gate_result_t ret; | ||
365 | gate_int64_t tmp; | ||
366 | 24 | ret = gate_value_load_int64(value_type, src, &tmp); | |
367 |
1/2✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
|
24 | if (GATE_SUCCEEDED(ret)) *dst = (gate_uint16_t)tmp; |
368 | 24 | return ret; | |
369 | } | ||
370 | 24 | gate_result_t gate_value_load_uint32(gate_type_id_t value_type, void const* src, gate_uint32_t* dst) | |
371 | { | ||
372 | gate_result_t ret; | ||
373 | gate_int64_t tmp; | ||
374 | 24 | ret = gate_value_load_int64(value_type, src, &tmp); | |
375 |
1/2✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
|
24 | if (GATE_SUCCEEDED(ret)) *dst = (gate_uint32_t)tmp; |
376 | 24 | return ret; | |
377 | } | ||
378 | 24 | gate_result_t gate_value_load_uint64(gate_type_id_t value_type, void const* src, gate_uint64_t* dst) | |
379 | { | ||
380 | gate_result_t ret; | ||
381 | gate_int64_t tmp; | ||
382 | 24 | ret = gate_value_load_int64(value_type, src, &tmp); | |
383 |
1/2✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
|
24 | if (GATE_SUCCEEDED(ret)) *dst = (gate_uint64_t)tmp; |
384 | 24 | return ret; | |
385 | } | ||
386 | |||
387 | |||
388 | 1 | gate_result_t gate_value_load_real32(gate_type_id_t value_type, void const* src, gate_real32_t* dst) | |
389 | { | ||
390 | gate_result_t ret; | ||
391 | gate_real64_t tmp; | ||
392 | 1 | ret = gate_value_load_real64(value_type, src, &tmp); | |
393 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | if (GATE_SUCCEEDED(ret)) *dst = (gate_real32_t)tmp; |
394 | 1 | return ret; | |
395 | } | ||
396 | |||
397 | 33 | gate_result_t gate_value_load_string(gate_type_id_t value_type, void const* src, gate_string_t* dst) | |
398 | { | ||
399 | gate_result_t ret; | ||
400 | gate_int64_t tmpint; | ||
401 | gate_real64_t tmpreal; | ||
402 | gate_strbuilder_t builder; | ||
403 | |||
404 |
10/10✓ Branch 0 taken 4 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 1 times.
✓ Branch 8 taken 1 times.
✓ Branch 9 taken 20 times.
|
33 | switch (value_type) |
405 | { | ||
406 | 4 | case GATE_TYPE_R32: | |
407 | case GATE_TYPE_R64: | ||
408 | { | ||
409 | 4 | ret = gate_value_load_real64(value_type, src, &tmpreal); | |
410 |
1/2✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
|
4 | if (GATE_SUCCEEDED(ret)) |
411 | { | ||
412 | 4 | gate_strbuilder_create(&builder, 32); | |
413 | 4 | gate_strbuilder_append_real(&builder, tmpreal, 0, 6, 0); | |
414 | 4 | gate_strbuilder_to_string(&builder, dst); | |
415 | 4 | gate_strbuilder_release(&builder); | |
416 | } | ||
417 | 4 | return ret; | |
418 | } | ||
419 | 2 | case GATE_TYPE_DATAPTR: | |
420 | case GATE_TYPE_CSTR: | ||
421 | { | ||
422 | 2 | return (NULL == gate_string_create(dst, *((char const* const*)src), gate_str_length(*((char const* const*)src)))) | |
423 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
2 | ? GATE_RESULT_FAILED : GATE_RESULT_OK; |
424 | } | ||
425 | 1 | case GATE_TYPE_WSTR: | |
426 | { | ||
427 | gate_string_t* r; | ||
428 | if (sizeof(wchar_t) == sizeof(gate_char16_t)) | ||
429 | { | ||
430 | gate_char16_t const* const text = *((gate_char16_t const* const*)src); | ||
431 | r = gate_string_create_utf16(dst, text, gate_str16_length(text)); | ||
432 | } | ||
433 | else | ||
434 | { | ||
435 | 1 | gate_char32_t const* const text = *((gate_char32_t const* const*)src); | |
436 | 1 | r = gate_string_create_utf32(dst, text, gate_str32_length(text)); | |
437 | } | ||
438 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | return (r == NULL) ? GATE_RESULT_FAILED : GATE_RESULT_OK; |
439 | } | ||
440 | 1 | case GATE_TYPE_STRING: | |
441 | { | ||
442 | 1 | return (NULL == gate_string_duplicate(dst, (gate_string_t const*)src)) | |
443 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | ? GATE_RESULT_FAILED : GATE_RESULT_OK; |
444 | } | ||
445 | 1 | case GATE_TYPE_GUID: | |
446 | { | ||
447 | 1 | gate_guid_t const* g = (gate_guid_t const*)src; | |
448 | char buffer[40]; | ||
449 | 1 | gate_result_t result = gate_guid_to_string(g, buffer); | |
450 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | GATE_RETURN_IF_FAILED(result); |
451 | 1 | return (NULL == gate_string_create(dst, buffer, gate_str_length_max(buffer, sizeof(buffer)))) | |
452 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | ? GATE_RESULT_FAILED : GATE_RESULT_OK; |
453 | } | ||
454 | 1 | case GATE_TYPE_DATE: | |
455 | { | ||
456 | char buffer[128]; | ||
457 | 1 | gate_size_t len = sizeof(buffer); | |
458 | gate_datetime_t dt; | ||
459 | gate_result_t result; | ||
460 | 1 | gate_mem_copy(&dt.date, src, sizeof(gate_date_t)); | |
461 | 1 | gate_mem_clear(&dt.time, sizeof(gate_daytime_t)); | |
462 | 1 | result = gate_date_to_string(&dt, 0, "{YYYY}-{MM}-{DD}", buffer, &len); | |
463 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | GATE_RETURN_IF_FAILED(result); |
464 | 1 | return (NULL == gate_string_create(dst, buffer, len)) | |
465 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | ? GATE_RESULT_FAILED : GATE_RESULT_OK; |
466 | } | ||
467 | 1 | case GATE_TYPE_DAYTIME: | |
468 | { | ||
469 | char buffer[128]; | ||
470 | 1 | gate_size_t len = sizeof(buffer); | |
471 | gate_datetime_t dt; | ||
472 | gate_result_t result; | ||
473 | 1 | gate_mem_clear(&dt.date, sizeof(gate_date_t)); | |
474 | 1 | gate_mem_copy(&dt.time, src, sizeof(gate_daytime_t)); | |
475 | 1 | result = gate_date_to_string(&dt, 0, "{hh}:{mm}:{ss}.{SSS}", buffer, &len); | |
476 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | GATE_RETURN_IF_FAILED(result); |
477 | 1 | return (NULL == gate_string_create(dst, buffer, len)) | |
478 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | ? GATE_RESULT_FAILED : GATE_RESULT_OK; |
479 | } | ||
480 | 1 | case GATE_TYPE_DATETIME: | |
481 | { | ||
482 | 1 | gate_datetime_t const* dt = (gate_datetime_t const*)src; | |
483 | char buffer[128]; | ||
484 | 1 | gate_size_t len = sizeof(buffer); | |
485 | 1 | gate_result_t result = gate_date_to_string(dt, 0, NULL, buffer, &len); | |
486 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | GATE_RETURN_IF_FAILED(result); |
487 | 1 | return (NULL == gate_string_create(dst, buffer, len)) | |
488 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | ? GATE_RESULT_FAILED : GATE_RESULT_OK; |
489 | } | ||
490 | 1 | case GATE_TYPE_TIME: | |
491 | { | ||
492 | 1 | gate_time_t const* t = (gate_time_t const*)src; | |
493 | char buffer[128]; | ||
494 | 1 | gate_size_t len = sizeof(buffer); | |
495 | 1 | gate_result_t result = gate_time_to_string(t, NULL, buffer, &len); | |
496 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | GATE_RETURN_IF_FAILED(result); |
497 | 1 | return (NULL == gate_string_create(dst, buffer, len)) | |
498 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | ? GATE_RESULT_FAILED : GATE_RESULT_OK; |
499 | } | ||
500 | 20 | default: | |
501 | { | ||
502 | 20 | ret = gate_value_load_int64(value_type, src, &tmpint); | |
503 |
1/2✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
|
20 | if (GATE_SUCCEEDED(ret)) |
504 | { | ||
505 | 20 | gate_strbuilder_create(&builder, 16); | |
506 | 20 | gate_strbuilder_append_int64(&builder, tmpint); | |
507 | 20 | gate_strbuilder_to_string(&builder, dst); | |
508 | 20 | gate_strbuilder_release(&builder); | |
509 | } | ||
510 | 20 | return ret; | |
511 | } | ||
512 | } | ||
513 | } | ||
514 | |||
515 | 23 | gate_result_t gate_value_load_blob(gate_type_id_t value_type, void const* src, gate_blob_t* dst) | |
516 | { | ||
517 | static gate_blob_t const true_blob = GATE_BLOB_INIT_STATIC("true"); | ||
518 | 23 | gate_blob_t* ptr_loaded = NULL; | |
519 | |||
520 |
2/4✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 23 times.
|
23 | if (!src || !dst) |
521 | { | ||
522 | ✗ | return GATE_RESULT_NULLPOINTER; | |
523 | } | ||
524 | |||
525 |
23/24✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 1 times.
✓ Branch 8 taken 1 times.
✓ Branch 9 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 11 taken 1 times.
✓ Branch 12 taken 1 times.
✓ Branch 13 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 15 taken 1 times.
✓ Branch 16 taken 1 times.
✓ Branch 17 taken 1 times.
✓ Branch 18 taken 1 times.
✓ Branch 19 taken 1 times.
✓ Branch 20 taken 1 times.
✓ Branch 21 taken 1 times.
✓ Branch 22 taken 1 times.
✗ Branch 23 not taken.
|
23 | switch (value_type) |
526 | { | ||
527 | 1 | case GATE_TYPE_BOOL: ptr_loaded = gate_blob_create_duplicate(dst, &true_blob); break; | |
528 | 1 | case GATE_TYPE_I8: ptr_loaded = gate_blob_create(dst, src, sizeof(gate_int8_t)); break; | |
529 | 1 | case GATE_TYPE_I16: ptr_loaded = gate_blob_create(dst, src, sizeof(gate_int16_t)); break; | |
530 | 1 | case GATE_TYPE_I32: ptr_loaded = gate_blob_create(dst, src, sizeof(gate_int32_t)); break; | |
531 | 1 | case GATE_TYPE_I64: ptr_loaded = gate_blob_create(dst, src, sizeof(gate_int64_t)); break; | |
532 | 1 | case GATE_TYPE_UI8: ptr_loaded = gate_blob_create(dst, src, sizeof(gate_uint8_t)); break; | |
533 | 1 | case GATE_TYPE_UI16: ptr_loaded = gate_blob_create(dst, src, sizeof(gate_uint16_t)); break; | |
534 | 1 | case GATE_TYPE_UI32: ptr_loaded = gate_blob_create(dst, src, sizeof(gate_uint32_t)); break; | |
535 | 1 | case GATE_TYPE_UI64: ptr_loaded = gate_blob_create(dst, src, sizeof(gate_uint64_t)); break; | |
536 | 1 | case GATE_TYPE_R32: ptr_loaded = gate_blob_create(dst, src, sizeof(gate_real32_t)); break; | |
537 | 1 | case GATE_TYPE_R64: ptr_loaded = gate_blob_create(dst, src, sizeof(gate_real64_t)); break; | |
538 | 1 | case GATE_TYPE_ADDRESS: ptr_loaded = gate_blob_create(dst, src, sizeof(gate_uintptr_t)); break; | |
539 | 1 | case GATE_TYPE_DATAPTR: ptr_loaded = gate_blob_create(dst, src, sizeof(gate_dataptr_t)); break; | |
540 | 1 | case GATE_TYPE_FUNCPTR: ptr_loaded = gate_blob_create(dst, src, sizeof(gate_funcptr_t)); break; | |
541 | 1 | case GATE_TYPE_CSTR: ptr_loaded = gate_blob_create(dst, *((char const* const*)src), gate_str_length(*((char const* const*)src))); break; | |
542 | 1 | case GATE_TYPE_WSTR: ptr_loaded = gate_blob_create(dst, *((wchar_t const* const*)src), sizeof(wchar_t) * gate_wstr_length(*((wchar_t const* const*)src))); break; | |
543 | 1 | case GATE_TYPE_GUID: ptr_loaded = gate_blob_create(dst, src, sizeof(gate_guid_t)); break; | |
544 | 1 | case GATE_TYPE_DATE: ptr_loaded = gate_blob_create(dst, src, sizeof(gate_date_t)); break; | |
545 | 1 | case GATE_TYPE_DAYTIME: ptr_loaded = gate_blob_create(dst, src, sizeof(gate_daytime_t)); break; | |
546 | 1 | case GATE_TYPE_DATETIME: ptr_loaded = gate_blob_create(dst, src, sizeof(gate_datetime_t)); break; | |
547 | 1 | case GATE_TYPE_TIME: ptr_loaded = gate_blob_create(dst, src, sizeof(gate_time_t)); break; | |
548 | 1 | case GATE_TYPE_STRING: ptr_loaded = gate_blob_create(dst, gate_string_ptr((gate_string_t const*)src, 0), gate_string_length((gate_string_t const*)src)); break; | |
549 | 1 | case GATE_TYPE_BLOB: ptr_loaded = gate_blob_create_clone(dst, (gate_blob_t const*)src); break; | |
550 | ✗ | default: return GATE_RESULT_NOTSUPPORTED; | |
551 | } | ||
552 | |||
553 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 23 times.
|
23 | return (ptr_loaded == NULL) ? GATE_RESULT_FAILED : GATE_RESULT_OK; |
554 | } | ||
555 | |||
556 | |||
557 | |||
558 | |||
559 | 112 | gate_result_t gate_value_save_int64(gate_int64_t src, gate_type_id_t dst_type, void* dst) | |
560 | { | ||
561 |
23/24✓ Branch 0 taken 4 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 5 taken 4 times.
✓ Branch 6 taken 4 times.
✓ Branch 7 taken 4 times.
✓ Branch 8 taken 4 times.
✓ Branch 9 taken 4 times.
✓ Branch 10 taken 4 times.
✓ Branch 11 taken 4 times.
✓ Branch 12 taken 6 times.
✓ Branch 13 taken 6 times.
✓ Branch 14 taken 6 times.
✓ Branch 15 taken 6 times.
✓ Branch 16 taken 6 times.
✓ Branch 17 taken 6 times.
✓ Branch 18 taken 6 times.
✓ Branch 19 taken 6 times.
✓ Branch 20 taken 6 times.
✓ Branch 21 taken 4 times.
✓ Branch 22 taken 6 times.
✗ Branch 23 not taken.
|
112 | switch (dst_type) |
562 | { | ||
563 | 4 | case GATE_TYPE_BOOL: *((gate_bool_t*)dst) = (src == 0) ? true : false; break; | |
564 | 4 | case GATE_TYPE_I8: *((gate_int8_t*)dst) = (gate_int8_t)src; break; | |
565 | 4 | case GATE_TYPE_I16: *((gate_int16_t*)dst) = (gate_int16_t)src; break; | |
566 | 4 | case GATE_TYPE_I32: *((gate_int32_t*)dst) = (gate_int32_t)src; break; | |
567 | 4 | case GATE_TYPE_I64: *((gate_int64_t*)dst) = (gate_int64_t)src; break; | |
568 | 4 | case GATE_TYPE_UI8: *((gate_uint8_t*)dst) = (gate_uint8_t)src; break; | |
569 | 4 | case GATE_TYPE_UI16: *((gate_uint16_t*)dst) = (gate_uint16_t)src; break; | |
570 | 4 | case GATE_TYPE_UI32: *((gate_uint32_t*)dst) = (gate_uint32_t)src; break; | |
571 | 4 | case GATE_TYPE_UI64: *((gate_uint64_t*)dst) = (gate_uint64_t)src; break; | |
572 | 4 | case GATE_TYPE_R32: *((gate_real32_t*)dst) = (gate_real32_t)src; break; | |
573 | 4 | case GATE_TYPE_R64: *((gate_real64_t*)dst) = (gate_real64_t)src; break; | |
574 | 4 | case GATE_TYPE_ADDRESS: *((gate_uintptr_t*)dst) = (gate_uintptr_t)src; break; | |
575 | 6 | case GATE_TYPE_DATAPTR: *((gate_dataptr_t*)dst) = (gate_dataptr_t)(gate_intptr_t)src; break; | |
576 | 6 | case GATE_TYPE_FUNCPTR: *((gate_funcptr_t*)dst) = (gate_funcptr_t)(gate_intptr_t)src; break; | |
577 | 6 | case GATE_TYPE_CSTR: *((gate_cstr_t*)dst) = NULL; break; | |
578 | 6 | case GATE_TYPE_WSTR: *((gate_wstr_t*)dst) = NULL; break; | |
579 | 6 | case GATE_TYPE_GUID: gate_mem_copy(dst, &src, sizeof(src)); break; | |
580 | 6 | case GATE_TYPE_DATE: | |
581 | { | ||
582 | 6 | gate_time_t tm = GATE_TIME_INIT; | |
583 | 6 | gate_datetime_t dt = GATE_DATETIME_INIT_EMPTY; | |
584 | 6 | gate_time_from_unix(src, &tm.timestamp); | |
585 | 6 | gate_time_to_datetime(&tm, &dt); | |
586 | 6 | *((gate_date_t*)dst) = dt.date; | |
587 | 6 | break; | |
588 | } | ||
589 | 6 | case GATE_TYPE_DAYTIME: | |
590 | { | ||
591 | 6 | const gate_uint64_t day_seconds = (gate_uint64_t)src; | |
592 | gate_daytime_t tm; | ||
593 | 6 | gate_uint32_t hour_seconds = (gate_uint32_t)(day_seconds % 3600); | |
594 | 6 | tm.hour = (gate_uint8_t)(day_seconds / 3600); | |
595 | 6 | tm.minute = (gate_uint8_t)(hour_seconds / 60); | |
596 | 6 | tm.second = (gate_uint8_t)(hour_seconds % 60); | |
597 | 6 | tm.microsecond = 0; | |
598 | 6 | *((gate_daytime_t*)dst) = tm; | |
599 | 6 | break; | |
600 | } | ||
601 | 6 | case GATE_TYPE_DATETIME: | |
602 | { | ||
603 | 6 | gate_time_t tm = GATE_TIME_INIT; | |
604 | 6 | gate_datetime_t dt = GATE_DATETIME_INIT_EMPTY; | |
605 | 6 | gate_time_from_unix(src, &tm.timestamp); | |
606 | 6 | gate_time_to_datetime(&tm, &dt); | |
607 | 6 | *((gate_datetime_t*)dst) = dt; | |
608 | 6 | break; | |
609 | } | ||
610 | 6 | case GATE_TYPE_TIME: | |
611 | { | ||
612 | 6 | gate_time_t tm = GATE_TIME_INIT; | |
613 | 6 | gate_time_from_unix(src, &tm.timestamp); | |
614 | 6 | *((gate_time_t*)dst) = tm; | |
615 | 6 | break; | |
616 | } | ||
617 | 4 | case GATE_TYPE_STRING: | |
618 | { | ||
619 | char strbuffer[128]; | ||
620 | 4 | gate_size_t strused = gate_str_print_int64(strbuffer, sizeof(strbuffer), src); | |
621 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
|
4 | if (NULL == gate_string_create((gate_string_t*)dst, strbuffer, strused)) |
622 | { | ||
623 | ✗ | return GATE_RESULT_FAILED; | |
624 | } | ||
625 | 4 | break; | |
626 | } | ||
627 | 6 | case GATE_TYPE_BLOB: | |
628 | { | ||
629 | char strbuffer[128]; | ||
630 | 6 | gate_size_t strused = gate_str_print_int64(strbuffer, sizeof(strbuffer), src); | |
631 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
|
6 | if (NULL == gate_blob_create((gate_blob_t*)dst, strbuffer, strused)) |
632 | { | ||
633 | ✗ | return GATE_RESULT_FAILED; | |
634 | } | ||
635 | 6 | break; | |
636 | } | ||
637 | |||
638 | ✗ | default: | |
639 | { | ||
640 | ✗ | return GATE_RESULT_NOTSUPPORTED; | |
641 | } | ||
642 | } | ||
643 | 112 | return GATE_RESULT_OK; | |
644 | } | ||
645 | 92 | gate_result_t gate_value_save_uint64(gate_uint64_t src, gate_type_id_t dst_type, void* dst) | |
646 | { | ||
647 |
23/24✓ Branch 0 taken 4 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 5 taken 4 times.
✓ Branch 6 taken 4 times.
✓ Branch 7 taken 4 times.
✓ Branch 8 taken 4 times.
✓ Branch 9 taken 4 times.
✓ Branch 10 taken 4 times.
✓ Branch 11 taken 4 times.
✓ Branch 12 taken 4 times.
✓ Branch 13 taken 4 times.
✓ Branch 14 taken 4 times.
✓ Branch 15 taken 4 times.
✓ Branch 16 taken 4 times.
✓ Branch 17 taken 4 times.
✓ Branch 18 taken 4 times.
✓ Branch 19 taken 4 times.
✓ Branch 20 taken 4 times.
✓ Branch 21 taken 4 times.
✓ Branch 22 taken 4 times.
✗ Branch 23 not taken.
|
92 | switch (dst_type) |
648 | { | ||
649 | 4 | case GATE_TYPE_BOOL: *((gate_bool_t*)dst) = (src == 0) ? true : false; break; | |
650 | 4 | case GATE_TYPE_I8: *((gate_int8_t*)dst) = (gate_int8_t)src; break; | |
651 | 4 | case GATE_TYPE_I16: *((gate_int16_t*)dst) = (gate_int16_t)src; break; | |
652 | 4 | case GATE_TYPE_I32: *((gate_int32_t*)dst) = (gate_int32_t)src; break; | |
653 | 4 | case GATE_TYPE_I64: *((gate_int64_t*)dst) = (gate_int64_t)src; break; | |
654 | 4 | case GATE_TYPE_UI8: *((gate_uint8_t*)dst) = (gate_uint8_t)src; break; | |
655 | 4 | case GATE_TYPE_UI16: *((gate_uint16_t*)dst) = (gate_uint16_t)src; break; | |
656 | 4 | case GATE_TYPE_UI32: *((gate_uint32_t*)dst) = (gate_uint32_t)src; break; | |
657 | 4 | case GATE_TYPE_UI64: *((gate_uint64_t*)dst) = (gate_uint64_t)src; break; | |
658 | 4 | case GATE_TYPE_R32: *((gate_real32_t*)dst) = (gate_real32_t)(gate_int64_t)src; break; | |
659 | 4 | case GATE_TYPE_R64: *((gate_real64_t*)dst) = (gate_real64_t)(gate_int64_t)src; break; | |
660 | 4 | case GATE_TYPE_ADDRESS: *((gate_uintptr_t*)dst) = (gate_uintptr_t)src; break; | |
661 | 4 | case GATE_TYPE_DATAPTR: *((gate_dataptr_t*)dst) = (gate_dataptr_t)(gate_uintptr_t)src; break; | |
662 | 4 | case GATE_TYPE_FUNCPTR: *((gate_funcptr_t*)dst) = (gate_funcptr_t)(gate_uintptr_t)src; break; | |
663 | 4 | case GATE_TYPE_CSTR: *((gate_cstr_t*)dst) = NULL; break; | |
664 | 4 | case GATE_TYPE_WSTR: *((gate_wstr_t*)dst) = NULL; break; | |
665 | 4 | case GATE_TYPE_GUID: gate_mem_copy(dst, &src, sizeof(src)); break; | |
666 | 4 | case GATE_TYPE_DATE: | |
667 | { | ||
668 | 4 | gate_time_t tm = GATE_TIME_INIT; | |
669 | 4 | gate_datetime_t dt = GATE_DATETIME_INIT_EMPTY; | |
670 | 4 | gate_time_from_unix((gate_int64_t)src, &tm.timestamp); | |
671 | 4 | gate_time_to_datetime(&tm, &dt); | |
672 | 4 | *((gate_date_t*)dst) = dt.date; | |
673 | 4 | break; | |
674 | } | ||
675 | 4 | case GATE_TYPE_DAYTIME: | |
676 | { | ||
677 | 4 | const gate_uint64_t day_seconds = src; | |
678 | gate_daytime_t tm; | ||
679 | 4 | gate_uint32_t hour_seconds = (gate_uint32_t)(day_seconds % 3600); | |
680 | 4 | tm.hour = (gate_uint8_t)(day_seconds / 3600); | |
681 | 4 | tm.minute = (gate_uint8_t)(hour_seconds / 60); | |
682 | 4 | tm.second = (gate_uint8_t)(hour_seconds % 60); | |
683 | 4 | tm.microsecond = 0; | |
684 | 4 | *((gate_daytime_t*)dst) = tm; | |
685 | 4 | break; | |
686 | } | ||
687 | 4 | case GATE_TYPE_DATETIME: | |
688 | { | ||
689 | 4 | gate_time_t tm = GATE_TIME_INIT; | |
690 | 4 | gate_datetime_t dt = GATE_DATETIME_INIT_EMPTY; | |
691 | 4 | gate_time_from_unix((gate_int64_t)src, &tm.timestamp); | |
692 | 4 | gate_time_to_datetime(&tm, &dt); | |
693 | 4 | *((gate_datetime_t*)dst) = dt; | |
694 | 4 | break; | |
695 | } | ||
696 | 4 | case GATE_TYPE_TIME: | |
697 | { | ||
698 | 4 | gate_time_t tm = GATE_TIME_INIT; | |
699 | 4 | gate_time_from_unix((gate_int64_t)src, &tm.timestamp); | |
700 | 4 | *((gate_time_t*)dst) = tm; | |
701 | 4 | break; | |
702 | } | ||
703 | 4 | case GATE_TYPE_STRING: | |
704 | { | ||
705 | char strbuffer[128]; | ||
706 | 4 | gate_size_t strused = gate_str_print_uint64(strbuffer, sizeof(strbuffer), src); | |
707 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
|
4 | if (NULL == gate_string_create((gate_string_t*)dst, strbuffer, strused)) |
708 | { | ||
709 | ✗ | return GATE_RESULT_FAILED; | |
710 | } | ||
711 | 4 | break; | |
712 | } | ||
713 | 4 | case GATE_TYPE_BLOB: | |
714 | { | ||
715 | char strbuffer[128]; | ||
716 | 4 | gate_size_t strused = gate_str_print_uint64(strbuffer, sizeof(strbuffer), src); | |
717 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
|
4 | if (NULL == gate_blob_create((gate_blob_t*)dst, strbuffer, strused)) |
718 | { | ||
719 | ✗ | return GATE_RESULT_FAILED; | |
720 | } | ||
721 | 4 | break; | |
722 | } | ||
723 | ✗ | default: | |
724 | ✗ | return GATE_RESULT_NOTSUPPORTED; | |
725 | } | ||
726 | 92 | return GATE_RESULT_OK; | |
727 | } | ||
728 | 46 | gate_result_t gate_value_save_real64(gate_real64_t src, gate_type_id_t dst_type, void* dst) | |
729 | { | ||
730 | char strbuffer[128]; | ||
731 | gate_size_t strused; | ||
732 |
14/14✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 2 times.
✓ Branch 6 taken 2 times.
✓ Branch 7 taken 2 times.
✓ Branch 8 taken 2 times.
✓ Branch 9 taken 2 times.
✓ Branch 10 taken 2 times.
✓ Branch 11 taken 2 times.
✓ Branch 12 taken 2 times.
✓ Branch 13 taken 20 times.
|
46 | switch (dst_type) |
733 | { | ||
734 | 2 | case GATE_TYPE_BOOL: *((gate_bool_t*)dst) = gate_math_iszero(src) ? true : false; break; | |
735 | 2 | case GATE_TYPE_I8: *((gate_int8_t*)dst) = (gate_int8_t)src; break; | |
736 | 2 | case GATE_TYPE_I16: *((gate_int16_t*)dst) = (gate_int16_t)src; break; | |
737 | 2 | case GATE_TYPE_I32: *((gate_int32_t*)dst) = (gate_int32_t)src; break; | |
738 | 2 | case GATE_TYPE_I64: *((gate_int64_t*)dst) = (gate_int64_t)src; break; | |
739 | 2 | case GATE_TYPE_UI8: *((gate_uint8_t*)dst) = (gate_uint8_t)src; break; | |
740 | 2 | case GATE_TYPE_UI16: *((gate_uint16_t*)dst) = (gate_uint16_t)src; break; | |
741 | 2 | case GATE_TYPE_UI32: *((gate_uint32_t*)dst) = (gate_uint32_t)src; break; | |
742 | 2 | case GATE_TYPE_UI64: *((gate_uint64_t*)dst) = (gate_uint64_t)src; break; | |
743 | 2 | case GATE_TYPE_R32: *((gate_real32_t*)dst) = (gate_real32_t)src; break; | |
744 | 2 | case GATE_TYPE_R64: *((gate_real64_t*)dst) = (gate_real64_t)src; break; | |
745 | 2 | case GATE_TYPE_ADDRESS: *((gate_uintptr_t*)dst) = (gate_uintptr_t)src; break; | |
746 | 2 | case GATE_TYPE_STRING: | |
747 | { | ||
748 | 2 | strused = gate_str_print_real(strbuffer, sizeof(strbuffer), src, 0, 6, 0); | |
749 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | if (NULL == gate_string_create((gate_string_t*)dst, strbuffer, strused)) |
750 | { | ||
751 | ✗ | return GATE_RESULT_FAILED; | |
752 | } | ||
753 | 2 | break; | |
754 | } | ||
755 | 20 | default: | |
756 | 20 | return gate_value_save_int64((gate_int64_t)src, dst_type, dst); | |
757 | } | ||
758 | 26 | return GATE_RESULT_OK; | |
759 | } | ||
760 | |||
761 | 23 | gate_result_t gate_value_save_bool(gate_bool_t src, gate_type_id_t dst_type, void* dst) | |
762 | { | ||
763 |
23/24✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 1 times.
✓ Branch 8 taken 1 times.
✓ Branch 9 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 11 taken 1 times.
✓ Branch 12 taken 1 times.
✓ Branch 13 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 15 taken 1 times.
✓ Branch 16 taken 1 times.
✓ Branch 17 taken 1 times.
✓ Branch 18 taken 1 times.
✓ Branch 19 taken 1 times.
✓ Branch 20 taken 1 times.
✓ Branch 21 taken 1 times.
✓ Branch 22 taken 1 times.
✗ Branch 23 not taken.
|
23 | switch (dst_type) |
764 | { | ||
765 | 1 | case GATE_TYPE_BOOL: *((gate_bool_t*)dst) = src ? true : false; break; | |
766 | 1 | case GATE_TYPE_I8: *((gate_int8_t*)dst) = src ? 1 : 0; break; | |
767 | 1 | case GATE_TYPE_I16: *((gate_int16_t*)dst) = src ? 1 : 0; break; | |
768 | 1 | case GATE_TYPE_I32: *((gate_int32_t*)dst) = src ? 1 : 0; break; | |
769 | 1 | case GATE_TYPE_I64: *((gate_int64_t*)dst) = src ? 1 : 0; break; | |
770 | 1 | case GATE_TYPE_UI8: *((gate_uint8_t*)dst) = src ? 1 : 0; break; | |
771 | 1 | case GATE_TYPE_UI16: *((gate_uint16_t*)dst) = src ? 1 : 0; break; | |
772 | 1 | case GATE_TYPE_UI32: *((gate_uint32_t*)dst) = src ? 1 : 0; break; | |
773 | 1 | case GATE_TYPE_UI64: *((gate_uint64_t*)dst) = src ? 1 : 0; break; | |
774 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | case GATE_TYPE_R32: *((gate_real32_t*)dst) = src ? 1.0f : 0.0f; break; |
775 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | case GATE_TYPE_R64: *((gate_real64_t*)dst) = src ? 1.0 : 0.0; break; |
776 | 1 | case GATE_TYPE_ADDRESS: *((gate_uintptr_t*)dst) = src ? 1 : 0; break; | |
777 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | case GATE_TYPE_DATAPTR: *((gate_dataptr_t*)dst) = src ? ((gate_dataptr_t*)1) : NULL; break; |
778 | 1 | case GATE_TYPE_FUNCPTR: *((gate_funcptr_t*)dst) = NULL; break; | |
779 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | case GATE_TYPE_CSTR: *((gate_cstr_t*)dst) = src ? "true" : "false"; break; |
780 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | case GATE_TYPE_WSTR: *((gate_wstr_t*)dst) = src ? L"true" : L"false"; break; |
781 | 1 | case GATE_TYPE_GUID: gate_mem_clear(dst, sizeof(gate_guid_t)); break; | |
782 | 1 | case GATE_TYPE_DATE: gate_mem_clear(dst, sizeof(gate_date_t)); break; | |
783 | 1 | case GATE_TYPE_DAYTIME: gate_mem_clear(dst, sizeof(gate_daytime_t)); break; | |
784 | 1 | case GATE_TYPE_DATETIME:gate_mem_clear(dst, sizeof(gate_datetime_t)); break; | |
785 | 1 | case GATE_TYPE_TIME: gate_mem_clear(dst, sizeof(gate_time_t)); break; | |
786 |
2/4✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
1 | case GATE_TYPE_STRING: gate_string_create_static_len((gate_string_t*)dst, src ? "true" : "false", src ? 4 : 5); break; |
787 |
2/4✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
1 | case GATE_TYPE_BLOB: gate_blob_create_static((gate_blob_t*)dst, src ? "true" : NULL, src ? 4 : 0); break; |
788 | ✗ | default: | |
789 | ✗ | return GATE_RESULT_NOTSUPPORTED; | |
790 | } | ||
791 | 23 | return GATE_RESULT_OK; | |
792 | } | ||
793 | |||
794 | 23 | gate_result_t gate_value_save_int8(gate_int8_t src, gate_type_id_t dst_type, void* dst) | |
795 | { | ||
796 | 23 | return gate_value_save_int64(src, dst_type, dst); | |
797 | } | ||
798 | 23 | gate_result_t gate_value_save_int16(gate_int16_t src, gate_type_id_t dst_type, void* dst) | |
799 | { | ||
800 | 23 | return gate_value_save_int64(src, dst_type, dst); | |
801 | } | ||
802 | 23 | gate_result_t gate_value_save_int32(gate_int32_t src, gate_type_id_t dst_type, void* dst) | |
803 | { | ||
804 | 23 | return gate_value_save_int64(src, dst_type, dst); | |
805 | } | ||
806 | 23 | gate_result_t gate_value_save_uint8(gate_uint8_t src, gate_type_id_t dst_type, void* dst) | |
807 | { | ||
808 | 23 | return gate_value_save_uint64(src, dst_type, dst); | |
809 | } | ||
810 | 23 | gate_result_t gate_value_save_uint16(gate_uint16_t src, gate_type_id_t dst_type, void* dst) | |
811 | { | ||
812 | 23 | return gate_value_save_uint64(src, dst_type, dst); | |
813 | } | ||
814 | 23 | gate_result_t gate_value_save_uint32(gate_uint32_t src, gate_type_id_t dst_type, void* dst) | |
815 | { | ||
816 | 23 | return gate_value_save_uint64(src, dst_type, dst); | |
817 | } | ||
818 | 23 | gate_result_t gate_value_save_real32(gate_real32_t src, gate_type_id_t dst_type, void* dst) | |
819 | { | ||
820 | 23 | return gate_value_save_real64((gate_real64_t)src, dst_type, dst); | |
821 | } | ||
822 | |||
823 | 30 | gate_result_t gate_value_save_string(gate_string_t const* src, gate_type_id_t dst_type, void* dst) | |
824 | { | ||
825 | 30 | gate_int64_t i64 = 0; | |
826 | 30 | gate_uint64_t ui64 = 0; | |
827 | 30 | gate_real64_t r64 = 0.0; | |
828 |
23/24✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 1 times.
✓ Branch 8 taken 1 times.
✓ Branch 9 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 11 taken 1 times.
✓ Branch 12 taken 1 times.
✓ Branch 13 taken 1 times.
✓ Branch 14 taken 2 times.
✓ Branch 15 taken 2 times.
✓ Branch 16 taken 2 times.
✓ Branch 17 taken 2 times.
✓ Branch 18 taken 2 times.
✓ Branch 19 taken 2 times.
✓ Branch 20 taken 2 times.
✓ Branch 21 taken 1 times.
✓ Branch 22 taken 1 times.
✗ Branch 23 not taken.
|
30 | switch (dst_type) |
829 | { | ||
830 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | case GATE_TYPE_BOOL: if (src) gate_str_parse_int64(src->str, src->length, &i64); *((gate_bool_t*)dst) = i64 != 0; break; |
831 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | case GATE_TYPE_I8: if (src) gate_str_parse_int64(src->str, src->length, &i64); *((gate_int8_t*)dst) = (gate_int8_t)i64; break; |
832 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | case GATE_TYPE_I16: if (src) gate_str_parse_int64(src->str, src->length, &i64); *((gate_int16_t*)dst) = (gate_int16_t)i64; break; |
833 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | case GATE_TYPE_I32: if (src) gate_str_parse_int64(src->str, src->length, &i64); *((gate_int32_t*)dst) = (gate_int32_t)i64; break; |
834 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | case GATE_TYPE_I64: if (src) gate_str_parse_int64(src->str, src->length, &i64); *((gate_int64_t*)dst) = (gate_int64_t)i64; break; |
835 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | case GATE_TYPE_UI8: if (src) gate_str_parse_uint64(src->str, src->length, &ui64); *((gate_uint8_t*)dst) = (gate_uint8_t)ui64; break; |
836 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | case GATE_TYPE_UI16: if (src) gate_str_parse_uint64(src->str, src->length, &ui64); *((gate_uint16_t*)dst) = (gate_uint16_t)ui64; break; |
837 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | case GATE_TYPE_UI32: if (src) gate_str_parse_uint64(src->str, src->length, &ui64); *((gate_uint32_t*)dst) = (gate_uint32_t)ui64; break; |
838 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | case GATE_TYPE_UI64: if (src) gate_str_parse_uint64(src->str, src->length, &ui64); *((gate_uint64_t*)dst) = (gate_uint64_t)ui64; break; |
839 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | case GATE_TYPE_R32: if (src) gate_str_parse_real(src->str, src->length, &r64); *((gate_real32_t*)dst) = (gate_real32_t)r64; break; |
840 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | case GATE_TYPE_R64: if (src) gate_str_parse_real(src->str, src->length, &r64); *((gate_real64_t*)dst) = (gate_real64_t)r64; break; |
841 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | case GATE_TYPE_ADDRESS: if (src) gate_str_parse_uint64(src->str, src->length, &ui64); *((gate_uintptr_t*)dst) = (gate_uintptr_t)ui64; break; |
842 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | case GATE_TYPE_DATAPTR: if (src) gate_str_parse_uint64(src->str, src->length, &ui64); *((gate_dataptr_t*)dst) = (gate_dataptr_t)(gate_uintptr_t)ui64; break; |
843 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | case GATE_TYPE_FUNCPTR: if (src) gate_str_parse_uint64(src->str, src->length, &ui64); *((gate_funcptr_t*)dst) = (gate_funcptr_t)(gate_uintptr_t)ui64; break; |
844 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 | case GATE_TYPE_GUID: if (src) gate_guid_parse_string(src->str, src->length, (gate_guid_t*)dst); break; |
845 | 2 | case GATE_TYPE_CSTR: *((gate_cstr_t*)dst) = src->str; break; | |
846 | 2 | case GATE_TYPE_WSTR: *((gate_wstr_t*)dst) = NULL; break; | |
847 | 2 | case GATE_TYPE_DATE: | |
848 | { | ||
849 | 2 | gate_datetime_t dt = GATE_DATETIME_INIT_EMPTY; | |
850 | 2 | gate_int16_t bias = 0; | |
851 | 2 | gate_date_parse_string(src->str, src->length, &dt, &bias); | |
852 | 2 | *((gate_date_t*)dst) = dt.date; | |
853 | 2 | break; | |
854 | } | ||
855 | 2 | case GATE_TYPE_DAYTIME: | |
856 | { | ||
857 | 2 | gate_datetime_t dt = GATE_DATETIME_INIT_EMPTY; | |
858 | 2 | gate_int16_t bias = 0; | |
859 | 2 | gate_date_parse_string(src->str, src->length, &dt, &bias); | |
860 | 2 | *((gate_daytime_t*)dst) = dt.time; | |
861 | 2 | break; | |
862 | } | ||
863 | 2 | case GATE_TYPE_DATETIME: | |
864 | { | ||
865 | 2 | gate_datetime_t dt = GATE_DATETIME_INIT_EMPTY; | |
866 | 2 | gate_int16_t bias = 0; | |
867 | 2 | gate_date_parse_string(src->str, src->length, &dt, &bias); | |
868 | 2 | *((gate_datetime_t*)dst) = dt; | |
869 | 2 | break; | |
870 | } | ||
871 | 2 | case GATE_TYPE_TIME: | |
872 | { | ||
873 | 2 | gate_datetime_t dt = GATE_DATETIME_INIT_EMPTY; | |
874 | 2 | gate_int16_t bias = 0; | |
875 | 2 | gate_time_t tm = GATE_TIME_INIT; | |
876 | 2 | gate_date_parse_string(src->str, src->length, &dt, &bias); | |
877 | 2 | gate_date_to_time(&dt, &tm); | |
878 | 2 | tm.bias = bias; | |
879 | 2 | *((gate_time_t*)dst) = tm; | |
880 | 2 | break; | |
881 | } | ||
882 | 1 | case GATE_TYPE_STRING: | |
883 | { | ||
884 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | if (NULL == gate_string_clone((gate_string_t*)dst, src)) |
885 | { | ||
886 | ✗ | return GATE_RESULT_FAILED; | |
887 | } | ||
888 | 1 | break; | |
889 | } | ||
890 | 1 | case GATE_TYPE_BLOB: | |
891 | { | ||
892 |
1/2✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
|
1 | if (NULL == gate_blob_create((gate_blob_t*)dst, gate_string_ptr(src, 0), gate_string_length(src))) |
893 | { | ||
894 | ✗ | return GATE_RESULT_FAILED; | |
895 | } | ||
896 | 1 | break; | |
897 | } | ||
898 | ✗ | default: return GATE_RESULT_NOTSUPPORTED; | |
899 | } | ||
900 | 30 | return GATE_RESULT_OK; | |
901 | } | ||
902 | |||
903 | #define BLOB_TO_NATIVE_TYPE(ptr_blob, native_type, ptr_target) \ | ||
904 | do { \ | ||
905 | gate_size_t blob_len = gate_blob_length(ptr_blob); \ | ||
906 | if(blob_len > sizeof(native_type)) blob_len = sizeof(native_type); \ | ||
907 | if(blob_len > 0) { \ | ||
908 | void const* blob_data = gate_blob_data(ptr_blob); \ | ||
909 | gate_mem_copy(ptr_target, blob_data, blob_len); \ | ||
910 | } \ | ||
911 | return GATE_RESULT_OK; \ | ||
912 | } while(0) | ||
913 | |||
914 | 23 | gate_result_t gate_value_save_blob(gate_blob_t const* src, gate_type_id_t dst_type, void* dst) | |
915 | { | ||
916 |
2/4✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 23 times.
|
23 | if (!src || !dst) |
917 | { | ||
918 | ✗ | return GATE_RESULT_NULLPOINTER; | |
919 | } | ||
920 | |||
921 |
17/17✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 1 times.
✓ Branch 8 taken 1 times.
✓ Branch 9 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 11 taken 1 times.
✓ Branch 12 taken 1 times.
✓ Branch 13 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 15 taken 1 times.
✓ Branch 16 taken 7 times.
|
23 | switch (dst_type) |
922 | { | ||
923 | 1 | case GATE_TYPE_BOOL: *((gate_bool_t*)dst) = gate_blob_length(src) != 0; return GATE_RESULT_OK; break; | |
924 |
2/4✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
|
1 | case GATE_TYPE_I8: BLOB_TO_NATIVE_TYPE(src, gate_int8_t, dst); break; |
925 |
2/4✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
|
1 | case GATE_TYPE_I16: BLOB_TO_NATIVE_TYPE(src, gate_int16_t, dst); break; |
926 |
2/4✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
|
1 | case GATE_TYPE_I32: BLOB_TO_NATIVE_TYPE(src, gate_int32_t, dst); break; |
927 |
2/4✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
|
1 | case GATE_TYPE_I64: BLOB_TO_NATIVE_TYPE(src, gate_int64_t, dst); break; |
928 |
2/4✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
|
1 | case GATE_TYPE_UI8: BLOB_TO_NATIVE_TYPE(src, gate_uint8_t, dst); break; |
929 |
2/4✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
|
1 | case GATE_TYPE_UI16: BLOB_TO_NATIVE_TYPE(src, gate_uint16_t, dst); break; |
930 |
2/4✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
|
1 | case GATE_TYPE_UI32: BLOB_TO_NATIVE_TYPE(src, gate_uint32_t, dst); break; |
931 |
2/4✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
|
1 | case GATE_TYPE_UI64: BLOB_TO_NATIVE_TYPE(src, gate_uint64_t, dst); break; |
932 |
2/4✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
|
1 | case GATE_TYPE_R32: BLOB_TO_NATIVE_TYPE(src, gate_real32_t, dst); break; |
933 |
2/4✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
|
1 | case GATE_TYPE_R64: BLOB_TO_NATIVE_TYPE(src, gate_real64_t, dst); break; |
934 |
2/4✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
|
1 | case GATE_TYPE_ADDRESS: BLOB_TO_NATIVE_TYPE(src, gate_uintptr_t, dst); break; |
935 |
2/4✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
|
1 | case GATE_TYPE_DATAPTR: BLOB_TO_NATIVE_TYPE(src, gate_dataptr_t, dst); break; |
936 |
2/4✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
|
1 | case GATE_TYPE_FUNCPTR: BLOB_TO_NATIVE_TYPE(src, gate_funcptr_t, dst); break; |
937 | 1 | case GATE_TYPE_STRING: | |
938 | { | ||
939 | 1 | return (NULL == gate_string_create((gate_string_t*)dst, (char const*)gate_blob_data(src), gate_blob_length(src))) | |
940 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | ? GATE_RESULT_OUTOFMEMORY : GATE_RESULT_OK; |
941 | } | ||
942 | 1 | case GATE_TYPE_BLOB: | |
943 | { | ||
944 | 1 | return (NULL == gate_blob_create_clone((gate_blob_t*)dst, src)) | |
945 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | ? GATE_RESULT_OUTOFMEMORY : GATE_RESULT_OK; |
946 | } | ||
947 | 7 | default: | |
948 | { | ||
949 | gate_string_t str; | ||
950 | 7 | gate_string_create_static_len(&str, (char const*)gate_blob_data(src), gate_blob_length(src)); | |
951 | 7 | return gate_value_save_string(&str, dst_type, dst); | |
952 | } | ||
953 | } | ||
954 | return GATE_RESULT_FAILED; | ||
955 | } | ||
956 | |||
957 | |||
958 | |||
959 | ✗ | gate_result_t gate_value_copy_constructor(void* dest, void const* src) | |
960 | { | ||
961 | ✗ | if (NULL == gate_value_clone((gate_value_t const*)src, (gate_value_t*)dest)) | |
962 | { | ||
963 | ✗ | return GATE_RESULT_OUTOFMEMORY; | |
964 | } | ||
965 | else | ||
966 | { | ||
967 | ✗ | return GATE_RESULT_OK; | |
968 | } | ||
969 | } | ||
970 | ✗ | void gate_value_destructor(void* dest) | |
971 | { | ||
972 | ✗ | gate_value_release((gate_value_t*)dest); | |
973 | ✗ | } | |
974 | |||
975 | static gate_uint8_t const false_value = 0; | ||
976 | static gate_uint8_t const true_value = 1; | ||
977 | |||
978 | 3 | static gate_size_t gate_value_serialize_address(char* dest_buffer, gate_size_t dest_buffer_len, void* ptr) | |
979 | { | ||
980 | 3 | const gate_uint64_t u64 = (gate_uint64_t)(gate_uintptr_t)ptr; | |
981 | 3 | return gate_serialize_uint64_l(dest_buffer, dest_buffer_len, &u64); | |
982 | } | ||
983 | 3 | static gate_size_t gate_value_deserialize_address(char const* src_buffer, gate_size_t src_buffer_len, void** ptr) | |
984 | { | ||
985 | 3 | gate_uint64_t u64 = 0; | |
986 | 3 | gate_size_t ret = gate_deserialize_uint64_l(src_buffer, src_buffer_len, &u64); | |
987 |
1/2✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
|
3 | if (ret > 0) |
988 | { | ||
989 | 3 | *ptr = (void*)(gate_uintptr_t)u64; | |
990 | } | ||
991 | 3 | return ret; | |
992 | } | ||
993 | |||
994 | 23 | gate_size_t gate_value_serialize(gate_value_t const* src, char* dest_buffer, gate_size_t dest_buffer_len) | |
995 | { | ||
996 | 23 | gate_size_t ret = 0; | |
997 | 23 | const gate_uint16_t ser_typeid = (gate_uint16_t)gate_value_type(src); | |
998 | |||
999 | 23 | gate_size_t len_payload = 0; | |
1000 | 23 | gate_size_t len_header = gate_serialize_uint16_l(dest_buffer, dest_buffer_len, &ser_typeid); | |
1001 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 23 times.
|
23 | if (len_header == 0) |
1002 | { | ||
1003 | /* error case */ | ||
1004 | ✗ | return 0; | |
1005 | } | ||
1006 | |||
1007 | 23 | dest_buffer += len_header; | |
1008 | 23 | dest_buffer_len -= len_header; | |
1009 | |||
1010 |
23/27✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 1 times.
✓ Branch 8 taken 1 times.
✓ Branch 9 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 11 taken 1 times.
✓ Branch 12 taken 1 times.
✓ Branch 13 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 15 taken 1 times.
✓ Branch 16 taken 1 times.
✓ Branch 17 taken 1 times.
✓ Branch 18 taken 1 times.
✓ Branch 19 taken 1 times.
✓ Branch 20 taken 1 times.
✓ Branch 21 taken 1 times.
✓ Branch 22 taken 1 times.
✗ Branch 23 not taken.
✓ Branch 24 taken 1 times.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
|
23 | switch (src->value_type) |
1011 | { | ||
1012 | ✗ | case GATE_TYPE_VOID: { len_payload = gate_serialize_uint8_l(dest_buffer, dest_buffer_len, &false_value); break; } | |
1013 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | case GATE_TYPE_BOOL: { len_payload = gate_serialize_uint8_l(dest_buffer, dest_buffer_len, src->content.bool_value ? &true_value : &false_value); break; } |
1014 | 1 | case GATE_TYPE_I8: { len_payload = gate_serialize_int8_l(dest_buffer, dest_buffer_len, &src->content.i8_value); break; } | |
1015 | 1 | case GATE_TYPE_UI8: { len_payload = gate_serialize_uint8_l(dest_buffer, dest_buffer_len, &src->content.ui8_value); break; } | |
1016 | 1 | case GATE_TYPE_I16: { len_payload = gate_serialize_int16_l(dest_buffer, dest_buffer_len, &src->content.i16_value); break; } | |
1017 | 1 | case GATE_TYPE_UI16: { len_payload = gate_serialize_uint16_l(dest_buffer, dest_buffer_len, &src->content.ui16_value); break; } | |
1018 | 1 | case GATE_TYPE_I32: { len_payload = gate_serialize_int32_l(dest_buffer, dest_buffer_len, &src->content.i32_value); break; } | |
1019 | 1 | case GATE_TYPE_UI32: { len_payload = gate_serialize_uint32_l(dest_buffer, dest_buffer_len, &src->content.ui32_value); break; } | |
1020 | 1 | case GATE_TYPE_I64: { len_payload = gate_serialize_int64_l(dest_buffer, dest_buffer_len, &src->content.i64_value); break; } | |
1021 | 1 | case GATE_TYPE_UI64: { len_payload = gate_serialize_uint64_l(dest_buffer, dest_buffer_len, &src->content.ui64_value); break; } | |
1022 | 1 | case GATE_TYPE_R32: { len_payload = gate_serialize_real32_l(dest_buffer, dest_buffer_len, &src->content.r32_value); break; } | |
1023 | 1 | case GATE_TYPE_R64: { len_payload = gate_serialize_real64_l(dest_buffer, dest_buffer_len, &src->content.r64_value); break; } | |
1024 | 1 | case GATE_TYPE_ADDRESS: { len_payload = gate_value_serialize_address(dest_buffer, dest_buffer_len, (void*)src->content.address_value); break; } | |
1025 | 1 | case GATE_TYPE_DATAPTR: { len_payload = gate_value_serialize_address(dest_buffer, dest_buffer_len, (void*)src->content.ptr_value); break; } | |
1026 | 1 | case GATE_TYPE_FUNCPTR: { len_payload = gate_value_serialize_address(dest_buffer, dest_buffer_len, (void*)src->content.address_value); break; } | |
1027 | 1 | case GATE_TYPE_CSTR: | |
1028 | { | ||
1029 | 1 | gate_size_t len_str = gate_str_length(src->content.cstring_value); | |
1030 | 1 | gate_uint32_t len_bytes = (gate_uint32_t)(len_str + 1); | |
1031 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | if (dest_buffer_len >= (len_bytes + 4)) |
1032 | { | ||
1033 | 1 | gate_serialize_uint32_l(dest_buffer, 4, &len_bytes); | |
1034 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | if (len_str > 0) |
1035 | { | ||
1036 | 1 | gate_mem_copy(&dest_buffer[4], src->content.cstring_value, len_str); | |
1037 | } | ||
1038 | 1 | dest_buffer[4 + len_str] = 0; | |
1039 | 1 | len_payload = len_bytes + 4; | |
1040 | } | ||
1041 | 1 | break; | |
1042 | } | ||
1043 | 1 | case GATE_TYPE_WSTR: | |
1044 | { | ||
1045 | 1 | gate_size_t len_str = gate_wstr_length(src->content.wstring_value); | |
1046 | 1 | gate_uint32_t len_bytes = (gate_uint32_t)((len_str + 1) * sizeof(wchar_t)); | |
1047 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | if (dest_buffer_len >= (len_bytes + 4)) |
1048 | { | ||
1049 | 1 | gate_serialize_uint32_l(dest_buffer, 4, &len_bytes); | |
1050 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | if (len_str > 0) |
1051 | { | ||
1052 | 1 | gate_mem_copy(&dest_buffer[4], src->content.wstring_value, len_str * sizeof(wchar_t)); | |
1053 | } | ||
1054 | 1 | gate_mem_clear(&dest_buffer[4 + len_str * sizeof(wchar_t)], sizeof(wchar_t)); | |
1055 | 1 | len_payload = len_bytes + 4; | |
1056 | } | ||
1057 | 1 | break; | |
1058 | } | ||
1059 | 1 | case GATE_TYPE_GUID: | |
1060 | { | ||
1061 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | if (dest_buffer_len >= 16) |
1062 | { | ||
1063 | 1 | gate_serialize_uint32_l(&dest_buffer[0], 4, &src->content.guid_value.item1); | |
1064 | 1 | gate_serialize_uint16_l(&dest_buffer[4], 2, &src->content.guid_value.item2); | |
1065 | 1 | gate_serialize_uint16_l(&dest_buffer[6], 2, &src->content.guid_value.item3); | |
1066 | 1 | gate_mem_copy(&dest_buffer[8], src->content.guid_value.item4, 8); | |
1067 | 1 | len_payload = 16; | |
1068 | } | ||
1069 | 1 | break; | |
1070 | } | ||
1071 | 1 | case GATE_TYPE_DATE: | |
1072 | { | ||
1073 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | if (dest_buffer_len >= 4) |
1074 | { | ||
1075 | 1 | gate_serialize_uint16_l(&dest_buffer[0], 2, &src->content.date_value.year); | |
1076 | 1 | gate_serialize_uint8_l(&dest_buffer[2], 1, &src->content.date_value.month); | |
1077 | 1 | gate_serialize_uint8_l(&dest_buffer[3], 1, &src->content.date_value.day); | |
1078 | 1 | len_payload = 4; | |
1079 | } | ||
1080 | 1 | break; | |
1081 | } | ||
1082 | 1 | case GATE_TYPE_DAYTIME: | |
1083 | { | ||
1084 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | if (dest_buffer_len >= 6) |
1085 | { | ||
1086 | char buf[4]; | ||
1087 | 1 | const gate_uint32_t micro = src->content.daytime_value.microsecond % 1000000; | |
1088 | 1 | gate_serialize_uint8_l(&dest_buffer[0], 1, &src->content.daytime_value.hour); | |
1089 | 1 | gate_serialize_uint8_l(&dest_buffer[1], 1, &src->content.daytime_value.minute); | |
1090 | 1 | gate_serialize_uint8_l(&dest_buffer[2], 1, &src->content.daytime_value.second); | |
1091 | 1 | gate_serialize_uint32_l(&buf[0], 4, &src->content.daytime_value.microsecond); | |
1092 | 1 | gate_mem_copy(&dest_buffer[3], &buf[0], 3); | |
1093 | 1 | len_payload = 6; | |
1094 | } | ||
1095 | 1 | break; | |
1096 | } | ||
1097 | 1 | case GATE_TYPE_DATETIME: | |
1098 | { | ||
1099 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | if (dest_buffer_len >= 10) |
1100 | { | ||
1101 | char buf[4]; | ||
1102 | 1 | const gate_uint32_t micro = src->content.daytime_value.microsecond % 1000000; | |
1103 | 1 | gate_serialize_uint16_l(&dest_buffer[0], 2, &src->content.date_value.year); | |
1104 | 1 | gate_serialize_uint8_l(&dest_buffer[2], 1, &src->content.date_value.month); | |
1105 | 1 | gate_serialize_uint8_l(&dest_buffer[3], 1, &src->content.date_value.day); | |
1106 | 1 | gate_serialize_uint8_l(&dest_buffer[4], 1, &src->content.daytime_value.hour); | |
1107 | 1 | gate_serialize_uint8_l(&dest_buffer[5], 1, &src->content.daytime_value.minute); | |
1108 | 1 | gate_serialize_uint8_l(&dest_buffer[6], 1, &src->content.daytime_value.second); | |
1109 | 1 | gate_serialize_uint32_l(&buf[0], 4, &src->content.daytime_value.microsecond); | |
1110 | 1 | gate_mem_copy(&dest_buffer[7], &buf[0], 3); | |
1111 | 1 | len_payload = 10; | |
1112 | } | ||
1113 | 1 | break; | |
1114 | } | ||
1115 | 1 | case GATE_TYPE_TIME: | |
1116 | { | ||
1117 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | if (dest_buffer_len >= 10) |
1118 | { | ||
1119 | 1 | const gate_int64_t ts = src->content.time_value.timestamp; | |
1120 | 1 | const gate_int16_t b = src->content.time_value.bias; | |
1121 | 1 | gate_serialize_int64_l(&dest_buffer[0], 8, &ts); | |
1122 | 1 | gate_serialize_int16_l(&dest_buffer[8], 2, &b); | |
1123 | 1 | len_payload = 10; | |
1124 | } | ||
1125 | 1 | break; | |
1126 | } | ||
1127 | 1 | case GATE_TYPE_STRING: | |
1128 | { | ||
1129 | 1 | const gate_uint32_t str_len = (gate_uint32_t)gate_string_length(&src->content.string_value); | |
1130 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | if (dest_buffer_len >= str_len + 4) |
1131 | { | ||
1132 | 1 | gate_serialize_uint32_l(&dest_buffer[0], 4, &str_len); | |
1133 | 1 | gate_mem_copy(&dest_buffer[4], gate_string_ptr(&src->content.string_value, 0), str_len); | |
1134 | 1 | len_payload = str_len + 4; | |
1135 | } | ||
1136 | 1 | break; | |
1137 | } | ||
1138 | ✗ | case GATE_TYPE_ARRAY: | |
1139 | { | ||
1140 | /* type-less arrays are not supported in serialization */ | ||
1141 | ✗ | break; | |
1142 | } | ||
1143 | 1 | case GATE_TYPE_BLOB: | |
1144 | { | ||
1145 | 1 | const gate_uint32_t blob_len = (gate_uint32_t)gate_blob_length(&src->content.blob_value); | |
1146 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | if (dest_buffer_len >= blob_len + 4) |
1147 | { | ||
1148 | 1 | gate_serialize_uint32_l(&dest_buffer[0], 4, &blob_len); | |
1149 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | if (blob_len > 0) |
1150 | { | ||
1151 | ✗ | gate_mem_copy(&dest_buffer[4], gate_blob_data(&src->content.blob_value), blob_len); | |
1152 | } | ||
1153 | 1 | len_payload = blob_len + 4; | |
1154 | } | ||
1155 | 1 | break; | |
1156 | } | ||
1157 | ✗ | case GATE_TYPE_STRUCT: | |
1158 | case GATE_TYPE_OBJECT: | ||
1159 | case GATE_TYPE_PROPERTY: | ||
1160 | |||
1161 | case GATE_TYPE_ARRAYLIST: | ||
1162 | case GATE_TYPE_ARRAYLIST_BOOL: | ||
1163 | case GATE_TYPE_ARRAYLIST_I8: | ||
1164 | case GATE_TYPE_ARRAYLIST_UI8: | ||
1165 | case GATE_TYPE_ARRAYLIST_I16: | ||
1166 | case GATE_TYPE_ARRAYLIST_UI16: | ||
1167 | case GATE_TYPE_ARRAYLIST_I32: | ||
1168 | case GATE_TYPE_ARRAYLIST_UI32: | ||
1169 | case GATE_TYPE_ARRAYLIST_I64: | ||
1170 | case GATE_TYPE_ARRAYLIST_UI64: | ||
1171 | case GATE_TYPE_ARRAYLIST_R32: | ||
1172 | case GATE_TYPE_ARRAYLIST_R64: | ||
1173 | case GATE_TYPE_ARRAYLIST_ADDRESS: | ||
1174 | |||
1175 | case GATE_TYPE_ARRAYLIST_DATAPTR: | ||
1176 | case GATE_TYPE_ARRAYLIST_FUNCPTR: | ||
1177 | case GATE_TYPE_ARRAYLIST_CSTR: | ||
1178 | case GATE_TYPE_ARRAYLIST_WSTR: | ||
1179 | case GATE_TYPE_ARRAYLIST_GUID: | ||
1180 | case GATE_TYPE_ARRAYLIST_DATE: | ||
1181 | case GATE_TYPE_ARRAYLIST_DAYTIME: | ||
1182 | case GATE_TYPE_ARRAYLIST_DATETIME: | ||
1183 | case GATE_TYPE_ARRAYLIST_TIME: | ||
1184 | |||
1185 | case GATE_TYPE_ARRAYLIST_STRING: | ||
1186 | case GATE_TYPE_ARRAYLIST_ARRAY: | ||
1187 | |||
1188 | case GATE_TYPE_ARRAYLIST_STRUCT: | ||
1189 | case GATE_TYPE_ARRAYLIST_OBJECT: | ||
1190 | case GATE_TYPE_ARRAYLIST_PROPERTY: | ||
1191 | ✗ | break; | |
1192 | } | ||
1193 | |||
1194 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 23 times.
|
23 | if (len_payload == 0) |
1195 | { | ||
1196 | /* error case */ | ||
1197 | ✗ | return 0; | |
1198 | } | ||
1199 | else | ||
1200 | { | ||
1201 | /* success case */ | ||
1202 | 23 | return len_header + len_payload; | |
1203 | } | ||
1204 | return ret; | ||
1205 | } | ||
1206 | |||
1207 | 23 | gate_size_t gate_value_deserialize(char const* src_buffer, gate_size_t src_buffer_len, gate_value_t* dst) | |
1208 | { | ||
1209 | 23 | gate_uint16_t ser_type = 0; | |
1210 | 23 | gate_size_t len_header = gate_deserialize_uint16_l(src_buffer, src_buffer_len, &ser_type); | |
1211 | 23 | gate_size_t len_payload = 0; | |
1212 | |||
1213 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 23 times.
|
23 | if (len_header == 0) |
1214 | { | ||
1215 | /* error case */ | ||
1216 | ✗ | return 0; | |
1217 | } | ||
1218 | |||
1219 | 23 | src_buffer += len_header; | |
1220 | 23 | src_buffer_len -= len_header; | |
1221 | |||
1222 |
23/27✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 1 times.
✓ Branch 8 taken 1 times.
✓ Branch 9 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 11 taken 1 times.
✓ Branch 12 taken 1 times.
✓ Branch 13 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 15 taken 1 times.
✓ Branch 16 taken 1 times.
✓ Branch 17 taken 1 times.
✓ Branch 18 taken 1 times.
✓ Branch 19 taken 1 times.
✓ Branch 20 taken 1 times.
✓ Branch 21 taken 1 times.
✓ Branch 22 taken 1 times.
✗ Branch 23 not taken.
✓ Branch 24 taken 1 times.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
|
23 | switch (ser_type) |
1223 | { | ||
1224 | ✗ | case GATE_TYPE_VOID: | |
1225 | { | ||
1226 | ✗ | gate_uint8_t v = 0; | |
1227 | ✗ | len_payload = gate_deserialize_uint8_l(src_buffer, src_buffer_len, &v); | |
1228 | ✗ | if (len_payload > 0) | |
1229 | { | ||
1230 | ✗ | gate_mem_clear(dst, sizeof(gate_value_t)); | |
1231 | } | ||
1232 | ✗ | break; | |
1233 | } | ||
1234 | 1 | case GATE_TYPE_BOOL: | |
1235 | { | ||
1236 | 1 | gate_uint8_t v = 0; | |
1237 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | v = (v != 0) ? true_value : false_value; |
1238 | 1 | len_payload = gate_deserialize_uint8_l(src_buffer, src_buffer_len, &v); | |
1239 |
2/4✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
|
1 | if ((len_payload > 0) && (NULL == gate_value_create(ser_type, &v, dst))) |
1240 | { | ||
1241 | ✗ | len_payload = 0; | |
1242 | } | ||
1243 | 1 | break; | |
1244 | } | ||
1245 | 1 | case GATE_TYPE_I8: | |
1246 | { | ||
1247 | 1 | gate_int8_t v = 0; | |
1248 | 1 | len_payload = gate_deserialize_int8_l(src_buffer, src_buffer_len, &v); | |
1249 |
2/4✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
|
1 | if ((len_payload > 0) && (NULL == gate_value_create(ser_type, &v, dst))) |
1250 | { | ||
1251 | ✗ | len_payload = 0; | |
1252 | } | ||
1253 | 1 | break; | |
1254 | } | ||
1255 | 1 | case GATE_TYPE_UI8: | |
1256 | { | ||
1257 | 1 | gate_uint8_t v = 0; | |
1258 | 1 | len_payload = gate_deserialize_uint8_l(src_buffer, src_buffer_len, &v); | |
1259 |
2/4✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
|
1 | if ((len_payload > 0) && (NULL == gate_value_create(ser_type, &v, dst))) |
1260 | { | ||
1261 | ✗ | len_payload = 0; | |
1262 | } | ||
1263 | 1 | break; | |
1264 | } | ||
1265 | 1 | case GATE_TYPE_I16: | |
1266 | { | ||
1267 | 1 | gate_int16_t v = 0; | |
1268 | 1 | len_payload = gate_deserialize_int16_l(src_buffer, src_buffer_len, &v); | |
1269 |
2/4✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
|
1 | if ((len_payload > 0) && (NULL == gate_value_create(ser_type, &v, dst))) |
1270 | { | ||
1271 | ✗ | len_payload = 0; | |
1272 | } | ||
1273 | 1 | break; | |
1274 | } | ||
1275 | 1 | case GATE_TYPE_UI16: | |
1276 | { | ||
1277 | 1 | gate_uint16_t v = 0; | |
1278 | 1 | len_payload = gate_deserialize_uint16_l(src_buffer, src_buffer_len, &v); | |
1279 |
2/4✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
|
1 | if ((len_payload > 0) && (NULL == gate_value_create(ser_type, &v, dst))) |
1280 | { | ||
1281 | ✗ | len_payload = 0; | |
1282 | } | ||
1283 | 1 | break; | |
1284 | } | ||
1285 | 1 | case GATE_TYPE_I32: | |
1286 | { | ||
1287 | 1 | gate_int32_t v = 0; | |
1288 | 1 | len_payload = gate_deserialize_int32_l(src_buffer, src_buffer_len, &v); | |
1289 |
2/4✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
|
1 | if ((len_payload > 0) && (NULL == gate_value_create(ser_type, &v, dst))) |
1290 | { | ||
1291 | ✗ | len_payload = 0; | |
1292 | } | ||
1293 | 1 | break; | |
1294 | } | ||
1295 | 1 | case GATE_TYPE_UI32: | |
1296 | { | ||
1297 | 1 | gate_uint32_t v = 0; | |
1298 | 1 | len_payload = gate_deserialize_uint32_l(src_buffer, src_buffer_len, &v); | |
1299 |
2/4✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
|
1 | if ((len_payload > 0) && (NULL == gate_value_create(ser_type, &v, dst))) |
1300 | { | ||
1301 | ✗ | len_payload = 0; | |
1302 | } | ||
1303 | 1 | break; | |
1304 | } | ||
1305 | 1 | case GATE_TYPE_I64: | |
1306 | { | ||
1307 | 1 | gate_int64_t v = 0; | |
1308 | 1 | len_payload = gate_deserialize_int64_l(src_buffer, src_buffer_len, &v); | |
1309 |
2/4✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
|
1 | if ((len_payload > 0) && (NULL == gate_value_create(ser_type, &v, dst))) |
1310 | { | ||
1311 | ✗ | len_payload = 0; | |
1312 | } | ||
1313 | 1 | break; | |
1314 | } | ||
1315 | 1 | case GATE_TYPE_UI64: | |
1316 | { | ||
1317 | 1 | gate_uint64_t v = 0; | |
1318 | 1 | len_payload = gate_deserialize_uint64_l(src_buffer, src_buffer_len, &v); | |
1319 |
2/4✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
|
1 | if ((len_payload > 0) && (NULL == gate_value_create(ser_type, &v, dst))) |
1320 | { | ||
1321 | ✗ | len_payload = 0; | |
1322 | } | ||
1323 | 1 | break; | |
1324 | } | ||
1325 | 1 | case GATE_TYPE_R32: | |
1326 | { | ||
1327 | 1 | gate_real32_t v = 0.0f; | |
1328 | 1 | len_payload = gate_deserialize_real32_l(src_buffer, src_buffer_len, &v); | |
1329 |
2/4✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
|
1 | if ((len_payload > 0) && (NULL == gate_value_create(ser_type, &v, dst))) |
1330 | { | ||
1331 | ✗ | len_payload = 0; | |
1332 | } | ||
1333 | 1 | break; | |
1334 | } | ||
1335 | 1 | case GATE_TYPE_R64: | |
1336 | { | ||
1337 | 1 | gate_real64_t v = 0.0; | |
1338 | 1 | len_payload = gate_deserialize_real64_l(src_buffer, src_buffer_len, &v); | |
1339 |
2/4✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
|
1 | if ((len_payload > 0) && (NULL == gate_value_create(ser_type, &v, dst))) |
1340 | { | ||
1341 | ✗ | len_payload = 0; | |
1342 | } | ||
1343 | 1 | break; | |
1344 | } | ||
1345 | 1 | case GATE_TYPE_ADDRESS: | |
1346 | { | ||
1347 | 1 | void* ptr = NULL; | |
1348 | 1 | len_payload = gate_value_deserialize_address(src_buffer, src_buffer_len, &ptr); | |
1349 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | if (len_payload > 0) |
1350 | { | ||
1351 | 1 | const gate_uintptr_t v = (gate_uintptr_t)ptr; | |
1352 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | if (NULL == gate_value_create(ser_type, &v, dst)) |
1353 | { | ||
1354 | ✗ | len_payload = 0; | |
1355 | } | ||
1356 | } | ||
1357 | 1 | break; | |
1358 | } | ||
1359 | 1 | case GATE_TYPE_DATAPTR: | |
1360 | { | ||
1361 | 1 | void* ptr = NULL; | |
1362 | 1 | len_payload = gate_value_deserialize_address(src_buffer, src_buffer_len, &ptr); | |
1363 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | if (len_payload > 0) |
1364 | { | ||
1365 | 1 | const gate_dataptr_t v = (gate_dataptr_t)ptr; | |
1366 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | if (NULL == gate_value_create(ser_type, &v, dst)) |
1367 | { | ||
1368 | ✗ | len_payload = 0; | |
1369 | } | ||
1370 | } | ||
1371 | 1 | break; | |
1372 | } | ||
1373 | 1 | case GATE_TYPE_FUNCPTR: | |
1374 | { | ||
1375 | 1 | void* ptr = NULL; | |
1376 | 1 | len_payload = gate_value_deserialize_address(src_buffer, src_buffer_len, &ptr); | |
1377 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | if (len_payload > 0) |
1378 | { | ||
1379 | 1 | const gate_funcptr_t v = (gate_funcptr_t)ptr; | |
1380 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | if (NULL == gate_value_create(ser_type, &v, dst)) |
1381 | { | ||
1382 | ✗ | len_payload = 0; | |
1383 | } | ||
1384 | } | ||
1385 | 1 | break; | |
1386 | } | ||
1387 | 1 | case GATE_TYPE_CSTR: | |
1388 | { | ||
1389 | 1 | gate_uint32_t len_str = 0; | |
1390 | 1 | len_payload = gate_deserialize_uint32_l(src_buffer, src_buffer_len, &len_str); | |
1391 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | if (len_payload > 0) |
1392 | { | ||
1393 | 1 | len_payload = 0; /* reset to error case */ | |
1394 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | if (src_buffer_len >= len_str + 4) |
1395 | { | ||
1396 | 1 | gate_cstr_t const str = (gate_cstr_t)(src_buffer + 4); | |
1397 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | if (NULL != gate_value_create(ser_type, &str, dst)) |
1398 | { | ||
1399 | /* succes case */ | ||
1400 | 1 | len_payload = len_str + 4; | |
1401 | } | ||
1402 | } | ||
1403 | } | ||
1404 | 1 | break; | |
1405 | } | ||
1406 | 1 | case GATE_TYPE_WSTR: | |
1407 | { | ||
1408 | 1 | gate_uint32_t len_str = 0; | |
1409 | 1 | len_payload = gate_deserialize_uint32_l(src_buffer, src_buffer_len, &len_str); | |
1410 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | if (len_payload > 0) |
1411 | { | ||
1412 | 1 | len_payload = 0; /* reset to error case */ | |
1413 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | if (src_buffer_len >= len_str + 4) |
1414 | { | ||
1415 | 1 | gate_wstr_t const str = (gate_wstr_t)(src_buffer + 4); | |
1416 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | if (NULL != gate_value_create(ser_type, &str, dst)) |
1417 | { | ||
1418 | /* success case */ | ||
1419 | 1 | len_payload = len_str + 4; | |
1420 | } | ||
1421 | } | ||
1422 | } | ||
1423 | 1 | break; | |
1424 | } | ||
1425 | 1 | case GATE_TYPE_GUID: | |
1426 | { | ||
1427 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | if (src_buffer_len >= 16) |
1428 | { | ||
1429 | 1 | gate_guid_t v = GATE_INIT_EMPTY; | |
1430 | 1 | gate_deserialize_uint32_l(&src_buffer[0], 4, &v.item1); | |
1431 | 1 | gate_deserialize_uint16_l(&src_buffer[4], 2, &v.item2); | |
1432 | 1 | gate_deserialize_uint16_l(&src_buffer[6], 2, &v.item3); | |
1433 | 1 | gate_mem_copy(&v.item4[0], &src_buffer[8], 8); | |
1434 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | if (NULL != gate_value_create(ser_type, &v, dst)) |
1435 | { | ||
1436 | /* success case */ | ||
1437 | 1 | len_payload = 16; | |
1438 | } | ||
1439 | } | ||
1440 | 1 | break; | |
1441 | } | ||
1442 | 1 | case GATE_TYPE_DATE: | |
1443 | { | ||
1444 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | if (src_buffer_len >= 4) |
1445 | { | ||
1446 | 1 | gate_date_t dt = GATE_DATE_INIT_EMPTY; | |
1447 | 1 | gate_deserialize_uint16_l(&src_buffer[0], 2, &dt.year); | |
1448 | 1 | gate_deserialize_uint8_l(&src_buffer[2], 1, &dt.month); | |
1449 | 1 | gate_deserialize_uint8_l(&src_buffer[3], 1, &dt.day); | |
1450 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | if (NULL != gate_value_create(ser_type, &dt, dst)) |
1451 | { | ||
1452 | /* success case */ | ||
1453 | 1 | len_payload = 4; | |
1454 | } | ||
1455 | } | ||
1456 | 1 | break; | |
1457 | } | ||
1458 | 1 | case GATE_TYPE_DAYTIME: | |
1459 | { | ||
1460 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | if (src_buffer_len >= 6) |
1461 | { | ||
1462 | 1 | gate_daytime_t dt = GATE_DAYTIME_INIT_EMPTY; | |
1463 | char buf[4]; | ||
1464 | 1 | gate_deserialize_uint8_l(&src_buffer[0], 1, &dt.hour); | |
1465 | 1 | gate_deserialize_uint8_l(&src_buffer[1], 1, &dt.minute); | |
1466 | 1 | gate_deserialize_uint8_l(&src_buffer[2], 1, &dt.second); | |
1467 | 1 | gate_mem_copy(buf, &src_buffer[3], 3); | |
1468 | 1 | buf[3] = 0; | |
1469 | 1 | gate_deserialize_uint32_l(buf, 4, &dt.microsecond); | |
1470 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | if (NULL != gate_value_create(ser_type, &dt, dst)) |
1471 | { | ||
1472 | /* success case */ | ||
1473 | 1 | len_payload = 6; | |
1474 | } | ||
1475 | } | ||
1476 | 1 | break; | |
1477 | } | ||
1478 | 1 | case GATE_TYPE_DATETIME: | |
1479 | { | ||
1480 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | if (src_buffer_len >= 10) |
1481 | { | ||
1482 | 1 | gate_datetime_t dt = GATE_DATETIME_INIT_EMPTY; | |
1483 | char buf[4]; | ||
1484 | 1 | gate_deserialize_uint16_l(&src_buffer[0], 2, &dt.date.year); | |
1485 | 1 | gate_deserialize_uint8_l(&src_buffer[2], 1, &dt.date.month); | |
1486 | 1 | gate_deserialize_uint8_l(&src_buffer[3], 1, &dt.date.day); | |
1487 | 1 | gate_deserialize_uint8_l(&src_buffer[4], 1, &dt.time.hour); | |
1488 | 1 | gate_deserialize_uint8_l(&src_buffer[5], 1, &dt.time.minute); | |
1489 | 1 | gate_deserialize_uint8_l(&src_buffer[6], 1, &dt.time.second); | |
1490 | 1 | gate_mem_copy(buf, &src_buffer[7], 3); | |
1491 | 1 | buf[3] = 0; | |
1492 | 1 | gate_deserialize_uint32_l(buf, 4, &dt.time.microsecond); | |
1493 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | if (NULL != gate_value_create(ser_type, &dt, dst)) |
1494 | { | ||
1495 | /* success case */ | ||
1496 | 1 | len_payload = 10; | |
1497 | } | ||
1498 | } | ||
1499 | 1 | break; | |
1500 | } | ||
1501 | 1 | case GATE_TYPE_TIME: | |
1502 | { | ||
1503 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | if (src_buffer_len >= 10) |
1504 | { | ||
1505 | 1 | gate_time_t tm = GATE_TIME_INIT; | |
1506 | 1 | gate_deserialize_int64_l(&src_buffer[0], 8, &tm.timestamp); | |
1507 | 1 | gate_deserialize_int16_l(&src_buffer[8], 2, &tm.bias); | |
1508 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | if (NULL != gate_value_create(ser_type, &tm, dst)) |
1509 | { | ||
1510 | /* success case */ | ||
1511 | 1 | len_payload = 10; | |
1512 | } | ||
1513 | } | ||
1514 | 1 | break; | |
1515 | } | ||
1516 | 1 | case GATE_TYPE_STRING: | |
1517 | { | ||
1518 | 1 | gate_uint32_t len_chars = 0; | |
1519 | 1 | len_payload = gate_deserialize_uint32_l(src_buffer, src_buffer_len, &len_chars); | |
1520 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | if (len_payload != 0) |
1521 | { | ||
1522 | 1 | len_payload = 0; | |
1523 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | if (src_buffer_len >= len_chars + 4) |
1524 | { | ||
1525 | 1 | gate_string_t text = GATE_STRING_INIT_EMPTY; | |
1526 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | if (NULL != gate_string_create(&text, &src_buffer[4], len_chars)) |
1527 | { | ||
1528 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | if (NULL != gate_value_create(ser_type, &text, dst)) |
1529 | { | ||
1530 | /* success case */ | ||
1531 | 1 | len_payload = len_chars + 4; | |
1532 | } | ||
1533 | 1 | gate_string_release(&text); | |
1534 | } | ||
1535 | } | ||
1536 | } | ||
1537 | 1 | break; | |
1538 | } | ||
1539 | ✗ | case GATE_TYPE_ARRAY: | |
1540 | { | ||
1541 | ✗ | break; | |
1542 | } | ||
1543 | 1 | case GATE_TYPE_BLOB: | |
1544 | { | ||
1545 | 1 | gate_uint32_t len_bytes = 0; | |
1546 | 1 | len_payload = gate_deserialize_uint32_l(src_buffer, src_buffer_len, &len_bytes); | |
1547 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | if (len_payload != 0) |
1548 | { | ||
1549 | 1 | len_payload = 0; | |
1550 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | if (src_buffer_len >= len_bytes + 4) |
1551 | { | ||
1552 | 1 | gate_blob_t blob = GATE_INIT_EMPTY; | |
1553 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | if (NULL != gate_blob_create(&blob, &src_buffer[4], len_bytes)) |
1554 | { | ||
1555 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | if (NULL != gate_value_create(ser_type, &blob, dst)) |
1556 | { | ||
1557 | /* success case */ | ||
1558 | 1 | len_payload = len_bytes + 4; | |
1559 | } | ||
1560 | 1 | gate_blob_release(&blob); | |
1561 | } | ||
1562 | } | ||
1563 | } | ||
1564 | 1 | break; | |
1565 | } | ||
1566 | ✗ | case GATE_TYPE_STRUCT: | |
1567 | case GATE_TYPE_OBJECT: | ||
1568 | case GATE_TYPE_PROPERTY: | ||
1569 | |||
1570 | case GATE_TYPE_ARRAYLIST: | ||
1571 | case GATE_TYPE_ARRAYLIST_BOOL: | ||
1572 | case GATE_TYPE_ARRAYLIST_I8: | ||
1573 | case GATE_TYPE_ARRAYLIST_UI8: | ||
1574 | case GATE_TYPE_ARRAYLIST_I16: | ||
1575 | case GATE_TYPE_ARRAYLIST_UI16: | ||
1576 | case GATE_TYPE_ARRAYLIST_I32: | ||
1577 | case GATE_TYPE_ARRAYLIST_UI32: | ||
1578 | case GATE_TYPE_ARRAYLIST_I64: | ||
1579 | case GATE_TYPE_ARRAYLIST_UI64: | ||
1580 | case GATE_TYPE_ARRAYLIST_R32: | ||
1581 | case GATE_TYPE_ARRAYLIST_R64: | ||
1582 | case GATE_TYPE_ARRAYLIST_ADDRESS: | ||
1583 | |||
1584 | case GATE_TYPE_ARRAYLIST_DATAPTR: | ||
1585 | case GATE_TYPE_ARRAYLIST_FUNCPTR: | ||
1586 | case GATE_TYPE_ARRAYLIST_CSTR: | ||
1587 | case GATE_TYPE_ARRAYLIST_WSTR: | ||
1588 | case GATE_TYPE_ARRAYLIST_GUID: | ||
1589 | case GATE_TYPE_ARRAYLIST_DATE: | ||
1590 | case GATE_TYPE_ARRAYLIST_DAYTIME: | ||
1591 | case GATE_TYPE_ARRAYLIST_DATETIME: | ||
1592 | case GATE_TYPE_ARRAYLIST_TIME: | ||
1593 | |||
1594 | case GATE_TYPE_ARRAYLIST_STRING: | ||
1595 | case GATE_TYPE_ARRAYLIST_ARRAY: | ||
1596 | case GATE_TYPE_ARRAYLIST_BLOB: | ||
1597 | |||
1598 | case GATE_TYPE_ARRAYLIST_STRUCT: | ||
1599 | case GATE_TYPE_ARRAYLIST_OBJECT: | ||
1600 | case GATE_TYPE_ARRAYLIST_PROPERTY: | ||
1601 | ✗ | break; | |
1602 | } | ||
1603 | |||
1604 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 23 times.
|
23 | if (len_payload == 0) |
1605 | { | ||
1606 | /* error case */ | ||
1607 | ✗ | return 0; | |
1608 | } | ||
1609 | else | ||
1610 | { | ||
1611 | 23 | return len_header + len_payload; | |
1612 | } | ||
1613 | } | ||
1614 |