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 "mozilla/Attributes.h" 11 12 #include "NamespaceImports.h" 13 14 #include "js/RootingAPI.h" 15 #include "js/Value.h" 16 17 namespace js { 18 19 class ArrayObject; 20 class GlobalObject; 21 class ObjectGroup; 22 23 /* Initialize the String class, returning its prototype object. */ 24 extern JSObject* InitStringClass(JSContext* cx, Handle<GlobalObject*> global); 25 26 extern bool str_fromCharCode(JSContext* cx, unsigned argc, Value* vp); 27 28 extern bool str_fromCharCode_one_arg(JSContext* cx, HandleValue code, 29 MutableHandleValue rval); 30 31 extern bool str_fromCodePoint(JSContext* cx, unsigned argc, Value* vp); 32 33 extern bool str_fromCodePoint_one_arg(JSContext* cx, HandleValue code, 34 MutableHandleValue rval); 35 36 // String methods exposed so they can be installed in the self-hosting global. 37 38 extern bool str_includes(JSContext* cx, unsigned argc, Value* vp); 39 40 extern bool str_indexOf(JSContext* cx, unsigned argc, Value* vp); 41 42 extern bool str_startsWith(JSContext* cx, unsigned argc, Value* vp); 43 44 extern bool str_toString(JSContext* cx, unsigned argc, Value* vp); 45 46 extern bool str_charCodeAt_impl(JSContext* cx, HandleString string, 47 HandleValue index, MutableHandleValue res); 48 49 extern bool str_charCodeAt(JSContext* cx, unsigned argc, Value* vp); 50 51 extern bool str_endsWith(JSContext* cx, unsigned argc, Value* vp); 52 53 #if JS_HAS_INTL_API 54 /** 55 * Returns the input string converted to lower case based on the language 56 * specific case mappings for the input locale. 57 * 58 * Usage: lowerCase = intl_toLocaleLowerCase(string, locale) 59 */ 60 extern MOZ_MUST_USE bool intl_toLocaleLowerCase(JSContext* cx, unsigned argc, 61 Value* vp); 62 63 /** 64 * Returns the input string converted to upper case based on the language 65 * specific case mappings for the input locale. 66 * 67 * Usage: upperCase = intl_toLocaleUpperCase(string, locale) 68 */ 69 extern MOZ_MUST_USE bool intl_toLocaleUpperCase(JSContext* cx, unsigned argc, 70 Value* vp); 71 #endif 72 73 ArrayObject* StringSplitString(JSContext* cx, Handle<ObjectGroup*> group, 74 HandleString str, HandleString sep, 75 uint32_t limit); 76 77 JSString* StringFlatReplaceString(JSContext* cx, HandleString string, 78 HandleString pattern, 79 HandleString replacement); 80 81 JSString* str_replace_string_raw(JSContext* cx, HandleString string, 82 HandleString pattern, 83 HandleString replacement); 84 85 JSString* str_replaceAll_string_raw(JSContext* cx, HandleString string, 86 HandleString pattern, 87 HandleString replacement); 88 89 extern JSString* StringToLowerCase(JSContext* cx, HandleString string); 90 91 extern JSString* StringToUpperCase(JSContext* cx, HandleString string); 92 93 extern bool StringConstructor(JSContext* cx, unsigned argc, Value* vp); 94 95 extern bool FlatStringMatch(JSContext* cx, unsigned argc, Value* vp); 96 97 extern bool FlatStringSearch(JSContext* cx, unsigned argc, Value* vp); 98 99 } /* namespace js */ 100 101 #endif /* builtin_String_h */ 102