summaryrefslogtreecommitdiffstats
path: root/js/public/RegExpFlags.h
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:13:27 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:13:27 +0000
commit40a355a42d4a9444dc753c04c6608dade2f06a23 (patch)
tree871fc667d2de662f171103ce5ec067014ef85e61 /js/public/RegExpFlags.h
parentAdding upstream version 124.0.1. (diff)
downloadfirefox-40a355a42d4a9444dc753c04c6608dade2f06a23.tar.xz
firefox-40a355a42d4a9444dc753c04c6608dade2f06a23.zip
Adding upstream version 125.0.1.upstream/125.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/public/RegExpFlags.h')
-rw-r--r--js/public/RegExpFlags.h43
1 files changed, 43 insertions, 0 deletions
diff --git a/js/public/RegExpFlags.h b/js/public/RegExpFlags.h
index 36a2e76c29..e4663786fc 100644
--- a/js/public/RegExpFlags.h
+++ b/js/public/RegExpFlags.h
@@ -12,6 +12,7 @@
#include "mozilla/Assertions.h" // MOZ_ASSERT
#include "mozilla/Attributes.h" // MOZ_IMPLICIT
+#include <ostream> // ostream
#include <stdint.h> // uint8_t
namespace JS {
@@ -129,6 +130,15 @@ class RegExpFlags {
explicit operator bool() const { return flags_ != 0; }
Flag value() const { return flags_; }
+ constexpr operator Flag() const { return flags_; }
+
+ void set(Flag flags, bool value) {
+ if (value) {
+ flags_ |= flags;
+ } else {
+ flags_ &= ~flags;
+ }
+ }
};
inline RegExpFlags& operator&=(RegExpFlags& flags, RegExpFlags::Flag flag) {
@@ -158,6 +168,39 @@ inline RegExpFlags operator|(const RegExpFlags& lhs, const RegExpFlags& rhs) {
return result;
}
+inline bool MaybeParseRegExpFlag(char c, RegExpFlags::Flag* flag) {
+ switch (c) {
+ case 'd':
+ *flag = RegExpFlag::HasIndices;
+ return true;
+ case 'g':
+ *flag = RegExpFlag::Global;
+ return true;
+ case 'i':
+ *flag = RegExpFlag::IgnoreCase;
+ return true;
+ case 'm':
+ *flag = RegExpFlag::Multiline;
+ return true;
+ case 's':
+ *flag = RegExpFlag::DotAll;
+ return true;
+ case 'u':
+ *flag = RegExpFlag::Unicode;
+ return true;
+ case 'v':
+ *flag = RegExpFlag::UnicodeSets;
+ return true;
+ case 'y':
+ *flag = RegExpFlag::Sticky;
+ return true;
+ default:
+ return false;
+ }
+}
+
+std::ostream& operator<<(std::ostream& os, RegExpFlags flags);
+
} // namespace JS
#endif // js_RegExpFlags_h