From 9e18b3291e6e7351a27b90eb971ed71d34e34db8 Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Tue, 19 Sep 2023 17:20:42 -0500 Subject: [PATCH] Update: Restructure f_type files and add missing f_number_signed_t. Break apart the f_type headers into multiple header files by major type groups. This should make navigating the files a little easier. Some of the header files are order sensitive. The f_number_signed_t is now implemented. Added appropriate unit tests. I manually added the disable defines in the fake stand alone configuration file. --- build/level_0/settings | 6 +- build/monolithic/settings | 6 +- build/stand_alone/byte_dump.settings | 2 +- build/stand_alone/fake.config.h | 4 + build/stand_alone/fake.settings | 2 +- build/stand_alone/firewall.settings | 2 +- build/stand_alone/utf8.settings | 2 +- level_0/f_conversion/c/conversion.h | 2 +- level_0/f_file/c/file.h | 2 +- level_0/f_print/c/print.h | 2 +- level_0/f_signal/c/signal.h | 2 +- level_0/f_type/c/type.h | 1267 +------------------- level_0/f_type/c/type/cell.h | 93 ++ level_0/f_type/c/{type_file.h => type/file.h} | 0 level_0/f_type/c/type/fll.h | 124 ++ level_0/f_type/c/type/mode.h | 102 ++ level_0/f_type/c/type/number.h | 762 ++++++++++++ level_0/f_type/c/type/state.h | 174 +++ level_0/f_type/c/type/status.h | 80 ++ level_0/f_type/c/type/time.h | 130 ++ level_0/f_type/data/build/settings | 2 +- level_0/f_type_array/c/type_array.h | 1 + level_0/f_type_array/c/type_array/number_signed.c | 50 + level_0/f_type_array/c/type_array/number_signed.h | 81 ++ level_0/f_type_array/c/type_array_file.h | 2 +- level_0/f_type_array/data/build/settings | 4 +- level_0/f_type_array/data/build/settings-mocks | 4 +- level_0/f_type_array/data/build/settings-tests | 1 + ...st-type_array-number_signedss_delete_callback.c | 57 + ...st-type_array-number_signedss_delete_callback.h | 27 + ...t-type_array-number_signedss_destroy_callback.c | 57 + ...t-type_array-number_signedss_destroy_callback.h | 27 + .../f_type_array/tests/unit/c/test-type_array.c | 9 + .../f_type_array/tests/unit/c/test-type_array.h | 4 +- level_1/fl_print/c/print.h | 2 +- 35 files changed, 1813 insertions(+), 1279 deletions(-) create mode 100644 level_0/f_type/c/type/cell.h rename level_0/f_type/c/{type_file.h => type/file.h} (100%) create mode 100644 level_0/f_type/c/type/fll.h create mode 100644 level_0/f_type/c/type/mode.h create mode 100644 level_0/f_type/c/type/number.h create mode 100644 level_0/f_type/c/type/state.h create mode 100644 level_0/f_type/c/type/status.h create mode 100644 level_0/f_type/c/type/time.h create mode 100644 level_0/f_type_array/c/type_array/number_signed.c create mode 100644 level_0/f_type_array/c/type_array/number_signed.h create mode 100644 level_0/f_type_array/tests/unit/c/test-type_array-number_signedss_delete_callback.c create mode 100644 level_0/f_type_array/tests/unit/c/test-type_array-number_signedss_delete_callback.h create mode 100644 level_0/f_type_array/tests/unit/c/test-type_array-number_signedss_destroy_callback.c create mode 100644 level_0/f_type_array/tests/unit/c/test-type_array-number_signedss_destroy_callback.h diff --git a/build/level_0/settings b/build/level_0/settings index 14b918e..6208ea8 100644 --- a/build/level_0/settings +++ b/build/level_0/settings @@ -70,7 +70,7 @@ build_sources_library string/range.c string/ranges.c string/rangess.c build_sources_library string/static.c string/statics.c string/staticss.c build_sources_library string/triple.c string/triples.c string/tripless.c build_sources_library time.c -build_sources_library type_array/cell.c type_array/file.c type_array/fll_id.c type_array/int8.c type_array/int16.c type_array/int32.c type_array/int64.c type_array/int128.c type_array/number_unsigned.c type_array/poll.c type_array/state.c type_array/status.c type_array/uint8.c type_array/uint16.c type_array/uint32.c type_array/uint64.c type_array/uint128.c +build_sources_library type_array/cell.c type_array/file.c type_array/fll_id.c type_array/int8.c type_array/int16.c type_array/int32.c type_array/int64.c type_array/int128.c type_array/number_signed.c type_array/number_unsigned.c type_array/poll.c type_array/state.c type_array/status.c type_array/uint8.c type_array/uint16.c type_array/uint32.c type_array/uint64.c type_array/uint128.c build_sources_library utf.c private-utf.c private-utf_alphabetic.c private-utf_combining.c private-utf_control.c private-utf_digit.c private-utf_emoji.c private-utf_numeric.c private-utf_phonetic.c private-utf_private.c private-utf_punctuation.c private-utf_subscript.c private-utf_superscript.c private-utf_symbol.c private-utf_unassigned.c private-utf_valid.c private-utf_whitespace.c private-utf_wide.c private-utf_word.c private-utf_zero_width.c build_sources_library utf/common.c utf/convert.c build_sources_library utf/dynamic.c utf/dynamics.c utf/dynamicss.c @@ -118,8 +118,8 @@ build_sources_headers string/range.h string/ranges.h string/rangess.h build_sources_headers string/static.h string/statics.h string/staticss.h build_sources_headers string/triple.h string/triples.h string/tripless.h build_sources_headers time.h -build_sources_headers type.h type_file.h -build_sources_headers type_array.h type_array_file.h type_array/common.h type_array/cell.h type_array/file.h type_array/fll_id.h type_array/int8.h type_array/int16.h type_array/int32.h type_array/int64.h type_array/int128.h type_array/number_unsigned.h type_array/poll.h type_array/state.h type_array/status.h type_array/uint8.h type_array/uint16.h type_array/uint32.h type_array/uint64.h type_array/uint128.h +build_sources_headers type.h type/cell.h type/file.h type/fll.h type/mode.h type/number.h type/state.h type/status.h type/time.h +build_sources_headers type_array.h type_array_file.h type_array/common.h type_array/cell.h type_array/file.h type_array/fll_id.h type_array/int8.h type_array/int16.h type_array/int32.h type_array/int64.h type_array/int128.h type_array/number_signed.h type_array/number_unsigned.h type_array/poll.h type_array/state.h type_array/status.h type_array/uint8.h type_array/uint16.h type_array/uint32.h type_array/uint64.h type_array/uint128.h build_sources_headers utf.h utf/common.h utf/convert.h utf/dynamic.h utf/dynamics.h utf/dynamicss.h utf/is.h utf/is_character.h utf/map.h utf/maps.h utf/mapss.h utf/map_multi.h utf/map_multis.h utf/map_multiss.h utf/static.h utf/statics.h utf/staticss.h utf/string.h utf/triple.h utf/triples.h utf/tripless.h build_sources_headers-thread thread.h thread/attribute.h thread/barrier.h thread/barrier_attribute.h thread/condition.h thread/condition_attribute.h thread/id.h thread/key.h thread/lock.h thread/lock_attribute.h thread/mutex.h thread/mutex_attribute.h thread/once.h thread/semaphore.h thread/set.h thread/spin.h diff --git a/build/monolithic/settings b/build/monolithic/settings index c8ae523..7eaf6ba 100644 --- a/build/monolithic/settings +++ b/build/monolithic/settings @@ -70,7 +70,7 @@ build_sources_library level_0/string/range.c level_0/string/ranges.c level_0/str build_sources_library level_0/string/static.c level_0/string/statics.c level_0/string/staticss.c build_sources_library level_0/string/triple.c level_0/string/triples.c level_0/string/tripless.c build_sources_library level_0/time.c -build_sources_library level_0/type_array/cell.c level_0/type_array/file.c level_0/type_array/fll_id.c level_0/type_array/int8.c level_0/type_array/int16.c level_0/type_array/int32.c level_0/type_array/int64.c level_0/type_array/int128.c level_0/type_array/number_unsigned.c level_0/type_array/poll.c level_0/type_array/state.c level_0/type_array/status.c level_0/type_array/uint8.c level_0/type_array/uint16.c level_0/type_array/uint32.c level_0/type_array/uint64.c level_0/type_array/uint128.c +build_sources_library level_0/type_array/cell.c level_0/type_array/file.c level_0/type_array/fll_id.c level_0/type_array/int8.c level_0/type_array/int16.c level_0/type_array/int32.c level_0/type_array/int64.c level_0/type_array/int128.c level_0/type_array/number_signed.c level_0/type_array/number_unsigned.c level_0/type_array/poll.c level_0/type_array/state.c level_0/type_array/status.c level_0/type_array/uint8.c level_0/type_array/uint16.c level_0/type_array/uint32.c level_0/type_array/uint64.c level_0/type_array/uint128.c build_sources_library level_0/utf.c level_0/private-utf.c level_0/private-utf_alphabetic.c level_0/private-utf_combining.c level_0/private-utf_control.c level_0/private-utf_digit.c level_0/private-utf_emoji.c level_0/private-utf_numeric.c level_0/private-utf_phonetic.c level_0/private-utf_private.c level_0/private-utf_punctuation.c level_0/private-utf_subscript.c level_0/private-utf_superscript.c level_0/private-utf_symbol.c level_0/private-utf_unassigned.c level_0/private-utf_valid.c level_0/private-utf_whitespace.c level_0/private-utf_wide.c level_0/private-utf_word.c level_0/private-utf_zero_width.c build_sources_library level_0/utf/common.c level_0/utf/convert.c build_sources_library level_0/utf/dynamic.c level_0/utf/dynamics.c level_0/utf/dynamicss.c @@ -139,8 +139,8 @@ build_sources_headers level_0/string/range.h level_0/string/ranges.h level_0/str build_sources_headers level_0/string/static.h level_0/string/statics.h level_0/string/staticss.h build_sources_headers level_0/string/triple.h level_0/string/triples.h level_0/string/tripless.h build_sources_headers level_0/time.h -build_sources_headers level_0/type.h level_0/type_file.h -build_sources_headers level_0/type_array.h level_0/type_array_file.h level_0/type_array/common.h level_0/type_array/cell.h level_0/type_array/file.h level_0/type_array/fll_id.h level_0/type_array/int8.h level_0/type_array/int16.h level_0/type_array/int32.h level_0/type_array/int64.h level_0/type_array/int128.h level_0/type_array/number_unsigned.h level_0/type_array/poll.h level_0/type_array/state.h level_0/type_array/status.h level_0/type_array/uint8.h level_0/type_array/uint16.h level_0/type_array/uint32.h level_0/type_array/uint64.h level_0/type_array/uint128.h +build_sources_headers level_0/type.h level_0/type/cell.h level_0/type/file.h level_0/type/fll.h level_0/type/mode.h level_0/type/number.h level_0/type/state.h level_0/type/status.h level_0/type/time.h +build_sources_headers level_0/type_array.h level_0/type_array_file.h level_0/type_array/common.h level_0/type_array/cell.h level_0/type_array/file.h level_0/type_array/fll_id.h level_0/type_array/int8.h level_0/type_array/int16.h level_0/type_array/int32.h level_0/type_array/int64.h level_0/type_array/int128.h level_0/type_array/number_signed.h level_0/type_array/number_unsigned.h level_0/type_array/poll.h level_0/type_array/state.h level_0/type_array/status.h level_0/type_array/uint8.h level_0/type_array/uint16.h level_0/type_array/uint32.h level_0/type_array/uint64.h level_0/type_array/uint128.h build_sources_headers level_0/utf.h level_0/utf/common.h level_0/utf/convert.h level_0/utf/dynamic.h level_0/utf/dynamics.h level_0/utf/dynamicss.h level_0/utf/is.h level_0/utf/is_character.h level_0/utf/map.h level_0/utf/maps.h level_0/utf/mapss.h level_0/utf/map_multi.h level_0/utf/map_multis.h level_0/utf/map_multiss.h level_0/utf/static.h level_0/utf/statics.h level_0/utf/staticss.h level_0/utf/string.h level_0/utf/triple.h level_0/utf/triples.h level_0/utf/tripless.h build_sources_headers level_1/control_group.h diff --git a/build/stand_alone/byte_dump.settings b/build/stand_alone/byte_dump.settings index 320f7d1..ea0e683 100644 --- a/build/stand_alone/byte_dump.settings +++ b/build/stand_alone/byte_dump.settings @@ -32,7 +32,7 @@ build_sources_program fll/level_0/pipe.c build_sources_program fll/level_0/print.c fll/level_0/private-print.c fll/level_0/print/common.c fll/level_0/print/to.c fll/level_0/print/private-to.c build_sources_program fll/level_0/signal.c build_sources_program fll/level_0/string.c fll/level_0/private-string.c fll/level_0/string/common.c fll/level_0/string/dynamic.c fll/level_0/string/map.c fll/level_0/string/map_multi.cfll/level_0/string/quantity.c fll/level_0/string/range.c fll/level_0/string/static.c fll/level_0/string/triple.c -build_sources_program fll/level_0/type_array/cell.c fll/level_0/type_array/file.c fll/level_0/type_array/fll_id.c fll/level_0/type_array/int8.c fll/level_0/type_array/int16.c fll/level_0/type_array/int32.c fll/level_0/type_array/int64.c fll/level_0/type_array/int128.c fll/level_0/type_array/number_unsigned.c fll/level_0/type_array/poll.c fll/level_0/type_array/state.c fll/level_0/type_array/status.c fll/level_0/type_array/uint8.c fll/level_0/type_array/uint16.c fll/level_0/type_array/uint32.c fll/level_0/type_array/uint64.c fll/level_0/type_array/uint128.c +build_sources_program fll/level_0/type_array/cell.c fll/level_0/type_array/file.c fll/level_0/type_array/fll_id.c fll/level_0/type_array/int8.c fll/level_0/type_array/int16.c fll/level_0/type_array/int32.c fll/level_0/type_array/int64.c fll/level_0/type_array/int128.c fll/level_0/type_array/number_signed.c fll/level_0/type_array/number_unsigned.c fll/level_0/type_array/poll.c fll/level_0/type_array/state.c fll/level_0/type_array/status.c fll/level_0/type_array/uint8.c fll/level_0/type_array/uint16.c fll/level_0/type_array/uint32.c fll/level_0/type_array/uint64.c fll/level_0/type_array/uint128.c build_sources_program fll/level_0/utf.c fll/level_0/private-utf.c fll/level_0/private-utf_alphabetic.c fll/level_0/private-utf_combining.c fll/level_0/private-utf_control.c fll/level_0/private-utf_digit.c fll/level_0/private-utf_emoji.c fll/level_0/private-utf_numeric.c fll/level_0/private-utf_phonetic.c fll/level_0/private-utf_private.c fll/level_0/private-utf_punctuation.c fll/level_0/private-utf_subscript.c fll/level_0/private-utf_superscript.c fll/level_0/private-utf_symbol.c fll/level_0/private-utf_unassigned.c fll/level_0/private-utf_valid.c fll/level_0/private-utf_whitespace.c fll/level_0/private-utf_wide.c fll/level_0/private-utf_word.c fll/level_0/private-utf_zero_width.c build_sources_program fll/level_0/utf/common.c fll/level_0/utf/convert.c fll/level_0/utf/dynamic.c fll/level_0/utf/is.c fll/level_0/utf/is_character.c fll/level_0/utf/map.c fll/level_0/utf/map_multi.c fll/level_0/utf/static.c fll/level_0/utf/string.c fll/level_0/utf/triple.c fll/level_0/utf/private-dynamic.c fll/level_0/utf/private-map.c fll/level_0/utf/private-map_multi.c fll/level_0/utf/private-triple.c fll/level_0/utf/private-string.c diff --git a/build/stand_alone/fake.config.h b/build/stand_alone/fake.config.h index ccbb1fd..fe96292 100644 --- a/build/stand_alone/fake.config.h +++ b/build/stand_alone/fake.config.h @@ -1028,6 +1028,10 @@ #define _di_f_network_to_host_long_ #define _di_f_network_to_host_short_ #define _di_f_network_to_ip_string_ +#define _di_f_number_signedss_delete_callback_ +#define _di_f_number_signedss_destroy_callback_ +#define _di_f_number_signedss_t_ +#define _di_f_number_signeds_t_ #define _di_f_number_unsignedss_delete_callback_ #define _di_f_number_unsignedss_destroy_callback_ #define _di_f_number_unsignedss_t_ diff --git a/build/stand_alone/fake.settings b/build/stand_alone/fake.settings index abeb2f4..09a0f9e 100644 --- a/build/stand_alone/fake.settings +++ b/build/stand_alone/fake.settings @@ -56,7 +56,7 @@ build_sources_program fll/level_0/rip.c fll/level_0/rip/utf.c fll/level_0/privat build_sources_program fll/level_0/signal.c build_sources_program fll/level_0/string.c fll/level_0/private-string.c fll/level_0/string/common.c build_sources_program fll/level_0/string/dynamic.c fll/level_0/string/dynamics.c fll/level_0/string/dynamicss.c fll/level_0/string/map.c fll/level_0/string/maps.c fll/level_0/string/mapss.c fll/level_0/string/map_multi.c fll/level_0/string/map_multis.c fll/level_0/string/map_multiss.c fll/level_0/string/quantity.c fll/level_0/string/quantitys.c fll/level_0/string/quantityss.c fll/level_0/string/range.c fll/level_0/string/ranges.c fll/level_0/string/rangess.c fll/level_0/string/static.c fll/level_0/string/statics.c fll/level_0/string/staticss.c fll/level_0/string/triple.c fll/level_0/string/triples.c fll/level_0/string/tripless.c -build_sources_program fll/level_0/type_array/cell.c fll/level_0/type_array/file.c fll/level_0/type_array/fll_id.c fll/level_0/type_array/int8.c fll/level_0/type_array/int16.c fll/level_0/type_array/int32.c fll/level_0/type_array/int64.c fll/level_0/type_array/int128.c fll/level_0/type_array/number_unsigned.c fll/level_0/type_array/poll.c fll/level_0/type_array/state.c fll/level_0/type_array/status.c fll/level_0/type_array/uint8.c fll/level_0/type_array/uint16.c fll/level_0/type_array/uint32.c fll/level_0/type_array/uint64.c fll/level_0/type_array/uint128.c +build_sources_program fll/level_0/type_array/cell.c fll/level_0/type_array/file.c fll/level_0/type_array/fll_id.c fll/level_0/type_array/int8.c fll/level_0/type_array/int16.c fll/level_0/type_array/int32.c fll/level_0/type_array/int64.c fll/level_0/type_array/int128.c fll/level_0/type_array/number_signed.c fll/level_0/type_array/number_unsigned.c fll/level_0/type_array/poll.c fll/level_0/type_array/state.c fll/level_0/type_array/status.c fll/level_0/type_array/uint8.c fll/level_0/type_array/uint16.c fll/level_0/type_array/uint32.c fll/level_0/type_array/uint64.c fll/level_0/type_array/uint128.c build_sources_program fll/level_0/utf.c fll/level_0/private-utf.c fll/level_0/private-utf_alphabetic.c fll/level_0/private-utf_combining.c fll/level_0/private-utf_control.c fll/level_0/private-utf_digit.c fll/level_0/private-utf_emoji.c fll/level_0/private-utf_numeric.c fll/level_0/private-utf_phonetic.c fll/level_0/private-utf_private.c fll/level_0/private-utf_punctuation.c fll/level_0/private-utf_subscript.c fll/level_0/private-utf_superscript.c fll/level_0/private-utf_symbol.c fll/level_0/private-utf_unassigned.c fll/level_0/private-utf_valid.c fll/level_0/private-utf_whitespace.c fll/level_0/private-utf_wide.c fll/level_0/private-utf_word.c fll/level_0/private-utf_zero_width.c build_sources_program fll/level_0/utf/common.c fll/level_0/utf/convert.c fll/level_0/utf/dynamic.c fll/level_0/utf/dynamics.c fll/level_0/utf/dynamicss.c fll/level_0/utf/is.c fll/level_0/utf/is_character.c fll/level_0/utf/map.c fll/level_0/utf/maps.c fll/level_0/utf/mapss.c fll/level_0/utf/map_multi.c fll/level_0/utf/map_multis.c fll/level_0/utf/map_multiss.c fll/level_0/utf/static.c fll/level_0/utf/statics.c fll/level_0/utf/staticss.c fll/level_0/utf/string.c fll/level_0/utf/triple.c fll/level_0/utf/triples.c fll/level_0/utf/tripless.c build_sources_program fll/level_0/utf/private-dynamics.c fll/level_0/utf/private-maps.c fll/level_0/utf/private-map_multis.c fll/level_0/utf/private-string.c fll/level_0/utf/private-triples.c diff --git a/build/stand_alone/firewall.settings b/build/stand_alone/firewall.settings index ae4f259..6ec5594 100644 --- a/build/stand_alone/firewall.settings +++ b/build/stand_alone/firewall.settings @@ -42,7 +42,7 @@ build_sources_program fll/level_0/print.c fll/level_0/private-print.c fll/level_ build_sources_program fll/level_0/signal.c build_sources_program fll/level_0/string.c fll/level_0/private-string.c fll/level_0/string/common.c fll/level_0/string/dynamic.c fll/level_0/string/map.c fll/level_0/string/map_multi.c fll/level_0/string/quantity.c fll/level_0/string/range.c fll/level_0/string/static.c fll/level_0/string/triple.c build_sources_program fll/level_0/thread.c fll/level_0/private-thread.c fll/level_0/thread/attribute.c fll/level_0/thread/barrier.c fll/level_0/thread/barrier_attribute.c fll/level_0/thread/condition.c fll/level_0/thread/condition_attribute.c fll/level_0/thread/id.c fll/level_0/thread/key.c fll/level_0/thread/lock.c fll/level_0/thread/lock_attribute.c fll/level_0/thread/mutex.c fll/level_0/thread/mutex_attribute.c fll/level_0/thread/once.c fll/level_0/thread/semaphore.c fll/level_0/thread/set.c fll/level_0/thread/spin.c -build_sources_program fll/level_0/type_array/cell.c fll/level_0/type_array/file.c fll/level_0/type_array/fll_id.c fll/level_0/type_array/int8.c fll/level_0/type_array/int16.c fll/level_0/type_array/int32.c fll/level_0/type_array/int64.c fll/level_0/type_array/int128.c fll/level_0/type_array/number_unsigned.c fll/level_0/type_array/poll.c fll/level_0/type_array/state.c fll/level_0/type_array/status.c fll/level_0/type_array/uint8.c fll/level_0/type_array/uint16.c fll/level_0/type_array/uint32.c fll/level_0/type_array/uint64.c fll/level_0/type_array/uint128.c +build_sources_program fll/level_0/type_array/cell.c fll/level_0/type_array/file.c fll/level_0/type_array/fll_id.c fll/level_0/type_array/int8.c fll/level_0/type_array/int16.c fll/level_0/type_array/int32.c fll/level_0/type_array/int64.c fll/level_0/type_array/int128.c fll/level_0/type_array/number_signed.c fll/level_0/type_array/number_unsigned.c fll/level_0/type_array/poll.c fll/level_0/type_array/state.c fll/level_0/type_array/status.c fll/level_0/type_array/uint8.c fll/level_0/type_array/uint16.c fll/level_0/type_array/uint32.c fll/level_0/type_array/uint64.c fll/level_0/type_array/uint128.c build_sources_program fll/level_0/utf.c fll/level_0/private-utf.c fll/level_0/private-utf_alphabetic.c fll/level_0/private-utf_combining.c fll/level_0/private-utf_control.c fll/level_0/private-utf_digit.c fll/level_0/private-utf_emoji.c fll/level_0/private-utf_numeric.c fll/level_0/private-utf_phonetic.c fll/level_0/private-utf_private.c fll/level_0/private-utf_punctuation.c fll/level_0/private-utf_subscript.c fll/level_0/private-utf_superscript.c fll/level_0/private-utf_symbol.c fll/level_0/private-utf_unassigned.c fll/level_0/private-utf_valid.c fll/level_0/private-utf_whitespace.c fll/level_0/private-utf_wide.c fll/level_0/private-utf_word.c fll/level_0/private-utf_zero_width.c build_sources_program fll/level_0/utf/common.c fll/level_0/utf/convert.c fll/level_0/utf/dynamic.c fll/level_0/utf/is.c fll/level_0/utf/is_character.c fll/level_0/utf/map.c fll/level_0/utf/map_multi.c fll/level_0/utf/static.c fll/level_0/utf/string.c fll/level_0/utf/triple.c fll/level_0/utf/private-dynamic.c fll/level_0/utf/private-map.c fll/level_0/utf/private-map_multi.c fll/level_0/utf/private-triple.c fll/level_0/utf/private-string.c diff --git a/build/stand_alone/utf8.settings b/build/stand_alone/utf8.settings index f1d6a5a..459c7d2 100644 --- a/build/stand_alone/utf8.settings +++ b/build/stand_alone/utf8.settings @@ -33,7 +33,7 @@ build_sources_program fll/level_0/print.c fll/level_0/private-print.c fll/level_ build_sources_program fll/level_0/signal.c build_sources_program fll/level_0/string.c fll/level_0/private-string.c fll/level_0/string/common.c build_sources_program fll/level_0/string/dynamic.c fll/level_0/string/dynamics.c fll/level_0/string/dynamicss.c fll/level_0/string/map.c fll/level_0/string/maps.c fll/level_0/string/mapss.c fll/level_0/string/map_multi.c fll/level_0/string/map_multis.c fll/level_0/string/map_multiss.c fll/level_0/string/quantity.c fll/level_0/string/quantitys.c fll/level_0/string/quantityss.c fll/level_0/string/range.c fll/level_0/string/ranges.c fll/level_0/string/rangess.c fll/level_0/string/static.c fll/level_0/string/statics.c fll/level_0/string/staticss.c fll/level_0/string/triple.c fll/level_0/string/triples.c fll/level_0/string/tripless.c -build_sources_program fll/level_0/type_array/cell.c fll/level_0/type_array/file.c fll/level_0/type_array/fll_id.c fll/level_0/type_array/int8.c fll/level_0/type_array/int16.c fll/level_0/type_array/int32.c fll/level_0/type_array/int64.c fll/level_0/type_array/int128.c fll/level_0/type_array/number_unsigned.c fll/level_0/type_array/poll.c fll/level_0/type_array/state.c fll/level_0/type_array/status.c fll/level_0/type_array/uint8.c fll/level_0/type_array/uint16.c fll/level_0/type_array/uint32.c fll/level_0/type_array/uint64.c fll/level_0/type_array/uint128.c +build_sources_program fll/level_0/type_array/cell.c fll/level_0/type_array/file.c fll/level_0/type_array/fll_id.c fll/level_0/type_array/int8.c fll/level_0/type_array/int16.c fll/level_0/type_array/int32.c fll/level_0/type_array/int64.c fll/level_0/type_array/int128.c fll/level_0/type_array/number_signed.c fll/level_0/type_array/number_unsigned.c fll/level_0/type_array/poll.c fll/level_0/type_array/state.c fll/level_0/type_array/status.c fll/level_0/type_array/uint8.c fll/level_0/type_array/uint16.c fll/level_0/type_array/uint32.c fll/level_0/type_array/uint64.c fll/level_0/type_array/uint128.c build_sources_program fll/level_0/utf.c fll/level_0/private-utf.c fll/level_0/private-utf_alphabetic.c fll/level_0/private-utf_combining.c fll/level_0/private-utf_control.c fll/level_0/private-utf_digit.c fll/level_0/private-utf_emoji.c fll/level_0/private-utf_numeric.c fll/level_0/private-utf_phonetic.c fll/level_0/private-utf_private.c fll/level_0/private-utf_punctuation.c fll/level_0/private-utf_subscript.c fll/level_0/private-utf_superscript.c fll/level_0/private-utf_symbol.c fll/level_0/private-utf_unassigned.c fll/level_0/private-utf_valid.c fll/level_0/private-utf_whitespace.c fll/level_0/private-utf_wide.c fll/level_0/private-utf_word.c fll/level_0/private-utf_zero_width.c build_sources_program fll/level_0/utf/common.c fll/level_0/utf/convert.c fll/level_0/utf/dynamic.c fll/level_0/utf/dynamics.c fll/level_0/utf/dynamicss.c fll/level_0/utf/is.c fll/level_0/utf/is_character.c fll/level_0/utf/map.c fll/level_0/utf/maps.c fll/level_0/utf/mapss.c fll/level_0/utf/map_multi.c fll/level_0/utf/map_multis.c fll/level_0/utf/map_multiss.c fll/level_0/utf/static.c fll/level_0/utf/statics.c fll/level_0/utf/staticss.c fll/level_0/utf/string.c fll/level_0/utf/triple.c fll/level_0/utf/triples.c fll/level_0/utf/tripless.c build_sources_program fll/level_0/utf/private-dynamics.c fll/level_0/utf/private-maps.c fll/level_0/utf/private-map_multis.c fll/level_0/utf/private-string.c fll/level_0/utf/private-triples.c diff --git a/level_0/f_conversion/c/conversion.h b/level_0/f_conversion/c/conversion.h index 76925b5..1167d4d 100644 --- a/level_0/f_conversion/c/conversion.h +++ b/level_0/f_conversion/c/conversion.h @@ -17,7 +17,7 @@ // FLL-0 includes. #include -#include +#include #include #include #include diff --git a/level_0/f_file/c/file.h b/level_0/f_file/c/file.h index 8f12018..24f4489 100644 --- a/level_0/f_file/c/file.h +++ b/level_0/f_file/c/file.h @@ -31,7 +31,7 @@ // FLL-0 includes. #include -#include +#include #include #include #include diff --git a/level_0/f_print/c/print.h b/level_0/f_print/c/print.h index 9ac0a99..8cd1f98 100644 --- a/level_0/f_print/c/print.h +++ b/level_0/f_print/c/print.h @@ -23,7 +23,7 @@ // FLL-0 includes. #include -#include +#include #include #include #include diff --git a/level_0/f_signal/c/signal.h b/level_0/f_signal/c/signal.h index 9af6ed5..fc29a46 100644 --- a/level_0/f_signal/c/signal.h +++ b/level_0/f_signal/c/signal.h @@ -19,7 +19,7 @@ // FLL-0 includes. #include -#include +#include #include // FLL-0 signal includes. diff --git a/level_0/f_type/c/type.h b/level_0/f_type/c/type.h index 3813e40..2c77e4a 100644 --- a/level_0/f_type/c/type.h +++ b/level_0/f_type/c/type.h @@ -7,7 +7,7 @@ * * Provides datatype definitions. * - * This does not auto-include type_file.h, which must be manually included when needed. + * This does not auto-include type/file.h, which must be manually included when needed. */ #ifndef _F_type_h #define _F_type_h @@ -23,6 +23,15 @@ #include #include +// FLL-0 type includes. +#include +#include +#include +#include +#include +#include +#include + #ifdef __cplusplus extern "C" { #endif @@ -49,256 +58,6 @@ extern "C" { #endif // _di_compiler_attributes_d_ /** - * A status intended to be used as the return value status of some function or operation. - */ -#ifndef _di_f_status_t_ - typedef uint16_t f_status_t; - - #define f_status_t_initialize F_okay -#endif // _di_f_status_t_ - -/** - * A representation of a state to be shared between different levels for some function. - * - * This is used to provide advanced controls on different levels of the project to something outside. - * - * The allocate provides an allocation step so that the caller can determine a better performing allocation step for their purpose. - * For example, if the caller knows that they need to allocate a hundred megabytes of data of which is separated into blocks of 8k, then allocate could be set to 8192. - * - * There are two standard callbacks that are expected to be commonly available: interrupt() and handle(). - * Additional callbacks are stored in the structure "callbacks" as defined by the class requiring the use of this structure (f_state_t). - * - * All state values may be NULL, in which case they are to be ignored. - * - * The general interpretation of the state.status results of interrupt() or any of the functions should have an error bit to designate an error and not an error bit to designate not an error. - * In the case of interrupt(), the F_interrupt and F_interrupt_not must be returned as appropriate and if not an error (the F_interrupt and F_interrupt_not may have an error bit). - * To keep the logic simple, it is recommended that F_interrupt always be returned with the error bit set. - * - * The general interpretation of handle() is to either print an error message or to perform additional tasks when an error occurs (such as saving state data for use at a higher level). - * This allows for the error to be processed with all relevant data before the function returns. - * - * These two callbacks (handle() and interrupt()) accept the following parameters: - * - state: The state data. Must be of type f_state_t. Must not be NULL. - * - internal: Additional data passed by the function being called, often containing internal data to the called function. May be NULL. - * - * The "custom" property on f_state_t is intended to be used so that the callback, such as the interrupt(), can make changes to something within the scope of the parent. - * - * For example: - * There exists some project "bob" with some functions "bob_does()" and "bob_interrupts()". - * The function "bob_does()" maintains a state (f_state_t) called "bob_state". - * The function "bob_does()" will call "f_talk()" that accepts a state (f_state_t) and defines the data structure type "f_interject_t" to be called interject. - * While "f_talk()" executes, "bob_interrupts()" is periodically with the state (f_state_t) "bob_state" as the first parameter and the data structure (f_interject_t) "interject" as the second parameter. - * If Bob interjects the talk, then bob_interrupts() would set state.status to F_interrupt. - * If Bob does not interject the talk, then bob_interrupts() would set state.status to F_interrupt_not. - * This response is handled within f_talk(). - * The f_talk() function will then set the state.status when done and might immediately set state.status to F_interrupt (with error bit) if bob_interrupts() returns F_interrupt (with/without error bit). - * - * Properties: - * - step_large: The allocation step to use for large buffers. - * - step_small: The allocation step to use for small buffers. - * - flag: A 64-bit digit intended for provided flags that are defined by the function. - * - code: A 64-bit digit intended for provided flags that are defined by the caller. - * - status: The status used while processing (This should hold the error passed to the handle callback and should be updated as necessary). - * - handle: A function to call on a specific error (allowing for the error to be handled before function returns). May be NULL. - * - interrupt: A function to call for checking to see if an interrupt is to be called. May be NULL. - * - callbacks: A structure (defined by function/project using this) of additional functions to call. May be NULL. - * - custom: A structure (defined by caller/parent) for holding custom data to be passed along to the interrupt() or one of the functions. May be NULL. - * - data: A structure (defined by function) for holding data relevant to the function. May be NULL. May be required. - */ -#ifndef _di_f_state_t_ - typedef struct { - uint16_t step_large; - uint16_t step_small; - f_status_t status; - uint64_t flag; - uint64_t code; - - void (*handle)(void * const state, void * const internal); - void (*interrupt)(void * const state, void * const internal); - - void *callbacks; - void *custom; - void *data; - } f_state_t; - - #define f_state_t_initialize { \ - F_memory_default_allocation_large_d, \ - F_memory_default_allocation_small_d, \ - F_okay, \ - 0, \ - 0, \ - 0, \ - 0, \ - 0, \ - 0, \ - 0, \ - } - - #define macro_f_state_t_initialize_1(step_large, step_small, status, flag, code, handle, interrupt, callbacks, custom, data) { \ - step_large, \ - step_small, \ - status, \ - flag, \ - code, \ - handle, \ - interrupt, \ - callbacks, \ - custom, \ - data, \ - } - - #define macro_f_state_t_clear(state) \ - state.step_large = 0; \ - state.step_small = 0; \ - state.status = F_okay; \ - state.flag = 0; \ - state.code = 0; \ - state.handle = 0; \ - state.interrupt = 0; \ - state.callbacks = 0; \ - state.custom = 0; \ - state.data = 0; -#endif // _di_f_state_t_ - -/** - * Conditional 128-bit support. - * - * This should work in GCC, but other compilers this may not be available. - * When not supported, these will fallback to 64-bit. - */ -#ifndef _di_f_int128_t_ - #ifdef __SIZEOF_INT128__ - typedef __int128_t f_int128_t; - typedef __uint128_t f_uint128_t; - #else - typedef int64_t f_int128_t; - typedef uint64_t f_uint128_t; - #endif // __SIZEOF_INT128__ -#endif // _di_f_int128_t_ - -/** - * Defines the maximum size to be supported. - * - * The size is to be the (max supported size - 1) such that that last number can be used for overflow operations. - * - * For example, F_type_size_8_negative_d is 2^7, or -1 to -128, therefore the max size here is -128 - 1 or -127. - * For example, F_type_size_8_positive_d is 2^7, or 0 to 127, therefore the max size here is 127 - 1 or 126. - * For example, F_type_size_8_unsigned_d is 2^8, or 0 to 255, therefore the max size here is 255 - 1 or 254. - * - * The max_size is provided for actual max sizes. - * For example, F_type_size_8_negative_d is 2^7, or -1 to -128, therefore the max size here is -128. - * For example, F_type_size_8_positive_d is 2^7, or 0 to 127, therefore the max size here is 127. - * For example, F_type_size_8_unsigned_d is 2^8, or 0 to 255, therefore the max size here is 255. - */ -#ifndef _di_f_type_sizes_d_ - #define F_type_size_8_negative_d 0x7f - #define F_type_size_8_positive_d 0x7e - #define F_type_size_8_unsigned_d 0xfe - - #define F_type_size_16_negative_d 0x7fff - #define F_type_size_16_positive_d 0x7ffe - #define F_type_size_16_unsigned_d 0xfffe - - #define F_type_size_32_negative_d 0x7fffffff - #define F_type_size_32_positive_d 0x7ffffffe - #define F_type_size_32_unsigned_d 0xfffffffe - - #define F_type_size_64_negative_d 0x7fffffffffffffff - #define F_type_size_64_positive_d 0x7ffffffffffffffe - #define F_type_size_64_unsigned_d 0xfffffffffffffffe - - #ifdef __SIZEOF_INT128__ - #define F_type_size_128_negative_d 0x7fffffffffffffffffffffff - #define F_type_size_128_positive_d 0x7ffffffffffffffffffffffe - #define F_type_size_128_unsigned_d 0xfffffffffffffffffffffffe - #else - #define F_type_size_128_negative_d F_type_size_64_negative_d - #define F_type_size_128_positive_d F_type_size_64_positive_d - #define F_type_size_128_unsigned_d F_type_size_64_unsigned_d - #endif // __SIZEOF_INT128__ - - #define F_type_size_max_8_negative_d 0x80 - #define F_type_size_max_8_positive_d 0x7f - #define F_type_size_max_8_unsigned_d 0xff - - #define F_type_size_max_16_negative_d 0x8000 - #define F_type_size_max_16_positive_d 0x7fff - #define F_type_size_max_16_unsigned_d 0xffff - - #define F_type_size_max_32_negative_d 0x80000000 - #define F_type_size_max_32_positive_d 0x7fffffff - #define F_type_size_max_32_unsigned_d 0xffffffff - - #define F_type_size_max_64_negative_d 0x8000000000000000 - #define F_type_size_max_64_positive_d 0x7fffffffffffffff - #define F_type_size_max_64_unsigned_d 0xffffffffffffffff - - #ifdef __SIZEOF_INT128__ - #define F_type_size_max_128_negative_d 0x800000000000000000000000 - #define F_type_size_max_128_positive_d 0x7fffffffffffffffffffffff - #define F_type_size_max_128_unsigned_d 0xffffffffffffffffffffffff - #else - #define F_type_size_max_128_negative_d F_type_size_max_64_negative_d - #define F_type_size_max_128_positive_d F_type_size_max_64_positive_d - #define F_type_size_max_128_unsigned_d F_type_size_max_64_unsigned_d - #endif // __SIZEOF_INT128__ -#endif // _di_f_type_sizes_d_ - -/** - * Custom data type to be used throughout the project to represent general numbers. - * - * This is intended to be used in buffers, such as strings, and in argument parameters. - * - * Provides additional custom types so that it can be more easily be overwritten. - * Specifically, there is support for using 32-bit, 64-bit, or 128-bit lengths. - * - * 64-bit is the designed default. - */ -#ifndef _di_f_type_number_64_t_ - typedef int64_t f_number_signed_t; - typedef uint64_t f_number_unsigned_t; - - #define f_number_signed_t_initialize 0 - #define f_number_unsigned_t_initialize 0 - - #define F_number_t_size_unsigned_d F_type_size_64_unsigned_d - #define F_number_t_size_positive_d F_type_size_64_positive_d - #define F_number_t_size_negative_d F_type_size_64_negative_d - - #define F_number_t_size_max_unsigned_d F_type_size_max_64_unsigned_d - #define F_number_t_size_max_positive_d F_type_size_max_64_positive_d - #define F_number_t_size_max_negative_d F_type_size_max_64_negative_d -#elif defined(_en_f_type_number_32_t_) - typedef int32_t f_number_signed_t; - typedef uint32_t f_number_unsigned_t; - - #define f_number_signed_t_initialize 0 - #define f_number_unsigned_t_initialize 0 - - #define F_number_t_size_unsigned_d F_type_size_32_unsigned_d - #define F_number_t_size_positive_d F_type_size_32_positive_d - #define F_number_t_size_negative_d F_type_size_32_negative_d - - #define F_number_t_size_max_unsigned_d F_type_size_max_32_unsigned_d - #define F_number_t_size_max_positive_d F_type_size_max_32_positive_d - #define F_number_t_size_max_negative_d F_type_size_max_32_negative_d -#elif defined(_en_f_type_number_128_t_) - typedef f_int128_t f_number_signed_t; - typedef f_uint128_t f_number_unsigned_t; - - #define f_number_signed_t_initialize 0 - #define f_number_unsigned_t_initialize 0 - - #define F_number_t_size_unsigned_d F_type_size_128_unsigned_d - #define F_number_t_size_positive_d F_type_size_128_positive_d - #define F_number_t_size_negative_d F_type_size_128_negative_d - - #define F_number_t_size_max_unsigned_d F_type_size_max_128_unsigned_d - #define F_number_t_size_max_positive_d F_type_size_max_128_positive_d - #define F_number_t_size_max_negative_d F_type_size_max_128_negative_d -#endif // _en_f_type_number_128_t_ - -/** * Standard file types defines. * * F_type_*_d: @@ -321,1012 +80,6 @@ extern "C" { #define F_type_descriptor_output_d STDOUT_FILENO #endif // _di_f_type_d_ -/** - * A structure designating a row and column, just like a cell in a table. - * - * Properties: - * - row: The row position. - * - column: The column position. - */ -#ifndef _di_f_cell_t_ - typedef struct { - f_number_unsigned_t row; - f_number_unsigned_t column; - } f_cell_t; - - #define f_cell_t_initialize { 0, 0 } - - #define macro_f_cell_t_initialize_1(row, column) { row, column } - - #define macro_f_cell_t_clear(cell) \ - cell.row = 0; \ - cell.column = 0; -#endif // _di_f_cell_t_ - -/** - * An array of f_cell_t. - * - * The macros are defined in type_array.h or type_array-common.h. - * - * Properties: - * - array: The array of f_cell_t. - * - size: Total amount of allocated space. - * - used: Total number of allocated spaces used. - */ -#ifndef _di_f_cells_t_ - typedef struct { - f_cell_t *array; - - f_number_unsigned_t size; - f_number_unsigned_t used; - } f_cells_t; - - #define f_cells_t_initialize { 0, 0, 0 } - - #define macro_f_cells_t_initialize_1(array, size, used) { array, size, used } - #define macro_f_cells_t_initialize_2(array, length) { array, length, length } -#endif // _di_f_cells_t_ - -/** - * This holds an array of f_cells_t. - * - * The macros are defined in type_array.h or type_array-common.h. - * - * Properties: - * - array: The array of f_cell_t arrays. - * - size: Total amount of allocated space. - * - used: Total number of allocated spaces used. - */ -#ifndef _di_f_cellss_t_ - typedef struct { - f_cells_t *array; - - f_number_unsigned_t size; - f_number_unsigned_t used; - } f_cellss_t; - - #define f_cellss_t_initialize { 0, 0, 0 } - - #define macro_f_cellss_t_initialize_1(array, size, used) { array, size, used } - #define macro_f_cellss_t_initialize_2(array, length) { array, length, length } -#endif // _di_f_cellss_t_ - -/** - * A structure representing a set of modes intended to be used by file or directory operations. - * - * Properties: - * - block: The mode for a block. - * - character: The mode for a character. - * - directory: The mode for a directory. - * - fifo: The mode for a FIFO. - * - regular: The mode for a regular file. - * - link: The mode for a link. - * - socket: The mode for a socket. - * - unknown: The mode for unknown types. - */ -#ifndef _di_f_mode_t_ - typedef struct { - mode_t block; // S_IFBLK - mode_t character; // S_IFCHR - mode_t directory; // S_IFDIR - mode_t fifo; // S_IFIFO - mode_t regular; // S_IFREG - mode_t link; // S_IFLNK - mode_t socket; // S_IFSOCK - mode_t unknown; - } f_mode_t; - - #define f_mode_t_initialize { \ - 0, \ - 0, \ - 0, \ - 0, \ - 0, \ - 0, \ - 0, \ - 0, \ - } - - #define macro_f_mode_t_set_default(mode) \ - mode.block = F_file_mode_all_rw_d; \ - mode.character = F_file_mode_all_rw_d; \ - mode.directory = F_file_mode_all_rwx_d; \ - mode.fifo = F_file_mode_all_rw_d; \ - mode.regular = F_file_mode_all_rw_d; \ - mode.link = F_file_mode_all_rw_d; \ - mode.socket = F_file_mode_all_rw_d; \ - mode.unknown = F_file_mode_all_rw_d; - - #define macro_f_mode_t_set_default_umask(mode, mask) \ - mode.block = F_file_mode_all_rw_d & ~mask; \ - mode.character = F_file_mode_all_rw_d & ~mask; \ - mode.directory = F_file_mode_all_rwx_d & ~mask; \ - mode.fifo = F_file_mode_all_rw_d & ~mask; \ - mode.regular = F_file_mode_all_rw_d & ~mask; \ - mode.link = F_file_mode_all_rw_d & ~mask; \ - mode.socket = F_file_mode_all_rw_d & ~mask; \ - mode.unknown = F_file_mode_all_rw_d & ~mask; - - #define macro_f_mode_t_set_all(mode, value) \ - mode.block = value; \ - mode.character = value; \ - mode.directory = value; \ - mode.fifo = value; \ - mode.regular = value; \ - mode.link = value; \ - mode.socket = value; \ - mode.unknown = value; - - #define macro_f_mode_t_set_common(mode, value_directory, value_file, value_link) \ - mode.directory = value_directory; \ - mode.regular = value_file; \ - mode.link = value_link; - - #define macro_f_mode_t_set_uncommon(mode, value_block, value_character, value_fifo, value_socket, value_unknown) \ - mode.block = value_block; \ - mode.character = value_character; \ - mode.fifo = value_fifo; \ - mode.socket = value_socket; \ - mode.unknown = value_unknown; -#endif // _di_f_directory_mode_ - -/** - * Hold a unit of Time. - * - * This is intended to be utilized for the unit of measurement called a "Time", represented with uppercase "T". - * For comparison, a unit of Time is equivalent to a nanosecond, or 10^-9 seconds. - * - * A unit of Time is intended to represent some unit of Time such that a single 64-bit integer may hold all units of Time for a single calendar year. - * This unit of Time does not and must not include Years (unlike Unixtime). - * - * A MegaTime (MT) is therefore equivalent to a millisecond such that a millisecond is 10^-3 seconds. - * - * To convert from Time to Unixtime, one must have a year (which could be assumed to be the current year) and then calculate all of those calendar od - * - * A unit of Time by default is assumed to be in UTC. - * 1 (Earth) year ~= 31536000000000000 Time or 31536000 GT (GigaTime). - * 1 (Earth) day = 86400000000000 Time or 86400 GT (GigaTime). - * 1 (Earth) hour = 3600000000000 Time or 3600 GT (GigaTime). - * 1 (Earth) minute = 60000000000 Time or 60 GT (GigaTime). - * 1 (Earth) second = 1000000000 Time or 1 GT (GigaTime). - * - * Consequentially, 1 day in units of Time is easily represented as 86.4 TT (TeraTime). - * - * This is not time_t, which is a different structure that may not be uint64_t and is often signed. - */ -#ifndef _di_f_time_t_ - typedef uint64_t f_time_t; - - #define f_time_t_initialize 0 -#endif // _di_f_time_t_ - -/** - * A non-kernel dependent alternative version of "struct timespec". - * - * This is may not compatible with struct timespec because seconds is time_t and that may not be a uint64_t. - * In many cases of "struct timespec", seconds is signed because time_t is signed. - * - * Properties: - * - seconds: The total number of seconds. - * - seconds_nano: The total number of nanoseconds. - */ -#ifndef _di_f_time_spec_t_ - typedef struct { - f_time_t seconds; - f_time_t seconds_nano; - } f_time_spec_t; - - #define f_time_spec_t_initialize { f_time_t_initialize, f_time_t_initialize } - - #define macro_f_time_spec_t_clear(spec) \ - spec.seconds = 0; \ - spec.seconds_nano = 0; -#endif // _di_f_time_spec_t_ - -/** - * Hold a unit of Time along with a year to represent a date. - * - * This implementation of a date using the unit of Time is limited on the size of the year. - * The value for year is expected to be a signed number. - * For anything that needs a larger (or smaller) year, create a new type or use the "year string format" of Time. - * - * In "year string format" of Time, a Year may be prepended to the Time followed by a single colon ':' to associate a year with the Time. - * This Year has no minimum or maximum but may not have decimals. - * - * For example, "2020:86400000000000" would represent: January 02, 2020 0:00 UTC. - * For example, "2020:86.4 TT" would represent: January 02, 2020 0:00 UTC. - * - * Properties: - * - year: A number representing the year. - * - time: A number representing the time. - */ -#ifndef _di_f_date_t_ - typedef struct { - f_number_signed_t year; - f_time_t time; - } f_date_t; - - #define f_date_t_initialize { 0, 0 } - - #define macro_f_date_t_clear(date) \ - date.year = 0; \ - date.time = 0; -#endif // _di_f_date_t_ - -/** - * A variation of f_date_t that using f_time_spec_t rather than f_time_t. - * - * This can is a more precise alternative to f_date_t because it stores nanoseconds. - * - * The f_time_spec_t.time.seconds can be directly cast to the f_date_t.time. - * - * Properties: - * - year: A number representing the year. - * - time: A number representing the time with seconds and nanoseconds. - */ -#ifndef _di_f_date_spec_t_ - typedef struct { - f_time_t year; - f_time_spec_t time; - } f_date_spec_t; - - #define f_date_spec_t_initialize { f_time_t_initialize, macro_f_time_spec_t_clear } - - #define macro_f_date_spec_t_clear(date) \ - date.year = 0; \ - macro_f_time_spec_t_clear(date.time); -#endif // _di_f_date_spec_t_ - -/** - * An array of array lengths. - * - * The macros are defined in type_array.h or type_array-common.h. - * - * Properties: - * - array: An array of array lengths. - * - size: Total amount of allocated space. - * - used: Total number of allocated spaces used. - */ -#ifndef _di_f_number_unsigneds_t_ - typedef struct { - f_number_unsigned_t *array; - - f_number_unsigned_t size; - f_number_unsigned_t used; - } f_number_unsigneds_t; - - #define f_number_unsigneds_t_initialize { 0, 0, 0 } - - #define macro_f_number_unsigneds_t_initialize_1(array, size, used) { array, size, used } - #define macro_f_number_unsigneds_t_initialize_2(array, length) { array, length, length } -#endif // _di_f_number_unsigneds_t_ - -/** - * An array of an array of array lengths. - * - * The macros are defined in type_array.h or type_array-common.h. - * - * Properties: - * - array: The array of an array of array lengths. - * - size: Total amount of allocated space. - * - used: Total number of allocated spaces used. - */ -#ifndef _di_f_number_unsignedss_t_ - typedef struct { - f_number_unsigneds_t *array; - - f_number_unsigned_t size; - f_number_unsigned_t used; - } f_number_unsignedss_t; - - #define f_number_unsignedss_t_initialize { 0, 0, 0 } - - #define macro_f_number_unsignedss_t_initialize_1(array, size, used) { array, size, used } - #define macro_f_number_unsignedss_t_initialize_2(array, length) { array, length, length } -#endif // _di_f_number_unsignedss_t_ - -/** - * An array of array int8_t. - * - * The macros are defined in type_array.h or type_array-common.h. - * - * Properties: - * - array: An array of int8_t. - * - size: Total amount of allocated space. - * - used: Total number of allocated spaces used. - */ -#ifndef _di_f_int8s_t_ - typedef struct { - int8_t *array; - - f_number_unsigned_t size; - f_number_unsigned_t used; - } f_int8s_t; - - #define f_int8s_t_initialize { 0, 0, 0 } - - #define macro_f_int8s_t_initialize_1(array, size, used) { array, size, used } - #define macro_f_int8s_t_initialize_2(array, length) { array, length, length } -#endif // _di_f_int8s_t_ - -/** - * An array of an array of array int8_t. - * - * The macros are defined in type_array.h or type_array-common.h. - * - * Properties: - * - array: The array of an array of array int8_t. - * - size: Total amount of allocated space. - * - used: Total number of allocated spaces used. - */ -#ifndef _di_f_int8ss_t_ - typedef struct { - f_int8s_t *array; - - f_number_unsigned_t size; - f_number_unsigned_t used; - } f_int8ss_t; - - #define f_int8ss_t_initialize { 0, 0, 0 } - - #define macro_f_int8ss_t_initialize_1(array, size, used) { array, size, used } - #define macro_f_int8ss_t_initialize_2(array, length) { array, length, length } -#endif // _di_f_int8ss_t_ - -/** - * An array of array uint8_t. - * - * The macros are defined in type_array.h or type_array-common.h. - * - * Properties: - * - array: An array of uint8_t. - * - size: Total amount of allocated space. - * - used: Total number of allocated spaces used. - */ -#ifndef _di_f_uint8s_t_ - typedef struct { - uint8_t *array; - - f_number_unsigned_t size; - f_number_unsigned_t used; - } f_uint8s_t; - - #define f_uint8s_t_initialize { 0, 0, 0 } - - #define macro_f_uint8s_t_initialize_1(array, size, used) { array, size, used } - #define macro_f_uint8s_t_initialize_2(array, length) { array, length, length } -#endif // _di_f_uint8s_t_ - -/** - * An array of an array of array uint8_t. - * - * The macros are defined in type_array.h or type_array-common.h. - * - * Properties: - * - array: The array of an array of array uint8_t. - * - size: Total amount of allocated space. - * - used: Total number of allocated spaces used. - */ -#ifndef _di_f_uint8ss_t_ - typedef struct { - f_uint8s_t *array; - - f_number_unsigned_t size; - f_number_unsigned_t used; - } f_uint8ss_t; - - #define f_uint8ss_t_initialize { 0, 0, 0 } - - #define macro_f_uint8ss_t_initialize_1(array, size, used) { array, size, used } - #define macro_f_uint8ss_t_initialize_2(array, length) { array, length, length } -#endif // _di_f_uint8ss_t_ - -/** - * An array of array int16_t. - * - * The macros are defined in type_array.h or type_array-common.h. - * - * Properties: - * - array: An array of int16_t. - * - size: Total amount of allocated space. - * - used: Total number of allocated spaces used. - */ -#ifndef _di_f_int16s_t_ - typedef struct { - int16_t *array; - - f_number_unsigned_t size; - f_number_unsigned_t used; - } f_int16s_t; - - #define f_int16s_t_initialize { 0, 0, 0 } - - #define macro_f_int16s_t_initialize_1(array, size, used) { array, size, used } - #define macro_f_int16s_t_initialize_2(array, length) { array, length, length } -#endif // _di_f_int16s_t_ - -/** - * An array of an array of array int16_t. - * - * The macros are defined in type_array.h or type_array-common.h. - * - * Properties: - * - array: The array of an array of array int16_t. - * - size: Total amount of allocated space. - * - used: Total number of allocated spaces used. - */ -#ifndef _di_f_int16ss_t_ - typedef struct { - f_int16s_t *array; - - f_number_unsigned_t size; - f_number_unsigned_t used; - } f_int16ss_t; - - #define f_int16ss_t_initialize { 0, 0, 0 } - - #define macro_f_int16ss_t_initialize_1(array, size, used) { array, size, used } - #define macro_f_int16ss_t_initialize_2(array, length) { array, length, length } -#endif // _di_f_int16ss_t_ - -/** - * An array of array uint16_t. - * - * The macros are defined in type_array.h or type_array-common.h. - * - * Properties: - * - array: An array of uint16_t. - * - size: Total amount of allocated space. - * - used: Total number of allocated spaces used. - */ -#ifndef _di_f_uint16s_t_ - typedef struct { - uint16_t *array; - - f_number_unsigned_t size; - f_number_unsigned_t used; - } f_uint16s_t; - - #define f_uint16s_t_initialize { 0, 0, 0 } - - #define macro_f_uint16s_t_initialize_1(array, size, used) { array, size, used } - #define macro_f_uint16s_t_initialize_2(array, length) { array, length, length } -#endif // _di_f_uint16s_t_ - -/** - * An array of an array of array uint16_t. - * - * The macros are defined in type_array.h or type_array-common.h. - * - * Properties: - * - array: The array of an array of array uint16_t. - * - size: Total amount of allocated space. - * - used: Total number of allocated spaces used. - */ -#ifndef _di_f_uint16ss_t_ - typedef struct { - f_uint16s_t *array; - - f_number_unsigned_t size; - f_number_unsigned_t used; - } f_uint16ss_t; - - #define f_uint16ss_t_initialize { 0, 0, 0 } - - #define macro_f_uint16s_t_initialize_1(array, size, used) { array, size, used } - #define macro_f_uint16s_t_initialize_2(array, length) { array, length, length } -#endif // _di_f_uint16ss_t_ - -/** - * An array of array int32_t. - * - * The macros are defined in type_array.h or type_array-common.h. - * - * Properties: - * - array: An array of int32_t. - * - size: Total amount of allocated space. - * - used: Total number of allocated spaces used. - */ -#ifndef _di_f_int32s_t_ - typedef struct { - int32_t *array; - - f_number_unsigned_t size; - f_number_unsigned_t used; - } f_int32s_t; - - #define f_int32s_t_initialize { 0, 0, 0 } - - #define macro_f_int32s_t_initialize_1(array, size, used) { array, size, used } - #define macro_f_int32s_t_initialize_2(array, length) { array, length, length } -#endif // _di_f_int32s_t_ - -/** - * An array of an array of array int32_t. - * - * The macros are defined in type_array.h or type_array-common.h. - * - * Properties: - * - array: The array of an array of array int32_t. - * - size: Total amount of allocated space. - * - used: Total number of allocated spaces used. - */ -#ifndef _di_f_int32ss_t_ - typedef struct { - f_int32s_t *array; - - f_number_unsigned_t size; - f_number_unsigned_t used; - } f_int32ss_t; - - #define f_int32ss_t_initialize { 0, 0, 0 } - - #define macro_f_int32ss_t_initialize_1(array, size, used) { array, size, used } - #define macro_f_int32ss_t_initialize_2(array, length) { array, length, length } -#endif // _di_f_int32ss_t_ - -/** - * An array of array uint32_t. - * - * The macros are defined in type_array.h or type_array-common.h. - * - * Properties: - * - array: An array of uint32_t. - * - size: Total amount of allocated space. - * - used: Total number of allocated spaces used. - */ -#ifndef _di_f_uint32s_t_ - typedef struct { - uint32_t *array; - - f_number_unsigned_t size; - f_number_unsigned_t used; - } f_uint32s_t; - - #define f_uint32s_t_initialize { 0, 0, 0 } - - #define macro_f_uint32s_t_initialize_1(array, size, used) { array, size, used } - #define macro_f_uint32s_t_initialize_2(array, length) { array, length, length } -#endif // _di_f_uint32s_t_ - -/** - * An array of an array of array uint32_t. - * - * The macros are defined in type_array.h or type_array-common.h. - * - * Properties: - * - array: The array of an array of array uint32_t. - * - size: Total amount of allocated space. - * - used: Total number of allocated spaces used. - */ -#ifndef _di_f_uint32ss_t_ - typedef struct { - f_uint32s_t *array; - - f_number_unsigned_t size; - f_number_unsigned_t used; - } f_uint32ss_t; - - #define f_uint32ss_t_initialize { 0, 0, 0 } - - #define macro_f_uint32ss_t_initialize_1(array, size, used) { array, size, used } - #define macro_f_uint32ss_t_initialize_2(array, length) { array, length, length } -#endif // _di_f_uint32ss_t_ - -/** - * An array of array int64_t. - * - * The macros are defined in type_array.h or type_array-common.h. - * - * Properties: - * - array: An array of int64_t. - * - size: Total amount of allocated space. - * - used: Total number of allocated spaces used. - */ -#ifndef _di_f_int64s_t_ - typedef struct { - int64_t *array; - - f_number_unsigned_t size; - f_number_unsigned_t used; - } f_int64s_t; - - #define f_int64s_t_initialize { 0, 0, 0 } - - #define macro_f_int64s_t_initialize_1(array, size, used) { array, size, used } - #define macro_f_int64s_t_initialize_2(array, length) { array, length, length } -#endif // _di_f_int64s_t_ - -/** - * An array of an array of array int64_t. - * - * The macros are defined in type_array.h or type_array-common.h. - * - * Properties: - * - array: The array of an array of array int64_t. - * - size: Total amount of allocated space. - * - used: Total number of allocated spaces used. - */ -#ifndef _di_f_int64ss_t_ - typedef struct { - f_int64s_t *array; - - f_number_unsigned_t size; - f_number_unsigned_t used; - } f_int64ss_t; - - #define f_int64ss_t_initialize { 0, 0, 0 } - - #define macro_f_int64ss_t_initialize_1(array, size, used) { array, size, used } - #define macro_f_int64ss_t_initialize_2(array, length) { array, length, length } -#endif // _di_f_int64ss_t_ - -/** - * An array of array uint64_t. - * - * The macros are defined in type_array.h or type_array-common.h. - * - * Properties: - * - array: An array of uint64_t. - * - size: Total amount of allocated space. - * - used: Total number of allocated spaces used. - */ -#ifndef _di_f_uint64s_t_ - typedef struct { - uint64_t *array; - - f_number_unsigned_t size; - f_number_unsigned_t used; - } f_uint64s_t; - - #define f_uint64s_t_initialize { 0, 0, 0 } - - #define macro_f_uint64s_t_initialize_1(array, size, used) { array, size, used } - #define macro_f_uint64s_t_initialize_2(array, length) { array, length, length } -#endif // _di_f_uint64s_t_ - -/** - * An array of an array of array uint64_t. - * - * The macros are defined in type_array.h or type_array-common.h. - * - * Properties: - * - array: The array of an array of array uint64_t. - * - size: Total amount of allocated space. - * - used: Total number of allocated spaces used. - */ -#ifndef _di_f_uint64ss_t_ - typedef struct { - f_uint64s_t *array; - - f_number_unsigned_t size; - f_number_unsigned_t used; - } f_uint64ss_t; - - #define f_uint64ss_t_initialize { 0, 0, 0 } - - #define macro_f_uint64ss_t_initialize_1(array, size, used) { array, size, used } - #define macro_f_uint64ss_t_initialize_2(array, length) { array, length, length } -#endif // _di_f_uint64ss_t_ - -/** - * Provide a 128-bit type wrapper, which could be either 64-bit or 128-bit depending on support. - * - * This is __int128_t when 128-bit is supported and int64_t when not supported. - * - * This provides the types without the normal "f_" leading prefixes to be more in line with the core types like int64_t. - */ -#ifdef __SIZEOF_INT128__ - #ifndef _di_f_int128_t_ - typedef __int128_t int128_t; - #endif // _di_f_int128_t_ - - #ifndef _di_f_uint128_t_ - typedef __uint128_t uint128_t; - #endif // _di_f_uint128_t_ -#else // __SIZEOF_INT128__ - #ifndef _di_f_int128_t_ - typedef int64_t int128_t; - #endif // _di_f_int128_t_ - - #ifndef _di_f_uint128_t_ - typedef uint64_t uint128_t; - #endif // _di_f_uint128_t_ -#endif // __SIZEOF_INT128__ - -/** - * An array of int128_t. - * - * The macros are defined in type_array.h or type_array-common.h. - * - * Properties: - * - array: The array of int128_t. - * - size: Total amount of allocated space. - * - used: Total number of allocated spaces used. - */ -#ifndef _di_f_int128s_t_ - typedef struct { - int128_t *array; - - f_number_unsigned_t size; - f_number_unsigned_t used; - } f_int128s_t; - - #define f_int128s_t_initialize { 0, 0, 0 } - - #define macro_f_int128s_t_initialize_1(array, size, used) { array, size, used } - #define macro_f_int128s_t_initialize_2(array, length) { array, length, length } -#endif // _di_f_int128s_t_ - -/** - * An array of and array of int128_t. - * - * The macros are defined in type_array.h or type_array-common.h. - * - * Properties: - * - array: The array of and array of int128_t. - * - size: Total amount of allocated space. - * - used: Total number of allocated spaces used. - */ -#ifndef _di_f_int128ss_t_ - typedef struct { - f_int128s_t *array; - - f_number_unsigned_t size; - f_number_unsigned_t used; - } f_int128ss_t; - - #define f_int128ss_t_initialize { 0, 0, 0 } - - #define macro_f_int128ss_t_initialize_1(array, size, used) { array, size, used } - #define macro_f_int128ss_t_initialize_2(array, length) { array, length, length } -#endif // _di_f_int128ss_t_ - -/** - * An array of uint128_t. - * - * The macros are defined in type_array.h or type_array-common.h. - * - * Properties: - * - array: The array of uint128_t. - * - size: Total amount of allocated space. - * - used: Total number of allocated spaces used. - */ -#ifndef _di_f_uint128s_t_ - typedef struct { - uint128_t *array; - - f_number_unsigned_t size; - f_number_unsigned_t used; - } f_uint128s_t; - - #define f_uint128s_t_initialize { 0, 0, 0 } - - #define macro_f_uint128s_t_initialize_1(array, size, used) { array, size, used } - #define macro_f_uint128s_t_initialize_2(array, length) { array, length, length } -#endif // _di_f_uint128s_t_ - -/** - * An array of and array of uint128_t. - * - * The macros are defined in type_array.h or type_array-common.h. - * - * Properties: - * - array: The array of and array of uint128_t. - * - size: Total amount of allocated space. - * - used: Total number of allocated spaces used. - */ -#ifndef _di_f_uint128ss_t_ - typedef struct { - f_uint128s_t *array; - - f_number_unsigned_t size; - f_number_unsigned_t used; - } f_uint128ss_t; - - #define f_uint128ss_t_initialize { 0, 0, 0 } - - #define macro_f_uint128ss_t_initialize_1(array, size, used) { array, size, used } - #define macro_f_uint128ss_t_initialize_2(array, length) { array, length, length } -#endif // _di_f_uint128ss_t_ - -/** - * This holds an array of f_status_t. - * - * The macros are defined in type_array.h or type_array-common.h. - * - * Properties: - * - array: The array of f_status_t arrays. - * - size: Total amount of allocated space. - * - used: Total number of allocated spaces used. - */ -#ifndef _di_f_statuss_t_ - typedef struct { - f_status_t *array; - - f_number_unsigned_t size; - f_number_unsigned_t used; - } f_statuss_t; - - #define f_statuss_t_initialize { 0, 0, 0 } - - #define macro_f_statuss_t_initialize_1(array, size, used) { array, size, used } - #define macro_f_statuss_t_initialize_2(array, length) { array, length, length } -#endif // _di_f_statuss_t_ - -/** - * This holds an array of f_statuss_t. - * - * The macros are defined in type_array.h or type_array-common.h. - * - * Properties: - * - array: The array of f_status_t arrays. - * - size: Total amount of allocated space. - * - used: Total number of allocated spaces used. - */ -#ifndef _di_f_statusss_t_ - typedef struct { - f_statuss_t *array; - - f_number_unsigned_t size; - f_number_unsigned_t used; - } f_statusss_t; - - #define f_statusss_t_initialize { 0, 0, 0 } - - #define macro_f_statusss_t_initialize_1(array, size, used) { array, size, used } - #define macro_f_statusss_t_initialize_2(array, length) { array, length, length } -#endif // _di_f_statusss_t_ - -/** - * This holds an array of f_state_t. - * - * The macros are defined in type_array.h or type_array-common.h. - * - * Properties: - * - array: The array of f_state_t arrays. - * - size: Total amount of allocated space. - * - used: Total number of allocated spaces used. - */ -#ifndef _di_f_states_t_ - typedef struct { - f_state_t *array; - - f_number_unsigned_t size; - f_number_unsigned_t used; - } f_states_t; - - #define f_states_t_initialize { 0, 0, 0 } - - #define macro_f_states_t_initialize_1(array, size, used) { array, size, used } - #define macro_f_states_t_initialize_2(array, length) { array, length, length } -#endif // _di_f_states_t_ - -/** - * This holds an array of f_states_t. - * - * The macros are defined in type_array.h or type_array-common.h. - * - * Properties: - * - array: The array of f_state_t arrays. - * - size: Total amount of allocated space. - * - used: Total number of allocated spaces used. - */ -#ifndef _di_f_statess_t_ - typedef struct { - f_states_t *array; - - f_number_unsigned_t size; - f_number_unsigned_t used; - } f_statess_t; - - #define f_statess_t_initialize { 0, 0, 0 } - - #define macro_f_statess_t_initialize_1(array, size, used) { array, size, used } - #define macro_f_statess_t_initialize_2(array, length) { array, length, length } -#endif // _di_f_statess_t_ - -/** - * An FLL Identifier represents a way to identify FLL related text files and possibly binary files. - * - * This was originally designed for FSS (Featureless Settings Specification) but has been expanded to be used by the entire project. - * - * An FLL Identifier consists of two parts: - * 1) A 64-byte long string representing a machine-name for the type. - * 2) A 16-bit digit representing 2^16 possible type classifications, which is representeed by 4 hexadecial 1-byte strings for text. - * - * For example "fss-1234" is a valid type such that: - * 1) name: "fss". - * 2) type: "1234", (or 0x1 in binary. - * - * UTF-8 codes are available, but one must consider that 1 4-byte characte still takes up 4-bytes. - * Therefore for all 4-byte UTF-8 characters, there is a maximum of 16 characters available. - * - * This intentionally utilizes a fixed array to avoid the need of dynamic allocation. - * - * The macro_f_fll_id_t_clear() only performs a minimalistic clear on the id.name string. - * The first character in the string array is assigned to NULL. - * For a more accurate clear, use memset() or something similar. - * - * The name must only be "word" characters (therefore "-" is not allowed). - * - * Properties: - * - name: The string representing the name of the FLL Identifier (This is not a NULL terminated string). - * - type: The code representing the type of the Identifier. - * - used: A representation of how many bytes in name are in used (if 0, then there is no name, thus this can be seen as not a valid identifier). - */ -#ifndef _di_f_fll_id_t_ - #define f_fll_id_name_length_d 64 - - typedef struct { - char name[f_fll_id_name_length_d]; - - uint16_t type; - uint8_t used; - } f_fll_id_t; - - #define f_fll_id_t_initialize { \ - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, \ - 0, \ - 0, \ - } - - #define macro_f_fll_id_t_initialize_1(name, type, used) { name, type, used } - - #define macro_f_fll_id_t_clear(id) \ - id.name[0] = 0; \ - id.type = 0; \ - id.used = 0; -#endif // _di_f_fll_id_t_ - -/** - * An array of f_fll_id_t. - * - * The macros are defined in type_array.h or type_array-common.h. - * - * Properties: - * - array: The array of f_fll_id_t. - * - size: Total amount of allocated space. - * - used: Total number of allocated spaces used. - */ -#ifndef _di_f_fll_ids_t_ - typedef struct { - f_fll_id_t *array; - - f_number_unsigned_t size; - f_number_unsigned_t used; - } f_fll_ids_t; - - #define f_fll_ids_t_initialize { 0, 0, 0 } - - #define macro_f_fll_ids_t_initialize_1(array, size, used) { array, size, used } - #define macro_f_fll_ids_t_initialize_2(array, length) { array, length, length } -#endif // _di_f_fll_ids_t_ - -/** - * This holds an array of f_fll_ids_t. - * - * The macros are defined in type_array.h or type_array-common.h. - * - * Properties: - * - array: The array of f_fll_id_t arrays. - * - size: Total amount of allocated space. - * - used: Total number of allocated spaces used. - */ -#ifndef _di_f_fll_idss_t_ - typedef struct { - f_fll_ids_t *array; - - f_number_unsigned_t size; - f_number_unsigned_t used; - } f_fll_idss_t; - - #define f_fll_idss_t_initialize { 0, 0, 0 } - - #define macro_f_fll_idss_t_initialize_1(array, size, used) { array, size, used } - #define macro_f_fll_idss_t_initialize_2(array, length) { array, length, length } -#endif // _di_f_fll_idss_t_ - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_0/f_type/c/type/cell.h b/level_0/f_type/c/type/cell.h new file mode 100644 index 0000000..9897347 --- /dev/null +++ b/level_0/f_type/c/type/cell.h @@ -0,0 +1,93 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Defines cell type data. + * + * This is auto-included by type.h and should not need to be explicitly included. + */ +#ifndef _F_type_cell_h +#define _F_type_cell_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * A structure designating a row and column, just like a cell in a table. + * + * Properties: + * - row: The row position. + * - column: The column position. + */ +#ifndef _di_f_cell_t_ + typedef struct { + f_number_unsigned_t row; + f_number_unsigned_t column; + } f_cell_t; + + #define f_cell_t_initialize { 0, 0 } + + #define macro_f_cell_t_initialize_1(row, column) { row, column } + + #define macro_f_cell_t_clear(cell) \ + cell.row = 0; \ + cell.column = 0; +#endif // _di_f_cell_t_ + +/** + * An array of f_cell_t. + * + * The macros are defined in type_array.h or type_array-common.h. + * + * Properties: + * - array: The array of f_cell_t. + * - size: Total amount of allocated space. + * - used: Total number of allocated spaces used. + */ +#ifndef _di_f_cells_t_ + typedef struct { + f_cell_t *array; + + f_number_unsigned_t size; + f_number_unsigned_t used; + } f_cells_t; + + #define f_cells_t_initialize { 0, 0, 0 } + + #define macro_f_cells_t_initialize_1(array, size, used) { array, size, used } + #define macro_f_cells_t_initialize_2(array, length) { array, length, length } +#endif // _di_f_cells_t_ + +/** + * This holds an array of f_cells_t. + * + * The macros are defined in type_array.h or type_array-common.h. + * + * Properties: + * - array: The array of f_cell_t arrays. + * - size: Total amount of allocated space. + * - used: Total number of allocated spaces used. + */ +#ifndef _di_f_cellss_t_ + typedef struct { + f_cells_t *array; + + f_number_unsigned_t size; + f_number_unsigned_t used; + } f_cellss_t; + + #define f_cellss_t_initialize { 0, 0, 0 } + + #define macro_f_cellss_t_initialize_1(array, size, used) { array, size, used } + #define macro_f_cellss_t_initialize_2(array, length) { array, length, length } +#endif // _di_f_cellss_t_ + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _F_type_cell_h diff --git a/level_0/f_type/c/type_file.h b/level_0/f_type/c/type/file.h similarity index 100% rename from level_0/f_type/c/type_file.h rename to level_0/f_type/c/type/file.h diff --git a/level_0/f_type/c/type/fll.h b/level_0/f_type/c/type/fll.h new file mode 100644 index 0000000..e1315aa --- /dev/null +++ b/level_0/f_type/c/type/fll.h @@ -0,0 +1,124 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Defines fll type data. + * + * This is auto-included by type.h and should not need to be explicitly included. + */ +#ifndef _F_type_fll_h +#define _F_type_fll_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * An FLL Identifier represents a way to identify FLL related text files and possibly binary files. + * + * This was originally designed for FSS (Featureless Settings Specification) but has been expanded to be used by the entire project. + * + * An FLL Identifier consists of two parts: + * 1) A 64-byte long string representing a machine-name for the type. + * 2) A 16-bit digit representing 2^16 possible type classifications, which is representeed by 4 hexadecial 1-byte strings for text. + * + * For example "fss-1234" is a valid type such that: + * 1) name: "fss". + * 2) type: "1234", (or 0x1 in binary. + * + * UTF-8 codes are available, but one must consider that 1 4-byte characte still takes up 4-bytes. + * Therefore for all 4-byte UTF-8 characters, there is a maximum of 16 characters available. + * + * This intentionally utilizes a fixed array to avoid the need of dynamic allocation. + * + * The macro_f_fll_id_t_clear() only performs a minimalistic clear on the id.name string. + * The first character in the string array is assigned to NULL. + * For a more accurate clear, use memset() or something similar. + * + * The name must only be "word" characters (therefore "-" is not allowed). + * + * Properties: + * - name: The string representing the name of the FLL Identifier (This is not a NULL terminated string). + * - type: The code representing the type of the Identifier. + * - used: A representation of how many bytes in name are in used (if 0, then there is no name, thus this can be seen as not a valid identifier). + */ +#ifndef _di_f_fll_id_t_ + #define f_fll_id_name_length_d 64 + + typedef struct { + char name[f_fll_id_name_length_d]; + + uint16_t type; + uint8_t used; + } f_fll_id_t; + + #define f_fll_id_t_initialize { \ + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, \ + 0, \ + 0, \ + } + + #define macro_f_fll_id_t_initialize_1(name, type, used) { name, type, used } + + #define macro_f_fll_id_t_clear(id) \ + id.name[0] = 0; \ + id.type = 0; \ + id.used = 0; +#endif // _di_f_fll_id_t_ + +/** + * An array of f_fll_id_t. + * + * The macros are defined in type_array.h or type_array-common.h. + * + * Properties: + * - array: The array of f_fll_id_t. + * - size: Total amount of allocated space. + * - used: Total number of allocated spaces used. + */ +#ifndef _di_f_fll_ids_t_ + typedef struct { + f_fll_id_t *array; + + f_number_unsigned_t size; + f_number_unsigned_t used; + } f_fll_ids_t; + + #define f_fll_ids_t_initialize { 0, 0, 0 } + + #define macro_f_fll_ids_t_initialize_1(array, size, used) { array, size, used } + #define macro_f_fll_ids_t_initialize_2(array, length) { array, length, length } +#endif // _di_f_fll_ids_t_ + +/** + * This holds an array of f_fll_ids_t. + * + * The macros are defined in type_array.h or type_array-common.h. + * + * Properties: + * - array: The array of f_fll_id_t arrays. + * - size: Total amount of allocated space. + * - used: Total number of allocated spaces used. + */ +#ifndef _di_f_fll_idss_t_ + typedef struct { + f_fll_ids_t *array; + + f_number_unsigned_t size; + f_number_unsigned_t used; + } f_fll_idss_t; + + #define f_fll_idss_t_initialize { 0, 0, 0 } + + #define macro_f_fll_idss_t_initialize_1(array, size, used) { array, size, used } + #define macro_f_fll_idss_t_initialize_2(array, length) { array, length, length } +#endif // _di_f_fll_idss_t_ + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _F_type_fll_h diff --git a/level_0/f_type/c/type/mode.h b/level_0/f_type/c/type/mode.h new file mode 100644 index 0000000..eb89f2b --- /dev/null +++ b/level_0/f_type/c/type/mode.h @@ -0,0 +1,102 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Defines mode type data. + * + * This is auto-included by type.h and should not need to be explicitly included. + */ +#ifndef _F_type_mode_h +#define _F_type_mode_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * A structure representing a set of modes intended to be used by file or directory operations. + * + * Properties: + * - block: The mode for a block. + * - character: The mode for a character. + * - directory: The mode for a directory. + * - fifo: The mode for a FIFO. + * - regular: The mode for a regular file. + * - link: The mode for a link. + * - socket: The mode for a socket. + * - unknown: The mode for unknown types. + */ +#ifndef _di_f_mode_t_ + typedef struct { + mode_t block; // S_IFBLK + mode_t character; // S_IFCHR + mode_t directory; // S_IFDIR + mode_t fifo; // S_IFIFO + mode_t regular; // S_IFREG + mode_t link; // S_IFLNK + mode_t socket; // S_IFSOCK + mode_t unknown; + } f_mode_t; + + #define f_mode_t_initialize { \ + 0, \ + 0, \ + 0, \ + 0, \ + 0, \ + 0, \ + 0, \ + 0, \ + } + + #define macro_f_mode_t_set_default(mode) \ + mode.block = F_file_mode_all_rw_d; \ + mode.character = F_file_mode_all_rw_d; \ + mode.directory = F_file_mode_all_rwx_d; \ + mode.fifo = F_file_mode_all_rw_d; \ + mode.regular = F_file_mode_all_rw_d; \ + mode.link = F_file_mode_all_rw_d; \ + mode.socket = F_file_mode_all_rw_d; \ + mode.unknown = F_file_mode_all_rw_d; + + #define macro_f_mode_t_set_default_umask(mode, mask) \ + mode.block = F_file_mode_all_rw_d & ~mask; \ + mode.character = F_file_mode_all_rw_d & ~mask; \ + mode.directory = F_file_mode_all_rwx_d & ~mask; \ + mode.fifo = F_file_mode_all_rw_d & ~mask; \ + mode.regular = F_file_mode_all_rw_d & ~mask; \ + mode.link = F_file_mode_all_rw_d & ~mask; \ + mode.socket = F_file_mode_all_rw_d & ~mask; \ + mode.unknown = F_file_mode_all_rw_d & ~mask; + + #define macro_f_mode_t_set_all(mode, value) \ + mode.block = value; \ + mode.character = value; \ + mode.directory = value; \ + mode.fifo = value; \ + mode.regular = value; \ + mode.link = value; \ + mode.socket = value; \ + mode.unknown = value; + + #define macro_f_mode_t_set_common(mode, value_directory, value_file, value_link) \ + mode.directory = value_directory; \ + mode.regular = value_file; \ + mode.link = value_link; + + #define macro_f_mode_t_set_uncommon(mode, value_block, value_character, value_fifo, value_socket, value_unknown) \ + mode.block = value_block; \ + mode.character = value_character; \ + mode.fifo = value_fifo; \ + mode.socket = value_socket; \ + mode.unknown = value_unknown; +#endif // _di_f_mode_t_ + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _F_type_mode_h diff --git a/level_0/f_type/c/type/number.h b/level_0/f_type/c/type/number.h new file mode 100644 index 0000000..ffc46ac --- /dev/null +++ b/level_0/f_type/c/type/number.h @@ -0,0 +1,762 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Defines number type data. + * + * This is auto-included by type.h and should not need to be explicitly included. + */ +#ifndef _F_type_number_h +#define _F_type_number_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Defines the maximum size to be supported. + * + * The size is to be the (max supported size - 1) such that that last number can be used for overflow operations. + * + * For example, F_type_size_8_negative_d is 2^7, or -1 to -128, therefore the max size here is -128 - 1 or -127. + * For example, F_type_size_8_positive_d is 2^7, or 0 to 127, therefore the max size here is 127 - 1 or 126. + * For example, F_type_size_8_unsigned_d is 2^8, or 0 to 255, therefore the max size here is 255 - 1 or 254. + * + * The max_size is provided for actual max sizes. + * For example, F_type_size_8_negative_d is 2^7, or -1 to -128, therefore the max size here is -128. + * For example, F_type_size_8_positive_d is 2^7, or 0 to 127, therefore the max size here is 127. + * For example, F_type_size_8_unsigned_d is 2^8, or 0 to 255, therefore the max size here is 255. + */ +#ifndef _di_f_type_sizes_d_ + #define F_type_size_8_negative_d 0x7f + #define F_type_size_8_positive_d 0x7e + #define F_type_size_8_unsigned_d 0xfe + + #define F_type_size_16_negative_d 0x7fff + #define F_type_size_16_positive_d 0x7ffe + #define F_type_size_16_unsigned_d 0xfffe + + #define F_type_size_32_negative_d 0x7fffffff + #define F_type_size_32_positive_d 0x7ffffffe + #define F_type_size_32_unsigned_d 0xfffffffe + + #define F_type_size_64_negative_d 0x7fffffffffffffff + #define F_type_size_64_positive_d 0x7ffffffffffffffe + #define F_type_size_64_unsigned_d 0xfffffffffffffffe + + #ifdef __SIZEOF_INT128__ + #define F_type_size_128_negative_d 0x7fffffffffffffffffffffff + #define F_type_size_128_positive_d 0x7ffffffffffffffffffffffe + #define F_type_size_128_unsigned_d 0xfffffffffffffffffffffffe + #else + #define F_type_size_128_negative_d F_type_size_64_negative_d + #define F_type_size_128_positive_d F_type_size_64_positive_d + #define F_type_size_128_unsigned_d F_type_size_64_unsigned_d + #endif // __SIZEOF_INT128__ + + #define F_type_size_max_8_negative_d 0x80 + #define F_type_size_max_8_positive_d 0x7f + #define F_type_size_max_8_unsigned_d 0xff + + #define F_type_size_max_16_negative_d 0x8000 + #define F_type_size_max_16_positive_d 0x7fff + #define F_type_size_max_16_unsigned_d 0xffff + + #define F_type_size_max_32_negative_d 0x80000000 + #define F_type_size_max_32_positive_d 0x7fffffff + #define F_type_size_max_32_unsigned_d 0xffffffff + + #define F_type_size_max_64_negative_d 0x8000000000000000 + #define F_type_size_max_64_positive_d 0x7fffffffffffffff + #define F_type_size_max_64_unsigned_d 0xffffffffffffffff + + #ifdef __SIZEOF_INT128__ + #define F_type_size_max_128_negative_d 0x800000000000000000000000 + #define F_type_size_max_128_positive_d 0x7fffffffffffffffffffffff + #define F_type_size_max_128_unsigned_d 0xffffffffffffffffffffffff + #else + #define F_type_size_max_128_negative_d F_type_size_max_64_negative_d + #define F_type_size_max_128_positive_d F_type_size_max_64_positive_d + #define F_type_size_max_128_unsigned_d F_type_size_max_64_unsigned_d + #endif // __SIZEOF_INT128__ +#endif // _di_f_type_sizes_d_ + +/** + * Conditional 128-bit support. + * + * This should work in GCC, but other compilers this may not be available. + * When not supported, these will fallback to 64-bit. + */ +#ifndef _di_f_int128_t_ + #ifdef __SIZEOF_INT128__ + typedef __int128_t f_int128_t; + typedef __uint128_t f_uint128_t; + #else + typedef int64_t f_int128_t; + typedef uint64_t f_uint128_t; + #endif // __SIZEOF_INT128__ +#endif // _di_f_int128_t_ + +/** + * Provide a 128-bit type wrapper, which could be either 64-bit or 128-bit depending on support. + * + * This is __int128_t when 128-bit is supported and int64_t when not supported. + * + * This provides the types without the normal "f_" leading prefixes to be more in line with the core types like int64_t. + */ +#ifdef __SIZEOF_INT128__ + #ifndef _di_f_int128_t_ + typedef __int128_t int128_t; + #endif // _di_f_int128_t_ + + #ifndef _di_f_uint128_t_ + typedef __uint128_t uint128_t; + #endif // _di_f_uint128_t_ +#else // __SIZEOF_INT128__ + #ifndef _di_f_int128_t_ + typedef int64_t int128_t; + #endif // _di_f_int128_t_ + + #ifndef _di_f_uint128_t_ + typedef uint64_t uint128_t; + #endif // _di_f_uint128_t_ +#endif // __SIZEOF_INT128__ + +/** + * Custom data type to be used throughout the project to represent general numbers. + * + * This is intended to be used in buffers, such as strings, and in argument parameters. + * + * Provides additional custom types so that it can be more easily be overwritten. + * Specifically, there is support for using 32-bit, 64-bit, or 128-bit lengths. + * + * 64-bit is the designed default. + */ +#ifndef _di_f_type_number_64_t_ + typedef int64_t f_number_signed_t; + typedef uint64_t f_number_unsigned_t; + + #define f_number_signed_t_initialize 0 + #define f_number_unsigned_t_initialize 0 + + #define F_number_t_size_unsigned_d F_type_size_64_unsigned_d + #define F_number_t_size_positive_d F_type_size_64_positive_d + #define F_number_t_size_negative_d F_type_size_64_negative_d + + #define F_number_t_size_max_unsigned_d F_type_size_max_64_unsigned_d + #define F_number_t_size_max_positive_d F_type_size_max_64_positive_d + #define F_number_t_size_max_negative_d F_type_size_max_64_negative_d +#elif defined(_en_f_type_number_32_t_) + typedef int32_t f_number_signed_t; + typedef uint32_t f_number_unsigned_t; + + #define f_number_signed_t_initialize 0 + #define f_number_unsigned_t_initialize 0 + + #define F_number_t_size_unsigned_d F_type_size_32_unsigned_d + #define F_number_t_size_positive_d F_type_size_32_positive_d + #define F_number_t_size_negative_d F_type_size_32_negative_d + + #define F_number_t_size_max_unsigned_d F_type_size_max_32_unsigned_d + #define F_number_t_size_max_positive_d F_type_size_max_32_positive_d + #define F_number_t_size_max_negative_d F_type_size_max_32_negative_d +#elif defined(_en_f_type_number_128_t_) + typedef f_int128_t f_number_signed_t; + typedef f_uint128_t f_number_unsigned_t; + + #define f_number_signed_t_initialize 0 + #define f_number_unsigned_t_initialize 0 + + #define F_number_t_size_unsigned_d F_type_size_128_unsigned_d + #define F_number_t_size_positive_d F_type_size_128_positive_d + #define F_number_t_size_negative_d F_type_size_128_negative_d + + #define F_number_t_size_max_unsigned_d F_type_size_max_128_unsigned_d + #define F_number_t_size_max_positive_d F_type_size_max_128_positive_d + #define F_number_t_size_max_negative_d F_type_size_max_128_negative_d +#endif // _en_f_type_number_128_t_ + +/** + * An array of array lengths. + * + * The macros are defined in type_array.h or type_array-common.h. + * + * Properties: + * - array: An array of array lengths. + * - size: Total amount of allocated space. + * - used: Total number of allocated spaces used. + */ +#ifndef _di_f_number_signeds_t_ + typedef struct { + f_number_signed_t *array; + + f_number_unsigned_t size; + f_number_unsigned_t used; + } f_number_signeds_t; + + #define f_number_signeds_t_initialize { 0, 0, 0 } + + #define macro_f_number_signeds_t_initialize_1(array, size, used) { array, size, used } + #define macro_f_number_signeds_t_initialize_2(array, length) { array, length, length } +#endif // _di_f_number_signeds_t_ + +/** + * An array of an array of array lengths. + * + * The macros are defined in type_array.h or type_array-common.h. + * + * Properties: + * - array: The array of an array of array lengths. + * - size: Total amount of allocated space. + * - used: Total number of allocated spaces used. + */ +#ifndef _di_f_number_signedss_t_ + typedef struct { + f_number_signeds_t *array; + + f_number_unsigned_t size; + f_number_unsigned_t used; + } f_number_signedss_t; + + #define f_number_signedss_t_initialize { 0, 0, 0 } + + #define macro_f_number_signedss_t_initialize_1(array, size, used) { array, size, used } + #define macro_f_number_signedss_t_initialize_2(array, length) { array, length, length } +#endif // _di_f_number_signedss_t_ + +/** + * An array of array lengths. + * + * The macros are defined in type_array.h or type_array-common.h. + * + * Properties: + * - array: An array of array lengths. + * - size: Total amount of allocated space. + * - used: Total number of allocated spaces used. + */ +#ifndef _di_f_number_unsigneds_t_ + typedef struct { + f_number_unsigned_t *array; + + f_number_unsigned_t size; + f_number_unsigned_t used; + } f_number_unsigneds_t; + + #define f_number_unsigneds_t_initialize { 0, 0, 0 } + + #define macro_f_number_unsigneds_t_initialize_1(array, size, used) { array, size, used } + #define macro_f_number_unsigneds_t_initialize_2(array, length) { array, length, length } +#endif // _di_f_number_unsigneds_t_ + +/** + * An array of an array of array lengths. + * + * The macros are defined in type_array.h or type_array-common.h. + * + * Properties: + * - array: The array of an array of array lengths. + * - size: Total amount of allocated space. + * - used: Total number of allocated spaces used. + */ +#ifndef _di_f_number_unsignedss_t_ + typedef struct { + f_number_unsigneds_t *array; + + f_number_unsigned_t size; + f_number_unsigned_t used; + } f_number_unsignedss_t; + + #define f_number_unsignedss_t_initialize { 0, 0, 0 } + + #define macro_f_number_unsignedss_t_initialize_1(array, size, used) { array, size, used } + #define macro_f_number_unsignedss_t_initialize_2(array, length) { array, length, length } +#endif // _di_f_number_unsignedss_t_ + +/** + * An array of array int8_t. + * + * The macros are defined in type_array.h or type_array-common.h. + * + * Properties: + * - array: An array of int8_t. + * - size: Total amount of allocated space. + * - used: Total number of allocated spaces used. + */ +#ifndef _di_f_int8s_t_ + typedef struct { + int8_t *array; + + f_number_unsigned_t size; + f_number_unsigned_t used; + } f_int8s_t; + + #define f_int8s_t_initialize { 0, 0, 0 } + + #define macro_f_int8s_t_initialize_1(array, size, used) { array, size, used } + #define macro_f_int8s_t_initialize_2(array, length) { array, length, length } +#endif // _di_f_int8s_t_ + +/** + * An array of an array of array int8_t. + * + * The macros are defined in type_array.h or type_array-common.h. + * + * Properties: + * - array: The array of an array of array int8_t. + * - size: Total amount of allocated space. + * - used: Total number of allocated spaces used. + */ +#ifndef _di_f_int8ss_t_ + typedef struct { + f_int8s_t *array; + + f_number_unsigned_t size; + f_number_unsigned_t used; + } f_int8ss_t; + + #define f_int8ss_t_initialize { 0, 0, 0 } + + #define macro_f_int8ss_t_initialize_1(array, size, used) { array, size, used } + #define macro_f_int8ss_t_initialize_2(array, length) { array, length, length } +#endif // _di_f_int8ss_t_ + +/** + * An array of array uint8_t. + * + * The macros are defined in type_array.h or type_array-common.h. + * + * Properties: + * - array: An array of uint8_t. + * - size: Total amount of allocated space. + * - used: Total number of allocated spaces used. + */ +#ifndef _di_f_uint8s_t_ + typedef struct { + uint8_t *array; + + f_number_unsigned_t size; + f_number_unsigned_t used; + } f_uint8s_t; + + #define f_uint8s_t_initialize { 0, 0, 0 } + + #define macro_f_uint8s_t_initialize_1(array, size, used) { array, size, used } + #define macro_f_uint8s_t_initialize_2(array, length) { array, length, length } +#endif // _di_f_uint8s_t_ + +/** + * An array of an array of array uint8_t. + * + * The macros are defined in type_array.h or type_array-common.h. + * + * Properties: + * - array: The array of an array of array uint8_t. + * - size: Total amount of allocated space. + * - used: Total number of allocated spaces used. + */ +#ifndef _di_f_uint8ss_t_ + typedef struct { + f_uint8s_t *array; + + f_number_unsigned_t size; + f_number_unsigned_t used; + } f_uint8ss_t; + + #define f_uint8ss_t_initialize { 0, 0, 0 } + + #define macro_f_uint8ss_t_initialize_1(array, size, used) { array, size, used } + #define macro_f_uint8ss_t_initialize_2(array, length) { array, length, length } +#endif // _di_f_uint8ss_t_ + +/** + * An array of array int16_t. + * + * The macros are defined in type_array.h or type_array-common.h. + * + * Properties: + * - array: An array of int16_t. + * - size: Total amount of allocated space. + * - used: Total number of allocated spaces used. + */ +#ifndef _di_f_int16s_t_ + typedef struct { + int16_t *array; + + f_number_unsigned_t size; + f_number_unsigned_t used; + } f_int16s_t; + + #define f_int16s_t_initialize { 0, 0, 0 } + + #define macro_f_int16s_t_initialize_1(array, size, used) { array, size, used } + #define macro_f_int16s_t_initialize_2(array, length) { array, length, length } +#endif // _di_f_int16s_t_ + +/** + * An array of an array of array int16_t. + * + * The macros are defined in type_array.h or type_array-common.h. + * + * Properties: + * - array: The array of an array of array int16_t. + * - size: Total amount of allocated space. + * - used: Total number of allocated spaces used. + */ +#ifndef _di_f_int16ss_t_ + typedef struct { + f_int16s_t *array; + + f_number_unsigned_t size; + f_number_unsigned_t used; + } f_int16ss_t; + + #define f_int16ss_t_initialize { 0, 0, 0 } + + #define macro_f_int16ss_t_initialize_1(array, size, used) { array, size, used } + #define macro_f_int16ss_t_initialize_2(array, length) { array, length, length } +#endif // _di_f_int16ss_t_ + +/** + * An array of array uint16_t. + * + * The macros are defined in type_array.h or type_array-common.h. + * + * Properties: + * - array: An array of uint16_t. + * - size: Total amount of allocated space. + * - used: Total number of allocated spaces used. + */ +#ifndef _di_f_uint16s_t_ + typedef struct { + uint16_t *array; + + f_number_unsigned_t size; + f_number_unsigned_t used; + } f_uint16s_t; + + #define f_uint16s_t_initialize { 0, 0, 0 } + + #define macro_f_uint16s_t_initialize_1(array, size, used) { array, size, used } + #define macro_f_uint16s_t_initialize_2(array, length) { array, length, length } +#endif // _di_f_uint16s_t_ + +/** + * An array of an array of array uint16_t. + * + * The macros are defined in type_array.h or type_array-common.h. + * + * Properties: + * - array: The array of an array of array uint16_t. + * - size: Total amount of allocated space. + * - used: Total number of allocated spaces used. + */ +#ifndef _di_f_uint16ss_t_ + typedef struct { + f_uint16s_t *array; + + f_number_unsigned_t size; + f_number_unsigned_t used; + } f_uint16ss_t; + + #define f_uint16ss_t_initialize { 0, 0, 0 } + + #define macro_f_uint16s_t_initialize_1(array, size, used) { array, size, used } + #define macro_f_uint16s_t_initialize_2(array, length) { array, length, length } +#endif // _di_f_uint16ss_t_ + +/** + * An array of array int32_t. + * + * The macros are defined in type_array.h or type_array-common.h. + * + * Properties: + * - array: An array of int32_t. + * - size: Total amount of allocated space. + * - used: Total number of allocated spaces used. + */ +#ifndef _di_f_int32s_t_ + typedef struct { + int32_t *array; + + f_number_unsigned_t size; + f_number_unsigned_t used; + } f_int32s_t; + + #define f_int32s_t_initialize { 0, 0, 0 } + + #define macro_f_int32s_t_initialize_1(array, size, used) { array, size, used } + #define macro_f_int32s_t_initialize_2(array, length) { array, length, length } +#endif // _di_f_int32s_t_ + +/** + * An array of an array of array int32_t. + * + * The macros are defined in type_array.h or type_array-common.h. + * + * Properties: + * - array: The array of an array of array int32_t. + * - size: Total amount of allocated space. + * - used: Total number of allocated spaces used. + */ +#ifndef _di_f_int32ss_t_ + typedef struct { + f_int32s_t *array; + + f_number_unsigned_t size; + f_number_unsigned_t used; + } f_int32ss_t; + + #define f_int32ss_t_initialize { 0, 0, 0 } + + #define macro_f_int32ss_t_initialize_1(array, size, used) { array, size, used } + #define macro_f_int32ss_t_initialize_2(array, length) { array, length, length } +#endif // _di_f_int32ss_t_ + +/** + * An array of array uint32_t. + * + * The macros are defined in type_array.h or type_array-common.h. + * + * Properties: + * - array: An array of uint32_t. + * - size: Total amount of allocated space. + * - used: Total number of allocated spaces used. + */ +#ifndef _di_f_uint32s_t_ + typedef struct { + uint32_t *array; + + f_number_unsigned_t size; + f_number_unsigned_t used; + } f_uint32s_t; + + #define f_uint32s_t_initialize { 0, 0, 0 } + + #define macro_f_uint32s_t_initialize_1(array, size, used) { array, size, used } + #define macro_f_uint32s_t_initialize_2(array, length) { array, length, length } +#endif // _di_f_uint32s_t_ + +/** + * An array of an array of array uint32_t. + * + * The macros are defined in type_array.h or type_array-common.h. + * + * Properties: + * - array: The array of an array of array uint32_t. + * - size: Total amount of allocated space. + * - used: Total number of allocated spaces used. + */ +#ifndef _di_f_uint32ss_t_ + typedef struct { + f_uint32s_t *array; + + f_number_unsigned_t size; + f_number_unsigned_t used; + } f_uint32ss_t; + + #define f_uint32ss_t_initialize { 0, 0, 0 } + + #define macro_f_uint32ss_t_initialize_1(array, size, used) { array, size, used } + #define macro_f_uint32ss_t_initialize_2(array, length) { array, length, length } +#endif // _di_f_uint32ss_t_ + +/** + * An array of array int64_t. + * + * The macros are defined in type_array.h or type_array-common.h. + * + * Properties: + * - array: An array of int64_t. + * - size: Total amount of allocated space. + * - used: Total number of allocated spaces used. + */ +#ifndef _di_f_int64s_t_ + typedef struct { + int64_t *array; + + f_number_unsigned_t size; + f_number_unsigned_t used; + } f_int64s_t; + + #define f_int64s_t_initialize { 0, 0, 0 } + + #define macro_f_int64s_t_initialize_1(array, size, used) { array, size, used } + #define macro_f_int64s_t_initialize_2(array, length) { array, length, length } +#endif // _di_f_int64s_t_ + +/** + * An array of an array of array int64_t. + * + * The macros are defined in type_array.h or type_array-common.h. + * + * Properties: + * - array: The array of an array of array int64_t. + * - size: Total amount of allocated space. + * - used: Total number of allocated spaces used. + */ +#ifndef _di_f_int64ss_t_ + typedef struct { + f_int64s_t *array; + + f_number_unsigned_t size; + f_number_unsigned_t used; + } f_int64ss_t; + + #define f_int64ss_t_initialize { 0, 0, 0 } + + #define macro_f_int64ss_t_initialize_1(array, size, used) { array, size, used } + #define macro_f_int64ss_t_initialize_2(array, length) { array, length, length } +#endif // _di_f_int64ss_t_ + +/** + * An array of array uint64_t. + * + * The macros are defined in type_array.h or type_array-common.h. + * + * Properties: + * - array: An array of uint64_t. + * - size: Total amount of allocated space. + * - used: Total number of allocated spaces used. + */ +#ifndef _di_f_uint64s_t_ + typedef struct { + uint64_t *array; + + f_number_unsigned_t size; + f_number_unsigned_t used; + } f_uint64s_t; + + #define f_uint64s_t_initialize { 0, 0, 0 } + + #define macro_f_uint64s_t_initialize_1(array, size, used) { array, size, used } + #define macro_f_uint64s_t_initialize_2(array, length) { array, length, length } +#endif // _di_f_uint64s_t_ + +/** + * An array of an array of array uint64_t. + * + * The macros are defined in type_array.h or type_array-common.h. + * + * Properties: + * - array: The array of an array of array uint64_t. + * - size: Total amount of allocated space. + * - used: Total number of allocated spaces used. + */ +#ifndef _di_f_uint64ss_t_ + typedef struct { + f_uint64s_t *array; + + f_number_unsigned_t size; + f_number_unsigned_t used; + } f_uint64ss_t; + + #define f_uint64ss_t_initialize { 0, 0, 0 } + + #define macro_f_uint64ss_t_initialize_1(array, size, used) { array, size, used } + #define macro_f_uint64ss_t_initialize_2(array, length) { array, length, length } +#endif // _di_f_uint64ss_t_ + +/** + * An array of int128_t. + * + * The macros are defined in type_array.h or type_array-common.h. + * + * Properties: + * - array: The array of int128_t. + * - size: Total amount of allocated space. + * - used: Total number of allocated spaces used. + */ +#ifndef _di_f_int128s_t_ + typedef struct { + int128_t *array; + + f_number_unsigned_t size; + f_number_unsigned_t used; + } f_int128s_t; + + #define f_int128s_t_initialize { 0, 0, 0 } + + #define macro_f_int128s_t_initialize_1(array, size, used) { array, size, used } + #define macro_f_int128s_t_initialize_2(array, length) { array, length, length } +#endif // _di_f_int128s_t_ + +/** + * An array of and array of int128_t. + * + * The macros are defined in type_array.h or type_array-common.h. + * + * Properties: + * - array: The array of and array of int128_t. + * - size: Total amount of allocated space. + * - used: Total number of allocated spaces used. + */ +#ifndef _di_f_int128ss_t_ + typedef struct { + f_int128s_t *array; + + f_number_unsigned_t size; + f_number_unsigned_t used; + } f_int128ss_t; + + #define f_int128ss_t_initialize { 0, 0, 0 } + + #define macro_f_int128ss_t_initialize_1(array, size, used) { array, size, used } + #define macro_f_int128ss_t_initialize_2(array, length) { array, length, length } +#endif // _di_f_int128ss_t_ + +/** + * An array of uint128_t. + * + * The macros are defined in type_array.h or type_array-common.h. + * + * Properties: + * - array: The array of uint128_t. + * - size: Total amount of allocated space. + * - used: Total number of allocated spaces used. + */ +#ifndef _di_f_uint128s_t_ + typedef struct { + uint128_t *array; + + f_number_unsigned_t size; + f_number_unsigned_t used; + } f_uint128s_t; + + #define f_uint128s_t_initialize { 0, 0, 0 } + + #define macro_f_uint128s_t_initialize_1(array, size, used) { array, size, used } + #define macro_f_uint128s_t_initialize_2(array, length) { array, length, length } +#endif // _di_f_uint128s_t_ + +/** + * An array of and array of uint128_t. + * + * The macros are defined in type_array.h or type_array-common.h. + * + * Properties: + * - array: The array of and array of uint128_t. + * - size: Total amount of allocated space. + * - used: Total number of allocated spaces used. + */ +#ifndef _di_f_uint128ss_t_ + typedef struct { + f_uint128s_t *array; + + f_number_unsigned_t size; + f_number_unsigned_t used; + } f_uint128ss_t; + + #define f_uint128ss_t_initialize { 0, 0, 0 } + + #define macro_f_uint128ss_t_initialize_1(array, size, used) { array, size, used } + #define macro_f_uint128ss_t_initialize_2(array, length) { array, length, length } +#endif // _di_f_uint128ss_t_ + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _F_type_number_h diff --git a/level_0/f_type/c/type/state.h b/level_0/f_type/c/type/state.h new file mode 100644 index 0000000..311516e --- /dev/null +++ b/level_0/f_type/c/type/state.h @@ -0,0 +1,174 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Defines state type data. + * + * This is auto-included by type.h and should not need to be explicitly included. + */ +#ifndef _F_type_state_h +#define _F_type_state_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * A representation of a state to be shared between different levels for some function. + * + * This is used to provide advanced controls on different levels of the project to something outside. + * + * The allocate provides an allocation step so that the caller can determine a better performing allocation step for their purpose. + * For example, if the caller knows that they need to allocate a hundred megabytes of data of which is separated into blocks of 8k, then allocate could be set to 8192. + * + * There are two standard callbacks that are expected to be commonly available: interrupt() and handle(). + * Additional callbacks are stored in the structure "callbacks" as defined by the class requiring the use of this structure (f_state_t). + * + * All state values may be NULL, in which case they are to be ignored. + * + * The general interpretation of the state.status results of interrupt() or any of the functions should have an error bit to designate an error and not an error bit to designate not an error. + * In the case of interrupt(), the F_interrupt and F_interrupt_not must be returned as appropriate and if not an error (the F_interrupt and F_interrupt_not may have an error bit). + * To keep the logic simple, it is recommended that F_interrupt always be returned with the error bit set. + * + * The general interpretation of handle() is to either print an error message or to perform additional tasks when an error occurs (such as saving state data for use at a higher level). + * This allows for the error to be processed with all relevant data before the function returns. + * + * These two callbacks (handle() and interrupt()) accept the following parameters: + * - state: The state data. Must be of type f_state_t. Must not be NULL. + * - internal: Additional data passed by the function being called, often containing internal data to the called function. May be NULL. + * + * The "custom" property on f_state_t is intended to be used so that the callback, such as the interrupt(), can make changes to something within the scope of the parent. + * + * For example: + * There exists some project "bob" with some functions "bob_does()" and "bob_interrupts()". + * The function "bob_does()" maintains a state (f_state_t) called "bob_state". + * The function "bob_does()" will call "f_talk()" that accepts a state (f_state_t) and defines the data structure type "f_interject_t" to be called interject. + * While "f_talk()" executes, "bob_interrupts()" is periodically with the state (f_state_t) "bob_state" as the first parameter and the data structure (f_interject_t) "interject" as the second parameter. + * If Bob interjects the talk, then bob_interrupts() would set state.status to F_interrupt. + * If Bob does not interject the talk, then bob_interrupts() would set state.status to F_interrupt_not. + * This response is handled within f_talk(). + * The f_talk() function will then set the state.status when done and might immediately set state.status to F_interrupt (with error bit) if bob_interrupts() returns F_interrupt (with/without error bit). + * + * Properties: + * - step_large: The allocation step to use for large buffers. + * - step_small: The allocation step to use for small buffers. + * - flag: A 64-bit digit intended for provided flags that are defined by the function. + * - code: A 64-bit digit intended for provided flags that are defined by the caller. + * - status: The status used while processing (This should hold the error passed to the handle callback and should be updated as necessary). + * - handle: A function to call on a specific error (allowing for the error to be handled before function returns). May be NULL. + * - interrupt: A function to call for checking to see if an interrupt is to be called. May be NULL. + * - callbacks: A structure (defined by function/project using this) of additional functions to call. May be NULL. + * - custom: A structure (defined by caller/parent) for holding custom data to be passed along to the interrupt() or one of the functions. May be NULL. + * - data: A structure (defined by function) for holding data relevant to the function. May be NULL. May be required. + */ +#ifndef _di_f_state_t_ + typedef struct { + uint16_t step_large; + uint16_t step_small; + f_status_t status; + uint64_t flag; + uint64_t code; + + void (*handle)(void * const state, void * const internal); + void (*interrupt)(void * const state, void * const internal); + + void *callbacks; + void *custom; + void *data; + } f_state_t; + + #define f_state_t_initialize { \ + F_memory_default_allocation_large_d, \ + F_memory_default_allocation_small_d, \ + F_okay, \ + 0, \ + 0, \ + 0, \ + 0, \ + 0, \ + 0, \ + 0, \ + } + + #define macro_f_state_t_initialize_1(step_large, step_small, status, flag, code, handle, interrupt, callbacks, custom, data) { \ + step_large, \ + step_small, \ + status, \ + flag, \ + code, \ + handle, \ + interrupt, \ + callbacks, \ + custom, \ + data, \ + } + + #define macro_f_state_t_clear(state) \ + state.step_large = 0; \ + state.step_small = 0; \ + state.status = F_okay; \ + state.flag = 0; \ + state.code = 0; \ + state.handle = 0; \ + state.interrupt = 0; \ + state.callbacks = 0; \ + state.custom = 0; \ + state.data = 0; +#endif // _di_f_state_t_ + +/** + * This holds an array of f_state_t. + * + * The macros are defined in type_array.h or type_array-common.h. + * + * Properties: + * - array: The array of f_state_t arrays. + * - size: Total amount of allocated space. + * - used: Total number of allocated spaces used. + */ +#ifndef _di_f_states_t_ + typedef struct { + f_state_t *array; + + f_number_unsigned_t size; + f_number_unsigned_t used; + } f_states_t; + + #define f_states_t_initialize { 0, 0, 0 } + + #define macro_f_states_t_initialize_1(array, size, used) { array, size, used } + #define macro_f_states_t_initialize_2(array, length) { array, length, length } +#endif // _di_f_states_t_ + +/** + * This holds an array of f_states_t. + * + * The macros are defined in type_array.h or type_array-common.h. + * + * Properties: + * - array: The array of f_state_t arrays. + * - size: Total amount of allocated space. + * - used: Total number of allocated spaces used. + */ +#ifndef _di_f_statess_t_ + typedef struct { + f_states_t *array; + + f_number_unsigned_t size; + f_number_unsigned_t used; + } f_statess_t; + + #define f_statess_t_initialize { 0, 0, 0 } + + #define macro_f_statess_t_initialize_1(array, size, used) { array, size, used } + #define macro_f_statess_t_initialize_2(array, length) { array, length, length } +#endif // _di_f_statess_t_ + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _F_type_state_h diff --git a/level_0/f_type/c/type/status.h b/level_0/f_type/c/type/status.h new file mode 100644 index 0000000..ea92bbf --- /dev/null +++ b/level_0/f_type/c/type/status.h @@ -0,0 +1,80 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Defines status type data. + * + * This is auto-included by type.h and should not need to be explicitly included. + */ +#ifndef _F_type_status_h +#define _F_type_status_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * A status intended to be used as the return value status of some function or operation. + */ +#ifndef _di_f_status_t_ + typedef uint16_t f_status_t; + + #define f_status_t_initialize F_okay +#endif // _di_f_status_t_ + +/** + * This holds an array of f_status_t. + * + * The macros are defined in type_array.h or type_array-common.h. + * + * Properties: + * - array: The array of f_status_t arrays. + * - size: Total amount of allocated space. + * - used: Total number of allocated spaces used. + */ +#ifndef _di_f_statuss_t_ + typedef struct { + f_status_t *array; + + f_number_unsigned_t size; + f_number_unsigned_t used; + } f_statuss_t; + + #define f_statuss_t_initialize { 0, 0, 0 } + + #define macro_f_statuss_t_initialize_1(array, size, used) { array, size, used } + #define macro_f_statuss_t_initialize_2(array, length) { array, length, length } +#endif // _di_f_statuss_t_ + +/** + * This holds an array of f_statuss_t. + * + * The macros are defined in type_array.h or type_array-common.h. + * + * Properties: + * - array: The array of f_status_t arrays. + * - size: Total amount of allocated space. + * - used: Total number of allocated spaces used. + */ +#ifndef _di_f_statusss_t_ + typedef struct { + f_statuss_t *array; + + f_number_unsigned_t size; + f_number_unsigned_t used; + } f_statusss_t; + + #define f_statusss_t_initialize { 0, 0, 0 } + + #define macro_f_statusss_t_initialize_1(array, size, used) { array, size, used } + #define macro_f_statusss_t_initialize_2(array, length) { array, length, length } +#endif // _di_f_statusss_t_ + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _F_type_status_h diff --git a/level_0/f_type/c/type/time.h b/level_0/f_type/c/type/time.h new file mode 100644 index 0000000..0d91f1e --- /dev/null +++ b/level_0/f_type/c/type/time.h @@ -0,0 +1,130 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Defines time type data. + * + * This is auto-included by type.h and should not need to be explicitly included. + */ +#ifndef _F_type_time_h +#define _F_type_time_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Hold a unit of Time. + * + * This is intended to be utilized for the unit of measurement called a "Time", represented with uppercase "T". + * For comparison, a unit of Time is equivalent to a nanosecond, or 10^-9 seconds. + * + * A unit of Time is intended to represent some unit of Time such that a single 64-bit integer may hold all units of Time for a single calendar year. + * This unit of Time does not and must not include Years (unlike Unixtime). + * + * A MegaTime (MT) is therefore equivalent to a millisecond such that a millisecond is 10^-3 seconds. + * + * To convert from Time to Unixtime, one must have a year (which could be assumed to be the current year) and then calculate all of those calendar od + * + * A unit of Time by default is assumed to be in UTC. + * 1 (Earth) year ~= 31536000000000000 Time or 31536000 GT (GigaTime). + * 1 (Earth) day = 86400000000000 Time or 86400 GT (GigaTime). + * 1 (Earth) hour = 3600000000000 Time or 3600 GT (GigaTime). + * 1 (Earth) minute = 60000000000 Time or 60 GT (GigaTime). + * 1 (Earth) second = 1000000000 Time or 1 GT (GigaTime). + * + * Consequentially, 1 day in units of Time is easily represented as 86.4 TT (TeraTime). + * + * This is not time_t, which is a different structure that may not be uint64_t and is often signed. + */ +#ifndef _di_f_time_t_ + typedef uint64_t f_time_t; + + #define f_time_t_initialize 0 +#endif // _di_f_time_t_ + +/** + * A non-kernel dependent alternative version of "struct timespec". + * + * This is may not compatible with struct timespec because seconds is time_t and that may not be a uint64_t. + * In many cases of "struct timespec", seconds is signed because time_t is signed. + * + * Properties: + * - seconds: The total number of seconds. + * - seconds_nano: The total number of nanoseconds. + */ +#ifndef _di_f_time_spec_t_ + typedef struct { + f_time_t seconds; + f_time_t seconds_nano; + } f_time_spec_t; + + #define f_time_spec_t_initialize { f_time_t_initialize, f_time_t_initialize } + + #define macro_f_time_spec_t_clear(spec) \ + spec.seconds = 0; \ + spec.seconds_nano = 0; +#endif // _di_f_time_spec_t_ + +/** + * Hold a unit of Time along with a year to represent a date. + * + * This implementation of a date using the unit of Time is limited on the size of the year. + * The value for year is expected to be a signed number. + * For anything that needs a larger (or smaller) year, create a new type or use the "year string format" of Time. + * + * In "year string format" of Time, a Year may be prepended to the Time followed by a single colon ':' to associate a year with the Time. + * This Year has no minimum or maximum but may not have decimals. + * + * For example, "2020:86400000000000" would represent: January 02, 2020 0:00 UTC. + * For example, "2020:86.4 TT" would represent: January 02, 2020 0:00 UTC. + * + * Properties: + * - year: A number representing the year. + * - time: A number representing the time. + */ +#ifndef _di_f_date_t_ + typedef struct { + f_number_signed_t year; + f_time_t time; + } f_date_t; + + #define f_date_t_initialize { 0, 0 } + + #define macro_f_date_t_clear(date) \ + date.year = 0; \ + date.time = 0; +#endif // _di_f_date_t_ + +/** + * A variation of f_date_t that using f_time_spec_t rather than f_time_t. + * + * This can is a more precise alternative to f_date_t because it stores nanoseconds. + * + * The f_time_spec_t.time.seconds can be directly cast to the f_date_t.time. + * + * Properties: + * - year: A number representing the year. + * - time: A number representing the time with seconds and nanoseconds. + */ +#ifndef _di_f_date_spec_t_ + typedef struct { + f_time_t year; + f_time_spec_t time; + } f_date_spec_t; + + #define f_date_spec_t_initialize { f_time_t_initialize, macro_f_time_spec_t_clear } + + #define macro_f_date_spec_t_clear(date) \ + date.year = 0; \ + macro_f_time_spec_t_clear(date.time); +#endif // _di_f_date_spec_t_ + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _F_type_time_h diff --git a/level_0/f_type/data/build/settings b/level_0/f_type/data/build/settings index cc801ba..9ea0f6b 100644 --- a/level_0/f_type/data/build/settings +++ b/level_0/f_type/data/build/settings @@ -31,7 +31,7 @@ build_language c build_libraries -lc -build_sources_headers type.h type_file.h +build_sources_headers type.h type/cell.h type/file.h type/fll.h type/mode.h type/number.h type/state.h type/status.h type/time.h build_script yes build_shared yes diff --git a/level_0/f_type_array/c/type_array.h b/level_0/f_type_array/c/type_array.h index b0b709e..57bf168 100644 --- a/level_0/f_type_array/c/type_array.h +++ b/level_0/f_type_array/c/type_array.h @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include diff --git a/level_0/f_type_array/c/type_array/number_signed.c b/level_0/f_type_array/c/type_array/number_signed.c new file mode 100644 index 0000000..d09ac6b --- /dev/null +++ b/level_0/f_type_array/c/type_array/number_signed.c @@ -0,0 +1,50 @@ +#include "../type_array.h" +#include "number_signed.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _di_f_number_signedss_delete_callback_ + f_status_t f_number_signedss_delete_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const void_array) { + + { + f_number_signeds_t * const array = (f_number_signeds_t *) void_array; + f_status_t status = F_okay; + + for (f_number_unsigned_t i = start; i < stop; ++i) { + + if (array[i].size && array[i].array) { + status = f_memory_array_resize(0, sizeof(f_number_signed_t), (void **) &array[i].array, &array[i].used, &array[i].size); + if (F_status_is_error(status)) return status; + } + } // for + } + + return F_okay; + } +#endif // _di_f_number_signedss_delete_callback_ + +#ifndef _di_f_number_signedss_destroy_callback_ + f_status_t f_number_signedss_destroy_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const void_array) { + + { + f_number_signeds_t * const array = (f_number_signeds_t *) void_array; + f_status_t status = F_okay; + + for (f_number_unsigned_t i = start; i < stop; ++i) { + + if (array[i].size && array[i].array) { + status = f_memory_array_adjust(0, sizeof(f_number_signed_t), (void **) &array[i].array, &array[i].used, &array[i].size); + if (F_status_is_error(status)) return status; + } + } // for + } + + return F_okay; + } +#endif // _di_f_number_signedss_destroy_callback_ + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_type_array/c/type_array/number_signed.h b/level_0/f_type_array/c/type_array/number_signed.h new file mode 100644 index 0000000..237f2c6 --- /dev/null +++ b/level_0/f_type_array/c/type_array/number_signed.h @@ -0,0 +1,81 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Defines data to be used for/by type (array) related functionality. + * + * This is auto-included by type_array.h and should not need to be explicitly included. + */ +#ifndef _F_type_array_number_signed_h +#define _F_type_array_number_signed_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * A callback intended to be passed to f_memory_arrays_resize() for an f_number_signedss_t structure. + * + * This is only called when shrinking the array and generally should perform deallocations. + * + * This does not do parameter checking. + * + * @param start + * The inclusive start position in the array to start deleting. + * @param stop + * The exclusive stop position in the array to stop deleting. + * @param array + * The array structure to delete all values of. + * Must not be NULL. + * + * @return + * F_okay on success. + * + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_array_resize(). + * + * @see f_memory_array_resize() + * @see f_memory_arrays_resize() + */ +#ifndef _di_f_number_signedss_delete_callback_ + extern f_status_t f_number_signedss_delete_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const array); +#endif // _di_f_number_signedss_delete_callback_ + +/** + * A callback intended to be passed to f_memory_arrays_adjust() for an f_number_signedss_t structure. + * + * This is only called when shrinking the array and generally should perform deallocations. + * + * This does not do parameter checking. + * + * @param start + * The inclusive start position in the array to start deleting. + * @param stop + * The exclusive stop position in the array to stop deleting. + * @param array + * The array structure to delete all values of. + * Must not be NULL. + * + * @return + * F_okay on success. + * + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_array_adjust(). + * + * @see f_memory_array_adjust() + * @see f_memory_arrays_adjust() + */ +#ifndef _di_f_number_signedss_destroy_callback_ + extern f_status_t f_number_signedss_destroy_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const array); +#endif // _di_f_number_signedss_destroy_callback_ + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _F_type_array_number_signed_h diff --git a/level_0/f_type_array/c/type_array_file.h b/level_0/f_type_array/c/type_array_file.h index df38550..435abf7 100644 --- a/level_0/f_type_array/c/type_array_file.h +++ b/level_0/f_type_array/c/type_array_file.h @@ -10,7 +10,7 @@ // FLL-0 includes. #include -#include +#include #include // FLL-0 type_array includes. diff --git a/level_0/f_type_array/data/build/settings b/level_0/f_type_array/data/build/settings index 47f7c15..aa3bf69 100644 --- a/level_0/f_type_array/data/build/settings +++ b/level_0/f_type_array/data/build/settings @@ -32,9 +32,9 @@ build_language c build_libraries -lc build_libraries-individual -lf_memory -build_sources_library type_array/cell.c type_array/file.c type_array/fll_id.c type_array/int8.c type_array/int16.c type_array/int32.c type_array/int64.c type_array/int128.c type_array/number_unsigned.c type_array/poll.c type_array/state.c type_array/status.c type_array/uint8.c type_array/uint16.c type_array/uint32.c type_array/uint64.c type_array/uint128.c +build_sources_library type_array/cell.c type_array/file.c type_array/fll_id.c type_array/int8.c type_array/int16.c type_array/int32.c type_array/int64.c type_array/int128.c type_array/number_signed.c type_array/number_unsigned.c type_array/poll.c type_array/state.c type_array/status.c type_array/uint8.c type_array/uint16.c type_array/uint32.c type_array/uint64.c type_array/uint128.c -build_sources_headers type_array.h type_array_file.h type_array/common.h type_array/cell.h type_array/file.h type_array/fll_id.h type_array/int8.h type_array/int16.h type_array/int32.h type_array/int64.h type_array/int128.h type_array/number_unsigned.h type_array/poll.h type_array/state.h type_array/status.h type_array/uint8.h type_array/uint16.h type_array/uint32.h type_array/uint64.h type_array/uint128.h +build_sources_headers type_array.h type_array_file.h type_array/common.h type_array/cell.h type_array/file.h type_array/fll_id.h type_array/int8.h type_array/int16.h type_array/int32.h type_array/int64.h type_array/int128.h type_array/number_signed.h type_array/number_unsigned.h type_array/poll.h type_array/state.h type_array/status.h type_array/uint8.h type_array/uint16.h type_array/uint32.h type_array/uint64.h type_array/uint128.h build_script yes build_shared yes diff --git a/level_0/f_type_array/data/build/settings-mocks b/level_0/f_type_array/data/build/settings-mocks index 53627d5..79faa8d 100644 --- a/level_0/f_type_array/data/build/settings-mocks +++ b/level_0/f_type_array/data/build/settings-mocks @@ -30,10 +30,10 @@ build_language c build_libraries -lc build_libraries-individual -lf_memory -build_sources_library type_array/cell.c type_array/file.c type_array/fll_id.c type_array/int8.c type_array/int16.c type_array/int32.c type_array/int64.c type_array/int128.c type_array/number_unsigned.c type_array/poll.c type_array/state.c type_array/status.c type_array/uint8.c type_array/uint16.c type_array/uint32.c type_array/uint64.c type_array/uint128.c +build_sources_library type_array/cell.c type_array/file.c type_array/fll_id.c type_array/int8.c type_array/int16.c type_array/int32.c type_array/int64.c type_array/int128.c type_array/number_signed.c type_array/number_unsigned.c type_array/poll.c type_array/state.c type_array/status.c type_array/uint8.c type_array/uint16.c type_array/uint32.c type_array/uint64.c type_array/uint128.c build_sources_library ../../tests/unit/c/mock-type_array.c -build_sources_headers type_array.h type_array_file.h type_array/common.h type_array/cell.h type_array/file.h type_array/fll_id.h type_array/int8.h type_array/int16.h type_array/int32.h type_array/int64.h type_array/int128.h type_array/number_unsigned.h type_array/poll.h type_array/state.h type_array/status.h type_array/uint8.h type_array/uint16.h type_array/uint32.h type_array/uint64.h type_array/uint128.h +build_sources_headers type_array.h type_array_file.h type_array/common.h type_array/cell.h type_array/file.h type_array/fll_id.h type_array/int8.h type_array/int16.h type_array/int32.h type_array/int64.h type_array/int128.h type_array/number_signed.h type_array/number_unsigned.h type_array/poll.h type_array/state.h type_array/status.h type_array/uint8.h type_array/uint16.h type_array/uint32.h type_array/uint64.h type_array/uint128.h build_script yes build_shared yes diff --git a/level_0/f_type_array/data/build/settings-tests b/level_0/f_type_array/data/build/settings-tests index d3ad7ba..4eb1824 100644 --- a/level_0/f_type_array/data/build/settings-tests +++ b/level_0/f_type_array/data/build/settings-tests @@ -31,6 +31,7 @@ build_sources_program test-type_array-int16ss_delete_callback.c test-type_array- build_sources_program test-type_array-int32ss_delete_callback.c test-type_array-int32ss_destroy_callback.c build_sources_program test-type_array-int64ss_delete_callback.c test-type_array-int64ss_destroy_callback.c build_sources_program test-type_array-int128ss_delete_callback.c test-type_array-int128ss_destroy_callback.c +build_sources_program test-type_array-number_signedss_delete_callback.c test-type_array-number_signedss_destroy_callback.c build_sources_program test-type_array-number_unsignedss_delete_callback.c test-type_array-number_unsignedss_destroy_callback.c build_sources_program test-type_array-pollss_delete_callback.c test-type_array-pollss_destroy_callback.c build_sources_program test-type_array-statess_delete_callback.c test-type_array-statess_destroy_callback.c diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-number_signedss_delete_callback.c b/level_0/f_type_array/tests/unit/c/test-type_array-number_signedss_delete_callback.c new file mode 100644 index 0000000..76eae24 --- /dev/null +++ b/level_0/f_type_array/tests/unit/c/test-type_array-number_signedss_delete_callback.c @@ -0,0 +1,57 @@ +#include "test-type_array.h" +#include "test-type_array-number_signedss_delete_callback.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_type_array_number_signedss_delete_callback__fails(void **state) { + + mock_unwrap = 0; + mock_unwrap_f_memory = 0; + + f_number_signed_t data = f_number_signed_t_initialize; + f_number_signed_t data_array[] = { data }; + f_number_signeds_t datas = { .array = data_array, .used = 1, .size = 1 }; + f_number_signeds_t datas_array[] = { datas }; + + { + will_return(__wrap_f_memory_array_resize, true); + will_return(__wrap_f_memory_array_resize, F_status_set_error(F_failure)); + + const f_status_t status = f_number_signedss_delete_callback(0, 1, (void *) datas_array); + + assert_int_equal(status, F_status_set_error(F_failure)); + } +} + +void test__f_type_array_number_signedss_delete_callback__works(void **state) { + + mock_unwrap = 1; + mock_unwrap_f_memory = 1; + + const f_number_signed_t length = 1; + + f_number_signedss_t datass = f_number_signedss_t_initialize; + + { + f_status_t status = f_memory_array_resize(length, sizeof(f_number_signeds_t), (void **) &datass.array, &datass.used, &datass.size); + assert_int_equal(status, F_okay); + + status = f_memory_array_resize(1, sizeof(f_number_signed_t), (void **) &datass.array[0].array, &datass.array[0].used, &datass.array[0].size); + assert_int_equal(status, F_okay); + } + + { + const f_status_t status = f_number_signedss_delete_callback(0, length, (void *) datass.array); + + assert_int_equal(status, F_okay); + assert_int_equal(datass.array[0].size, 0); + } + + free((void *) datass.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-number_signedss_delete_callback.h b/level_0/f_type_array/tests/unit/c/test-type_array-number_signedss_delete_callback.h new file mode 100644 index 0000000..06a4386 --- /dev/null +++ b/level_0/f_type_array/tests/unit/c/test-type_array-number_signedss_delete_callback.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_type_array__number_signedss_delete_callback +#define _TEST__F_type_array__number_signedss_delete_callback + +/** + * Test that the function fails. + * + * @see f_number_signedss_delete_callback() + */ +extern void test__f_type_array_number_signedss_delete_callback__fails(void **state); + +/** + * Test that the function works. + * + * @see f_number_signedss_delete_callback() + */ +extern void test__f_type_array_number_signedss_delete_callback__works(void **state); + +#endif // _TEST__F_type_array__number_signedss_delete_callback diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-number_signedss_destroy_callback.c b/level_0/f_type_array/tests/unit/c/test-type_array-number_signedss_destroy_callback.c new file mode 100644 index 0000000..4329145 --- /dev/null +++ b/level_0/f_type_array/tests/unit/c/test-type_array-number_signedss_destroy_callback.c @@ -0,0 +1,57 @@ +#include "test-type_array.h" +#include "test-type_array-number_signedss_destroy_callback.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_type_array_number_signedss_destroy_callback__fails(void **state) { + + mock_unwrap = 0; + mock_unwrap_f_memory = 0; + + f_number_signed_t data = f_number_signed_t_initialize; + f_number_signed_t data_array[] = { data }; + f_number_signeds_t datas = { .array = data_array, .used = 1, .size = 1 }; + f_number_signeds_t datas_array[] = { datas }; + + { + will_return(__wrap_f_memory_array_adjust, true); + will_return(__wrap_f_memory_array_adjust, F_status_set_error(F_failure)); + + const f_status_t status = f_number_signedss_destroy_callback(0, 1, (void *) datas_array); + + assert_int_equal(status, F_status_set_error(F_failure)); + } +} + +void test__f_type_array_number_signedss_destroy_callback__works(void **state) { + + mock_unwrap = 1; + mock_unwrap_f_memory = 1; + + const f_number_signed_t length = 1; + + f_number_signedss_t datass = f_number_signedss_t_initialize; + + { + f_status_t status = f_memory_array_adjust(length, sizeof(f_number_signeds_t), (void **) &datass.array, &datass.used, &datass.size); + assert_int_equal(status, F_okay); + + status = f_memory_array_adjust(1, sizeof(f_number_signed_t), (void **) &datass.array[0].array, &datass.array[0].used, &datass.array[0].size); + assert_int_equal(status, F_okay); + } + + { + const f_status_t status = f_number_signedss_destroy_callback(0, length, (void *) datass.array); + + assert_int_equal(status, F_okay); + assert_int_equal(datass.array[0].size, 0); + } + + free((void *) datass.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-number_signedss_destroy_callback.h b/level_0/f_type_array/tests/unit/c/test-type_array-number_signedss_destroy_callback.h new file mode 100644 index 0000000..f254396 --- /dev/null +++ b/level_0/f_type_array/tests/unit/c/test-type_array-number_signedss_destroy_callback.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_type_array__number_signedss_destroy_callback +#define _TEST__F_type_array__number_signedss_destroy_callback + +/** + * Test that the function fails. + * + * @see f_number_signedss_destroy_callback() + */ +extern void test__f_type_array_number_signedss_destroy_callback__fails(void **state); + +/** + * Test that the function works. + * + * @see f_number_signedss_destroy_callback() + */ +extern void test__f_type_array_number_signedss_destroy_callback__works(void **state); + +#endif // _TEST__F_type_array__number_signedss_destroy_callback diff --git a/level_0/f_type_array/tests/unit/c/test-type_array.c b/level_0/f_type_array/tests/unit/c/test-type_array.c index 4c01325..73d1f01 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array.c @@ -65,6 +65,12 @@ int main(void) { cmocka_unit_test(test__f_type_array_int128ss_destroy_callback__fails), cmocka_unit_test(test__f_type_array_int128ss_destroy_callback__works), + cmocka_unit_test(test__f_type_array_number_signedss_delete_callback__fails), + cmocka_unit_test(test__f_type_array_number_signedss_delete_callback__works), + + cmocka_unit_test(test__f_type_array_number_signedss_destroy_callback__fails), + cmocka_unit_test(test__f_type_array_number_signedss_destroy_callback__works), + cmocka_unit_test(test__f_type_array_number_unsignedss_delete_callback__fails), cmocka_unit_test(test__f_type_array_number_unsignedss_delete_callback__works), @@ -144,6 +150,9 @@ int main(void) { // f_int128ss_destroy_callback() doesn't use parameter checking. // f_int128ss_delete_callback() doesn't use parameter checking. + // f_number_signedss_destroy_callback() doesn't use parameter checking. + // f_number_signedss_delete_callback() doesn't use parameter checking. + // f_number_unsignedss_destroy_callback() doesn't use parameter checking. // f_number_unsignedss_delete_callback() doesn't use parameter checking. diff --git a/level_0/f_type_array/tests/unit/c/test-type_array.h b/level_0/f_type_array/tests/unit/c/test-type_array.h index 66c9bde..b9b588c 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array.h +++ b/level_0/f_type_array/tests/unit/c/test-type_array.h @@ -21,7 +21,7 @@ // fll-0 includes. #include -#include +#include #include #include #include @@ -46,6 +46,8 @@ #include "test-type_array-int64ss_destroy_callback.h" #include "test-type_array-int128ss_delete_callback.h" #include "test-type_array-int128ss_destroy_callback.h" +#include "test-type_array-number_signedss_delete_callback.h" +#include "test-type_array-number_signedss_destroy_callback.h" #include "test-type_array-number_unsignedss_delete_callback.h" #include "test-type_array-number_unsignedss_destroy_callback.h" #include "test-type_array-pollss_delete_callback.h" diff --git a/level_1/fl_print/c/print.h b/level_1/fl_print/c/print.h index 9a5a955..f446c4e 100644 --- a/level_1/fl_print/c/print.h +++ b/level_1/fl_print/c/print.h @@ -17,7 +17,7 @@ // FLL-0 includes. #include -#include +#include #include #include #include -- 1.8.3.1