Files
ivy/mie/record.c
Max Wash 1431cb7b47 mie: ctx is now used to query the type of a value
this allows value get_type callbacks to use mie_ctx to obtain mie_type pointers,
rather than having to define their own static versions of the type structs.
2025-04-28 15:40:32 +01:00

30 lines
584 B
C

#include <mie/record.h>
#include <stdlib.h>
#include <string.h>
struct mie_record *mie_record_create(const struct mie_const *val)
{
struct mie_record *out = malloc(sizeof *out);
if (!out) {
return NULL;
}
memset(out, 0x0, sizeof *out);
mie_value_init(&out->r_base, MIE_VALUE_RECORD);
out->r_value = val;
return out;
}
static struct mie_type *get_type(struct mie_value *v, struct mie_ctx *ctx)
{
struct mie_record *r = MIE_RECORD(v);
return r->r_value->c_type;
}
const struct mie_value_type record_value_type = {
.t_id = MIE_VALUE_RECORD,
.t_get_type = get_type,
};