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

Side by Side Diff: include/AdblockPlus/V8ValueHolder.h

Issue 29364548: Issue 4188 - Update libadblockplus-android to use the latest libadblockplus (Closed)
Patch Set: recompiled for libadblockplus git:70ac2462a5e6437b5b1f58455b2e0172c33cc432. Duplicated on gihtub: https://github.com/4ntoine/libadblockplus-binaries/commit/5b9c89920c72f0b980a268bc80b73705c29a034a Created Dec. 5, 2016, 11:20 a.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
(Empty)
1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2015 Eyeo GmbH
4 *
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
7 * published by the Free Software Foundation.
8 *
9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18 #ifndef ADBLOCK_PLUS_V8_VALUE_HOLDER_H
19 #define ADBLOCK_PLUS_V8_VALUE_HOLDER_H
20
21 #include <memory>
22
23 namespace v8
24 {
25 class Isolate;
26 template<class T> class Handle;
27 template<class T> class Persistent;
28 }
29
30 namespace AdblockPlus
31 {
32 template<class T>
33 class V8ValueHolder
34 {
35 public:
36 typedef typename v8::Persistent<T> V8Persistent;
37 V8ValueHolder()
38 {
39 reset();
40 }
41 V8ValueHolder(v8::Isolate* isolate, v8::Handle<T> value)
42 {
43 reset(isolate, value);
44 }
45 ~V8ValueHolder()
46 {
47 if (this->value.get())
48 {
49 this->value->Dispose(this->isolate);
50 this->value.reset(0);
51 }
52 }
53 void reset(v8::Isolate* isolate, v8::Handle<T> value)
54 {
55 reset(isolate, std::auto_ptr<V8Persistent>(new V8Persistent(isolate, value )));
56 }
57 void reset(v8::Isolate* isolate = 0, std::auto_ptr<V8Persistent> value = std ::auto_ptr<V8Persistent>(new V8Persistent()))
58 {
59 if (this->value.get())
60 {
61 this->value->Dispose(this->isolate);
62 this->value.reset(0);
63 }
64
65 if (!value->IsEmpty())
66 {
67 this->isolate = isolate;
68 this->value = value;
69 }
70 }
71
72 operator V8Persistent&() const
73 {
74 return *value;
75 }
76 private:
77 v8::Isolate* isolate;
78 std::auto_ptr<V8Persistent> value;
79 };
80 }
81
82 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld