From: Kevin Day Date: Thu, 5 Oct 2023 03:11:38 +0000 (-0500) Subject: Update: Simplify the f_abstruse types a little. X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=13c40eadbfcd23dc270b9be28d419176fa48de73;p=fll Update: Simplify the f_abstruse types a little. Being a union, the single valued integer types provide very little gain and introduce a cost in complexity. Remove the integer types that overlap and just stick with the f_number_signed_t and f_number_unsigned_t for single value number types. Multiple valued number types remain because there is potential for design differences due to the memory allocation and size differences. The f_char_t type is removed. Just stick with f_string_t. --- diff --git a/level_0/f_abstruse/c/abstruse/enum.h b/level_0/f_abstruse/c/abstruse/enum.h index 696d417..001440c 100644 --- a/level_0/f_abstruse/c/abstruse/enum.h +++ b/level_0/f_abstruse/c/abstruse/enum.h @@ -21,72 +21,52 @@ extern "C" { * * Generally, the types ending in "s" represent an array. * - * f_abstruse_uint8: Maps to uint8_t. - * f_abstruse_uint8s: Maps to f_uint8s_t. - * f_abstruse_uint16: Maps to uint16_t. - * f_abstruse_uint16s: Maps to f_uint16s_t. - * f_abstruse_uint32: Maps to uint32_t. - * f_abstruse_uint32s: Maps to f_uint32s_t. - * f_abstruse_uint64: Maps to uint64_t. - * f_abstruse_uint64s: Maps to f_uint64s_t. - * f_abstruse_int8: Maps to int8_t. - * f_abstruse_int8s: Maps to f_int8_t. - * f_abstruse_int16: Maps to int16_t. - * f_abstruse_int16s: Maps to f_int16_t. - * f_abstruse_int32: Maps to int32_t. - * f_abstruse_int32s: Maps to f_int32s_t. - * f_abstruse_int64: Maps to int64_t. - * f_abstruse_int64s: Maps to f_int64_t. - * f_abstruse_signed: Maps to f_number_singed_t. - * f_abstruse_signeds: Maps to f_number_singeds_t. - * f_abstruse_unsigned: Maps to f_number_unsinged_t. - * f_abstruse_unsigneds: Maps to f_number_unsingeds_t. - * f_abstruse_char: Maps to f_char_t. - * f_abstruse_string: Maps to f_string_t (also: (f_char_t *)). - * f_abstruse_strings: Maps to (f_string_t *). - * f_abstruse_dynamic: Maps to f_string_dynamic_t (or f_string_static_t). - * f_abstruse_dynamics: Maps to f_string_dynamics_t (or f_string_statics_t). - * f_abstruse_map: Maps to f_string_map_t. - * f_abstruse_maps: Maps to f_string_maps_t. - * f_abstruse_map_multi: Maps to f_string_map_multi_t. - * f_abstruse_map_multis: Maps to f_string_map_multis_t. - * f_abstruse_quantity: Maps to f_string_quantity_t. - * f_abstruse_quantitys: Maps to f_string_quantitys_t. - * f_abstruse_range: Maps to f_string_range_t. - * f_abstruse_ranges: Maps to f_string_ranges_t. - * f_abstruse_triple: Maps to f_string_triple_t. - * f_abstruse_triples: Maps to f_string_triples_t. - * f_abstruse_void: Maps to (void *). - * f_abstruse_voids: Maps to (void **). - * f_abstruse_size: Maps to size_t. - * f_abstruse_sizes: Maps to (size_t *). - * f_abstruse_ssize: Maps to ssize_t. - * f_abstruse_ssizes: Maps to (ssize_t *). + * f_abstruse_*_e: + * - none: No value set. + * - int8s: Maps to f_int8s_t. + * - int16s: Maps to f_int16s_t. + * - int32s: Maps to f_int32s_t. + * - int64s: Maps to f_int64s_t. + * - uint8s: Maps to f_uint8s_t. + * - uint16s: Maps to f_uint16s_t. + * - uint32s: Maps to f_uint32s_t. + * - uint64s: Maps to f_uint64s_t. + * - signed: Maps to f_number_singed_t. + * - signeds: Maps to f_number_singeds_t. + * - unsigned: Maps to f_number_unsinged_t. + * - unsigneds: Maps to f_number_unsingeds_t. + * - string: Maps to f_string_t, also: (f_char_t *). + * - strings: Maps to (f_string_t *). + * - dynamic: Maps to f_string_dynamic_t, also: f_string_static_t. + * - dynamics: Maps to f_string_dynamics_t, also: f_string_statics_t. + * - map: Maps to f_string_map_t. + * - maps: Maps to f_string_maps_t. + * - map_multi: Maps to f_string_map_multi_t. + * - map_multis: Maps to f_string_map_multis_t. + * - quantity: Maps to f_string_quantity_t. + * - quantitys: Maps to f_string_quantitys_t. + * - range: Maps to f_string_range_t. + * - ranges: Maps to f_string_ranges_t. + * - triple: Maps to f_string_triple_t. + * - triples: Maps to f_string_triples_t. + * - void: Maps to (void *). + * - voids: Maps to (void **). */ #ifndef _di_f_abstruse_e_ enum { f_abstruse_none_e = 0, - f_abstruse_uint8_e, - f_abstruse_uint8s_e, - f_abstruse_uint16_e, - f_abstruse_uint16s_e, - f_abstruse_uint32_e, - f_abstruse_uint32s_e, - f_abstruse_uint64_e, - f_abstruse_uint64s_e, - f_abstruse_int8_e, f_abstruse_int8s_e, - f_abstruse_int16_e, f_abstruse_int16s_e, - f_abstruse_int32_e, f_abstruse_int32s_e, - f_abstruse_int64_e, f_abstruse_int64s_e, + f_abstruse_uint8s_e, + f_abstruse_uint16s_e, + f_abstruse_uint32s_e, + f_abstruse_uint64s_e, f_abstruse_signed_e, f_abstruse_signeds_e, f_abstruse_unsigned_e, f_abstruse_unsigneds_e, - f_abstruse_char_e, f_abstruse_string_e, f_abstruse_strings_e, f_abstruse_dynamic_e, @@ -103,11 +83,7 @@ extern "C" { f_abstruse_triples_e, f_abstruse_void_e, f_abstruse_voids_e, - f_abstruse_size_e, - f_abstruse_sizes_e, - f_abstruse_ssize_e, - f_abstruse_ssizes_e, - }; + }; // enum #endif // _di_f_abstruse_e_ #ifdef __cplusplus diff --git a/level_0/f_abstruse/c/abstruse/private-abstruse.c b/level_0/f_abstruse/c/abstruse/private-abstruse.c index 7753f1b..50de219 100644 --- a/level_0/f_abstruse/c/abstruse/private-abstruse.c +++ b/level_0/f_abstruse/c/abstruse/private-abstruse.c @@ -9,58 +9,58 @@ extern "C" { f_status_t private_f_abstruses_delete_switch(f_abstruse_t * const abstruse) { switch (abstruse->type) { - case f_abstruse_uint8_e: - if (abstruse->is.a_u8s.size) { - return f_memory_array_resize(0, sizeof(uint8_t), (void **) &abstruse->is.a_u8s.array, &abstruse->is.a_u8s.used, &abstruse->is.a_u8s.size); + case f_abstruse_int8s_e: + if (abstruse->is.a_i8s.size) { + return f_memory_array_resize(0, sizeof(int8_t), (void **) &abstruse->is.a_i8s.array, &abstruse->is.a_i8s.used, &abstruse->is.a_i8s.size); } break; - case f_abstruse_uint16s_e: - if (abstruse->is.a_u16s.size) { - return f_memory_array_resize(0, sizeof(uint16_t), (void **) &abstruse->is.a_u16s.array, &abstruse->is.a_u16s.used, &abstruse->is.a_u16s.size); + case f_abstruse_int16s_e: + if (abstruse->is.a_i16s.size) { + return f_memory_array_resize(0, sizeof(int16_t), (void **) &abstruse->is.a_i16s.array, &abstruse->is.a_i16s.used, &abstruse->is.a_i16s.size); } break; - case f_abstruse_uint32s_e: - if (abstruse->is.a_u32s.size) { - return f_memory_array_resize(0, sizeof(uint32_t), (void **) &abstruse->is.a_u32s.array, &abstruse->is.a_u32s.used, &abstruse->is.a_u32s.size); + case f_abstruse_int32s_e: + if (abstruse->is.a_i32s.size) { + return f_memory_array_resize(0, sizeof(int32_t), (void **) &abstruse->is.a_i32s.array, &abstruse->is.a_i32s.used, &abstruse->is.a_i32s.size); } break; - case f_abstruse_uint64s_e: - if (abstruse->is.a_u64s.size) { - return f_memory_array_resize(0, sizeof(uint64_t), (void **) &abstruse->is.a_u64s.array, &abstruse->is.a_u64s.used, &abstruse->is.a_u64s.size); + case f_abstruse_int64s_e: + if (abstruse->is.a_i64s.size) { + return f_memory_array_resize(0, sizeof(int64_t), (void **) &abstruse->is.a_i64s.array, &abstruse->is.a_i64s.used, &abstruse->is.a_i64s.size); } break; - case f_abstruse_int8s_e: - if (abstruse->is.a_i8s.size) { - return f_memory_array_resize(0, sizeof(int8_t), (void **) &abstruse->is.a_i8s.array, &abstruse->is.a_i8s.used, &abstruse->is.a_i8s.size); + case f_abstruse_uint8s_e: + if (abstruse->is.a_u8s.size) { + return f_memory_array_resize(0, sizeof(uint8_t), (void **) &abstruse->is.a_u8s.array, &abstruse->is.a_u8s.used, &abstruse->is.a_u8s.size); } break; - case f_abstruse_int16s_e: - if (abstruse->is.a_i16s.size) { - return f_memory_array_resize(0, sizeof(int16_t), (void **) &abstruse->is.a_i16s.array, &abstruse->is.a_i16s.used, &abstruse->is.a_i16s.size); + case f_abstruse_uint16s_e: + if (abstruse->is.a_u16s.size) { + return f_memory_array_resize(0, sizeof(uint16_t), (void **) &abstruse->is.a_u16s.array, &abstruse->is.a_u16s.used, &abstruse->is.a_u16s.size); } break; - case f_abstruse_int32s_e: - if (abstruse->is.a_i32s.size) { - return f_memory_array_resize(0, sizeof(int32_t), (void **) &abstruse->is.a_i32s.array, &abstruse->is.a_i32s.used, &abstruse->is.a_i32s.size); + case f_abstruse_uint32s_e: + if (abstruse->is.a_u32s.size) { + return f_memory_array_resize(0, sizeof(uint32_t), (void **) &abstruse->is.a_u32s.array, &abstruse->is.a_u32s.used, &abstruse->is.a_u32s.size); } break; - case f_abstruse_int64s_e: - if (abstruse->is.a_i64s.size) { - return f_memory_array_resize(0, sizeof(int64_t), (void **) &abstruse->is.a_i64s.array, &abstruse->is.a_i64s.used, &abstruse->is.a_i64s.size); + case f_abstruse_uint64s_e: + if (abstruse->is.a_u64s.size) { + return f_memory_array_resize(0, sizeof(uint64_t), (void **) &abstruse->is.a_u64s.array, &abstruse->is.a_u64s.used, &abstruse->is.a_u64s.size); } break; @@ -177,7 +177,7 @@ extern "C" { f_status_t private_f_abstruses_destroy_switch(f_abstruse_t * const abstruse) { switch (abstruse->type) { - case f_abstruse_uint8_e: + case f_abstruse_uint8s_e: if (abstruse->is.a_u8s.size) { return f_memory_array_adjust(0, sizeof(uint8_t), (void **) &abstruse->is.a_u8s.array, &abstruse->is.a_u8s.used, &abstruse->is.a_u8s.size); } diff --git a/level_0/f_abstruse/c/abstruse/type.h b/level_0/f_abstruse/c/abstruse/type.h index be26152..879f02d 100644 --- a/level_0/f_abstruse/c/abstruse/type.h +++ b/level_0/f_abstruse/c/abstruse/type.h @@ -26,27 +26,18 @@ extern "C" { */ #ifndef _di_f_abstruse_type_t_ typedef union { - uint8_t a_u8; f_uint8s_t a_u8s; - uint16_t a_u16; f_uint16s_t a_u16s; - uint32_t a_u32; f_uint32s_t a_u32s; - uint64_t a_u64; f_uint64s_t a_u64s; - int8_t a_i8; f_int8s_t a_i8s; - int16_t a_i16; f_int16s_t a_i16s; - int32_t a_i32; f_int32s_t a_i32s; - int64_t a_i64; f_int64s_t a_i64s; f_number_signed_t a_signed; f_number_signeds_t a_signeds; f_number_unsigned_t a_unsigned; f_number_unsigneds_t a_unsigneds; - f_char_t a_char; f_string_t a_string; f_string_t * a_strings; f_string_dynamic_t a_dynamic; @@ -63,10 +54,6 @@ extern "C" { f_string_triples_t a_triples; void * a_void; void ** a_voids; - size_t a_size; - size_t * a_sizes; - ssize_t a_ssize; - ssize_t * a_ssizes; } f_abstruse_type_t; #define f_abstruse_type_t_initialize { 0 }