Let’s see how it goes with a very flat hierarchy and no .h extension.wip/core-clipp
@@ -12,6 +12,5 @@ | |||||
#pragma once | #pragma once | ||||
#include "private/string.h" | |||||
#include "private/containers.h" | |||||
#include "private/types/bigint.h" | |||||
@@ -0,0 +1,16 @@ | |||||
// | |||||
// Lol Engine | |||||
// | |||||
// Copyright © 2010—2020 Sam Hocevar <sam@hocevar.net> | |||||
// | |||||
// Lol Engine is free software. It comes without any warranty, to | |||||
// the extent permitted by applicable law. You can redistribute it | |||||
// and/or modify it under the terms of the Do What the Fuck You Want | |||||
// to Public License, Version 2, as published by the WTFPL Task Force. | |||||
// See http://www.wtfpl.net/ for more details. | |||||
// | |||||
#pragma once | |||||
#include "private/image/color.h" | |||||
@@ -13,9 +13,9 @@ | |||||
#pragma once | #pragma once | ||||
// | // | ||||
// The Portable File Dialogs classes | |||||
// ————————————————————————————————— | |||||
// The Portable File Dialogs | |||||
// ————————————————————————— | |||||
// | // | ||||
#include "../3rdparty/portable-file-dialogs/portable-file-dialogs.h" | |||||
#include "3rdparty/portable-file-dialogs/portable-file-dialogs.h" | |||||
@@ -0,0 +1,16 @@ | |||||
// | |||||
// Lol Engine | |||||
// | |||||
// Copyright © 2010—2020 Sam Hocevar <sam@hocevar.net> | |||||
// | |||||
// Lol Engine is free software. It comes without any warranty, to | |||||
// the extent permitted by applicable law. You can redistribute it | |||||
// and/or modify it under the terms of the Do What the Fuck You Want | |||||
// to Public License, Version 2, as published by the WTFPL Task Force. | |||||
// See http://www.wtfpl.net/ for more details. | |||||
// | |||||
#pragma once | |||||
#include "private/sys/getopt.h" | |||||
@@ -0,0 +1,16 @@ | |||||
// | |||||
// Lol Engine | |||||
// | |||||
// Copyright © 2010—2020 Sam Hocevar <sam@hocevar.net> | |||||
// | |||||
// Lol Engine is free software. It comes without any warranty, to | |||||
// the extent permitted by applicable law. You can redistribute it | |||||
// and/or modify it under the terms of the Do What the Fuck You Want | |||||
// to Public License, Version 2, as published by the WTFPL Task Force. | |||||
// See http://www.wtfpl.net/ for more details. | |||||
// | |||||
#pragma once | |||||
#include "private/types/half.h" | |||||
@@ -0,0 +1,19 @@ | |||||
// | |||||
// Lol Engine | |||||
// | |||||
// Copyright © 2010—2020 Sam Hocevar <sam@hocevar.net> | |||||
// | |||||
// Lol Engine is free software. It comes without any warranty, to | |||||
// the extent permitted by applicable law. You can redistribute it | |||||
// and/or modify it under the terms of the Do What the Fuck You Want | |||||
// to Public License, Version 2, as published by the WTFPL Task Force. | |||||
// See http://www.wtfpl.net/ for more details. | |||||
// | |||||
#pragma once | |||||
#include "private/math/constants.h" | |||||
#include "private/math/functions.h" | |||||
#include "private/math/rand.h" | |||||
#include "private/math/polynomial.h" | |||||
@@ -17,6 +17,7 @@ | |||||
// ——————————————— | // ——————————————— | ||||
// | // | ||||
#include "private/perlin.h" | |||||
#include "private/simplex.h" | |||||
#include "private/math/gradient.h" | |||||
#include "private/math/perlin.h" | |||||
#include "private/math/simplex.h" | |||||
@@ -24,10 +24,5 @@ | |||||
# define _WIN32_WINNT 0x0602 | # define _WIN32_WINNT 0x0602 | ||||
#endif | #endif | ||||
//namespace lol | |||||
//{ | |||||
#include "../3rdparty/pegtl/include/tao/pegtl.hpp" | |||||
//} // namespace lol | |||||
#include "3rdparty/pegtl/include/tao/pegtl.hpp" | |||||
@@ -18,7 +18,7 @@ | |||||
namespace lol | namespace lol | ||||
{ | { | ||||
namespace os | |||||
namespace sys | |||||
{ | { | ||||
static inline std::string getenv(std::string const &var) | static inline std::string getenv(std::string const &var) | ||||
@@ -39,14 +39,6 @@ static inline std::string getenv(std::string const &var) | |||||
return std::string(); | return std::string(); | ||||
} | } | ||||
// A handy endianness test function | |||||
static inline bool is_big_endian() | |||||
{ | |||||
union { int i; char c; } u; | |||||
u.i = 1; | |||||
return u.c == 0; | |||||
} | |||||
} // namespace os | } // namespace os | ||||
} // namespace lol | } // namespace lol |
@@ -0,0 +1,31 @@ | |||||
// | |||||
// Lol Engine | |||||
// | |||||
// Copyright © 2010—2020 Sam Hocevar <sam@hocevar.net> | |||||
// | |||||
// Lol Engine is free software. It comes without any warranty, to | |||||
// the extent permitted by applicable law. You can redistribute it | |||||
// and/or modify it under the terms of the Do What the Fuck You Want | |||||
// to Public License, Version 2, as published by the WTFPL Task Force. | |||||
// See http://www.wtfpl.net/ for more details. | |||||
// | |||||
#pragma once | |||||
namespace lol | |||||
{ | |||||
namespace sys | |||||
{ | |||||
// A handy endianness test function | |||||
static inline bool is_big_endian() | |||||
{ | |||||
union { int i; char c; } u; | |||||
u.i = 1; | |||||
return u.c == 0; | |||||
} | |||||
} // namespace os | |||||
} // namespace lol |
@@ -19,7 +19,7 @@ | |||||
// Contains some utilities to work with std::string objects. | // Contains some utilities to work with std::string objects. | ||||
// | // | ||||
#include "features.h" | |||||
#include "../features.h" | |||||
#include <vector> // std::vector | #include <vector> // std::vector | ||||
#include <string> // std::basic_string | #include <string> // std::basic_string | ||||
@@ -149,7 +149,7 @@ std::basic_string<T> toupper(T const *s) | |||||
// Format a string, printf-style | // Format a string, printf-style | ||||
template<typename T = char> | template<typename T = char> | ||||
std::basic_string<T> vformat(char const *format, va_list ap) | |||||
std::basic_string<T> vformat(char const *fmt, va_list ap) | |||||
{ | { | ||||
va_list ap2; | va_list ap2; | ||||
#if defined va_copy || !defined _MSC_VER | #if defined va_copy || !defined _MSC_VER | ||||
@@ -161,7 +161,7 @@ std::basic_string<T> vformat(char const *format, va_list ap) | |||||
// vsnprintf() tells us how many characters we need, not counting | // vsnprintf() tells us how many characters we need, not counting | ||||
// the terminating null character. | // the terminating null character. | ||||
size_t needed = vsnprintf(nullptr, 0, format, ap2); | |||||
size_t needed = vsnprintf(nullptr, 0, fmt, ap2); | |||||
#if defined va_copy || !defined _MSC_VER | #if defined va_copy || !defined _MSC_VER | ||||
// do not call va_end() if va_copy() wasn't called. | // do not call va_end() if va_copy() wasn't called. | ||||
@@ -170,17 +170,17 @@ std::basic_string<T> vformat(char const *format, va_list ap) | |||||
std::string ret; | std::string ret; | ||||
ret.resize(needed); | ret.resize(needed); | ||||
vsnprintf(&ret[0], needed + 1, format, ap); | |||||
vsnprintf(&ret[0], needed + 1, fmt, ap); | |||||
return ret; | return ret; | ||||
} | } | ||||
template<typename T = char> lol_attr_printf_format(1, 2) | template<typename T = char> lol_attr_printf_format(1, 2) | ||||
std::basic_string<T> format(T const *format, ...) | |||||
std::basic_string<T> format(T const *fmt, ...) | |||||
{ | { | ||||
va_list ap; | va_list ap; | ||||
va_start(ap, format); | |||||
std::string ret = vformat(format, ap); | |||||
va_start(ap, fmt); | |||||
std::string ret = vformat(fmt, ap); | |||||
va_end(ap); | va_end(ap); | ||||
return ret; | return ret; | ||||
} | } |
@@ -18,9 +18,9 @@ | |||||
// Provides various color conversion routines. | // Provides various color conversion routines. | ||||
// | // | ||||
#include <lol/math/functions.h> // FIXME: try to remove this | |||||
#include <lol/math/vector.h> // vec_t | |||||
#include <lol/math/transform.h> // mat_t | |||||
#include <lol/math> | |||||
#include <lol/vector> // vec_t | |||||
#include <lol/transform> // mat_t | |||||
#include <cmath> // std::fabs | #include <cmath> // std::fabs | ||||
#include <algorithm> // std::min | #include <algorithm> // std::min | ||||
@@ -362,7 +362,7 @@ public: | |||||
using color = color_t<float>; | using color = color_t<float>; | ||||
} /* namespace lol */ | |||||
} // namespace lol | |||||
#include "private/color.ipp" | |||||
#include "private/cie1931.ipp" | |||||
#include "color.ipp" | |||||
#include "cie1931.ipp" |
@@ -17,8 +17,6 @@ | |||||
// ——————————————————————— | // ——————————————————————— | ||||
// | // | ||||
#include <lol/math/constants.h> | |||||
#include <cmath> | #include <cmath> | ||||
#include <cstdio> | #include <cstdio> | ||||
#include <algorithm> | #include <algorithm> | ||||
@@ -110,6 +108,17 @@ LOL_FORWARD_FP_1_ARG(round) | |||||
return degrees * (LD_PI / 180.0L); | return degrees * (LD_PI / 180.0L); | ||||
} | } | ||||
// Integer version of radians() for convenience | |||||
[[nodiscard]] static inline double radians(int32_t degrees) | |||||
{ | |||||
return radians(double(degrees)); | |||||
} | |||||
[[nodiscard]] static inline double radians(int64_t degrees) | |||||
{ | |||||
return radians(double(degrees)); | |||||
} | |||||
// Interpolation | // Interpolation | ||||
template<typename T, typename T2 = LOL_T_FLOATING_POINT> | template<typename T, typename T2 = LOL_T_FLOATING_POINT> | ||||
[[nodiscard]] static inline T2 mix(T a, T b, T x) | [[nodiscard]] static inline T2 mix(T a, T b, T x) |
@@ -14,11 +14,10 @@ | |||||
#pragma once | #pragma once | ||||
#include <lol/math/vector.h> // vec_t | |||||
#include <lol/math/rand.h> // rand() | |||||
#include <array> // std::array | |||||
#include <algorithm> // std::min | |||||
#include <lol/vector> // lol::vec_t | |||||
#include <lol/math> // lol::rand() | |||||
#include <array> // std::array | |||||
#include <algorithm> // std::min | |||||
namespace lol | namespace lol | ||||
{ | { |
@@ -18,10 +18,9 @@ | |||||
// | // | ||||
#include "ops.h" | #include "ops.h" | ||||
#include <lol/math/vector.h> | |||||
#include <ostream> // std::ostream | |||||
#include <cmath> // std::fabs | |||||
#include <lol/vector> // lol::vec_t | |||||
#include <ostream> // std::ostream | |||||
#include <cmath> // std::fabs | |||||
#if _WIN32 | #if _WIN32 | ||||
# pragma push_macro("near") | # pragma push_macro("near") |
@@ -14,7 +14,7 @@ | |||||
#pragma once | #pragma once | ||||
#include <lol/math/functions.h> // for clamp() | |||||
#include "functions.h" // for clamp() | |||||
#include "gradient.h" | #include "gradient.h" | ||||
#include <cmath> // std::sqrt | #include <cmath> // std::sqrt |
@@ -19,7 +19,7 @@ | |||||
// added guarantee that the leading coefficient is always non-zero. | // added guarantee that the leading coefficient is always non-zero. | ||||
// | // | ||||
#include "../base/private/features.h" | |||||
#include "../features.h" | |||||
#include <vector> // std::vector | #include <vector> // std::vector | ||||
#include <algorithm> // std::min | #include <algorithm> // std::min |
@@ -17,8 +17,6 @@ | |||||
// ———————————————————————————— | // ———————————————————————————— | ||||
// | // | ||||
#include "../base/private/features.h" | |||||
#include <cassert> | #include <cassert> | ||||
#include <cstdlib> | #include <cstdlib> | ||||
#include <stdint.h> | #include <stdint.h> |
@@ -16,12 +16,11 @@ | |||||
#include "gradient.h" | #include "gradient.h" | ||||
#include <lol/math/vector.h> // vec_t | |||||
#include <lol/math/transform.h> // mat_t | |||||
#include <vector> // std::vector | |||||
#include <cmath> // std::fabs | |||||
#include <algorithm> // std::min, std::max | |||||
#include <lol/vector> // lol::vec_t | |||||
#include <lol/transform> // lol::mat_t | |||||
#include <vector> // std::vector | |||||
#include <cmath> // std::fabs | |||||
#include <algorithm> // std::min, std::max | |||||
namespace lol | namespace lol | ||||
{ | { |
@@ -17,13 +17,12 @@ | |||||
// ——————————————————————————————————————————————————— | // ——————————————————————————————————————————————————— | ||||
// | // | ||||
#include <lol/math/private/ops.h> | |||||
#include <lol/math/vector.h> | |||||
#include <lol/vector> | |||||
#include <ostream> // std::ostream | #include <ostream> // std::ostream | ||||
#include <cmath> // std::atan2, std::sqrt | #include <cmath> // std::atan2, std::sqrt | ||||
#include "private/matrix.h" | |||||
#include "ops.h" | |||||
#include "matrix.h" | |||||
namespace lol | namespace lol | ||||
{ | { | ||||
@@ -591,6 +590,6 @@ typedef imat4x3 int4x3; | |||||
} // namespace lol | } // namespace lol | ||||
#include "private/matrix.ipp" | |||||
#include "private/transform.ipp" | |||||
#include "matrix.ipp" | |||||
#include "transform.ipp" | |||||
@@ -26,7 +26,7 @@ | |||||
// FIXME: get rid of this, too | // FIXME: get rid of this, too | ||||
#include <../legacy/lol/base/types.h> | #include <../legacy/lol/base/types.h> | ||||
#include "private/ops.h" | |||||
#include "ops.h" | |||||
#if _MSC_VER | #if _MSC_VER | ||||
# pragma push_macro("min") | # pragma push_macro("min") | ||||
@@ -1437,7 +1437,7 @@ typedef ivec12 int12; | |||||
} // namespace lol | } // namespace lol | ||||
#include "private/vector.ipp" | |||||
#include "vector.ipp" | |||||
#if _MSC_VER | #if _MSC_VER | ||||
# pragma pop_macro("min") | # pragma pop_macro("min") |
@@ -12,7 +12,7 @@ | |||||
#pragma once | #pragma once | ||||
#include <lol/base/private/string.h> // lol::format | |||||
#include "../base/string.h" // lol::format | |||||
namespace lol | namespace lol | ||||
{ | { |
@@ -17,7 +17,7 @@ | |||||
// ————————————————————— | // ————————————————————— | ||||
// | // | ||||
#include <lol/base/core.h> // os::getenv | |||||
#include "../base/env.h" // sys::getenv | |||||
#include <functional> // std::function | #include <functional> // std::function | ||||
#include <thread> | #include <thread> | ||||
@@ -73,7 +73,7 @@ public: | |||||
// FIXME: move to os::has_threads? | // FIXME: move to os::has_threads? | ||||
static bool has_threads() | static bool has_threads() | ||||
{ | { | ||||
static bool const disable_threads = os::getenv("LOL_NOTHREADS").size() > 0; | |||||
static bool const disable_threads = sys::getenv("LOL_NOTHREADS").size() > 0; | |||||
#if defined __EMSCRIPTEN__ && !defined __EMSCRIPTEN_PTHREADS__ | #if defined __EMSCRIPTEN__ && !defined __EMSCRIPTEN_PTHREADS__ | ||||
// For some reason hardware_concurrency() will return the actual number | // For some reason hardware_concurrency() will return the actual number | ||||
// of threads/cores even though the system cannot spawn threads. | // of threads/cores even though the system cannot spawn threads. |
@@ -22,7 +22,8 @@ | |||||
#include <stdint.h> // uint32_t etc. | #include <stdint.h> // uint32_t etc. | ||||
// FIXME: get rid of this | // FIXME: get rid of this | ||||
#include <lol/math/functions.h> | |||||
#include "../math/constants.h" | |||||
#include "../math/functions.h" | |||||
namespace lol | namespace lol | ||||
{ | { |
@@ -17,7 +17,7 @@ | |||||
// ————————————————————— | // ————————————————————— | ||||
// | // | ||||
#include "../base/private/features.h" | |||||
#include "../features.h" | |||||
#include <limits> // std::numeric_limits | #include <limits> // std::numeric_limits | ||||
#include <vector> // std::vector | #include <vector> // std::vector | ||||
@@ -265,7 +265,7 @@ typedef real_t<uint32_t> real; | |||||
} // namespace lol | } // namespace lol | ||||
#include "private/real.ipp" | |||||
#include "real.ipp" | |||||
#if _MSC_VER | #if _MSC_VER | ||||
# pragma pop_macro("min") | # pragma pop_macro("min") |
@@ -0,0 +1,16 @@ | |||||
// | |||||
// Lol Engine | |||||
// | |||||
// Copyright © 2010—2020 Sam Hocevar <sam@hocevar.net> | |||||
// | |||||
// Lol Engine is free software. It comes without any warranty, to | |||||
// the extent permitted by applicable law. You can redistribute it | |||||
// and/or modify it under the terms of the Do What the Fuck You Want | |||||
// to Public License, Version 2, as published by the WTFPL Task Force. | |||||
// See http://www.wtfpl.net/ for more details. | |||||
// | |||||
#pragma once | |||||
#include "private/types/real.h" | |||||
@@ -0,0 +1,16 @@ | |||||
// | |||||
// Lol Engine | |||||
// | |||||
// Copyright © 2010—2020 Sam Hocevar <sam@hocevar.net> | |||||
// | |||||
// Lol Engine is free software. It comes without any warranty, to | |||||
// the extent permitted by applicable law. You can redistribute it | |||||
// and/or modify it under the terms of the Do What the Fuck You Want | |||||
// to Public License, Version 2, as published by the WTFPL Task Force. | |||||
// See http://www.wtfpl.net/ for more details. | |||||
// | |||||
#pragma once | |||||
#include "private/sys/threading.h" | |||||
@@ -0,0 +1,16 @@ | |||||
// | |||||
// Lol Engine | |||||
// | |||||
// Copyright © 2010—2020 Sam Hocevar <sam@hocevar.net> | |||||
// | |||||
// Lol Engine is free software. It comes without any warranty, to | |||||
// the extent permitted by applicable law. You can redistribute it | |||||
// and/or modify it under the terms of the Do What the Fuck You Want | |||||
// to Public License, Version 2, as published by the WTFPL Task Force. | |||||
// See http://www.wtfpl.net/ for more details. | |||||
// | |||||
#pragma once | |||||
#include "private/math/transform.h" | |||||
@@ -0,0 +1,16 @@ | |||||
// | |||||
// Lol Engine | |||||
// | |||||
// Copyright © 2010—2020 Sam Hocevar <sam@hocevar.net> | |||||
// | |||||
// Lol Engine is free software. It comes without any warranty, to | |||||
// the extent permitted by applicable law. You can redistribute it | |||||
// and/or modify it under the terms of the Do What the Fuck You Want | |||||
// to Public License, Version 2, as published by the WTFPL Task Force. | |||||
// See http://www.wtfpl.net/ for more details. | |||||
// | |||||
#pragma once | |||||
#include "private/lolunit.h" | |||||
@@ -0,0 +1,20 @@ | |||||
// | |||||
// Lol Engine | |||||
// | |||||
// Copyright © 2010—2020 Sam Hocevar <sam@hocevar.net> | |||||
// | |||||
// Lol Engine is free software. It comes without any warranty, to | |||||
// the extent permitted by applicable law. You can redistribute it | |||||
// and/or modify it under the terms of the Do What the Fuck You Want | |||||
// to Public License, Version 2, as published by the WTFPL Task Force. | |||||
// See http://www.wtfpl.net/ for more details. | |||||
// | |||||
#pragma once | |||||
#include "private/features.h" | |||||
#include "private/base/env.h" | |||||
#include "private/base/string.h" | |||||
#include "private/base/containers.h" | |||||
#include "private/base/misc.h" | |||||
@@ -0,0 +1,16 @@ | |||||
// | |||||
// Lol Engine | |||||
// | |||||
// Copyright © 2010—2020 Sam Hocevar <sam@hocevar.net> | |||||
// | |||||
// Lol Engine is free software. It comes without any warranty, to | |||||
// the extent permitted by applicable law. You can redistribute it | |||||
// and/or modify it under the terms of the Do What the Fuck You Want | |||||
// to Public License, Version 2, as published by the WTFPL Task Force. | |||||
// See http://www.wtfpl.net/ for more details. | |||||
// | |||||
#pragma once | |||||
#include "private/math/vector.h" | |||||
@@ -14,12 +14,12 @@ | |||||
#pragma once | #pragma once | ||||
#include <lol/base/array.h> | #include <lol/base/array.h> | ||||
#include <lol/math/vector.h> // vec_t | |||||
#include <lol/math/transform.h> // mat_t | |||||
#include <lol/vector> // vec_t | |||||
#include <lol/transform> // mat_t | |||||
#include <lol/debug/lines.h> | #include <lol/debug/lines.h> | ||||
#include <lol/image/color.h> | |||||
#include <lol/color> | |||||
#include <cfloat> /* for FLT_MAX */ | |||||
#include <cfloat> // FLT_MAX | |||||
namespace lol | namespace lol | ||||
{ | { | ||||
@@ -18,7 +18,7 @@ | |||||
// | // | ||||
#include <../legacy/lol/base/types.h> | #include <../legacy/lol/base/types.h> | ||||
#include <lol/math/vector.h> | |||||
#include <lol/vector> | |||||
namespace lol | namespace lol | ||||
{ | { | ||||
@@ -20,12 +20,7 @@ | |||||
// A N-Dimensional array class allowing var[i][j][k]... indexing, | // A N-Dimensional array class allowing var[i][j][k]... indexing, | ||||
// | // | ||||
// | |||||
// XXX: This file is in lol/math/ instead of lol/base/ because it uses vec_t. | |||||
// | |||||
#include <lol/math/vector.h> // vec_t | |||||
#include <lol/vector> // lol::vec_t | |||||
#include <vector> // std::vector | #include <vector> // std::vector | ||||
#include <algorithm> // std::min | #include <algorithm> // std::min | ||||
#include <cstring> // memset | #include <cstring> // memset | ||||
@@ -19,9 +19,9 @@ | |||||
// | // | ||||
#include <lol/base/enum.h> | #include <lol/base/enum.h> | ||||
#include <lol/math/functions.h> // distance, clamp… | |||||
#include <lol/math/vector.h> // vec_t | |||||
#include <lol/math/transform.h> // mat_t | |||||
#include <lol/math> // distance, clamp… | |||||
#include <lol/vector> // vec_t | |||||
#include <lol/transform> // mat_t | |||||
#include <algorithm> | #include <algorithm> | ||||
#include <map> | #include <map> | ||||
@@ -12,7 +12,7 @@ | |||||
#pragma once | #pragma once | ||||
#include <../legacy/lol/math/functions.h> | |||||
#include <lol/math> | |||||
// | // | ||||
// Interpolator classes | // Interpolator classes | ||||
@@ -17,8 +17,7 @@ | |||||
// —————————————————————————————— | // —————————————————————————————— | ||||
// | // | ||||
#include <lol/math/functions.h> | |||||
#include <lol/math> // lol::lerp, lol::clamp | |||||
#include <cstdlib> | #include <cstdlib> | ||||
#include <stdint.h> | #include <stdint.h> | ||||