source: webkit/trunk/JavaScriptCore/kjs/regexp.h@ 34946

Last change on this file since 34946 was 30109, checked in by Darin Adler, 17 years ago

Reviewed by Mitz.

We'll want to do this to every RefCounted class, one at a time.

  • kjs/nodes.h: (KJS::RegExpNode::RegExpNode): Use RegExp::create instead of new RegExp.
  • kjs/regexp.cpp: (KJS::RegExp::RegExp): Marked inline, set initial ref count to 1. (KJS::RegExp::create): Added. Calls new RegExp then adopts the initial ref.
  • kjs/regexp.h: Reformatted. Made the constructors private. Added static create functions that return objects already wrapped in PassRefPtr.
  • kjs/regexp_object.cpp: (KJS::regExpProtoFuncCompile): Use RegExp::create instead of new RegExp. (KJS::RegExpObjectImp::construct): Ditto.
  • kjs/string_object.cpp: (KJS::stringProtoFuncMatch): Ditto. (KJS::stringProtoFuncSearch): Ditto.
  • Property svn:eol-style set to native
File size: 2.4 KB
Line 
1/*
2 * Copyright (C) 1999-2000 Harri Porten ([email protected])
3 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 *
19 */
20
21#ifndef KJS_REGEXP_H
22#define KJS_REGEXP_H
23
24#include "ustring.h"
25#include <wtf/Forward.h>
26#include <wtf/RefCounted.h>
27
28struct JSRegExp;
29
30namespace KJS {
31
32 class RegExp : public RefCounted<RegExp> {
33 public:
34 static PassRefPtr<RegExp> create(const UString& pattern);
35 static PassRefPtr<RegExp> create(const UString& pattern, const UString& flags);
36 ~RegExp();
37
38 bool global() const { return m_flagBits & Global; }
39 bool ignoreCase() const { return m_flagBits & IgnoreCase; }
40 bool multiline() const { return m_flagBits & Multiline; }
41
42 const UString& pattern() const { return m_pattern; }
43 const UString& flags() const { return m_flags; }
44
45 bool isValid() const { return !m_constructionError; }
46 const char* errorMessage() const { return m_constructionError; }
47
48 int match(const UString&, int offset, OwnArrayPtr<int>* ovector = 0);
49 unsigned numSubpatterns() const { return m_numSubpatterns; }
50
51 private:
52 RegExp(const UString& pattern);
53 RegExp(const UString& pattern, const UString& flags);
54
55 void compile();
56
57 enum FlagBits { Global = 1, IgnoreCase = 2, Multiline = 4 };
58
59 UString m_pattern; // FIXME: Just decompile m_regExp instead of storing this.
60 UString m_flags; // FIXME: Just decompile m_regExp instead of storing this.
61 int m_flagBits;
62 JSRegExp* m_regExp;
63 const char* m_constructionError;
64 unsigned m_numSubpatterns;
65 };
66
67} // namespace
68
69#endif
Note: See TracBrowser for help on using the repository browser.