| 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/. */ |
| 6 |
|
| 7 |
#ifndef builtin_String_h |
| 8 |
#define builtin_String_h |
| 9 |
|
| 10 |
#include "NamespaceImports.h" |
| 11 |
|
| 12 |
#include "js/RootingAPI.h" |
| 13 |
#include "js/Value.h" |
| 14 |
|
| 15 |
namespace js { |
| 16 |
|
| 17 |
class ArrayObject; |
| 18 |
class GlobalObject; |
| 19 |
|
| 20 |
/* Initialize the String class, returning its prototype object. */ |
| 21 |
extern JSObject* InitStringClass(JSContext* cx, Handle<GlobalObject*> global); |
| 22 |
|
| 23 |
// String methods exposed so they can be installed in the self-hosting global. |
| 24 |
|
| 25 |
extern bool str_fromCharCode(JSContext* cx, unsigned argc, Value* vp); |
| 26 |
|
| 27 |
extern bool str_fromCodePoint(JSContext* cx, unsigned argc, Value* vp); |
| 28 |
|
| 29 |
extern bool str_includes(JSContext* cx, unsigned argc, Value* vp); |
| 30 |
|
| 31 |
extern bool str_indexOf(JSContext* cx, unsigned argc, Value* vp); |
| 32 |
|
| 33 |
extern bool str_startsWith(JSContext* cx, unsigned argc, Value* vp); |
| 34 |
|
| 35 |
extern bool str_toString(JSContext* cx, unsigned argc, Value* vp); |
| 36 |
|
| 37 |
extern bool str_charCodeAt(JSContext* cx, unsigned argc, Value* vp); |
| 38 |
|
| 39 |
extern bool str_codePointAt(JSContext* cx, unsigned argc, Value* vp); |
| 40 |
|
| 41 |
extern bool str_endsWith(JSContext* cx, unsigned argc, Value* vp); |
| 42 |
|
| 43 |
#if JS_HAS_INTL_API |
| 44 |
/** |
| 45 |
* Returns the input string converted to lower case based on the language |
| 46 |
* specific case mappings for the input locale. |
| 47 |
* |
| 48 |
* Usage: lowerCase = intl_toLocaleLowerCase(string, locale) |
| 49 |
*/ |
| 50 |
[[nodiscard]] extern bool intl_toLocaleLowerCase(JSContext* cx, unsigned argc, |
| 51 |
Value* vp); |
| 52 |
|
| 53 |
/** |
| 54 |
* Returns the input string converted to upper case based on the language |
| 55 |
* specific case mappings for the input locale. |
| 56 |
* |
| 57 |
* Usage: upperCase = intl_toLocaleUpperCase(string, locale) |
| 58 |
*/ |
| 59 |
[[nodiscard]] extern bool intl_toLocaleUpperCase(JSContext* cx, unsigned argc, |
| 60 |
Value* vp); |
| 61 |
#endif |
| 62 |
|
| 63 |
ArrayObject* StringSplitString(JSContext* cx, HandleString str, |
| 64 |
HandleString sep, uint32_t limit); |
| 65 |
|
| 66 |
JSString* StringFlatReplaceString(JSContext* cx, HandleString string, |
| 67 |
HandleString pattern, |
| 68 |
HandleString replacement); |
| 69 |
|
| 70 |
JSString* str_replace_string_raw(JSContext* cx, HandleString string, |
| 71 |
HandleString pattern, |
| 72 |
HandleString replacement); |
| 73 |
|
| 74 |
JSString* str_replaceAll_string_raw(JSContext* cx, HandleString string, |
| 75 |
HandleString pattern, |
| 76 |
HandleString replacement); |
| 77 |
|
| 78 |
extern bool StringIncludes(JSContext* cx, HandleString string, |
| 79 |
HandleString searchString, bool* result); |
| 80 |
|
| 81 |
extern bool StringIndexOf(JSContext* cx, HandleString string, |
| 82 |
HandleString searchString, int32_t* result); |
| 83 |
|
| 84 |
extern bool StringLastIndexOf(JSContext* cx, HandleString string, |
| 85 |
HandleString searchString, int32_t* result); |
| 86 |
|
| 87 |
extern bool StringStartsWith(JSContext* cx, HandleString string, |
| 88 |
HandleString searchString, bool* result); |
| 89 |
|
| 90 |
extern bool StringEndsWith(JSContext* cx, HandleString string, |
| 91 |
HandleString searchString, bool* result); |
| 92 |
|
| 93 |
extern JSLinearString* StringToLowerCase(JSContext* cx, JSString* string); |
| 94 |
|
| 95 |
extern JSLinearString* StringToUpperCase(JSContext* cx, JSString* string); |
| 96 |
|
| 97 |
extern JSString* StringTrim(JSContext* cx, HandleString string); |
| 98 |
|
| 99 |
extern JSString* StringTrimStart(JSContext* cx, HandleString string); |
| 100 |
|
| 101 |
extern JSString* StringTrimEnd(JSContext* cx, HandleString string); |
| 102 |
|
| 103 |
extern bool StringConstructor(JSContext* cx, unsigned argc, Value* vp); |
| 104 |
|
| 105 |
extern bool FlatStringMatch(JSContext* cx, unsigned argc, Value* vp); |
| 106 |
|
| 107 |
extern bool FlatStringSearch(JSContext* cx, unsigned argc, Value* vp); |
| 108 |
|
| 109 |
extern JSLinearString* StringFromCharCode(JSContext* cx, int32_t charCode); |
| 110 |
|
| 111 |
extern JSLinearString* StringFromCodePoint(JSContext* cx, char32_t codePoint); |
| 112 |
|
| 113 |
} /* namespace js */ |
| 114 |
|
| 115 |
#endif /* builtin_String_h */ |