Merge remote-tracking branch 'zoomulator/master'

Adding zoomulator's patches for allowing of non-const globals if the user
wants to.
This commit is contained in:
Jason Turner
2013-11-27 08:06:39 -07:00
2 changed files with 22 additions and 0 deletions

View File

@@ -477,6 +477,22 @@ namespace chaiscript
}
}
void add_global(const Boxed_Value &obj, const std::string &name)
{
validate_object_name(name);
chaiscript::detail::threading::unique_lock<chaiscript::detail::threading::shared_mutex> l(m_global_object_mutex);
if (m_state.m_global_objects.find(name) != m_state.m_global_objects.end())
{
throw exception::name_conflict_error(name);
} else {
m_state.m_global_objects.insert(std::make_pair(name, obj));
}
}
/**
* Adds a new scope to the stack
*/