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

Side by Side Diff: compiled/subscription/UserDefinedSubscription.cpp

Issue 29532626: Issue 5603 - Support references in parameters of exported functions (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore
Patch Set: Created Aug. 31, 2017, 12:36 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
OLDNEW
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-present eyeo GmbH 3 * Copyright (C) 2006-present 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 sizeof(filterTypeToCategory) / sizeof(filterTypeToCategory[0]) == Filter::Ty pe::VALUE_COUNT, 45 sizeof(filterTypeToCategory) / sizeof(filterTypeToCategory[0]) == Filter::Ty pe::VALUE_COUNT,
46 "Unexpected number of filter types, was a new type added?" 46 "Unexpected number of filter types, was a new type added?"
47 ); 47 );
48 } 48 }
49 49
50 UserDefinedSubscription::UserDefinedSubscription(const String& id) 50 UserDefinedSubscription::UserDefinedSubscription(const String& id)
51 : Subscription(Type::USERDEFINED, id), mDefaults(0) 51 : Subscription(Type::USERDEFINED, id), mDefaults(0)
52 { 52 {
53 } 53 }
54 54
55 bool UserDefinedSubscription::IsDefaultFor(const Filter* filter) const 55 bool UserDefinedSubscription::IsDefaultFor(const Filter& filter) const
56 { 56 {
57 if (filter->mType >= Filter::Type::VALUE_COUNT) 57 if (filter.mType >= Filter::Type::VALUE_COUNT)
58 { 58 {
59 assert(false, "Filter type exceeds valid range"); 59 assert(false, "Filter type exceeds valid range");
60 abort(); 60 abort();
61 } 61 }
62 return mDefaults & filterTypeToCategory[filter->mType]; 62 return mDefaults & filterTypeToCategory[filter.mType];
63 } 63 }
64 64
65 void UserDefinedSubscription::MakeDefaultFor(const Filter* filter) 65 void UserDefinedSubscription::MakeDefaultFor(const Filter& filter)
66 { 66 {
67 if (filter->mType >= Filter::Type::VALUE_COUNT) 67 if (filter.mType >= Filter::Type::VALUE_COUNT)
68 { 68 {
69 assert(false, "Filter type exceeds valid range"); 69 assert(false, "Filter type exceeds valid range");
70 abort(); 70 abort();
71 } 71 }
72 mDefaults |= filterTypeToCategory[filter->mType]; 72 mDefaults |= filterTypeToCategory[filter.mType];
73 } 73 }
74 74
75 void UserDefinedSubscription::InsertFilterAt(Filter* filter, unsigned pos) 75 void UserDefinedSubscription::InsertFilterAt(Filter& filter, unsigned pos)
76 { 76 {
77 if (pos >= mFilters.size()) 77 if (pos >= mFilters.size())
78 pos = mFilters.size(); 78 pos = mFilters.size();
79 mFilters.emplace(mFilters.begin() + pos, filter); 79 mFilters.emplace(mFilters.begin() + pos, &filter);
80 80
81 if (GetListed()) 81 if (GetListed())
82 { 82 {
83 FilterNotifier::FilterChange(FilterNotifier::Topic::FILTER_ADDED, filter, th is, 83 FilterNotifier::FilterChange(FilterNotifier::Topic::FILTER_ADDED, filter,
84 pos); 84 this, pos);
85 } 85 }
86 } 86 }
87 87
88 bool UserDefinedSubscription::RemoveFilterAt(unsigned pos) 88 bool UserDefinedSubscription::RemoveFilterAt(unsigned pos)
89 { 89 {
90 if (pos >= mFilters.size()) 90 if (pos >= mFilters.size())
91 return false; 91 return false;
92 92
93 FilterPtr filter(mFilters[pos]); 93 FilterPtr filter(mFilters[pos]);
94 mFilters.erase(mFilters.begin() + pos); 94 mFilters.erase(mFilters.begin() + pos);
95 if (GetListed()) 95 if (GetListed())
96 { 96 {
97 FilterNotifier::FilterChange(FilterNotifier::Topic::FILTER_REMOVED, 97 FilterNotifier::FilterChange(FilterNotifier::Topic::FILTER_REMOVED,
98 filter.get(), this, pos); 98 *filter.get(), this, pos);
99 } 99 }
100 return true; 100 return true;
101 } 101 }
102 102
103 OwnedString UserDefinedSubscription::Serialize() const 103 OwnedString UserDefinedSubscription::Serialize() const
104 { 104 {
105 OwnedString result(Subscription::Serialize()); 105 OwnedString result(Subscription::Serialize());
106 if (!IsGeneric()) 106 if (!IsGeneric())
107 { 107 {
108 result.append(u"defaults="_str); 108 result.append(u"defaults="_str);
109 if (mDefaults & FilterCategory::BLOCKING) 109 if (mDefaults & FilterCategory::BLOCKING)
110 result.append(u" blocking"_str); 110 result.append(u" blocking"_str);
111 if (mDefaults & FilterCategory::WHITELIST) 111 if (mDefaults & FilterCategory::WHITELIST)
112 result.append(u" whitelist"_str); 112 result.append(u" whitelist"_str);
113 if (mDefaults & FilterCategory::ELEMHIDE) 113 if (mDefaults & FilterCategory::ELEMHIDE)
114 result.append(u" elemhide"_str); 114 result.append(u" elemhide"_str);
115 result.append(u'\n'); 115 result.append(u'\n');
116 } 116 }
117 return result; 117 return result;
118 } 118 }
OLDNEW
« compiled/bindings/generator.cpp ('K') | « compiled/subscription/UserDefinedSubscription.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld