⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jsstr.h

📁 java script test programing source code
💻 H
📖 第 1 页 / 共 2 页
字号:
/* Unicode control-format characters, ignored in input */#define JS_ISFORMAT(c) (((1 << JSCT_FORMAT) >> JS_CTYPE(c)) & 1)/* * Per ECMA-262 15.10.2.6, these characters are the only ones that make up a * "word", as far as a RegExp is concerned.  If we want a Unicode-friendlier * definition of "word", we should rename this macro to something regexp-y. */#define JS_ISWORD(c)    ((c) < 128 && (isalnum(c) || (c) == '_'))#define JS_ISIDSTART(c) (JS_ISLETTER(c) || (c) == '_' || (c) == '$')#define JS_ISIDENT(c)   (JS_ISIDPART(c) || (c) == '_' || (c) == '$')#define JS_ISXMLSPACE(c)        ((c) == ' ' || (c) == '\t' || (c) == '\r' ||  \                                 (c) == '\n')#define JS_ISXMLNSSTART(c)      ((JS_CCODE(c) & 0x00000100) || (c) == '_')#define JS_ISXMLNS(c)           ((JS_CCODE(c) & 0x00000080) || (c) == '.' ||  \                                 (c) == '-' || (c) == '_')#define JS_ISXMLNAMESTART(c)    (JS_ISXMLNSSTART(c) || (c) == ':')#define JS_ISXMLNAME(c)         (JS_ISXMLNS(c) || (c) == ':')#define JS_ISDIGIT(c)   (JS_CTYPE(c) == JSCT_DECIMAL_DIGIT_NUMBER)/* XXXbe unify on A/X/Y tbls, avoid ctype.h? *//* XXXbe fs, etc. ? */#define JS_ISSPACE(c)   ((JS_CCODE(c) & 0x00070000) == 0x00040000)#define JS_ISPRINT(c)   ((c) < 128 && isprint(c))#define JS_ISUPPER(c)   (JS_CTYPE(c) == JSCT_UPPERCASE_LETTER)#define JS_ISLOWER(c)   (JS_CTYPE(c) == JSCT_LOWERCASE_LETTER)#define JS_TOUPPER(c)   ((jschar) ((JS_CCODE(c) & 0x00100000)                 \                                   ? (c) - ((int32)JS_CCODE(c) >> 22)         \                                   : (c)))#define JS_TOLOWER(c)   ((jschar) ((JS_CCODE(c) & 0x00200000)                 \                                   ? (c) + ((int32)JS_CCODE(c) >> 22)         \                                   : (c)))/* * 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 per-runtime string state for the first context in the runtime. */extern JSBooljs_InitRuntimeStringState(JSContext *cx);extern voidjs_FinishRuntimeStringState(JSContext *cx);extern voidjs_FinishDeflatedStringCache(JSRuntime *rt);/* Initialize the String class, returning its prototype object. */extern JSClass js_StringClass;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 JSString *js_NewString(JSContext *cx, jschar *chars, size_t length, uintN gcflag);extern JSString *js_NewDependentString(JSContext *cx, JSString *base, size_t start,                      size_t length, uintN gcflag);/* Copy a counted string and GC-allocate a descriptor for it. */extern JSString *js_NewStringCopyN(JSContext *cx, const jschar *s, size_t n, uintN gcflag);/* Copy a C string and GC-allocate a descriptor for it. */extern JSString *js_NewStringCopyZ(JSContext *cx, const jschar *s, uintN gcflag);/* Free the chars held by str when it is finalized by the GC. */extern voidjs_FinalizeString(JSContext *cx, JSString *str);extern voidjs_FinalizeStringRT(JSRuntime *rt, JSString *str);/* Wrap a string value in a String object. */extern JSObject *js_StringToObject(JSContext *cx, JSString *str);/* * Convert a value to a printable C string. */typedef JSString *(*JSValueToStringFun)(JSContext *cx, jsval v);extern JS_FRIEND_API(const char *)js_ValueToPrintable(JSContext *cx, jsval v, JSValueToStringFun v2sfun);#define js_ValueToPrintableString(cx,v) \    js_ValueToPrintable(cx, v, js_ValueToString)#define js_ValueToPrintableSource(cx,v) \    js_ValueToPrintable(cx, v, js_ValueToSource)/* * Convert a value to a string, returning null after reporting an error, * otherwise returning a new string reference. */extern JS_FRIEND_API(JSString *)js_ValueToString(JSContext *cx, jsval v);/* * 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, jsval v);#ifdef HT_ENUMERATE_NEXT        /* XXX don't require jshash.h *//* * Compute a hash function from str. */extern JSHashNumberjs_HashString(JSString *str);#endif/* * Return less than, equal to, or greater than zero depending on whether * str1 is less than, equal to, or greater than str2. */extern intNjs_CompareStrings(JSString *str1, JSString *str2);/* * Test if strings are equal. */extern JSBooljs_EqualStrings(JSString *str1, JSString *str2);/* * Boyer-Moore-Horspool superlinear search for pat:patlen in text:textlen. * The patlen argument must be positive and no greater than BMH_PATLEN_MAX. * The start argument tells where in text to begin the search. * * Return the index of pat in text, or -1 if not found. */#define BMH_CHARSET_SIZE 256    /* ISO-Latin-1 */#define BMH_PATLEN_MAX   255    /* skip table element is uint8 */#define BMH_BAD_PATTERN  (-2)   /* return value if pat is not ISO-Latin-1 */extern jsintjs_BoyerMooreHorspool(const jschar *text, jsint textlen,                      const jschar *pat, jsint patlen,                      jsint start);extern size_tjs_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))/* * Return s advanced past any Unicode white space characters. */extern const jschar *js_SkipWhiteSpace(const jschar *s);/* * Inflate bytes to JS chars and vice versa.  Report out of memory via cx * and return null on error, otherwise return the jschar or byte vector that * was JS_malloc'ed. length is updated with the length of the new string in jschars. */extern jschar *js_InflateString(JSContext *cx, const char *bytes, size_t *length);extern char *js_DeflateString(JSContext *cx, const jschar *chars, size_t length);/* * Inflate bytes to JS chars into a buffer. * 'chars' must be large enough for 'length' jschars. * The buffer is NOT null-terminated. * cx may be NULL, which means no errors are thrown. * The destination length needs to be initialized with the buffer size, takes * the number of chars moved. */extern JSBooljs_InflateStringToBuffer(JSContext* cx, const char *bytes, size_t length,                         jschar *chars, size_t* charsLength);/* * Deflate JS chars to bytes into a buffer. * 'bytes' must be large enough for 'length chars. * The buffer is NOT null-terminated. * cx may be NULL, which means no errors are thrown. * The destination length needs to be initialized with the buffer size, takes * the number of bytes moved. */extern JSBooljs_DeflateStringToBuffer(JSContext* cx, const jschar *chars,                         size_t charsLength, char *bytes, size_t* length);/* * Associate bytes with str in the deflated string cache, returning true on * successful association, false on out of memory. */extern JSBooljs_SetStringBytes(JSRuntime *rt, JSString *str, char *bytes, size_t length);/* * Find or create a deflated string cache entry for str that contains its * characters chopped from Unicode code points into bytes. */extern char *js_GetStringBytes(JSRuntime *rt, JSString *str);/* Remove a deflated string cache entry associated with str if any. */extern voidjs_PurgeDeflatedStringCache(JSRuntime *rt, JSString *str);JSBooljs_str_escape(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,              jsval *rval);/* * 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 intjs_OneUcs4ToUtf8Char(uint8 *utf8Buffer, uint32 ucs4Char);JS_END_EXTERN_C#endif /* jsstr_h___ */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -