Make def
more efficient, fix to_string(string)
This commit is contained in:
@@ -443,7 +443,7 @@ namespace chaiscript
|
|||||||
operators::assign<bool>(m);
|
operators::assign<bool>(m);
|
||||||
operators::equal<bool>(m);
|
operators::equal<bool>(m);
|
||||||
|
|
||||||
m->add(fun(&to_string<const std::string &>), "to_string");
|
m->add(fun<std::string (const std::string &t_ss)>([](const std::string &s) -> std::string { return s; }), "to_string");
|
||||||
m->add(fun(&Bootstrap::bool_to_string), "to_string");
|
m->add(fun(&Bootstrap::bool_to_string), "to_string");
|
||||||
m->add(fun(&unknown_assign), "=");
|
m->add(fun(&unknown_assign), "=");
|
||||||
m->add(fun(&throw_exception), "throw");
|
m->add(fun(&throw_exception), "throw");
|
||||||
|
@@ -443,17 +443,13 @@ namespace chaiscript
|
|||||||
|
|
||||||
|
|
||||||
/// Adds a named object to the current scope
|
/// Adds a named object to the current scope
|
||||||
|
/// \warning This version does not check the validity of the name
|
||||||
|
/// it is meant for internal use only
|
||||||
void add_object(const std::string &name, const Boxed_Value &obj) const
|
void add_object(const std::string &name, const Boxed_Value &obj) const
|
||||||
{
|
{
|
||||||
auto &stack = get_stack_data();
|
if (!get_stack_data().back().insert(std::make_pair(name, obj)).second)
|
||||||
validate_object_name(name);
|
|
||||||
|
|
||||||
auto &scope = stack.back();
|
|
||||||
if (scope.find(name) != scope.end())
|
|
||||||
{
|
{
|
||||||
throw chaiscript::exception::name_conflict_error(name);
|
throw chaiscript::exception::name_conflict_error(name);
|
||||||
} else {
|
|
||||||
scope.insert(std::make_pair(name, obj));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user