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

Unified Diff: compiled/subscription/Subscription.h

Issue 29384812: Issue 4127 - [emscripten] Convert subscription classes to C++ - Part 1 (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore
Patch Set: Created March 15, 2017, 3:05 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/subscription/DownloadableSubscription.cpp ('k') | compiled/subscription/Subscription.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: compiled/subscription/Subscription.h
===================================================================
new file mode 100644
--- /dev/null
+++ b/compiled/subscription/Subscription.h
@@ -0,0 +1,87 @@
+#pragma once
+
+#include <vector>
+
+#include "../filter/Filter.h"
+#include "../String.h"
+#include "../intrusive_ptr.h"
+#include "../debug.h"
+
+#define SUBSCRIPTION_PROPERTY(type, name, getter, setter) \
+ private:\
+ type name;\
+ public:\
+ type EMSCRIPTEN_KEEPALIVE getter() const\
+ {\
+ return name;\
+ }\
+ void EMSCRIPTEN_KEEPALIVE setter(type value)\
+ {\
+ if (name != value)\
+ {\
+ type oldvalue = name;\
+ name = value;\
+ DependentString action(u"subscription."_str #name);\
+ EM_ASM_ARGS({\
+ var subscription = new (exports[Subscription_mapping[$2]])($1);\
+ FilterNotifier.triggerListeners(readString($0), subscription, $3, $4);\
+ }, &action, this, mType, value, oldvalue);\
+ }\
+ }
+
+#define SUBSCRIPTION_STRING_PROPERTY(name, getter, setter) \
+ private:\
+ OwnedString name;\
+ public:\
+ const String& EMSCRIPTEN_KEEPALIVE getter() const\
+ {\
+ return name;\
+ }\
+ void EMSCRIPTEN_KEEPALIVE setter(const String& value)\
+ {\
+ if (!name.equals(value))\
+ {\
+ OwnedString oldvalue(name);\
+ name = value;\
+ DependentString action(u"subscription."_str #name);\
+ EM_ASM_ARGS({\
+ var subscription = new (exports[Subscription_mapping[$2]])($1);\
+ FilterNotifier.triggerListeners(readString($0), subscription, readString($3), readString($4));\
+ }, &action, this, mType, &value, &oldvalue);\
+ }\
+ }
+
+class Subscription : public ref_counted
+{
+protected:
+ OwnedString mID;
+ std::vector<Filter> mFilters;
+
+public:
+ enum Type
+ {
+ UNKNOWN = 0,
+ DOWNLOADABLE = 1,
+ USERDEFINED = 2
+ };
+
+ explicit Subscription(Type type, const String& id);
+ ~Subscription();
+
+ Type mType;
+
+ EMSCRIPTEN_KEEPALIVE const String& GetID() const
+ {
+ return mID;
+ }
+
+ SUBSCRIPTION_STRING_PROPERTY(mTitle, GetTitle, SetTitle);
+ SUBSCRIPTION_PROPERTY(bool, mDisabled, GetDisabled, SetDisabled);
+
+ EMSCRIPTEN_KEEPALIVE OwnedString Serialize() const;
+ EMSCRIPTEN_KEEPALIVE OwnedString SerializeFilters() const;
+
+ static EMSCRIPTEN_KEEPALIVE Subscription* FromID(const String& id);
+};
+
+typedef intrusive_ptr<Subscription> SubscriptionPtr;
« no previous file with comments | « compiled/subscription/DownloadableSubscription.cpp ('k') | compiled/subscription/Subscription.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld