Compare commits

...

8 Commits

18 changed files with 1586 additions and 67 deletions

View File

@ -1,14 +1,7 @@
Libostd is licensed under the University of Illinois/NCSA Open Source License, Copyright (c) 2015-2020 Daniel "q66" Kolesa
a permissive, non-copyleft, BSD style license. The license text goes as follows:
Copyright (c) 2015 Daniel "q66" Kolesa. All rights reserved. Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal with
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
* Redistributions of source code must retain the above copyright notice, * Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimers. this list of conditions and the following disclaimers.
@ -17,17 +10,17 @@ so, subject to the following conditions:
this list of conditions and the following disclaimers in the this list of conditions and the following disclaimers in the
documentation and/or other materials provided with the distribution. documentation and/or other materials provided with the distribution.
* Neither the names of libostd developers nor any contributors may be **THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
used to endorse or promote products derived from this Software without AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
specific prior written permission. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
**THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
SOFTWARE.** THE POSSIBILITY OF SUCH DAMAGE.**
Additionally some code from the libc++ project has been used as a reference; Additionally some code from the libc++ project has been used as a reference;
libc++ is a part of the LLVM project. libc++ is a part of the LLVM project.
@ -41,7 +34,7 @@ to the project here.
Additional thanks to Dale Weiler aka graphitemaster (reference code in the Additional thanks to Dale Weiler aka graphitemaster (reference code in the
Neothyne project) and cppreference.com. Neothyne project) and cppreference.com.
**The data/UnicodeData-11.0.txt file is taken from the Unicode Character **The data/UnicodeData-13.0.txt file is taken from the Unicode Character
Database and provided under the following license:** Database and provided under the following license:**
COPYRIGHT AND PERMISSION NOTICE COPYRIGHT AND PERMISSION NOTICE

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
project('libostd', ['cpp'], project('libostd', ['cpp'],
version: '0.1.0', version: '0.1.0',
default_options: ['buildtype=plain', 'cpp_std=c++17'], default_options: ['buildtype=plain', 'cpp_std=c++17', 'warning_level=3'],
meson_version: '>=0.46' meson_version: '>=0.46'
) )
@ -11,15 +11,25 @@ dir_lib = join_paths(dir_prefix, get_option('libdir'))
dir_package_include = join_paths(dir_include, 'ostd') dir_package_include = join_paths(dir_include, 'ostd')
unicode_data = join_paths('data', 'UnicodeData-11.0.txt') unicode_data = join_paths('data', 'UnicodeData-13.0.txt')
libostd_includes = [include_directories('.')] libostd_includes = [include_directories('.')]
tgt_compiler_id = meson.get_compiler('cpp').get_id() cxx = meson.get_compiler('cpp')
if tgt_compiler_id == 'gcc' or tgt_compiler_id == 'clang'
extra_cxxflags = ['-Wextra', '-Wshadow', '-Wold-style-cast'] extra_cxxflags = []
else
extra_cxxflags = [] if get_option('buildtype') != 'plain'
if cxx.has_argument('-Wshadow')
extra_cxxflags += '-Wshadow'
endif
if cxx.has_argument('-Wold-style-cast')
extra_cxxflags += '-Wold-style-cast'
endif
endif
if cxx.has_argument('-fvisibility=hidden')
extra_cxxflags += '-fvisibility=hidden'
endif endif
subdir('src') subdir('src')

View File

@ -488,7 +488,7 @@ inline UnaryFunction for_each(InputRange range, UnaryFunction func) {
for (; !range.empty(); range.pop_front()) { for (; !range.empty(); range.pop_front()) {
func(range.front()); func(range.front());
} }
return std::move(func); return func;
} }
/** @brief A pipeable version of ostd::for_each(). /** @brief A pipeable version of ostd::for_each().

View File

@ -41,7 +41,7 @@ namespace ostd {
*/ */
/** @brief The error thrown on parsing and other failures. */ /** @brief The error thrown on parsing and other failures. */
struct arg_error: std::runtime_error { struct OSTD_EXPORT arg_error: std::runtime_error {
using std::runtime_error::runtime_error; using std::runtime_error::runtime_error;
/* empty, for vtable placement */ /* empty, for vtable placement */
@ -98,7 +98,7 @@ enum class arg_value {
* *
* This base class is abstract so it cannot be instantiated. * This base class is abstract so it cannot be instantiated.
*/ */
struct arg_description { struct OSTD_EXPORT arg_description {
friend struct arg_description_container; friend struct arg_description_container;
friend struct arg_mutually_exclusive_group; friend struct arg_mutually_exclusive_group;
friend struct arg_group; friend struct arg_group;
@ -138,7 +138,7 @@ protected:
* *
* It's not instantiated directly. * It's not instantiated directly.
*/ */
struct arg_argument: arg_description { struct OSTD_EXPORT arg_argument: arg_description {
/* empty, for vtable placement */ /* empty, for vtable placement */
virtual ~arg_argument(); virtual ~arg_argument();
@ -225,7 +225,7 @@ private:
* *
*See ostd::basic_arg_parser for more. *See ostd::basic_arg_parser for more.
*/ */
struct arg_optional: arg_argument { struct OSTD_EXPORT arg_optional: arg_argument {
template<typename HelpFormatter> template<typename HelpFormatter>
friend struct basic_arg_parser; friend struct basic_arg_parser;
friend struct arg_description_container; friend struct arg_description_container;
@ -459,7 +459,7 @@ private:
* *
*See ostd::basic_arg_parser for more. *See ostd::basic_arg_parser for more.
*/ */
struct arg_positional: arg_argument { struct OSTD_EXPORT arg_positional: arg_argument {
template<typename HelpFormatter> template<typename HelpFormatter>
friend struct basic_arg_parser; friend struct basic_arg_parser;
friend struct arg_description_container; friend struct arg_description_container;
@ -603,7 +603,7 @@ private:
* A mutually exclusive group can also have the `required` flag set * A mutually exclusive group can also have the `required` flag set
* in which case one of the arguments must always be used. * in which case one of the arguments must always be used.
*/ */
struct arg_mutually_exclusive_group: arg_description { struct OSTD_EXPORT arg_mutually_exclusive_group: arg_description {
friend struct arg_description_container; friend struct arg_description_container;
/* empty, for vtable placement */ /* empty, for vtable placement */
@ -940,7 +940,7 @@ protected:
* A group is named and can optionally have a title. The title is * A group is named and can optionally have a title. The title is
* displayed in help listing. If not set, the name is displayed. * displayed in help listing. If not set, the name is displayed.
*/ */
struct arg_group: arg_description, arg_description_container { struct OSTD_EXPORT arg_group: arg_description, arg_description_container {
friend struct arg_description_container; friend struct arg_description_container;
/* empty, for vtable placement */ /* empty, for vtable placement */

View File

@ -198,7 +198,7 @@ private:
bool p_action = false; bool p_action = false;
}; };
struct make_task { struct OSTD_EXPORT make_task {
make_task() {} make_task() {}
virtual ~make_task(); virtual ~make_task();

View File

@ -24,6 +24,7 @@
#include <stdexcept> #include <stdexcept>
#include <memory> #include <memory>
#include <ostd/platform.hh>
#include <ostd/generic_condvar.hh> #include <ostd/generic_condvar.hh>
namespace ostd { namespace ostd {
@ -33,7 +34,7 @@ namespace ostd {
*/ */
/** @brief Thrown when manipulating a channel that has been closed. */ /** @brief Thrown when manipulating a channel that has been closed. */
struct channel_error: std::logic_error { struct OSTD_EXPORT channel_error: std::logic_error {
using std::logic_error::logic_error; using std::logic_error::logic_error;
/* empty, for vtable placement */ /* empty, for vtable placement */
virtual ~channel_error(); virtual ~channel_error();

View File

@ -212,7 +212,7 @@ private:
* The `start` method will also set the internal current scheduler pointer * The `start` method will also set the internal current scheduler pointer
* so that APIs such as ostd::spawn() can work. * so that APIs such as ostd::spawn() can work.
*/ */
struct scheduler { struct OSTD_EXPORT scheduler {
private: private:
struct stack_allocator { struct stack_allocator {
stack_allocator() = delete; stack_allocator() = delete;
@ -544,7 +544,7 @@ namespace detail {
OSTD_EXPORT extern thread_local csched_task *current_csched_task; OSTD_EXPORT extern thread_local csched_task *current_csched_task;
struct csched_task: coroutine_context { struct OSTD_EXPORT csched_task: coroutine_context {
friend struct coroutine_context; friend struct coroutine_context;
csched_task() = delete; csched_task() = delete;

View File

@ -54,14 +54,14 @@ namespace ostd {
* *
* These can include a dead coroutine/generator call/access. * These can include a dead coroutine/generator call/access.
*/ */
struct coroutine_error: std::runtime_error { struct OSTD_EXPORT coroutine_error: std::runtime_error {
using std::runtime_error::runtime_error; using std::runtime_error::runtime_error;
/* empty, for vtable placement */ /* empty, for vtable placement */
virtual ~coroutine_error(); virtual ~coroutine_error();
}; };
namespace detail { namespace detail {
struct stack_free_iface { struct OSTD_EXPORT stack_free_iface {
stack_free_iface() {} stack_free_iface() {}
/* empty, for vtable placement */ /* empty, for vtable placement */
virtual ~stack_free_iface(); virtual ~stack_free_iface();
@ -84,7 +84,7 @@ namespace detail {
* managing the coroutine as well as its entry point. All coroutine types * managing the coroutine as well as its entry point. All coroutine types
* inherit from this. * inherit from this.
*/ */
struct coroutine_context { struct OSTD_EXPORT coroutine_context {
/** @brief Gets the currently executing coroutine context. /** @brief Gets the currently executing coroutine context.
* *
* Sometimes custom coroutine types might want to bypass being able * Sometimes custom coroutine types might want to bypass being able

View File

@ -55,7 +55,7 @@ enum format_flags {
}; };
/** @brief Thrown when format string does not properly match the arguments. */ /** @brief Thrown when format string does not properly match the arguments. */
struct format_error: std::runtime_error { struct OSTD_EXPORT format_error: std::runtime_error {
using std::runtime_error::runtime_error; using std::runtime_error::runtime_error;
/* empty, for vtable placement */ /* empty, for vtable placement */
virtual ~format_error(); virtual ~format_error();

View File

@ -16,6 +16,8 @@
#include <algorithm> #include <algorithm>
#include <condition_variable> #include <condition_variable>
#include <ostd/platform.hh>
namespace ostd { namespace ostd {
/** @addtogroup Concurrency /** @addtogroup Concurrency
@ -23,7 +25,7 @@ namespace ostd {
*/ */
namespace detail { namespace detail {
struct cond_iface { struct OSTD_EXPORT cond_iface {
cond_iface() {} cond_iface() {}
virtual ~cond_iface(); virtual ~cond_iface();
virtual void notify_one() = 0; virtual void notify_one() = 0;

View File

@ -90,7 +90,7 @@ namespace detail {
* *
* It inherits from std::runtime_error and has the same methods and behavior. * It inherits from std::runtime_error and has the same methods and behavior.
*/ */
struct path_error: std::runtime_error { struct OSTD_EXPORT path_error: std::runtime_error {
using std::runtime_error::runtime_error; using std::runtime_error::runtime_error;
/* empty, for vtable placement */ /* empty, for vtable placement */
@ -1263,7 +1263,7 @@ using file_time_t = std::chrono::time_point<std::chrono::system_clock>;
* up to two paths involved in the operation as ostd::path. Whether those * up to two paths involved in the operation as ostd::path. Whether those
* are used depends on the operation. * are used depends on the operation.
*/ */
struct fs_error: std::system_error { struct OSTD_EXPORT fs_error: std::system_error {
/** @brief Constructs the error without paths. */ /** @brief Constructs the error without paths. */
fs_error(std::string const &warg, std::error_code ec): fs_error(std::string const &warg, std::error_code ec):
std::system_error::system_error(ec, warg) std::system_error::system_error(ec, warg)

View File

@ -32,7 +32,7 @@ namespace ostd {
*/ */
/** @brief Thrown on errors in ostd::split_args(). */ /** @brief Thrown on errors in ostd::split_args(). */
struct word_error: std::runtime_error { struct OSTD_EXPORT word_error: std::runtime_error {
using std::runtime_error::runtime_error; using std::runtime_error::runtime_error;
/* empty, for vtable placement */ /* empty, for vtable placement */
virtual ~word_error(); virtual ~word_error();
@ -81,7 +81,7 @@ Sink &&split_args(Sink &&out, string_range str) {
} }
/** @brief Thrown on errors in ostd::subprocess. */ /** @brief Thrown on errors in ostd::subprocess. */
struct subprocess_error: std::runtime_error { struct OSTD_EXPORT subprocess_error: std::runtime_error {
using std::runtime_error::runtime_error; using std::runtime_error::runtime_error;
/* empty, for vtable placement */ /* empty, for vtable placement */
virtual ~subprocess_error(); virtual ~subprocess_error();

View File

@ -88,7 +88,7 @@ template<typename T = char, bool = std::is_trivial_v<T>>
struct stream_range; struct stream_range;
/** @brief Thrown on stream errors. */ /** @brief Thrown on stream errors. */
struct stream_error: std::system_error { struct OSTD_EXPORT stream_error: std::system_error {
using std::system_error::system_error; using std::system_error::system_error;
/* empty, for vtable placement */ /* empty, for vtable placement */
virtual ~stream_error(); virtual ~stream_error();
@ -102,7 +102,7 @@ struct stream_line_range;
* All streams derive from this, for example ostd::file_steram. * All streams derive from this, for example ostd::file_steram.
* They implement the virtual interface provided by this class. * They implement the virtual interface provided by this class.
*/ */
struct stream { struct OSTD_EXPORT stream {
/** @brief The stream offset type. */ /** @brief The stream offset type. */
using offset_type = stream_off_t; using offset_type = stream_off_t;

View File

@ -126,6 +126,14 @@ public:
p_beg(v.p_beg), p_end(v.p_end) p_beg(v.p_beg), p_end(v.p_end)
{} {}
/** @brief Slices can be constructed from string views. */
template<typename U>
basic_char_range(std::basic_string_view<
std::remove_const_t<value_type>, U
> const &v) noexcept:
p_beg{v.data()}, p_end{v.data() + v.size()}
{}
/** @brief Constructs a slice from a pointer or a static array. /** @brief Constructs a slice from a pointer or a static array.
* *
* This constructor handles two cases. The input must be convertible * This constructor handles two cases. The input must be convertible
@ -790,7 +798,7 @@ namespace utf {
static inline constexpr char32_t const max_unicode = 0x10FFFF; static inline constexpr char32_t const max_unicode = 0x10FFFF;
/** @brief Thrown on UTF-8 decoding failure. */ /** @brief Thrown on UTF-8 decoding failure. */
struct utf_error: std::runtime_error { struct OSTD_EXPORT utf_error: std::runtime_error {
using std::runtime_error::runtime_error; using std::runtime_error::runtime_error;
/* empty, for vtable placement */ /* empty, for vtable placement */
virtual ~utf_error(); virtual ~utf_error();

View File

@ -9,7 +9,7 @@ namespace ostd {
namespace build { namespace build {
/* place the vtable in here */ /* place the vtable in here */
make_task::~make_task() {} OSTD_EXPORT make_task::~make_task() {}
static bool check_exec( static bool check_exec(
string_range tname, std::vector<string_range> const &deps string_range tname, std::vector<string_range> const &deps

View File

@ -49,7 +49,7 @@ thread_dep = dependency('threads')
libostd_gen_unicode_exe = executable('gen_unicode', libostd_gen_unicode_exe = executable('gen_unicode',
['../gen_unicode.cc'], ['../gen_unicode.cc'],
include_directories: libostd_includes, include_directories: libostd_includes,
cpp_args: extra_cxxflags + ['-DOSTD_GEN_UNICODE_BUILD'], cpp_args: ['-DOSTD_GEN_UNICODE_BUILD'] + extra_cxxflags,
install: false, install: false,
native: true native: true
) )

View File

@ -21,7 +21,7 @@ namespace ostd {
/* place the vtables in here */ /* place the vtables in here */
path_error::~path_error() {} OSTD_EXPORT path_error::~path_error() {}
namespace fs { namespace fs {
fs_error::~fs_error() {} fs_error::~fs_error() {}