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

Side by Side Diff: compiled/library.cpp

Issue 29661608: Issue 6241 - Allow a native build. (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: addressed comments Created Jan. 11, 2018, 8:40 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 | « compiled/Utils.cpp ('k') | meson.build » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-present eyeo GmbH
4 *
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
7 * published by the Free Software Foundation.
8 *
9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18 #include <cwctype>
19 #include <mutex>
20 #include <regex>
21
22 #include "String.h"
23 #include "Utils.h"
24 #include "debug.h"
25 #include "library.h"
26
27
28 char16_t CharToLower(char16_t charCode)
29 {
30 return std::towlower(charCode);
31 }
32
33
34 void JSNotifyFilterChange(FilterNotifier::Topic topic, Filter& filter,
35 Subscription* subscription, unsigned int position)
36 {
37 }
38
39 void JSNotifySubscriptionChange(FilterNotifier::Topic topic,
40 Subscription& subscription)
41 {
42 }
43
44 namespace {
45 std::vector<std::unique_ptr<std::wregex>> regexPool;
sergei 2018/01/12 09:58:12 I missed it first time, but what is the whole poin
hub 2018/01/12 14:33:53 This is because of the original code and bindings
46 std::mutex regexPoolMutex;
47 }
48
49 int GenerateRegExp(const String& regexp, bool matchCase)
50 {
51 std::lock_guard<std::mutex> guard(regexPoolMutex);
52 auto index = regexPool.size();
53 auto flags = std::regex_constants::ECMAScript;
54 if (!matchCase)
55 flags |= std::regex_constants::icase;
56 regexPool.emplace_back(new std::wregex(StdWStringFromString(regexp), flags));
57 return index;
58 }
59
60 void DeleteRegExp(int id)
61 {
62 std::lock_guard<std::mutex> guard(regexPoolMutex);
63 if (id < regexPool.size())
64 regexPool[id].reset();
65 }
66
67 bool TestRegExp(int id, const String& str)
68 {
69 std::lock_guard<std::mutex> guard(regexPoolMutex);
70 if ((id < regexPool.size()) && regexPool[id])
71 return std::regex_match(StdWStringFromString(str), *regexPool[id]);
72
73 assert2(id < regexPool.size() && regexPool[id], "Invalid RegExp index.");
74 return false;
75 }
76
OLDNEW
« no previous file with comments | « compiled/Utils.cpp ('k') | meson.build » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld