Ver código fonte

Big header refactor yet again.

Let’s see how it goes with a very flat hierarchy and no .h extension.
wip/core-clipp
Sam Hocevar 4 anos atrás
pai
commit
b85c7adfe6
49 arquivos alterados com 270 adições e 87 exclusões
  1. +1
    -2
      include/lol/bigint
  2. +16
    -0
      include/lol/color
  3. +3
    -3
      include/lol/dialogs
  4. +16
    -0
      include/lol/getopt
  5. +16
    -0
      include/lol/half
  6. +19
    -0
      include/lol/math
  7. +3
    -2
      include/lol/noise
  8. +1
    -6
      include/lol/pegtl
  9. +0
    -0
      include/lol/private/base/containers.h
  10. +1
    -9
      include/lol/private/base/env.h
  11. +31
    -0
      include/lol/private/base/misc.h
  12. +7
    -7
      include/lol/private/base/string.h
  13. +0
    -0
      include/lol/private/features.h
  14. +0
    -0
      include/lol/private/image/cie1931.ipp
  15. +6
    -6
      include/lol/private/image/color.h
  16. +0
    -0
      include/lol/private/image/color.ipp
  17. +0
    -0
      include/lol/private/lolunit.h
  18. +0
    -0
      include/lol/private/math/constants.h
  19. +11
    -2
      include/lol/private/math/functions.h
  20. +4
    -5
      include/lol/private/math/gradient.h
  21. +3
    -4
      include/lol/private/math/matrix.h
  22. +0
    -0
      include/lol/private/math/matrix.ipp
  23. +0
    -0
      include/lol/private/math/ops.h
  24. +1
    -1
      include/lol/private/math/perlin.h
  25. +1
    -1
      include/lol/private/math/polynomial.h
  26. +0
    -2
      include/lol/private/math/rand.h
  27. +5
    -6
      include/lol/private/math/simplex.h
  28. +5
    -6
      include/lol/private/math/transform.h
  29. +0
    -0
      include/lol/private/math/transform.ipp
  30. +2
    -2
      include/lol/private/math/vector.h
  31. +1
    -1
      include/lol/private/math/vector.ipp
  32. +0
    -0
      include/lol/private/sys/getopt.h
  33. +2
    -2
      include/lol/private/sys/threading.h
  34. +0
    -0
      include/lol/private/types/bigint.h
  35. +2
    -1
      include/lol/private/types/half.h
  36. +2
    -2
      include/lol/private/types/real.h
  37. +0
    -0
      include/lol/private/types/real.ipp
  38. +16
    -0
      include/lol/real
  39. +16
    -0
      include/lol/thread
  40. +16
    -0
      include/lol/transform
  41. +16
    -0
      include/lol/unit_test
  42. +20
    -0
      include/lol/utils
  43. +16
    -0
      include/lol/vector
  44. +4
    -4
      legacy/lol/algorithm/portal.h
  45. +1
    -1
      legacy/lol/image/pixel.h
  46. +1
    -6
      legacy/lol/math/arraynd.h
  47. +3
    -3
      legacy/lol/math/geometry.h
  48. +1
    -1
      legacy/lol/math/interp.h
  49. +1
    -2
      legacy/numeric.h

include/lol/base/utils.h → include/lol/bigint Ver arquivo

@@ -12,6 +12,5 @@

#pragma once

#include "private/string.h"
#include "private/containers.h"
#include "private/types/bigint.h"


+ 16
- 0
include/lol/color Ver arquivo

@@ -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"


include/lol/base/dialogs.h → include/lol/dialogs Ver arquivo

@@ -13,9 +13,9 @@
#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"


+ 16
- 0
include/lol/getopt Ver arquivo

@@ -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"


+ 16
- 0
include/lol/half Ver arquivo

@@ -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"


+ 19
- 0
include/lol/math Ver arquivo

@@ -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"


include/lol/math/noise.h → include/lol/noise Ver arquivo

@@ -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"


include/lol/base/pegtl.h → include/lol/pegtl Ver arquivo

@@ -24,10 +24,5 @@
# define _WIN32_WINNT 0x0602
#endif

//namespace lol
//{

#include "../3rdparty/pegtl/include/tao/pegtl.hpp"

//} // namespace lol
#include "3rdparty/pegtl/include/tao/pegtl.hpp"


include/lol/base/private/containers.h → include/lol/private/base/containers.h Ver arquivo


include/lol/base/core.h → include/lol/private/base/env.h Ver arquivo

@@ -18,7 +18,7 @@
namespace lol
{

namespace os
namespace sys
{

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();
}

// 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

+ 31
- 0
include/lol/private/base/misc.h Ver arquivo

@@ -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

include/lol/base/private/string.h → include/lol/private/base/string.h Ver arquivo

@@ -19,7 +19,7 @@
// Contains some utilities to work with std::string objects.
//

#include "features.h"
#include "../features.h"

#include <vector> // std::vector
#include <string> // std::basic_string
@@ -149,7 +149,7 @@ std::basic_string<T> toupper(T const *s)

// Format a string, printf-style
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;
#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
// 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
// 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;
ret.resize(needed);
vsnprintf(&ret[0], needed + 1, format, ap);
vsnprintf(&ret[0], needed + 1, fmt, ap);

return ret;
}

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_start(ap, format);
std::string ret = vformat(format, ap);
va_start(ap, fmt);
std::string ret = vformat(fmt, ap);
va_end(ap);
return ret;
}

include/lol/base/private/features.h → include/lol/private/features.h Ver arquivo


include/lol/image/private/cie1931.ipp → include/lol/private/image/cie1931.ipp Ver arquivo


include/lol/image/color.h → include/lol/private/image/color.h Ver arquivo

@@ -18,9 +18,9 @@
// 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 <algorithm> // std::min
@@ -362,7 +362,7 @@ public:

using color = color_t<float>;

} /* namespace lol */
} // namespace lol

#include "private/color.ipp"
#include "private/cie1931.ipp"
#include "color.ipp"
#include "cie1931.ipp"

include/lol/image/private/color.ipp → include/lol/private/image/color.ipp Ver arquivo


include/lol/base/lolunit.h → include/lol/private/lolunit.h Ver arquivo


include/lol/math/constants.h → include/lol/private/math/constants.h Ver arquivo


include/lol/math/functions.h → include/lol/private/math/functions.h Ver arquivo

@@ -17,8 +17,6 @@
// ———————————————————————
//

#include <lol/math/constants.h>

#include <cmath>
#include <cstdio>
#include <algorithm>
@@ -110,6 +108,17 @@ LOL_FORWARD_FP_1_ARG(round)
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
template<typename T, typename T2 = LOL_T_FLOATING_POINT>
[[nodiscard]] static inline T2 mix(T a, T b, T x)

include/lol/math/private/gradient.h → include/lol/private/math/gradient.h Ver arquivo

@@ -14,11 +14,10 @@

#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
{

include/lol/math/private/matrix.h → include/lol/private/math/matrix.h Ver arquivo

@@ -18,10 +18,9 @@
//

#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
# pragma push_macro("near")

include/lol/math/private/matrix.ipp → include/lol/private/math/matrix.ipp Ver arquivo


include/lol/math/private/ops.h → include/lol/private/math/ops.h Ver arquivo


include/lol/math/private/perlin.h → include/lol/private/math/perlin.h Ver arquivo

@@ -14,7 +14,7 @@

#pragma once

#include <lol/math/functions.h> // for clamp()
#include "functions.h" // for clamp()
#include "gradient.h"

#include <cmath> // std::sqrt

include/lol/math/polynomial.h → include/lol/private/math/polynomial.h Ver arquivo

@@ -19,7 +19,7 @@
// added guarantee that the leading coefficient is always non-zero.
//

#include "../base/private/features.h"
#include "../features.h"

#include <vector> // std::vector
#include <algorithm> // std::min

include/lol/math/rand.h → include/lol/private/math/rand.h Ver arquivo

@@ -17,8 +17,6 @@
// ————————————————————————————
//

#include "../base/private/features.h"

#include <cassert>
#include <cstdlib>
#include <stdint.h>

include/lol/math/private/simplex.h → include/lol/private/math/simplex.h Ver arquivo

@@ -16,12 +16,11 @@

#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
{

include/lol/math/transform.h → include/lol/private/math/transform.h Ver arquivo

@@ -17,13 +17,12 @@
// ———————————————————————————————————————————————————
//

#include <lol/math/private/ops.h>
#include <lol/math/vector.h>

#include <lol/vector>
#include <ostream> // std::ostream
#include <cmath> // std::atan2, std::sqrt

#include "private/matrix.h"
#include "ops.h"
#include "matrix.h"

namespace lol
{
@@ -591,6 +590,6 @@ typedef imat4x3 int4x3;

} // namespace lol

#include "private/matrix.ipp"
#include "private/transform.ipp"
#include "matrix.ipp"
#include "transform.ipp"


include/lol/math/private/transform.ipp → include/lol/private/math/transform.ipp Ver arquivo


include/lol/math/vector.h → include/lol/private/math/vector.h Ver arquivo

@@ -26,7 +26,7 @@
// FIXME: get rid of this, too
#include <../legacy/lol/base/types.h>

#include "private/ops.h"
#include "ops.h"

#if _MSC_VER
# pragma push_macro("min")
@@ -1437,7 +1437,7 @@ typedef ivec12 int12;

} // namespace lol

#include "private/vector.ipp"
#include "vector.ipp"

#if _MSC_VER
# pragma pop_macro("min")

include/lol/math/private/vector.ipp → include/lol/private/math/vector.ipp Ver arquivo

@@ -12,7 +12,7 @@

#pragma once

#include <lol/base/private/string.h> // lol::format
#include "../base/string.h" // lol::format

namespace lol
{

include/lol/base/getopt.h → include/lol/private/sys/getopt.h Ver arquivo


include/lol/base/thread.h → include/lol/private/sys/threading.h Ver arquivo

@@ -17,7 +17,7 @@
// —————————————————————
//

#include <lol/base/core.h> // os::getenv
#include "../base/env.h" // sys::getenv

#include <functional> // std::function
#include <thread>
@@ -73,7 +73,7 @@ public:
// FIXME: move to os::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__
// For some reason hardware_concurrency() will return the actual number
// of threads/cores even though the system cannot spawn threads.

include/lol/types/bigint.h → include/lol/private/types/bigint.h Ver arquivo


include/lol/types/half.h → include/lol/private/types/half.h Ver arquivo

@@ -22,7 +22,8 @@
#include <stdint.h> // uint32_t etc.

// FIXME: get rid of this
#include <lol/math/functions.h>
#include "../math/constants.h"
#include "../math/functions.h"

namespace lol
{

include/lol/types/real.h → include/lol/private/types/real.h Ver arquivo

@@ -17,7 +17,7 @@
// —————————————————————
//

#include "../base/private/features.h"
#include "../features.h"

#include <limits> // std::numeric_limits
#include <vector> // std::vector
@@ -265,7 +265,7 @@ typedef real_t<uint32_t> real;

} // namespace lol

#include "private/real.ipp"
#include "real.ipp"

#if _MSC_VER
# pragma pop_macro("min")

include/lol/types/private/real.ipp → include/lol/private/types/real.ipp Ver arquivo


+ 16
- 0
include/lol/real Ver arquivo

@@ -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"


+ 16
- 0
include/lol/thread Ver arquivo

@@ -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"


+ 16
- 0
include/lol/transform Ver arquivo

@@ -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"


+ 16
- 0
include/lol/unit_test Ver arquivo

@@ -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"


+ 20
- 0
include/lol/utils Ver arquivo

@@ -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"


+ 16
- 0
include/lol/vector Ver arquivo

@@ -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"


+ 4
- 4
legacy/lol/algorithm/portal.h Ver arquivo

@@ -14,12 +14,12 @@
#pragma once

#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/image/color.h>
#include <lol/color>

#include <cfloat> /* for FLT_MAX */
#include <cfloat> // FLT_MAX

namespace lol
{


+ 1
- 1
legacy/lol/image/pixel.h Ver arquivo

@@ -18,7 +18,7 @@
//

#include <../legacy/lol/base/types.h>
#include <lol/math/vector.h>
#include <lol/vector>

namespace lol
{


+ 1
- 6
legacy/lol/math/arraynd.h Ver arquivo

@@ -20,12 +20,7 @@
// 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 <algorithm> // std::min
#include <cstring> // memset


+ 3
- 3
legacy/lol/math/geometry.h Ver arquivo

@@ -19,9 +19,9 @@
//

#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 <map>


+ 1
- 1
legacy/lol/math/interp.h Ver arquivo

@@ -12,7 +12,7 @@

#pragma once

#include <../legacy/lol/math/functions.h>
#include <lol/math>

//
// Interpolator classes


+ 1
- 2
legacy/numeric.h Ver arquivo

@@ -17,8 +17,7 @@
// ——————————————————————————————
//

#include <lol/math/functions.h>

#include <lol/math> // lol::lerp, lol::clamp
#include <cstdlib>
#include <stdint.h>



Carregando…
Cancelar
Salvar