Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: src/JsEngine.cpp

Issue 29396582: Issue 5039 - add support of nullable non-object values in settings
Left Patch Set: fix comparison with undefined Created March 28, 2017, 1:49 p.m.
Right Patch Set: rebase Created March 29, 2017, 4:39 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Right: Side by side diff | Download
« no previous file with change/comment | « src/FilterEngine.cpp ('k') | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
(no file at all)
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2017 eyeo GmbH 3 * Copyright (C) 2006-2017 eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 const JsContext context(shared_from_this()); 220 const JsContext context(shared_from_this());
221 return JsValuePtr(new JsValue(shared_from_this(), v8::Boolean::New(val))); 221 return JsValuePtr(new JsValue(shared_from_this(), v8::Boolean::New(val)));
222 } 222 }
223 223
224 AdblockPlus::JsValuePtr AdblockPlus::JsEngine::NewObject() 224 AdblockPlus::JsValuePtr AdblockPlus::JsEngine::NewObject()
225 { 225 {
226 const JsContext context(shared_from_this()); 226 const JsContext context(shared_from_this());
227 return JsValuePtr(new JsValue(shared_from_this(), v8::Object::New())); 227 return JsValuePtr(new JsValue(shared_from_this(), v8::Object::New()));
228 } 228 }
229 229
230 JsValuePtr JsEngine::NullValue()
231 {
232 const JsContext context(shared_from_this());
233 return JsValuePtr(new JsValue(shared_from_this(), v8::Null()));
234 }
235
230 AdblockPlus::JsValuePtr AdblockPlus::JsEngine::NewCallback( 236 AdblockPlus::JsValuePtr AdblockPlus::JsEngine::NewCallback(
231 v8::InvocationCallback callback) 237 v8::InvocationCallback callback)
232 { 238 {
233 const JsContext context(shared_from_this()); 239 const JsContext context(shared_from_this());
234 240
235 // Note: we are leaking this weak pointer, no obvious way to destroy it when 241 // Note: we are leaking this weak pointer, no obvious way to destroy it when
236 // it's no longer used 242 // it's no longer used
237 std::weak_ptr<JsEngine>* data = 243 std::weak_ptr<JsEngine>* data =
238 new std::weak_ptr<JsEngine>(shared_from_this()); 244 new std::weak_ptr<JsEngine>(shared_from_this());
239 v8::Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(callback, 245 v8::Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(callback,
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 335
330 336
331 void AdblockPlus::JsEngine::SetGlobalProperty(const std::string& name, 337 void AdblockPlus::JsEngine::SetGlobalProperty(const std::string& name,
332 AdblockPlus::JsValuePtr value) 338 AdblockPlus::JsValuePtr value)
333 { 339 {
334 auto global = GetGlobalObject(); 340 auto global = GetGlobalObject();
335 if (!global) 341 if (!global)
336 throw std::runtime_error("Global object cannot be null"); 342 throw std::runtime_error("Global object cannot be null");
337 global->SetProperty(name, value); 343 global->SetProperty(name, value);
338 } 344 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld