js/src/builtin/RegExp.h

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:d620af2b8752
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 * vim: set ts=8 sts=4 et sw=4 tw=99:
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6
7 #ifndef builtin_RegExp_h
8 #define builtin_RegExp_h
9
10 #include "vm/RegExpObject.h"
11
12 JSObject *
13 js_InitRegExpClass(JSContext *cx, js::HandleObject obj);
14
15 /*
16 * The following builtin natives are extern'd for pointer comparison in
17 * other parts of the engine.
18 */
19
20 namespace js {
21
22 // Whether RegExp statics should be updated with the input and results of a
23 // regular expression execution.
24 enum RegExpStaticsUpdate { UpdateRegExpStatics, DontUpdateRegExpStatics };
25
26 RegExpRunStatus
27 ExecuteRegExp(JSContext *cx, HandleObject regexp, HandleString string,
28 MatchConduit &matches, RegExpStaticsUpdate staticsUpdate);
29
30 /*
31 * Legacy behavior of ExecuteRegExp(), which is baked into the JSAPI.
32 *
33 * |res| may be nullptr if the RegExpStatics are not to be updated.
34 * |input| may be nullptr if there is no JSString corresponding to
35 * |chars| and |length|.
36 */
37 bool
38 ExecuteRegExpLegacy(JSContext *cx, RegExpStatics *res, RegExpObject &reobj,
39 Handle<JSLinearString*> input, const jschar *chars, size_t length,
40 size_t *lastIndex, bool test, MutableHandleValue rval);
41
42 /* Translation from MatchPairs to a JS array in regexp_exec()'s output format. */
43 bool
44 CreateRegExpMatchResult(JSContext *cx, HandleString input, const MatchPairs &matches,
45 MutableHandleValue rval);
46
47 extern bool
48 regexp_exec_raw(JSContext *cx, HandleObject regexp, HandleString input, MutableHandleValue output);
49
50 extern bool
51 regexp_exec(JSContext *cx, unsigned argc, Value *vp);
52
53 bool
54 regexp_test_raw(JSContext *cx, HandleObject regexp, HandleString input, bool *result);
55
56 extern bool
57 regexp_test(JSContext *cx, unsigned argc, Value *vp);
58
59 /*
60 * The following functions are for use by self-hosted code.
61 */
62
63 /*
64 * Behaves like regexp.exec(string), but doesn't set RegExp statics.
65 *
66 * Usage: match = regexp_exec_no_statics(regexp, string)
67 */
68 extern bool
69 regexp_exec_no_statics(JSContext *cx, unsigned argc, Value *vp);
70
71 /*
72 * Behaves like regexp.test(string), but doesn't set RegExp statics.
73 *
74 * Usage: does_match = regexp_test_no_statics(regexp, string)
75 */
76 extern bool
77 regexp_test_no_statics(JSContext *cx, unsigned argc, Value *vp);
78
79 } /* namespace js */
80
81 #endif /* builtin_RegExp_h */

mercurial