Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(661)

Unified Diff: src/objects.h

Issue 2775303002: [regexp] Named capture support for string replacements (Closed)
Patch Set: Only cast if not undefined Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/messages.h ('k') | src/objects.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/objects.h
diff --git a/src/objects.h b/src/objects.h
index 4e2f3239705a5bda0666a23e074fe60ff1e10e1d..dad95363be255527147597dfe6a90a18247743e1 100644
--- a/src/objects.h
+++ b/src/objects.h
@@ -8269,6 +8269,7 @@ class JSRegExp: public JSObject {
Handle<String> flags_string);
inline Type TypeTag();
+ // Number of captures (without the match itself).
inline int CaptureCount();
inline Flags GetFlags();
inline String* Pattern();
@@ -8341,7 +8342,7 @@ class JSRegExp: public JSObject {
// Number of captures in the compiled regexp.
static const int kIrregexpCaptureCountIndex = kDataIndex + 5;
// Maps names of named capture groups (at indices 2i) to their corresponding
- // capture group indices (at indices 2i + 1).
+ // (1-based) capture group indices (at indices 2i + 1).
static const int kIrregexpCaptureNameMapIndex = kDataIndex + 6;
static const int kIrregexpDataSize = kIrregexpCaptureNameMapIndex + 1;
@@ -9196,10 +9197,15 @@ class String: public Name {
class Match {
public:
virtual Handle<String> GetMatch() = 0;
- virtual MaybeHandle<String> GetCapture(int i, bool* capture_exists) = 0;
virtual Handle<String> GetPrefix() = 0;
virtual Handle<String> GetSuffix() = 0;
+
virtual int CaptureCount() = 0;
+ virtual bool HasNamedCaptures() = 0;
+ virtual MaybeHandle<String> GetCapture(int i, bool* capture_exists) = 0;
+ virtual MaybeHandle<String> GetNamedCapture(Handle<String> name,
+ bool* capture_exists) = 0;
+
virtual ~Match() {}
};
@@ -9214,6 +9220,11 @@ class String: public Name {
inline bool Equals(String* other);
inline static bool Equals(Handle<String> one, Handle<String> two);
bool IsUtf8EqualTo(Vector<const char> str, bool allow_prefix_match = false);
+
+ // Dispatches to Is{One,Two}ByteEqualTo.
+ template <typename Char>
+ bool IsEqualTo(Vector<const Char> str);
+
bool IsOneByteEqualTo(Vector<const uint8_t> str);
bool IsTwoByteEqualTo(Vector<const uc16> str);
« no previous file with comments | « src/messages.h ('k') | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698