| 34 | } |
| 35 | |
| 36 | void ScriptGlobal::Set(const String& name, const Value& value) |
| 37 | { |
| 38 | std::vector<String> tokens = name.Split("."); |
| 39 | |
| 40 | if (tokens.empty()) |
| 41 | BOOST_THROW_EXCEPTION(std::invalid_argument("Name must not be empty")); |
| 42 | |
| 43 | { |
| 44 | ObjectLock olock(m_Globals); |
| 45 | |
| 46 | Namespace::Ptr parent = m_Globals; |
| 47 | |
| 48 | for (std::vector<String>::size_type i = 0; i < tokens.size(); i++) { |
| 49 | const String& token = tokens[i]; |
| 50 | |
| 51 | if (i + 1 != tokens.size()) { |
| 52 | Value vparent; |
| 53 | |
| 54 | if (!parent->Get(token, &vparent)) { |
| 55 | Namespace::Ptr dict = new Namespace(); |
| 56 | parent->Set(token, dict); |
| 57 | parent = dict; |
| 58 | } else { |
| 59 | parent = vparent; |
| 60 | } |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | parent->Set(tokens[tokens.size() - 1], value); |
| 65 | } |
| 66 | } |
| 67 | |
| 68 | void ScriptGlobal::SetConst(const String& name, const Value& value) |
| 69 | { |