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

Delta Between Two Patch Sets: src/JsValue.cpp

Issue 10254076: API cleanup, get rid of JsObject and GetProperty() methods that don`t return JsValue (Closed)
Left Patch Set: Created April 26, 2013, 11:41 a.m.
Right Patch Set: Slightly better Filter/Subscription constructors Created April 26, 2013, 11:51 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Right: Side by side diff | Download
« no previous file with change/comment | « src/FilterEngine.cpp ('k') | test/FilterEngine.cpp » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
(no file at all)
1 #include <AdblockPlus.h> 1 #include <AdblockPlus.h>
2 2
3 namespace 3 namespace
4 { 4 {
5 std::string fromV8String(v8::Handle<v8::Value> value) 5 std::string fromV8String(v8::Handle<v8::Value> value)
6 { 6 {
7 v8::String::Utf8Value stringValue(value); 7 v8::String::Utf8Value stringValue(value);
8 if (stringValue.length()) 8 if (stringValue.length())
9 return std::string(*stringValue, stringValue.length()); 9 return std::string(*stringValue, stringValue.length());
10 else 10 else
11 return std::string(); 11 return std::string();
12 } 12 }
13 13
14 v8::Local<v8::String> toV8String(const std::string& str) 14 v8::Local<v8::String> toV8String(const std::string& str)
15 { 15 {
16 return v8::String::New(str.c_str(), str.length()); 16 return v8::String::New(str.c_str(), str.length());
17 } 17 }
18 } 18 }
19 19
20 AdblockPlus::JsValue::JsValue(AdblockPlus::JsEnginePtr jsEngine, 20 AdblockPlus::JsValue::JsValue(AdblockPlus::JsEnginePtr jsEngine,
21 v8::Handle<v8::Value> value) 21 v8::Handle<v8::Value> value)
22 : jsEngine(jsEngine), 22 : jsEngine(jsEngine),
23 value(v8::Persistent<v8::Value>::New(jsEngine->isolate, value)) 23 value(v8::Persistent<v8::Value>::New(jsEngine->isolate, value))
24 {
25 }
26
27 AdblockPlus::JsValue::JsValue(AdblockPlus::JsValuePtr value)
28 : jsEngine(value->jsEngine),
29 value(v8::Persistent<v8::Value>::New(jsEngine->isolate, value->value))
24 { 30 {
25 } 31 }
26 32
27 AdblockPlus::JsValue::~JsValue() 33 AdblockPlus::JsValue::~JsValue()
28 { 34 {
29 value.Dispose(jsEngine->isolate); 35 value.Dispose(jsEngine->isolate);
30 } 36 }
31 37
32 bool AdblockPlus::JsValue::IsUndefined() const 38 bool AdblockPlus::JsValue::IsUndefined() const
33 { 39 {
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 const v8::TryCatch tryCatch; 211 const v8::TryCatch tryCatch;
206 v8::Persistent<v8::Function> func = v8::Persistent<v8::Function>::Cast(value); 212 v8::Persistent<v8::Function> func = v8::Persistent<v8::Function>::Cast(value);
207 v8::Local<v8::Value> result = func->Call(thisObj, argc, argv); 213 v8::Local<v8::Value> result = func->Call(thisObj, argc, argv);
208 delete argv; 214 delete argv;
209 215
210 if (tryCatch.HasCaught()) 216 if (tryCatch.HasCaught())
211 throw AdblockPlus::JsError(tryCatch.Exception(), tryCatch.Message()); 217 throw AdblockPlus::JsError(tryCatch.Exception(), tryCatch.Message());
212 218
213 return JsValuePtr(new JsValue(jsEngine, result)); 219 return JsValuePtr(new JsValue(jsEngine, result));
214 } 220 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld