OLD | NEW |
(Empty) | |
| 1 #ifndef ADBLOCKPLUS_TOOLS_H |
| 2 #define ADBLOCKPLUS_TOOLS_H |
| 3 |
| 4 #include <emscripten.h> |
| 5 #include <cstddef> |
| 6 #include <string> |
| 7 |
| 8 #define PROPERTY(classprefix, type, name) \ |
| 9 private:\ |
| 10 type name;\ |
| 11 public:\ |
| 12 type get_##name()\ |
| 13 {\ |
| 14 return name;\ |
| 15 }\ |
| 16 void set_##name(type value)\ |
| 17 {\ |
| 18 if (name != value)\ |
| 19 {\ |
| 20 type oldvalue = value;\ |
| 21 name = value;\ |
| 22 /* TODO FilterNotifier.triggerListeners(#classprefix "." #name, this,
value, oldValue); */\ |
| 23 }\ |
| 24 } |
| 25 |
| 26 #define FILTER_PROPERTY(type, name) PROPERTY(filter, type, name) |
| 27 |
| 28 #define EXPOSE_PROPERTY_GETTER(class, t, name) \ |
| 29 t EMSCRIPTEN_KEEPALIVE class##_get_##name(class* obj)\ |
| 30 {\ |
| 31 return obj->get_##name();\ |
| 32 } |
| 33 |
| 34 #define EXPOSE_PROPERTY_SETTER(class, t, name) \ |
| 35 void EMSCRIPTEN_KEEPALIVE class##_set_##name(class* obj, t value)\ |
| 36 {\ |
| 37 obj->set_##name(value);\ |
| 38 } |
| 39 |
| 40 #define EXPOSE_PROPERTY(class, t, name) \ |
| 41 EXPOSE_PROPERTY_GETTER(class, t, name) \ |
| 42 EXPOSE_PROPERTY_SETTER(class, t, name) |
| 43 |
| 44 #define EXPOSE_READONLY_PROPERTY(class, t, name) \ |
| 45 EXPOSE_PROPERTY_GETTER(class, t, name) |
| 46 |
| 47 #define EXPOSE_STRPROPERTY_GETTER(class, name) \ |
| 48 char16_t* EMSCRIPTEN_KEEPALIVE class##_get_##name(class* obj, size_t* result
Len)\ |
| 49 {\ |
| 50 return stringToBuffer(obj->get_##name(), resultLen);\ |
| 51 } |
| 52 |
| 53 #define EXPOSE_STRPROPERTY_SETTER(class, name) \ |
| 54 void EMSCRIPTEN_KEEPALIVE class##_set_##name(class* obj, char16_t* value, si
ze_t len)\ |
| 55 {\ |
| 56 obj->set_##name(std::u16string(value, len));\ |
| 57 } |
| 58 |
| 59 #define EXPOSE_STRPROPERTY(class, name) \ |
| 60 EXPOSE_PROPERTY_STRGETTER(class, name) \ |
| 61 EXPOSE_PROPERTY_STRSETTER(class, name) |
| 62 |
| 63 #define EXPOSE_READONLY_STRPROPERTY(class, name) \ |
| 64 EXPOSE_STRPROPERTY_GETTER(class, name) |
| 65 |
| 66 char16_t* stringToBuffer(const std::u16string& str, size_t* resultLen); |
| 67 |
| 68 #endif |
OLD | NEW |