~ubuntu-branches/ubuntu/karmic/webkit/karmic-proposed

« back to all changes in this revision

Viewing changes to JavaScriptCore/runtime/RegExpPrototype.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Gustavo Noronha Silva
  • Date: 2009-05-15 18:30:58 UTC
  • mto: (4.4.1 sid) (1.2.2 upstream) (16.1.1 lucid)
  • mto: This revision was merged to the branch mainline in revision 8.
  • Revision ID: james.westby@ubuntu.com-20090515183058-35m5or0ufm5tutud
Tags: upstream-1.1.7
ImportĀ upstreamĀ versionĀ 1.1.7

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
 
24
24
#include "ArrayPrototype.h"
25
25
#include "JSArray.h"
 
26
#include "JSFunction.h"
26
27
#include "JSObject.h"
27
28
#include "JSString.h"
28
29
#include "JSValue.h"
35
36
 
36
37
ASSERT_CLASS_FITS_IN_CELL(RegExpPrototype);
37
38
 
38
 
static JSValuePtr regExpProtoFuncTest(ExecState*, JSObject*, JSValuePtr, const ArgList&);
39
 
static JSValuePtr regExpProtoFuncExec(ExecState*, JSObject*, JSValuePtr, const ArgList&);
40
 
static JSValuePtr regExpProtoFuncCompile(ExecState*, JSObject*, JSValuePtr, const ArgList&);
41
 
static JSValuePtr regExpProtoFuncToString(ExecState*, JSObject*, JSValuePtr, const ArgList&);
 
39
static JSValue JSC_HOST_CALL regExpProtoFuncTest(ExecState*, JSObject*, JSValue, const ArgList&);
 
40
static JSValue JSC_HOST_CALL regExpProtoFuncExec(ExecState*, JSObject*, JSValue, const ArgList&);
 
41
static JSValue JSC_HOST_CALL regExpProtoFuncCompile(ExecState*, JSObject*, JSValue, const ArgList&);
 
42
static JSValue JSC_HOST_CALL regExpProtoFuncToString(ExecState*, JSObject*, JSValue, const ArgList&);
42
43
 
43
44
// ECMA 15.10.5
44
45
 
47
48
RegExpPrototype::RegExpPrototype(ExecState* exec, PassRefPtr<Structure> structure, Structure* prototypeFunctionStructure)
48
49
    : JSObject(structure)
49
50
{
50
 
    putDirectFunctionWithoutTransition(exec, new (exec) PrototypeFunction(exec, prototypeFunctionStructure, 0, exec->propertyNames().compile, regExpProtoFuncCompile), DontEnum);
51
 
    putDirectFunctionWithoutTransition(exec, new (exec) PrototypeFunction(exec, prototypeFunctionStructure, 0, exec->propertyNames().exec, regExpProtoFuncExec), DontEnum);
52
 
    putDirectFunctionWithoutTransition(exec, new (exec) PrototypeFunction(exec, prototypeFunctionStructure, 0, exec->propertyNames().test, regExpProtoFuncTest), DontEnum);
53
 
    putDirectFunctionWithoutTransition(exec, new (exec) PrototypeFunction(exec, prototypeFunctionStructure, 0, exec->propertyNames().toString, regExpProtoFuncToString), DontEnum);
 
51
    putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 0, exec->propertyNames().compile, regExpProtoFuncCompile), DontEnum);
 
52
    putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 0, exec->propertyNames().exec, regExpProtoFuncExec), DontEnum);
 
53
    putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 0, exec->propertyNames().test, regExpProtoFuncTest), DontEnum);
 
54
    putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 0, exec->propertyNames().toString, regExpProtoFuncToString), DontEnum);
54
55
}
55
56
 
56
57
// ------------------------------ Functions ---------------------------
57
58
    
58
 
JSValuePtr regExpProtoFuncTest(ExecState* exec, JSObject*, JSValuePtr thisValue, const ArgList& args)
 
59
JSValue JSC_HOST_CALL regExpProtoFuncTest(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args)
59
60
{
60
61
    if (!thisValue.isObject(&RegExpObject::info))
61
62
        return throwError(exec, TypeError);
62
63
    return asRegExpObject(thisValue)->test(exec, args);
63
64
}
64
65
 
65
 
JSValuePtr regExpProtoFuncExec(ExecState* exec, JSObject*, JSValuePtr thisValue, const ArgList& args)
 
66
JSValue JSC_HOST_CALL regExpProtoFuncExec(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args)
66
67
{
67
68
    if (!thisValue.isObject(&RegExpObject::info))
68
69
        return throwError(exec, TypeError);
69
70
    return asRegExpObject(thisValue)->exec(exec, args);
70
71
}
71
72
 
72
 
JSValuePtr regExpProtoFuncCompile(ExecState* exec, JSObject*, JSValuePtr thisValue, const ArgList& args)
 
73
JSValue JSC_HOST_CALL regExpProtoFuncCompile(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args)
73
74
{
74
75
    if (!thisValue.isObject(&RegExpObject::info))
75
76
        return throwError(exec, TypeError);
76
77
 
77
78
    RefPtr<RegExp> regExp;
78
 
    JSValuePtr arg0 = args.at(exec, 0);
79
 
    JSValuePtr arg1 = args.at(exec, 1);
 
79
    JSValue arg0 = args.at(0);
 
80
    JSValue arg1 = args.at(1);
80
81
    
81
82
    if (arg0.isObject(&RegExpObject::info)) {
82
83
        if (!arg1.isUndefined())
96
97
    return jsUndefined();
97
98
}
98
99
 
99
 
JSValuePtr regExpProtoFuncToString(ExecState* exec, JSObject*, JSValuePtr thisValue, const ArgList&)
 
100
JSValue JSC_HOST_CALL regExpProtoFuncToString(ExecState* exec, JSObject*, JSValue thisValue, const ArgList&)
100
101
{
101
102
    if (!thisValue.isObject(&RegExpObject::info)) {
102
103
        if (thisValue.isObject(&RegExpPrototype::info))