Adaptive Framework  0.9.0
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
Files | Data Structures | Macros | Typedefs | Enumerations | Functions

Files

file  afw_compile.h
 Header file for Adaptive Framework Compile.
 

Data Structures

struct  afw_compile_type_info_s
 Struc for afw_compile_type_info_t. More...
 

Macros

#define afw_compile_and_evaluate_type(compile_type, string, source_location, p, xctx)
 Convience macro to call afw_compile_and_evaluate() with compile_type. More...
 
#define afw_compile_to_value(string, source_location, compile_type, parent, shared, p, xctx)
 Compile string to adaptive value. More...
 
#define afw_compile_expression(string, source_location, parent, shared, p, xctx)
 Compile expression. More...
 
#define afw_compile_hybrid_source(string, source_location, parent, shared, p, xctx)
 Compile hybrid. More...
 
#define afw_compile_template(string, source_location, parent, shared, p, xctx)
 Compile template. More...
 

Typedefs

typedef enum afw_compile_residual_check_e afw_compile_residual_check_t
 Residual checking options.
 

Enumerations

enum  afw_compile_residual_check_e { afw_compile_residual_check_none , afw_compile_residual_check_to_newline , afw_compile_residual_check_to_full }
 Residual checking options.
 

Functions

const afw_compile_type_info_tafw_compile_type_get_info_by_pneumonic (const afw_utf8_t *pneumonic, const afw_xctx_t *xctx)
 Return compile type info for a pneumonic. More...
 
const afw_compile_type_info_tafw_compile_type_get_info (afw_compile_type_t compile_type, const afw_xctx_t *xctx)
 Return info for a afw_compile_type_t. More...
 
const afw_compile_shared_tafw_compile_shared_create (const afw_pool_t *p, afw_xctx_t *xctx)
 Created a struct for sharing resources by multiple compiles. More...
 
const afw_value_tafw_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. More...
 
const afw_value_tafw_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. More...
 
const afw_value_tafw_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. More...
 
const afw_object_tafw_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. More...
 
void 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. More...
 
const afw_object_tafw_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. More...
 
void 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. More...
 
const afw_utf8_tafw_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. More...
 

Detailed Description

Adaptive Framework Compile AFW syntax.

Macro Definition Documentation

◆ afw_compile_and_evaluate_type

#define afw_compile_and_evaluate_type (   compile_type,
  string,
  source_location,
  p,
  xctx 
)
Value:
afw_compile_and_evaluate(string, source_location, \
afw_compile_type_ ## compile_type, p, xctx)
const afw_value_t * 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

Convience macro to call afw_compile_and_evaluate() with compile_type.

Parameters
compile_typeappended to "afw_compile_type_" for option.
stringto compile and evaluate.
source_locationto associate with compiled string or NULL.
pto use for result.
xctxof caller.
Returns
result of compiling and evaluating string.

Definition at line 118 of file afw_compile.h.

◆ afw_compile_expression

#define afw_compile_expression (   string,
  source_location,
  parent,
  shared,
  p,
  xctx 
)
Value:
afw_compile_to_value_with_callback(string, NULL, NULL, \
source_location, afw_compile_type_expression, \
afw_compile_residual_check_to_full, \
parent, shared, p, xctx)
const afw_value_t * 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

Compile expression.

Parameters
stringcontaining expression to compile.
source_locationto associate with compiled string or NULL.
parentcompiled value for contextual and shared resource or NULL.
sharedstruct for shared compile resources or NULL.
pto use for result or NULL.
xctxof caller.
Returns
value

Either shared, parent, or p must be specified. The p used by the parser is shared->p, parent->p, or p as available in that order.

Definition at line 210 of file afw_compile.h.

◆ afw_compile_hybrid_source

#define afw_compile_hybrid_source (   string,
  source_location,
  parent,
  shared,
  p,
  xctx 
)
Value:
afw_compile_to_value_with_callback(string, NULL, NULL, \
source_location, afw_compile_type_hybrid, \
afw_compile_residual_check_to_full, \
parent, shared, p, xctx)

Compile hybrid.

Parameters
stringcontaining hybrid source to compile.
source_locationto associate with compiled string or NULL.
parentcompiled value for contextual and shared resource or NULL.
sharedstruct for shared compile resources or NULL.
pto use for result or NULL.
xctxof caller.
Returns
value

Either shared, parent, or p must be specified. The p used by the parser is shared->p, parent->p, or p as available in that order.

Definition at line 256 of file afw_compile.h.

◆ afw_compile_template

#define afw_compile_template (   string,
  source_location,
  parent,
  shared,
  p,
  xctx 
)
Value:
afw_compile_to_value_with_callback(string, NULL, NULL, \
source_location, afw_compile_type_template, \
afw_compile_residual_check_to_full, \
parent, shared, p, xctx)

Compile template.

Parameters
stringcontaining template to compile.
source_locationto associate with compiled string or NULL.
parentcompiled value for contextual and shared resource or NULL.
sharedstruct for shared compile resources or NULL.
pto use for result or NULL.
xctxof caller.
Returns
value

Either shared, parent, or p must be specified. The p used by the parser is shared->p, parent->p, or p as available in that order.

Definition at line 278 of file afw_compile.h.

◆ afw_compile_to_value

#define afw_compile_to_value (   string,
  source_location,
  compile_type,
  parent,
  shared,
  p,
  xctx 
)
Value:
afw_compile_to_value_with_callback(string, NULL, NULL, \
source_location, compile_type, afw_compile_residual_check_to_full, \
parent, shared, p, xctx)

Compile string to adaptive value.

Parameters
stringto compile.
source_locationto associate with compiled string or NULL.
compile_typeCompile type.
parentcompiled value for contextual and shared resource or NULL.
sharedstruct for shared compile resources or NULL.
pto use for result or NULL.
xctxof caller.
Returns
value

Either shared, parent, or p must be specified. The p used by the parser is shared->p, parent->p, or p as available in that order.

This function can be used for callbacks of type afw_utf8_to_value_t.

If source_location is NULL and path is specified, the path will be used as the source location.

The meta.path and meta.parentPaths of any compiled object is always used to set the corresponding values in the new object.

Definition at line 189 of file afw_compile.h.

Function Documentation

◆ afw_compile_and_evaluate()

const afw_value_t* 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.

Parameters
stringto compile and evaluate.
source_locationto associate with compiled string or NULL.
compile_typeCompile type.
pto use for result.
xctxof caller.
Returns
result of compiling and evaluating string.
Todo:
more needs to be thought about for memory usage. Only result needs to be saved, but anything "done" in the script needs to remain "done". For instance, if a service is started, its pool should be available. This might solve itself with new memory management.

Definition at line 66 of file afw_compile.c.

◆ afw_compile_expressions_templates_and_hybrids()

void 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.

Parameters
objectto process.
source_locationto associate with compiled string or NULL.
recursiveindicates object should be processed recursively.
sharedstruct for shared compile resources or NULL.
xctxof caller.

The object must be mutable. The p of the object will be used.

Embedded objects are processed as well.

Property source_location defaults to the object path.

" property " followed by the property name will be appended to the source_location when appropriate.

All single data type expression, template, and hybrid values in object will be replaced with the their compiled value.

The compiled value will be evaluated each time the property in the object is accessed in the context of that access.

This function is called for each conf and map object.

Todo:
FIXME: Support bags and lists?

Definition at line 411 of file afw_compile.c.

◆ afw_compile_hybrid()

const afw_value_t* 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.

Parameters
valuecontaining hybrid to compile.
source_locationto associate with compiled string or NULL.
parentcompiled value for contextual and shared resource or NULL.
sharedstruct for shared compile resources or NULL.
pto use for result or NULL.
xctxof caller.
Returns
value

Either shared, parent, or p must be specified. The p used by the parser is shared->p, parent->p, or p as available in that order.

Definition at line 385 of file afw_compile.c.

◆ afw_compile_object_all_hybrid_properties()

const afw_object_t* 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.

Parameters
objectto process.
source_locationto associate with compiled string or NULL.
sharedstruct for shared compile resources or NULL.
pto use for result or NULL.
xctxof caller.
Returns
object instance.

This was originally written to process a qualifier object which is just an object where all properties are hybrids. The resulting object contains properties representing variables and their evaluated values. See afw_xctx_push_qualifier_object().

Definition at line 499 of file afw_compile.c.

◆ afw_compile_shared_create()

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.

Parameters
stringto compile or NULL.
pto use for result.
xctxof caller.
Returns
stuct to be passed in the shared parameter of compiles.

The purpose of this struct is to allow multiple compiles that have a p with the same lifetime to share strings, literals, etc.

Definition at line 2168 of file afw_compile_lexical.c.

◆ afw_compile_source_location_of_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.

Parameters
value
pto use for result or NULL.
xctxof caller
Returns
source location of value or NULL if it can't be determined.

Definition at line 578 of file afw_compile.c.

◆ afw_compile_split_qualified_name()

void 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.

Parameters
qualified_name(qualifier:: optional)
qualifieris preallocated place to return qualifier.
nameis preallocated place to return name.
xctxof caller.

Definition at line 548 of file afw_compile.c.

◆ afw_compile_to_object()

const afw_object_t* 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.

Parameters
stringto compile.
source_locationto associate with compiled string or NULL.
adaptor_idto use for created object or NULL.
object_type_idto use for created object or NULL.
object_idto use for created object or NULL.
cede_pif true, cede control of p to the created object.
pto use for result or NULL.
xctxof caller.
Returns
object instance.

If source_location is NULL and path is specified, adaptor_id, object_type_id, and object_id will be used to produce a path that will be used as the source location.

If adaptor_id is NULL, object_type_id and object_id must be NULL. If they're NULL, the object's meta will not be set.

Definition at line 313 of file afw_compile.c.

◆ afw_compile_to_value_with_callback()

const afw_value_t* 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.

Parameters
stringto compile or NULL.
callbackto get an octet or NULL.
callback_datato pass to callback function or NULL.
source_locationto associate with compiled string or NULL.
compile_typeCompile type.
residual_checkoption.
parentcompiled value for contextual and shared resource or NULL.
sharedstruct for shared compile resources or NULL.
pto use for result or NULL.
xctxof caller.
Returns
value or NULL if afw_compile_type_parenthesized_expression and all input is whitespace or comments.

Either shared, parent, or p must be specified. The p used by the parser is shared->p, parent->p, or p as available in that order.

Either string or callback must be non-NULL. If both are non-NULL, the string will be processed first.

If source_location is NULL and path is specified, the path will be used as the source location.

The meta.path and meta.parentPaths of any compiled object is always used to set the corresponding values in the new object.

Definition at line 140 of file afw_compile.c.

◆ afw_compile_type_get_info()

const afw_compile_type_info_t* afw_compile_type_get_info ( afw_compile_type_t  compile_type,
const afw_xctx_t xctx 
)

Return info for a afw_compile_type_t.

Parameters
compile_type.
Returns
info for compile type or info for error with no compile function.

Definition at line 120 of file afw_compile.c.

◆ afw_compile_type_get_info_by_pneumonic()

const afw_compile_type_info_t* afw_compile_type_get_info_by_pneumonic ( const afw_utf8_t pneumonic,
const afw_xctx_t xctx 
)

Return compile type info for a pneumonic.

Parameters
pneumonicof a compile type.
See also
AFW_COMPILE_TYPE_MAP.
Returns
info for compile type or info for error with no compile function.

Definition at line 97 of file afw_compile.c.