2019-03-23 02:56:08 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
* vim: set ts=8 sts=2 et sw=2 tw=80:
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
/* Regular expression-related operations. */
|
|
|
|
|
|
|
|
#ifndef js_RegExp_h
|
|
|
|
#define js_RegExp_h
|
|
|
|
|
|
|
|
#include <stddef.h> // size_t
|
|
|
|
|
|
|
|
#include "jstypes.h" // JS_PUBLIC_API
|
|
|
|
|
2019-04-02 06:16:43 +03:00
|
|
|
#include "js/RegExpFlags.h" // JS::RegExpFlags
|
2019-04-06 00:41:42 +03:00
|
|
|
#include "js/RootingAPI.h" // JS::{,Mutable}Handle
|
|
|
|
#include "js/Value.h" // JS::Value
|
2019-03-23 02:56:08 +03:00
|
|
|
|
|
|
|
struct JSContext;
|
|
|
|
class JSString;
|
|
|
|
|
|
|
|
namespace JS {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a new RegExp for the given Latin-1-encoded bytes and flags.
|
|
|
|
*/
|
|
|
|
extern JS_PUBLIC_API JSObject* NewRegExpObject(JSContext* cx, const char* bytes,
|
2019-04-02 06:16:43 +03:00
|
|
|
size_t length,
|
|
|
|
RegExpFlags flags);
|
2019-03-23 02:56:08 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a new RegExp for the given source and flags.
|
|
|
|
*/
|
|
|
|
extern JS_PUBLIC_API JSObject* NewUCRegExpObject(JSContext* cx,
|
|
|
|
const char16_t* chars,
|
2019-04-02 06:16:43 +03:00
|
|
|
size_t length,
|
|
|
|
RegExpFlags flags);
|
2019-03-23 02:56:08 +03:00
|
|
|
|
|
|
|
extern JS_PUBLIC_API bool SetRegExpInput(JSContext* cx, Handle<JSObject*> obj,
|
|
|
|
Handle<JSString*> input);
|
|
|
|
|
|
|
|
extern JS_PUBLIC_API bool ClearRegExpStatics(JSContext* cx,
|
|
|
|
Handle<JSObject*> obj);
|
|
|
|
|
|
|
|
extern JS_PUBLIC_API bool ExecuteRegExp(JSContext* cx, Handle<JSObject*> obj,
|
|
|
|
Handle<JSObject*> reobj,
|
|
|
|
char16_t* chars, size_t length,
|
|
|
|
size_t* indexp, bool test,
|
|
|
|
MutableHandle<Value> rval);
|
|
|
|
|
|
|
|
/* RegExp interface for clients without a global object. */
|
|
|
|
|
|
|
|
extern JS_PUBLIC_API bool ExecuteRegExpNoStatics(JSContext* cx,
|
|
|
|
Handle<JSObject*> reobj,
|
|
|
|
char16_t* chars, size_t length,
|
|
|
|
size_t* indexp, bool test,
|
|
|
|
MutableHandle<Value> rval);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* On success, returns true, setting |*isRegExp| to true if |obj| is a RegExp
|
|
|
|
* object or a wrapper around one, or to false if not. Returns false on
|
|
|
|
* failure.
|
|
|
|
*
|
|
|
|
* This method returns true with |*isRegExp == false| when passed an ES6 proxy
|
|
|
|
* whose target is a RegExp, or when passed a revoked proxy.
|
|
|
|
*/
|
|
|
|
extern JS_PUBLIC_API bool ObjectIsRegExp(JSContext* cx, Handle<JSObject*> obj,
|
|
|
|
bool* isRegExp);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Given a RegExp object (or a wrapper around one), return the set of all
|
2019-04-02 06:16:43 +03:00
|
|
|
* JS::RegExpFlag::* for it.
|
2019-03-23 02:56:08 +03:00
|
|
|
*/
|
2019-04-02 06:16:43 +03:00
|
|
|
extern JS_PUBLIC_API RegExpFlags GetRegExpFlags(JSContext* cx,
|
|
|
|
Handle<JSObject*> obj);
|
2019-03-23 02:56:08 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the source text for a RegExp object (or a wrapper around one), or null
|
|
|
|
* on failure.
|
|
|
|
*/
|
|
|
|
extern JS_PUBLIC_API JSString* GetRegExpSource(JSContext* cx,
|
|
|
|
Handle<JSObject*> obj);
|
|
|
|
|
|
|
|
} // namespace JS
|
|
|
|
|
|
|
|
#endif // js_RegExp_h
|