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 RegExpConstructor_h 22 #define RegExpConstructor_h 23 24 #include "InternalFunction.h" 25 #include <wtf/OwnPtr.h> 26 27 namespace JSC { 28 29 class RegExp; 30 class RegExpPrototype; 31 struct RegExpConstructorPrivate; 32 33 class RegExpConstructor : public InternalFunction { 34 public: 35 RegExpConstructor(ExecState*, PassRefPtr<Structure>, RegExpPrototype*); 36 createStructure(JSValue prototype)37 static PassRefPtr<Structure> createStructure(JSValue prototype) 38 { 39 return Structure::create(prototype, TypeInfo(ObjectType, ImplementsHasInstance)); 40 } 41 42 virtual void put(ExecState*, const Identifier& propertyName, JSValue, PutPropertySlot&); 43 virtual bool getOwnPropertySlot(ExecState*, const Identifier& propertyName, PropertySlot&); 44 45 static const ClassInfo info; 46 47 void performMatch(RegExp*, const UString&, int startOffset, int& position, int& length, int** ovector = 0); 48 JSObject* arrayOfMatches(ExecState*) const; 49 50 void setInput(const UString&); 51 const UString& input() const; 52 53 void setMultiline(bool); 54 bool multiline() const; 55 56 JSValue getBackref(ExecState*, unsigned) const; 57 JSValue getLastParen(ExecState*) const; 58 JSValue getLeftContext(ExecState*) const; 59 JSValue getRightContext(ExecState*) const; 60 61 private: 62 virtual ConstructType getConstructData(ConstructData&); 63 virtual CallType getCallData(CallData&); 64 classInfo()65 virtual const ClassInfo* classInfo() const { return &info; } 66 67 OwnPtr<RegExpConstructorPrivate> d; 68 }; 69 70 RegExpConstructor* asRegExpConstructor(JSValue); 71 72 JSObject* constructRegExp(ExecState*, const ArgList&); 73 asRegExpConstructor(JSValue value)74 inline RegExpConstructor* asRegExpConstructor(JSValue value) 75 { 76 ASSERT(asObject(value)->inherits(&RegExpConstructor::info)); 77 return static_cast<RegExpConstructor*>(asObject(value)); 78 } 79 80 } // namespace JSC 81 82 #endif // RegExpConstructor_h 83