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

Side by Side Diff: src/JsEngine.cpp

Issue 5163715573841920: Issue 768 - Switch from TR1 to C++11 (Closed)
Patch Set: Created July 11, 2014, 2:24 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <http://adblockplus.org/>, 2 * This file is part of Adblock Plus <http://adblockplus.org/>,
3 * Copyright (C) 2006-2014 Eyeo GmbH 3 * Copyright (C) 2006-2014 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 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 return JsValuePtr(new JsValue(shared_from_this(), v8::Object::New())); 121 return JsValuePtr(new JsValue(shared_from_this(), v8::Object::New()));
122 } 122 }
123 123
124 AdblockPlus::JsValuePtr AdblockPlus::JsEngine::NewCallback( 124 AdblockPlus::JsValuePtr AdblockPlus::JsEngine::NewCallback(
125 v8::InvocationCallback callback) 125 v8::InvocationCallback callback)
126 { 126 {
127 const JsContext context(shared_from_this()); 127 const JsContext context(shared_from_this());
128 128
129 // Note: we are leaking this weak pointer, no obvious way to destroy it when 129 // Note: we are leaking this weak pointer, no obvious way to destroy it when
130 // it's no longer used 130 // it's no longer used
131 std::tr1::weak_ptr<JsEngine>* data = 131 std::weak_ptr<JsEngine>* data =
132 new std::tr1::weak_ptr<JsEngine>(shared_from_this()); 132 new std::weak_ptr<JsEngine>(shared_from_this());
133 v8::Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(callback, 133 v8::Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(callback,
134 v8::External::New(data)); 134 v8::External::New(data));
135 return JsValuePtr(new JsValue(shared_from_this(), templ->GetFunction())); 135 return JsValuePtr(new JsValue(shared_from_this(), templ->GetFunction()));
136 } 136 }
137 137
138 AdblockPlus::JsEnginePtr AdblockPlus::JsEngine::FromArguments(const v8::Argument s& arguments) 138 AdblockPlus::JsEnginePtr AdblockPlus::JsEngine::FromArguments(const v8::Argument s& arguments)
139 { 139 {
140 const v8::Local<const v8::External> external = 140 const v8::Local<const v8::External> external =
141 v8::Local<const v8::External>::Cast(arguments.Data()); 141 v8::Local<const v8::External>::Cast(arguments.Data());
142 std::tr1::weak_ptr<JsEngine>* data = 142 std::weak_ptr<JsEngine>* data =
143 static_cast<std::tr1::weak_ptr<JsEngine>*>(external->Value()); 143 static_cast<std::weak_ptr<JsEngine>*>(external->Value());
144 JsEnginePtr result = data->lock(); 144 JsEnginePtr result = data->lock();
145 if (!result) 145 if (!result)
146 throw std::runtime_error("Oops, our JsEngine is gone, how did that happen?") ; 146 throw std::runtime_error("Oops, our JsEngine is gone, how did that happen?") ;
147 return result; 147 return result;
148 } 148 }
149 149
150 AdblockPlus::JsValueList AdblockPlus::JsEngine::ConvertArguments(const v8::Argum ents& arguments) 150 AdblockPlus::JsValueList AdblockPlus::JsEngine::ConvertArguments(const v8::Argum ents& arguments)
151 { 151 {
152 const JsContext context(shared_from_this()); 152 const JsContext context(shared_from_this());
153 JsValueList list; 153 JsValueList list;
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 return logSystem; 193 return logSystem;
194 } 194 }
195 195
196 void AdblockPlus::JsEngine::SetLogSystem(AdblockPlus::LogSystemPtr val) 196 void AdblockPlus::JsEngine::SetLogSystem(AdblockPlus::LogSystemPtr val)
197 { 197 {
198 if (!val) 198 if (!val)
199 throw std::runtime_error("LogSystem cannot be null"); 199 throw std::runtime_error("LogSystem cannot be null");
200 200
201 logSystem = val; 201 logSystem = val;
202 } 202 }
OLDNEW

Powered by Google App Engine
This is Rietveld