support user conf file
parent
84f6d1f0d6
commit
816d6e521d
|
@ -12,6 +12,8 @@ current_triplet=`$CC -dumpmachine`
|
||||||
if [ "$CC" = "clang" ]; then
|
if [ "$CC" = "clang" ]; then
|
||||||
export CXX="clang++"
|
export CXX="clang++"
|
||||||
export CXXFLAGS="-stdlib=libc++"
|
export CXXFLAGS="-stdlib=libc++"
|
||||||
|
elif [ "$CC" = "gcc" ]; then
|
||||||
|
export CXX="g++"
|
||||||
else
|
else
|
||||||
export CXX="g++-10"
|
export CXX="g++-10"
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -12,7 +12,6 @@
|
||||||
#define LIBCUBESCRIPT_CUBESCRIPT_STATE_HH
|
#define LIBCUBESCRIPT_CUBESCRIPT_STATE_HH
|
||||||
|
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <span>
|
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <string_view>
|
#include <string_view>
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,6 @@
|
||||||
|
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <string_view>
|
#include <string_view>
|
||||||
#include <span>
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
#include "ident.hh"
|
#include "ident.hh"
|
||||||
|
|
|
@ -2,13 +2,10 @@
|
||||||
*
|
*
|
||||||
* @brief Library configuration.
|
* @brief Library configuration.
|
||||||
*
|
*
|
||||||
* This is the one file you are allowed to touch as a user - it contains
|
* While you can technically modify this directly, it is better if you use
|
||||||
* settings that are used when building the library, notably the integer
|
* a custom file `cubescript_conf_user.hh` in the same location. Most of the
|
||||||
* and floating point types used and their formats (used for conversions).
|
* time you will not want to override anything, but should you need to change
|
||||||
*
|
* the integer, float or span types for a specific purpose, this allows you to.
|
||||||
* Usually you will not want to touch this, but occasionally you might want
|
|
||||||
* to, e.g. to make a build of the library that uses double precision floats
|
|
||||||
* or larger integers.
|
|
||||||
*
|
*
|
||||||
* @copyright See COPYING.md in the project tree for further information.
|
* @copyright See COPYING.md in the project tree for further information.
|
||||||
*/
|
*/
|
||||||
|
@ -18,13 +15,18 @@
|
||||||
|
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
|
|
||||||
|
#if __has_include("cubescript_conf_user.hh")
|
||||||
|
# include "cubescript_conf_user.hh"
|
||||||
|
#endif
|
||||||
|
|
||||||
#if __has_include(<span>)
|
#if __has_include(<span>)
|
||||||
# include <span>
|
# include <span>
|
||||||
#else
|
#elif !defined(LIBCUBESCRIPT_CONF_USER_SPAN)
|
||||||
# error "This implementation does not provide an std::span<T>."
|
# error "This implementation does not provide an std::span<T>."
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace cubescript {
|
namespace cubescript {
|
||||||
|
#if !defined(LIBCUBESCRIPT_CONF_USER_INTEGER)
|
||||||
/** @brief The integer type used.
|
/** @brief The integer type used.
|
||||||
*
|
*
|
||||||
* While Cubescript is a stringly typed language, it uses integers and
|
* While Cubescript is a stringly typed language, it uses integers and
|
||||||
|
@ -35,35 +37,50 @@ namespace cubescript {
|
||||||
* 32-bit signed integer on most platforms. Keep in mind that is is
|
* 32-bit signed integer on most platforms. Keep in mind that is is
|
||||||
* necessary for this type to be a signed integer type.
|
* necessary for this type to be a signed integer type.
|
||||||
*
|
*
|
||||||
|
* Define `LIBCUBESCRIPT_CONF_USER_INTEGER` in your custom conf file
|
||||||
|
* to disable the builtin.
|
||||||
|
*
|
||||||
* @see float_type
|
* @see float_type
|
||||||
* @see INTEGER_FORMAT
|
* @see INTEGER_FORMAT
|
||||||
*/
|
*/
|
||||||
using integer_type = int;
|
using integer_type = int;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !defined(LIBCUBESCRIPT_CONF_USER_FLOAT)
|
||||||
/** @brief The floating point type used.
|
/** @brief The floating point type used.
|
||||||
*
|
*
|
||||||
* By default, this is `float`, which is on most platforms an IEEE754
|
* By default, this is `float`, which is on most platforms an IEEE754
|
||||||
* binary32 data type.
|
* binary32 data type.
|
||||||
*
|
*
|
||||||
|
* Define `LIBCUBESCRIPT_CONF_USER_FLOAT` in your custom conf file
|
||||||
|
* to disable the builtin.
|
||||||
|
*
|
||||||
* @see integer_type
|
* @see integer_type
|
||||||
* @see FLOAT_FORMAT
|
* @see FLOAT_FORMAT
|
||||||
* @see ROUND_FLOAT_FORMAT
|
* @see ROUND_FLOAT_FORMAT
|
||||||
*/
|
*/
|
||||||
using float_type = float;
|
using float_type = float;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !defined(LIBCUBESCRIPT_CONF_USER_SPAN)
|
||||||
#if __has_include(<span>) || defined(LIBCS_GENERATING_DOC)
|
#if __has_include(<span>) || defined(LIBCS_GENERATING_DOC)
|
||||||
/** @brief The span type used.
|
/** @brief The span type used.
|
||||||
*
|
*
|
||||||
* By default, this is `std::span`. You will almost never want to override
|
* By default, this is `std::span`. You will almost never want to override
|
||||||
* this, but an alternative implementation can be supplied if your standard
|
* this, but an alternative implementation can be supplied if your standard
|
||||||
* library does not support it.
|
* library does not support it.
|
||||||
|
*
|
||||||
|
* Define `LIBCUBESCRIPT_CONF_USER_SPAN` in your custom conf file to
|
||||||
|
* disable the builtin.
|
||||||
*/
|
*/
|
||||||
template<typename T>
|
template<typename T>
|
||||||
using span_type = std::span<T>;
|
using span_type = std::span<T>;
|
||||||
#else
|
#else
|
||||||
using span_type = void;
|
using span_type = void;
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !defined(LIBCUBESCRIPT_CONF_USER_INTEGER)
|
||||||
/** @brief The integer format used.
|
/** @brief The integer format used.
|
||||||
*
|
*
|
||||||
* This is a formatting specifier as in `printf`, corresponding to the
|
* This is a formatting specifier as in `printf`, corresponding to the
|
||||||
|
@ -74,11 +91,16 @@ namespace cubescript {
|
||||||
* There are no special restrictions imposed on the floating point type
|
* There are no special restrictions imposed on the floating point type
|
||||||
* other than that it actually has to be floating point.
|
* other than that it actually has to be floating point.
|
||||||
*
|
*
|
||||||
|
* Define `LIBCUBESCRIPT_CONF_USER_INTEGER` in your custom conf file
|
||||||
|
* to disable the builtin.
|
||||||
|
*
|
||||||
* @see integer_type
|
* @see integer_type
|
||||||
* @see FLOAT_FORMAT
|
* @see FLOAT_FORMAT
|
||||||
*/
|
*/
|
||||||
constexpr auto const INTEGER_FORMAT = "%d";
|
constexpr auto const INTEGER_FORMAT = "%d";
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !defined(LIBCUBESCRIPT_CONF_USER_FLOAT)
|
||||||
/** @brief The float format used.
|
/** @brief The float format used.
|
||||||
*
|
*
|
||||||
* This is a formatting specifier as in `printf`, corresponding to the
|
* This is a formatting specifier as in `printf`, corresponding to the
|
||||||
|
@ -88,6 +110,9 @@ namespace cubescript {
|
||||||
* When the floating point value is equivalent to its integer value (i.e.
|
* When the floating point value is equivalent to its integer value (i.e.
|
||||||
* it has no decimal point), ROUND_FLOAT_FORMAT is used.
|
* it has no decimal point), ROUND_FLOAT_FORMAT is used.
|
||||||
*
|
*
|
||||||
|
* Define `LIBCUBESCRIPT_CONF_USER_FLOAT` in your custom conf file
|
||||||
|
* to disable the builtin.
|
||||||
|
*
|
||||||
* @see float_type
|
* @see float_type
|
||||||
* @see ROUND_FLOAT_FORMAT
|
* @see ROUND_FLOAT_FORMAT
|
||||||
* @see INTEGER_FORMAT
|
* @see INTEGER_FORMAT
|
||||||
|
@ -104,6 +129,7 @@ namespace cubescript {
|
||||||
* @see FLOAT_FORMAT
|
* @see FLOAT_FORMAT
|
||||||
*/
|
*/
|
||||||
constexpr auto const ROUND_FLOAT_FORMAT = "%.1f";
|
constexpr auto const ROUND_FLOAT_FORMAT = "%.1f";
|
||||||
|
#endif
|
||||||
} /* namespace cubescript */
|
} /* namespace cubescript */
|
||||||
|
|
||||||
/* conf verification */
|
/* conf verification */
|
||||||
|
|
Loading…
Reference in New Issue