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: Created Jan. 10, 2018, 9:26 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 | « README.md ('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,77 @@
+/*
+ * 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 <regex>
+
+#include "String.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)
+{
sergei 2018/01/11 08:54:07 stubs are OK for present.
+}
+
+void JSNotifySubscriptionChange(FilterNotifier::Topic topic,
+ Subscription& subscription)
+{
+}
+
+namespace {
+ std::vector<std::unique_ptr<std::wregex>> mRegexPool;
sergei 2018/01/11 08:54:06 BTW, this code is not thread safe, we should be ve
hub 2018/01/11 20:41:27 Done.
+
+ std::wstring from_string(const String& str)
sergei 2018/01/11 08:54:07 What about putting this method into some utils.h (
hub 2018/01/11 20:41:27 Done.
+ {
+ std::wstring s;
+ for (String::size_type idx = 0; idx < str.length(); idx++)
+ s.push_back(str[idx]);
sergei 2018/01/11 08:54:07 std::string has the constructor accepting a pointe
hub 2018/01/11 20:41:27 std::wstring::value_type is a wchar_t which is 32-
sergei 2018/01/12 09:58:12 Acknowledged.
+
+ return s;
+ }
+}
+
+int GenerateRegExp(const String& regexp, bool matchCase)
+{
+ auto index = mRegexPool.size();
+ auto flags = std::regex_constants::ECMAScript;
+ if (!matchCase)
+ flags |= std::regex_constants::icase;
+ mRegexPool.emplace_back(new std::wregex(from_string(regexp), flags));
+ return index;
+}
+
+void DeleteRegExp(int id)
+{
+ if (id < mRegexPool.size())
+ mRegexPool[id].reset();
sergei 2018/01/11 08:54:07 What about using of std::list and its iterator as
hub 2018/01/11 20:41:27 How do you know if the id is valid? erase() invali
sergei 2018/01/12 09:58:12 IMO there is no necessity in it, as soon as the re
+}
+
+bool TestRegExp(int id, const String& str)
+{
+ if ((id < mRegexPool.size()) && mRegexPool[id])
+ return std::regex_match(from_string(str), *mRegexPool[id]);
+
+ return false;
sergei 2018/01/11 08:54:07 Could please add an assert here because it should
hub 2018/01/11 20:41:27 Done.
+}
+
« no previous file with comments | « README.md ('k') | meson.build » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld