fx: value: implement copy and unset functions
This commit is contained in:
@@ -70,7 +70,11 @@ typedef struct fx_value {
|
|||||||
FX_API void fx_value_init(fx_value *v, fx_type type);
|
FX_API void fx_value_init(fx_value *v, fx_type type);
|
||||||
FX_API void fx_value_init_primitive(fx_value *v, fx_value_type type);
|
FX_API void fx_value_init_primitive(fx_value *v, fx_value_type type);
|
||||||
|
|
||||||
|
FX_API void fx_value_copy(fx_value *dst, fx_value *src);
|
||||||
|
FX_API void fx_value_copy_array(fx_value *dst, fx_value *src, size_t count);
|
||||||
|
|
||||||
FX_API void fx_value_unset(fx_value *v);
|
FX_API void fx_value_unset(fx_value *v);
|
||||||
|
FX_API void fx_value_unset_array(fx_value *v, size_t length);
|
||||||
|
|
||||||
FX_API void fx_value_set_bool(fx_value *v, bool b);
|
FX_API void fx_value_set_bool(fx_value *v, bool b);
|
||||||
FX_API void fx_value_set_int(fx_value *v, intptr_t i);
|
FX_API void fx_value_set_int(fx_value *v, intptr_t i);
|
||||||
|
|||||||
+28
@@ -13,8 +13,36 @@ void fx_value_init_primitive(fx_value *v, fx_value_type type)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void fx_value_copy(fx_value *dst, fx_value *src)
|
||||||
|
{
|
||||||
|
memcpy(dst, src, sizeof *dst);
|
||||||
|
|
||||||
|
if (dst->v_type.t_primitive > __FX_VALUE_TYPE_OBJECT_BOUNDARY) {
|
||||||
|
fx_object_ref(dst->v_object);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void fx_value_copy_array(fx_value *dst, fx_value *src, size_t count)
|
||||||
|
{
|
||||||
|
for (size_t i = 0; i < count; i++) {
|
||||||
|
fx_value_copy(dst + i, src + i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void fx_value_unset(fx_value *v)
|
void fx_value_unset(fx_value *v)
|
||||||
{
|
{
|
||||||
|
if (v->v_type.t_primitive > __FX_VALUE_TYPE_OBJECT_BOUNDARY) {
|
||||||
|
fx_object_unref(v->v_object);
|
||||||
|
}
|
||||||
|
|
||||||
|
memset(v, 0x0, sizeof *v);
|
||||||
|
}
|
||||||
|
|
||||||
|
void fx_value_unset_array(fx_value *v, size_t count)
|
||||||
|
{
|
||||||
|
for (size_t i = 0; i < count; i++) {
|
||||||
|
fx_value_unset(v + i);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void fx_value_set_bool(fx_value *v, bool b)
|
void fx_value_set_bool(fx_value *v, bool b)
|
||||||
|
|||||||
Reference in New Issue
Block a user