| 46 | } |
| 47 | |
| 48 | void Namespace::Set(const String& field, const Value& value, bool isConst, const DebugInfo& debugInfo) |
| 49 | { |
| 50 | ObjectLock olock(this); |
| 51 | |
| 52 | if (m_Frozen) { |
| 53 | BOOST_THROW_EXCEPTION(ScriptError("Namespace is read-only and must not be modified.", debugInfo)); |
| 54 | } |
| 55 | |
| 56 | std::unique_lock<decltype(m_DataMutex)> dlock (m_DataMutex); |
| 57 | |
| 58 | auto nsVal = m_Data.find(field); |
| 59 | |
| 60 | if (nsVal == m_Data.end()) { |
| 61 | m_Data[field] = NamespaceValue{value, isConst || m_ConstValues}; |
| 62 | } else { |
| 63 | if (nsVal->second.Const) { |
| 64 | BOOST_THROW_EXCEPTION(ScriptError("Constant must not be modified.", debugInfo)); |
| 65 | } |
| 66 | |
| 67 | nsVal->second.Val = value; |
| 68 | } |
| 69 | } |
| 70 | |
| 71 | /** |
| 72 | * Returns the number of elements in the namespace. |
nothing calls this directly
no test coverage detected