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

Unified Diff: compiled/filter/RegExpFilter.cpp

Issue 29425555: Issue 5201 - [emscripten] Replace EM_ASM calls by a custom JavaScript library (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore
Patch Set: Moved all declarations into a single header and corrected emscripten.h includes Created April 30, 2017, 3:14 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
Index: compiled/filter/RegExpFilter.cpp
===================================================================
--- a/compiled/filter/RegExpFilter.cpp
+++ b/compiled/filter/RegExpFilter.cpp
@@ -15,19 +15,18 @@
* along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
*/
#include <cctype>
#include <climits>
#include <cstdio>
#include <string>
-#include <emscripten.h>
-
#include "RegExpFilter.h"
+#include "../library.h"
#include "../StringScanner.h"
#include "../StringMap.h"
namespace
{
enum
{
TYPE_OTHER = 0x1,
@@ -132,21 +131,16 @@ namespace
}
result.append(currChar);
}
prevChar = currChar;
}
return result;
}
- int GenerateRegExp(const String& regexp, bool matchCase)
- {
- return EM_ASM_INT(return regexps.create($0, $1), &regexp, matchCase);
- }
-
void NormalizeWhitespace(DependentString& text)
{
// We want to remove all spaces but bail out early in the common scenario
// that the string contains no spaces.
// Look for the first space
String::size_type len = text.length();
String::size_type pos;
@@ -286,17 +280,17 @@ namespace
RegExpFilter::RegExpFilter(Type type, const String& text, const RegExpFilterData& data)
: ActiveFilter(type, text, true), mData(data)
{
}
RegExpFilter::~RegExpFilter()
{
if (mData.HasRegExp())
- EM_ASM_ARGS(regexps.delete($0), mData.mRegexpId);
+ DeleteRegExp(mData.mRegexpId);
}
Filter::Type RegExpFilter::Parse(DependentString& text, DependentString& error,
RegExpFilterData& data)
{
NormalizeWhitespace(text);
Filter::Type type = Type::BLOCKING;
@@ -394,10 +388,10 @@ bool RegExpFilter::Matches(const String&
return false;
}
if (!mData.RegExpParsingDone())
{
const OwnedString pattern(mData.GetRegExpSource(mText));
mData.SetRegExp(GenerateRegExp(RegExpFromSource(pattern), mData.mMatchCase));
}
- return EM_ASM_INT(return regexps.test($0, $1), mData.mRegexpId, &location);
+ return TestRegExp(mData.mRegexpId, location);
}

Powered by Google App Engine
This is Rietveld