2018-04-12 23:54:58 -07:00
|
|
|
#include "value.h"
|
2018-04-17 15:49:09 -07:00
|
|
|
#include "parsetype.h"
|
2018-04-12 23:54:58 -07:00
|
|
|
|
2018-05-14 17:41:41 -07:00
|
|
|
void libab_value_init_ref(libab_value* value, libab_ref* data, libab_ref* type) {
|
|
|
|
libab_ref_copy(data, &value->data);
|
2018-04-12 23:54:58 -07:00
|
|
|
libab_ref_copy(type, &value->type);
|
|
|
|
}
|
|
|
|
|
2018-05-14 17:41:41 -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;
|
|
|
|
|
|
|
|
result = libab_ref_new(&tmp_ref, data,
|
|
|
|
((libab_parsetype*) libab_ref_get(type))->data_u.base->free_function);
|
|
|
|
|
|
|
|
if(result == LIBAB_SUCCESS) {
|
|
|
|
libab_value_init_ref(value, &tmp_ref, type);
|
|
|
|
libab_ref_free(&tmp_ref);
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2018-04-12 23:54:58 -07:00
|
|
|
void libab_value_free(libab_value* value) {
|
2018-05-14 17:41:41 -07:00
|
|
|
libab_ref_free(&value->data);
|
2018-04-24 18:28:31 -07:00
|
|
|
libab_ref_free(&value->type);
|
2018-04-12 23:54:58 -07:00
|
|
|
}
|