js/src/builtin/RegExp.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/builtin/RegExp.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,81 @@
     1.4 +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
     1.5 + * vim: set ts=8 sts=4 et sw=4 tw=99:
     1.6 + * This Source Code Form is subject to the terms of the Mozilla Public
     1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.9 +
    1.10 +#ifndef builtin_RegExp_h
    1.11 +#define builtin_RegExp_h
    1.12 +
    1.13 +#include "vm/RegExpObject.h"
    1.14 +
    1.15 +JSObject *
    1.16 +js_InitRegExpClass(JSContext *cx, js::HandleObject obj);
    1.17 +
    1.18 +/*
    1.19 + * The following builtin natives are extern'd for pointer comparison in
    1.20 + * other parts of the engine.
    1.21 + */
    1.22 +
    1.23 +namespace js {
    1.24 +
    1.25 +// Whether RegExp statics should be updated with the input and results of a
    1.26 +// regular expression execution.
    1.27 +enum RegExpStaticsUpdate { UpdateRegExpStatics, DontUpdateRegExpStatics };
    1.28 +
    1.29 +RegExpRunStatus
    1.30 +ExecuteRegExp(JSContext *cx, HandleObject regexp, HandleString string,
    1.31 +              MatchConduit &matches, RegExpStaticsUpdate staticsUpdate);
    1.32 +
    1.33 +/*
    1.34 + * Legacy behavior of ExecuteRegExp(), which is baked into the JSAPI.
    1.35 + *
    1.36 + * |res| may be nullptr if the RegExpStatics are not to be updated.
    1.37 + * |input| may be nullptr if there is no JSString corresponding to
    1.38 + * |chars| and |length|.
    1.39 + */
    1.40 +bool
    1.41 +ExecuteRegExpLegacy(JSContext *cx, RegExpStatics *res, RegExpObject &reobj,
    1.42 +                    Handle<JSLinearString*> input, const jschar *chars, size_t length,
    1.43 +                    size_t *lastIndex, bool test, MutableHandleValue rval);
    1.44 +
    1.45 +/* Translation from MatchPairs to a JS array in regexp_exec()'s output format. */
    1.46 +bool
    1.47 +CreateRegExpMatchResult(JSContext *cx, HandleString input, const MatchPairs &matches,
    1.48 +                        MutableHandleValue rval);
    1.49 +
    1.50 +extern bool
    1.51 +regexp_exec_raw(JSContext *cx, HandleObject regexp, HandleString input, MutableHandleValue output);
    1.52 +
    1.53 +extern bool
    1.54 +regexp_exec(JSContext *cx, unsigned argc, Value *vp);
    1.55 +
    1.56 +bool
    1.57 +regexp_test_raw(JSContext *cx, HandleObject regexp, HandleString input, bool *result);
    1.58 +
    1.59 +extern bool
    1.60 +regexp_test(JSContext *cx, unsigned argc, Value *vp);
    1.61 +
    1.62 +/*
    1.63 + * The following functions are for use by self-hosted code.
    1.64 + */
    1.65 +
    1.66 +/*
    1.67 + * Behaves like regexp.exec(string), but doesn't set RegExp statics.
    1.68 + *
    1.69 + * Usage: match = regexp_exec_no_statics(regexp, string)
    1.70 + */
    1.71 +extern bool
    1.72 +regexp_exec_no_statics(JSContext *cx, unsigned argc, Value *vp);
    1.73 +
    1.74 +/*
    1.75 + * Behaves like regexp.test(string), but doesn't set RegExp statics.
    1.76 + *
    1.77 + * Usage: does_match = regexp_test_no_statics(regexp, string)
    1.78 + */
    1.79 +extern bool
    1.80 +regexp_test_no_statics(JSContext *cx, unsigned argc, Value *vp);
    1.81 +
    1.82 +} /* namespace js */
    1.83 +
    1.84 +#endif /* builtin_RegExp_h */

mercurial