/usr/include/firefox/jsstr.h is in firefox-dev 11.0+build1-0ubuntu4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 | /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Communicator client code, released
* March 31, 1998.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef jsstr_h___
#define jsstr_h___
#include <ctype.h>
#include "jsapi.h"
#include "jsatom.h"
#include "jsprvtd.h"
#include "jslock.h"
#include "jscell.h"
#include "js/HashTable.h"
#include "vm/Unicode.h"
namespace js {
/* Implemented in jsstrinlines.h */
class StringBuffer;
/*
* When an algorithm does not need a string represented as a single linear
* array of characters, this range utility may be used to traverse the string a
* sequence of linear arrays of characters. This avoids flattening ropes.
*
* Implemented in jsstrinlines.h.
*/
class StringSegmentRange;
class MutatingRopeSegmentRange;
/*
* Utility for building a rope (lazy concatenation) of strings.
*/
class RopeBuilder;
} /* namespace js */
extern JSString * JS_FASTCALL
js_ConcatStrings(JSContext *cx, JSString *s1, JSString *s2);
extern JSString * JS_FASTCALL
js_toLowerCase(JSContext *cx, JSString *str);
extern JSString * JS_FASTCALL
js_toUpperCase(JSContext *cx, JSString *str);
struct JSSubString {
size_t length;
const jschar *chars;
};
extern jschar js_empty_ucstr[];
extern JSSubString js_EmptySubString;
/*
* Shorthands for ASCII (7-bit) decimal and hex conversion.
* Manually inline isdigit for performance; MSVC doesn't do this for us.
*/
#define JS7_ISDEC(c) ((((unsigned)(c)) - '0') <= 9)
#define JS7_UNDEC(c) ((c) - '0')
#define JS7_ISHEX(c) ((c) < 128 && isxdigit(c))
#define JS7_UNHEX(c) (uintN)(JS7_ISDEC(c) ? (c) - '0' : 10 + tolower(c) - 'a')
#define JS7_ISLET(c) ((c) < 128 && isalpha(c))
/* Initialize the String class, returning its prototype object. */
extern JSObject *
js_InitStringClass(JSContext *cx, JSObject *obj);
extern const char js_escape_str[];
extern const char js_unescape_str[];
extern const char js_uneval_str[];
extern const char js_decodeURI_str[];
extern const char js_encodeURI_str[];
extern const char js_decodeURIComponent_str[];
extern const char js_encodeURIComponent_str[];
/* GC-allocate a string descriptor for the given malloc-allocated chars. */
extern JSFixedString *
js_NewString(JSContext *cx, jschar *chars, size_t length);
extern JSLinearString *
js_NewDependentString(JSContext *cx, JSString *base, size_t start, size_t length);
/* Copy a counted string and GC-allocate a descriptor for it. */
extern JSFixedString *
js_NewStringCopyN(JSContext *cx, const jschar *s, size_t n);
extern JSFixedString *
js_NewStringCopyN(JSContext *cx, const char *s, size_t n);
/* Copy a C string and GC-allocate a descriptor for it. */
extern JSFixedString *
js_NewStringCopyZ(JSContext *cx, const jschar *s);
extern JSFixedString *
js_NewStringCopyZ(JSContext *cx, const char *s);
/*
* Convert a value to a printable C string.
*/
extern const char *
js_ValueToPrintable(JSContext *cx, const js::Value &,
JSAutoByteString *bytes, bool asSource = false);
namespace js {
/*
* Convert a non-string value to a string, returning null after reporting an
* error, otherwise returning a new string reference.
*/
extern JSString *
ToStringSlow(JSContext *cx, const Value &v);
/*
* Convert the given value to a string. This method includes an inline
* fast-path for the case where the value is already a string; if the value is
* known not to be a string, use ToStringSlow instead.
*/
static JS_ALWAYS_INLINE JSString *
ToString(JSContext *cx, const js::Value &v)
{
if (v.isString())
return v.toString();
return ToStringSlow(cx, v);
}
/*
* This function implements E-262-3 section 9.8, toString. Convert the given
* value to a string of jschars appended to the given buffer. On error, the
* passed buffer may have partial results appended.
*/
inline bool
ValueToStringBuffer(JSContext *cx, const Value &v, StringBuffer &sb);
} /* namespace js */
/*
* Convert a value to its source expression, returning null after reporting
* an error, otherwise returning a new string reference.
*/
extern JS_FRIEND_API(JSString *)
js_ValueToSource(JSContext *cx, const js::Value &v);
namespace js {
/*
* Test if strings are equal. The caller can call the function even if str1
* or str2 are not GC-allocated things.
*/
extern bool
EqualStrings(JSContext *cx, JSString *str1, JSString *str2, JSBool *result);
/* EqualStrings is infallible on linear strings. */
extern bool
EqualStrings(JSLinearString *str1, JSLinearString *str2);
/*
* Return less than, equal to, or greater than zero depending on whether
* str1 is less than, equal to, or greater than str2.
*/
extern bool
CompareStrings(JSContext *cx, JSString *str1, JSString *str2, int32_t *result);
/*
* Return true if the string matches the given sequence of ASCII bytes.
*/
extern bool
StringEqualsAscii(JSLinearString *str, const char *asciiBytes);
} /* namespace js */
extern size_t
js_strlen(const jschar *s);
extern jschar *
js_strchr(const jschar *s, jschar c);
extern jschar *
js_strchr_limit(const jschar *s, jschar c, const jschar *limit);
#define js_strncpy(t, s, n) memcpy((t), (s), (n) * sizeof(jschar))
namespace js {
/*
* Inflate bytes to jschars. Return null on error, otherwise return the jschar
* or byte vector that was malloc'ed. length is updated to the length of the
* new string (in jschars).
*/
extern jschar *
InflateString(JSContext *cx, const char *bytes, size_t *length,
FlationCoding fc = NormalEncoding);
extern char *
DeflateString(JSContext *cx, const jschar *chars, size_t length);
/*
* Inflate bytes to JS chars in an existing buffer. 'chars' must be large
* enough for 'length' jschars. The buffer is NOT null-terminated.
*
* charsLength must be be initialized with the destination buffer size and, on
* return, will contain on return the number of copied chars.
*/
extern bool
InflateStringToBuffer(JSContext *cx, const char *bytes, size_t length,
jschar *chars, size_t *charsLength);
extern bool
InflateUTF8StringToBuffer(JSContext *cx, const char *bytes, size_t length,
jschar *chars, size_t *charsLength,
FlationCoding fc = NormalEncoding);
/* Get number of bytes in the deflated sequence of characters. */
extern size_t
GetDeflatedStringLength(JSContext *cx, const jschar *chars, size_t charsLength);
/* This function will never fail (return -1) in CESU-8 mode. */
extern size_t
GetDeflatedUTF8StringLength(JSContext *cx, const jschar *chars,
size_t charsLength,
FlationCoding fc = NormalEncoding);
/*
* Deflate JS chars to bytes into a buffer. 'bytes' must be large enough for
* 'length chars. The buffer is NOT null-terminated. The destination length
* must to be initialized with the buffer size and will contain on return the
* number of copied bytes. Conversion behavior depends on js_CStringsAreUTF8.
*/
extern bool
DeflateStringToBuffer(JSContext *cx, const jschar *chars,
size_t charsLength, char *bytes, size_t *length);
/*
* Same as DeflateStringToBuffer, but treats 'bytes' as UTF-8 or CESU-8.
*/
extern bool
DeflateStringToUTF8Buffer(JSContext *cx, const jschar *chars,
size_t charsLength, char *bytes, size_t *length,
FlationCoding fc = NormalEncoding);
/*
* The String.prototype.replace fast-native entry point is exported for joined
* function optimization in js{interp,tracer}.cpp.
*/
extern JSBool
str_replace(JSContext *cx, uintN argc, js::Value *vp);
extern JSBool
str_fromCharCode(JSContext *cx, uintN argc, Value *vp);
} /* namespace js */
extern JSBool
js_str_toString(JSContext *cx, uintN argc, js::Value *vp);
extern JSBool
js_str_charAt(JSContext *cx, uintN argc, js::Value *vp);
extern JSBool
js_str_charCodeAt(JSContext *cx, uintN argc, js::Value *vp);
/*
* Convert one UCS-4 char and write it into a UTF-8 buffer, which must be at
* least 6 bytes long. Return the number of UTF-8 bytes of data written.
*/
extern int
js_OneUcs4ToUtf8Char(uint8_t *utf8Buffer, uint32_t ucs4Char);
namespace js {
extern size_t
PutEscapedStringImpl(char *buffer, size_t size, FILE *fp, JSLinearString *str, uint32_t quote);
/*
* Write str into buffer escaping any non-printable or non-ASCII character
* using \escapes for JS string literals.
* Guarantees that a NUL is at the end of the buffer unless size is 0. Returns
* the length of the written output, NOT including the NUL. Thus, a return
* value of size or more means that the output was truncated. If buffer
* is null, just returns the length of the output. If quote is not 0, it must
* be a single or double quote character that will quote the output.
*/
inline size_t
PutEscapedString(char *buffer, size_t size, JSLinearString *str, uint32_t quote)
{
size_t n = PutEscapedStringImpl(buffer, size, NULL, str, quote);
/* PutEscapedStringImpl can only fail with a file. */
JS_ASSERT(n != size_t(-1));
return n;
}
/*
* Write str into file escaping any non-printable or non-ASCII character.
* If quote is not 0, it must be a single or double quote character that
* will quote the output.
*/
inline bool
FileEscapedString(FILE *fp, JSLinearString *str, uint32_t quote)
{
return PutEscapedStringImpl(NULL, 0, fp, str, quote) != size_t(-1);
}
JSBool
str_match(JSContext *cx, uintN argc, Value *vp);
JSBool
str_search(JSContext *cx, uintN argc, Value *vp);
JSBool
str_split(JSContext *cx, uintN argc, Value *vp);
} /* namespace js */
extern JSBool
js_String(JSContext *cx, uintN argc, js::Value *vp);
#endif /* jsstr_h___ */
|