mie: ctx: add function to create ops
This commit is contained in:
21
mie/ctx.c
21
mie/ctx.c
@@ -70,6 +70,27 @@ struct mie_ctx *mie_ctx_create(void)
|
|||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct mie_op *mie_ctx_create_op(
|
||||||
|
const struct mie_ctx *ctx, const char *dialect, const char *op)
|
||||||
|
{
|
||||||
|
const struct mie_op_definition *def
|
||||||
|
= mie_ctx_get_op_definition(ctx, dialect, op);
|
||||||
|
if (!def) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct mie_op *out = mie_op_create();
|
||||||
|
if (!out) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
out->op_flags |= MIE_OP_F_OP_RESOLVED;
|
||||||
|
out->op_info = def;
|
||||||
|
out->op_dialect = def->op_parent;
|
||||||
|
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
bool mie_ctx_resolve_op(const struct mie_ctx *ctx, struct mie_op *op)
|
bool mie_ctx_resolve_op(const struct mie_ctx *ctx, struct mie_op *op)
|
||||||
{
|
{
|
||||||
if (op->op_flags & MIE_OP_F_OP_RESOLVED) {
|
if (op->op_flags & MIE_OP_F_OP_RESOLVED) {
|
||||||
|
|||||||
@@ -36,6 +36,8 @@ struct mie_ctx {
|
|||||||
MIE_API struct mie_ctx *mie_ctx_create(void);
|
MIE_API struct mie_ctx *mie_ctx_create(void);
|
||||||
MIE_API void mie_ctx_destroy(struct mie_ctx *ctx);
|
MIE_API void mie_ctx_destroy(struct mie_ctx *ctx);
|
||||||
|
|
||||||
|
MIE_API struct mie_op *mie_ctx_create_op(
|
||||||
|
const struct mie_ctx *ctx, const char *dialect, const char *op);
|
||||||
MIE_API bool mie_ctx_resolve_op(const struct mie_ctx *ctx, struct mie_op *op);
|
MIE_API bool mie_ctx_resolve_op(const struct mie_ctx *ctx, struct mie_op *op);
|
||||||
|
|
||||||
MIE_API struct mie_dialect *mie_ctx_get_dialect(
|
MIE_API struct mie_dialect *mie_ctx_get_dialect(
|
||||||
|
|||||||
Reference in New Issue
Block a user