Index: include/AdblockPlus/JsValue.h |
=================================================================== |
--- a/include/AdblockPlus/JsValue.h |
+++ b/include/AdblockPlus/JsValue.h |
@@ -28,6 +28,7 @@ |
{ |
class Value; |
template<class T> class Handle; |
+ template<class T> class Local; |
} |
namespace AdblockPlus |
@@ -53,9 +54,22 @@ |
*/ |
class JsValue |
{ |
- friend class JsEngine; |
public: |
- JsValue(JsValuePtr value); |
+ struct Private |
+ { |
+ private: |
+ // allow access to the ctr only JsEngine and don't allow JsEngine to access other members. |
+ friend class JsEngine; |
+ friend class JsValue; |
+ struct CtrArg |
Felix Dahlke
2014/10/31 05:31:57
So the idea is that only friend classes can access
sergei
2014/10/31 11:47:01
Here it's merely another form of `friend class JsE
Felix Dahlke
2014/10/31 15:07:51
At first glance it seems like a rather complex hac
sergei
2014/10/31 16:13:35
reverted.
JIC, it's mainly for std::make_{shared,u
|
+ { |
+ }; |
+ }; |
+ protected: |
+ typedef Private::CtrArg PrivateCtrArg; |
+ JsValue(const JsValuePtr& value); |
+ public: |
+ JsValue(const JsEnginePtr& jsEngine, const v8::Handle<v8::Value> value, PrivateCtrArg); |
virtual ~JsValue(); |
bool IsUndefined() const; |
@@ -94,7 +108,7 @@ |
void SetProperty(const std::string& name, const std::string& val); |
void SetProperty(const std::string& name, int64_t val); |
void SetProperty(const std::string& name, bool val); |
- void SetProperty(const std::string& name, JsValuePtr value); |
+ void SetProperty(const std::string& name, const JsValuePtr& value); |
inline void SetProperty(const std::string& name, const char* val) |
{ |
SetProperty(name, std::string(val)); |
@@ -123,11 +137,12 @@ |
JsValuePtr Call(const JsValueList& params = JsValueList(), |
AdblockPlus::JsValuePtr thisPtr = AdblockPlus::JsValuePtr()) const; |
+ v8::Local<v8::Value> unwrapValue() const; |
Felix Dahlke
2014/10/31 05:31:57
All functions should start with an upper case lett
sergei
2014/10/31 11:47:01
fixed
|
+ private: |
+ void SetProperty(const std::string& name, const v8::Handle<v8::Value> val); |
protected: |
- JsValue(JsEnginePtr jsEngine, v8::Handle<v8::Value> value); |
- void SetProperty(const std::string& name, v8::Handle<v8::Value> val); |
- |
JsEnginePtr jsEngine; |
+ private: |
V8ValueHolder<v8::Value> value; |
}; |
} |