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

Side by Side Diff: src/Utils.h

Issue 29809555: Issue #6526 - pass v8::Isolate to more functions because old approach is deprecated (Closed) Base URL: https://github.com/adblockplus/libadblockplus@4d9bcc12e77369cbc4bc04bace9a3e7fa03de17b
Patch Set: Created June 18, 2018, 10:22 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
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-present eyeo GmbH 3 * Copyright (C) 2006-present 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 13 matching lines...) Expand all
24 #include <string> 24 #include <string>
25 #include <vector> 25 #include <vector>
26 #include <v8.h> 26 #include <v8.h>
27 27
28 #include "AdblockPlus/JsValue.h" 28 #include "AdblockPlus/JsValue.h"
29 29
30 namespace AdblockPlus 30 namespace AdblockPlus
31 { 31 {
32 namespace Utils 32 namespace Utils
33 { 33 {
34 std::string FromV8String(const v8::Local<v8::Value>& value); 34 std::string FromV8String(v8::Isolate* isolate, const v8::Local<v8::Value>& v alue);
35 StringBuffer StringBufferFromV8String(const v8::Local<v8::Value>& value); 35 StringBuffer StringBufferFromV8String(v8::Isolate* isolate, const v8::Local< v8::Value>& value);
36 v8::Local<v8::String> ToV8String(v8::Isolate* isolate, const std::string& st r); 36 v8::Local<v8::String> ToV8String(v8::Isolate* isolate, const std::string& st r);
37 v8::Local<v8::String> StringBufferToV8String(v8::Isolate* isolate, const Str ingBuffer& bytes); 37 v8::Local<v8::String> StringBufferToV8String(v8::Isolate* isolate, const Str ingBuffer& bytes);
38 void ThrowExceptionInJS(v8::Isolate* isolate, const std::string& str); 38 void ThrowExceptionInJS(v8::Isolate* isolate, const std::string& str);
39 39
40 // Code for templated function has to be in a header file, can't be in .cpp 40 // Code for templated function has to be in a header file, can't be in .cpp
41 template<class T> 41 template<class T>
42 T TrimString(const T& text) 42 T TrimString(const T& text)
43 { 43 {
44 // Via http://stackoverflow.com/questions/216823/whats-the-best-way-to-tri m-stdstring 44 // Via http://stackoverflow.com/questions/216823/whats-the-best-way-to-tri m-stdstring
45 T trimmed(text); 45 T trimmed(text);
46 trimmed.erase(trimmed.begin(), std::find_if(trimmed.begin(), trimmed.end() , std::not1(std::ptr_fun<int, int>(std::isspace)))); 46 trimmed.erase(trimmed.begin(), std::find_if(trimmed.begin(), trimmed.end() , std::not1(std::ptr_fun<int, int>(std::isspace))));
47 trimmed.erase(std::find_if(trimmed.rbegin(), trimmed.rend(), std::not1(std ::ptr_fun<int, int>(std::isspace))).base(), trimmed.end()); 47 trimmed.erase(std::find_if(trimmed.rbegin(), trimmed.rend(), std::not1(std ::ptr_fun<int, int>(std::isspace))).base(), trimmed.end());
48 return trimmed; 48 return trimmed;
49 } 49 }
50 #ifdef _WIN32 50 #ifdef _WIN32
51 std::wstring ToUtf16String(const std::string& str); 51 std::wstring ToUtf16String(const std::string& str);
52 std::string ToUtf8String(const std::wstring& str); 52 std::string ToUtf8String(const std::wstring& str);
53 std::wstring CanonizeUrl(const std::wstring& url); 53 std::wstring CanonizeUrl(const std::wstring& url);
54 #endif 54 #endif
55 } 55 }
56 } 56 }
57 57
58 #endif 58 #endif
OLDNEW
« src/FileSystemJsObject.cpp ('K') | « src/JsValue.cpp ('k') | src/Utils.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld