Adaptive Framework  0.9.0
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
afw_data_type.c
Go to the documentation of this file.
1 // See the 'COPYING' file in the project root for licensing information.
2 /*
3  * Adaptive framework core data type functions
4  *
5  * Copyright (c) 2010-2023 Clemson University
6  *
7  */
8 
9 
15 #include "afw_internal.h"
16 #include "apr_base64.h"
17 
18 
19 
20 static void
21 impl_clone_and_set_property(
22  const afw_object_t *obj,
23  const afw_utf8_t *property_name,
24  const afw_value_t *value,
25  afw_xctx_t *xctx);
26 
27 
28 /* object clone. */
29 static void
30 impl_afw_data_type_object_clone_internal(
31  const afw_data_type_t * instance,
32  void * to_internal,
33  const void * from_internal,
34  const afw_pool_t *p,
35  afw_xctx_t *xctx);
36 
37 
38 
39 /* afw_boolean_t true value. */
42 
43 /* afw_boolean_t false value. */
46 
47 
48 /* ---- Common utf8 to internal ----------------------------------------------*/
49 
50 static void
51 impl_afw_data_type_utf8_utf8_to_internal(
52  const afw_data_type_t * instance,
53  void * to_internal,
54  const afw_utf8_t * from_utf8,
55  const afw_pool_t * p,
56  afw_xctx_t *xctx)
57 {
58  /* Input must already be NFC. */
59  memcpy(to_internal, from_utf8, sizeof(afw_utf8_t));
60 }
61 
62 
63 /* ---- Common internal to utf8 ----------------------------------------------*/
64 
65 /* Can use for any afw_utf8_t internal. */
66 static const afw_utf8_t *
67 impl_afw_data_type_utf8_internal_to_utf8(
68  const afw_data_type_t * instance,
69  const void * from_internal,
70  const afw_pool_t * p,
71  afw_xctx_t *xctx)
72 {
73  return (const afw_utf8_t *)from_internal;
74 }
75 
76 
77 /* ---- Common compare -------------------------------------------------------*/
78 
79 /* Can use for any afw_memory_t internal. */
80 static int
81 impl_afw_data_type_raw_compare_internal(
82  const afw_data_type_t * instance,
83  const void * value1,
84  const void * value2,
85  afw_xctx_t *xctx)
86 {
87  const afw_memory_t *v1 = value1;
88  const afw_memory_t *v2 = value2;
89  int result;
90 
91  if (v1->size == v2->size) {
92  result = memcmp(v1->ptr, v2->ptr, v1->size);
93  }
94 
95  else if (v1->size < v2->size) {
96  result = memcmp(v1->ptr, v2->ptr, v1->size);
97  if (result == 0) result = -1;
98  }
99 
100  else {
101  result = memcmp(v1->ptr, v2->ptr, v2->size);
102  if (result == 0) result = 1;
103  }
104 
105  return result;
106 }
107 
108 
109 /* Can use for any afw_utf8_t internal. */
110 static int
111 impl_afw_data_type_utf8_compare_internal(
112  const afw_data_type_t * instance,
113  const void * value1,
114  const void * value2,
115  afw_xctx_t *xctx)
116 {
117  const afw_utf8_t *v1 = value1;
118  const afw_utf8_t *v2 = value2;
119  int result;
120 
121  if (v1->len == v2->len) {
122  result = memcmp(v1->s, v2->s, v1->len);
123  }
124 
125  else if (v1->len < v2->len) {
126  result = memcmp(v1->s, v2->s, v1->len);
127  if (result == 0) result = -1;
128  }
129 
130  else {
131  result = memcmp(v1->s, v2->s, v2->len);
132  if (result == 0) result = 1;
133  }
134 
135  return result;
136 }
137 
138 
139 /* ---- Convert ------------------------------------------------------*/
140 
141 /* Can use for any data type tha does not have a convert function. */
142 static void
143 impl_afw_data_type_standard_convert_internal(
144  const afw_data_type_t * instance,
145  void * to_internal,
146  const void * from_internal,
147  const afw_data_type_t *to_data_type,
148  const afw_pool_t * p,
149  afw_xctx_t *xctx)
150 {
151  const afw_utf8_t *from_utf8;
152 
153  /* Try converting to utf8 and then to to_data_type. */
154  from_utf8 = afw_data_type_internal_to_utf8(instance, from_internal,
155  p, xctx);
156  afw_data_type_utf8_to_internal(to_data_type, to_internal, from_utf8,
157  p, xctx);
158 }
159 
160 
161 /* Can use for any data type with cType afw_utf8_t. */
162 static void
163 impl_afw_data_type_from_utf8_convert_internal(
164  const afw_data_type_t * instance,
165  void * to_internal,
166  const void * from_internal,
167  const afw_data_type_t *to_data_type,
168  const afw_pool_t * p,
169  afw_xctx_t *xctx)
170 {
171  if (afw_data_type_is_boolean(to_data_type)) {
172  *((afw_boolean_t *)to_internal) =
173  (!from_internal ||
174  (((const afw_utf8_t *)from_internal)->len == 0))
175  ? false
176  : true;
177  }
178  else {
179  afw_data_type_utf8_to_internal(to_data_type,
180  to_internal, (const afw_utf8_t *)from_internal,
181  p, xctx);
182  }
183 }
184 
185 
186 /* Can use for any data type with cType afw_memory_t. */
187 static void
188 impl_afw_data_type_from_raw_convert_internal(
189  const afw_data_type_t *instance,
190  void *to_internal,
191  const void *from_internal,
192  const afw_data_type_t *to_data_type,
193  const afw_pool_t *p,
194  afw_xctx_t *xctx)
195 {
196  if (afw_data_type_is_boolean(to_data_type)) {
197  *((afw_boolean_t *)to_internal) =
198  (((const afw_memory_t *)from_internal)->size == 0) ? false : true;
199  }
200  else if (afw_data_type_is_base64Binary(to_data_type) ||
201  afw_data_type_is_hexBinary(to_data_type))
202  {
203  memcpy(to_internal, (afw_octet_t *)from_internal, sizeof(afw_memory_t));
204  }
205  else {
206  impl_afw_data_type_standard_convert_internal(
207  instance, to_internal, from_internal, to_data_type, p, xctx);
208  }
209 }
210 
211 
212 /* Can use for any data type with cType afw_memory_t. */
213 static void
214 impl_afw_data_type_from_pointer_convert_internal(
215  const afw_data_type_t *instance,
216  void *to_internal,
217  const void *from_internal,
218  const afw_data_type_t *to_data_type,
219  const afw_pool_t *p,
220  afw_xctx_t *xctx)
221 {
222  if (afw_data_type_is_boolean(to_data_type)) {
223  *((afw_boolean_t *)to_internal) =
224  (*(char *)from_internal) ? false : true;
225  }
226  else {
227  impl_afw_data_type_standard_convert_internal(
228  instance, to_internal, from_internal, to_data_type, p, xctx);
229  }
230 }
231 
232 
233 /* Used for any data type dateTime. Will convert to date and time. */
234 static void
235 impl_afw_data_type_from_dateTime_convert_internal(
236  const afw_data_type_t * instance,
237  void * to_internal,
238  const void * from_internal,
239  const afw_data_type_t *to_data_type,
240  const afw_pool_t * p,
241  afw_xctx_t *xctx)
242 {
243  if (afw_data_type_is_dateTime(to_data_type)) {
244  memcpy(to_internal, from_internal, sizeof(afw_dateTime_t));
245  }
246  else if (afw_data_type_is_date(to_data_type)) {
247  memcpy(&((afw_date_t *)to_internal)->date,
248  &((const afw_dateTime_t *)from_internal)->date,
249  sizeof(afw_date_no_time_zone_t));
250  memcpy(&((afw_date_t *)to_internal)->time_zone,
251  &((const afw_dateTime_t *)from_internal)->time_zone,
252  sizeof(afw_time_zone_t));
253  }
254  else if (afw_data_type_is_time(to_data_type)) {
255  memcpy(&((afw_time_t *)to_internal)->time,
256  &((const afw_dateTime_t *)from_internal)->time,
257  sizeof(afw_time_no_time_zone_t));
258  memcpy(&((afw_time_t *)to_internal)->time_zone,
259  &((const afw_dateTime_t *)from_internal)->time_zone,
260  sizeof(afw_time_zone_t));
261  }
262  else {
263  impl_afw_data_type_standard_convert_internal(instance,
264  to_internal, from_internal, to_data_type, p, xctx);
265  }
266 }
267 
268 
269 /* Used for data type double. Will convert double to integer. */
270 static void
271 impl_afw_data_type_from_double_convert_internal(
272  const afw_data_type_t * instance,
273  void * to_internal,
274  const void * from_internal,
275  const afw_data_type_t *to_data_type,
276  const afw_pool_t * p,
277  afw_xctx_t *xctx)
278 {
279  afw_integer_t i;
280 
281  if (afw_data_type_is_double(to_data_type)) {
282  memcpy(to_internal, from_internal, sizeof(afw_double_t));
283  }
284  else if (afw_data_type_is_integer(to_data_type)) {
285  /*
286  AFW_THROW_ERROR_FZ(general, xctx,
287  "Cannot convert data type %" AFW_UTF8_FMT
288  " to %" AFW_UTF8_FMT,
289  AFW_UTF8_FMT_ARG(&instance->data_type_id),
290  AFW_UTF8_FMT_ARG(&to_data_type->data_type_id));
291  */
292  i = (afw_integer_t)(*(const afw_double_t *)from_internal);
293  //if (i != *(const afw_double_t *)from_internal) {
294  // AFW_THROW_ERROR_Z(general,
295  // "This double value can not be converted to integer",
296  // xctx);
297  //}
298  *((afw_integer_t *)to_internal) = i;
299  }
300  else if (afw_data_type_is_boolean(to_data_type)) {
301  *(afw_boolean_t *)to_internal =
302  afw_number_is_NaN(*(const afw_double_t *)from_internal)
303  ? false
304  : *(const afw_double_t *)from_internal != 0.0;
305  }
306  else {
307  impl_afw_data_type_standard_convert_internal(instance,
308  to_internal, from_internal, to_data_type, p, xctx);
309  }
310 }
311 
312 
313 /* Used for data type integer. Will convert integer to double. */
314 static void
315 impl_afw_data_type_from_integer_convert_internal(
316  const afw_data_type_t * instance,
317  void * to_internal,
318  const void * from_internal,
319  const afw_data_type_t *to_data_type,
320  const afw_pool_t * p,
321  afw_xctx_t *xctx)
322 {
323  if (afw_data_type_is_integer(to_data_type)) {
324  memcpy(to_internal, from_internal, sizeof(afw_integer_t));
325  }
326  else if (afw_data_type_is_double(to_data_type)) {
327  *((afw_double_t *)to_internal) =
328  (afw_double_t)(*(const afw_integer_t *)from_internal);
329  }
330  else if (afw_data_type_is_boolean(to_data_type)) {
331  *(afw_boolean_t *)to_internal =
332  *(const afw_integer_t *)from_internal != 0;
333  }
334  else {
335  impl_afw_data_type_standard_convert_internal(instance,
336  to_internal, from_internal, to_data_type, p, xctx);
337  }
338 }
339 
340 
341 /* Used for data type date. Will convert date to dateTime with just date. */
342 static void
343 impl_afw_data_type_from_date_convert_internal(
344  const afw_data_type_t * instance,
345  void * to_internal,
346  const void * from_internal,
347  const afw_data_type_t *to_data_type,
348  const afw_pool_t * p,
349  afw_xctx_t *xctx)
350 {
351  if (afw_data_type_is_date(to_data_type)) {
352  memcpy(to_internal, from_internal, sizeof(afw_date_t));
353  }
354  else if (afw_data_type_is_dateTime(to_data_type)) {
355  afw_memory_clear(&((afw_dateTime_t *)to_internal)->time);
356  memcpy(&((afw_dateTime_t *)to_internal)->date,
357  &((const afw_date_t *)from_internal)->date,
358  sizeof(afw_date_no_time_zone_t));
359  memcpy(&((afw_dateTime_t *)to_internal)->time_zone,
360  &((const afw_date_t *)from_internal)->time_zone,
361  sizeof(afw_time_zone_t));
362  }
363  else {
364  impl_afw_data_type_standard_convert_internal(instance,
365  to_internal, from_internal, to_data_type, p, xctx);
366  }
367 }
368 
369 
370 /* Used for data type time. Will convert time to dateTime with just time. */
371 static void
372 impl_afw_data_type_from_time_convert_internal(
373  const afw_data_type_t * instance,
374  void * to_internal,
375  const void * from_internal,
376  const afw_data_type_t *to_data_type,
377  const afw_pool_t * p,
378  afw_xctx_t *xctx)
379 {
380  if (afw_data_type_is_time(to_data_type)) {
381  memcpy(to_internal, from_internal, sizeof(afw_time_t));
382  }
383  else if (afw_data_type_is_dateTime(to_data_type)) {
384  afw_memory_clear(&((afw_dateTime_t *)to_internal)->date);
385  memcpy(&((afw_dateTime_t *)to_internal)->time,
386  &((const afw_time_t *)from_internal)->time,
387  sizeof(afw_time_no_time_zone_t));
388  memcpy(&((afw_dateTime_t *)to_internal)->time_zone,
389  &((const afw_time_t *)from_internal)->time_zone,
390  sizeof(afw_time_zone_t));
391  }
392  else {
393  impl_afw_data_type_standard_convert_internal(instance,
394  to_internal, from_internal, to_data_type, p, xctx);
395  }
396 }
397 
398 
399 /* ---- Data type specific ---------------------------------------------------*/
400 
401 /* Data type anyURI to internal. */
402 static void
403 impl_afw_data_type_anyURI_utf8_to_internal(
404  const afw_data_type_t * instance,
405  void * to_internal,
406  const afw_utf8_t * from_utf8,
407  const afw_pool_t * p,
408  afw_xctx_t *xctx)
409 {
410  /* Input must already be NFC. */
411  memcpy(to_internal, from_utf8, sizeof(afw_utf8_t));
412 }
413 
414 
415 /* Data type base64Binary to utf8. */
416 static const afw_utf8_t *
417 impl_afw_data_type_base64Binary_internal_to_utf8(
418  const afw_data_type_t * instance,
419  const void * from_internal,
420  const afw_pool_t * p,
421  afw_xctx_t *xctx)
422 {
423  afw_utf8_t *encoded;
424 
425  encoded = afw_pool_calloc_type(p, afw_utf8_t, xctx);
426  afw_memory_encode_base64(encoded, from_internal, p, xctx);
427  return encoded;
428 }
429 
430 
431 
432 /* Data type base64Binary to internal. */
433 static void
434 impl_afw_data_type_base64Binary_utf8_to_internal(
435  const afw_data_type_t * instance,
436  void * to_internal,
437  const afw_utf8_t * from_utf8,
438  const afw_pool_t * p,
439  afw_xctx_t *xctx)
440 {
441  afw_memory_decode_base64(to_internal, from_utf8, p, xctx);
442 }
443 
444 
445 /* Data type boolean to utf8. */
446 static const afw_utf8_t *
447 impl_afw_data_type_boolean_internal_to_utf8(
448  const afw_data_type_t * instance,
449  const void * from_internal,
450  const afw_pool_t * p,
451  afw_xctx_t *xctx)
452 {
453  return (*(afw_boolean_t *)from_internal) ? &afw_s_true : &afw_s_false;
454 }
455 
456 
457 /* Data type boolean to internal. */
458 static void
459 impl_afw_data_type_boolean_utf8_to_internal(
460  const afw_data_type_t * instance,
461  void * to_internal,
462  const afw_utf8_t * from_utf8,
463  const afw_pool_t * p,
464  afw_xctx_t *xctx)
465 {
466  const afw_utf8_octet_t *s;
467  afw_size_t len;
468 
469  s = from_utf8->s;
470  len = from_utf8->len;
471 
472  if (len == 1) {
473  if (*s == '1') {
474  *(afw_boolean_t *)to_internal = AFW_TRUE;
475  } else if (*s == 't') {
476  *(afw_boolean_t *)to_internal = AFW_TRUE;
477  } else if (*s == 'T') {
478  *(afw_boolean_t *)to_internal = AFW_TRUE;
479  } else if (*s == '0') {
480  *(afw_boolean_t *)to_internal = AFW_FALSE;
481  } else if (*s == 'f') {
482  *(afw_boolean_t *)to_internal = AFW_FALSE;
483  } else if (*s == 'F') {
484  *(afw_boolean_t *)to_internal = AFW_FALSE;
485  }
486  } else if (len == 4) {
487  if (*s != 't' && *s != 'T') goto error;
488  s++;
489  if (*s != 'r' && *s != 'R') goto error;
490  s++;
491  if (*s != 'u' && *s != 'U') goto error;
492  s++;
493  if (*s != 'e' && *s != 'E') goto error;
494  *(afw_boolean_t *)to_internal = true;
495  } else if (len == 5) {
496  if (*s != 'f' && *s != 'F') goto error;
497  s++;
498  if (*s != 'a' && *s != 'A') goto error;
499  s++;
500  if (*s != 'l' && *s != 'L') goto error;
501  s++;
502  if (*s != 's' && *s != 'S') goto error;
503  s++;
504  if (*s != 'e' && *s != 'E') goto error;
505  *(afw_boolean_t *)to_internal = false;
506  }
507  else {
508  goto error;
509  }
510 
511  return;
512 
513 error:
514  AFW_THROW_ERROR_FZ(general, xctx,
515  "Not a valid boolean value %" AFW_UTF8_FMT ".",
516  (int)len, s);
517 }
518 
519 
520 /* Data type boolean compare. */
521 static int
522 impl_afw_data_type_boolean_compare_internal(
523  const afw_data_type_t * instance,
524  const void * value1,
525  const void * value2,
526  afw_xctx_t *xctx)
527 {
528  const afw_boolean_t *v1 = value1;
529  const afw_boolean_t *v2 = value2;
530 
531  /* Consider true > false. */
532  if (*v1 == false) {
533  if (*v2 == false) return 0;
534  return -1;
535  }
536  if (*v2 == false) return 1;
537  return 0;
538 }
539 
540 
541 /* Data type date to utf8. */
542 static const afw_utf8_t *
543 impl_afw_data_type_date_internal_to_utf8(
544  const afw_data_type_t * instance,
545  const void * from_internal,
546  const afw_pool_t * p,
547  afw_xctx_t *xctx)
548 {
550  (const afw_date_t *)from_internal, p, xctx);
551 }
552 
553 
554 /* Data type date to internal. */
555 static void
556 impl_afw_data_type_date_utf8_to_internal(
557  const afw_data_type_t * instance,
558  void * to_internal,
559  const afw_utf8_t * from_utf8,
560  const afw_pool_t * p,
561  afw_xctx_t *xctx)
562 {
563  afw_date_utf8_set_internal(from_utf8, (afw_date_t *)to_internal, xctx);
564 }
565 
566 
567 /* Data type date compare internal. */
568 static int
569 impl_afw_data_type_date_compare_internal(
570  const afw_data_type_t * instance,
571  const void * value1,
572  const void * value2,
573  afw_xctx_t *xctx)
574 {
575  return afw_date_compare(value1, value2, xctx);
576 }
577 
578 
579 /* Data type dateTime to utf8. */
580 static const afw_utf8_t *
581 impl_afw_data_type_dateTime_internal_to_utf8(
582  const afw_data_type_t * instance,
583  const void * from_internal,
584  const afw_pool_t * p,
585  afw_xctx_t *xctx)
586 {
588  (const afw_dateTime_t *)from_internal, p, xctx);
589 }
590 
591 
592 /* Data type dateTime to internal. */
593 static void
594 impl_afw_data_type_dateTime_utf8_to_internal(
595  const afw_data_type_t * instance,
596  void * to_internal,
597  const afw_utf8_t * from_utf8,
598  const afw_pool_t * p,
599  afw_xctx_t *xctx)
600 {
602  (afw_dateTime_t *)to_internal, xctx);
603 }
604 
605 
606 /* Data type dateTime compare internal. */
607 static int
608 impl_afw_data_type_dateTime_compare_internal(
609  const afw_data_type_t * instance,
610  const void * value1,
611  const void * value2,
612  afw_xctx_t *xctx)
613 {
614  return afw_dateTime_compare(value1, value2, xctx);
615 }
616 
617 
618 /* Data type dayTimeDuration to utf8. */
619 static const afw_utf8_t *
620 impl_afw_data_type_dayTimeDuration_internal_to_utf8(
621  const afw_data_type_t * instance,
622  const void * from_internal,
623  const afw_pool_t * p,
624  afw_xctx_t *xctx)
625 {
627  (const afw_dayTimeDuration_t *)from_internal, p, xctx);
628 }
629 
630 
631 /* Data type dayTimeDuration to internal. */
632 static void
633 impl_afw_data_type_dayTimeDuration_utf8_to_internal(
634  const afw_data_type_t * instance,
635  void * to_internal,
636  const afw_utf8_t * from_utf8,
637  const afw_pool_t * p,
638  afw_xctx_t *xctx)
639 {
641  (afw_dayTimeDuration_t *)to_internal, xctx);
642 }
643 
644 
645 /* Data type dayTimeDuration compare internal. */
646 static int
647 impl_afw_data_type_dayTimeDuration_compare_internal(
648  const afw_data_type_t * instance,
649  const void * value1,
650  const void * value2,
651  afw_xctx_t *xctx)
652 {
653  return afw_dayTimeDuration_compare(value1, value2, xctx);
654 }
655 
656 
657 /* Data type dnsName to utf8. */
658 static void
659 impl_afw_data_type_dnsName_utf8_to_internal(
660  const afw_data_type_t * instance,
661  void * to_internal,
662  const afw_utf8_t * from_utf8,
663  const afw_pool_t * p,
664  afw_xctx_t *xctx)
665 {
666  /* Input must already be NFC. */
667  memcpy(to_internal, from_utf8, sizeof(afw_utf8_t));
668 }
669 
670 
671 /* Data type double to utf8. */
672 static const afw_utf8_t *
673 impl_afw_data_type_double_internal_to_utf8(
674  const afw_data_type_t * instance,
675  const void * from_internal,
676  const afw_pool_t * p,
677  afw_xctx_t *xctx)
678 {
679  return afw_number_double_to_utf8(*(afw_double_t *)from_internal,
680  p, xctx);
681 }
682 
683 
684 /* Data type double to internal. */
685 static void
686 impl_afw_data_type_double_utf8_to_internal(
687  const afw_data_type_t * instance,
688  void * to_internal,
689  const afw_utf8_t * from_utf8,
690  const afw_pool_t * p,
691  afw_xctx_t *xctx)
692 {
693  afw_double_t d;
694 
695  d = afw_number_utf8_to_double(from_utf8, p, xctx);
696  memcpy(to_internal, &d, sizeof(d));
697 }
698 
699 
700 /* Data type double compare. */
701 /* */
702 /* http://www.gnu.org/software/libc/manual/html_node/Infinity-and-NaN.html */
703 /* In comparison operations, positive infinity is larger than all values */
704 /* except itself and NaN, and negative infinity is smaller than all values */
705 /* except itself and NaN. NaN is unordered: it is not equal to, */
706 /* greater than, or less than anything, including itself. */
707 static int
708 impl_afw_data_type_double_compare_internal(
709  const afw_data_type_t * instance,
710  const void * value1,
711  const void * value2,
712  afw_xctx_t *xctx)
713 {
714  const afw_double_t *v1 = value1;
715  const afw_double_t *v2 = value2;
716 
717  if (afw_number_is_NaN(*v1)) {
719  return 1;
720  else if (afw_number_is_NaN(*v2))
721  return 0;
722  else
723  return -1;
724  };
727  return 0;
728  else
729  return 1;
730  };
733  return 0;
734  else
735  return -1;
736  };
737 
738  if (*v1 == *v2) return 0;
739  if (*v1 > *v2) return 1;
740  return -1;
741 }
742 
743 
744 /* Data type function to utf8. */
745 /* Note: some other impl_* functions call with instance and p set to NULL. */
746 static const afw_utf8_t *
747 impl_afw_data_type_function_internal_to_utf8(
748  const afw_data_type_t * instance,
749  const void * from_internal,
750  const afw_pool_t * p,
751  afw_xctx_t *xctx)
752 {
753  const afw_value_t *value = from_internal;
754  const afw_utf8_t *result;
755 
756  if (afw_value_is_string(value)) {
757  result = AFW_VALUE_INTERNAL(value);
758  }
759  else if (afw_value_is_function_definition(value)) {
760  result = &((const afw_value_function_definition_t *)value)->functionId;
761  }
762  else if (afw_value_is_script_function(value)) {
763  result = ((const afw_value_script_function_definition_t *)value)->
764  contextual->compiled_value->full_source;
765  }
766  else {
767  result = &afw_s_a_empty_string;
773  }
774 
775  return result;
776 }
777 
778 
779 /* Data type function to internal. */
780 static void
781 impl_afw_data_type_function_utf8_to_internal(
782  const afw_data_type_t * instance,
783  void * to_internal,
784  const afw_utf8_t * from_utf8,
785  const afw_pool_t * p,
786  afw_xctx_t *xctx)
787 {
788  const afw_value_t *value;
789 
790  value = afw_value_create_string(from_utf8, p, xctx);
791  memcpy(to_internal, (const void *)&value, sizeof(afw_value_t *));
792 }
793 
794 
795 /* Data type function compare. */
796 static int
797 impl_afw_data_type_function_compare_internal(
798  const afw_data_type_t * instance,
799  const void * value1,
800  const void * value2,
801  afw_xctx_t *xctx)
802 {
803  /* The address of function is used for comparison purposes. */
804  return (value1 == value2) ? 0 : (value1 > value2) ? 1 : -1;
805 }
806 
807 
808 /* Data type function clone. */
809 static void
810 impl_afw_data_type_function_clone_internal(
811  const afw_data_type_t * instance,
812  void * to_internal,
813  const void * from_internal,
814  const afw_pool_t *p,
815  afw_xctx_t *xctx)
816 {
817  const afw_utf8_t *s;
818  const afw_value_t *value;
819 
820  s = impl_afw_data_type_function_internal_to_utf8(
821  NULL, from_internal, NULL, xctx);
822  value = afw_value_create_string(s, p, xctx);
823  memcpy(to_internal, (const void *)&value, sizeof(afw_value_t *));
824 }
825 
826 
827 /* Data type hexBinary to utf8. */
828 static const afw_utf8_t *
829 impl_afw_data_type_hexBinary_internal_to_utf8(
830  const afw_data_type_t * instance,
831  const void * from_internal,
832  const afw_pool_t * p,
833  afw_xctx_t *xctx)
834 {
835  afw_utf8_t *encoded;
836 
837  encoded = afw_pool_calloc_type(p, afw_utf8_t, xctx);
839  encoded,
840  (const afw_memory_t *)from_internal,
841  p, xctx);
842 
843  return encoded;
844 }
845 
846 
847 /* Data type hexBinary to internal. */
848 static void
849 impl_afw_data_type_hexBinary_utf8_to_internal(
850  const afw_data_type_t * instance,
851  void * to_internal,
852  const afw_utf8_t * from_utf8,
853  const afw_pool_t * p,
854  afw_xctx_t *xctx)
855 {
856  afw_memory_decode_printable_hex((afw_memory_t *)to_internal, from_utf8, p, xctx);
857 }
858 
859 
860 /* Data type ia5String ... */
861 
862 /* Data type ia5String to utf8. */
863 static void
864 impl_afw_data_type_ia5String_utf8_to_internal(
865  const afw_data_type_t * instance,
866  void * to_internal,
867  const afw_utf8_t * from_utf8,
868  const afw_pool_t * p,
869  afw_xctx_t *xctx)
870 {
871  /* Input must already be NFC. */
872  memcpy(to_internal, from_utf8, sizeof(afw_utf8_t));
873 }
874 
875 
876 /* Data type integer to utf8. */
877 static const afw_utf8_t *
878 impl_afw_data_type_integer_internal_to_utf8(
879  const afw_data_type_t * instance,
880  const void * from_internal,
881  const afw_pool_t * p,
882  afw_xctx_t *xctx)
883 {
885  *(afw_integer_t *)from_internal, p, xctx);
886 }
887 
888 
889 /* Data type integer to internal. */
890 static void
891 impl_afw_data_type_integer_utf8_to_internal(
892  const afw_data_type_t * instance,
893  void * to_internal,
894  const afw_utf8_t * from_utf8,
895  const afw_pool_t * p,
896  afw_xctx_t *xctx)
897 {
898  afw_integer_t i;
899 
900  i = afw_number_utf8_to_integer(from_utf8, p, xctx);
901  memcpy(to_internal, &i, sizeof(i));
902 }
903 
904 
905 /* Data type integer compare. */
906 static int
907 impl_afw_data_type_integer_compare_internal(
908  const afw_data_type_t * instance,
909  const void * value1,
910  const void * value2,
911  afw_xctx_t *xctx)
912 {
913  const afw_integer_t *v1 = value1;
914  const afw_integer_t *v2 = value2;
915 
916  /* Done this way because afw_integer_t may be larger than int. */
917  if (*v1 == *v2) return 0;
918  if (*v1 > *v2) return 1;
919  return -1;
920 }
921 
922 
923 /* Data type ipAddress to internal. */
924 static void
925 impl_afw_data_type_ipAddress_utf8_to_internal(
926  const afw_data_type_t * instance,
927  void * to_internal,
928  const afw_utf8_t * from_utf8,
929  const afw_pool_t * p,
930  afw_xctx_t *xctx)
931 {
932  /* Input must already be NFC. */
933  memcpy(to_internal, from_utf8, sizeof(afw_utf8_t));
934 }
935 
936 
937 /* Data type list to utf8. */
938 static const afw_utf8_t *
939 impl_afw_data_type_list_internal_to_utf8(
940  const afw_data_type_t * instance,
941  const void * from_internal,
942  const afw_pool_t * p,
943  afw_xctx_t *xctx)
944 {
945  afw_value_list_t list;
946 
947  list.inf = &afw_value_evaluated_list_inf;
948  list.internal = *(const afw_list_t **)from_internal;
949  return afw_json_from_value((const afw_value_t *)&list, NULL,
950  p, xctx);
951 }
952 
953 
954 /* Data type list to internal. */
955 static void
956 impl_afw_data_type_list_utf8_to_internal(
957  const afw_data_type_t * instance,
958  void * to_internal,
959  const afw_utf8_t * from_utf8,
960  const afw_pool_t * p,
961  afw_xctx_t *xctx)
962 {
963  const afw_value_t *value;
964 
965  value = afw_json_to_value(from_utf8, NULL, p, xctx);
966 
967  AFW_VALUE_ASSERT_IS_DATA_TYPE(value, list, xctx);
968 
969  *((const afw_list_t **)to_internal) =
970  ((afw_value_list_t *)value)->internal;
971 }
972 
973 
974 /* Data type list compare. */
975 static int
976 impl_afw_data_type_list_compare_internal(
977  const afw_data_type_t * instance,
978  const void * value1,
979  const void * value2,
980  afw_xctx_t *xctx)
981 {
982  const afw_list_t *list1 = *(const afw_list_t * const *)value1;
983  const afw_list_t *list2 = *(const afw_list_t * const *)value2;
984  const afw_iterator_t *iterator1;
985  const afw_iterator_t *iterator2;
986  const void *internal1;
987  const void *internal2;
988  const afw_data_type_t *data_type1;
989  const afw_data_type_t *data_type2;
990  int result;
991 
992  for (iterator1 = NULL, iterator2 = NULL, result = 0; result == 0;) {
993  afw_list_get_next_internal(list1, &iterator1,
994  &data_type1, &internal1, xctx);
995  afw_list_get_next_internal(list2, &iterator2,
996  &data_type2, &internal2, xctx);
997 
998  if (!internal1) {
999  if (internal2) {
1000  result = -1;
1001  }
1002  break;
1003  }
1004 
1005  if (!internal2) {
1006  result = 1;
1007  break;
1008  }
1009 
1010  if (!data_type1) {
1011  AFW_THROW_ERROR_Z(general,
1012  "list needs data type for compare",
1013  xctx);
1014  }
1015 
1016  if (data_type1 != data_type2) {
1017  result = 1;
1018  break;
1019  }
1020 
1022  data_type1, internal1, internal2, xctx);
1023  }
1024 
1025  return result;
1026 }
1027 
1028 
1029 /* Data type null to utf8. */
1030 static const afw_utf8_t *
1031 impl_afw_data_type_null_internal_to_utf8(
1032  const afw_data_type_t * instance,
1033  const void * from_internal,
1034  const afw_pool_t * p,
1035  afw_xctx_t *xctx)
1036 {
1037  return &afw_s_null;
1038 }
1039 
1040 
1041 /* Data type null to internal. */
1042 static void
1043 impl_afw_data_type_null_utf8_to_internal(
1044  const afw_data_type_t * instance,
1045  void * to_internal,
1046  const afw_utf8_t * from_utf8,
1047  const afw_pool_t * p,
1048  afw_xctx_t *xctx)
1049 {
1050  memset(to_internal, 0, sizeof(void *));
1051 }
1052 
1053 
1054 /* Data type null compare. */
1055 static int
1056 impl_afw_data_type_null_compare_internal(
1057  const afw_data_type_t * instance,
1058  const void * value1,
1059  const void * value2,
1060  afw_xctx_t *xctx)
1061 {
1062  /* Null has no value so comparing two nulls is always true. */
1063  return 0;
1064 }
1065 
1066 
1067 /* Data type object to utf8. */
1068 static const afw_utf8_t *
1069 impl_afw_data_type_object_internal_to_utf8(
1070  const afw_data_type_t * instance,
1071  const void * from_internal,
1072  const afw_pool_t * p,
1073  afw_xctx_t *xctx)
1074 {
1075  afw_value_object_t obj;
1076 
1077  obj.inf = &afw_value_evaluated_object_inf;
1078  obj.internal = *(const afw_object_t **)from_internal;
1079 
1080  return afw_json_from_value((const afw_value_t *)&obj,
1081  NULL, p, xctx);
1082 }
1083 
1084 
1085 /* Data type object to internal. */
1086 static void
1087 impl_afw_data_type_object_utf8_to_internal(
1088  const afw_data_type_t * instance,
1089  void * to_internal,
1090  const afw_utf8_t * from_utf8,
1091  const afw_pool_t * p,
1092  afw_xctx_t *xctx)
1093 {
1094  const afw_value_t *value;
1095 
1096  value = afw_json_to_value(from_utf8, NULL, p, xctx);
1097 
1098  AFW_VALUE_ASSERT_IS_DATA_TYPE(value, object, xctx);
1099 
1100  *((const afw_object_t **)to_internal) =
1101  ((afw_value_object_t *)value)->internal;
1102 }
1103 
1104 
1105 /* Data type object compare. */
1106 static int
1107 impl_afw_data_type_object_compare_internal(
1108  const afw_data_type_t * instance,
1109  const void * value1,
1110  const void * value2,
1111  afw_xctx_t *xctx)
1112 {
1113  const afw_object_t *o1;
1114  const afw_object_t *o2;
1115  const afw_value_t *v1;
1116  const afw_value_t *v2;
1117  const afw_utf8_t *property_name;
1118  afw_size_t count1, count2;
1119  const afw_iterator_t *iterator;
1120 
1121  /* Get object 1 & 2 pointer. */
1122  o1 = *(const afw_object_t **)value1;
1123  o2 = *(const afw_object_t **)value2;
1124 
1125  /* Compare matching properties. Return -1 if one doesn't match. */
1126  iterator = NULL;
1127  count1 = 0;
1128  while ((v1 = afw_object_get_next_property(o1, &iterator, &property_name,
1129  xctx)))
1130  {
1131  count1++;
1132  v2 = afw_object_get_property(o2, property_name, xctx);
1133  if (!afw_value_equal(v1, v2, xctx)) {
1134  return -1;
1135  }
1136  }
1137 
1138  /* Count properties in second object. */
1139  iterator = NULL;
1140  count2 = 0;
1141  while (afw_object_get_next_property(o2, &iterator, &property_name, xctx))
1142  {
1143  count2++;
1144  }
1145 
1146  /* Return 0 if same number of entries else -1. */
1147  return (count1 == count2) ? 0 : -1;
1148 }
1149 
1150 
1151 /* Data type objectId to utf8. */
1152 static void
1153 impl_afw_data_type_objectId_utf8_to_internal(
1154  const afw_data_type_t * instance,
1155  void * to_internal,
1156  const afw_utf8_t * from_utf8,
1157  const afw_pool_t * p,
1158  afw_xctx_t *xctx)
1159 {
1160  /* Input must already be NFC. */
1161  memcpy(to_internal, from_utf8, sizeof(afw_utf8_t));
1162 }
1163 
1164 
1165 /* Data type objectPath to utf8. */
1166 static void
1167 impl_afw_data_type_objectPath_utf8_to_internal(
1168  const afw_data_type_t * instance,
1169  void * to_internal,
1170  const afw_utf8_t * from_utf8,
1171  const afw_pool_t * p,
1172  afw_xctx_t *xctx)
1173 {
1174  /* Input must already be NFC. */
1175  memcpy(to_internal, from_utf8, sizeof(afw_utf8_t));
1176 }
1177 
1178 
1179 /* Data type rfc822Name to utf8. */
1180 static void
1181 impl_afw_data_type_rfc822Name_utf8_to_internal(
1182  const afw_data_type_t * instance,
1183  void * to_internal,
1184  const afw_utf8_t * from_utf8,
1185  const afw_pool_t * p,
1186  afw_xctx_t *xctx)
1187 {
1188  /* Input must already be NFC. */
1189  memcpy(to_internal, from_utf8, sizeof(afw_utf8_t));
1190 }
1191 
1192 
1193 /* Data type time to utf8. */
1194 static const afw_utf8_t *
1195 impl_afw_data_type_time_internal_to_utf8(
1196  const afw_data_type_t * instance,
1197  const void * from_internal,
1198  const afw_pool_t * p,
1199  afw_xctx_t *xctx)
1200 {
1202  (const afw_time_t *)from_internal, p, xctx);
1203 }
1204 
1205 
1206 /* Data type time to internal. */
1207 static void
1208 impl_afw_data_type_time_utf8_to_internal(
1209  const afw_data_type_t * instance,
1210  void * to_internal,
1211  const afw_utf8_t * from_utf8,
1212  const afw_pool_t * p,
1213  afw_xctx_t *xctx)
1214 {
1215  afw_time_utf8_set_internal(from_utf8, (afw_time_t *)to_internal, xctx);
1216 }
1217 
1218 
1219 /* Data type time compare internal. */
1220 static int
1221 impl_afw_data_type_time_compare_internal(
1222  const afw_data_type_t * instance,
1223  const void * value1,
1224  const void * value2,
1225  afw_xctx_t *xctx)
1226 {
1227  return afw_time_compare(value1, value2, xctx);
1228 }
1229 
1230 
1231 /* Data type x500Name to internal. */
1232 static void
1233 impl_afw_data_type_x500Name_utf8_to_internal(
1234  const afw_data_type_t * instance,
1235  void * to_internal,
1236  const afw_utf8_t * from_utf8,
1237  const afw_pool_t * p,
1238  afw_xctx_t *xctx)
1239 {
1240  /* Input must already be NFC. */
1241  memcpy(to_internal, from_utf8, sizeof(afw_utf8_t));
1242 }
1243 
1244 
1245 /* Data type yearMonthDuration to utf8. */
1246 static const afw_utf8_t *
1247 impl_afw_data_type_yearMonthDuration_internal_to_utf8(
1248  const afw_data_type_t * instance,
1249  const void * from_internal,
1250  const afw_pool_t * p,
1251  afw_xctx_t *xctx)
1252 {
1254  (const afw_yearMonthDuration_t *)from_internal, p, xctx);
1255 }
1256 
1257 
1258 /* Data type yearMonthDuration to internal. */
1259 static void
1260 impl_afw_data_type_yearMonthDuration_utf8_to_internal(
1261  const afw_data_type_t * instance,
1262  void * to_internal,
1263  const afw_utf8_t * from_utf8,
1264  const afw_pool_t * p,
1265  afw_xctx_t *xctx)
1266 {
1268  (afw_yearMonthDuration_t *)to_internal, xctx);
1269 }
1270 
1271 
1272 /* Data type yearMonthDuration compare internal. */
1273 static int
1274 impl_afw_data_type_yearMonthDuration_compare_internal(
1275  const afw_data_type_t * instance,
1276  const void * value1,
1277  const void * value2,
1278  afw_xctx_t *xctx)
1279 {
1280  return afw_yearMonthDuration_compare(value1, value2, xctx);
1281 }
1282 
1283 
1284 /* ---- Common clone ------------------------------------------------------*/
1285 
1286 /* utf8 clone. */
1287 static void
1288 impl_afw_data_type_utf8_clone_internal(
1289  const afw_data_type_t * instance,
1290  void * to_internal,
1291  const void * from_internal,
1292  const afw_pool_t *p,
1293  afw_xctx_t *xctx)
1294 {
1295  const afw_utf8_t *from;
1296  afw_utf8_t *to;
1297  afw_utf8_octet_t *s;
1298 
1299  memset(to_internal, 0, sizeof(afw_utf8_t));
1300  from = from_internal;
1301  if (from->len > 0) {
1302  s = afw_pool_malloc(p, from->len, xctx);
1303  to = to_internal;
1304  to->s = s;
1305  to->len = from->len;
1306  memcpy(s, from->s, from->len);
1307  }
1308 }
1309 
1310 
1311 /* raw clone. */
1312 static void
1313 impl_afw_data_type_raw_clone_internal(
1314  const afw_data_type_t * instance,
1315  void * to_internal,
1316  const void * from_internal,
1317  const afw_pool_t *p,
1318  afw_xctx_t *xctx)
1319 {
1320  const afw_memory_t *from;
1321  afw_memory_t *to;
1322  afw_byte_t *ptr;
1323 
1324  memset(to_internal, 0, sizeof(afw_utf8_t));
1325  from = from_internal;
1326  if (from->size > 0) {
1327  ptr = afw_pool_malloc(p, from->size, xctx);
1328  to = to_internal;
1329  to->ptr = ptr;
1330  to->size = from->size;
1331  memcpy(ptr, from->ptr, from->size);
1332  }
1333 }
1334 
1335 
1336 /* direct clone. */
1337 static void
1338 impl_afw_data_type_direct_clone_internal(
1339  const afw_data_type_t * instance,
1340  void * to_internal,
1341  const void * from_internal,
1342  const afw_pool_t *p,
1343  afw_xctx_t *xctx)
1344 {
1345  memcpy(to_internal, from_internal, instance->c_type_size);
1346 }
1347 
1348 
1349 /* list clone. */
1350 static void
1351 impl_afw_data_type_list_clone_internal(
1352  const afw_data_type_t * instance,
1353  void * to_internal,
1354  const void * from_internal,
1355  const afw_pool_t *p,
1356  afw_xctx_t *xctx)
1357 {
1358  const afw_list_t *from;
1359  const afw_list_t *to;
1360  const afw_iterator_t *iterator;
1361  const afw_value_t *value;
1362  const afw_value_t *cloned_value;
1363  const afw_data_type_t *data_type;
1364 
1365  from = *(const afw_list_t * *)from_internal;
1366  data_type = afw_list_get_data_type(from, xctx);
1367  to = afw_list_of_create(data_type, p, xctx);
1368  memcpy(to_internal, &to, sizeof(const afw_list_t *));
1369 
1370  for (iterator = NULL;;) {
1371  value = afw_list_get_next_value(from, &iterator, p, xctx);
1372  if (!value) break;
1373  cloned_value = afw_value_clone(value, p, xctx);
1374  afw_list_add_value(to, cloned_value, xctx);
1375  }
1376 }
1377 
1378 
1379 
1380 /* Clone object properties and meta. */
1381 static void
1382 impl_object_clone_properties_and_meta(
1383  const afw_object_t *to,
1384  const afw_object_t *from,
1385  const afw_object_t *embedding_object,
1386  afw_xctx_t *xctx)
1387 {
1388  const afw_pool_t *p = to->p;
1389  const afw_iterator_t *iterator;
1390  const afw_value_t *value;
1391  const afw_utf8_t *property_name;
1392  afw_object_meta_t *to_meta;
1393  const afw_object_t *delta;
1394 
1395  /* Set to meta directly. */
1396  to_meta = (afw_object_meta_t *)&to->meta;
1397 
1398  /* If const object, no clone is needed of ids. */
1399  if (!from->p) {
1400  to_meta->object_type_uri =
1402  to_meta->id = from->meta.id;
1403  to_meta->object_uri = from->meta.object_uri;
1404  }
1405 
1406  /* If not const object, clone ids. */
1407  else {
1408  if (from->meta.object_type_uri) {
1409  to_meta->object_type_uri = afw_utf8_clone(
1410  from->meta.object_type_uri,
1411  p, xctx);
1412  }
1413  if (!to->meta.embedding_object && from->meta.id)
1414  {
1415  to_meta->id = afw_utf8_clone(from->meta.id, p, xctx);
1416  }
1417  if (!to->meta.embedding_object && from->meta.object_uri)
1418  {
1419  to_meta->object_uri =
1420  afw_utf8_clone(from->meta.object_uri, p, xctx);
1421  }
1422  }
1423 
1424  /* Get meta info. */
1425  if (from->meta.meta_object) {
1426  delta = afw_object_meta_get_nonempty_delta(to, xctx);
1427  impl_object_clone_properties_and_meta(
1428  delta, from->meta.meta_object, NULL, xctx);
1429  }
1430 
1431  /* Clone properties. */
1432  for (iterator = NULL;;) {
1433  value = afw_object_get_next_property(from,
1434  &iterator, &property_name, xctx);
1435  if (!value) break;
1436  impl_clone_and_set_property(to, property_name, value,
1437  xctx);
1438  }
1439 }
1440 
1441 
1442 
1443 AFW_DEFINE_STATIC_INLINE(void)
1444 impl_clone_embedded_object(
1445  const afw_object_t * *to,
1446  const afw_object_t *from,
1447  const afw_object_t *embedding_object,
1448  const afw_utf8_t *property_name,
1449  afw_xctx_t *xctx)
1450 {
1452  embedding_object, property_name,
1453  xctx);
1454 
1455  impl_object_clone_properties_and_meta(*to, from,
1456  embedding_object, xctx);
1457 }
1458 
1459 
1460 
1461 static void
1462 impl_clone_and_set_property(
1463  const afw_object_t *obj,
1464  const afw_utf8_t *property_name,
1465  const afw_value_t *value,
1466  afw_xctx_t *xctx)
1467 {
1468  const afw_value_t *cloned_value;
1469  const afw_pool_t *p = obj->p;
1470 
1471  /* Clone property name.*/
1472  property_name = afw_utf8_clone(property_name, p, xctx);
1473 
1474  /* If object, handle special to support embedding object. */
1475  if (afw_value_is_object(value)) {
1476  cloned_value = (const afw_value_t *)
1477  afw_value_allocate_object(p, xctx);
1478  impl_clone_embedded_object(
1479  &((afw_value_object_t *)cloned_value)->internal,
1480  ((const afw_value_object_t *)value)->internal,
1481  obj, property_name, xctx);
1482  }
1483 
1484  /* Other cases, just use normal value clone. */
1485  else {
1486  cloned_value = afw_value_clone(value, p, xctx);
1487  }
1488 
1489  /* Set property to cloned value. */
1491  afw_utf8_clone(property_name, p, xctx),
1492  cloned_value, xctx);
1493 }
1494 
1495 
1496 
1497 /* object clone. */
1498 static void
1499 impl_afw_data_type_object_clone_internal(
1500  const afw_data_type_t * instance,
1501  void * to_internal,
1502  const void * from_internal,
1503  const afw_pool_t *p,
1504  afw_xctx_t *xctx)
1505 {
1506  const afw_object_t *from;
1507  const afw_object_t *to;
1508 
1509  from = *(const afw_object_t * *)from_internal;
1510  to = afw_object_create(p, xctx);
1511  memcpy(to_internal, &to, sizeof(const afw_object_t *));
1512  impl_object_clone_properties_and_meta(to, from, NULL, xctx);
1513 }
1514 
1515 
1516 
1517 
1518 /* Clone an object to a managed object. */
1519 AFW_DEFINE(const afw_object_t *)
1521  const afw_object_t * object,
1522  const afw_pool_t *p,
1523  afw_xctx_t *xctx)
1524 {
1525  const afw_object_t *result;
1526 
1527  result = afw_object_create_managed(p, xctx);
1528  impl_object_clone_properties_and_meta(result, object, NULL, xctx);
1529 
1530  return result;
1531 }
1532 
1533 
1534 
1535 /* ---- Value compiler listing -----------------------------------*/
1536 
1537 static void
1538 impl_afw_data_type_double_value_compiler_listing(
1539  const afw_data_type_t *instance,
1540  const afw_writer_t *writer,
1541  const afw_value_t *value,
1542  afw_xctx_t *xctx)
1543 {
1544  const afw_utf8_t *string;
1545 
1546  afw_value_compiler_listing_begin_value(writer, value, NULL, xctx);
1547  afw_writer_write_z(writer, " ", xctx);
1549  instance,
1550  AFW_VALUE_INTERNAL(value),
1551  writer->p, xctx);
1552  afw_writer_write_utf8(writer, string, xctx);
1553  afw_writer_write_eol(writer, xctx);
1554 }
1555 
1556 
1557 static void
1558 impl_afw_data_type_boolean_value_compiler_listing(
1559  const afw_data_type_t *instance,
1560  const afw_writer_t *writer,
1561  const afw_value_t *value,
1562  afw_xctx_t *xctx)
1563 {
1564  afw_value_compiler_listing_begin_value(writer, value, NULL, xctx);
1565  afw_writer_write_z(writer, " ", xctx);
1566 
1567  if (((const afw_value_boolean_t *)value)->internal) {
1568  afw_writer_write_z(writer, "true", xctx);
1569  }
1570  else {
1571  afw_writer_write_z(writer, "false", xctx);
1572  }
1573  afw_writer_write_eol(writer, xctx);
1574 }
1575 
1576 
1577 
1578 static void
1579 impl_afw_data_type_function_value_compiler_listing(
1580  const afw_data_type_t *instance,
1581  const afw_writer_t *writer,
1582  const afw_value_t *value,
1583  afw_xctx_t *xctx)
1584 {
1585  const afw_utf8_t *string;
1586 
1588  afw_value_compiler_listing_begin_value(writer, value, NULL, xctx);
1589  afw_writer_write_z(writer, " ", xctx);
1591  instance,
1592  AFW_VALUE_INTERNAL(value),
1593  writer->p, xctx);
1594  afw_writer_write_utf8(writer, string, xctx);
1595  afw_writer_write_eol(writer, xctx);
1596 }
1597 
1598 
1599 
1600 static void
1601 impl_afw_data_type_integer_value_compiler_listing(
1602  const afw_data_type_t *instance,
1603  const afw_writer_t *writer,
1604  const afw_value_t *value,
1605  afw_xctx_t *xctx)
1606 {
1607  const afw_utf8_t *string;
1608 
1609  afw_value_compiler_listing_begin_value(writer, value, NULL, xctx);
1610  afw_writer_write_z(writer, " ", xctx);
1612  instance,
1613  AFW_VALUE_INTERNAL(value),
1614  writer->p, xctx);
1615  afw_writer_write_utf8(writer, string, xctx);
1616  afw_writer_write_eol(writer, xctx);
1617 }
1618 
1619 
1620 static void
1621 impl_afw_data_type_null_value_compiler_listing(
1622  const afw_data_type_t *instance,
1623  const afw_writer_t *writer,
1624  const afw_value_t *value,
1625  afw_xctx_t *xctx)
1626 {
1627  afw_value_compiler_listing_begin_value(writer, value, NULL, xctx);
1628  afw_writer_write_z(writer, " null", xctx);
1629  afw_writer_write_eol(writer, xctx);
1630 }
1631 
1632 
1633 static void
1634 impl_afw_data_type_utf8_value_compiler_listing(
1635  const afw_data_type_t *instance,
1636  const afw_writer_t *writer,
1637  const afw_value_t *value,
1638  afw_xctx_t *xctx)
1639 {
1640  afw_value_compiler_listing_begin_value(writer, value, NULL, xctx);
1641  afw_writer_write_z(writer, " ", xctx);
1643  AFW_VALUE_INTERNAL(value),
1644  writer, xctx);
1645  afw_writer_write_eol(writer, xctx);
1646 }
1647 
1648 
1649 
1650 static void
1651 impl_afw_data_type_typed_to_string_value_compiler_listing(
1652  const afw_data_type_t *instance,
1653  const afw_writer_t *writer,
1654  const afw_value_t *value,
1655  afw_xctx_t *xctx)
1656 {
1657  const afw_utf8_t *string;
1658 
1659  afw_value_compiler_listing_begin_value(writer, value, NULL, xctx);
1660  afw_writer_write_z(writer, " ", xctx);
1661  string = afw_data_type_internal_to_utf8(instance,
1662  AFW_VALUE_INTERNAL(value), writer->p, xctx);
1664  string, writer, xctx);
1665  afw_writer_write_eol(writer, xctx);
1666 }
1667 
1668 
1669 static void
1670 impl_afw_data_type_list_value_compiler_listing(
1671  const afw_data_type_t *instance,
1672  const afw_writer_t *writer,
1673  const afw_value_t *value,
1674  afw_xctx_t *xctx)
1675 {
1676  const afw_list_t *list;
1677  const afw_iterator_t *iterator;
1678  const afw_value_t *entry;
1679 
1680  list = ((const afw_value_list_t *)value)->internal;
1681  afw_value_compiler_listing_begin_value(writer, value, NULL, xctx);
1682  afw_writer_write_z(writer, ": [", xctx);
1683  afw_writer_write_eol(writer, xctx);
1684  afw_writer_increment_indent(writer, xctx);
1685 
1686  for (iterator = NULL;;)
1687  {
1688  entry = afw_list_get_next_value(list, &iterator, writer->p, xctx);
1689  if (!entry) break;
1690  afw_value_compiler_listing_value(entry, writer, xctx);
1691  }
1692 
1693  afw_writer_decrement_indent(writer, xctx);
1694  afw_writer_write_z(writer, "]", xctx);
1695  afw_writer_write_eol(writer, xctx);
1696 }
1697 
1698 
1699 static void
1700 impl_afw_data_type_object_value_compiler_listing(
1701  const afw_data_type_t *instance,
1702  const afw_writer_t *writer,
1703  const afw_value_t *value,
1704  afw_xctx_t *xctx)
1705 {
1706  const afw_object_t *object;
1707  const afw_iterator_t *iterator;
1708  const afw_value_t *pv;
1709  const afw_utf8_t *property_name;
1710 
1711  object = ((const afw_value_object_t *)value)->internal;
1712  afw_value_compiler_listing_begin_value(writer, value, NULL, xctx);
1713  afw_writer_write_z(writer, ": [", xctx);
1714  afw_writer_write_eol(writer, xctx);
1715  afw_writer_increment_indent(writer, xctx);
1716 
1717  for (iterator = NULL;;)
1718  {
1719  pv = afw_object_get_next_property(object,
1720  &iterator, &property_name, xctx);
1721  if (!pv) break;
1722  afw_writer_write_z(writer, "property ", xctx);
1723  afw_writer_write_utf8(writer, property_name, xctx);
1724  afw_writer_write_z(writer, " ", xctx);
1725  afw_value_compiler_listing_value(pv, writer, xctx);
1726  }
1727 
1728  afw_writer_decrement_indent(writer, xctx);
1729  afw_writer_write_z(writer, "]", xctx);
1730  afw_writer_write_eol(writer, xctx);
1731 }
1732 
1733 
1734 
1735 /* ---- Write as expression -------------------------------------------------*/
1736 
1737 static void
1738 impl_afw_data_type_double_write_as_expression(
1739  const afw_data_type_t *instance,
1740  const afw_writer_t *writer,
1741  const void *from_internal,
1742  afw_xctx_t *xctx)
1743 {
1744  const afw_utf8_t *string;
1745 
1747  instance,
1748  from_internal,
1749  writer->p, xctx);
1750  afw_writer_write_utf8(writer, string, xctx);
1751 }
1752 
1753 
1754 static void
1755 impl_afw_data_type_boolean_write_as_expression(
1756  const afw_data_type_t *instance,
1757  const afw_writer_t *writer,
1758  const void *from_internal,
1759  afw_xctx_t *xctx)
1760 {
1761  if (*(const afw_boolean_t *)from_internal) {
1762  afw_writer_write_z(writer, "true", xctx);
1763  }
1764  else {
1765  afw_writer_write_z(writer, "false", xctx);
1766  }
1767 }
1768 
1769 
1770 static void
1771 impl_afw_data_type_integer_write_as_expression(
1772  const afw_data_type_t *instance,
1773  const afw_writer_t *writer,
1774  const void *from_internal,
1775  afw_xctx_t *xctx)
1776 {
1777  const afw_utf8_t *string;
1778 
1780  instance,
1781  from_internal,
1782  writer->p, xctx);
1783  afw_writer_write_utf8(writer, string, xctx);
1784 }
1785 
1786 
1787 static void
1788 impl_afw_data_type_null_write_as_expression(
1789  const afw_data_type_t *instance,
1790  const afw_writer_t *writer,
1791  const void *from_internal,
1792  afw_xctx_t *xctx)
1793 {
1794  afw_writer_write_z(writer, "null", xctx);
1795 }
1796 
1797 
1798 static void
1799 impl_afw_data_type_string_write_as_expression(
1800  const afw_data_type_t *instance,
1801  const afw_writer_t *writer,
1802  const void *from_internal,
1803  afw_xctx_t *xctx)
1804 {
1806  (const afw_utf8_t *)from_internal,
1807  writer, xctx);
1808 }
1809 
1810 
1811 static void
1812 impl_afw_data_type_typed_string_write_as_expression(
1813  const afw_data_type_t *instance,
1814  const afw_writer_t *writer,
1815  const void *from_internal,
1816  afw_xctx_t *xctx)
1817 {
1818  afw_writer_write_utf8(writer, &instance->data_type_id, xctx);
1819  afw_writer_write_z(writer, "(", xctx);
1821  (const afw_utf8_t *)from_internal,
1822  writer, xctx);
1823  afw_writer_write_z(writer, ")", xctx);
1824 }
1825 
1826 
1827 static void
1828 impl_afw_data_type_typed_to_string_write_as_expression(
1829  const afw_data_type_t *instance,
1830  const afw_writer_t *writer,
1831  const void *from_internal,
1832  afw_xctx_t *xctx)
1833 {
1834  const afw_utf8_t *string;
1835 
1836  string = afw_data_type_internal_to_utf8(instance, from_internal,
1837  writer->p, xctx);
1838  afw_writer_write_utf8(writer, &instance->data_type_id, xctx);
1839  afw_writer_write_z(writer, "(", xctx);
1841  string, writer, xctx);
1842  afw_writer_write_z(writer, ")", xctx);
1843 }
1844 
1845 
1846 static void
1847 impl_afw_data_type_list_write_as_expression(
1848  const afw_data_type_t *instance,
1849  const afw_writer_t *writer,
1850  const void *from_internal,
1851  afw_xctx_t *xctx)
1852 {
1853  const afw_list_t *list;
1854  const afw_iterator_t *iterator;
1855  const afw_value_t *value;
1856  afw_size_t i;
1857 
1858  list = *(const afw_list_t * const *)from_internal;
1859 
1860  afw_writer_write_z(writer, "[", xctx);
1861  if (writer->tab) {
1862  afw_writer_increment_indent(writer, xctx);
1863  }
1864 
1865  for (i = 0, iterator = NULL;
1866  (value = afw_list_get_next_value(list, &iterator, writer->p, xctx));
1867  i++)
1868  {
1869  if (i != 0) {
1870  afw_writer_write_z(writer, ",", xctx);
1871  }
1872  if (writer->tab) {
1873  afw_writer_write_eol(writer, xctx);
1874  }
1875  afw_value_decompile_value(value, writer, xctx);
1876  }
1877 
1878  if (writer->tab) {
1879  afw_writer_write_eol(writer, xctx);
1880  afw_writer_decrement_indent(writer, xctx);
1881  }
1882  afw_writer_write_z(writer, "]", xctx);
1883 
1884 }
1885 
1886 
1887 static void
1888 impl_afw_data_type_object_write_as_expression(
1889  const afw_data_type_t *instance,
1890  const afw_writer_t *writer,
1891  const void *from_internal,
1892  afw_xctx_t *xctx)
1893 {
1894  const afw_object_t *object;
1895  const afw_iterator_t *iterator;
1896  const afw_value_t *value;
1897  const afw_utf8_t *property_name;
1898  afw_size_t i;
1899 
1900  object = *(const afw_object_t * const *)from_internal;
1901 
1902  afw_writer_write_z(writer, "{", xctx);
1903  if (writer->tab) {
1904  afw_writer_increment_indent(writer, xctx);
1905  }
1906 
1907  for (i = 0, iterator = NULL;
1908  (value = afw_object_get_next_property(object,
1909  &iterator, &property_name, xctx));
1910  i++)
1911  {
1912  if (i != 0) {
1913  afw_writer_write_z(writer, ",", xctx);
1914  }
1915  if (writer->tab) {
1916  afw_writer_write_eol(writer, xctx);
1917  }
1918  afw_json_write_encoded_string(property_name, writer, xctx);
1919  if (writer->tab) {
1920  /* if there is any tab argument, use one space to separate property keys from values */
1921  afw_writer_write_z(writer, ": ", xctx);
1922  } else {
1923  afw_writer_write_z(writer, ":", xctx);
1924  }
1925  afw_value_decompile_value(value, writer, xctx);
1926  }
1927 
1928  if (writer->tab) {
1929  afw_writer_write_eol(writer, xctx);
1930  afw_writer_decrement_indent(writer, xctx);
1931  }
1932  afw_writer_write_z(writer, "}", xctx);
1933 }
1934 
1935 
1936 /* ---- Not implemented methods -------------------------------------------- */
1937 
1938 static void
1939 impl_afw_data_type_evaluate_utf8_to_internal(
1940  const afw_data_type_t* instance,
1941  void* to_internal,
1942  const afw_utf8_t* from_utf8,
1943  const afw_pool_t* p,
1944  afw_xctx_t* xctx)
1945 {
1946  AFW_THROW_ERROR_Z(general, "Not implemented for this data type", xctx);
1947 }
1948 
1949 
1950 static const afw_utf8_t*
1951 impl_afw_data_type_evaluate_internal_to_utf8(
1952  const afw_data_type_t* instance,
1953  const void* from_internal,
1954  const afw_pool_t* p,
1955  afw_xctx_t* xctx)
1956 {
1957  AFW_THROW_ERROR_Z(general, "Not implemented for this data type", xctx);
1958 }
1959 
1960 
1961 static int
1962 impl_afw_data_type_evaluate_compare_internal(
1963  const afw_data_type_t* instance,
1964  const void* value1,
1965  const void* value2,
1966  afw_xctx_t* xctx)
1967 {
1968  AFW_THROW_ERROR_Z(general, "Not implemented for this data type", xctx);
1969 }
1970 
1971 
1972 static void
1973 impl_afw_data_type_evaluate_convert_internal(
1974  const afw_data_type_t* instance,
1975  void* to_internal,
1976  const void* from_internal,
1977  const afw_data_type_t* to_data_type,
1978  const afw_pool_t* p,
1979  afw_xctx_t* xctx)
1980 {
1981  AFW_THROW_ERROR_Z(general, "Not implemented for this data type", xctx);
1982 }
1983 
1984 
1985 static void
1986 impl_afw_data_type_evaluate_clone_internal(
1987  const afw_data_type_t* instance,
1988  void* to_internal,
1989  const void* from_internal,
1990  const afw_pool_t* p,
1991  afw_xctx_t* xctx)
1992 {
1993  AFW_THROW_ERROR_Z(general, "Not implemented for this data type", xctx);
1994 }
1995 
1996 
1997 static void
1998 impl_afw_data_type_evaluate_value_compiler_listing(
1999  const afw_data_type_t* instance,
2000  const afw_writer_t* writer,
2001  const afw_value_t* value,
2002  afw_xctx_t* xctx)
2003 {
2004  AFW_THROW_ERROR_Z(general, "Not implemented for this data type", xctx);
2005 }
2006 
2007 
2008 static void
2009 impl_afw_data_type_evaluate_write_as_expression(
2010  const afw_data_type_t* instance,
2011  const afw_writer_t* writer,
2012  const void* from_internal,
2013  afw_xctx_t* xctx)
2014 {
2015  AFW_THROW_ERROR_Z(general, "Not implemented for this data type", xctx);
2016 }
2017 
2018 
2019 
2020 /* ---- Interface definitions ------------------------------------------------*/
2021 
2022 #define IMPL_DATA_TYPE_INF( \
2023  _id, _to_utf8, _to_internal, _compare, _conv, _clone, \
2024  _compiler_listing, _expression) \
2025  \
2026 AFW_DEFINE_INTERNAL_CONST_DATA(afw_data_type_inf_t) \
2027 afw_data_type_ ## _id ## _inf = { \
2028  { \
2029  AFW_UTF8_LITERAL("afw_data_type"), \
2030  AFW_UTF8_LITERAL(__FILE__), \
2031  AFW_UTF8_LITERAL("afw_data_type_" #_id ) \
2032  }, \
2033  impl_afw_data_type_ ## _to_utf8 ## _internal_to_utf8, \
2034  impl_afw_data_type_ ## _to_internal ## _utf8_to_internal, \
2035  impl_afw_data_type_ ## _compare ## _compare_internal, \
2036  impl_afw_data_type_ ## _conv ## _convert_internal, \
2037  impl_afw_data_type_ ## _clone ## _clone_internal, \
2038  impl_afw_data_type_ ## _compiler_listing ## _value_compiler_listing, \
2039  impl_afw_data_type_ ## _expression ## _write_as_expression \
2040 }; \
2041 
2042 
2043 IMPL_DATA_TYPE_INF(
2044  any, /* data type id */
2045  evaluate, /* to utf8 */
2046  evaluate, /* to internal */
2047  evaluate, /* compare */
2048  evaluate, /* conversion */
2049  evaluate, /* clone */
2050  evaluate, /* compiler listing */
2051  evaluate) /* as expression */
2052 
2053 IMPL_DATA_TYPE_INF(
2054  anyURI, /* data type id */
2055  utf8, /* to utf8 */
2056  anyURI, /* to internal */
2057  utf8, /* compare */
2058  from_utf8, /* conversion */
2059  utf8, /* clone */
2060  utf8, /* compiler listing */
2061  typed_string) /* as expression */
2062 
2063 IMPL_DATA_TYPE_INF(
2064  base64Binary, /* data type id */
2065  base64Binary, /* to utf8 */
2066  base64Binary, /* to internal */
2067  raw, /* compare */
2068  from_raw, /* conversion */
2069  raw, /* clone */
2070  typed_to_string, /* compiler listing */
2071  typed_to_string) /* as expression */
2072 
2073 IMPL_DATA_TYPE_INF(
2074  boolean, /* data type id */
2075  boolean, /* to utf8 */
2076  boolean, /* to internal */
2077  boolean, /* compare */
2078  standard, /* conversion */
2079  direct, /* clone */
2080  boolean, /* compiler listing */
2081  boolean) /* as expression */
2082 
2083 IMPL_DATA_TYPE_INF(
2084  date, /* data type id */
2085  date, /* to utf8 */
2086  date, /* to internal */
2087  date, /* compare */
2088  from_date, /* conversion */
2089  direct, /* clone */
2090  typed_to_string, /* compiler listing */
2091  typed_to_string) /* as expression */
2092 
2093 IMPL_DATA_TYPE_INF(
2094  dateTime, /* data type id */
2095  dateTime, /* to utf8 */
2096  dateTime, /* to internal */
2097  dateTime, /* compare */
2098  from_dateTime, /* conversion */
2099  direct, /* clone */
2100  typed_to_string, /* compiler listing */
2101  typed_to_string) /* as expression */
2102 
2103 IMPL_DATA_TYPE_INF(
2104  dayTimeDuration, /* data type id */
2105  dayTimeDuration, /* to utf8 */
2106  dayTimeDuration, /* to internal */
2107  dayTimeDuration, /* compare */
2108  standard, /* conversion */
2109  direct, /* clone */
2110  typed_to_string, /* compiler listing */
2111  typed_to_string) /* as expression */
2112 
2113 IMPL_DATA_TYPE_INF(
2114  dnsName, /* data type id */
2115  utf8, /* to utf8 */
2116  dnsName, /* to internal */
2117  utf8, /* compare */
2118  from_utf8, /* conversion */
2119  utf8, /* clone */
2120  utf8, /* compiler listing */
2121  typed_string) /* as expression */
2122 
2123 IMPL_DATA_TYPE_INF(
2124  double, /* data type id */
2125  double, /* to_utf8 */
2126  double, /* to internal */
2127  double, /* compare */
2128  from_double, /* conversion */
2129  direct, /* clone */
2130  double, /* compiler listing */
2131  double) /* as expression */
2132 
2133 IMPL_DATA_TYPE_INF(
2134  expression, /* data type id */
2135  utf8, /* to utf8 */
2136  utf8, /* to internal */
2137  utf8, /* compare */
2138  from_utf8, /* conversion */
2139  utf8, /* clone */
2140  utf8, /* compiler listing */
2141  typed_string) /* as expression */
2142 
2143 IMPL_DATA_TYPE_INF(
2144  function, /* data type id */
2145  function, /* to utf8 */
2146  function, /* to internal */
2147  function, /* compare */
2148  standard, /* conversion */
2149  function, /* clone */
2150  function, /* compiler listing */
2151  typed_string) /* as expression */
2152 
2153 IMPL_DATA_TYPE_INF(
2154  hexBinary, /* data type id */
2155  hexBinary, /* to utf8 */
2156  hexBinary, /* to internal */
2157  raw, /* compare */
2158  from_raw, /* conversion */
2159  raw, /* clone */
2160  typed_to_string, /* compiler listing */
2161  typed_to_string) /* as expression */
2162 
2163 IMPL_DATA_TYPE_INF(
2164  ia5String, /* data type id */
2165  utf8, /* to utf8 */
2166  ia5String, /* to internal */
2167  utf8, /* compare */
2168  from_utf8, /* conversion */
2169  utf8, /* clone */
2170  utf8, /* compiler listing */
2171  typed_string) /* as expression */
2172 
2173 IMPL_DATA_TYPE_INF(
2174  implied, /* data type id */
2175  evaluate, /* to utf8 */
2176  evaluate, /* to internal */
2177  evaluate, /* compare */
2178  evaluate, /* conversion */
2179  evaluate, /* clone */
2180  evaluate, /* compiler listing */
2181  evaluate) /* as expression */
2182 
2183 IMPL_DATA_TYPE_INF(
2184  hybrid, /* data type id */
2185  utf8, /* to utf8 */
2186  utf8, /* to internal */
2187  utf8, /* compare */
2188  from_utf8, /* conversion */
2189  utf8, /* clone */
2190  utf8, /* compiler listing */
2191  typed_string) /* as expression */
2192 
2193 IMPL_DATA_TYPE_INF(
2194  integer, /* data type id */
2195  integer, /* to utf8 */
2196  integer, /* to internal */
2197  integer, /* compare */
2198  from_integer, /* conversion */
2199  direct, /* clone */
2200  integer, /* compiler listing */
2201  integer) /* as expression */
2202 
2203 IMPL_DATA_TYPE_INF(
2204  ipAddress, /* data type id */
2205  utf8, /* to utf8 */
2206  ipAddress, /* to internal */
2207  utf8, /* compare */
2208  from_utf8, /* conversion */
2209  utf8, /* clone */
2210  utf8, /* compiler listing */
2211  typed_string) /* as expression */
2212 
2213 IMPL_DATA_TYPE_INF(
2214  list, /* data type id */
2215  list, /* to utf8 */
2216  list, /* to internal */
2217  list, /* compare */
2218  from_pointer, /* conversion */
2219  list, /* clone */
2220  list, /* compiler listing */
2221  list) /* as expression */
2222 
2223 IMPL_DATA_TYPE_INF(
2224  null, /* data type id */
2225  null, /* to utf8 */
2226  null, /* to internal */
2227  null, /* compare */
2228  standard, /* conversion */
2229  direct, /* clone */
2230  null, /* compiler listing */
2231  null) /* as expression */
2232 
2233 IMPL_DATA_TYPE_INF(
2234  object, /* data type id */
2235  object, /* to utf8 */
2236  object, /* to internal */
2237  object, /* compare */
2238  from_pointer, /* conversion */
2239  object, /* clone */
2240  object, /* compiler listing */
2241  object) /* as expression */
2242 
2243 IMPL_DATA_TYPE_INF(
2244  objectId, /* data type id */
2245  utf8, /* to utf8 */
2246  objectId, /* to internal */
2247  utf8, /* compare */
2248  from_utf8, /* conversion */
2249  utf8, /* clone */
2250  utf8, /* compiler listing */
2251  typed_string) /* as expression */
2252 
2253 IMPL_DATA_TYPE_INF(
2254  objectPath, /* data type id */
2255  utf8, /* to utf8 */
2256  objectPath, /* to internal */
2257  utf8, /* compare */
2258  from_utf8, /* conversion */
2259  utf8, /* clone */
2260  utf8, /* compiler listing */
2261  typed_string) /* as expression */
2262 
2264 IMPL_DATA_TYPE_INF(
2265  password, /* data type id */
2266  utf8, /* to utf8 */
2267  utf8, /* to internal */
2268  utf8, /* compare */
2269  from_utf8, /* conversion */
2270  utf8, /* clone */
2271  utf8, /* compiler listing */
2272  typed_string) /* as expression */
2273 
2274 IMPL_DATA_TYPE_INF(
2275  regexp, /* data type id */
2276  utf8, /* to utf8 */
2277  utf8, /* to internal */
2278  utf8, /* compare */
2279  from_utf8, /* conversion */
2280  utf8, /* clone */
2281  utf8, /* compiler listing */
2282  typed_string) /* as expression */
2283 
2284 IMPL_DATA_TYPE_INF(
2285  rfc822Name, /* data type id */
2286  utf8, /* to utf8 */
2287  rfc822Name, /* to internal */
2288  utf8, /* compare */
2289  from_utf8, /* conversion */
2290  utf8, /* clone */
2291  utf8, /* compiler listing */
2292  typed_string) /* as expression */
2293 
2294 IMPL_DATA_TYPE_INF(
2295  script, /* data type id */
2296  utf8, /* to utf8 */
2297  utf8, /* to internal */
2298  utf8, /* compare */
2299  from_utf8, /* conversion */
2300  utf8, /* clone */
2301  utf8, /* compiler listing */
2302  typed_string) /* as expression */
2303 
2304 IMPL_DATA_TYPE_INF(
2305  string, /* data type id */
2306  utf8, /* to utf8 */
2307  utf8, /* to internal */
2308  utf8, /* compare */
2309  from_utf8, /* conversion */
2310  utf8, /* clone */
2311  utf8, /* compiler listing */
2312  string) /* as expression */
2313 
2314 IMPL_DATA_TYPE_INF(
2315  template, /* data type id */
2316  utf8, /* to utf8 */
2317  utf8, /* to internal */
2318  utf8, /* compare */
2319  from_utf8, /* conversion */
2320  utf8, /* clone */
2321  utf8, /* compiler listing */
2322  typed_string) /* as expression */
2323 
2324 IMPL_DATA_TYPE_INF(
2325  time, /* data type id */
2326  time, /* to utf8 */
2327  time, /* to internal */
2328  time, /* compare */
2329  from_time, /* conversion */
2330  direct, /* clone */
2331  typed_to_string, /* compiler listing */
2332  typed_to_string) /* as expression */
2333 
2334 IMPL_DATA_TYPE_INF(
2335  unevaluated, /* data type id */
2336  evaluate, /* to utf8 */
2337  evaluate, /* to internal */
2338  evaluate, /* compare */
2339  evaluate, /* conversion */
2340  evaluate, /* clone */
2341  evaluate, /* compiler listing */
2342  evaluate) /* as expression */
2343 
2344 IMPL_DATA_TYPE_INF(
2345  x500Name, /* data type id */
2346  utf8, /* to utf8 */
2347  x500Name, /* to internal */
2348  utf8, /* compare */
2349  from_utf8, /* conversion */
2350  utf8, /* clone */
2351  utf8, /* compiler listing */
2352  typed_string) /* as expression */
2353 
2354 IMPL_DATA_TYPE_INF(
2355  xpathExpression, /* data type id */
2356  utf8, /* to utf8 */
2357  utf8, /* to internal */
2358  utf8, /* compare */
2359  from_utf8, /* conversion */
2360  utf8, /* clone */
2361  utf8, /* compiler listing */
2362  typed_string) /* as expression */
2363 
2364 IMPL_DATA_TYPE_INF(
2365  yearMonthDuration, /* data type id */
2366  yearMonthDuration, /* to utf8 */
2367  yearMonthDuration, /* to internal */
2368  yearMonthDuration, /* compare */
2369  standard, /* conversion */
2370  direct, /* clone */
2371  typed_to_string, /* compiler listing */
2372  typed_to_string) /* as expression */
AFW_DEFINE(const afw_object_t *)
#define AFW_DEFINE_CONST_DATA(type)
Define a public afw variable.
Adaptive Framework Core Internal.
#define afw_data_type_is_base64Binary(A_DATA_TYPE)
Macro to determine if data type is base64Binary.
#define afw_data_type_is_boolean(A_DATA_TYPE)
Macro to determine if data type is boolean.
#define afw_data_type_is_date(A_DATA_TYPE)
Macro to determine if data type is date.
#define afw_data_type_is_dateTime(A_DATA_TYPE)
Macro to determine if data type is dateTime.
#define afw_data_type_is_double(A_DATA_TYPE)
Macro to determine if data type is double.
#define afw_data_type_is_hexBinary(A_DATA_TYPE)
Macro to determine if data type is hexBinary.
#define afw_data_type_is_integer(A_DATA_TYPE)
Macro to determine if data type is integer.
afw_value_evaluated_list_inf
Unmanaged evaluated value inf for data type list.
#define afw_value_is_object(A_VALUE)
Macro to determine if value is evaluated object.
afw_value_allocate_object(const afw_pool_t *p, afw_xctx_t *xctx)
Allocate function for unmanaged data type object value.
afw_value_evaluated_object_inf
Unmanaged evaluated value inf for data type object.
afw_value_create_string(const afw_utf8_t *internal, const afw_pool_t *p, afw_xctx_t *xctx)
Create function for unmanaged data type string value.
#define afw_value_is_string(A_VALUE)
Macro to determine if value is evaluated string.
#define afw_data_type_is_time(A_DATA_TYPE)
Macro to determine if data type is time.
#define AFW_FALSE
Definition: afw_common.h:392
double afw_double_t
Normal AFW number is double.
Definition: afw_common.h:202
struct afw_iterator_s afw_iterator_t
#define AFW_TRUE
Definition: afw_common.h:383
_Bool afw_boolean_t
Definition: afw_common.h:373
unsigned char afw_byte_t
A byte of memory (unsigned).
Definition: afw_common.h:208
#define AFW_UTF8_FMT
Format string specifier used for afw_utf8_t.
Definition: afw_common.h:588
char afw_utf8_octet_t
8 bits of utf-8 codepoint.
Definition: afw_common.h:236
apr_size_t afw_size_t
size_t.
Definition: afw_common.h:151
unsigned char afw_octet_t
8 bits (unsigned).
Definition: afw_common.h:211
apr_int64_t afw_integer_t
typedef for big signed int.
Definition: afw_common.h:321
#define afw_data_type_compare_internal(instance, internal1, internal2, xctx)
Call method compare_internal of interface afw_data_type.
#define afw_data_type_utf8_to_internal(instance, to_internal, from_utf8, p, xctx)
Call method utf8_to_internal of interface afw_data_type.
#define afw_data_type_internal_to_utf8(instance, from_internal, p, xctx)
Call method internal_to_utf8 of interface afw_data_type.
afw_data_type_boolean_true
afw_boolean_t true value.
Definition: afw_data_type.h:33
afw_data_type_boolean_false
afw_boolean_t false value.
Definition: afw_data_type.h:37
afw_data_type_object_create_clone_to_managed_object(const afw_object_t *object, const afw_pool_t *p, afw_xctx_t *xctx)
Clone an object to a managed object.
#define AFW_THROW_ERROR_FZ(code, xctx, format_z,...)
Macro used to set error and 0 rv in xctx and throw it.
Definition: afw_error.h:319
#define AFW_THROW_ERROR_Z(code, message_z, xctx)
Macro used to set error and 0 rv in xctx and throw it.
Definition: afw_error.h:283
void afw_json_write_encoded_string(const afw_utf8_t *string, const afw_writer_t *writer, afw_xctx_t *xctx)
Write string as json encoded string.
#define afw_json_to_value(json, source_location, p, xctx)
Convert JSON to an adaptive value.
Definition: afw_json.h:128
const afw_utf8_t * afw_json_from_value(const afw_value_t *value, const afw_object_options_t *options, const afw_pool_t *p, afw_xctx_t *xctx)
Convert an adaptive value to JSON.
#define afw_list_get_next_internal(instance, iterator, data_type, internal, xctx)
Call method get_next_internal of interface afw_list.
#define afw_list_get_next_value(instance, iterator, p, xctx)
Call method get_next_value of interface afw_list.
#define afw_list_get_data_type(instance, xctx)
Call method get_data_type of interface afw_list.
afw_list_add_value(const afw_list_t *instance, const afw_value_t *value, afw_xctx_t *xctx)
Call method add_value of interface afw_list_setter.
Definition: afw_list.c:104
#define afw_list_of_create(data_type, p, xctx)
Create an list of a specific data type in memory.
Definition: afw_list.h:64
#define afw_memory_clear(to)
Clear preallocated memory for sizeof(*(to)).
Definition: afw_memory.h:47
afw_memory_decode_base64(afw_memory_t *memory, const afw_utf8_t *encoded, const afw_pool_t *p, afw_xctx_t *xctx)
Decode memory to a base64 string.
Definition: afw_memory.c:223
afw_memory_encode_printable_hex(afw_utf8_t *encoded, const afw_memory_t *memory, const afw_pool_t *p, afw_xctx_t *xctx)
Encode memory to a printable hex string.
Definition: afw_memory.c:310
afw_memory_encode_base64(afw_utf8_t *encoded, const afw_memory_t *memory, const afw_pool_t *p, afw_xctx_t *xctx)
Encode memory to as base64 string.
Definition: afw_memory.c:185
afw_memory_decode_printable_hex(afw_memory_t *memory, const afw_utf8_t *encoded, const afw_pool_t *p, afw_xctx_t *xctx)
Decode memory to a printable hex string.
Definition: afw_memory.c:337
afw_double_t afw_number_utf8_to_double(const afw_utf8_t *s, const afw_pool_t *p, afw_xctx_t *xctx)
Convert a utf8 string to double in specified pool.
Definition: afw_number.h:169
afw_integer_t afw_number_utf8_to_integer(const afw_utf8_t *s, const afw_pool_t *p, afw_xctx_t *xctx)
Convert a utf8 string to integer in specified pool.
Definition: afw_number.h:221
afw_boolean_t afw_number_is_negative_infinity(double d)
Determine if double is negative infinity.
Definition: afw_number.h:69
afw_boolean_t afw_number_is_NaN(double d)
Determine if double is not a number.
Definition: afw_number.h:84
afw_number_double_to_utf8(afw_double_t d, const afw_pool_t *p, afw_xctx_t *xctx)
Convert a double to utf8 in specified pool.
Definition: afw_number.c:19
afw_boolean_t afw_number_is_positive_infinity(double d)
Determine if double is positive infinity.
Definition: afw_number.h:57
afw_number_integer_to_utf8(afw_integer_t i, const afw_pool_t *p, afw_xctx_t *xctx)
Convert an integer to utf8 in specified pool.
Definition: afw_number.c:168
#define afw_object_get_property(instance, property_name, xctx)
Call method get_property of interface afw_object.
#define afw_object_get_next_property(instance, iterator, property_name, xctx)
Call method get_next_property of interface afw_object.
#define afw_object_meta_get_object_type_id(instance, xctx)
Get object's object_type_id.
afw_object_meta_get_nonempty_delta(const afw_object_t *instance, afw_xctx_t *xctx)
Return meta delta object for an object creating an empty one if needed.
#define afw_object_create_managed(p, xctx)
Create an empty entity object in its own pool.
Definition: afw_object.h:913
#define afw_object_create(p, xctx)
Create an empty unmanaged object in memory.
Definition: afw_object.h:948
afw_object_set_property(const afw_object_t *instance, const afw_utf8_t *property_name, const afw_value_t *value, afw_xctx_t *xctx)
Set the value of an object's property.
Definition: afw_object.c:46
const afw_object_t * afw_object_create_embedded(const afw_object_t *embedding_object, const afw_utf8_t *property_name, afw_xctx_t *xctx)
Create an empty embedded object in a memory object.
#define afw_pool_malloc(instance, size, xctx)
Call method malloc of interface afw_pool.
#define afw_pool_calloc_type(instance, type, xctx)
Macro to allocate cleared memory to hold type in pool.
Definition: afw_pool.h:167
afw_dayTimeDuration_internal_to_utf8(const afw_dayTimeDuration_t *dayTimeDuration, const afw_pool_t *p, afw_xctx_t *xctx)
Convert internal dayTimeDuration to utf8 xml schema dayTimeDuration in specified pool.
Definition: afw_time.c:1126
afw_yearMonthDuration_compare(const afw_yearMonthDuration_t *v1, const afw_yearMonthDuration_t *v2, afw_xctx_t *xctx)
compare two yearMonthDuration values.
Definition: afw_time.c:1773
afw_date_utf8_set_internal(const afw_utf8_t *utf8, afw_date_t *internal, afw_xctx_t *xctx)
Convert utf8 xml schema date to internal and set.
Definition: afw_time.c:1061
afw_dayTimeDuration_compare(const afw_dayTimeDuration_t *v1, const afw_dayTimeDuration_t *v2, afw_xctx_t *xctx)
compare two dateTime values.
Definition: afw_time.c:1751
afw_date_internal_to_utf8(const afw_date_t *date, const afw_pool_t *p, afw_xctx_t *xctx)
Convert internal date to utf8 xml schema date in specified pool.
Definition: afw_time.c:1045
afw_dateTime_internal_to_utf8(const afw_dateTime_t *dateTime, const afw_pool_t *p, afw_xctx_t *xctx)
Convert internal dateTime to utf8 xml schema dateTime in specified pool.
Definition: afw_time.c:1081
afw_time_utf8_set_internal(const afw_utf8_t *utf8, afw_time_t *internal, afw_xctx_t *xctx)
Convert utf8 xml schema dateTime to internal and set.
Definition: afw_time.c:1385
afw_yearMonthDuration_internal_to_utf8(const afw_yearMonthDuration_t *yearMonthDuration, const afw_pool_t *p, afw_xctx_t *xctx)
Convert internal yearMonthDuration to utf8 xml schema yearMonthDuration in specified pool.
Definition: afw_time.c:1407
afw_time_internal_to_utf8(const afw_time_t *time, const afw_pool_t *p, afw_xctx_t *xctx)
Convert internal time to utf8 xml schema time in specified pool.
Definition: afw_time.c:1369
afw_date_compare(const afw_date_t *v1, const afw_date_t *v2, afw_xctx_t *xctx)
compare two date values.
Definition: afw_time.c:1517
afw_dateTime_compare(const afw_dateTime_t *v1, const afw_dateTime_t *v2, afw_xctx_t *xctx)
compare two dateTime values.
Definition: afw_time.c:1540
afw_time_compare(const afw_time_t *v1, const afw_time_t *v2, afw_xctx_t *xctx)
compare two time values.
Definition: afw_time.c:1590
afw_dateTime_utf8_set_internal(const afw_utf8_t *utf8, afw_dateTime_t *internal, afw_xctx_t *xctx)
Convert utf8 xml schema dateTime to internal and set.
Definition: afw_time.c:1099
afw_dayTimeDuration_utf8_set_internal(const afw_utf8_t *utf8, afw_dayTimeDuration_t *internal, afw_xctx_t *xctx)
Convert utf8 xml schema dayTimeDuration to internal and set.
Definition: afw_time.c:1234
afw_yearMonthDuration_utf8_set_internal(const afw_utf8_t *utf8, afw_yearMonthDuration_t *internal, afw_xctx_t *xctx)
Convert utf8 xml schema yearMonthDuration to internal and set.
Definition: afw_time.c:1458
const afw_utf8_t * afw_utf8_clone(const afw_utf8_t *string, const afw_pool_t *p, afw_xctx_t *xctx)
Clone a utf-8 string into a specific pool.
Definition: afw_utf8.h:347
afw_value_equal(const afw_value_t *value1, const afw_value_t *value2, afw_xctx_t *xctx)
Test whether two values are equal.
Definition: afw_value.c:851
afw_value_clone(const afw_value_t *value, const afw_pool_t *p, afw_xctx_t *xctx)
Clone a value to specified pool.
Definition: afw_value.c:282
#define afw_value_is_function_definition(A_VALUE)
Macro to determine if value is a function definition.
Definition: afw_value.h:614
afw_value_decompile_value(const afw_value_t *instance, const afw_writer_t *writer, afw_xctx_t *xctx)
Decompile Value::.
#define AFW_VALUE_INTERNAL(_VALUE_)
Macro to get const void * of the internal of a value.
Definition: afw_value.h:856
#define AFW_VALUE_ASSERT_IS_DATA_TYPE(A_VALUE, A_DATA_TYPE, A_SCOPE)
Throw and error if A_VALUE is not evaluated data type A_DATA_TYPE.
Definition: afw_value.h:768
#define afw_value_is_script_function(A_VALUE)
Macro to determine if value is lambda definition.
Definition: afw_value.h:666
#define afw_writer_increment_indent(instance, xctx)
Call method increment_indent of interface afw_writer.
#define afw_writer_write_eol(instance, xctx)
Call method write_eol of interface afw_writer.
#define afw_writer_decrement_indent(instance, xctx)
Call method decrement_indent of interface afw_writer.
#define afw_writer_write_z(writer, s_z, xctx)
Call afw_writer_write() with zero terminated string.
Definition: afw_writer.h:35
#define afw_writer_write_utf8(writer, S, xctx)
Call afw_writer_write() with a afw_utf8_t string.
Definition: afw_writer.h:45
Interface afw_data_type public struct.
date with no time zone.
Definition: afw_common.h:1695
date with time zone.
Definition: afw_common.h:1712
date, time, and time zone.
Definition: afw_common.h:1760
dayTime duration
Definition: afw_common.h:1657
Interface afw_list public struct.
Struct for memory pointer and size.
Definition: afw_common.h:505
Typedef for meta variable in afw_object interface.
Definition: afw_common.h:753
const afw_utf8_t * id
Object id or property name.
Definition: afw_common.h:782
const afw_utf8_t * object_uri
Object path or NULL.
Definition: afw_common.h:811
const afw_object_t * embedding_object
Embedding object.
Definition: afw_common.h:768
const afw_utf8_t * object_type_uri
Object type object URI or NULL.
Definition: afw_common.h:796
const afw_object_t * meta_object
Meta object.
Definition: afw_common.h:761
Interface afw_object public struct.
Interface afw_pool public struct.
time with no time zone.
Definition: afw_common.h:1726
time with time zone.
Definition: afw_common.h:1746
NFC normalized UTF-8 string.
Definition: afw_common.h:545
struct for data type boolean values.
Struct for function value.
Definition: afw_value.h:102
struct for data type list values.
struct for data type object values.
Interface afw_value public struct.
Interface afw_writer public struct.
Interface afw_xctx public struct.
yearMonth duration
Definition: afw_common.h:1646