|
14 | 14 |
|
15 | 15 | namespace node::url_pattern { |
16 | 16 |
|
| 17 | +#define URL_PATTERN_COMPONENTS(V) \ |
| 18 | + V(Protocol, protocol) \ |
| 19 | + V(Username, username) \ |
| 20 | + V(Password, password) \ |
| 21 | + V(Hostname, hostname) \ |
| 22 | + V(Port, port) \ |
| 23 | + V(Pathname, pathname) \ |
| 24 | + V(Search, search) \ |
| 25 | + V(Hash, hash) |
| 26 | + |
17 | 27 | // By default, ada::url_pattern doesn't ship with any regex library. |
18 | 28 | // Ada has a std::regex implementation, but it is considered unsafe and does |
19 | 29 | // not have a fully compliant ecmascript syntax support. Therefore, Ada |
@@ -42,15 +52,12 @@ class URLPattern : public BaseObject { |
42 | 52 | // - Functions |
43 | 53 | static void Exec(const v8::FunctionCallbackInfo<v8::Value>& info); |
44 | 54 | static void Test(const v8::FunctionCallbackInfo<v8::Value>& info); |
45 | | - // - Getters |
46 | | - static void Hash(const v8::FunctionCallbackInfo<v8::Value>& info); |
47 | | - static void Hostname(const v8::FunctionCallbackInfo<v8::Value>& info); |
48 | | - static void Password(const v8::FunctionCallbackInfo<v8::Value>& info); |
49 | | - static void Pathname(const v8::FunctionCallbackInfo<v8::Value>& info); |
50 | | - static void Port(const v8::FunctionCallbackInfo<v8::Value>& info); |
51 | | - static void Protocol(const v8::FunctionCallbackInfo<v8::Value>& info); |
52 | | - static void Search(const v8::FunctionCallbackInfo<v8::Value>& info); |
53 | | - static void Username(const v8::FunctionCallbackInfo<v8::Value>& info); |
| 55 | + // - Component Getters |
| 56 | +#define URL_PATTERN_COMPONENT_GETTERS(name, _) \ |
| 57 | + static void name(const v8::FunctionCallbackInfo<v8::Value>& info); |
| 58 | + URL_PATTERN_COMPONENTS(URL_PATTERN_COMPONENT_GETTERS) |
| 59 | +#undef URL_PATTERN_COMPONENT_GETTERS |
| 60 | + // - Has Regexp Groups |
54 | 61 | static void HasRegexpGroups(const v8::FunctionCallbackInfo<v8::Value>& info); |
55 | 62 |
|
56 | 63 | void MemoryInfo(MemoryTracker* tracker) const override; |
@@ -86,14 +93,10 @@ class URLPattern : public BaseObject { |
86 | 93 | private: |
87 | 94 | ada::url_pattern<URLPatternRegexProvider> url_pattern_; |
88 | 95 | // Getter methods |
89 | | - v8::MaybeLocal<v8::Value> Hash() const; |
90 | | - v8::MaybeLocal<v8::Value> Hostname() const; |
91 | | - v8::MaybeLocal<v8::Value> Password() const; |
92 | | - v8::MaybeLocal<v8::Value> Pathname() const; |
93 | | - v8::MaybeLocal<v8::Value> Port() const; |
94 | | - v8::MaybeLocal<v8::Value> Protocol() const; |
95 | | - v8::MaybeLocal<v8::Value> Search() const; |
96 | | - v8::MaybeLocal<v8::Value> Username() const; |
| 96 | +#define URL_PATTERN_COMPONENT_GETTERS(name, _) \ |
| 97 | + v8::MaybeLocal<v8::Value> name() const; |
| 98 | + URL_PATTERN_COMPONENTS(URL_PATTERN_COMPONENT_GETTERS) |
| 99 | +#undef URL_PATTERN_COMPONENT_GETTERS |
97 | 100 | bool HasRegExpGroups() const; |
98 | 101 | // Public API |
99 | 102 | v8::MaybeLocal<v8::Value> Exec( |
|
0 commit comments