17 #define XX(name, data_type, compile_function, description) \
19 static const afw_utf8_t \
20 impl_compile_type_ ## name ## _name = \
21 AFW_UTF8_LITERAL(#name); \
23 static const afw_value_string_t \
24 impl_compile_type_ ## name ## _name_value = \
25 {&afw_value_evaluated_string_inf, AFW_UTF8_LITERAL(#name)}; \
27 static const afw_utf8_t \
28 impl_compile_type_ ## name ## _description = \
29 AFW_UTF8_LITERAL(#description); \
31 static const afw_value_string_t \
32 impl_compile_type_ ## name ## _description_value = \
33 {&afw_value_evaluated_string_inf, AFW_UTF8_LITERAL(#description)}; \
42 impl_compile_type_pneumonic[] = {
43 #define XX(name, data_type, compile_function, description) \
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, \
57 afw_compile_type_error,
58 NULL, NULL, NULL, NULL, NULL, NULL
84 source_location, compile_type,
85 afw_compile_residual_check_to_full, \
103 for (compile_type = afw_compile_type_error;
104 compile_type < afw_compile_type_count &&
106 impl_compile_type_pneumonic[compile_type].name);
109 if (compile_type >= afw_compile_type_count) {
110 compile_type = afw_compile_type_error;
113 return &impl_compile_type_pneumonic[compile_type];
125 result = &impl_compile_type_pneumonic[afw_compile_type_error];
126 if (compile_type > 0 &&
127 compile_type < afw_compile_type_count)
129 result = &impl_compile_type_pneumonic[compile_type];
162 if (compile_type == afw_compile_type_regexp) {
164 "afw_compile_type_regexp not supported yet",
167 else if (compile_type == afw_compile_type_xpathExpression) {
169 "afw_compile_type_xpathExpression not supported yet",
174 parser = afw_compile_lexical_parser_create(
175 string, callback, callback_data, source_location,
176 compile_type, residual_check,
false, parent, shared, p, xctx);
186 if (compile_type == afw_compile_type_json ||
187 compile_type == afw_compile_type_relaxed_json)
190 result = afw_compile_parse_Json(parser);
191 afw_compile_check_for_residual(parser);
199 result = (
const afw_value_t *)parser->compiled_value;
200 interim = &parser->compiled_value->
root_value;
207 if (!parent && compile_type != afw_compile_type_script)
211 interim = &block_argv[0];
212 block = afw_compile_parse_link_new_value_block(parser, 0);
216 if (compile_type == afw_compile_type_script) {
218 *interim = afw_compile_parse_Script(parser);
221 else if (compile_type == afw_compile_type_template) {
223 *interim = afw_compile_parse_Template(parser);
226 else if (compile_type == afw_compile_type_expression) {
228 *interim = afw_compile_parse_Expression(parser);
231 else if (compile_type == afw_compile_type_expression_tuple) {
233 *interim = afw_compile_parse_ExpressionTuple(parser);
236 else if (compile_type == afw_compile_type_parenthesized_expression) {
238 afw_compile_skip_ws(parser);
239 if (afw_compile_is_at_eof()) {
243 *interim = afw_compile_parse_ParenthesizedExpression(parser);
246 else if (compile_type == afw_compile_type_hybrid) {
248 afw_compile_skip_ws(parser);
249 *interim = afw_compile_parse_Hybrid(parser);
252 else if (compile_type == afw_compile_type_test_script) {
254 afw_compile_skip_ws(parser);
255 *interim = afw_compile_parse_TestScript(parser);
266 afw_compile_parse_pop_value_block(parser);
270 if (parser->full_source)
273 parser->full_source, parser->p, xctx);
276 cursor = line_begin = parser->full_source->s;
277 count < parser->full_source->len; count++, cursor++)
288 line_begin = cursor + 1;
293 afw_compile_check_for_residual(parser);
302 afw_compile_lexical_parser_finish_and_release(parser, xctx);
332 if ((adaptor_id || object_type_id || object_id) &&
333 (!adaptor_id || !object_type_id || !object_id))
336 "If adaptor_id, object_type_id, or object_id is not NULL, all must "
342 if (!source_location && adaptor_id) {
344 adaptor_id, object_type_id, object_id, parser_p, xctx);
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);
361 value = afw_compile_parse_Object(parser,
false,
false);
362 afw_compile_check_for_residual(parser);
367 adaptor_id, object_type_id, object_id, xctx);
376 afw_compile_lexical_parser_finish_and_release(parser, xctx);
403 source_location, parent, shared, p, xctx);
424 if (!source_location) {
434 for (iterator = NULL;;) {
438 &iterator, &property_name, xctx);
449 detail_source_location,
450 afw_compile_type_expression,
451 NULL, shared, NULL, xctx);
463 detail_source_location,
464 afw_compile_type_template,
465 NULL, shared, NULL, xctx);
476 value, detail_source_location,
477 NULL, shared, NULL, xctx);
489 detail_source_location,
true, shared, xctx);
514 if (!source_location) {
517 if (!source_location) {
518 source_location = &afw_s_a_empty_string;
523 object, &iterator, &property_name, xctx)))
530 if (!value_data_type ||
539 detail_source_location, NULL, shared, p, xctx);
560 for (len = qualified_name->len, s = qualified_name->s; len > 0; len--, s++)
563 if (len < 2 || *(s + 1) !=
':') {
566 qualifier->len = s - qualified_name->s;
567 qualifier->s = qualified_name->s;
589 if (info.contextual) {
593 &line_number, &column_number,
604 line_number, column_number);
623 result = &afw_s_a_empty_string;
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.
struct afw_iterator_s afw_iterator_t
#define AFW_UTF8_FMT
Format string specifier used for afw_utf8_t.
#define AFW_COMPILE_TYPE_MAP(XX)
Compile Type Map.
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).
enum afw_compile_type_e afw_compile_type_t
Compile type enum.
char afw_utf8_octet_t
8 bits of utf-8 codepoint.
apr_size_t afw_size_t
size_t.
#define AFW_SIZE_T_FMT
Format string specifier used for afw_size_t.
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.
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.
afw_compile_type_get_info(afw_compile_type_t compile_type, const afw_xctx_t *xctx)
Return info for a afw_compile_type_t.
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.
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.
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.
#define afw_compile_to_value(string, source_location, compile_type, parent, shared, p, xctx)
Compile string to adaptive value.
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.
afw_compile_type_get_info_by_pneumonic(const afw_utf8_t *pneumonic, const afw_xctx_t *xctx)
Return compile type info for a pneumonic.
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.
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.
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.
#define AFW_FINALLY
Always executed regardless of error.
#define AFW_ENDTRY
Ends an AFW try block.
#define AFW_TRY
Begin an AFW TRY block.
#define AFW_THROW_ERROR_FZ(code, xctx, format_z,...)
Macro used to set error and 0 rv in xctx and throw it.
#define AFW_THROW_ERROR_Z(code, message_z, xctx)
Macro used to set error and 0 rv in xctx and throw it.
#define afw_memory_clear(to)
Clear preallocated memory for sizeof(*(to)).
#define afw_memory_copy(to, from)
Copy to preallocated memory of same type.
#define afw_object_get_next_property(instance, iterator, property_name, xctx)
Call method get_next_property of interface afw_object.
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.
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.
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.
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.
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.
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.
afw_uuid_create_utf8(const afw_pool_t *p, afw_xctx_t *xctx)
Create a UUID as a standard format UUID utf-8 string.
#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.
afw_value_as_utf8(const afw_value_t *value, const afw_pool_t *p, afw_xctx_t *xctx)
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.
void afw_xctx_end_stack_frame(int top, afw_xctx_t *xctx)
Set stack top.
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.
Interface afw_data_type public struct.
Interface afw_object public struct.
Interface afw_pool public struct.
NFC normalized UTF-8 string.
struct for afw_value_block_t
struct for data type expression values.
Filled in by afw_value get_info method.
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.