#define YarrPattern_h
#include <wtf/CheckedArithmetic.h>
-#include <wtf/OwnPtr.h>
-#include <wtf/PassOwnPtr.h>
#include <wtf/RefCounted.h>
#include <wtf/Vector.h>
#include <wtf/text/WTFString.h>
PatternAlternative* addNewAlternative()
{
- PatternAlternative* alternative = new PatternAlternative(this);
- m_alternatives.append(adoptPtr(alternative));
- return alternative;
+ m_alternatives.append(std::make_unique<PatternAlternative>(this));
+ return static_cast<PatternAlternative*>(m_alternatives.last().get());
}
- Vector<OwnPtr<PatternAlternative>> m_alternatives;
+ Vector<std::unique_ptr<PatternAlternative>> m_alternatives;
PatternAlternative* m_parent;
unsigned m_minimumSize;
unsigned m_callFrameSize;
// (please to be calling newlineCharacterClass() et al on your
// friendly neighborhood YarrPattern instance to get nicely
// cached copies).
-CharacterClass* newlineCreate();
-CharacterClass* digitsCreate();
-CharacterClass* spacesCreate();
-CharacterClass* wordcharCreate();
-CharacterClass* nondigitsCreate();
-CharacterClass* nonspacesCreate();
-CharacterClass* nonwordcharCreate();
+std::unique_ptr<CharacterClass> newlineCreate();
+std::unique_ptr<CharacterClass> digitsCreate();
+std::unique_ptr<CharacterClass> spacesCreate();
+std::unique_ptr<CharacterClass> wordcharCreate();
+std::unique_ptr<CharacterClass> nondigitsCreate();
+std::unique_ptr<CharacterClass> nonspacesCreate();
+std::unique_ptr<CharacterClass> nonwordcharCreate();
struct TermChain {
TermChain(PatternTerm term)
CharacterClass* newlineCharacterClass()
{
- if (!newlineCached)
- m_userCharacterClasses.append(adoptPtr(newlineCached = newlineCreate()));
+ if (!newlineCached) {
+ m_userCharacterClasses.append(newlineCreate());
+ newlineCached = m_userCharacterClasses.last().get();
+ }
return newlineCached;
}
CharacterClass* digitsCharacterClass()
{
- if (!digitsCached)
- m_userCharacterClasses.append(adoptPtr(digitsCached = digitsCreate()));
+ if (!digitsCached) {
+ m_userCharacterClasses.append(digitsCreate());
+ digitsCached = m_userCharacterClasses.last().get();
+ }
return digitsCached;
}
CharacterClass* spacesCharacterClass()
{
- if (!spacesCached)
- m_userCharacterClasses.append(adoptPtr(spacesCached = spacesCreate()));
+ if (!spacesCached) {
+ m_userCharacterClasses.append(spacesCreate());
+ spacesCached = m_userCharacterClasses.last().get();
+ }
return spacesCached;
}
CharacterClass* wordcharCharacterClass()
{
- if (!wordcharCached)
- m_userCharacterClasses.append(adoptPtr(wordcharCached = wordcharCreate()));
+ if (!wordcharCached) {
+ m_userCharacterClasses.append(wordcharCreate());
+ wordcharCached = m_userCharacterClasses.last().get();
+ }
return wordcharCached;
}
CharacterClass* nondigitsCharacterClass()
{
- if (!nondigitsCached)
- m_userCharacterClasses.append(adoptPtr(nondigitsCached = nondigitsCreate()));
+ if (!nondigitsCached) {
+ m_userCharacterClasses.append(nondigitsCreate());
+ nondigitsCached = m_userCharacterClasses.last().get();
+ }
return nondigitsCached;
}
CharacterClass* nonspacesCharacterClass()
{
- if (!nonspacesCached)
- m_userCharacterClasses.append(adoptPtr(nonspacesCached = nonspacesCreate()));
+ if (!nonspacesCached) {
+ m_userCharacterClasses.append(nonspacesCreate());
+ nonspacesCached = m_userCharacterClasses.last().get();
+ }
return nonspacesCached;
}
CharacterClass* nonwordcharCharacterClass()
{
- if (!nonwordcharCached)
- m_userCharacterClasses.append(adoptPtr(nonwordcharCached = nonwordcharCreate()));
+ if (!nonwordcharCached) {
+ m_userCharacterClasses.append(nonwordcharCreate());
+ nonwordcharCached = m_userCharacterClasses.last().get();
+ }
return nonwordcharCached;
}
unsigned m_numSubpatterns;
unsigned m_maxBackReference;
PatternDisjunction* m_body;
- Vector<OwnPtr<PatternDisjunction>, 4> m_disjunctions;
- Vector<OwnPtr<CharacterClass>> m_userCharacterClasses;
+ Vector<std::unique_ptr<PatternDisjunction>, 4> m_disjunctions;
+ Vector<std::unique_ptr<CharacterClass>> m_userCharacterClasses;
private:
const char* compile(const String& patternString);