diff --git a/MODULE.bazel.lock b/MODULE.bazel.lock index cf2ece4..5947753 100644 --- a/MODULE.bazel.lock +++ b/MODULE.bazel.lock @@ -1,5 +1,5 @@ { - "lockFileVersion": 16, + "lockFileVersion": 18, "registryFileHashes": { "https://bcr.bazel.build/bazel_registry.json": "8a28e4aff06ee60aed2a8c281907fb8bcbf3b753c91fb5a5c57da3215d5b3497", "https://bcr.bazel.build/modules/abseil-cpp/20210324.2/MODULE.bazel": "7cd0312e064fde87c8d1cd79ba06c876bd23630c83466e9500321be55c96ace2", diff --git a/asl/BUILD.bazel b/asl/BUILD.bazel deleted file mode 100644 index 2cc4af5..0000000 --- a/asl/BUILD.bazel +++ /dev/null @@ -1,78 +0,0 @@ -cc_library( - name = "asl", - hdrs = [ - "allocator.hpp", - "annotations.hpp", - "assert.hpp", - "atomic.hpp", - "box.hpp", - "buffer.hpp", - "config.hpp", - "float.hpp", - "format.hpp", - "functional.hpp", - "hash.hpp", - "hash_map.hpp", - "hash_set.hpp", - "integers.hpp", - "io.hpp", - "layout.hpp", - "maybe_uninit.hpp", - "memory.hpp", - "meta.hpp", - "option.hpp", - "print.hpp", - "span.hpp", - "status.hpp", - "status_or.hpp", - "string.hpp", - "string_builder.hpp", - "string_view.hpp", - "utility.hpp", - ], - srcs = [ - "allocator.cpp", - "assert.cpp", - "format.cpp", - "format_float.cpp", - "hash_cityhash.cpp", - "print.cpp", - "status.cpp", - ], - deps = [ - "//vendor/dragonbox", - ], - visibility = ["//visibility:public"], -) - -[cc_test( - name = "%s_tests" % name, - srcs = [ - "tests/%s_tests.cpp" % name, - "tests/test_types.hpp", - ], - deps = [ - ":asl", - "//asl/testing", - ], -) for name in [ - "box", - "buffer", - "float", - "format", - "functional", - "hash", - "hash_map", - "hash_set", - "integers", - "maybe_uninit", - "meta", - "option", - "span", - "status", - "status_or", - "string", - "string_builder", - "string_view", - "utility", -]] diff --git a/asl/assert.cpp b/asl/assert.cpp deleted file mode 100644 index 353232e..0000000 --- a/asl/assert.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include "asl/assert.hpp" -#include "asl/print.hpp" - - -void asl::report_assert_failure(const char* msg, const source_location& sl) -{ - eprint("------------------------------------------------------------\n"); - eprint("Assertion failure at {}, line {}:\n", sl.file, sl.line); - eprint("{}\n", msg); - eprint("------------------------------------------------------------\n"); -} diff --git a/asl/base/BUILD.bazel b/asl/base/BUILD.bazel new file mode 100644 index 0000000..317c20b --- /dev/null +++ b/asl/base/BUILD.bazel @@ -0,0 +1,36 @@ +cc_library( + name = "base", + hdrs = [ + "annotations.hpp", + "assert.hpp", + "config.hpp", + "float.hpp", + "functional.hpp", + "integers.hpp", + "meta.hpp", + "utility.hpp", + ], + srcs = [ + "assert.cpp", + ], + visibility = ["//visibility:public"], +) + +[cc_test( + name = "%s_tests" % name, + srcs = [ + "%s_tests.cpp" % name, + ], + deps = [ + ":base", + "//asl/tests:utils", + "//asl/testing", + "//asl/types:box", + ], +) for name in [ + "float", + "functional", + "integers", + "meta", + "utility", +]] diff --git a/asl/annotations.hpp b/asl/base/annotations.hpp similarity index 86% rename from asl/annotations.hpp rename to asl/base/annotations.hpp index 6ea3a84..b87dbde 100644 --- a/asl/annotations.hpp +++ b/asl/base/annotations.hpp @@ -1,6 +1,6 @@ #pragma once -#include "asl/config.hpp" +#include "asl/base/config.hpp" #if ASL_COMPILER_CLANG_CL #define ASL_NO_UNIQUE_ADDRESS [[msvc::no_unique_address]] diff --git a/asl/base/assert.cpp b/asl/base/assert.cpp new file mode 100644 index 0000000..2383e9e --- /dev/null +++ b/asl/base/assert.cpp @@ -0,0 +1,12 @@ +#include "asl/base/assert.hpp" +// #include "asl/io/print.hpp" + + +void asl::report_assert_failure(const char* msg, const source_location& sl) +{ + // @Todo(org) + // eprint("------------------------------------------------------------\n"); + // eprint("Assertion failure at {}, line {}:\n", sl.file, sl.line); + // eprint("{}\n", msg); + // eprint("------------------------------------------------------------\n"); +} diff --git a/asl/assert.hpp b/asl/base/assert.hpp similarity index 95% rename from asl/assert.hpp rename to asl/base/assert.hpp index 608a44f..42e8635 100644 --- a/asl/assert.hpp +++ b/asl/base/assert.hpp @@ -1,7 +1,7 @@ #pragma once -#include "asl/config.hpp" -#include "asl/meta.hpp" +#include "asl/base/config.hpp" +#include "asl/base/meta.hpp" namespace asl { diff --git a/asl/config.hpp b/asl/base/config.hpp similarity index 100% rename from asl/config.hpp rename to asl/base/config.hpp diff --git a/asl/float.hpp b/asl/base/float.hpp similarity index 93% rename from asl/float.hpp rename to asl/base/float.hpp index 99c3f32..2de2e0c 100644 --- a/asl/float.hpp +++ b/asl/base/float.hpp @@ -1,6 +1,6 @@ #pragma once -#include "asl/meta.hpp" +#include "asl/base/meta.hpp" namespace asl { diff --git a/asl/tests/float_tests.cpp b/asl/base/float_tests.cpp similarity index 95% rename from asl/tests/float_tests.cpp rename to asl/base/float_tests.cpp index d645be8..0a5bebf 100644 --- a/asl/tests/float_tests.cpp +++ b/asl/base/float_tests.cpp @@ -1,4 +1,4 @@ -#include "asl/float.hpp" +#include "asl/base/float.hpp" #include "asl/testing/testing.hpp" diff --git a/asl/functional.hpp b/asl/base/functional.hpp similarity index 95% rename from asl/functional.hpp rename to asl/base/functional.hpp index f5ff0d9..d820bce 100644 --- a/asl/functional.hpp +++ b/asl/base/functional.hpp @@ -1,7 +1,7 @@ #pragma once -#include "asl/meta.hpp" -#include "asl/utility.hpp" +#include "asl/base/meta.hpp" +#include "asl/base/utility.hpp" namespace asl { diff --git a/asl/tests/functional_tests.cpp b/asl/base/functional_tests.cpp similarity index 98% rename from asl/tests/functional_tests.cpp rename to asl/base/functional_tests.cpp index 2cdbe7a..92c5c7b 100644 --- a/asl/tests/functional_tests.cpp +++ b/asl/base/functional_tests.cpp @@ -1,4 +1,4 @@ -#include "asl/functional.hpp" +#include "asl/base/functional.hpp" #include "asl/testing/testing.hpp" struct HasFunction diff --git a/asl/integers.hpp b/asl/base/integers.hpp similarity index 95% rename from asl/integers.hpp rename to asl/base/integers.hpp index 04722a3..c18c850 100644 --- a/asl/integers.hpp +++ b/asl/base/integers.hpp @@ -1,6 +1,6 @@ #pragma once -#include "asl/config.hpp" +#include "asl/base/config.hpp" using int8_t = signed char; using int16_t = signed short; diff --git a/asl/tests/integers_tests.cpp b/asl/base/integers_tests.cpp similarity index 92% rename from asl/tests/integers_tests.cpp rename to asl/base/integers_tests.cpp index 1b5a20a..52feb85 100644 --- a/asl/tests/integers_tests.cpp +++ b/asl/base/integers_tests.cpp @@ -1,4 +1,4 @@ -#include "asl/integers.hpp" +#include "asl/base/integers.hpp" static_assert(sizeof(int8_t) == 1); static_assert(sizeof(int16_t) == 2); diff --git a/asl/meta.hpp b/asl/base/meta.hpp similarity index 99% rename from asl/meta.hpp rename to asl/base/meta.hpp index a464e36..ce17420 100644 --- a/asl/meta.hpp +++ b/asl/base/meta.hpp @@ -1,6 +1,6 @@ #pragma once -#include "asl/integers.hpp" +#include "asl/base/integers.hpp" namespace asl { diff --git a/asl/tests/meta_tests.cpp b/asl/base/meta_tests.cpp similarity index 99% rename from asl/tests/meta_tests.cpp rename to asl/base/meta_tests.cpp index b015eb6..7aa7145 100644 --- a/asl/tests/meta_tests.cpp +++ b/asl/base/meta_tests.cpp @@ -1,7 +1,7 @@ -#include "asl/meta.hpp" -#include "asl/tests/test_types.hpp" +#include "asl/base/meta.hpp" +#include "asl/tests/types.hpp" #include "asl/testing/testing.hpp" -#include "asl/box.hpp" +#include "asl/types/box.hpp" struct Struct {}; union Union {}; diff --git a/asl/utility.hpp b/asl/base/utility.hpp similarity index 93% rename from asl/utility.hpp rename to asl/base/utility.hpp index f3b94c3..c03554f 100644 --- a/asl/utility.hpp +++ b/asl/base/utility.hpp @@ -1,8 +1,7 @@ #pragma once -#include "asl/meta.hpp" -#include "asl/layout.hpp" -#include "asl/assert.hpp" +#include "asl/base/meta.hpp" +#include "asl/base/assert.hpp" #define ASL_MOVE(...) (static_cast<::asl::un_ref_t&&>(__VA_ARGS__)) @@ -31,7 +30,7 @@ T exchange(T& obj, U&& new_value) } template -constexpr U bit_cast(T value) requires (size_of == size_of) +constexpr U bit_cast(T value) requires (sizeof(T) == sizeof(U)) { return __builtin_bit_cast(U, value); } diff --git a/asl/base/utility_tests.cpp b/asl/base/utility_tests.cpp new file mode 100644 index 0000000..4b8e3d1 --- /dev/null +++ b/asl/base/utility_tests.cpp @@ -0,0 +1 @@ +#include "asl/base/utility.hpp" diff --git a/asl/containers/BUILD.bazel b/asl/containers/BUILD.bazel new file mode 100644 index 0000000..2d2e057 --- /dev/null +++ b/asl/containers/BUILD.bazel @@ -0,0 +1,58 @@ +cc_library( + name = "buffer", + hdrs = [ + "buffer.hpp", + ], + deps = [ + "//asl/memory", + "//asl/base", + "//asl/types:span", + "//asl/hashing", + ], + visibility = ["//visibility:public"], +) + +cc_library( + name = "hash_set", + hdrs = [ + "hash_set.hpp", + ], + deps = [ + "//asl/base", + "//asl/memory", + "//asl/types:maybe_uninit", + "//asl/hashing", + ], + visibility = ["//visibility:public"], +) + +cc_library( + name = "hash_map", + hdrs = [ + "hash_map.hpp", + ], + deps = [ + "//asl/base", + "//asl/memory", + "//asl/hashing", + ":hash_set", + ], + visibility = ["//visibility:public"], +) + +[cc_test( + name = "%s_tests" % name, + srcs = [ + "%s_tests.cpp" % name, + ], + deps = [ + ":%s" % name, + "//asl/tests:utils", + "//asl/testing", + "//asl/strings:string", + ], +) for name in [ + "buffer", + "hash_map", + "hash_set", +]] diff --git a/asl/buffer.hpp b/asl/containers/buffer.hpp similarity index 98% rename from asl/buffer.hpp rename to asl/containers/buffer.hpp index 5cf9964..76562d3 100644 --- a/asl/buffer.hpp +++ b/asl/containers/buffer.hpp @@ -1,12 +1,12 @@ #pragma once -#include "asl/meta.hpp" -#include "asl/allocator.hpp" -#include "asl/annotations.hpp" -#include "asl/memory.hpp" -#include "asl/assert.hpp" -#include "asl/span.hpp" -#include "asl/hash.hpp" +#include "asl/base/meta.hpp" +#include "asl/memory/allocator.hpp" +#include "asl/memory/memory.hpp" +#include "asl/base/annotations.hpp" +#include "asl/base/assert.hpp" +#include "asl/types/span.hpp" +#include "asl/hashing/hash.hpp" namespace asl { diff --git a/asl/tests/buffer_tests.cpp b/asl/containers/buffer_tests.cpp similarity index 99% rename from asl/tests/buffer_tests.cpp rename to asl/containers/buffer_tests.cpp index 174b3bc..fd8ad45 100644 --- a/asl/tests/buffer_tests.cpp +++ b/asl/containers/buffer_tests.cpp @@ -1,7 +1,7 @@ -#include "asl/buffer.hpp" +#include "asl/containers/buffer.hpp" #include "asl/testing/testing.hpp" -#include "asl/tests/test_types.hpp" +#include "asl/tests/types.hpp" struct Big { diff --git a/asl/hash_map.hpp b/asl/containers/hash_map.hpp similarity index 96% rename from asl/hash_map.hpp rename to asl/containers/hash_map.hpp index edb3b4c..104bd6a 100644 --- a/asl/hash_map.hpp +++ b/asl/containers/hash_map.hpp @@ -1,10 +1,10 @@ #pragma once -#include "asl/meta.hpp" -#include "asl/utility.hpp" -#include "asl/hash.hpp" -#include "asl/allocator.hpp" -#include "asl/hash_set.hpp" +#include "asl/base/utility.hpp" +#include "asl/base/meta.hpp" +#include "asl/hashing/hash.hpp" +#include "asl/memory/allocator.hpp" +#include "asl/containers/hash_set.hpp" namespace asl { diff --git a/asl/tests/hash_map_tests.cpp b/asl/containers/hash_map_tests.cpp similarity index 96% rename from asl/tests/hash_map_tests.cpp rename to asl/containers/hash_map_tests.cpp index 619c5e7..6cb7fe1 100644 --- a/asl/tests/hash_map_tests.cpp +++ b/asl/containers/hash_map_tests.cpp @@ -1,5 +1,5 @@ #include "asl/testing/testing.hpp" -#include "asl/hash_map.hpp" +#include "asl/containers/hash_map.hpp" ASL_TEST(default) { diff --git a/asl/hash_set.hpp b/asl/containers/hash_set.hpp similarity index 97% rename from asl/hash_set.hpp rename to asl/containers/hash_set.hpp index d252b37..97a37f2 100644 --- a/asl/hash_set.hpp +++ b/asl/containers/hash_set.hpp @@ -1,12 +1,12 @@ #pragma once -#include "asl/annotations.hpp" -#include "asl/meta.hpp" -#include "asl/utility.hpp" -#include "asl/maybe_uninit.hpp" -#include "asl/hash.hpp" -#include "asl/allocator.hpp" -#include "asl/memory.hpp" +#include "asl/base/annotations.hpp" +#include "asl/base/utility.hpp" +#include "asl/base/meta.hpp" +#include "asl/memory/allocator.hpp" +#include "asl/memory/memory.hpp" +#include "asl/types/maybe_uninit.hpp" +#include "asl/hashing/hash.hpp" namespace asl { diff --git a/asl/tests/hash_set_tests.cpp b/asl/containers/hash_set_tests.cpp similarity index 96% rename from asl/tests/hash_set_tests.cpp rename to asl/containers/hash_set_tests.cpp index 0c00c87..2baab94 100644 --- a/asl/tests/hash_set_tests.cpp +++ b/asl/containers/hash_set_tests.cpp @@ -1,8 +1,8 @@ -#include "asl/hash_set.hpp" +#include "asl/containers/hash_set.hpp" #include "asl/testing/testing.hpp" -#include "asl/tests/test_types.hpp" -#include "asl/string.hpp" -#include "asl/string_view.hpp" +#include "asl/tests/types.hpp" +#include "asl/strings/string.hpp" +#include "asl/strings/string_view.hpp" ASL_TEST(empty) { diff --git a/asl/formatting/BUILD.bazel b/asl/formatting/BUILD.bazel new file mode 100644 index 0000000..cab293e --- /dev/null +++ b/asl/formatting/BUILD.bazel @@ -0,0 +1,32 @@ +cc_library( + name = "formatting", + hdrs = [ + "format.hpp", + ], + srcs = [ + "format.cpp", + "format_float.cpp", + ], + deps = [ + "//asl/base", + "//asl/memory", + "//asl/strings:string_view", + "//asl/types:span", + "//asl/io:writer", + "//vendor/dragonbox", + ], + visibility = ["//visibility:public"], +) + +cc_test( + name = "tests", + srcs = [ + "format_tests.cpp", + ], + deps = [ + ":formatting", + "//asl/tests:utils", + "//asl/testing", + "//asl/strings:string_builder", + ], +) diff --git a/asl/format.cpp b/asl/formatting/format.cpp similarity index 97% rename from asl/format.cpp rename to asl/formatting/format.cpp index 91a7be9..0c52c1b 100644 --- a/asl/format.cpp +++ b/asl/formatting/format.cpp @@ -1,7 +1,7 @@ -#include "asl/format.hpp" -#include "asl/utility.hpp" -#include "asl/assert.hpp" -#include "asl/memory.hpp" +#include "asl/formatting/format.hpp" +#include "asl/base/utility.hpp" +#include "asl/base/assert.hpp" +#include "asl/memory/memory.hpp" void asl::format_internals::format( Writer* writer, diff --git a/asl/format.hpp b/asl/formatting/format.hpp similarity index 93% rename from asl/format.hpp rename to asl/formatting/format.hpp index 70de9b9..02f43eb 100644 --- a/asl/format.hpp +++ b/asl/formatting/format.hpp @@ -1,10 +1,10 @@ #pragma once -#include "asl/integers.hpp" -#include "asl/meta.hpp" -#include "asl/io.hpp" -#include "asl/span.hpp" -#include "asl/string_view.hpp" +#include "asl/base/integers.hpp" +#include "asl/base/meta.hpp" +#include "asl/io/writer.hpp" +#include "asl/types/span.hpp" +#include "asl/strings/string_view.hpp" namespace asl { diff --git a/asl/format_float.cpp b/asl/formatting/format_float.cpp similarity index 97% rename from asl/format_float.cpp rename to asl/formatting/format_float.cpp index 1b3186e..eca1d92 100644 --- a/asl/format_float.cpp +++ b/asl/formatting/format_float.cpp @@ -1,5 +1,5 @@ -#include "asl/format.hpp" -#include "asl/float.hpp" +#include "asl/formatting/format.hpp" +#include "asl/base/float.hpp" #define JKJ_STD_REPLACEMENT_NAMESPACE_DEFINED 0 #define JKJ_STATIC_DATA_SECTION_DEFINED 0 diff --git a/asl/tests/format_tests.cpp b/asl/formatting/format_tests.cpp similarity index 96% rename from asl/tests/format_tests.cpp rename to asl/formatting/format_tests.cpp index a91cac6..96ed7d0 100644 --- a/asl/tests/format_tests.cpp +++ b/asl/formatting/format_tests.cpp @@ -1,7 +1,7 @@ -#include "asl/format.hpp" +#include "asl/formatting/format.hpp" #include "asl/testing/testing.hpp" -#include "asl/float.hpp" -#include "asl/string_builder.hpp" +#include "asl/base/float.hpp" +#include "asl/strings/string_builder.hpp" static_assert(asl::formattable); diff --git a/asl/hashing/BUILD.bazel b/asl/hashing/BUILD.bazel new file mode 100644 index 0000000..6b9b410 --- /dev/null +++ b/asl/hashing/BUILD.bazel @@ -0,0 +1,33 @@ +cc_library( + name = "hashing", + hdrs = [ + "hash.hpp", + ], + srcs = [ + "hash_cityhash.cpp", + ], + deps = [ + "//asl/base", + "//asl/types:span", + ], + visibility = ["//visibility:public"], +) + +cc_test( + name = "tests", + srcs = [ + "hash_tests.cpp", + ], + deps = [ + "//asl/base", + "//asl/tests:utils", + "//asl/testing", + ":hashing", + "//asl/strings:string_view", + "//asl/strings:string", + "//asl/containers:buffer", + "//asl/types:box", + "//asl/types:option", + "//asl/types:status", + ], +) diff --git a/asl/hash.hpp b/asl/hashing/hash.hpp similarity index 96% rename from asl/hash.hpp rename to asl/hashing/hash.hpp index 9539755..60550d0 100644 --- a/asl/hash.hpp +++ b/asl/hashing/hash.hpp @@ -1,9 +1,9 @@ #pragma once -#include "asl/integers.hpp" -#include "asl/meta.hpp" -#include "asl/span.hpp" -#include "asl/utility.hpp" +#include "asl/base/integers.hpp" +#include "asl/base/meta.hpp" +#include "asl/types/span.hpp" +#include "asl/base/utility.hpp" namespace asl::city_hash { diff --git a/asl/hash_cityhash.cpp b/asl/hashing/hash_cityhash.cpp similarity index 99% rename from asl/hash_cityhash.cpp rename to asl/hashing/hash_cityhash.cpp index 63dd6bb..9748344 100644 --- a/asl/hash_cityhash.cpp +++ b/asl/hashing/hash_cityhash.cpp @@ -27,8 +27,8 @@ // possible hash functions, by using SIMD instructions, or by // compromising on hash quality. -#include "asl/hash.hpp" -#include "asl/memory.hpp" +#include "asl/hashing/hash.hpp" +#include "asl/memory/memory.hpp" using uint8 = uint8_t; using uint32 = uint32_t; diff --git a/asl/tests/hash_tests.cpp b/asl/hashing/hash_tests.cpp similarity index 97% rename from asl/tests/hash_tests.cpp rename to asl/hashing/hash_tests.cpp index 20a5183..9efb497 100644 --- a/asl/tests/hash_tests.cpp +++ b/asl/hashing/hash_tests.cpp @@ -1,12 +1,12 @@ #include "asl/testing/testing.hpp" -#include "asl/hash.hpp" -#include "asl/string_view.hpp" -#include "asl/string.hpp" -#include "asl/buffer.hpp" -#include "asl/box.hpp" -#include "asl/option.hpp" -#include "asl/status.hpp" -#include "asl/status_or.hpp" +#include "asl/hashing/hash.hpp" +#include "asl/strings/string_view.hpp" +#include "asl/strings/string.hpp" +#include "asl/containers/buffer.hpp" +#include "asl/types/box.hpp" +#include "asl/types/option.hpp" +#include "asl/types/status.hpp" +#include "asl/types/status_or.hpp" static_assert(!asl::hashable); static_assert(!asl::hashable); diff --git a/asl/io/BUILD.bazel b/asl/io/BUILD.bazel new file mode 100644 index 0000000..b37787c --- /dev/null +++ b/asl/io/BUILD.bazel @@ -0,0 +1,26 @@ +cc_library( + name = "writer", + hdrs = [ + "writer.hpp", + ], + deps = [ + "//asl/base", + "//asl/types:span", + ], + visibility = ["//visibility:public"], +) + +cc_library( + name = "print", + hdrs = [ + "print.hpp", + ], + srcs = [ + "print.cpp", + ], + deps = [ + "//asl/formatting", + ":writer", + ], + visibility = ["//visibility:public"], +) diff --git a/asl/print.cpp b/asl/io/print.cpp similarity index 95% rename from asl/print.cpp rename to asl/io/print.cpp index 559dcbd..0161bd1 100644 --- a/asl/print.cpp +++ b/asl/io/print.cpp @@ -1,4 +1,4 @@ -#include "asl/print.hpp" +#include "asl/io/print.hpp" #include diff --git a/asl/print.hpp b/asl/io/print.hpp similarity index 88% rename from asl/print.hpp rename to asl/io/print.hpp index 283a311..a1899a8 100644 --- a/asl/print.hpp +++ b/asl/io/print.hpp @@ -1,6 +1,7 @@ #pragma once -#include "asl/format.hpp" +#include "asl/formatting/format.hpp" +#include "asl/io/writer.hpp" namespace asl { diff --git a/asl/io.hpp b/asl/io/writer.hpp similarity index 69% rename from asl/io.hpp rename to asl/io/writer.hpp index 66de6d7..e3cb313 100644 --- a/asl/io.hpp +++ b/asl/io/writer.hpp @@ -1,8 +1,8 @@ #pragma once -#include "asl/integers.hpp" -#include "asl/utility.hpp" -#include "asl/span.hpp" +#include "asl/base/integers.hpp" +#include "asl/base/utility.hpp" +#include "asl/types/span.hpp" namespace asl { diff --git a/asl/logging/BUILD.bazel b/asl/logging/BUILD.bazel index 396da74..3c60915 100644 --- a/asl/logging/BUILD.bazel +++ b/asl/logging/BUILD.bazel @@ -7,7 +7,11 @@ cc_library( "logging.hpp", ], deps = [ - "//asl", + "//asl/base", + "//asl/types:box", + "//asl/formatting", + "//asl/io:print", + "//asl/strings:string_builder", ], visibility = ["//visibility:public"], ) diff --git a/asl/logging/logging.cpp b/asl/logging/logging.cpp index aa630ac..df7758d 100644 --- a/asl/logging/logging.cpp +++ b/asl/logging/logging.cpp @@ -1,6 +1,6 @@ #include "asl/logging/logging.hpp" -#include "asl/print.hpp" -#include "asl/string_builder.hpp" +#include "asl/io/print.hpp" +#include "asl/strings/string_builder.hpp" // @Todo Don't use internal get_stdout_writer, make console module diff --git a/asl/logging/logging.hpp b/asl/logging/logging.hpp index 81f10e7..c692750 100644 --- a/asl/logging/logging.hpp +++ b/asl/logging/logging.hpp @@ -1,8 +1,8 @@ #pragma once -#include "asl/format.hpp" -#include "asl/utility.hpp" -#include "asl/box.hpp" +#include "asl/base/utility.hpp" +#include "asl/types/box.hpp" +#include "asl/formatting/format.hpp" namespace asl::log { diff --git a/asl/logging/logging_tests.cpp b/asl/logging/logging_tests.cpp index ebbf800..39a800a 100644 --- a/asl/logging/logging_tests.cpp +++ b/asl/logging/logging_tests.cpp @@ -1,6 +1,6 @@ #include "asl/logging/logging.hpp" #include "asl/testing/testing.hpp" -#include "asl/string_builder.hpp" +#include "asl/strings/string_builder.hpp" ASL_TEST(log) { diff --git a/asl/memory/BUILD.bazel b/asl/memory/BUILD.bazel new file mode 100644 index 0000000..0a198bc --- /dev/null +++ b/asl/memory/BUILD.bazel @@ -0,0 +1,16 @@ +cc_library( + name = "memory", + hdrs = [ + "allocator.hpp", + "layout.hpp", + "memory.hpp", + ], + srcs = [ + "allocator.cpp", + ], + deps = [ + "//asl/base", + ], + visibility = ["//visibility:public"], +) + diff --git a/asl/allocator.cpp b/asl/memory/allocator.cpp similarity index 90% rename from asl/allocator.cpp rename to asl/memory/allocator.cpp index 59bff76..504202d 100644 --- a/asl/allocator.cpp +++ b/asl/memory/allocator.cpp @@ -1,8 +1,6 @@ -#include "asl/allocator.hpp" -#include "asl/assert.hpp" -#include "asl/utility.hpp" -#include "asl/memory.hpp" -#include "asl/print.hpp" +#include "asl/memory/allocator.hpp" +#include "asl/base/assert.hpp" +#include "asl/memory/layout.hpp" #include diff --git a/asl/allocator.hpp b/asl/memory/allocator.hpp similarity index 92% rename from asl/allocator.hpp rename to asl/memory/allocator.hpp index 90793dd..d39fa23 100644 --- a/asl/allocator.hpp +++ b/asl/memory/allocator.hpp @@ -1,8 +1,8 @@ #pragma once -#include "asl/layout.hpp" -#include "asl/meta.hpp" -#include "asl/memory.hpp" +#include "asl/base/meta.hpp" +#include "asl/memory/layout.hpp" +#include "asl/memory/memory.hpp" namespace asl { diff --git a/asl/layout.hpp b/asl/memory/layout.hpp similarity index 91% rename from asl/layout.hpp rename to asl/memory/layout.hpp index 0201e94..af867d8 100644 --- a/asl/layout.hpp +++ b/asl/memory/layout.hpp @@ -1,7 +1,7 @@ #pragma once -#include "asl/integers.hpp" -#include "asl/meta.hpp" +#include "asl/base/integers.hpp" +#include "asl/base/meta.hpp" namespace asl { diff --git a/asl/memory.hpp b/asl/memory/memory.hpp similarity index 95% rename from asl/memory.hpp rename to asl/memory/memory.hpp index 5a73d26..de8e07d 100644 --- a/asl/memory.hpp +++ b/asl/memory/memory.hpp @@ -1,9 +1,9 @@ #pragma once -#include "asl/integers.hpp" -#include "asl/meta.hpp" -#include "asl/layout.hpp" -#include "asl/utility.hpp" +#include "asl/base/integers.hpp" +#include "asl/base/meta.hpp" +#include "asl/base/utility.hpp" +#include "asl/memory/layout.hpp" constexpr void* operator new(size_t, void* ptr) { diff --git a/asl/strings/BUILD.bazel b/asl/strings/BUILD.bazel new file mode 100644 index 0000000..b9032dc --- /dev/null +++ b/asl/strings/BUILD.bazel @@ -0,0 +1,56 @@ +cc_library( + name = "string_view", + hdrs = [ + "string_view.hpp", + ], + deps = [ + "//asl/base", + "//asl/memory", + "//asl/types:span", + ], + visibility = ["//visibility:public"], +) + +cc_library( + name = "string", + hdrs = [ + "string.hpp", + ], + deps = [ + "//asl/containers:buffer", + ":string_view", + ], + visibility = ["//visibility:public"], +) + +cc_library( + name = "string_builder", + hdrs = [ + "string_builder.hpp", + ], + deps = [ + "//asl/containers:buffer", + "//asl/formatting", + ":string", + "//asl/io:writer", + ], + visibility = ["//visibility:public"], +) + +[cc_test( + name = "%s_tests" % name, + srcs = [ + "%s_tests.cpp" % name, + ], + deps = [ + ":string", + ":string_builder", + ":string_view", + "//asl/tests:utils", + "//asl/testing", + ], +) for name in [ + "string", + "string_view", + "string_builder", +]] diff --git a/asl/string.hpp b/asl/strings/string.hpp similarity index 96% rename from asl/string.hpp rename to asl/strings/string.hpp index ae732f0..abad3b4 100644 --- a/asl/string.hpp +++ b/asl/strings/string.hpp @@ -1,7 +1,7 @@ #pragma once -#include "asl/buffer.hpp" -#include "asl/string_view.hpp" +#include "asl/containers/buffer.hpp" +#include "asl/strings/string_view.hpp" namespace asl { diff --git a/asl/string_builder.hpp b/asl/strings/string_builder.hpp similarity index 96% rename from asl/string_builder.hpp rename to asl/strings/string_builder.hpp index 15422f6..d30f1d5 100644 --- a/asl/string_builder.hpp +++ b/asl/strings/string_builder.hpp @@ -1,10 +1,10 @@ #pragma once -#include "asl/buffer.hpp" -#include "asl/string.hpp" -#include "asl/string_view.hpp" -#include "asl/format.hpp" -#include "asl/io.hpp" +#include "asl/containers/buffer.hpp" +#include "asl/strings/string.hpp" +#include "asl/strings/string_view.hpp" +#include "asl/formatting/format.hpp" +#include "asl/io/writer.hpp" namespace asl { diff --git a/asl/tests/string_builder_tests.cpp b/asl/strings/string_builder_tests.cpp similarity index 91% rename from asl/tests/string_builder_tests.cpp rename to asl/strings/string_builder_tests.cpp index dddf2a9..5341af2 100644 --- a/asl/tests/string_builder_tests.cpp +++ b/asl/strings/string_builder_tests.cpp @@ -1,4 +1,4 @@ -#include "asl/string_builder.hpp" +#include "asl/strings/string_builder.hpp" #include "asl/testing/testing.hpp" ASL_TEST(string_builder) diff --git a/asl/tests/string_tests.cpp b/asl/strings/string_tests.cpp similarity index 85% rename from asl/tests/string_tests.cpp rename to asl/strings/string_tests.cpp index 80aaf24..dda8f74 100644 --- a/asl/tests/string_tests.cpp +++ b/asl/strings/string_tests.cpp @@ -1,6 +1,6 @@ -#include "asl/string.hpp" +#include "asl/strings/string.hpp" #include "asl/testing/testing.hpp" -#include "asl/format.hpp" +#include "asl/formatting/format.hpp" ASL_TEST(default) { diff --git a/asl/string_view.hpp b/asl/strings/string_view.hpp similarity index 95% rename from asl/string_view.hpp rename to asl/strings/string_view.hpp index c869092..9d8b576 100644 --- a/asl/string_view.hpp +++ b/asl/strings/string_view.hpp @@ -1,9 +1,9 @@ #pragma once -#include "asl/integers.hpp" -#include "asl/meta.hpp" -#include "asl/span.hpp" -#include "asl/memory.hpp" +#include "asl/base/integers.hpp" +#include "asl/base/meta.hpp" +#include "asl/types/span.hpp" +#include "asl/memory/memory.hpp" namespace asl { diff --git a/asl/tests/string_view_tests.cpp b/asl/strings/string_view_tests.cpp similarity index 98% rename from asl/tests/string_view_tests.cpp rename to asl/strings/string_view_tests.cpp index 7175661..a357186 100644 --- a/asl/tests/string_view_tests.cpp +++ b/asl/strings/string_view_tests.cpp @@ -1,4 +1,4 @@ -#include "asl/string_view.hpp" +#include "asl/strings/string_view.hpp" #include "asl/testing/testing.hpp" static_assert(asl::trivially_destructible); diff --git a/asl/synchronization/BUILD.bazel b/asl/synchronization/BUILD.bazel new file mode 100644 index 0000000..29e0a62 --- /dev/null +++ b/asl/synchronization/BUILD.bazel @@ -0,0 +1,10 @@ +cc_library( + name = "atomic", + hdrs = [ + "atomic.hpp", + ], + deps = [ + "//asl/base", + ], + visibility = ["//visibility:public"], +) diff --git a/asl/atomic.hpp b/asl/synchronization/atomic.hpp similarity index 97% rename from asl/atomic.hpp rename to asl/synchronization/atomic.hpp index 95c3715..528a6fa 100644 --- a/asl/atomic.hpp +++ b/asl/synchronization/atomic.hpp @@ -1,6 +1,6 @@ #pragma once -#include "asl/meta.hpp" +#include "asl/base/meta.hpp" namespace asl { diff --git a/asl/testing/BUILD.bazel b/asl/testing/BUILD.bazel index 22f59e1..0bfb7ee 100644 --- a/asl/testing/BUILD.bazel +++ b/asl/testing/BUILD.bazel @@ -7,7 +7,9 @@ cc_library( "testing.cpp", ], deps = [ - "//asl", + "//asl/base", + "//asl/formatting", + "//asl/io:print", ], visibility = ["//visibility:public"], ) diff --git a/asl/testing/testing.cpp b/asl/testing/testing.cpp index 1aa0571..623d87b 100644 --- a/asl/testing/testing.cpp +++ b/asl/testing/testing.cpp @@ -1,6 +1,6 @@ #include "asl/testing/testing.hpp" -#include "asl/print.hpp" +#include "asl/io/print.hpp" static asl::testing::Test* g_head = nullptr; static asl::testing::Test* g_tail = nullptr; diff --git a/asl/testing/testing.hpp b/asl/testing/testing.hpp index e23325f..b47c416 100644 --- a/asl/testing/testing.hpp +++ b/asl/testing/testing.hpp @@ -1,6 +1,6 @@ #pragma once -#include "asl/utility.hpp" +#include "asl/base/utility.hpp" namespace asl::testing { diff --git a/asl/tests/BUILD.bazel b/asl/tests/BUILD.bazel new file mode 100644 index 0000000..eb51ec8 --- /dev/null +++ b/asl/tests/BUILD.bazel @@ -0,0 +1,10 @@ +cc_library( + name = "utils", + hdrs = [ + "types.hpp", + ], + deps = [ + "//asl/base", + ], + visibility = ["//asl:__subpackages__"], +) diff --git a/asl/tests/test_types.hpp b/asl/tests/types.hpp similarity index 95% rename from asl/tests/test_types.hpp rename to asl/tests/types.hpp index 0fcc693..e65aa11 100644 --- a/asl/tests/test_types.hpp +++ b/asl/tests/types.hpp @@ -1,9 +1,6 @@ #pragma once -#include "asl/utility.hpp" -#include "asl/io.hpp" -#include "asl/allocator.hpp" -#include "asl/string_view.hpp" +#include "asl/base/utility.hpp" struct TrivialType { diff --git a/asl/tests/utility_tests.cpp b/asl/tests/utility_tests.cpp deleted file mode 100644 index 32bcf4a..0000000 --- a/asl/tests/utility_tests.cpp +++ /dev/null @@ -1 +0,0 @@ -#include "asl/utility.hpp" diff --git a/asl/types/BUILD.bazel b/asl/types/BUILD.bazel new file mode 100644 index 0000000..d39586b --- /dev/null +++ b/asl/types/BUILD.bazel @@ -0,0 +1,135 @@ +cc_library( + name = "box", + hdrs = [ + "box.hpp", + ], + deps = [ + "//asl/base", + "//asl/memory", + "//asl/hashing", + ], + visibility = ["//visibility:public"], +) + +cc_library( + name = "span", + hdrs = [ + "span.hpp", + ], + deps = [ + "//asl/base", + "//asl/memory", + ], + visibility = ["//visibility:public"], +) + +cc_library( + name = "maybe_uninit", + hdrs = [ + "maybe_uninit.hpp", + ], + deps = [ + "//asl/base", + "//asl/memory", + ], + visibility = ["//visibility:public"], +) + +cc_library( + name = "option", + hdrs = [ + "option.hpp", + ], + deps = [ + "//asl/base", + "//asl/types:maybe_uninit", + "//asl/hashing", + ], + visibility = ["//visibility:public"], +) + +cc_library( + name = "status", + hdrs = [ + "status.hpp", + "status_or.hpp", + ], + srcs = [ + "status.cpp", + ], + deps = [ + "//asl/base", + "//asl/strings:string", + "//asl/strings:string_builder", + "//asl/formatting", + "//asl/memory", + "//asl/synchronization:atomic", + "//asl/types:maybe_uninit", + "//asl/hashing", + ], + visibility = ["//visibility:public"], +) + +cc_test( + name = "box_tests", + srcs = ["box_tests.cpp"], + deps = [ + "//asl/tests:utils", + "//asl/testing", + "//asl/types:box", + "//asl/types:option", + "//asl/types:maybe_uninit", + "//asl/hashing", + ], +) + +cc_test( + name = "maybe_uninit_tests", + srcs = ["maybe_uninit_tests.cpp"], + deps = [ + "//asl/tests:utils", + "//asl/testing", + "//asl/types:maybe_uninit", + ], +) + +cc_test( + name = "span_tests", + srcs = ["span_tests.cpp"], + deps = [ + "//asl/tests:utils", + "//asl/testing", + "//asl/types:span", + ], +) + +cc_test( + name = "option_tests", + srcs = ["option_tests.cpp"], + deps = [ + "//asl/tests:utils", + "//asl/testing", + "//asl/types:option", + ], +) + +cc_test( + name = "status_tests", + srcs = ["status_tests.cpp"], + deps = [ + "//asl/tests:utils", + "//asl/testing", + "//asl/types:status", + ], +) + +cc_test( + name = "status_or_tests", + srcs = ["status_or_tests.cpp"], + deps = [ + "//asl/tests:utils", + "//asl/testing", + "//asl/types:status", + ], +) + diff --git a/asl/box.hpp b/asl/types/box.hpp similarity index 93% rename from asl/box.hpp rename to asl/types/box.hpp index 9d3c7f0..d8577ec 100644 --- a/asl/box.hpp +++ b/asl/types/box.hpp @@ -1,11 +1,11 @@ #pragma once -#include "asl/allocator.hpp" -#include "asl/assert.hpp" -#include "asl/annotations.hpp" -#include "asl/memory.hpp" -#include "asl/utility.hpp" -#include "asl/hash.hpp" +#include "asl/base/assert.hpp" +#include "asl/base/annotations.hpp" +#include "asl/base/utility.hpp" +#include "asl/memory/memory.hpp" +#include "asl/memory/allocator.hpp" +#include "asl/hashing/hash.hpp" namespace asl { diff --git a/asl/tests/box_tests.cpp b/asl/types/box_tests.cpp similarity index 95% rename from asl/tests/box_tests.cpp rename to asl/types/box_tests.cpp index 3faf121..58eb4f6 100644 --- a/asl/tests/box_tests.cpp +++ b/asl/types/box_tests.cpp @@ -1,8 +1,8 @@ -#include "asl/box.hpp" -#include "asl/option.hpp" +#include "asl/types/box.hpp" +#include "asl/types/option.hpp" #include "asl/testing/testing.hpp" -#include "asl/tests/test_types.hpp" +#include "asl/tests/types.hpp" static_assert(sizeof(asl::box) == sizeof(int*)); static_assert(!asl::copyable>); diff --git a/asl/maybe_uninit.hpp b/asl/types/maybe_uninit.hpp similarity index 96% rename from asl/maybe_uninit.hpp rename to asl/types/maybe_uninit.hpp index a69f39b..9134fe9 100644 --- a/asl/maybe_uninit.hpp +++ b/asl/types/maybe_uninit.hpp @@ -1,8 +1,8 @@ #pragma once -#include "asl/meta.hpp" -#include "asl/utility.hpp" -#include "asl/memory.hpp" +#include "asl/base/meta.hpp" +#include "asl/base/utility.hpp" +#include "asl/memory/memory.hpp" namespace asl { diff --git a/asl/tests/maybe_uninit_tests.cpp b/asl/types/maybe_uninit_tests.cpp similarity index 94% rename from asl/tests/maybe_uninit_tests.cpp rename to asl/types/maybe_uninit_tests.cpp index 9861c33..4b414cd 100644 --- a/asl/tests/maybe_uninit_tests.cpp +++ b/asl/types/maybe_uninit_tests.cpp @@ -1,5 +1,5 @@ -#include "asl/maybe_uninit.hpp" -#include "asl/tests/test_types.hpp" +#include "asl/types/maybe_uninit.hpp" +#include "asl/tests/types.hpp" static_assert(asl::layout::of() == asl::layout::of>()); static_assert(asl::size_of == asl::size_of>); diff --git a/asl/option.hpp b/asl/types/option.hpp similarity index 98% rename from asl/option.hpp rename to asl/types/option.hpp index d12d4ce..86cfca3 100644 --- a/asl/option.hpp +++ b/asl/types/option.hpp @@ -1,11 +1,11 @@ #pragma once -#include "asl/assert.hpp" -#include "asl/meta.hpp" -#include "asl/maybe_uninit.hpp" -#include "asl/functional.hpp" -#include "asl/annotations.hpp" -#include "asl/hash.hpp" +#include "asl/base/assert.hpp" +#include "asl/base/meta.hpp" +#include "asl/base/functional.hpp" +#include "asl/base/annotations.hpp" +#include "asl/types/maybe_uninit.hpp" +#include "asl/hashing/hash.hpp" namespace asl { diff --git a/asl/tests/option_tests.cpp b/asl/types/option_tests.cpp similarity index 99% rename from asl/tests/option_tests.cpp rename to asl/types/option_tests.cpp index c5461b1..272b40a 100644 --- a/asl/tests/option_tests.cpp +++ b/asl/types/option_tests.cpp @@ -1,5 +1,5 @@ -#include "asl/option.hpp" -#include "asl/tests/test_types.hpp" +#include "asl/types/option.hpp" +#include "asl/tests/types.hpp" #include "asl/testing/testing.hpp" class Base {}; diff --git a/asl/span.hpp b/asl/types/span.hpp similarity index 97% rename from asl/span.hpp rename to asl/types/span.hpp index 9ebe022..b258708 100644 --- a/asl/span.hpp +++ b/asl/types/span.hpp @@ -1,9 +1,9 @@ #pragma once -#include "asl/meta.hpp" -#include "asl/annotations.hpp" -#include "asl/layout.hpp" -#include "asl/assert.hpp" +#include "asl/base/meta.hpp" +#include "asl/base/assert.hpp" +#include "asl/base/annotations.hpp" +#include "asl/memory/layout.hpp" namespace asl { diff --git a/asl/tests/span_tests.cpp b/asl/types/span_tests.cpp similarity index 99% rename from asl/tests/span_tests.cpp rename to asl/types/span_tests.cpp index 52e7736..43be2fc 100644 --- a/asl/tests/span_tests.cpp +++ b/asl/types/span_tests.cpp @@ -1,6 +1,6 @@ -#include "asl/span.hpp" +#include "asl/types/span.hpp" #include "asl/testing/testing.hpp" -#include "asl/tests/test_types.hpp" +#include "asl/tests/types.hpp" static_assert(asl::trivially_destructible>); static_assert(asl::trivially_destructible>); diff --git a/asl/status.cpp b/asl/types/status.cpp similarity index 91% rename from asl/status.cpp rename to asl/types/status.cpp index 7db293c..a16b1a2 100644 --- a/asl/status.cpp +++ b/asl/types/status.cpp @@ -1,9 +1,9 @@ -#include "asl/status.hpp" -#include "asl/allocator.hpp" -#include "asl/string.hpp" -#include "asl/atomic.hpp" -#include "asl/format.hpp" -#include "asl/string_builder.hpp" +#include "asl/types/status.hpp" +#include "asl/memory/allocator.hpp" +#include "asl/strings/string.hpp" +#include "asl/synchronization/atomic.hpp" +#include "asl/formatting/format.hpp" +#include "asl/strings/string_builder.hpp" // @Todo Use custom allocator using Allocator = asl::DefaultAllocator; diff --git a/asl/status.hpp b/asl/types/status.hpp similarity index 97% rename from asl/status.hpp rename to asl/types/status.hpp index 169dfce..738feb1 100644 --- a/asl/status.hpp +++ b/asl/types/status.hpp @@ -1,8 +1,8 @@ #pragma once -#include "asl/integers.hpp" -#include "asl/string_view.hpp" -#include "asl/format.hpp" +#include "asl/base/integers.hpp" +#include "asl/strings/string_view.hpp" +#include "asl/formatting/format.hpp" namespace asl { diff --git a/asl/status_or.hpp b/asl/types/status_or.hpp similarity index 97% rename from asl/status_or.hpp rename to asl/types/status_or.hpp index ec76e47..07cfd7f 100644 --- a/asl/status_or.hpp +++ b/asl/types/status_or.hpp @@ -1,8 +1,8 @@ #pragma once -#include "asl/status.hpp" -#include "asl/maybe_uninit.hpp" -#include "asl/hash.hpp" +#include "asl/types/status.hpp" +#include "asl/types/maybe_uninit.hpp" +#include "asl/hashing/hash.hpp" namespace asl { diff --git a/asl/tests/status_or_tests.cpp b/asl/types/status_or_tests.cpp similarity index 96% rename from asl/tests/status_or_tests.cpp rename to asl/types/status_or_tests.cpp index 2f3f475..81a2b19 100644 --- a/asl/tests/status_or_tests.cpp +++ b/asl/types/status_or_tests.cpp @@ -1,6 +1,6 @@ -#include "asl/status_or.hpp" +#include "asl/types/status_or.hpp" #include "asl/testing/testing.hpp" -#include "asl/tests/test_types.hpp" +#include "asl/tests/types.hpp" static_assert(asl::copyable>); static_assert(asl::moveable>); diff --git a/asl/tests/status_tests.cpp b/asl/types/status_tests.cpp similarity index 95% rename from asl/tests/status_tests.cpp rename to asl/types/status_tests.cpp index a025f92..4c3579b 100644 --- a/asl/tests/status_tests.cpp +++ b/asl/types/status_tests.cpp @@ -1,7 +1,7 @@ -#include "asl/status.hpp" +#include "asl/types/status.hpp" #include "asl/testing/testing.hpp" -#include "asl/format.hpp" -#include "asl/string_builder.hpp" +#include "asl/formatting/format.hpp" +#include "asl/strings/string_builder.hpp" ASL_TEST(simple_ok) { diff --git a/todo.txt b/todo.txt index ffec3b3..2c010fa 100644 --- a/todo.txt +++ b/todo.txt @@ -1,2 +1 @@ warning compare with 0 in format_float.cpp -split asl into multiple sublibraries