michael@0: /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- michael@0: * vim: set ts=8 sts=4 et sw=4 tw=99: michael@0: * This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef builtin_RegExp_h michael@0: #define builtin_RegExp_h michael@0: michael@0: #include "vm/RegExpObject.h" michael@0: michael@0: JSObject * michael@0: js_InitRegExpClass(JSContext *cx, js::HandleObject obj); michael@0: michael@0: /* michael@0: * The following builtin natives are extern'd for pointer comparison in michael@0: * other parts of the engine. michael@0: */ michael@0: michael@0: namespace js { michael@0: michael@0: // Whether RegExp statics should be updated with the input and results of a michael@0: // regular expression execution. michael@0: enum RegExpStaticsUpdate { UpdateRegExpStatics, DontUpdateRegExpStatics }; michael@0: michael@0: RegExpRunStatus michael@0: ExecuteRegExp(JSContext *cx, HandleObject regexp, HandleString string, michael@0: MatchConduit &matches, RegExpStaticsUpdate staticsUpdate); michael@0: michael@0: /* michael@0: * Legacy behavior of ExecuteRegExp(), which is baked into the JSAPI. michael@0: * michael@0: * |res| may be nullptr if the RegExpStatics are not to be updated. michael@0: * |input| may be nullptr if there is no JSString corresponding to michael@0: * |chars| and |length|. michael@0: */ michael@0: bool michael@0: ExecuteRegExpLegacy(JSContext *cx, RegExpStatics *res, RegExpObject &reobj, michael@0: Handle input, const jschar *chars, size_t length, michael@0: size_t *lastIndex, bool test, MutableHandleValue rval); michael@0: michael@0: /* Translation from MatchPairs to a JS array in regexp_exec()'s output format. */ michael@0: bool michael@0: CreateRegExpMatchResult(JSContext *cx, HandleString input, const MatchPairs &matches, michael@0: MutableHandleValue rval); michael@0: michael@0: extern bool michael@0: regexp_exec_raw(JSContext *cx, HandleObject regexp, HandleString input, MutableHandleValue output); michael@0: michael@0: extern bool michael@0: regexp_exec(JSContext *cx, unsigned argc, Value *vp); michael@0: michael@0: bool michael@0: regexp_test_raw(JSContext *cx, HandleObject regexp, HandleString input, bool *result); michael@0: michael@0: extern bool michael@0: regexp_test(JSContext *cx, unsigned argc, Value *vp); michael@0: michael@0: /* michael@0: * The following functions are for use by self-hosted code. michael@0: */ michael@0: michael@0: /* michael@0: * Behaves like regexp.exec(string), but doesn't set RegExp statics. michael@0: * michael@0: * Usage: match = regexp_exec_no_statics(regexp, string) michael@0: */ michael@0: extern bool michael@0: regexp_exec_no_statics(JSContext *cx, unsigned argc, Value *vp); michael@0: michael@0: /* michael@0: * Behaves like regexp.test(string), but doesn't set RegExp statics. michael@0: * michael@0: * Usage: does_match = regexp_test_no_statics(regexp, string) michael@0: */ michael@0: extern bool michael@0: regexp_test_no_statics(JSContext *cx, unsigned argc, Value *vp); michael@0: michael@0: } /* namespace js */ michael@0: michael@0: #endif /* builtin_RegExp_h */