[SM91] Update to Spidermonkey 91.1.3 APIs
[0ad.git] / libraries / source / spidermonkey / include-win32-release / js / RegExp.h
blobd33c90a3347ead7f2854bf3232bcacec8188af03
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 * vim: set ts=8 sts=2 et sw=2 tw=80:
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/. */
7 /* Regular expression-related operations. */
9 #ifndef js_RegExp_h
10 #define js_RegExp_h
12 #include <stddef.h> // size_t
14 #include "jstypes.h" // JS_PUBLIC_API
16 #include "js/RegExpFlags.h" // JS::RegExpFlags
17 #include "js/TypeDecls.h"
19 struct JS_PUBLIC_API JSContext;
20 class JS_PUBLIC_API JSString;
22 namespace JS {
24 /**
25 * Create a new RegExp for the given Latin-1-encoded bytes and flags.
27 extern JS_PUBLIC_API JSObject* NewRegExpObject(JSContext* cx, const char* bytes,
28 size_t length,
29 RegExpFlags flags);
31 /**
32 * Create a new RegExp for the given source and flags.
34 extern JS_PUBLIC_API JSObject* NewUCRegExpObject(JSContext* cx,
35 const char16_t* chars,
36 size_t length,
37 RegExpFlags flags);
39 extern JS_PUBLIC_API bool SetRegExpInput(JSContext* cx, Handle<JSObject*> obj,
40 Handle<JSString*> input);
42 extern JS_PUBLIC_API bool ClearRegExpStatics(JSContext* cx,
43 Handle<JSObject*> obj);
45 extern JS_PUBLIC_API bool ExecuteRegExp(JSContext* cx, Handle<JSObject*> obj,
46 Handle<JSObject*> reobj,
47 const char16_t* chars, size_t length,
48 size_t* indexp, bool test,
49 MutableHandle<Value> rval);
51 /* RegExp interface for clients without a global object. */
53 extern JS_PUBLIC_API bool ExecuteRegExpNoStatics(
54 JSContext* cx, Handle<JSObject*> reobj, const char16_t* chars,
55 size_t length, size_t* indexp, bool test, MutableHandle<Value> rval);
57 /**
58 * On success, returns true, setting |*isRegExp| to true if |obj| is a RegExp
59 * object or a wrapper around one, or to false if not. Returns false on
60 * failure.
62 * This method returns true with |*isRegExp == false| when passed an ES6 proxy
63 * whose target is a RegExp, or when passed a revoked proxy.
65 extern JS_PUBLIC_API bool ObjectIsRegExp(JSContext* cx, Handle<JSObject*> obj,
66 bool* isRegExp);
68 /**
69 * Given a RegExp object (or a wrapper around one), return the set of all
70 * JS::RegExpFlag::* for it.
72 extern JS_PUBLIC_API RegExpFlags GetRegExpFlags(JSContext* cx,
73 Handle<JSObject*> obj);
75 /**
76 * Return the source text for a RegExp object (or a wrapper around one), or null
77 * on failure.
79 extern JS_PUBLIC_API JSString* GetRegExpSource(JSContext* cx,
80 Handle<JSObject*> obj);
81 /**
82 * Check whether the given source is a valid regexp. If the regexp parses
83 * successfully, returns true and sets |error| to undefined. If the regexp
84 * has a syntax error, returns true, sets |error| to that error object, and
85 * clears the exception. Returns false on OOM or over-recursion.
87 extern JS_PUBLIC_API bool CheckRegExpSyntax(JSContext* cx,
88 const char16_t* chars,
89 size_t length, RegExpFlags flags,
90 MutableHandle<Value> error);
92 } // namespace JS
94 #endif // js_RegExp_h