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 |