mirror of
https://github.com/ChaiScript/ChaiScript.git
synced 2025-12-06 16:57:04 +08:00
replace const std::string_view with std::string_view
This commit is contained in:
parent
180a6d4a1c
commit
c47b9e3b0d
@ -198,7 +198,7 @@ namespace chaiscript
|
||||
apply_globals(m_globals.begin(), m_globals.end(), t_engine);
|
||||
}
|
||||
|
||||
bool has_function(const Proxy_Function &new_f, const std::string_view &name) noexcept
|
||||
bool has_function(const Proxy_Function &new_f, std::string_view name) noexcept
|
||||
{
|
||||
return std::any_of(m_funcs.begin(), m_funcs.end(),
|
||||
[&](const std::pair<Proxy_Function, std::string> &existing_f) {
|
||||
@ -617,7 +617,7 @@ namespace chaiscript
|
||||
/// Searches the current stack for an object of the given name
|
||||
/// includes a special overload for the _ place holder object to
|
||||
/// ensure that it is always in scope.
|
||||
Boxed_Value get_object(const std::string_view &name, std::atomic_uint_fast32_t &t_loc, Stack_Holder &t_holder) const
|
||||
Boxed_Value get_object(std::string_view name, std::atomic_uint_fast32_t &t_loc, Stack_Holder &t_holder) const
|
||||
{
|
||||
enum class Loc : uint_fast32_t {
|
||||
located = 0x80000000,
|
||||
@ -739,7 +739,7 @@ namespace chaiscript
|
||||
|
||||
|
||||
/// Return a function by name
|
||||
std::pair<size_t, std::shared_ptr<std::vector< Proxy_Function>>> get_function(const std::string_view &t_name, const size_t t_hint) const
|
||||
std::pair<size_t, std::shared_ptr<std::vector< Proxy_Function>>> get_function(std::string_view t_name, const size_t t_hint) const
|
||||
{
|
||||
chaiscript::detail::threading::shared_lock<chaiscript::detail::threading::shared_mutex> l(m_mutex);
|
||||
|
||||
@ -765,7 +765,7 @@ namespace chaiscript
|
||||
/// \returns a function object (Boxed_Value wrapper) if it exists
|
||||
/// \throws std::range_error if it does not
|
||||
/// \warn does not obtain a mutex lock. \sa get_function_object for public version
|
||||
std::pair<size_t, Boxed_Value> get_function_object_int(const std::string_view &t_name, const size_t t_hint) const
|
||||
std::pair<size_t, Boxed_Value> get_function_object_int(std::string_view t_name, const size_t t_hint) const
|
||||
{
|
||||
const auto &funs = get_boxed_functions_int();
|
||||
|
||||
@ -779,7 +779,7 @@ namespace chaiscript
|
||||
|
||||
|
||||
/// Return true if a function exists
|
||||
bool function_exists(const std::string_view &name) const
|
||||
bool function_exists(std::string_view name) const
|
||||
{
|
||||
chaiscript::detail::threading::shared_lock<chaiscript::detail::threading::shared_mutex> l(m_mutex);
|
||||
|
||||
@ -1035,7 +1035,7 @@ namespace chaiscript
|
||||
|
||||
|
||||
|
||||
Boxed_Value call_function(const std::string_view &t_name, std::atomic_uint_fast32_t &t_loc, const Function_Params ¶ms,
|
||||
Boxed_Value call_function(std::string_view t_name, std::atomic_uint_fast32_t &t_loc, const Function_Params ¶ms,
|
||||
const Type_Conversions_State &t_conversions) const
|
||||
{
|
||||
uint_fast32_t loc = t_loc;
|
||||
@ -1116,7 +1116,7 @@ namespace chaiscript
|
||||
}
|
||||
|
||||
/// return true if the Boxed_Value matches the registered type by name
|
||||
bool is_type(const Boxed_Value &r, const std::string_view &user_typename) const noexcept
|
||||
bool is_type(const Boxed_Value &r, std::string_view user_typename) const noexcept
|
||||
{
|
||||
try {
|
||||
if (get_type(user_typename).bare_equal(r.get_type_info()))
|
||||
@ -1453,7 +1453,7 @@ namespace chaiscript
|
||||
return m_engine.get().add_object(t_name, std::move(obj), m_stack_holder.get());
|
||||
}
|
||||
|
||||
Boxed_Value get_object(const std::string_view &t_name, std::atomic_uint_fast32_t &t_loc) const {
|
||||
Boxed_Value get_object(std::string_view t_name, std::atomic_uint_fast32_t &t_loc) const {
|
||||
return m_engine.get().get_object(t_name, t_loc, m_stack_holder.get());
|
||||
}
|
||||
|
||||
|
||||
@ -50,7 +50,7 @@ namespace chaiscript
|
||||
return opers[static_cast<int>(t_oper)];
|
||||
}
|
||||
|
||||
constexpr static Opers to_operator(const std::string_view &t_str, bool t_is_unary = false) noexcept
|
||||
constexpr static Opers to_operator(std::string_view t_str, bool t_is_unary = false) noexcept
|
||||
{
|
||||
#ifdef CHAISCRIPT_MSVC
|
||||
#pragma warning(push)
|
||||
|
||||
@ -232,7 +232,7 @@ namespace chaiscript
|
||||
std::array<utility::Static_String, 3> m_10 {{SS("*"), SS("/"), SS("%")}};
|
||||
std::array<utility::Static_String, 6> m_11 {{SS("++"), SS("--"), SS("-"), SS("+"), SS("!"), SS("~")}};
|
||||
|
||||
bool is_match(const std::string_view &t_str) const noexcept {
|
||||
bool is_match(std::string_view t_str) const noexcept {
|
||||
constexpr std::array<std::size_t, 12> groups{{0,1,2,3,4,5,6,7,8,9,10,11}};
|
||||
return std::any_of(groups.begin(), groups.end(), [&t_str, this](const std::size_t group){ return is_match(group, t_str); });
|
||||
}
|
||||
@ -261,7 +261,7 @@ namespace chaiscript
|
||||
}
|
||||
}
|
||||
|
||||
constexpr bool is_match(const std::size_t t_group, const std::string_view &t_str) const noexcept {
|
||||
constexpr bool is_match(const std::size_t t_group, std::string_view t_str) const noexcept {
|
||||
auto match = [&t_str](const auto &array) {
|
||||
return std::any_of(array.begin(), array.end(), [&t_str](const auto &v){ return v == t_str; });
|
||||
};
|
||||
@ -421,7 +421,7 @@ namespace chaiscript
|
||||
Tracer m_tracer;
|
||||
Optimizer m_optimizer;
|
||||
|
||||
void validate_object_name(const std::string_view &name) const
|
||||
void validate_object_name(std::string_view name) const
|
||||
{
|
||||
if (!Name_Validator::valid_object_name(name)) {
|
||||
throw exception::eval_error("Invalid Object Name: " + std::string(name), File_Position(m_position.line, m_position.col), *m_filename);
|
||||
@ -724,7 +724,7 @@ namespace chaiscript
|
||||
}
|
||||
|
||||
/// Parses a floating point value and returns a Boxed_Value representation of it
|
||||
static Boxed_Value buildFloat(const std::string_view &t_val)
|
||||
static Boxed_Value buildFloat(std::string_view t_val)
|
||||
{
|
||||
bool float_ = false;
|
||||
bool long_ = false;
|
||||
@ -1491,7 +1491,7 @@ namespace chaiscript
|
||||
return retval;
|
||||
}
|
||||
|
||||
bool is_operator(const std::string_view &t_s) const noexcept {
|
||||
bool is_operator(std::string_view t_s) const noexcept {
|
||||
return m_operator_matches.is_match(t_s);
|
||||
}
|
||||
|
||||
|
||||
@ -52,7 +52,7 @@ namespace chaiscript
|
||||
return hash(std::begin(str), std::end(str)-1);
|
||||
}
|
||||
|
||||
static constexpr std::uint32_t hash(const std::string_view &sv) noexcept {
|
||||
static constexpr std::uint32_t hash(std::string_view sv) noexcept {
|
||||
return hash(sv.begin(), sv.end());
|
||||
}
|
||||
|
||||
@ -84,7 +84,7 @@ namespace chaiscript
|
||||
return hash(std::begin(str), std::end(str)-1);
|
||||
}
|
||||
|
||||
static constexpr std::uint32_t hash(const std::string_view &sv) noexcept {
|
||||
static constexpr std::uint32_t hash(std::string_view sv) noexcept {
|
||||
return hash(sv.begin(), sv.end());
|
||||
}
|
||||
|
||||
|
||||
@ -36,7 +36,7 @@ namespace chaiscript
|
||||
return data + m_size;
|
||||
}
|
||||
|
||||
constexpr bool operator==(const std::string_view &other) const noexcept {
|
||||
constexpr bool operator==(std::string_view other) const noexcept {
|
||||
//return std::string_view(data, m_size) == other;
|
||||
auto b1 = begin();
|
||||
const auto e1 = end();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user