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

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

Issue 6584950149087232: Issue 1280 - Update v8 (Closed)
Patch Set: Created Oct. 24, 2014, 12:42 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
« no previous file with comments | « include/AdblockPlus/JsValue.h ('k') | libadblockplus.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 15 matching lines...) Expand all
26 template<class T> class Handle; 26 template<class T> class Handle;
27 template<class T> class Persistent; 27 template<class T> class Persistent;
28 } 28 }
29 29
30 namespace AdblockPlus 30 namespace AdblockPlus
31 { 31 {
32 template<class T> 32 template<class T>
33 class V8ValueHolder 33 class V8ValueHolder
34 { 34 {
35 public: 35 public:
36 typedef typename v8::Persistent<T> V8Persistent;
36 V8ValueHolder() 37 V8ValueHolder()
37 { 38 {
38 reset(0, v8::Persistent<T>()); 39 reset();
39 }
40 V8ValueHolder(V8ValueHolder& value)
41 {
42 reset(value.isolate, static_cast<v8::Handle<T> >(value));
43 }
44 V8ValueHolder(v8::Isolate* isolate, v8::Persistent<T> value)
45 {
46 reset(isolate, value);
47 } 40 }
48 V8ValueHolder(v8::Isolate* isolate, v8::Handle<T> value) 41 V8ValueHolder(v8::Isolate* isolate, v8::Handle<T> value)
49 { 42 {
50 reset(isolate, value); 43 reset(isolate, value);
51 } 44 }
52 ~V8ValueHolder() 45 ~V8ValueHolder()
53 { 46 {
54 if (this->value.get()) 47 if (this->value.get())
55 { 48 {
56 this->value->Dispose(this->isolate); 49 this->value->Dispose(this->isolate);
57 this->value.reset(0); 50 this->value.reset(0);
58 } 51 }
59 } 52 }
60 void reset(v8::Isolate* isolate, v8::Persistent<T> value) 53 void reset(v8::Isolate* isolate, v8::Handle<T> value)
54 {
55 reset(isolate, std::auto_ptr<V8Persistent>(new V8Persistent(isolate, val ue)));
56 }
57 void reset(v8::Isolate* isolate = nullptr, std::auto_ptr<V8Persistent> value = std::auto_ptr<V8Persistent>(new V8Persistent()))
61 { 58 {
62 if (this->value.get()) 59 if (this->value.get())
63 { 60 {
64 this->value->Dispose(this->isolate); 61 this->value->Dispose(this->isolate);
65 this->value.reset(0); 62 this->value.reset(0);
66 } 63 }
67 64
68 if (!value.IsEmpty()) 65 if (!value->IsEmpty())
69 { 66 {
70 this->isolate = isolate; 67 this->isolate = isolate;
71 this->value.reset(new v8::Persistent<T>(value)); 68 this->value = value;
72 } 69 }
73 } 70 }
74 71
75 void reset(v8::Isolate* isolate, v8::Handle<T> value) 72 operator V8Persistent&() const
76 {
77 reset(isolate, v8::Persistent<T>::New(isolate, value));
78 }
79
80 T* operator->() const
81 {
82 return **value;
83 }
84 operator v8::Handle<T>() const
85 {
86 return *value;
87 }
88 operator v8::Persistent<T>() const
89 { 73 {
90 return *value; 74 return *value;
91 } 75 }
92 private: 76 private:
93 v8::Isolate* isolate; 77 v8::Isolate* isolate;
94 std::auto_ptr<v8::Persistent<T> > value; 78 std::auto_ptr<V8Persistent> value;
95 }; 79 };
96 } 80 }
97 81
98 #endif 82 #endif
OLDNEW
« no previous file with comments | « include/AdblockPlus/JsValue.h ('k') | libadblockplus.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld