libabacus/src/value.c

31 lines
814 B
C
Raw Normal View History

#include "value.h"
#include "parsetype.h"
2018-05-17 14:53:48 -07:00
void libab_value_init_ref(libab_value* value, libab_ref* data,
libab_ref* type) {
libab_ref_copy(data, &value->data);
libab_ref_copy(type, &value->type);
}
2018-05-17 14:53:48 -07:00
libab_result libab_value_init_raw(libab_value* value, void* data,
libab_ref* type) {
libab_result result = LIBAB_SUCCESS;
libab_ref tmp_ref;
2018-05-17 14:53:48 -07:00
result = libab_ref_new(
&tmp_ref, data,
((libab_parsetype*)libab_ref_get(type))->data_u.base->free_function);
2018-05-17 14:53:48 -07:00
if (result == LIBAB_SUCCESS) {
libab_value_init_ref(value, &tmp_ref, type);
libab_ref_free(&tmp_ref);
}
return result;
}
void libab_value_free(libab_value* value) {
libab_ref_free(&value->data);
libab_ref_free(&value->type);
}