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

Delta Between Two Patch Sets: compiled/filter/RegExpFilter.cpp

Issue 29398655: Issue 5062 - [emscripten] Allow generation of custom bindings code (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore
Left Patch Set: Improved binding generation Created April 4, 2017, 3:40 p.m.
Right Patch Set: Rebased Created April 13, 2017, 1:06 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « compiled/filter/RegExpFilter.h ('k') | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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-2017 eyeo GmbH 3 * Copyright (C) 2006-2017 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 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 AddSitekey(DependentString(sitekeys, start, scanner.position() - start)) ; 346 AddSitekey(DependentString(sitekeys, start, scanner.position() - start)) ;
347 start = scanner.position() + 1; 347 start = scanner.position() + 1;
348 } 348 }
349 } 349 }
350 } 350 }
351 351
352 void RegExpFilter::GenerateCustomBindings() 352 void RegExpFilter::GenerateCustomBindings()
353 { 353 {
354 printf("exports.RegExpFilter.typeMap = {\n"); 354 printf("exports.RegExpFilter.typeMap = {\n");
355 355
356 for (const auto& it : typeMap) 356 for (const auto& item : typeMap)
357 { 357 {
358 std::string type(it.first.length(), '\0'); 358 std::string type(item.first.length(), '\0');
359 for (int i = 0; i < it.first.length(); i++) 359 for (int i = 0; i < item.first.length(); i++)
360 type[i] = (it.first[i] == '-' ? '_' : toupper(it.first[i])); 360 type[i] = (item.first[i] == '-' ? '_' : toupper(item.first[i]));
361 printf(" %s: %i,\n", type.c_str(), it.second); 361 printf(" %s: %i,\n", type.c_str(), item.second);
362 } 362 }
363 printf("};\n"); 363 printf("};\n");
364 } 364 }
365 365
366 RegExpFilter::DomainMap* RegExpFilter::GetDomains() const 366 RegExpFilter::DomainMap* RegExpFilter::GetDomains() const
367 { 367 {
368 if (!mData.DomainsParsingDone()) 368 if (!mData.DomainsParsingDone())
369 { 369 {
370 ParseDomains(mData.GetDomainsSource(mText), u'|'); 370 ParseDomains(mData.GetDomainsSource(mText), u'|');
371 mData.SetDomainsParsingDone(); 371 mData.SetDomainsParsingDone();
(...skipping 22 matching lines...) Expand all
394 return false; 394 return false;
395 } 395 }
396 396
397 if (!mData.RegExpParsingDone()) 397 if (!mData.RegExpParsingDone())
398 { 398 {
399 const OwnedString pattern(mData.GetRegExpSource(mText)); 399 const OwnedString pattern(mData.GetRegExpSource(mText));
400 mData.SetRegExp(GenerateRegExp(RegExpFromSource(pattern), mData.mMatchCase)) ; 400 mData.SetRegExp(GenerateRegExp(RegExpFromSource(pattern), mData.mMatchCase)) ;
401 } 401 }
402 return EM_ASM_INT(return regexps.test($0, $1), mData.mRegexpId, &location); 402 return EM_ASM_INT(return regexps.test($0, $1), mData.mRegexpId, &location);
403 } 403 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld