]> git.saurik.com Git - apple/javascriptcore.git/blame - runtime/RegExpObject.h
JavaScriptCore-721.26.tar.gz
[apple/javascriptcore.git] / runtime / RegExpObject.h
CommitLineData
9dae56ea
A
1/*
2 * Copyright (C) 1999-2000 Harri Porten (porten@kde.org)
3 * Copyright (C) 2003, 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 RegExpObject_h
22#define RegExpObject_h
23
24#include "JSObject.h"
25#include "RegExp.h"
26
27namespace JSC {
28
29 class RegExpObject : public JSObject {
30 public:
f9bf01c6 31 RegExpObject(NonNullPassRefPtr<Structure>, NonNullPassRefPtr<RegExp>);
9dae56ea
A
32 virtual ~RegExpObject();
33
34 void setRegExp(PassRefPtr<RegExp> r) { d->regExp = r; }
35 RegExp* regExp() const { return d->regExp.get(); }
36
37 void setLastIndex(double lastIndex) { d->lastIndex = lastIndex; }
38 double lastIndex() const { return d->lastIndex; }
39
ba379fdc
A
40 JSValue test(ExecState*, const ArgList&);
41 JSValue exec(ExecState*, const ArgList&);
9dae56ea
A
42
43 virtual bool getOwnPropertySlot(ExecState*, const Identifier& propertyName, PropertySlot&);
f9bf01c6 44 virtual bool getOwnPropertyDescriptor(ExecState*, const Identifier&, PropertyDescriptor&);
ba379fdc 45 virtual void put(ExecState*, const Identifier& propertyName, JSValue, PutPropertySlot&);
9dae56ea
A
46
47 virtual const ClassInfo* classInfo() const { return &info; }
48 static const ClassInfo info;
49
ba379fdc 50 static PassRefPtr<Structure> createStructure(JSValue prototype)
9dae56ea 51 {
f9bf01c6 52 return Structure::create(prototype, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount);
9dae56ea
A
53 }
54
f9bf01c6
A
55 protected:
56 static const unsigned StructureFlags = OverridesGetOwnPropertySlot | JSObject::StructureFlags;
57
9dae56ea
A
58 private:
59 bool match(ExecState*, const ArgList&);
60
61 virtual CallType getCallData(CallData&);
62
f9bf01c6
A
63 struct RegExpObjectData : FastAllocBase {
64 RegExpObjectData(NonNullPassRefPtr<RegExp> regExp, double lastIndex)
9dae56ea
A
65 : regExp(regExp)
66 , lastIndex(lastIndex)
67 {
68 }
69
70 RefPtr<RegExp> regExp;
71 double lastIndex;
72 };
73
74 OwnPtr<RegExpObjectData> d;
75 };
76
ba379fdc 77 RegExpObject* asRegExpObject(JSValue);
9dae56ea 78
ba379fdc 79 inline RegExpObject* asRegExpObject(JSValue value)
9dae56ea
A
80 {
81 ASSERT(asObject(value)->inherits(&RegExpObject::info));
82 return static_cast<RegExpObject*>(asObject(value));
83 }
84
85} // namespace JSC
86
87#endif // RegExpObject_h