Rev 1657 | Rev 1741 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed
| Rev 1657 | Rev 1740 | ||
|---|---|---|---|
| Line 98... | Line 98... | ||
| 98 | } |
98 | } |
| 99 | } |
99 | } |
| 100 | 100 | ||
| 101 | Value Manager::Export_Log(const v8::Arguments& args) |
101 | Value Manager::Export_Log(const v8::Arguments& args) |
| 102 | { |
102 | { |
| - | 103 | v8::Locker lock; |
|
| 103 | v8::Context::Scope context_scope(Manager::Instance()->GetContext()); |
104 | v8::Context::Scope context_scope(Manager::Instance()->GetContext()); |
| 104 | 105 | ||
| 105 | //LOG.Debug(std::string(__FUNCTION__) + " called!"); |
106 | //LOG.Debug(std::string(__FUNCTION__) + " called!"); |
| 106 | 107 | ||
| 107 | if (args.Length() < 1) |
108 | if (args.Length() < 1) |
| Line 127... | Line 128... | ||
| 127 | this->io_service_.post(boost::bind(&Manager::ExecuteHandler, this, plugin_name, request_id, code)); |
128 | this->io_service_.post(boost::bind(&Manager::ExecuteHandler, this, plugin_name, request_id, code)); |
| 128 | } |
129 | } |
| 129 | 130 | ||
| 130 | bool Manager::CallHandler(std::string plugin_name, unsigned int request_id, std::string name, ArgumentListPointer arguments) |
131 | bool Manager::CallHandler(std::string plugin_name, unsigned int request_id, std::string name, ArgumentListPointer arguments) |
| 131 | { |
132 | { |
| - | 133 | v8::Locker lock; |
|
| 132 | v8::Context::Scope context_scope(this->context_); |
134 | v8::Context::Scope context_scope(this->context_); |
| 133 | v8::TryCatch try_catch; |
135 | v8::TryCatch try_catch; |
| 134 | 136 | ||
| 135 | this->current_plugin_name_ = plugin_name; |
137 | this->current_plugin_name_ = plugin_name; |
| 136 | this->current_request_id_ = request_id; |
138 | this->current_request_id_ = request_id; |
| Line 181... | Line 183... | ||
| 181 | } |
183 | } |
| 182 | } |
184 | } |
| 183 | 185 | ||
| 184 | this->context_ = v8::Context::New(NULL, raw_template); |
186 | this->context_ = v8::Context::New(NULL, raw_template); |
| 185 | 187 | ||
| - | 188 | v8::Locker lock; |
|
| 186 | v8::Context::Scope context_scope(this->context_); |
189 | v8::Context::Scope context_scope(this->context_); |
| 187 | 190 | ||
| 188 | for (unsigned int c = 0; c < this->plugins_.size(); c++) |
191 | for (unsigned int c = 0; c < this->plugins_.size(); c++) |
| 189 | { |
192 | { |
| 190 | this->LoadScript("plugin/" + this->plugins_[c]->GetName() + ".js"); |
193 | this->LoadScript("plugin/" + this->plugins_[c]->GetName() + ".js"); |
| Line 198... | Line 201... | ||
| 198 | } |
201 | } |
| 199 | } |
202 | } |
| 200 | 203 | ||
| 201 | bool Manager::ImportFunction(std::string functionname) |
204 | bool Manager::ImportFunction(std::string functionname) |
| 202 | { |
205 | { |
| - | 206 | v8::Locker lock; |
|
| 203 | v8::Context::Scope context_scope(this->context_); |
207 | v8::Context::Scope context_scope(this->context_); |
| 204 | 208 | ||
| 205 | v8::TryCatch try_catch; |
209 | v8::TryCatch try_catch; |
| 206 | 210 | ||
| 207 | v8::Handle<v8::String> process_name = v8::String::New(functionname.data()); |
211 | v8::Handle<v8::String> process_name = v8::String::New(functionname.data()); |
| Line 264... | Line 268... | ||
| 264 | 268 | ||
| 265 | code += "\n"; |
269 | code += "\n"; |
| 266 | 270 | ||
| 267 | file.close(); |
271 | file.close(); |
| 268 | 272 | ||
| - | 273 | v8::Locker lock; |
|
| 269 | v8::Context::Scope context_scope(this->context_); |
274 | v8::Context::Scope context_scope(this->context_); |
| 270 | 275 | ||
| 271 | v8::TryCatch try_catch; |
276 | v8::TryCatch try_catch; |
| 272 | 277 | ||
| 273 | v8::Handle<v8::Script> script = v8::Script::Compile(v8::String::New(code.data(), code.length()), |
278 | v8::Handle<v8::Script> script = v8::Script::Compile(v8::String::New(code.data(), code.length()), |
| Line 297... | Line 302... | ||
| 297 | 302 | ||
| 298 | void Manager::ExecuteHandler(std::string plugin_name, unsigned int request_id, std::string code) |
303 | void Manager::ExecuteHandler(std::string plugin_name, unsigned int request_id, std::string code) |
| 299 | { |
304 | { |
| 300 | std::string scriptname = "execute_" + plugin_name + ".js"; |
305 | std::string scriptname = "execute_" + plugin_name + ".js"; |
| 301 | 306 | ||
| - | 307 | v8::Locker lock; |
|
| 302 | v8::Context::Scope context_scope(this->context_); |
308 | v8::Context::Scope context_scope(this->context_); |
| 303 | 309 | ||
| 304 | v8::TryCatch try_catch; |
310 | v8::TryCatch try_catch; |
| 305 | 311 | ||
| 306 | v8::Handle<v8::Script> script = v8::Script::Compile(v8::String::New(code.data(), code.length()), |
312 | v8::Handle<v8::Script> script = v8::Script::Compile(v8::String::New(code.data(), code.length()), |
| Line 332... | Line 338... | ||
| 332 | this->current_request_id_ = 0; |
338 | this->current_request_id_ = 0; |
| 333 | } |
339 | } |
| 334 | 340 | ||
| 335 | std::string Manager::FormatException(v8::TryCatch& try_catch) |
341 | std::string Manager::FormatException(v8::TryCatch& try_catch) |
| 336 | { |
342 | { |
| - | 343 | v8::Locker lock; |
|
| 337 | v8::Context::Scope context_scope(this->context_); |
344 | v8::Context::Scope context_scope(this->context_); |
| 338 | 345 | ||
| 339 | std::string result; |
346 | std::string result; |
| 340 | 347 | ||
| 341 | v8::HandleScope handle_scope; |
348 | v8::HandleScope handle_scope; |