Index: include/AdblockPlus/V8ValueHolder.h |
diff --git a/include/AdblockPlus/V8ValueHolder.h b/include/AdblockPlus/V8ValueHolder.h |
index 8b17859b4e1d98b69221f5eb7aae112d39e4f104..254f3652651ac714769d9e07bdbfb91faf34d4c6 100644 |
--- a/include/AdblockPlus/V8ValueHolder.h |
+++ b/include/AdblockPlus/V8ValueHolder.h |
@@ -1,6 +1,6 @@ |
/* |
- * This file is part of Adblock Plus <http://adblockplus.org/>, |
- * Copyright (C) 2006-2014 Eyeo GmbH |
+ * This file is part of Adblock Plus <https://adblockplus.org/>, |
+ * Copyright (C) 2006-2015 Eyeo GmbH |
* |
* Adblock Plus is free software: you can redistribute it and/or modify |
* it under the terms of the GNU General Public License version 3 as |
@@ -33,17 +33,10 @@ namespace AdblockPlus |
class V8ValueHolder |
{ |
public: |
+ typedef typename v8::Persistent<T> V8Persistent; |
V8ValueHolder() |
{ |
- reset(0, v8::Persistent<T>()); |
- } |
- V8ValueHolder(V8ValueHolder& value) |
- { |
- reset(value.isolate, static_cast<v8::Handle<T> >(value)); |
- } |
- V8ValueHolder(v8::Isolate* isolate, v8::Persistent<T> value) |
- { |
- reset(isolate, value); |
+ reset(); |
} |
V8ValueHolder(v8::Isolate* isolate, v8::Handle<T> value) |
{ |
@@ -57,7 +50,11 @@ namespace AdblockPlus |
this->value.reset(0); |
} |
} |
- void reset(v8::Isolate* isolate, v8::Persistent<T> value) |
+ void reset(v8::Isolate* isolate, v8::Handle<T> value) |
+ { |
+ reset(isolate, std::auto_ptr<V8Persistent>(new V8Persistent(isolate, value))); |
+ } |
+ void reset(v8::Isolate* isolate = 0, std::auto_ptr<V8Persistent> value = std::auto_ptr<V8Persistent>(new V8Persistent())) |
{ |
if (this->value.get()) |
{ |
@@ -65,33 +62,20 @@ namespace AdblockPlus |
this->value.reset(0); |
} |
- if (!value.IsEmpty()) |
+ if (!value->IsEmpty()) |
{ |
this->isolate = isolate; |
- this->value.reset(new v8::Persistent<T>(value)); |
+ this->value = value; |
} |
} |
- void reset(v8::Isolate* isolate, v8::Handle<T> value) |
- { |
- reset(isolate, v8::Persistent<T>::New(isolate, value)); |
- } |
- |
- T* operator->() const |
- { |
- return **value; |
- } |
- operator v8::Handle<T>() const |
- { |
- return *value; |
- } |
- operator v8::Persistent<T>() const |
+ operator V8Persistent&() const |
{ |
return *value; |
} |
private: |
v8::Isolate* isolate; |
- std::auto_ptr<v8::Persistent<T> > value; |
+ std::auto_ptr<V8Persistent> value; |
}; |
} |