]>
git.saurik.com Git - apple/javascriptcore.git/blob - kjs/regexp_object.h
2 * Copyright (C) 1999-2000 Harri Porten (porten@kde.org)
3 * Copyright (C) 2003, 2007, 2008 Apple Inc. All Rights Reserved.
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.
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.
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
21 #ifndef REGEXP_OBJECT_H_
22 #define REGEXP_OBJECT_H_
24 #include "function_object.h"
29 struct RegExpObjectImpPrivate
;
31 class RegExpPrototype
: public JSObject
{
33 RegExpPrototype(ExecState
*, ObjectPrototype
*, FunctionPrototype
*);
35 virtual const ClassInfo
* classInfo() const { return &info
; }
36 static const ClassInfo info
;
39 class RegExpImp
: public JSObject
{
41 enum { Global
, IgnoreCase
, Multiline
, Source
, LastIndex
};
43 RegExpImp(RegExpPrototype
*, PassRefPtr
<RegExp
>);
46 void setRegExp(PassRefPtr
<RegExp
> r
) { m_regExp
= r
; }
47 RegExp
* regExp() const { return m_regExp
.get(); }
49 JSValue
* test(ExecState
*, const List
& args
);
50 JSValue
* exec(ExecState
*, const List
& args
);
52 virtual bool implementsCall() const;
53 virtual JSValue
* callAsFunction(ExecState
*, JSObject
*, const List
&);
54 bool getOwnPropertySlot(ExecState
*, const Identifier
&, PropertySlot
&);
55 JSValue
* getValueProperty(ExecState
*, int token
) const;
56 void put(ExecState
*, const Identifier
&, JSValue
*, int attributes
= None
);
57 void putValueProperty(ExecState
*, int token
, JSValue
*, int attributes
);
59 virtual const ClassInfo
* classInfo() const { return &info
; }
60 static const ClassInfo info
;
62 void setLastIndex(double lastIndex
) { m_lastIndex
= lastIndex
; }
65 bool match(ExecState
*, const List
& args
);
67 RefPtr
<RegExp
> m_regExp
;
71 class RegExpObjectImp
: public InternalFunctionImp
{
73 enum { Dollar1
, Dollar2
, Dollar3
, Dollar4
, Dollar5
, Dollar6
, Dollar7
, Dollar8
, Dollar9
,
74 Input
, Multiline
, LastMatch
, LastParen
, LeftContext
, RightContext
};
76 RegExpObjectImp(ExecState
*, FunctionPrototype
*, RegExpPrototype
*);
78 virtual bool implementsConstruct() const;
79 virtual JSObject
* construct(ExecState
*, const List
&);
80 JSObject
* createRegExpImp(ExecState
*, PassRefPtr
<RegExp
>);
81 virtual JSValue
* callAsFunction(ExecState
*, JSObject
*, const List
&);
82 virtual void put(ExecState
*, const Identifier
&, JSValue
*, int attributes
= None
);
83 void putValueProperty(ExecState
*, int token
, JSValue
*, int attributes
);
84 virtual bool getOwnPropertySlot(ExecState
*, const Identifier
&, PropertySlot
&);
85 JSValue
* getValueProperty(ExecState
*, int token
) const;
86 virtual const ClassInfo
* classInfo() const { return &info
; }
88 void performMatch(RegExp
*, const UString
&, int startOffset
, int& position
, int& length
, int** ovector
= 0);
89 JSObject
* arrayOfMatches(ExecState
*) const;
90 const UString
& input() const;
93 JSValue
* getBackref(unsigned) const;
94 JSValue
* getLastParen() const;
95 JSValue
* getLeftContext() const;
96 JSValue
* getRightContext() const;
98 OwnPtr
<RegExpObjectImpPrivate
> d
;
100 static const ClassInfo info
;