Source code

Revision control

Other Tools

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_lastIndexOf(JSContext* cx, unsigned argc, Value* vp);
43
44
extern bool str_startsWith(JSContext* cx, unsigned argc, Value* vp);
45
46
extern bool str_toLowerCase(JSContext* cx, unsigned argc, Value* vp);
47
48
extern bool str_toUpperCase(JSContext* cx, unsigned argc, Value* vp);
49
50
extern bool str_toString(JSContext* cx, unsigned argc, Value* vp);
51
52
extern bool str_charCodeAt_impl(JSContext* cx, HandleString string,
53
HandleValue index, MutableHandleValue res);
54
55
extern bool str_charCodeAt(JSContext* cx, unsigned argc, Value* vp);
56
57
extern bool str_endsWith(JSContext* cx, unsigned argc, Value* vp);
58
59
#if ENABLE_INTL_API
60
/**
61
* Returns the input string converted to lower case based on the language
62
* specific case mappings for the input locale.
63
*
64
* Usage: lowerCase = intl_toLocaleLowerCase(string, locale)
65
*/
66
extern MOZ_MUST_USE bool intl_toLocaleLowerCase(JSContext* cx, unsigned argc,
67
Value* vp);
68
69
/**
70
* Returns the input string converted to upper case based on the language
71
* specific case mappings for the input locale.
72
*
73
* Usage: upperCase = intl_toLocaleUpperCase(string, locale)
74
*/
75
extern MOZ_MUST_USE bool intl_toLocaleUpperCase(JSContext* cx, unsigned argc,
76
Value* vp);
77
#endif
78
79
ArrayObject* StringSplitString(JSContext* cx, Handle<ObjectGroup*> group,
80
HandleString str, HandleString sep,
81
uint32_t limit);
82
83
JSString* StringFlatReplaceString(JSContext* cx, HandleString string,
84
HandleString pattern,
85
HandleString replacement);
86
87
JSString* str_replace_string_raw(JSContext* cx, HandleString string,
88
HandleString pattern,
89
HandleString replacement);
90
91
JSString* str_replaceAll_string_raw(JSContext* cx, HandleString string,
92
HandleString pattern,
93
HandleString replacement);
94
95
extern JSString* StringToLowerCase(JSContext* cx, HandleString string);
96
97
extern JSString* StringToUpperCase(JSContext* cx, HandleString string);
98
99
extern bool StringConstructor(JSContext* cx, unsigned argc, Value* vp);
100
101
extern bool FlatStringMatch(JSContext* cx, unsigned argc, Value* vp);
102
103
extern bool FlatStringSearch(JSContext* cx, unsigned argc, Value* vp);
104
105
} /* namespace js */
106
107
#endif /* builtin_String_h */