From df00df5a7a5bcd9076d4423128ea014ab3535626 Mon Sep 17 00:00:00 2001 From: Mitya Selivanov Date: Sun, 11 Feb 2024 18:17:33 +0100 Subject: Update kit --- source/kit/unival.h | 45 ++++++++++++++++++++++++++------------------- 1 file changed, 26 insertions(+), 19 deletions(-) (limited to 'source/kit/unival.h') diff --git a/source/kit/unival.h b/source/kit/unival.h index a87a763..e0362b1 100644 --- a/source/kit/unival.h +++ b/source/kit/unival.h @@ -1,7 +1,6 @@ -#ifndef KIT_UV_H -#define KIT_UV_H +#ifndef KIT_UNIVAL_H +#define KIT_UNIVAL_H -#include "status.h" #include "string_builder.h" #include "input_stream.h" @@ -20,15 +19,18 @@ enum { KIT_UV_COMPOSITE, }; -enum { KIT_UV_ENCODE_BZIP = 1 }; -enum { KIT_UV_PRINT_PRETTY = 1, KIT_UV_PRINT_JSON = 2 }; +enum { + KIT_UV_ENCODE_BZIP = 1, + KIT_UV_PRINT_PRETTY = 1, + KIT_UV_PRINT_JSON = 2, +}; -typedef struct kit_uv_data kit_unival_t; +typedef struct kit_unival_ kit_unival_t; typedef KIT_DA(kit_unival_t) kit_da_unival_t; typedef KIT_DA(u8) kit_uv_bytes_t; -struct kit_uv_data { +struct kit_unival_ { i8 type; union { i8 boolean; @@ -45,32 +47,37 @@ struct kit_uv_data { }; typedef struct { - kit_status_t status; + s32 status; kit_unival_t *value; } kit_uv_decode_result_t; +kit_uv_decode_result_t kit_uv_decode(kit_is_handle_t is, + kit_allocator_t *alloc); + typedef struct { - kit_status_t status; + s32 status; kit_uv_bytes_t value; } kit_uv_encode_result_t; -typedef struct { - kit_status_t status; - kit_str_builder_t value; -} kit_uv_print_result_t; - -kit_uv_decode_result_t kit_uv_decode(kit_is_handle_t is, - kit_allocator_t *alloc); kit_uv_encode_result_t kit_uv_encode(kit_unival_t *value, kit_allocator_t *alloc, i32 flags); + kit_uv_decode_result_t kit_uv_parse(kit_is_handle_t is, kit_allocator_t *alloc); + kit_uv_decode_result_t kit_uv_parse_json(kit_is_handle_t is, kit_allocator_t *alloc); -kit_uv_print_result_t kit_uv_print(kit_unival_t *value, - kit_allocator_t *alloc, i32 flags); -void kit_uv_destroy(kit_unival_t *value); + +typedef struct { + s32 status; + kit_str_builder_t value; +} kit_uv_print_result_t; + +kit_uv_print_result_t kit_uv_print(kit_unival_t *value, + kit_allocator_t *alloc, i32 flags); + +void kit_uv_destroy(kit_unival_t *value); #ifdef __cplusplus } -- cgit v1.2.3