Back to index

lightning-sunbird  0.9+nobinonly
jsstr.h
Go to the documentation of this file.
00001 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
00002  *
00003  * ***** BEGIN LICENSE BLOCK *****
00004  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00005  *
00006  * The contents of this file are subject to the Mozilla Public License Version
00007  * 1.1 (the "License"); you may not use this file except in compliance with
00008  * the License. You may obtain a copy of the License at
00009  * http://www.mozilla.org/MPL/
00010  *
00011  * Software distributed under the License is distributed on an "AS IS" basis,
00012  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00013  * for the specific language governing rights and limitations under the
00014  * License.
00015  *
00016  * The Original Code is Mozilla Communicator client code, released
00017  * March 31, 1998.
00018  *
00019  * The Initial Developer of the Original Code is
00020  * Netscape Communications Corporation.
00021  * Portions created by the Initial Developer are Copyright (C) 1998
00022  * the Initial Developer. All Rights Reserved.
00023  *
00024  * Contributor(s):
00025  *
00026  * Alternatively, the contents of this file may be used under the terms of
00027  * either of the GNU General Public License Version 2 or later (the "GPL"),
00028  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00029  * in which case the provisions of the GPL or the LGPL are applicable instead
00030  * of those above. If you wish to allow use of your version of this file only
00031  * under the terms of either the GPL or the LGPL, and not to allow others to
00032  * use your version of this file under the terms of the MPL, indicate your
00033  * decision by deleting the provisions above and replace them with the notice
00034  * and other provisions required by the GPL or the LGPL. If you do not delete
00035  * the provisions above, a recipient may use your version of this file under
00036  * the terms of any one of the MPL, the GPL or the LGPL.
00037  *
00038  * ***** END LICENSE BLOCK ***** */
00039 
00040 #ifndef jsstr_h___
00041 #define jsstr_h___
00042 /*
00043  * JS string type implementation.
00044  *
00045  * A JS string is a counted array of unicode characters.  To support handoff
00046  * of API client memory, the chars are allocated separately from the length,
00047  * necessitating a pointer after the count, to form a separately allocated
00048  * string descriptor.  String descriptors are GC'ed, while their chars are
00049  * allocated from the malloc heap.
00050  *
00051  * When a string is treated as an object (by following it with . or []), the
00052  * runtime wraps it with a JSObject whose valueOf method returns the unwrapped
00053  * string descriptor.
00054  */
00055 #include <ctype.h>
00056 #include "jspubtd.h"
00057 #include "jsprvtd.h"
00058 #include "jshash.h"
00059 
00060 JS_BEGIN_EXTERN_C
00061 
00062 /*
00063  * The original GC-thing "string" type, a flat character string owned by its
00064  * GC-thing descriptor.  The chars member points to a vector having byte size
00065  * (length + 1) * sizeof(jschar), terminated at index length by a zero jschar.
00066  * The terminator is purely a backstop, in case the chars pointer flows out to
00067  * native code that requires \u0000 termination.
00068  *
00069  * NB: Always use the JSSTRING_LENGTH and JSSTRING_CHARS accessor macros,
00070  * unless you guard str->member uses with !JSSTRING_IS_DEPENDENT(str).
00071  */
00072 struct JSString {
00073     size_t          length;
00074     jschar          *chars;
00075 };
00076 
00077 /*
00078  * Overlay structure for a string that depends on another string's characters.
00079  * Distinguished by the JSSTRFLAG_DEPENDENT bit being set in length.  The base
00080  * member may point to another dependent string if JSSTRING_CHARS has not been
00081  * called yet.  The length chars in a dependent string are stored starting at
00082  * base->chars + start, and are not necessarily zero-terminated.  If start is
00083  * 0, it is not stored, length is a full size_t (minus the JSSTRFLAG_* bits in
00084  * the high two positions), and the JSSTRFLAG_PREFIX flag is set.
00085  */
00086 struct JSDependentString {
00087     size_t          length;
00088     JSString        *base;
00089 };
00090 
00091 /* Definitions for flags stored in the high order bits of JSString.length. */
00092 #define JSSTRFLAG_BITS              2
00093 #define JSSTRFLAG_SHIFT(flg)        ((size_t)(flg) << JSSTRING_LENGTH_BITS)
00094 #define JSSTRFLAG_MASK              JSSTRFLAG_SHIFT(JS_BITMASK(JSSTRFLAG_BITS))
00095 #define JSSTRFLAG_DEPENDENT         JSSTRFLAG_SHIFT(1)
00096 #define JSSTRFLAG_PREFIX            JSSTRFLAG_SHIFT(2)
00097 
00098 /* Universal JSString type inquiry and accessor macros. */
00099 #define JSSTRING_BIT(n)             ((size_t)1 << (n))
00100 #define JSSTRING_BITMASK(n)         (JSSTRING_BIT(n) - 1)
00101 #define JSSTRING_HAS_FLAG(str,flg)  ((str)->length & (flg))
00102 #define JSSTRING_IS_DEPENDENT(str)  JSSTRING_HAS_FLAG(str, JSSTRFLAG_DEPENDENT)
00103 #define JSSTRING_IS_PREFIX(str)     JSSTRING_HAS_FLAG(str, JSSTRFLAG_PREFIX)
00104 #define JSSTRING_CHARS(str)         (JSSTRING_IS_DEPENDENT(str)               \
00105                                      ? JSSTRDEP_CHARS(str)                    \
00106                                      : (str)->chars)
00107 #define JSSTRING_LENGTH(str)        (JSSTRING_IS_DEPENDENT(str)               \
00108                                      ? JSSTRDEP_LENGTH(str)                   \
00109                                      : (str)->length)
00110 #define JSSTRING_LENGTH_BITS        (sizeof(size_t) * JS_BITS_PER_BYTE        \
00111                                      - JSSTRFLAG_BITS)
00112 #define JSSTRING_LENGTH_MASK        JSSTRING_BITMASK(JSSTRING_LENGTH_BITS)
00113 
00114 /* Specific JSDependentString shift/mask accessor and mutator macros. */
00115 #define JSSTRDEP_START_BITS         (JSSTRING_LENGTH_BITS-JSSTRDEP_LENGTH_BITS)
00116 #define JSSTRDEP_START_SHIFT        JSSTRDEP_LENGTH_BITS
00117 #define JSSTRDEP_START_MASK         JSSTRING_BITMASK(JSSTRDEP_START_BITS)
00118 #define JSSTRDEP_LENGTH_BITS        (JSSTRING_LENGTH_BITS / 2)
00119 #define JSSTRDEP_LENGTH_MASK        JSSTRING_BITMASK(JSSTRDEP_LENGTH_BITS)
00120 
00121 #define JSSTRDEP(str)               ((JSDependentString *)(str))
00122 #define JSSTRDEP_START(str)         (JSSTRING_IS_PREFIX(str) ? 0              \
00123                                      : ((JSSTRDEP(str)->length                \
00124                                          >> JSSTRDEP_START_SHIFT)             \
00125                                         & JSSTRDEP_START_MASK))
00126 #define JSSTRDEP_LENGTH(str)        (JSSTRDEP(str)->length                    \
00127                                      & (JSSTRING_IS_PREFIX(str)               \
00128                                         ? JSSTRING_LENGTH_MASK                \
00129                                         : JSSTRDEP_LENGTH_MASK))
00130 
00131 #define JSSTRDEP_SET_START_AND_LENGTH(str,off,len)                            \
00132     (JSSTRDEP(str)->length = JSSTRFLAG_DEPENDENT                              \
00133                            | ((off) << JSSTRDEP_START_SHIFT)                  \
00134                            | (len))
00135 #define JSPREFIX_SET_LENGTH(str,len)                                          \
00136     (JSSTRDEP(str)->length = JSSTRFLAG_DEPENDENT | JSSTRFLAG_PREFIX | (len))
00137 
00138 #define JSSTRDEP_BASE(str)          (JSSTRDEP(str)->base)
00139 #define JSSTRDEP_SET_BASE(str,bstr) (JSSTRDEP(str)->base = (bstr))
00140 #define JSPREFIX_BASE(str)          JSSTRDEP_BASE(str)
00141 #define JSPREFIX_SET_BASE(str,bstr) JSSTRDEP_SET_BASE(str,bstr)
00142 
00143 #define JSSTRDEP_CHARS(str)                                                   \
00144     (JSSTRING_IS_DEPENDENT(JSSTRDEP_BASE(str))                                \
00145      ? js_GetDependentStringChars(str)                                        \
00146      : JSSTRDEP_BASE(str)->chars + JSSTRDEP_START(str))
00147 
00148 extern size_t
00149 js_MinimizeDependentStrings(JSString *str, int level, JSString **basep);
00150 
00151 extern jschar *
00152 js_GetDependentStringChars(JSString *str);
00153 
00154 extern jschar *
00155 js_GetStringChars(JSString *str);
00156 
00157 extern JSString *
00158 js_ConcatStrings(JSContext *cx, JSString *left, JSString *right);
00159 
00160 extern const jschar *
00161 js_UndependString(JSContext *cx, JSString *str);
00162 
00163 struct JSSubString {
00164     size_t          length;
00165     const jschar    *chars;
00166 };
00167 
00168 extern jschar      js_empty_ucstr[];
00169 extern JSSubString js_EmptySubString;
00170 
00171 /* Unicode character attribute lookup tables. */
00172 extern const uint8 js_X[];
00173 extern const uint8 js_Y[];
00174 extern const uint32 js_A[];
00175 
00176 /* Enumerated Unicode general category types. */
00177 typedef enum JSCharType {
00178     JSCT_UNASSIGNED             = 0,
00179     JSCT_UPPERCASE_LETTER       = 1,
00180     JSCT_LOWERCASE_LETTER       = 2,
00181     JSCT_TITLECASE_LETTER       = 3,
00182     JSCT_MODIFIER_LETTER        = 4,
00183     JSCT_OTHER_LETTER           = 5,
00184     JSCT_NON_SPACING_MARK       = 6,
00185     JSCT_ENCLOSING_MARK         = 7,
00186     JSCT_COMBINING_SPACING_MARK = 8,
00187     JSCT_DECIMAL_DIGIT_NUMBER   = 9,
00188     JSCT_LETTER_NUMBER          = 10,
00189     JSCT_OTHER_NUMBER           = 11,
00190     JSCT_SPACE_SEPARATOR        = 12,
00191     JSCT_LINE_SEPARATOR         = 13,
00192     JSCT_PARAGRAPH_SEPARATOR    = 14,
00193     JSCT_CONTROL                = 15,
00194     JSCT_FORMAT                 = 16,
00195     JSCT_PRIVATE_USE            = 18,
00196     JSCT_SURROGATE              = 19,
00197     JSCT_DASH_PUNCTUATION       = 20,
00198     JSCT_START_PUNCTUATION      = 21,
00199     JSCT_END_PUNCTUATION        = 22,
00200     JSCT_CONNECTOR_PUNCTUATION  = 23,
00201     JSCT_OTHER_PUNCTUATION      = 24,
00202     JSCT_MATH_SYMBOL            = 25,
00203     JSCT_CURRENCY_SYMBOL        = 26,
00204     JSCT_MODIFIER_SYMBOL        = 27,
00205     JSCT_OTHER_SYMBOL           = 28
00206 } JSCharType;
00207 
00208 /* Character classifying and mapping macros, based on java.lang.Character. */
00209 #define JS_CCODE(c)     (js_A[js_Y[(js_X[(uint16)(c)>>6]<<6)|((c)&0x3F)]])
00210 #define JS_CTYPE(c)     (JS_CCODE(c) & 0x1F)
00211 
00212 #define JS_ISALPHA(c)   ((((1 << JSCT_UPPERCASE_LETTER) |                     \
00213                            (1 << JSCT_LOWERCASE_LETTER) |                     \
00214                            (1 << JSCT_TITLECASE_LETTER) |                     \
00215                            (1 << JSCT_MODIFIER_LETTER) |                      \
00216                            (1 << JSCT_OTHER_LETTER))                          \
00217                           >> JS_CTYPE(c)) & 1)
00218 
00219 #define JS_ISALNUM(c)   ((((1 << JSCT_UPPERCASE_LETTER) |                     \
00220                            (1 << JSCT_LOWERCASE_LETTER) |                     \
00221                            (1 << JSCT_TITLECASE_LETTER) |                     \
00222                            (1 << JSCT_MODIFIER_LETTER) |                      \
00223                            (1 << JSCT_OTHER_LETTER) |                         \
00224                            (1 << JSCT_DECIMAL_DIGIT_NUMBER))                  \
00225                           >> JS_CTYPE(c)) & 1)
00226 
00227 /* A unicode letter, suitable for use in an identifier. */
00228 #define JS_ISLETTER(c)   ((((1 << JSCT_UPPERCASE_LETTER) |                    \
00229                             (1 << JSCT_LOWERCASE_LETTER) |                    \
00230                             (1 << JSCT_TITLECASE_LETTER) |                    \
00231                             (1 << JSCT_MODIFIER_LETTER) |                     \
00232                             (1 << JSCT_OTHER_LETTER) |                        \
00233                             (1 << JSCT_LETTER_NUMBER))                        \
00234                            >> JS_CTYPE(c)) & 1)
00235 
00236 /*
00237  * 'IdentifierPart' from ECMA grammar, is Unicode letter or combining mark or
00238  * digit or connector punctuation.
00239  */
00240 #define JS_ISIDPART(c)  ((((1 << JSCT_UPPERCASE_LETTER) |                     \
00241                            (1 << JSCT_LOWERCASE_LETTER) |                     \
00242                            (1 << JSCT_TITLECASE_LETTER) |                     \
00243                            (1 << JSCT_MODIFIER_LETTER) |                      \
00244                            (1 << JSCT_OTHER_LETTER) |                         \
00245                            (1 << JSCT_LETTER_NUMBER) |                        \
00246                            (1 << JSCT_NON_SPACING_MARK) |                     \
00247                            (1 << JSCT_COMBINING_SPACING_MARK) |               \
00248                            (1 << JSCT_DECIMAL_DIGIT_NUMBER) |                 \
00249                            (1 << JSCT_CONNECTOR_PUNCTUATION))                 \
00250                           >> JS_CTYPE(c)) & 1)
00251 
00252 /* Unicode control-format characters, ignored in input */
00253 #define JS_ISFORMAT(c) (((1 << JSCT_FORMAT) >> JS_CTYPE(c)) & 1)
00254 
00255 /*
00256  * Per ECMA-262 15.10.2.6, these characters are the only ones that make up a
00257  * "word", as far as a RegExp is concerned.  If we want a Unicode-friendlier
00258  * definition of "word", we should rename this macro to something regexp-y.
00259  */
00260 #define JS_ISWORD(c)    ((c) < 128 && (isalnum(c) || (c) == '_'))
00261 
00262 #define JS_ISIDSTART(c) (JS_ISLETTER(c) || (c) == '_' || (c) == '$')
00263 #define JS_ISIDENT(c)   (JS_ISIDPART(c) || (c) == '_' || (c) == '$')
00264 
00265 #define JS_ISXMLSPACE(c)        ((c) == ' ' || (c) == '\t' || (c) == '\r' ||  \
00266                                  (c) == '\n')
00267 #define JS_ISXMLNSSTART(c)      ((JS_CCODE(c) & 0x00000100) || (c) == '_')
00268 #define JS_ISXMLNS(c)           ((JS_CCODE(c) & 0x00000080) || (c) == '.' ||  \
00269                                  (c) == '-' || (c) == '_')
00270 #define JS_ISXMLNAMESTART(c)    (JS_ISXMLNSSTART(c) || (c) == ':')
00271 #define JS_ISXMLNAME(c)         (JS_ISXMLNS(c) || (c) == ':')
00272 
00273 #define JS_ISDIGIT(c)   (JS_CTYPE(c) == JSCT_DECIMAL_DIGIT_NUMBER)
00274 
00275 /* XXXbe unify on A/X/Y tbls, avoid ctype.h? */
00276 /* XXXbe fs, etc. ? */
00277 #define JS_ISSPACE(c)   ((JS_CCODE(c) & 0x00070000) == 0x00040000)
00278 #define JS_ISPRINT(c)   ((c) < 128 && isprint(c))
00279 
00280 #define JS_ISUPPER(c)   (JS_CTYPE(c) == JSCT_UPPERCASE_LETTER)
00281 #define JS_ISLOWER(c)   (JS_CTYPE(c) == JSCT_LOWERCASE_LETTER)
00282 
00283 #define JS_TOUPPER(c)   ((jschar) ((JS_CCODE(c) & 0x00100000)                 \
00284                                    ? (c) - ((int32)JS_CCODE(c) >> 22)         \
00285                                    : (c)))
00286 #define JS_TOLOWER(c)   ((jschar) ((JS_CCODE(c) & 0x00200000)                 \
00287                                    ? (c) + ((int32)JS_CCODE(c) >> 22)         \
00288                                    : (c)))
00289 
00290 /*
00291  * Shorthands for ASCII (7-bit) decimal and hex conversion.
00292  * Manually inline isdigit for performance; MSVC doesn't do this for us.
00293  */
00294 #define JS7_ISDEC(c)    ((((unsigned)(c)) - '0') <= 9)
00295 #define JS7_UNDEC(c)    ((c) - '0')
00296 #define JS7_ISHEX(c)    ((c) < 128 && isxdigit(c))
00297 #define JS7_UNHEX(c)    (uintN)(JS7_ISDEC(c) ? (c) - '0' : 10 + tolower(c) - 'a')
00298 #define JS7_ISLET(c)    ((c) < 128 && isalpha(c))
00299 
00300 /* Initialize per-runtime string state for the first context in the runtime. */
00301 extern JSBool
00302 js_InitRuntimeStringState(JSContext *cx);
00303 
00304 extern void
00305 js_FinishRuntimeStringState(JSContext *cx);
00306 
00307 extern void
00308 js_FinishDeflatedStringCache(JSRuntime *rt);
00309 
00310 /* Initialize the String class, returning its prototype object. */
00311 extern JSClass js_StringClass;
00312 
00313 extern JSObject *
00314 js_InitStringClass(JSContext *cx, JSObject *obj);
00315 
00316 extern const char js_escape_str[];
00317 extern const char js_unescape_str[];
00318 extern const char js_uneval_str[];
00319 extern const char js_decodeURI_str[];
00320 extern const char js_encodeURI_str[];
00321 extern const char js_decodeURIComponent_str[];
00322 extern const char js_encodeURIComponent_str[];
00323 
00324 /* GC-allocate a string descriptor for the given malloc-allocated chars. */
00325 extern JSString *
00326 js_NewString(JSContext *cx, jschar *chars, size_t length, uintN gcflag);
00327 
00328 extern JSString *
00329 js_NewDependentString(JSContext *cx, JSString *base, size_t start,
00330                       size_t length, uintN gcflag);
00331 
00332 /* Copy a counted string and GC-allocate a descriptor for it. */
00333 extern JSString *
00334 js_NewStringCopyN(JSContext *cx, const jschar *s, size_t n, uintN gcflag);
00335 
00336 /* Copy a C string and GC-allocate a descriptor for it. */
00337 extern JSString *
00338 js_NewStringCopyZ(JSContext *cx, const jschar *s, uintN gcflag);
00339 
00340 /* Free the chars held by str when it is finalized by the GC. */
00341 extern void
00342 js_FinalizeString(JSContext *cx, JSString *str);
00343 
00344 extern void
00345 js_FinalizeStringRT(JSRuntime *rt, JSString *str);
00346 
00347 /* Wrap a string value in a String object. */
00348 extern JSObject *
00349 js_StringToObject(JSContext *cx, JSString *str);
00350 
00351 /*
00352  * Convert a value to a printable C string.
00353  */
00354 typedef JSString *(*JSValueToStringFun)(JSContext *cx, jsval v);
00355 
00356 extern JS_FRIEND_API(const char *)
00357 js_ValueToPrintable(JSContext *cx, jsval v, JSValueToStringFun v2sfun);
00358 
00359 #define js_ValueToPrintableString(cx,v) \
00360     js_ValueToPrintable(cx, v, js_ValueToString)
00361 
00362 #define js_ValueToPrintableSource(cx,v) \
00363     js_ValueToPrintable(cx, v, js_ValueToSource)
00364 
00365 /*
00366  * Convert a value to a string, returning null after reporting an error,
00367  * otherwise returning a new string reference.
00368  */
00369 extern JS_FRIEND_API(JSString *)
00370 js_ValueToString(JSContext *cx, jsval v);
00371 
00372 /*
00373  * Convert a value to its source expression, returning null after reporting
00374  * an error, otherwise returning a new string reference.
00375  */
00376 extern JS_FRIEND_API(JSString *)
00377 js_ValueToSource(JSContext *cx, jsval v);
00378 
00379 #ifdef HT_ENUMERATE_NEXT        /* XXX don't require jshash.h */
00380 /*
00381  * Compute a hash function from str.
00382  */
00383 extern JSHashNumber
00384 js_HashString(JSString *str);
00385 #endif
00386 
00387 /*
00388  * Return less than, equal to, or greater than zero depending on whether
00389  * str1 is less than, equal to, or greater than str2.
00390  */
00391 extern intN
00392 js_CompareStrings(JSString *str1, JSString *str2);
00393 
00394 /*
00395  * Test if strings are equal.
00396  */
00397 extern JSBool
00398 js_EqualStrings(JSString *str1, JSString *str2);
00399 
00400 /*
00401  * Boyer-Moore-Horspool superlinear search for pat:patlen in text:textlen.
00402  * The patlen argument must be positive and no greater than BMH_PATLEN_MAX.
00403  * The start argument tells where in text to begin the search.
00404  *
00405  * Return the index of pat in text, or -1 if not found.
00406  */
00407 #define BMH_CHARSET_SIZE 256    /* ISO-Latin-1 */
00408 #define BMH_PATLEN_MAX   255    /* skip table element is uint8 */
00409 
00410 #define BMH_BAD_PATTERN  (-2)   /* return value if pat is not ISO-Latin-1 */
00411 
00412 extern jsint
00413 js_BoyerMooreHorspool(const jschar *text, jsint textlen,
00414                       const jschar *pat, jsint patlen,
00415                       jsint start);
00416 
00417 extern size_t
00418 js_strlen(const jschar *s);
00419 
00420 extern jschar *
00421 js_strchr(const jschar *s, jschar c);
00422 
00423 extern jschar *
00424 js_strchr_limit(const jschar *s, jschar c, const jschar *limit);
00425 
00426 #define js_strncpy(t, s, n)     memcpy((t), (s), (n) * sizeof(jschar))
00427 
00428 /*
00429  * Return s advanced past any Unicode white space characters.
00430  */
00431 extern const jschar *
00432 js_SkipWhiteSpace(const jschar *s);
00433 
00434 /*
00435  * Inflate bytes to JS chars and vice versa.  Report out of memory via cx
00436  * and return null on error, otherwise return the jschar or byte vector that
00437  * was JS_malloc'ed. length is updated with the length of the new string in jschars.
00438  */
00439 extern jschar *
00440 js_InflateString(JSContext *cx, const char *bytes, size_t *length);
00441 
00442 extern char *
00443 js_DeflateString(JSContext *cx, const jschar *chars, size_t length);
00444 
00445 /*
00446  * Inflate bytes to JS chars into a buffer.
00447  * 'chars' must be large enough for 'length' jschars.
00448  * The buffer is NOT null-terminated.
00449  * cx may be NULL, which means no errors are thrown.
00450  * The destination length needs to be initialized with the buffer size, takes
00451  * the number of chars moved.
00452  */
00453 extern JSBool
00454 js_InflateStringToBuffer(JSContext* cx, const char *bytes, size_t length,
00455                          jschar *chars, size_t* charsLength);
00456 
00457 /*
00458  * Deflate JS chars to bytes into a buffer.
00459  * 'bytes' must be large enough for 'length chars.
00460  * The buffer is NOT null-terminated.
00461  * cx may be NULL, which means no errors are thrown.
00462  * The destination length needs to be initialized with the buffer size, takes
00463  * the number of bytes moved.
00464  */
00465 extern JSBool
00466 js_DeflateStringToBuffer(JSContext* cx, const jschar *chars,
00467                          size_t charsLength, char *bytes, size_t* length);
00468 
00469 /*
00470  * Associate bytes with str in the deflated string cache, returning true on
00471  * successful association, false on out of memory.
00472  */
00473 extern JSBool
00474 js_SetStringBytes(JSRuntime *rt, JSString *str, char *bytes, size_t length);
00475 
00476 /*
00477  * Find or create a deflated string cache entry for str that contains its
00478  * characters chopped from Unicode code points into bytes.
00479  */
00480 extern char *
00481 js_GetStringBytes(JSRuntime *rt, JSString *str);
00482 
00483 /* Remove a deflated string cache entry associated with str if any. */
00484 extern void
00485 js_PurgeDeflatedStringCache(JSRuntime *rt, JSString *str);
00486 
00487 JSBool
00488 js_str_escape(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
00489               jsval *rval);
00490 
00491 /*
00492  * Convert one UCS-4 char and write it into a UTF-8 buffer, which must be at
00493  * least 6 bytes long.  Return the number of UTF-8 bytes of data written.
00494  */
00495 extern int
00496 js_OneUcs4ToUtf8Char(uint8 *utf8Buffer, uint32 ucs4Char);
00497 
00498 JS_END_EXTERN_C
00499 
00500 #endif /* jsstr_h___ */