Adaptive Framework  0.9.0
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
afw_compile.c
Go to the documentation of this file.
1 // See the 'COPYING' file in the project root for licensing information.
2 /*
3  * AFW parse functions
4  *
5  * Copyright (c) 2010-2023 Clemson University
6  *
7  */
8 
15 #include "afw_internal.h"
16 
17 #define XX(name, data_type, compile_function, description) \
18  \
19 static const afw_utf8_t \
20 impl_compile_type_ ## name ## _name = \
21  AFW_UTF8_LITERAL(#name); \
22  \
23 static const afw_value_string_t \
24 impl_compile_type_ ## name ## _name_value = \
25  {&afw_value_evaluated_string_inf, AFW_UTF8_LITERAL(#name)}; \
26  \
27 static const afw_utf8_t \
28 impl_compile_type_ ## name ## _description = \
29  AFW_UTF8_LITERAL(#description); \
30  \
31 static const afw_value_string_t \
32 impl_compile_type_ ## name ## _description_value = \
33  {&afw_value_evaluated_string_inf, AFW_UTF8_LITERAL(#description)}; \
34 
36 
37 #undef XX
38 
39 
40 
41 static const afw_compile_type_info_t
42 impl_compile_type_pneumonic[] = {
43 #define XX(name, data_type, compile_function, description) \
44 { \
45  afw_compile_type_ ## name, \
46  &impl_compile_type_ ## name ## _name, \
47  (const afw_value_t *)&impl_compile_type_ ## name ## _name_value, \
48  &impl_compile_type_ ## name ## _description, \
49  (const afw_value_t *)&impl_compile_type_ ## name ## _description_value, \
50  &afw_data_type_ ## data_type ##_direct, \
51  compile_function \
52 }, \
53 
55 #undef XX
56 {
57  afw_compile_type_error,
58  NULL, NULL, NULL, NULL, NULL, NULL
59 }
60 };
61 
62 
63 
64 /* Compile and evaluate a string. */
65 AFW_DEFINE(const afw_value_t *)
67  const afw_utf8_t *string,
68  const afw_utf8_t *source_location,
69  afw_compile_type_t compile_type,
70  const afw_pool_t *p,
71  afw_xctx_t *xctx)
72 {
73  const afw_value_t *compiled_value;
74  const afw_value_t *result;
75 
82  compiled_value = afw_compile_to_value_with_callback(
83  string, NULL, NULL,
84  source_location, compile_type,
85  afw_compile_residual_check_to_full, \
86  NULL, NULL, p, xctx);
87 
88  result = afw_value_evaluate(compiled_value, p, xctx);
89 
90  return result;
91 }
92 
93 
94 
95 /* Return afw_compile_type_t for a pneumonic. */
98  const afw_utf8_t *pneumonic,
99  const afw_xctx_t *xctx)
100 {
101  afw_compile_type_t compile_type;
102 
103  for (compile_type = afw_compile_type_error;
104  compile_type < afw_compile_type_count &&
105  !afw_utf8_equal(pneumonic,
106  impl_compile_type_pneumonic[compile_type].name);
107  compile_type++);
108 
109  if (compile_type >= afw_compile_type_count) {
110  compile_type = afw_compile_type_error;
111  }
112 
113  return &impl_compile_type_pneumonic[compile_type];
114 }
115 
116 
117 
118 /* Return pneumonic for a afw_compile_type_t. */
121  afw_compile_type_t compile_type,
122  const afw_xctx_t *xctx)
123 {
124  const afw_compile_type_info_t *result;
125  result = &impl_compile_type_pneumonic[afw_compile_type_error];
126  if (compile_type > 0 &&
127  compile_type < afw_compile_type_count)
128  {
129  result = &impl_compile_type_pneumonic[compile_type];
130  }
131  return result;
132 }
133 
134 
135 
136 /*
137  * Parse string to adaptive value with callback.
138  */
139 AFW_DEFINE(const afw_value_t *)
141  const afw_utf8_t *string,
142  afw_utf8_octet_get_cb_t callback,
143  void *callback_data,
144  const afw_utf8_t *source_location,
145  afw_compile_type_t compile_type,
146  afw_compile_residual_check_t residual_check,
147  const afw_value_compiled_value_t *parent,
148  const afw_compile_shared_t *shared,
149  const afw_pool_t *p,
150  afw_xctx_t *xctx)
151 {
152  afw_compile_parser_t *parser;
153  const afw_value_t *result = NULL;
154  const afw_value_t * *interim = NULL;
155  const afw_utf8_octet_t *line_begin;
156  const afw_utf8_octet_t *cursor;
157  const afw_value_block_t *block;
158  const afw_value_t **block_argv;
159  afw_size_t count;
160  int top;
161 
162  if (compile_type == afw_compile_type_regexp) {
163  AFW_THROW_ERROR_Z(general,
164  "afw_compile_type_regexp not supported yet",
165  xctx);
166  }
167  else if (compile_type == afw_compile_type_xpathExpression) {
168  AFW_THROW_ERROR_Z(general,
169  "afw_compile_type_xpathExpression not supported yet",
170  xctx);
171  }
172 
173  /* Create parser. */
174  parser = afw_compile_lexical_parser_create(
175  string, callback, callback_data, source_location,
176  compile_type, residual_check, false, parent, shared, p, xctx);
177 
178  /*
179  * Parse expression.
180  *
181  * Make sure stack has same top before and after parse.
182  */
183  top = afw_xctx_begin_stack_frame(xctx);
184  AFW_TRY{
185 
186  if (compile_type == afw_compile_type_json ||
187  compile_type == afw_compile_type_relaxed_json)
188  {
189  parser->compiled_value->full_source_type = &afw_s_json;
190  result = afw_compile_parse_Json(parser);
191  afw_compile_check_for_residual(parser);
192  }
193 
194  else {
195 
196  /* Result is a compiled value. */
197  parser->compiled_value->reference_id =
198  afw_uuid_create_utf8(parser->p, xctx);
199  result = (const afw_value_t *)parser->compiled_value;
200  interim = &parser->compiled_value->root_value;
201 
202  /*
203  * There is no parent and this is not a script, surround root value
204  * with a block.
205  */
206  block = NULL;
207  if (!parent && compile_type != afw_compile_type_script)
208  {
209  block_argv = afw_pool_malloc_type(parser->p,
210  const afw_value_t *, xctx);
211  interim = &block_argv[0];
212  block = afw_compile_parse_link_new_value_block(parser, 0);
213  }
214 
215  /* Process based on compile option. */
216  if (compile_type == afw_compile_type_script) {
217  parser->compiled_value->full_source_type = &afw_s_script;
218  *interim = afw_compile_parse_Script(parser);
219  }
220 
221  else if (compile_type == afw_compile_type_template) {
222  parser->compiled_value->full_source_type = &afw_s_template;
223  *interim = afw_compile_parse_Template(parser);
224  }
225 
226  else if (compile_type == afw_compile_type_expression) {
227  parser->compiled_value->full_source_type = &afw_s_expression;
228  *interim = afw_compile_parse_Expression(parser);
229  }
230 
231  else if (compile_type == afw_compile_type_expression_tuple) {
232  parser->compiled_value->full_source_type = &afw_s_expression_tuple;
233  *interim = afw_compile_parse_ExpressionTuple(parser);
234  }
235 
236  else if (compile_type == afw_compile_type_parenthesized_expression) {
237  parser->compiled_value->full_source_type = &afw_s_expression;
238  afw_compile_skip_ws(parser);
239  if (afw_compile_is_at_eof()) {
240  result = NULL;
241  break;
242  }
243  *interim = afw_compile_parse_ParenthesizedExpression(parser);
244  }
245 
246  else if (compile_type == afw_compile_type_hybrid) {
247  parser->compiled_value->full_source_type = &afw_s_hybrid;
248  afw_compile_skip_ws(parser);
249  *interim = afw_compile_parse_Hybrid(parser);
250  }
251 
252  else if (compile_type == afw_compile_type_test_script) {
253  parser->compiled_value->full_source_type = &afw_s_test_script;
254  afw_compile_skip_ws(parser);
255  *interim = afw_compile_parse_TestScript(parser);
256  }
257 
258  else {
259  AFW_THROW_ERROR_Z(general, "Invalid compile type.", xctx);
260  }
261 
262  /* If surrounding with a block, finalize it. */
263  if (block) {
264  parser->compiled_value->root_value =
265  afw_value_block_finalize(block, 1, block_argv, xctx);
266  afw_compile_parse_pop_value_block(parser);
267  }
268 
269  /* Get clone of full source in correct pool. */
270  if (parser->full_source)
271  {
272  parser->compiled_value->full_source = afw_utf8_clone(
273  parser->full_source, parser->p, xctx);
274  for (
275  count = 0,
276  cursor = line_begin = parser->full_source->s;
277  count < parser->full_source->len; count++, cursor++)
278  {
279  if (*cursor == '\n')
280  {
281  (parser->compiled_value->line_count)++;
282  if ((afw_size_t)(cursor - line_begin) >
283  parser->compiled_value->longest_line)
284  {
285  parser->compiled_value->longest_line =
286  cursor - line_begin;
287  }
288  line_begin = cursor + 1;
289  }
290  }
291  }
292 
293  afw_compile_check_for_residual(parser);
294  }
295 
296  }
297  AFW_FINALLY {
298  afw_xctx_end_stack_frame(top, xctx);
299  }
300  AFW_ENDTRY;
301 
302  afw_compile_lexical_parser_finish_and_release(parser, xctx);
303 
304  /* Return result. */
305  return result;
306 }
307 
308 
309 /*
310  * Implementation of method raw_to_object of interface afw_content_type.
311  */
312 AFW_DEFINE(const afw_object_t *)
314  const afw_utf8_t *string,
315  const afw_utf8_t *source_location,
316  const afw_utf8_t *adaptor_id,
317  const afw_utf8_t *object_type_id,
318  const afw_utf8_t *object_id,
319  afw_boolean_t cede_p,
320  const afw_pool_t * p,
321  afw_xctx_t *xctx)
322 {
323  afw_compile_parser_t *parser;
324  const afw_object_t *result = NULL;
325  const afw_value_t *value;
326  int top;
327  const afw_pool_t *parser_p;
328 
329  /* Create parser. */
330  parser_p = (cede_p) ? p : afw_pool_create(p, xctx);
331 
332  if ((adaptor_id || object_type_id || object_id) &&
333  (!adaptor_id || !object_type_id || !object_id))
334  {
335  AFW_THROW_ERROR_Z(general,
336  "If adaptor_id, object_type_id, or object_id is not NULL, all must "
337  "not be NULL",
338  xctx);
339  }
340 
341  /* Default source location to path if adaptor_id supplied. */
342  if (!source_location && adaptor_id) {
343  source_location = afw_object_path_make(
344  adaptor_id, object_type_id, object_id, parser_p, xctx);
345  }
346 
347  /* Create parser. */
348  parser = afw_compile_lexical_parser_create(
349  string, NULL, NULL, source_location,
350  afw_compile_type_json, afw_compile_residual_check_to_full,
351  true, NULL, NULL, parser_p, xctx);
352  parser->compiled_value->full_source_type = &afw_s_json;
353 
354  /*
355  * Parse expression.
356  *
357  * Make sure stack has same top before and after parse.
358  */
359  top = afw_xctx_begin_stack_frame(xctx);
360  AFW_TRY {
361  value = afw_compile_parse_Object(parser, false, false);
362  afw_compile_check_for_residual(parser);
363  if (value) {
364  result = afw_value_as_object(value, xctx);
365  if (adaptor_id) {
367  adaptor_id, object_type_id, object_id, xctx);
368  }
369  }
370  }
371  AFW_FINALLY {
372  afw_xctx_end_stack_frame(top, xctx);
373  }
374  AFW_ENDTRY;
375 
376  afw_compile_lexical_parser_finish_and_release(parser, xctx);
377 
378  /* Return result. */
379  return result;
380 }
381 
382 
383 /* Compile hybrid. */
384 AFW_DEFINE(const afw_value_t *)
386  const afw_value_t *value,
387  const afw_utf8_t *source_location,
388  const afw_value_compiled_value_t *parent,
389  const afw_compile_shared_t *shared,
390  const afw_pool_t *p,
391  afw_xctx_t *xctx)
392 {
393  const afw_utf8_t *source;
394  const afw_value_t *result;
395 
396  //FIXME
397  if (afw_value_is_object(value)) {
398  return value;
399  }
400 
401  source = afw_value_as_utf8(value, p, xctx);
402  result = afw_compile_hybrid_source(source,
403  source_location, parent, shared, p, xctx);
404  return result;
405 }
406 
407 
408 
409 /* Compile object's expressions and templates properties. */
410 AFW_DEFINE(void)
412  const afw_object_t *object,
413  const afw_utf8_t *source_location,
414  afw_boolean_t recursive,
415  const afw_compile_shared_t *shared,
416  afw_xctx_t *xctx)
417 {
418  const afw_iterator_t *iterator;
419  const afw_utf8_t *property_name;
420  const afw_utf8_t *detail_source_location;
421  const afw_value_t *value;
422 
423  /* Default source_location is object path. */
424  if (!source_location) {
425  source_location = afw_object_meta_get_path(object, xctx);
426  }
427 
428  /* If shared is NULL, make one. */
429  if (!shared) {
430  shared = afw_compile_shared_create(object->p, xctx);
431  }
432 
433  /* Compile single expressions and templates. */
434  for (iterator = NULL;;) {
435 
436  /* Get the next property. */
437  value = afw_object_get_next_property(object,
438  &iterator, &property_name, xctx);
439  if (!value) break;
440 
441  /* If this is an expression value, compile it. */
442  if (afw_value_is_expression(value)) {
443  detail_source_location = afw_utf8_printf(object->p, xctx,
444  "%" AFW_UTF8_FMT "/%" AFW_UTF8_FMT,
445  AFW_UTF8_FMT_ARG(source_location),
446  AFW_UTF8_FMT_ARG(property_name));
447  value = afw_compile_to_value(
448  &((afw_value_expression_t *)value)->internal,
449  detail_source_location,
450  afw_compile_type_expression,
451  NULL, shared, NULL, xctx);
452  afw_object_set_property(object, property_name, value, xctx);
453  }
454 
455  /* If this is a template value, compile it. */
456  else if (afw_value_is_template(value)) {
457  detail_source_location = afw_utf8_printf(object->p, xctx,
458  "%" AFW_UTF8_FMT "/%" AFW_UTF8_FMT,
459  AFW_UTF8_FMT_ARG(source_location),
460  AFW_UTF8_FMT_ARG(property_name));
461  value = afw_compile_to_value(
462  &((afw_value_template_t *)value)->internal,
463  detail_source_location,
464  afw_compile_type_template,
465  NULL, shared, NULL, xctx);
466  afw_object_set_property(object, property_name, value, xctx);
467  }
468 
469  /* If this is a hybrid value, compile it. */
470  else if (afw_value_is_hybrid(value)) {
471  detail_source_location = afw_utf8_printf(object->p, xctx,
472  "%" AFW_UTF8_FMT "/%" AFW_UTF8_FMT,
473  AFW_UTF8_FMT_ARG(source_location),
474  AFW_UTF8_FMT_ARG(property_name));
475  value = afw_compile_hybrid(
476  value, detail_source_location,
477  NULL, shared, NULL, xctx);
478  afw_object_set_property(object, property_name, value, xctx);
479  }
480 
481  /* Recursively process objects. */
482  else if (recursive && afw_value_is_object(value)) {
483  detail_source_location = afw_utf8_printf(object->p, xctx,
484  "%" AFW_UTF8_FMT "/%" AFW_UTF8_FMT,
485  AFW_UTF8_FMT_ARG(source_location),
486  AFW_UTF8_FMT_ARG(property_name));
488  ((const afw_value_object_t *)value)->internal,
489  detail_source_location, true, shared, xctx);
490  }
491 
493  }
494 }
495 
496 
497 /* Compile an object with all hybrid properties. */
498 AFW_DEFINE(const afw_object_t *)
500  const afw_object_t *object,
501  const afw_utf8_t *source_location,
502  const afw_compile_shared_t *shared,
503  const afw_pool_t *p,
504  afw_xctx_t *xctx)
505 {
506  const afw_object_t *result;
507  const afw_utf8_t *property_name;
508  const afw_iterator_t *iterator;
509  const afw_value_t *value;
510  const afw_value_t *compiled_value;
511  const afw_utf8_t *detail_source_location;
512  const afw_data_type_t *value_data_type;
513 
514  if (!source_location) {
515  source_location = afw_object_meta_get_path(object, xctx);
516  }
517  if (!source_location) {
518  source_location = &afw_s_a_empty_string;
519  }
520  result = afw_object_create(p, xctx);
521  iterator = NULL;
522  while ((value = afw_object_get_next_property(
523  object, &iterator, &property_name, xctx)))
524  {
525  detail_source_location = afw_utf8_printf(object->p, xctx,
526  "%" AFW_UTF8_FMT " property %" AFW_UTF8_FMT,
527  AFW_UTF8_FMT_ARG(source_location),
528  AFW_UTF8_FMT_ARG(property_name));
529  value_data_type = afw_value_get_data_type(value, xctx);
530  if (!value_data_type ||
531  !afw_utf8_equal(&value_data_type->cType, &afw_s_afw_utf8_t))
532  {
533  AFW_THROW_ERROR_FZ(general, xctx,
534  "%" AFW_UTF8_FMT " is not a hybrid",
535  AFW_UTF8_FMT_ARG(detail_source_location));
536  }
537  compiled_value = afw_compile_hybrid_source(
538  &((const afw_value_string_t *)value)->internal,
539  detail_source_location, NULL, shared, p, xctx);
540  afw_object_set_property(result, property_name, compiled_value, xctx);
541  }
542  return result;
543 }
544 
545 
546 /* Split name with optional qualifier. */
547 AFW_DEFINE(void)
549  const afw_utf8_t *qualified_name,
550  afw_utf8_t *qualifier,
551  afw_utf8_t *name,
552  afw_xctx_t *xctx)
553 {
554  const afw_utf8_octet_t *s;
555  afw_size_t len;
556 
557  afw_memory_clear(qualifier);
558  afw_memory_copy(name, qualified_name);
559 
560  for (len = qualified_name->len, s = qualified_name->s; len > 0; len--, s++)
561  {
562  if (*s == ':') {
563  if (len < 2 || *(s + 1) != ':') {
564  AFW_THROW_ERROR_Z(general, "invalid qualified name", xctx);
565  }
566  qualifier->len = s - qualified_name->s;
567  qualifier->s = qualified_name->s;
568  name->len = len - 2;
569  name->s = s + 2;
570  break;
571  }
572  }
573 }
574 
575 
576 /* Return the source location of a value. */
577 AFW_DECLARE(const afw_utf8_t *)
579  const afw_value_t *value,
580  const afw_pool_t *p,
581  afw_xctx_t *xctx)
582 {
583  afw_value_info_t info;
584  const afw_utf8_t *result;
585  afw_size_t line_number;
586  afw_size_t column_number;
587 
588  afw_value_get_info(value, &info, p, xctx);
589  if (info.contextual) {
590  if (info.contextual->compiled_value)
591  {
593  &line_number, &column_number,
594  info.contextual->compiled_value->full_source,
595  info.contextual->value_offset,
596  4, xctx);
597  result = afw_utf8_printf(p, xctx,
598  "%" AFW_UTF8_FMT
599  "+%" AFW_SIZE_T_FMT
600  "(%" AFW_SIZE_T_FMT
601  ":%" AFW_SIZE_T_FMT ")",
602  AFW_UTF8_FMT_ARG(info.contextual->source_location),
603  info.contextual->value_offset,
604  line_number, column_number);
605  }
606  else if (info.contextual->source_location)
607  {
608  if (info.contextual->value_offset == 0) {
609  result = afw_utf8_printf(p, xctx,
610  "%" AFW_UTF8_FMT,
611  AFW_UTF8_FMT_ARG(info.contextual->source_location));
612  }
613  else {
614  result = afw_utf8_printf(p, xctx,
615  "%" AFW_UTF8_FMT
616  "%s+%" AFW_SIZE_T_FMT,
617  AFW_UTF8_FMT_ARG(info.contextual->source_location),
618  info.contextual->value_offset);
619  }
620  }
621  else {
622  if (info.contextual->value_offset == 0) {
623  result = &afw_s_a_empty_string;
624  }
625  else {
626  result = afw_utf8_printf(p, xctx,
627  "%" AFW_SIZE_T_FMT,
628  info.contextual->value_offset);
629  }
630  }
631  }
632 
633  return result;
634 }
AFW_DEFINE(const afw_object_t *)
#define AFW_DECLARE(type)
Declare a public afw function.
Adaptive Framework Core Internal.
#define afw_value_is_expression(A_VALUE)
Macro to determine if value is evaluated expression.
#define afw_value_is_hybrid(A_VALUE)
Macro to determine if value is evaluated hybrid.
#define afw_value_is_object(A_VALUE)
Macro to determine if value is evaluated object.
afw_value_as_object(const afw_value_t *value, afw_xctx_t *xctx)
Typesafe cast of data type object.
#define afw_value_is_template(A_VALUE)
Macro to determine if value is evaluated template.
#define AFW_UTF8_FMT_ARG(A_STRING)
Convenience Macro for use with AFW_UTF8_FMT to specify arg.
Definition: afw_common.h:605
struct afw_iterator_s afw_iterator_t
_Bool afw_boolean_t
Definition: afw_common.h:373
#define AFW_UTF8_FMT
Format string specifier used for afw_utf8_t.
Definition: afw_common.h:588
#define AFW_COMPILE_TYPE_MAP(XX)
Compile Type Map.
Definition: afw_common.h:409
int(* afw_utf8_octet_get_cb_t)(afw_utf8_octet_t *octet, void *data, afw_xctx_t *xctx)
Get an utf-8 octet (8 bits).
Definition: afw_common.h:255
enum afw_compile_type_e afw_compile_type_t
Compile type enum.
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
#define AFW_SIZE_T_FMT
Format string specifier used for afw_size_t.
Definition: afw_common.h:341
enum afw_compile_residual_check_e afw_compile_residual_check_t
Residual checking options.
afw_compile_expressions_templates_and_hybrids(const afw_object_t *object, const afw_utf8_t *source_location, afw_boolean_t recursive, const afw_compile_shared_t *shared, afw_xctx_t *xctx)
Compile object's expressions, templates, and hybrids.
Definition: afw_compile.c:411
afw_compile_object_all_hybrid_properties(const afw_object_t *object, const afw_utf8_t *source_location, const afw_compile_shared_t *shared, const afw_pool_t *p, afw_xctx_t *xctx)
Compile an object with all hybrid properties.
Definition: afw_compile.c:499
afw_compile_type_get_info(afw_compile_type_t compile_type, const afw_xctx_t *xctx)
Return info for a afw_compile_type_t.
Definition: afw_compile.c:120
const afw_compile_shared_t * afw_compile_shared_create(const afw_pool_t *p, afw_xctx_t *xctx)
Created a struct for sharing resources by multiple compiles.
#define afw_compile_hybrid_source(string, source_location, parent, shared, p, xctx)
Compile hybrid.
Definition: afw_compile.h:256
afw_compile_to_value_with_callback(const afw_utf8_t *string, afw_utf8_octet_get_cb_t callback, void *callback_data, const afw_utf8_t *source_location, afw_compile_type_t compile_type, afw_compile_residual_check_t residual_check, const afw_value_compiled_value_t *parent, const afw_compile_shared_t *shared, const afw_pool_t *p, afw_xctx_t *xctx)
Compile string to adaptive value with callback.
Definition: afw_compile.c:140
afw_compile_and_evaluate(const afw_utf8_t *string, const afw_utf8_t *source_location, afw_compile_type_t compile_type, const afw_pool_t *p, afw_xctx_t *xctx)
Compile and evaluate a string.
Definition: afw_compile.c:66
#define afw_compile_to_value(string, source_location, compile_type, parent, shared, p, xctx)
Compile string to adaptive value.
Definition: afw_compile.h:189
const afw_utf8_t * afw_compile_source_location_of_value(const afw_value_t *value, const afw_pool_t *p, afw_xctx_t *xctx)
Return the source location of a value.
Definition: afw_compile.c:578
afw_compile_type_get_info_by_pneumonic(const afw_utf8_t *pneumonic, const afw_xctx_t *xctx)
Return compile type info for a pneumonic.
Definition: afw_compile.c:97
afw_compile_to_object(const afw_utf8_t *string, const afw_utf8_t *source_location, const afw_utf8_t *adaptor_id, const afw_utf8_t *object_type_id, const afw_utf8_t *object_id, afw_boolean_t cede_p, const afw_pool_t *p, afw_xctx_t *xctx)
Compile string to adaptive object.
Definition: afw_compile.c:313
afw_compile_split_qualified_name(const afw_utf8_t *qualified_name, afw_utf8_t *qualifier, afw_utf8_t *name, afw_xctx_t *xctx)
Split name with optional qualifier.
Definition: afw_compile.c:548
afw_compile_hybrid(const afw_value_t *value, const afw_utf8_t *source_location, const afw_value_compiled_value_t *parent, const afw_compile_shared_t *shared, const afw_pool_t *p, afw_xctx_t *xctx)
Compile hybrid.
Definition: afw_compile.c:385
#define AFW_FINALLY
Always executed regardless of error.
Definition: afw_error.h:702
#define AFW_ENDTRY
Ends an AFW try block.
Definition: afw_error.h:727
#define AFW_TRY
Begin an AFW TRY block.
Definition: afw_error.h:634
#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
#define afw_memory_clear(to)
Clear preallocated memory for sizeof(*(to)).
Definition: afw_memory.h:47
#define afw_memory_copy(to, from)
Copy to preallocated memory of same type.
Definition: afw_memory.h:39
#define afw_object_get_next_property(instance, iterator, property_name, xctx)
Call method get_next_property of interface afw_object.
afw_object_meta_get_path(const afw_object_t *instance, afw_xctx_t *xctx)
Get an object's path.
afw_object_meta_set_ids(const afw_object_t *instance, const afw_utf8_t *adaptor_id, const afw_utf8_t *object_type_id, const afw_utf8_t *object_id, afw_xctx_t *xctx)
Set object's ids.
afw_object_path_make(const afw_utf8_t *adaptor_id, const afw_utf8_t *object_type_id, const afw_utf8_t *object_id, const afw_pool_t *p, afw_xctx_t *xctx)
Construct an object path in a specified pool.
#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_pool_t * afw_pool_create(const afw_pool_t *parent, afw_xctx_t *xctx)
Create a new pool.
#define afw_pool_malloc_type(instance, type, xctx)
Macro to allocate uncleared memory to hold type in pool.
Definition: afw_pool.h:182
afw_boolean_t afw_utf8_equal(const afw_utf8_t *s1, const afw_utf8_t *s2)
Check to see if a string equals another string.
afw_utf8_line_column_of_offset(afw_size_t *line_number, afw_size_t *column_number, const afw_utf8_t *s, afw_size_t offset, int tab_size, afw_xctx_t *xctx)
Determine the line and column of an offset in a string.
Definition: afw_utf8.c:1058
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_utf8_printf(const afw_pool_t *p, afw_xctx_t *xctx, const afw_utf8_z_t *format,...)
Create a utf-8 string using a c format string in specified pool.
Definition: afw_utf8.c:459
afw_uuid_create_utf8(const afw_pool_t *p, afw_xctx_t *xctx)
Create a UUID as a standard format UUID utf-8 string.
Definition: afw_uuid.c:62
#define afw_value_get_data_type(instance, xctx)
Call method get_data_type of interface afw_value.
#define afw_value_get_info(instance, info, p, xctx)
Call method get_info of interface afw_value.
#define afw_value_evaluate(value, p, xctx)
Evaluate value if needed using specific pool.
Definition: afw_value.h:841
afw_value_as_utf8(const afw_value_t *value, const afw_pool_t *p, afw_xctx_t *xctx)
Definition: afw_value.c:456
const afw_value_t * afw_value_block_finalize(const afw_value_block_t *block, afw_size_t argc, const afw_value_t *const *argv, afw_xctx_t *xctx)
Create and link a new block.
int afw_xctx_begin_stack_frame(afw_xctx_t *xctx)
Begin stack frame.
Definition: afw_xctx.h:329
void afw_xctx_end_stack_frame(int top, afw_xctx_t *xctx)
Set stack top.
Definition: afw_xctx.h:343
Resources that can be shared by multiple compiles.
const afw_utf8_t * source_location
Source location.
const afw_value_compiled_value_t * compiled_value
Compiled value this value is part of.
afw_size_t value_offset
Offset in full source of compiled value to this value.
Struc for afw_compile_type_info_t.
Definition: afw_compile.h:30
Interface afw_data_type public struct.
Interface afw_object public struct.
Interface afw_pool public struct.
NFC normalized UTF-8 string.
Definition: afw_common.h:545
struct for afw_value_block_t
struct for data type expression values.
Filled in by afw_value get_info method.
Definition: afw_value.h:49
Struct for compiled value value.
afw_size_t line_count
The total number of lines in source.
const afw_utf8_t * full_source_type
The type of the full source.
const afw_utf8_t * full_source
The full source that was compiled.
afw_size_t longest_line
The longest line excluding .
const afw_value_t * root_value
The root value.
const afw_utf8_t * reference_id
A uuid for this compiled value.
struct for data type object values.
Interface afw_value public struct.
struct for data type string values.
struct for data type template values.
Interface afw_xctx public struct.