From bde4398888d50cb58f067eeff2cdb9aa928fe7af Mon Sep 17 00:00:00 2001 From: chatlanin Date: Sun, 27 Mar 2022 22:23:36 +0300 Subject: [PATCH] rebuild project --- bin/main.cpp | 242 ++++++++++++++++++------------------ bin/meson.build | 9 +- meson.build | 14 --- src/concepts/meson.build | 13 -- src/container/container.cpp | 5 - src/container/meson.build | 13 -- src/iterators/meson.build | 13 -- src/math/meson.build | 13 -- src/meson.build | 20 +-- src/range/meson.build | 13 -- src/range/range.cpp | 5 - src/utils/meson.build | 13 -- src/view/meson.build | 13 -- tests/meson.build | 4 +- 14 files changed, 137 insertions(+), 253 deletions(-) delete mode 100644 src/concepts/meson.build delete mode 100644 src/container/container.cpp delete mode 100644 src/container/meson.build delete mode 100644 src/iterators/meson.build delete mode 100644 src/math/meson.build delete mode 100644 src/range/meson.build delete mode 100644 src/range/range.cpp delete mode 100644 src/utils/meson.build delete mode 100644 src/view/meson.build diff --git a/bin/main.cpp b/bin/main.cpp index d0ed705..9750852 100644 --- a/bin/main.cpp +++ b/bin/main.cpp @@ -25,128 +25,128 @@ int f(int a) int main(int argc, char *argv[]) { - // {// ex: string::split_str - // std::string str { "asdf,qwer,zxcv" }; - // hack::string::v_str v = hack::string::split_str(str, ','); - // for (const auto& c : v) hack::log()(c); - // } - // - // {// ex: renge::within - // hack::log()(hack::range::within(12, 34, 12, 23, 31, 17, 22, 33)); - // } - // - // {// ex: container::vector_multiset - // std::vector v; - // hack::container::vector_multiset(v, "asdf", "qwer", "zcv"); - // for(const auto& c : v) std::cout << c << std::endl; - // } - // - // {// ex: container::set_multiset - // std::set s; - // hack::container::set_multiset(s, 1, 2, 3, 3, 2, 1); - // for(const auto& c : s) std::cout << c << std::endl; - // } - // - // {// ex: logger::log - // hack::log()(1234, "run in main", 1234); - // hack::warn(" # ")(1234, "run in main", 1234); - // hack::error(" - ")(1234, "run in main", 1234); - // - // std::string str { "hi" }; - // hack::log()(str); - // - // std::vector vs { "asdf", "qwer", "zxcv" }; - // hack::log()("vector", vs, 1, 2, 'a'); - // - // std::list ls { "asdf", "qwer", "zxcv" }; - // hack::log()(vs, ls); - // - // std::map m { { 1, "asdf" }, { 2, "qwer" }, { 3, "zxcv" } }; - // hack::log()(vs, ls, m); - // - // std::tuple tp { 1, "tuple test", false }; - // hack::log()(tp); - // } - // - // {// ex: container::matches - // std::vector v { 1, 2, 3, 4, 5, 6, 7, 8, 9 }; - // hack::log()(hack::container::matches(v, 2, 5, 4, 12)); - // } - // - // {// ex: container::vector_remove_at - // std::vector v { 1, 2, 3, 4, 5, 6, 7, 8, 9 }; - // hack::container::vector_remove_at(v, 3); - // hack::log()(v); - // } + {// ex: string::split_str + std::string str { "asdf,qwer,zxcv" }; + hack::string::v_str v = hack::string::split_str(str, ','); + for (const auto& c : v) hack::log()(c); + } - // {// ex: math::matrix - // hack::matrix m_int; - // hack::matrix m_int_c { { 2, 3, 4, 123 }, { 0, 2, 4, 555 } }; - // hack::matrix m_float; - // - // m_int[0][0][0] = 123; - // m_int[0][0][1] = 23; - // m_int[0][0][2] = 43; - // m_int_c[0][0][0] = 123; - // m_float[0][0][0] = 123.123; - // - // auto i = m_int[0][0][0]; - // auto f = m_float[0][0][0]; - // - // hack::log()("m_int", i); - // hack::log()("m_float", f); - // hack::log()("empty", m_float[123][22][33]); - // - // hack::log("")("compare (true): ", m_int == m_int_c); - // hack::log("")("compare (false): ", m_int == m_float); - // hack::log("")(m_int); - // hack::log("")(m_int_c); - // - // auto m_moved {std::forward>(m_int_c)}; - // hack::log("")("moved data: ", m_moved); - // - // m_int = std::forward>(m_int_c); - // hack::log("")("moved data: ", m_int); - // - // hack::matrix m_int_d = m_int; - // hack::log("")("copy data: ", m_int_d); - // - // hack::matrix m_int_cd { { 2, 3, 4, 3 }, { 0, 2, 4, 5 } }; - // hack::log("")("copy data: ", m_int_cd); - // m_int_cd = m_int; - // hack::log("")("copy data: ", m_int_cd); - // } - // - // {// ex: math::vector - // hack::vector v3_1 { 8, 4, 9, }; - // hack::vector v3_2 { 1, 2, 3, }; - // hack::log()(v3_1.get_value()); - // hack::log()(v3_2.get_value()); - // - // v3_1 = v3_2; - // - // hack::log()(v3_1.get_value()); - // hack::log()(v3_2.get_value()); - // - // hack::log()("length 3", v3_2.length()); - // - // hack::vector v2_1 { 11, 22 }; - // hack::log()("length 2", v2_1.length()); - // - // hack::vector lerp_1 { 1, 2, 3 }; - // hack::vector lerp_2 { 5, 6, 7 }; - // hack::log()("lerp", lerp_1.lerp(lerp_2, 0.75f)); - // - // auto [x, y, z] = lerp_1.get_value(); - // hack::log()("get", x, y, z); - // hack::log()("get", lerp_1.x()); - // } - // - // {// ex: utils::func_memory - // auto cach_f = hack::utils::func_memory(f); - // hack::log()("result 1", cach_f(12)); - // hack::log()("result 2", cach_f(12)); - // } + {// ex: renge::within + hack::log()(hack::range::within(12, 34, 12, 23, 31, 17, 22, 33)); + } + + {// ex: container::vector_multiset + std::vector v; + hack::container::vector_multiset(v, "asdf", "qwer", "zcv"); + for(const auto& c : v) std::cout << c << std::endl; + } + + {// ex: container::set_multiset + std::set s; + hack::container::set_multiset(s, 1, 2, 3, 3, 2, 1); + for(const auto& c : s) std::cout << c << std::endl; + } + + {// ex: logger::log + hack::log()(1234, "run in main", 1234); + hack::warn(" # ")(1234, "run in main", 1234); + hack::error(" - ")(1234, "run in main", 1234); + + std::string str { "hi" }; + hack::log()(str); + + std::vector vs { "asdf", "qwer", "zxcv" }; + hack::log()("vector", vs, 1, 2, 'a'); + + std::list ls { "asdf", "qwer", "zxcv" }; + hack::log()(vs, ls); + + std::map m { { 1, "asdf" }, { 2, "qwer" }, { 3, "zxcv" } }; + hack::log()(vs, ls, m); + + std::tuple tp { 1, "tuple test", false }; + hack::log()(tp); + } + + {// ex: container::matches + std::vector v { 1, 2, 3, 4, 5, 6, 7, 8, 9 }; + hack::log()(hack::container::matches(v, 2, 5, 4, 12)); + } + + {// ex: container::vector_remove_at + std::vector v { 1, 2, 3, 4, 5, 6, 7, 8, 9 }; + hack::container::vector_remove_at(v, 3); + hack::log()(v); + } + + {// ex: math::matrix + hack::matrix m_int; + hack::matrix m_int_c { { 2, 3, 4, 123 }, { 0, 2, 4, 555 } }; + hack::matrix m_float; + + m_int[0][0][0] = 123; + m_int[0][0][1] = 23; + m_int[0][0][2] = 43; + m_int_c[0][0][0] = 123; + m_float[0][0][0] = 123.123; + + auto i = m_int[0][0][0]; + auto f = m_float[0][0][0]; + + hack::log()("m_int", i); + hack::log()("m_float", f); + hack::log()("empty", m_float[123][22][33]); + + hack::log("")("compare (true): ", m_int == m_int_c); + hack::log("")("compare (false): ", m_int == m_float); + hack::log("")(m_int); + hack::log("")(m_int_c); + + auto m_moved {std::forward>(m_int_c)}; + hack::log("")("moved data: ", m_moved); + + m_int = std::forward>(m_int_c); + hack::log("")("moved data: ", m_int); + + hack::matrix m_int_d = m_int; + hack::log("")("copy data: ", m_int_d); + + hack::matrix m_int_cd { { 2, 3, 4, 3 }, { 0, 2, 4, 5 } }; + hack::log("")("copy data: ", m_int_cd); + m_int_cd = m_int; + hack::log("")("copy data: ", m_int_cd); + } + + {// ex: math::vector + hack::vector v3_1 { 8, 4, 9, }; + hack::vector v3_2 { 1, 2, 3, }; + hack::log()(v3_1.get_value()); + hack::log()(v3_2.get_value()); + + v3_1 = v3_2; + + hack::log()(v3_1.get_value()); + hack::log()(v3_2.get_value()); + + hack::log()("length 3", v3_2.length()); + + hack::vector v2_1 { 11, 22 }; + hack::log()("length 2", v2_1.length()); + + hack::vector lerp_1 { 1, 2, 3 }; + hack::vector lerp_2 { 5, 6, 7 }; + hack::log()("lerp", lerp_1.lerp(lerp_2, 0.75f)); + + auto [x, y, z] = lerp_1.get_value(); + hack::log()("get", x, y, z); + hack::log()("get", lerp_1.x()); + } + + {// ex: utils::func_memory + auto cach_f = hack::utils::func_memory(f); + hack::log()("result 1", cach_f(12)); + hack::log()("result 2", cach_f(12)); + } {// ex: string::str_concat std::string name = "tro"; diff --git a/bin/meson.build b/bin/meson.build index 07f99b3..fb156bf 100644 --- a/bin/meson.build +++ b/bin/meson.build @@ -1,11 +1,4 @@ -deps += view_dep -deps += concepts_dep -deps += utils_dep -deps += iterators_dep -deps += string_dep -deps += range_dep -deps += container_dep -deps += logger_dep +deps += hack_dep executable( 'hack', 'main.cpp', diff --git a/meson.build b/meson.build index cf5c2f6..319cea4 100644 --- a/meson.build +++ b/meson.build @@ -24,21 +24,7 @@ endif args = [] deps = [] - inc = [] -inc += include_directories('.') - -conf = configuration_data() -check_headers = [ - ['ncurses.h', 'HAVE_NCURSES_H'], - ['curses.h', 'HAVE_CURSES_H'], -] - -foreach h : check_headers - if compiler.has_header(h.get(0)) - conf.set(h.get(1), 1) - endif -endforeach subdir('src') subdir('bin') diff --git a/src/concepts/meson.build b/src/concepts/meson.build deleted file mode 100644 index 1c8b9d1..0000000 --- a/src/concepts/meson.build +++ /dev/null @@ -1,13 +0,0 @@ -headers = ['concepts.hpp'] -sources = [] - -lib = library( - 'concepts', - include_directories : inc, - sources: [headers, sources] -) - -concepts_dep = declare_dependency( - include_directories: inc, - link_with: lib -) diff --git a/src/container/container.cpp b/src/container/container.cpp deleted file mode 100644 index b9b67f4..0000000 --- a/src/container/container.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#include "container.hpp" - -namespace hack::container -{ -} diff --git a/src/container/meson.build b/src/container/meson.build deleted file mode 100644 index 1375212..0000000 --- a/src/container/meson.build +++ /dev/null @@ -1,13 +0,0 @@ -headers = ['container.hpp'] -sources = ['container.cpp'] - -lib = library( - 'container', - include_directories : inc, - sources: [headers, sources] -) - -container_dep = declare_dependency( - include_directories: inc, - link_with: lib -) diff --git a/src/iterators/meson.build b/src/iterators/meson.build deleted file mode 100644 index c554717..0000000 --- a/src/iterators/meson.build +++ /dev/null @@ -1,13 +0,0 @@ -headers = ['sequence_ostream_iterator.hpp', 'associative_ostream_iterator.hpp'] -sources = [] - -lib = library( - 'iterators', - include_directories : inc, - sources: [headers, sources] -) - -iterators_dep = declare_dependency( - include_directories: inc, - link_with: lib -) diff --git a/src/math/meson.build b/src/math/meson.build deleted file mode 100644 index 07f548d..0000000 --- a/src/math/meson.build +++ /dev/null @@ -1,13 +0,0 @@ -headers = ['vector.hpp', 'matrix.hpp'] -sources = [] - -lib = library( - 'math', - include_directories : inc, - sources: [headers, sources] -) - -math_dep = declare_dependency( - include_directories: inc, - link_with: lib -) diff --git a/src/meson.build b/src/meson.build index f91c050..1642bd7 100644 --- a/src/meson.build +++ b/src/meson.build @@ -1,11 +1,17 @@ inc += include_directories('.') -subdir('view') -subdir('concepts') -subdir('utils') -subdir('iterators') subdir('string') -subdir('range') -subdir('container') subdir('logger') -subdir('math') + +deps += string_dep +deps += logger_dep + +lib = library( + 'hack', + include_directories : inc, +) + +hack_dep = declare_dependency( + include_directories: inc, + link_with: lib +) diff --git a/src/range/meson.build b/src/range/meson.build deleted file mode 100644 index 0a870ad..0000000 --- a/src/range/meson.build +++ /dev/null @@ -1,13 +0,0 @@ -headers = ['range.hpp'] -sources = ['range.cpp'] - -lib = library( - 'range', - include_directories : inc, - sources: [headers, sources] -) - -range_dep = declare_dependency( - include_directories: inc, - link_with: lib -) diff --git a/src/range/range.cpp b/src/range/range.cpp deleted file mode 100644 index 70dd2e8..0000000 --- a/src/range/range.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#include "range.hpp" - -namespace hack::renge -{ -} diff --git a/src/utils/meson.build b/src/utils/meson.build deleted file mode 100644 index 0945475..0000000 --- a/src/utils/meson.build +++ /dev/null @@ -1,13 +0,0 @@ -headers = ['utils.hpp'] -sources = [] - -lib = library( - 'utils', - include_directories : inc, - sources: [headers, sources] -) - -utils_dep = declare_dependency( - include_directories: inc, - link_with: lib -) diff --git a/src/view/meson.build b/src/view/meson.build deleted file mode 100644 index c24c709..0000000 --- a/src/view/meson.build +++ /dev/null @@ -1,13 +0,0 @@ -headers = ['color.hpp'] -sources = [] - -lib = library( - 'view', - include_directories : inc, - sources: [headers, sources] -) - -view_dep = declare_dependency( - include_directories: inc, - link_with: lib -) diff --git a/tests/meson.build b/tests/meson.build index 24775e3..2bdafb8 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -15,7 +15,7 @@ test( executable( 'within', 'range.cpp', - dependencies: [ range_dep, gtest_dep ] + dependencies: [ hack_dep, gtest_dep ] ) ) @@ -24,6 +24,6 @@ test( executable( 'container', 'container.cpp', - dependencies: [ range_dep, gtest_dep ] + dependencies: [ hack_dep, gtest_dep ] ) )