the type is now in the unlang_op_t. And even that will be removed.
also reformat for consistency.
and add unlang_t size and name for each instruction
* functionality can be in their own source files, and we don't need to include
* supporting types and function declarations in the interpreter.
*
- * Later, this could potentially be used to register custom operations for modules.
- *
- * The reason why there's a function instead of accessing the unlang_op array
- * directly, is because 'type' really needs to go away, as needing to add ops to
- * the unlang_type_t enum breaks the pluggable module model. If there's no
- * explicit/consistent type values we need to enumerate the operations ourselves.
- *
- * @param[in] type Operation identifier. Used to map compiled unlang code
- * to operations.
- * @param[in] op unlang_op to register.
+ * @param[in] op #unlang_op_t to register.
*/
-void unlang_register(int type, unlang_op_t *op)
+void unlang_register(unlang_op_t *op)
{
- fr_assert(type < UNLANG_TYPE_MAX); /* Unlang max isn't a valid type */
+ fr_assert(op->type < UNLANG_TYPE_MAX); /* Unlang max isn't a valid type */
fr_assert(unlang_op_table != NULL);
- fr_assert(op->type == (unlang_type_t) type);
- memcpy(&unlang_ops[type], op, sizeof(unlang_ops[type]));
+ memcpy(&unlang_ops[op->type], op, sizeof(unlang_ops[op->type]));
/*
* Some instruction types are internal, and are not real keywords.
*/
if ((op->flag & UNLANG_OP_FLAG_INTERNAL) != 0) return;
- MEM(fr_hash_table_insert(unlang_op_table, &unlang_ops[type]));
+ MEM(fr_hash_table_insert(unlang_op_table, &unlang_ops[op->type]));
}
static TALLOC_CTX *unlang_ctx = NULL;
void unlang_call_init(void)
{
- unlang_register(UNLANG_TYPE_CALL,
- &(unlang_op_t){
- .name = "call",
- .flag = UNLANG_OP_FLAG_RCODE_SET | UNLANG_OP_FLAG_DEBUG_BRACES,
- .type = UNLANG_TYPE_CALL,
+ unlang_register(&(unlang_op_t){
+ .name = "call",
+ .flag = UNLANG_OP_FLAG_RCODE_SET | UNLANG_OP_FLAG_DEBUG_BRACES,
+ .type = UNLANG_TYPE_CALL,
- .compile = unlang_compile_call,
- .interpret = unlang_call_frame_init,
+ .compile = unlang_compile_call,
+ .interpret = unlang_call_frame_init,
-
- .unlang_size = sizeof(unlang_call_t),
- .unlang_name = "unlang_call_t",
- });
+ .unlang_size = sizeof(unlang_call_t),
+ .unlang_name = "unlang_call_t",
+ });
}
void unlang_caller_init(void)
{
- unlang_register(UNLANG_TYPE_CALLER,
- &(unlang_op_t){
- .name = "caller",
- .type = UNLANG_TYPE_CALLER,
- .flag = UNLANG_OP_FLAG_DEBUG_BRACES,
-
- .compile = unlang_compile_caller,
- .interpret = unlang_caller,
-
- .unlang_size = sizeof(unlang_caller_t),
- .unlang_name = "unlang_caller_t",
- });
+ unlang_register(&(unlang_op_t){
+ .name = "caller",
+ .type = UNLANG_TYPE_CALLER,
+ .flag = UNLANG_OP_FLAG_DEBUG_BRACES,
+
+ .compile = unlang_compile_caller,
+ .interpret = unlang_caller,
+
+ .unlang_size = sizeof(unlang_caller_t),
+ .unlang_name = "unlang_caller_t",
+ });
}
void unlang_catch_init(void)
{
- unlang_register(UNLANG_TYPE_CATCH,
- &(unlang_op_t){
- .name = "catch",
- .type = UNLANG_TYPE_CATCH,
- .flag = UNLANG_OP_FLAG_DEBUG_BRACES,
-
- .compile = unlang_compile_catch,
- .interpret = unlang_catch,
-
- .unlang_size = sizeof(unlang_catch_t),
- .unlang_name = "unlang_catch_t",
- });
+ unlang_register(&(unlang_op_t){
+ .name = "catch",
+ .type = UNLANG_TYPE_CATCH,
+ .flag = UNLANG_OP_FLAG_DEBUG_BRACES,
+
+ .compile = unlang_compile_catch,
+ .interpret = unlang_catch,
+
+ .unlang_size = sizeof(unlang_catch_t),
+ .unlang_name = "unlang_catch_t",
+ });
}
int unlang_child_request_op_init(void)
{
- unlang_register(UNLANG_TYPE_CHILD_REQUEST,
- &(unlang_op_t){
- .name = "child-request",
- .type = UNLANG_TYPE_CHILD_REQUEST,
-
- /*
- * Frame can't be cancelled, because children need to
- * write out status to the parent. If we don't do this,
- * then all children must be detachable and must detach
- * so they don't try and write out status to a "done"
- * parent.
- *
- * It's easier to allow the child/parent relationship
- * to end normally so that non-detachable requests are
- * guaranteed the parent still exists.
- */
- .flag = UNLANG_OP_FLAG_NO_FORCE_UNWIND | UNLANG_OP_FLAG_INTERNAL,
-
- .interpret = unlang_child_request_done,
- .signal = unlang_child_request_signal,
-
- .frame_state_size = sizeof(unlang_frame_state_child_request_t),
- .frame_state_type = "unlang_frame_state_child_request_t"
- });
+ unlang_register(&(unlang_op_t){
+ .name = "child-request",
+ .type = UNLANG_TYPE_CHILD_REQUEST,
+
+ /*
+ * Frame can't be cancelled, because children need to
+ * write out status to the parent. If we don't do this,
+ * then all children must be detachable and must detach
+ * so they don't try and write out status to a "done"
+ * parent.
+ *
+ * It's easier to allow the child/parent relationship
+ * to end normally so that non-detachable requests are
+ * guaranteed the parent still exists.
+ */
+ .flag = UNLANG_OP_FLAG_NO_FORCE_UNWIND | UNLANG_OP_FLAG_INTERNAL,
+
+ .interpret = unlang_child_request_done,
+ .signal = unlang_child_request_signal,
+
+ .frame_state_size = sizeof(unlang_frame_state_child_request_t),
+ .frame_state_type = "unlang_frame_state_child_request_t"
+ });
return 0;
}
void unlang_condition_init(void)
{
- unlang_register(UNLANG_TYPE_IF,
- &(unlang_op_t){
- .name = "if",
- .type = UNLANG_TYPE_IF,
- .flag = UNLANG_OP_FLAG_DEBUG_BRACES,
-
- .compile = unlang_compile_if,
- .interpret = unlang_if,
-
- .unlang_size = sizeof(unlang_cond_t),
- .unlang_name = "unlang_cond_t",
- .pool_headers = 1 + 1 + (TMPL_POOL_DEF_HEADERS * 2),
- .pool_len = sizeof(map_t) + (TMPL_POOL_DEF_LEN * 2),
-
- .frame_state_size = sizeof(unlang_frame_state_cond_t),
- .frame_state_type = "unlang_frame_state_cond_t",
- });
-
- unlang_register(UNLANG_TYPE_ELSE,
- &(unlang_op_t){
- .name = "else",
- .type = UNLANG_TYPE_ELSE,
- .flag = UNLANG_OP_FLAG_DEBUG_BRACES,
-
- .compile = unlang_compile_else,
- .interpret = unlang_group,
-
- .unlang_size = sizeof(unlang_group_t),
- .unlang_name = "unlang_group_t"
- });
-
- unlang_register(UNLANG_TYPE_ELSIF,
- &(unlang_op_t){
- .name = "elsif",
- .type = UNLANG_TYPE_ELSIF,
- .flag = UNLANG_OP_FLAG_DEBUG_BRACES,
-
- .compile = unlang_compile_elsif,
- .interpret = unlang_if,
-
- .unlang_size = sizeof(unlang_cond_t),
- .unlang_name = "unlang_cond_t",
- .pool_headers = 1 + 1 + (TMPL_POOL_DEF_HEADERS * 2),
- .pool_len = sizeof(map_t) + (TMPL_POOL_DEF_LEN * 2),
-
- .frame_state_size = sizeof(unlang_frame_state_cond_t),
- .frame_state_type = "unlang_frame_state_cond_t",
- });
+ unlang_register(&(unlang_op_t){
+ .name = "if",
+ .type = UNLANG_TYPE_IF,
+ .flag = UNLANG_OP_FLAG_DEBUG_BRACES,
+
+ .compile = unlang_compile_if,
+ .interpret = unlang_if,
+
+ .unlang_size = sizeof(unlang_cond_t),
+ .unlang_name = "unlang_cond_t",
+ .pool_headers = 1 + 1 + (TMPL_POOL_DEF_HEADERS * 2),
+ .pool_len = sizeof(map_t) + (TMPL_POOL_DEF_LEN * 2),
+
+ .frame_state_size = sizeof(unlang_frame_state_cond_t),
+ .frame_state_type = "unlang_frame_state_cond_t",
+ });
+
+ unlang_register(&(unlang_op_t){
+ .name = "else",
+ .type = UNLANG_TYPE_ELSE,
+ .flag = UNLANG_OP_FLAG_DEBUG_BRACES,
+
+ .compile = unlang_compile_else,
+ .interpret = unlang_group,
+
+ .unlang_size = sizeof(unlang_group_t),
+ .unlang_name = "unlang_group_t"
+ });
+
+ unlang_register(&(unlang_op_t){
+ .name = "elsif",
+ .type = UNLANG_TYPE_ELSIF,
+ .flag = UNLANG_OP_FLAG_DEBUG_BRACES,
+
+ .compile = unlang_compile_elsif,
+ .interpret = unlang_if,
+
+ .unlang_size = sizeof(unlang_cond_t),
+ .unlang_name = "unlang_cond_t",
+ .pool_headers = 1 + 1 + (TMPL_POOL_DEF_HEADERS * 2),
+ .pool_len = sizeof(map_t) + (TMPL_POOL_DEF_LEN * 2),
+
+ .frame_state_size = sizeof(unlang_frame_state_cond_t),
+ .frame_state_type = "unlang_frame_state_cond_t",
+ });
}
*/
void unlang_detach_init(void)
{
- unlang_register(UNLANG_TYPE_DETACH,
- &(unlang_op_t){
- .name = "detach",
- .type = UNLANG_TYPE_DETACH,
- .flag = UNLANG_OP_FLAG_SINGLE_WORD,
+ unlang_register(&(unlang_op_t){
+ .name = "detach",
+ .type = UNLANG_TYPE_DETACH,
+ .flag = UNLANG_OP_FLAG_SINGLE_WORD,
- .compile = unlang_compile_detach,
- .interpret = unlang_detach,
+ .compile = unlang_compile_detach,
+ .interpret = unlang_detach,
- .unlang_size = sizeof(unlang_group_t),
- .unlang_name = "unlang_group_t",
+ .unlang_size = sizeof(unlang_group_t),
+ .unlang_name = "unlang_group_t",
});
}
void unlang_edit_init(void)
{
- unlang_register(UNLANG_TYPE_EDIT,
- &(unlang_op_t){
- .name = "edit",
- .type = UNLANG_TYPE_EDIT,
- .flag = UNLANG_OP_FLAG_INTERNAL,
+ unlang_register(&(unlang_op_t){
+ .name = "edit",
+ .type = UNLANG_TYPE_EDIT,
+ .flag = UNLANG_OP_FLAG_INTERNAL,
- .interpret = unlang_edit_state_init,
+ .interpret = unlang_edit_state_init,
- .frame_state_size = sizeof(unlang_frame_state_edit_t),
- .frame_state_type = "unlang_frame_state_edit_t",
- });
+ .unlang_size = sizeof(unlang_edit_t),
+ .unlang_name = "unlang_edit_t",
+
+ .frame_state_size = sizeof(unlang_frame_state_edit_t),
+ .frame_state_type = "unlang_frame_state_edit_t",
+ });
}
void unlang_finally_init(void)
{
- unlang_register(UNLANG_TYPE_FINALLY,
- &(unlang_op_t){
- .name = "finally",
- .type = UNLANG_TYPE_FINALLY,
-
- .interpret = unlang_finally,
-
- /*
- * No debug braces, the thing
- * that's pushed in unlang
- * finally should have braces
- */
- .flag = UNLANG_OP_FLAG_NO_FORCE_UNWIND | UNLANG_OP_FLAG_INTERNAL,
-
- .frame_state_size = sizeof(unlang_frame_state_finally_t),
- .frame_state_type = "unlang_frame_state_finally_t",
- });
+ unlang_register(&(unlang_op_t){
+ .name = "finally",
+ .type = UNLANG_TYPE_FINALLY,
+
+ .interpret = unlang_finally,
+
+ /*
+ * No debug braces, the thing
+ * that's pushed in unlang
+ * finally should have braces
+ */
+ .flag = UNLANG_OP_FLAG_NO_FORCE_UNWIND | UNLANG_OP_FLAG_INTERNAL,
+
+ .frame_state_size = sizeof(unlang_frame_state_finally_t),
+ .frame_state_type = "unlang_frame_state_finally_t",
+ });
}
void unlang_foreach_init(void)
{
- unlang_register(UNLANG_TYPE_FOREACH,
- &(unlang_op_t){
- .name = "foreach",
- .type = UNLANG_TYPE_FOREACH,
- .flag = UNLANG_OP_FLAG_DEBUG_BRACES | UNLANG_OP_FLAG_BREAK_POINT | UNLANG_OP_FLAG_CONTINUE_POINT,
-
- .compile = unlang_compile_foreach,
- .interpret = unlang_foreach,
-
- .unlang_size = sizeof(unlang_foreach_t),
- .unlang_name = "unlang_foreach_t",
-
- .pool_headers = TMPL_POOL_DEF_HEADERS,
- .pool_len = TMPL_POOL_DEF_LEN
- });
-
- unlang_register(UNLANG_TYPE_BREAK,
- &(unlang_op_t){
- .name = "break",
- .type = UNLANG_TYPE_BREAK,
- .flag = UNLANG_OP_FLAG_SINGLE_WORD
+ unlang_register(&(unlang_op_t){
+ .name = "foreach",
+ .type = UNLANG_TYPE_FOREACH,
+ .flag = UNLANG_OP_FLAG_DEBUG_BRACES | UNLANG_OP_FLAG_BREAK_POINT | UNLANG_OP_FLAG_CONTINUE_POINT,
+
+ .compile = unlang_compile_foreach,
+ .interpret = unlang_foreach,
+
+ .unlang_size = sizeof(unlang_foreach_t),
+ .unlang_name = "unlang_foreach_t",
+
+ .pool_headers = TMPL_POOL_DEF_HEADERS,
+ .pool_len = TMPL_POOL_DEF_LEN
+ });
+
+ unlang_register(&(unlang_op_t){
+ .name = "break",
+ .type = UNLANG_TYPE_BREAK,
+ .flag = UNLANG_OP_FLAG_SINGLE_WORD
,
- .compile = unlang_compile_break,
- .interpret = unlang_break,
+ .compile = unlang_compile_break,
+ .interpret = unlang_break,
- .unlang_size = sizeof(unlang_group_t),
- .unlang_name = "unlang_group_t",
- });
+ .unlang_size = sizeof(unlang_group_t),
+ .unlang_name = "unlang_group_t",
+ });
- unlang_register(UNLANG_TYPE_CONTINUE,
- &(unlang_op_t){
- .name = "continue",
- .type = UNLANG_TYPE_CONTINUE,
- .flag = UNLANG_OP_FLAG_SINGLE_WORD,
+ unlang_register(&(unlang_op_t){
+ .name = "continue",
+ .type = UNLANG_TYPE_CONTINUE,
+ .flag = UNLANG_OP_FLAG_SINGLE_WORD,
- .compile = unlang_compile_continue,
- .interpret = unlang_continue,
+ .compile = unlang_compile_continue,
+ .interpret = unlang_continue,
- .unlang_size = sizeof(unlang_group_t),
- .unlang_name = "unlang_group_t",
- });
+ .unlang_size = sizeof(unlang_group_t),
+ .unlang_name = "unlang_group_t",
+ });
}
void unlang_function_init(void)
{
- unlang_register(UNLANG_TYPE_FUNCTION,
- &(unlang_op_t){
- .name = "function",
- .type = UNLANG_TYPE_FUNCTION,
- .flag = UNLANG_OP_FLAG_RETURN_POINT | UNLANG_OP_FLAG_INTERNAL,
-
- .interpret = call_no_result,
- .signal = unlang_function_signal,
- .dump = unlang_function_dump,
- .frame_state_size = sizeof(unlang_frame_state_func_t),
- .frame_state_type = "unlang_frame_state_func_t",
- });
+ unlang_register(&(unlang_op_t){
+ .name = "function",
+ .type = UNLANG_TYPE_FUNCTION,
+ .flag = UNLANG_OP_FLAG_RETURN_POINT | UNLANG_OP_FLAG_INTERNAL,
+ .interpret = call_no_result,
+ .signal = unlang_function_signal,
+ .dump = unlang_function_dump,
+
+ .unlang_size = sizeof(unlang_group_t),
+ .unlang_name = "unlang_group_t",
+
+ .frame_state_size = sizeof(unlang_frame_state_func_t),
+ .frame_state_type = "unlang_frame_state_func_t",
+ });
}
void unlang_group_init(void)
{
- unlang_register(UNLANG_TYPE_GROUP,
- &(unlang_op_t){
- .name = "group",
- .type = UNLANG_TYPE_GROUP,
- .flag = UNLANG_OP_FLAG_DEBUG_BRACES,
-
- .compile = unlang_compile_group,
- .interpret = unlang_group,
-
- .unlang_size = sizeof(unlang_group_t),
- .unlang_name = "unlang_group_t",
- });
-
- unlang_register(UNLANG_TYPE_REDUNDANT,
- &(unlang_op_t){
- .name = "redundant",
- .type = UNLANG_TYPE_REDUNDANT,
- .flag = UNLANG_OP_FLAG_DEBUG_BRACES,
-
- .compile = unlang_compile_redundant,
- .interpret = unlang_group,
-
- .unlang_size = sizeof(unlang_group_t),
- .unlang_name = "unlang_group_t",
- });
-
- unlang_register(UNLANG_TYPE_POLICY,
- &(unlang_op_t){
- .name = "policy",
- .type = UNLANG_TYPE_POLICY,
- .flag = UNLANG_OP_FLAG_DEBUG_BRACES | UNLANG_OP_FLAG_RETURN_POINT,
-
- .interpret = unlang_policy,
-
- .unlang_size = sizeof(unlang_group_t),
- .unlang_name = "unlang_group_t",
- });
+ unlang_register(&(unlang_op_t){
+ .name = "group",
+ .type = UNLANG_TYPE_GROUP,
+ .flag = UNLANG_OP_FLAG_DEBUG_BRACES,
+
+ .compile = unlang_compile_group,
+ .interpret = unlang_group,
+
+ .unlang_size = sizeof(unlang_group_t),
+ .unlang_name = "unlang_group_t",
+ });
+
+ unlang_register(&(unlang_op_t){
+ .name = "redundant",
+ .type = UNLANG_TYPE_REDUNDANT,
+ .flag = UNLANG_OP_FLAG_DEBUG_BRACES,
+
+ .compile = unlang_compile_redundant,
+ .interpret = unlang_group,
+
+ .unlang_size = sizeof(unlang_group_t),
+ .unlang_name = "unlang_group_t",
+ });
+
+ unlang_register(&(unlang_op_t){
+ .name = "policy",
+ .type = UNLANG_TYPE_POLICY,
+ .flag = UNLANG_OP_FLAG_DEBUG_BRACES | UNLANG_OP_FLAG_RETURN_POINT | UNLANG_OP_FLAG_INTERNAL,
+
+ .interpret = unlang_policy,
+
+ .unlang_size = sizeof(unlang_group_t),
+ .unlang_name = "unlang_group_t",
+ });
}
void unlang_limit_init(void)
{
- unlang_register(UNLANG_TYPE_LIMIT,
- &(unlang_op_t){
- .name = "limit",
- .type = UNLANG_TYPE_LIMIT,
- .flag = UNLANG_OP_FLAG_DEBUG_BRACES,
+ unlang_register(&(unlang_op_t){
+ .name = "limit",
+ .type = UNLANG_TYPE_LIMIT,
+ .flag = UNLANG_OP_FLAG_DEBUG_BRACES,
- .compile = unlang_compile_limit,
- .interpret = unlang_limit,
- .signal = unlang_limit_signal,
+ .compile = unlang_compile_limit,
+ .interpret = unlang_limit,
+ .signal = unlang_limit_signal,
- .unlang_size = sizeof(unlang_limit_t),
- .unlang_name = "unlang_limit_t",
+ .unlang_size = sizeof(unlang_limit_t),
+ .unlang_name = "unlang_limit_t",
- .frame_state_size = sizeof(unlang_frame_state_limit_t),
- .frame_state_type = "unlang_frame_state_limit_t",
+ .frame_state_size = sizeof(unlang_frame_state_limit_t),
+ .frame_state_type = "unlang_frame_state_limit_t",
- .thread_inst_size = sizeof(unlang_thread_limit_t),
- .thread_inst_type = "unlang_thread_limit_t",
- });
+ .thread_inst_size = sizeof(unlang_thread_limit_t),
+ .thread_inst_type = "unlang_thread_limit_t",
+ });
}
void unlang_load_balance_init(void)
{
- unlang_register(UNLANG_TYPE_LOAD_BALANCE,
- &(unlang_op_t){
- .name = "load-balance",
- .type = UNLANG_TYPE_LOAD_BALANCE,
- .flag = UNLANG_OP_FLAG_DEBUG_BRACES | UNLANG_OP_FLAG_RCODE_SET,
+ unlang_register(&(unlang_op_t){
+ .name = "load-balance",
+ .type = UNLANG_TYPE_LOAD_BALANCE,
+ .flag = UNLANG_OP_FLAG_DEBUG_BRACES | UNLANG_OP_FLAG_RCODE_SET,
- .compile = unlang_compile_load_balance,
- .interpret = unlang_load_balance,
+ .compile = unlang_compile_load_balance,
+ .interpret = unlang_load_balance,
- .unlang_size = sizeof(unlang_load_balance_t),
- .unlang_name = "unlang_load_balance_t",
+ .unlang_size = sizeof(unlang_load_balance_t),
+ .unlang_name = "unlang_load_balance_t",
- .frame_state_size = sizeof(unlang_frame_state_redundant_t),
- .frame_state_type = "unlang_frame_state_redundant_t",
- });
+ .frame_state_size = sizeof(unlang_frame_state_redundant_t),
+ .frame_state_type = "unlang_frame_state_redundant_t",
+ });
- unlang_register(UNLANG_TYPE_REDUNDANT_LOAD_BALANCE,
- &(unlang_op_t){
- .name = "redundant-load-balance",
- .type = UNLANG_TYPE_REDUNDANT_LOAD_BALANCE,
- .flag = UNLANG_OP_FLAG_DEBUG_BRACES | UNLANG_OP_FLAG_RCODE_SET,
+ unlang_register(&(unlang_op_t){
+ .name = "redundant-load-balance",
+ .type = UNLANG_TYPE_REDUNDANT_LOAD_BALANCE,
+ .flag = UNLANG_OP_FLAG_DEBUG_BRACES | UNLANG_OP_FLAG_RCODE_SET,
- .compile = unlang_compile_redundant_load_balance,
- .interpret = unlang_redundant_load_balance,
+ .compile = unlang_compile_redundant_load_balance,
+ .interpret = unlang_redundant_load_balance,
- .unlang_size = sizeof(unlang_load_balance_t),
- .unlang_name = "unlang_load_balance_t",
+ .unlang_size = sizeof(unlang_load_balance_t),
+ .unlang_name = "unlang_load_balance_t",
- .frame_state_size = sizeof(unlang_frame_state_redundant_t),
- .frame_state_type = "unlang_frame_state_redundant_t",
- });
+ .frame_state_size = sizeof(unlang_frame_state_redundant_t),
+ .frame_state_type = "unlang_frame_state_redundant_t",
+ });
}
void unlang_map_init(void)
{
- unlang_register(UNLANG_TYPE_UPDATE,
- &(unlang_op_t){
- .name = "update",
- .type = UNLANG_TYPE_UPDATE,
- .flag = UNLANG_OP_FLAG_DEBUG_BRACES,
-
- .compile = unlang_compile_update,
- .interpret = unlang_update_state_init,
-
- .unlang_size = sizeof(unlang_map_t),
- .unlang_name = "unlang_map_t",
- });
-
- unlang_register(UNLANG_TYPE_MAP,
- &(unlang_op_t){
- .name = "map",
- .type = UNLANG_TYPE_MAP,
- .flag = UNLANG_OP_FLAG_RCODE_SET,
-
- .compile = unlang_compile_map,
- .interpret = unlang_map_state_init,
-
- .unlang_size = sizeof(unlang_map_t),
- .unlang_name = "unlang_map_t",
-
- .frame_state_size = sizeof(unlang_frame_state_map_proc_t),
- .frame_state_type = "unlang_frame_state_map_proc_t",
- });
+ unlang_register(&(unlang_op_t){
+ .name = "update",
+ .type = UNLANG_TYPE_UPDATE,
+ .flag = UNLANG_OP_FLAG_DEBUG_BRACES,
+
+ .compile = unlang_compile_update,
+ .interpret = unlang_update_state_init,
+
+ .unlang_size = sizeof(unlang_map_t),
+ .unlang_name = "unlang_map_t",
+ });
+
+ unlang_register(&(unlang_op_t){
+ .name = "map",
+ .type = UNLANG_TYPE_MAP,
+ .flag = UNLANG_OP_FLAG_RCODE_SET,
+
+ .compile = unlang_compile_map,
+ .interpret = unlang_map_state_init,
+
+ .unlang_size = sizeof(unlang_map_t),
+ .unlang_name = "unlang_map_t",
+
+ .frame_state_size = sizeof(unlang_frame_state_map_proc_t),
+ .frame_state_type = "unlang_frame_state_map_proc_t",
+ });
}
void unlang_module_init(void)
{
- unlang_register(UNLANG_TYPE_MODULE,
- &(unlang_op_t){
- .name = "module",
- .type = UNLANG_TYPE_MODULE,
-
- /*
- * - UNLANG_OP_FLAG_RCODE_SET
- * Set request->rcode to be the rcode from the module.
- * - UNLANG_OP_FLAG_RETURN_POINT
- * Set the return point to be the module.
- */
- .flag = UNLANG_OP_FLAG_RCODE_SET |
- UNLANG_OP_FLAG_RETURN_POINT |
- UNLANG_OP_FLAG_INTERNAL,
-
- .interpret = unlang_module,
- .signal = unlang_module_signal,
-
- .frame_state_size = sizeof(unlang_frame_state_module_t),
- .frame_state_type = "unlang_frame_state_module_t",
- });
+ unlang_register(&(unlang_op_t){
+ .name = "module",
+ .type = UNLANG_TYPE_MODULE,
+
+ /*
+ * - UNLANG_OP_FLAG_RCODE_SET
+ * Set request->rcode to be the rcode from the module.
+ * - UNLANG_OP_FLAG_RETURN_POINT
+ * Set the return point to be the module.
+ */
+ .flag = UNLANG_OP_FLAG_RCODE_SET |
+ UNLANG_OP_FLAG_RETURN_POINT |
+ UNLANG_OP_FLAG_INTERNAL,
+
+ .interpret = unlang_module,
+ .signal = unlang_module_signal,
+
+ .unlang_size = sizeof(unlang_module_t),
+ .unlang_name = "unlang_module_t",
+
+ .frame_state_size = sizeof(unlang_frame_state_module_t),
+ .frame_state_type = "unlang_frame_state_module_t",
+ });
}
void unlang_parallel_init(void)
{
- unlang_register(UNLANG_TYPE_PARALLEL,
- &(unlang_op_t){
- .name = "parallel",
- .type = UNLANG_TYPE_PARALLEL,
- .flag = UNLANG_OP_FLAG_DEBUG_BRACES | UNLANG_OP_FLAG_RCODE_SET | UNLANG_OP_FLAG_NO_FORCE_UNWIND,
-
- .compile = unlang_compile_parallel,
- .interpret = unlang_parallel,
- .signal = unlang_parallel_signal,
-
- .unlang_size = sizeof(unlang_parallel_t),
- .unlang_name = "unlang_parallel_t"
- });
+ unlang_register(&(unlang_op_t){
+ .name = "parallel",
+ .type = UNLANG_TYPE_PARALLEL,
+ .flag = UNLANG_OP_FLAG_DEBUG_BRACES | UNLANG_OP_FLAG_RCODE_SET | UNLANG_OP_FLAG_NO_FORCE_UNWIND,
+
+ .compile = unlang_compile_parallel,
+ .interpret = unlang_parallel,
+ .signal = unlang_parallel_signal,
+
+ .unlang_size = sizeof(unlang_parallel_t),
+ .unlang_name = "unlang_parallel_t"
+ });
}
void unlang_return_init(void)
{
- unlang_register(UNLANG_TYPE_RETURN,
- &(unlang_op_t){
- .name = "return",
- .type = UNLANG_TYPE_RETURN,
- .flag = UNLANG_OP_FLAG_SINGLE_WORD,
+ unlang_register(&(unlang_op_t){
+ .name = "return",
+ .type = UNLANG_TYPE_RETURN,
+ .flag = UNLANG_OP_FLAG_SINGLE_WORD,
- .compile = unlang_compile_return,
- .interpret = unlang_return,
+ .compile = unlang_compile_return,
+ .interpret = unlang_return,
- .unlang_size = sizeof(unlang_group_t),
- .unlang_name = "unlang_group_t",
- });
+ .unlang_size = sizeof(unlang_group_t),
+ .unlang_name = "unlang_group_t",
+ });
}
*/
int unlang_subrequest_op_init(void)
{
- unlang_register(UNLANG_TYPE_SUBREQUEST,
- &(unlang_op_t){
- .name = "subrequest",
- .type = UNLANG_TYPE_SUBREQUEST,
-
- /*
- * Frame can't be cancelled, because children need to
- * write out status to the parent. If we don't do this,
- * then all children must be detachable and must detach
- * so they don't try and write out status to a "done"
- * parent.
- *
- * It's easier to allow the child/parent relationship
- * to end normally so that non-detachable requests are
- * guaranteed the parent still exists.
- */
- .flag = UNLANG_OP_FLAG_DEBUG_BRACES | UNLANG_OP_FLAG_RCODE_SET | UNLANG_OP_FLAG_NO_FORCE_UNWIND,
+ unlang_register(&(unlang_op_t) {
+ .name = "subrequest",
+ .type = UNLANG_TYPE_SUBREQUEST,
- .compile = unlang_compile_subrequest,
- .interpret = unlang_subrequest_init,
- .signal = unlang_subrequest_signal,
+ /*
+ * Frame can't be cancelled, because children need to
+ * write out status to the parent. If we don't do this,
+ * then all children must be detachable and must detach
+ * so they don't try and write out status to a "done"
+ * parent.
+ *
+ * It's easier to allow the child/parent relationship
+ * to end normally so that non-detachable requests are
+ * guaranteed the parent still exists.
+ */
+ .flag = UNLANG_OP_FLAG_DEBUG_BRACES | UNLANG_OP_FLAG_RCODE_SET | UNLANG_OP_FLAG_NO_FORCE_UNWIND,
+ .compile = unlang_compile_subrequest,
+ .interpret = unlang_subrequest_init,
+ .signal = unlang_subrequest_signal,
- .unlang_size = sizeof(unlang_subrequest_t),
- .unlang_name = "unlang_subrequest_t",
- .pool_headers = (TMPL_POOL_DEF_HEADERS * 3),
- .pool_len = (TMPL_POOL_DEF_LEN * 3),
+ .unlang_size = sizeof(unlang_subrequest_t),
+ .unlang_name = "unlang_subrequest_t",
+ .pool_headers = (TMPL_POOL_DEF_HEADERS * 3),
+ .pool_len = (TMPL_POOL_DEF_LEN * 3),
- .frame_state_size = sizeof(unlang_child_request_t),
- .frame_state_type = "unlang_child_request_t",
- });
+ .frame_state_size = sizeof(unlang_child_request_t),
+ .frame_state_type = "unlang_child_request_t",
+ });
if (unlang_child_request_op_init() < 0) return -1;
void unlang_switch_init(void)
{
- unlang_register(UNLANG_TYPE_SWITCH,
- &(unlang_op_t){
- .name = "switch",
- .type = UNLANG_TYPE_SWITCH,
- .flag = UNLANG_OP_FLAG_DEBUG_BRACES,
+ unlang_register(&(unlang_op_t) {
+ .name = "switch",
+ .type = UNLANG_TYPE_SWITCH,
+ .flag = UNLANG_OP_FLAG_DEBUG_BRACES,
- .compile = unlang_compile_switch,
- .interpret = unlang_switch,
-
+ .compile = unlang_compile_switch,
+ .interpret = unlang_switch,
+
+ .unlang_size = sizeof(unlang_switch_t),
+ .unlang_name = "unlang_switch_t",
- .unlang_size = sizeof(unlang_switch_t),
- .unlang_name = "unlang_switch_t",
+ .pool_headers = TMPL_POOL_DEF_HEADERS,
+ .pool_len = TMPL_POOL_DEF_LEN
+ });
- .pool_headers = TMPL_POOL_DEF_HEADERS,
- .pool_len = TMPL_POOL_DEF_LEN
- });
+ unlang_register(&(unlang_op_t){
+ .name = "case",
+ .type = UNLANG_TYPE_CASE,
+ .flag = UNLANG_OP_FLAG_DEBUG_BRACES | UNLANG_OP_FLAG_BREAK_POINT,
- unlang_register(UNLANG_TYPE_CASE,
- &(unlang_op_t){
- .name = "case",
- .type = UNLANG_TYPE_CASE,
- .flag = UNLANG_OP_FLAG_DEBUG_BRACES | UNLANG_OP_FLAG_BREAK_POINT,
+ .compile = unlang_compile_case,
+ .interpret = unlang_case,
- .compile = unlang_compile_case,
- .interpret = unlang_case,
-
- .unlang_size = sizeof(unlang_case_t),
- .unlang_name = "unlang_case_t",
- });
+ .unlang_size = sizeof(unlang_case_t),
+ .unlang_name = "unlang_case_t",
+ });
}
void unlang_timeout_init(void)
{
- unlang_register(UNLANG_TYPE_TIMEOUT,
- &(unlang_op_t){
- .name = "timeout",
- .type = UNLANG_TYPE_TIMEOUT,
- .flag = UNLANG_OP_FLAG_DEBUG_BRACES | UNLANG_OP_FLAG_RCODE_SET,
-
- .compile = unlang_compile_timeout,
- .interpret = unlang_timeout,
- .signal = unlang_timeout_signal,
-
- .unlang_size = sizeof(unlang_timeout_t),
- .unlang_name = "unlang_timeout_t",
-
- .frame_state_size = sizeof(unlang_frame_state_timeout_t),
- .frame_state_type = "unlang_frame_state_timeout_t",
- });
+ unlang_register(&(unlang_op_t){
+ .name = "timeout",
+ .type = UNLANG_TYPE_TIMEOUT,
+ .flag = UNLANG_OP_FLAG_DEBUG_BRACES | UNLANG_OP_FLAG_RCODE_SET,
+
+ .compile = unlang_compile_timeout,
+ .interpret = unlang_timeout,
+ .signal = unlang_timeout_signal,
+
+ .unlang_size = sizeof(unlang_timeout_t),
+ .unlang_name = "unlang_timeout_t",
+
+ .frame_state_size = sizeof(unlang_frame_state_timeout_t),
+ .frame_state_type = "unlang_frame_state_timeout_t",
+ });
}
void unlang_tmpl_init(void)
{
- unlang_register(UNLANG_TYPE_TMPL,
- &(unlang_op_t){
- .name = "tmpl",
- .type = UNLANG_TYPE_TMPL,
- .flag = UNLANG_OP_FLAG_INTERNAL,
-
- .interpret = unlang_tmpl,
- .signal = unlang_tmpl_signal,
-
- .frame_state_size = sizeof(unlang_frame_state_tmpl_t),
- .frame_state_type = "unlang_frame_state_tmpl_t",
- });
+ unlang_register(&(unlang_op_t){
+ .name = "tmpl",
+ .type = UNLANG_TYPE_TMPL,
+ .flag = UNLANG_OP_FLAG_INTERNAL,
+
+ .interpret = unlang_tmpl,
+ .signal = unlang_tmpl_signal,
+
+ .unlang_size = sizeof(unlang_tmpl_t),
+ .unlang_name = "unlang_tmpl_t",
+
+ .frame_state_size = sizeof(unlang_frame_state_tmpl_t),
+ .frame_state_type = "unlang_frame_state_tmpl_t",
+ });
}
void unlang_transaction_init(void)
{
- unlang_register(UNLANG_TYPE_TRANSACTION,
- &(unlang_op_t){
- .name = "transaction",
- .type = UNLANG_TYPE_TRANSACTION,
- .flag = UNLANG_OP_FLAG_DEBUG_BRACES,
-
- .compile = unlang_compile_transaction,
- .interpret = unlang_transaction,
- .signal = unlang_transaction_signal,
-
- .unlang_size = sizeof(unlang_transaction_t),
- .unlang_name = "unlang_transaction_t",
-
- .frame_state_size = sizeof(unlang_frame_state_transaction_t),
- .frame_state_type = "unlang_frame_state_transaction_t",
- });
+ unlang_register(&(unlang_op_t){
+ .name = "transaction",
+ .type = UNLANG_TYPE_TRANSACTION,
+ .flag = UNLANG_OP_FLAG_DEBUG_BRACES,
+
+ .compile = unlang_compile_transaction,
+ .interpret = unlang_transaction,
+ .signal = unlang_transaction_signal,
+
+ .unlang_size = sizeof(unlang_transaction_t),
+ .unlang_name = "unlang_transaction_t",
+
+ .frame_state_size = sizeof(unlang_frame_state_transaction_t),
+ .frame_state_type = "unlang_frame_state_transaction_t",
+ });
}
void unlang_try_init(void)
{
- unlang_register(UNLANG_TYPE_TRY,
- &(unlang_op_t){
- .name = "try",
- .type = UNLANG_TYPE_TRY,
- .flag = UNLANG_OP_FLAG_DEBUG_BRACES,
-
- .compile = unlang_compile_try,
- .interpret = unlang_try,
-
- .unlang_size = sizeof(unlang_try_t),
- .unlang_name = "unlang_try_t",
- });
+ unlang_register(&(unlang_op_t){
+ .name = "try",
+ .type = UNLANG_TYPE_TRY,
+ .flag = UNLANG_OP_FLAG_DEBUG_BRACES,
+
+ .compile = unlang_compile_try,
+ .interpret = unlang_try,
+
+ .unlang_size = sizeof(unlang_try_t),
+ .unlang_name = "unlang_try_t",
+ });
}
*
* @{
*/
-void unlang_register(int type, unlang_op_t *op);
+void unlang_register(unlang_op_t *op) CC_HINT(nonnull);
void unlang_call_init(void);
*/
void unlang_xlat_init(void)
{
- unlang_register(UNLANG_TYPE_XLAT,
- &(unlang_op_t){
- .name = "xlat",
- .type = UNLANG_TYPE_XLAT,
- .flag = UNLANG_OP_FLAG_INTERNAL,
-
- .interpret = unlang_xlat,
- .signal = unlang_xlat_signal,
- .dump = unlang_xlat_dump,
-
- .frame_state_size = sizeof(unlang_frame_state_xlat_t),
- .frame_state_type = "unlang_frame_state_xlat_t",
- });
+ unlang_register(&(unlang_op_t){
+ .name = "xlat",
+ .type = UNLANG_TYPE_XLAT,
+ .flag = UNLANG_OP_FLAG_INTERNAL,
+
+ .interpret = unlang_xlat,
+ .signal = unlang_xlat_signal,
+ .dump = unlang_xlat_dump,
+
+ .frame_state_size = sizeof(unlang_frame_state_xlat_t),
+ .frame_state_type = "unlang_frame_state_xlat_t",
+ });
}