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

Unified 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.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « compiled/Utils.cpp ('k') | meson.build » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: compiled/library.cpp
===================================================================
new file mode 100644
--- /dev/null
+++ b/compiled/library.cpp
@@ -0,0 +1,76 @@
+/*
+ * This file is part of Adblock Plus <https://adblockplus.org/>,
+ * Copyright (C) 2006-present 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
+ * published by the Free Software Foundation.
+ *
+ * Adblock Plus is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <cwctype>
+#include <mutex>
+#include <regex>
+
+#include "String.h"
+#include "Utils.h"
+#include "debug.h"
+#include "library.h"
+
+
+char16_t CharToLower(char16_t charCode)
+{
+ return std::towlower(charCode);
+}
+
+
+void JSNotifyFilterChange(FilterNotifier::Topic topic, Filter& filter,
+ Subscription* subscription, unsigned int position)
+{
+}
+
+void JSNotifySubscriptionChange(FilterNotifier::Topic topic,
+ Subscription& subscription)
+{
+}
+
+namespace {
+ 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
+ std::mutex regexPoolMutex;
+}
+
+int GenerateRegExp(const String& regexp, bool matchCase)
+{
+ std::lock_guard<std::mutex> guard(regexPoolMutex);
+ auto index = regexPool.size();
+ auto flags = std::regex_constants::ECMAScript;
+ if (!matchCase)
+ flags |= std::regex_constants::icase;
+ regexPool.emplace_back(new std::wregex(StdWStringFromString(regexp), flags));
+ return index;
+}
+
+void DeleteRegExp(int id)
+{
+ std::lock_guard<std::mutex> guard(regexPoolMutex);
+ if (id < regexPool.size())
+ regexPool[id].reset();
+}
+
+bool TestRegExp(int id, const String& str)
+{
+ std::lock_guard<std::mutex> guard(regexPoolMutex);
+ if ((id < regexPool.size()) && regexPool[id])
+ return std::regex_match(StdWStringFromString(str), *regexPool[id]);
+
+ assert2(id < regexPool.size() && regexPool[id], "Invalid RegExp index.");
+ return false;
+}
+
« 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