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

Unified Diff: compiled/tools.h

Issue 29333474: Issue 4125 - [emscripten] Convert filter classes to C++ (Closed)
Patch Set: Fixed some bugs and exposed/tested more properties Created Jan. 15, 2016, 3:40 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/tools.h
===================================================================
new file mode 100644
--- /dev/null
+++ b/compiled/tools.h
@@ -0,0 +1,68 @@
+#ifndef ADBLOCKPLUS_TOOLS_H
+#define ADBLOCKPLUS_TOOLS_H
+
+#include <emscripten.h>
+#include <cstddef>
+#include <string>
+
+#define PROPERTY(classprefix, type, name) \
+ private:\
+ type name;\
+ public:\
+ type get_##name()\
+ {\
+ return name;\
+ }\
+ void set_##name(type value)\
+ {\
+ if (name != value)\
+ {\
+ type oldvalue = value;\
+ name = value;\
+ /* TODO FilterNotifier.triggerListeners(#classprefix "." #name, this, value, oldValue); */\
+ }\
+ }
+
+#define FILTER_PROPERTY(type, name) PROPERTY(filter, type, name)
+
+#define EXPOSE_PROPERTY_GETTER(class, t, name) \
+ t EMSCRIPTEN_KEEPALIVE class##_get_##name(class* obj)\
+ {\
+ return obj->get_##name();\
+ }
+
+#define EXPOSE_PROPERTY_SETTER(class, t, name) \
+ void EMSCRIPTEN_KEEPALIVE class##_set_##name(class* obj, t value)\
+ {\
+ obj->set_##name(value);\
+ }
+
+#define EXPOSE_PROPERTY(class, t, name) \
+ EXPOSE_PROPERTY_GETTER(class, t, name) \
+ EXPOSE_PROPERTY_SETTER(class, t, name)
+
+#define EXPOSE_READONLY_PROPERTY(class, t, name) \
+ EXPOSE_PROPERTY_GETTER(class, t, name)
+
+#define EXPOSE_STRPROPERTY_GETTER(class, name) \
+ char16_t* EMSCRIPTEN_KEEPALIVE class##_get_##name(class* obj, size_t* resultLen)\
+ {\
+ return stringToBuffer(obj->get_##name(), resultLen);\
+ }
+
+#define EXPOSE_STRPROPERTY_SETTER(class, name) \
+ void EMSCRIPTEN_KEEPALIVE class##_set_##name(class* obj, char16_t* value, size_t len)\
+ {\
+ obj->set_##name(std::u16string(value, len));\
+ }
+
+#define EXPOSE_STRPROPERTY(class, name) \
+ EXPOSE_PROPERTY_STRGETTER(class, name) \
+ EXPOSE_PROPERTY_STRSETTER(class, name)
+
+#define EXPOSE_READONLY_STRPROPERTY(class, name) \
+ EXPOSE_STRPROPERTY_GETTER(class, name)
+
+char16_t* stringToBuffer(const std::u16string& str, size_t* resultLen);
+
+#endif
« compiled/Filter.cpp ('K') | « compiled/pre.js ('k') | compiled/tools.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld