mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
up to jsxml now
This commit is contained in:
parent
6d87e93eef
commit
9b7f2175aa
@ -3365,6 +3365,16 @@ class Value
|
|||||||
|
|
||||||
inline void setNumber(double d);
|
inline void setNumber(double d);
|
||||||
|
|
||||||
|
void setNumber(uint32 ui) {
|
||||||
|
if (ui > JSVAL_INT_MAX) {
|
||||||
|
mask = DoubleMask;
|
||||||
|
data.dbl = ui;
|
||||||
|
} else {
|
||||||
|
mask = Int32Mask;
|
||||||
|
data.i32 = ui;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
double &asDoubleRef() {
|
double &asDoubleRef() {
|
||||||
JS_ASSERT(size_t(&data.dbl) % sizeof(double) == 0);
|
JS_ASSERT(size_t(&data.dbl) % sizeof(double) == 0);
|
||||||
JS_ASSERT(isDouble());
|
JS_ASSERT(isDouble());
|
||||||
@ -3557,8 +3567,12 @@ class Value
|
|||||||
return mask == BooleanMask;
|
return mask == BooleanMask;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isBoolean(bool b) const {
|
bool isTrue() const {
|
||||||
return (mask == BooleanMask) & (data.boo == b);
|
return (mask == BooleanMask) & data.boo;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isFalse() const {
|
||||||
|
return (mask == BooleanMask) & !data.boo;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool asBoolean() const {
|
bool asBoolean() const {
|
||||||
|
@ -2022,7 +2022,7 @@ IteratorMore(JSContext *cx, JSObject *iterobj, bool *cond, Value *rval)
|
|||||||
} else {
|
} else {
|
||||||
if (!js_IteratorMore(cx, iterobj, rval))
|
if (!js_IteratorMore(cx, iterobj, rval))
|
||||||
return false;
|
return false;
|
||||||
*cond = rval->isBoolean(true);
|
*cond = rval->isTrue();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -5716,7 +5716,7 @@ regexp_test(JSContext *cx, uintN argc, Value *vp)
|
|||||||
if (!regexp_exec_sub(cx, ComputeThisObjectFromVp(cx, vp),
|
if (!regexp_exec_sub(cx, ComputeThisObjectFromVp(cx, vp),
|
||||||
argc, vp + 2, JS_TRUE, vp))
|
argc, vp + 2, JS_TRUE, vp))
|
||||||
return JS_FALSE;
|
return JS_FALSE;
|
||||||
if (!vp->isBoolean(true))
|
if (!vp->isTrue())
|
||||||
vp->setBoolean(false);
|
vp->setBoolean(false);
|
||||||
return JS_TRUE;
|
return JS_TRUE;
|
||||||
}
|
}
|
||||||
|
159
js/src/jsstr.cpp
159
js/src/jsstr.cpp
@ -722,6 +722,7 @@ js_str_toString(JSContext *cx, uintN argc, Value *vp)
|
|||||||
if (!js_GetPrimitiveThis(cx, vp, &js_StringClass, &primp))
|
if (!js_GetPrimitiveThis(cx, vp, &js_StringClass, &primp))
|
||||||
return false;
|
return false;
|
||||||
vp->copy(*primp);
|
vp->copy(*primp);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1499,7 +1500,7 @@ class RegExpGuard
|
|||||||
static JS_ALWAYS_INLINE bool
|
static JS_ALWAYS_INLINE bool
|
||||||
Matched(bool test, const Value &v)
|
Matched(bool test, const Value &v)
|
||||||
{
|
{
|
||||||
return test ? v.isBoolean(true) : !v.isNull();
|
return test ? v.isTrue() : !v.isNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef bool (*DoMatchCallback)(JSContext *cx, size_t count, void *data);
|
typedef bool (*DoMatchCallback)(JSContext *cx, size_t count, void *data);
|
||||||
@ -1652,7 +1653,7 @@ str_search(JSContext *cx, uintN argc, Value *vp)
|
|||||||
if (!js_ExecuteRegExp(cx, g.re(), str, &i, true, vp))
|
if (!js_ExecuteRegExp(cx, g.re(), str, &i, true, vp))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (vp->isBoolean(true))
|
if (vp->isTrue())
|
||||||
vp->setInt32(cx->regExpStatics.leftContext.length);
|
vp->setInt32(cx->regExpStatics.leftContext.length);
|
||||||
else
|
else
|
||||||
vp->setInt32(-1);
|
vp->setInt32(-1);
|
||||||
@ -1749,7 +1750,7 @@ PushRegExpSubstr(JSContext *cx, const JSSubString &sub, Value *&sp)
|
|||||||
JSString *str = js_NewDependentString(cx, whole, off, sub.length);
|
JSString *str = js_NewDependentString(cx, whole, off, sub.length);
|
||||||
if (!str)
|
if (!str)
|
||||||
return false;
|
return false;
|
||||||
*sp++ = STRING_TO_JSVAL(str);
|
sp++->setString(str);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1798,8 +1799,8 @@ FindReplaceLength(JSContext *cx, ReplaceData &rdata, size_t *sizep)
|
|||||||
|
|
||||||
/* Push lambda and its 'this' parameter. */
|
/* Push lambda and its 'this' parameter. */
|
||||||
Value *sp = rdata.args.getvp();
|
Value *sp = rdata.args.getvp();
|
||||||
*sp++ = OBJECT_TO_JSVAL(lambda);
|
sp++->setObject(*lambda);
|
||||||
*sp++ = OBJECT_TO_JSVAL(lambda->getParent());
|
sp++->setNonFunObjOrNull(lambda->getParent());
|
||||||
|
|
||||||
/* Push $&, $1, $2, ... */
|
/* Push $&, $1, $2, ... */
|
||||||
if (!PushRegExpSubstr(cx, cx->regExpStatics.lastMatch, sp))
|
if (!PushRegExpSubstr(cx, cx->regExpStatics.lastMatch, sp))
|
||||||
@ -1813,13 +1814,13 @@ FindReplaceLength(JSContext *cx, ReplaceData &rdata, size_t *sizep)
|
|||||||
|
|
||||||
/* Make sure to push undefined for any unmatched parens. */
|
/* Make sure to push undefined for any unmatched parens. */
|
||||||
for (; i < p; i++)
|
for (; i < p; i++)
|
||||||
*sp++ = JSVAL_VOID;
|
sp++->setUndefined();
|
||||||
|
|
||||||
/* Push match index and input string. */
|
/* Push match index and input string. */
|
||||||
*sp++ = INT_TO_JSVAL((jsint)cx->regExpStatics.leftContext.length);
|
sp++->setInt32(cx->regExpStatics.leftContext.length);
|
||||||
*sp++ = STRING_TO_JSVAL(rdata.str);
|
sp++->setString(rdata.str);
|
||||||
|
|
||||||
if (!js_Invoke(cx, rdata.args, 0))
|
if (!Invoke(cx, rdata.args, 0))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1917,7 +1918,7 @@ BuildFlatReplacement(JSContext *cx, JSString *textstr, JSString *repstr,
|
|||||||
const RegExpGuard &g, Value *vp)
|
const RegExpGuard &g, Value *vp)
|
||||||
{
|
{
|
||||||
if (g.match == -1) {
|
if (g.match == -1) {
|
||||||
*vp = STRING_TO_JSVAL(textstr);
|
vp->setString(textstr);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1936,7 +1937,7 @@ BuildFlatReplacement(JSContext *cx, JSString *textstr, JSString *repstr,
|
|||||||
JSString *str = js_NewStringFromCharBuffer(cx, cb);
|
JSString *str = js_NewStringFromCharBuffer(cx, cb);
|
||||||
if (!str)
|
if (!str)
|
||||||
return false;
|
return false;
|
||||||
*vp = STRING_TO_JSVAL(str);
|
vp->setString(str);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1948,7 +1949,7 @@ str_replace(JSContext *cx, uintN argc, Value *vp)
|
|||||||
|
|
||||||
/* Extract replacement string/function. */
|
/* Extract replacement string/function. */
|
||||||
if (argc >= 2 && js_IsCallable(vp[3])) {
|
if (argc >= 2 && js_IsCallable(vp[3])) {
|
||||||
rdata.lambda = JSVAL_TO_OBJECT(vp[3]);
|
rdata.lambda = &vp[3].asObject();
|
||||||
rdata.repstr = NULL;
|
rdata.repstr = NULL;
|
||||||
rdata.dollar = rdata.dollarEnd = NULL;
|
rdata.dollar = rdata.dollarEnd = NULL;
|
||||||
} else {
|
} else {
|
||||||
@ -1983,7 +1984,7 @@ str_replace(JSContext *cx, uintN argc, Value *vp)
|
|||||||
|
|
||||||
if (!rdata.calledBack) {
|
if (!rdata.calledBack) {
|
||||||
/* Didn't match, so the string is unmodified. */
|
/* Didn't match, so the string is unmodified. */
|
||||||
*vp = STRING_TO_JSVAL(rdata.str);
|
vp->setString(rdata.str);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1995,7 +1996,7 @@ str_replace(JSContext *cx, uintN argc, Value *vp)
|
|||||||
if (!retstr)
|
if (!retstr)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
*vp = STRING_TO_JSVAL(retstr);
|
vp->setString(retstr);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2048,7 +2049,7 @@ find_split(JSContext *cx, JSString *str, JSRegExp *re, jsint *ip,
|
|||||||
index = (size_t)i;
|
index = (size_t)i;
|
||||||
if (!js_ExecuteRegExp(cx, re, str, &index, JS_TRUE, &rval))
|
if (!js_ExecuteRegExp(cx, re, str, &index, JS_TRUE, &rval))
|
||||||
return -2;
|
return -2;
|
||||||
if (rval != JSVAL_TRUE) {
|
if (!rval.isTrue()) {
|
||||||
/* Mismatch: ensure our caller advances i past end of string. */
|
/* Mismatch: ensure our caller advances i past end of string. */
|
||||||
sep->length = 1;
|
sep->length = 1;
|
||||||
return length;
|
return length;
|
||||||
@ -2109,18 +2110,18 @@ str_split(JSContext *cx, uintN argc, Value *vp)
|
|||||||
NORMALIZE_THIS(cx, vp, str);
|
NORMALIZE_THIS(cx, vp, str);
|
||||||
|
|
||||||
if (argc == 0) {
|
if (argc == 0) {
|
||||||
Value v = STRING_TO_JSVAL(str);
|
Value v(str);
|
||||||
JSObject *aobj = js_NewArrayObject(cx, 1, &v);
|
JSObject *aobj = js_NewArrayObject(cx, 1, &v);
|
||||||
if (!aobj)
|
if (!aobj)
|
||||||
return false;
|
return false;
|
||||||
*vp = OBJECT_TO_JSVAL(aobj);
|
vp->setNonFunObj(*aobj);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
JSRegExp *re;
|
JSRegExp *re;
|
||||||
JSSubString *sep, tmp;
|
JSSubString *sep, tmp;
|
||||||
if (VALUE_IS_REGEXP(cx, vp[2])) {
|
if (VALUE_IS_REGEXP(cx, vp[2])) {
|
||||||
re = (JSRegExp *) JSVAL_TO_OBJECT(vp[2])->getPrivate();
|
re = (JSRegExp *) vp[2].asObject().getPrivate();
|
||||||
sep = &tmp;
|
sep = &tmp;
|
||||||
|
|
||||||
/* Set a magic value so we can detect a successful re match. */
|
/* Set a magic value so we can detect a successful re match. */
|
||||||
@ -2130,7 +2131,7 @@ str_split(JSContext *cx, uintN argc, Value *vp)
|
|||||||
JSString *str2 = js_ValueToString(cx, vp[2]);
|
JSString *str2 = js_ValueToString(cx, vp[2]);
|
||||||
if (!str2)
|
if (!str2)
|
||||||
return false;
|
return false;
|
||||||
vp[2] = STRING_TO_JSVAL(str2);
|
vp[2].setString(str2);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Point sep at a local copy of str2's header because find_split
|
* Point sep at a local copy of str2's header because find_split
|
||||||
@ -2143,7 +2144,7 @@ str_split(JSContext *cx, uintN argc, Value *vp)
|
|||||||
|
|
||||||
/* Use the second argument as the split limit, if given. */
|
/* Use the second argument as the split limit, if given. */
|
||||||
uint32 limit = 0; /* Avoid warning. */
|
uint32 limit = 0; /* Avoid warning. */
|
||||||
bool limited = (argc > 1) && !JSVAL_IS_VOID(vp[3]);
|
bool limited = (argc > 1) && !vp[3].isUndefined();
|
||||||
if (limited) {
|
if (limited) {
|
||||||
jsdouble d;
|
jsdouble d;
|
||||||
if (!ValueToNumber(cx, vp[3], &d))
|
if (!ValueToNumber(cx, vp[3], &d))
|
||||||
@ -2195,7 +2196,7 @@ str_split(JSContext *cx, uintN argc, Value *vp)
|
|||||||
JSObject *aobj = js_NewArrayObject(cx, splits.length(), splits.begin());
|
JSObject *aobj = js_NewArrayObject(cx, splits.length(), splits.begin());
|
||||||
if (!aobj)
|
if (!aobj)
|
||||||
return false;
|
return false;
|
||||||
*vp = OBJECT_TO_JSVAL(aobj);
|
vp->setNonFunObj(*aobj);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2240,7 +2241,7 @@ str_substr(JSContext *cx, uintN argc, Value *vp)
|
|||||||
if (!str)
|
if (!str)
|
||||||
return JS_FALSE;
|
return JS_FALSE;
|
||||||
}
|
}
|
||||||
*vp = STRING_TO_JSVAL(str);
|
vp->setString(str);
|
||||||
return JS_TRUE;
|
return JS_TRUE;
|
||||||
}
|
}
|
||||||
#endif /* JS_HAS_PERL_SUBSTR */
|
#endif /* JS_HAS_PERL_SUBSTR */
|
||||||
@ -2258,18 +2259,18 @@ str_concat(JSContext *cx, uintN argc, Value *vp)
|
|||||||
NORMALIZE_THIS(cx, vp, str);
|
NORMALIZE_THIS(cx, vp, str);
|
||||||
|
|
||||||
/* Set vp (aka rval) early to handle the argc == 0 case. */
|
/* Set vp (aka rval) early to handle the argc == 0 case. */
|
||||||
*vp = STRING_TO_JSVAL(str);
|
vp->setString(str);
|
||||||
|
|
||||||
for (i = 0, argv = vp + 2; i < argc; i++) {
|
for (i = 0, argv = vp + 2; i < argc; i++) {
|
||||||
str2 = js_ValueToString(cx, argv[i]);
|
str2 = js_ValueToString(cx, argv[i]);
|
||||||
if (!str2)
|
if (!str2)
|
||||||
return JS_FALSE;
|
return JS_FALSE;
|
||||||
argv[i] = STRING_TO_JSVAL(str2);
|
argv[i].setString(str2);
|
||||||
|
|
||||||
str = js_ConcatStrings(cx, str, str2);
|
str = js_ConcatStrings(cx, str, str2);
|
||||||
if (!str)
|
if (!str)
|
||||||
return JS_FALSE;
|
return JS_FALSE;
|
||||||
*vp = STRING_TO_JSVAL(str);
|
vp->setString(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
return JS_TRUE;
|
return JS_TRUE;
|
||||||
@ -2278,16 +2279,11 @@ str_concat(JSContext *cx, uintN argc, Value *vp)
|
|||||||
static JSBool
|
static JSBool
|
||||||
str_slice(JSContext *cx, uintN argc, Value *vp)
|
str_slice(JSContext *cx, uintN argc, Value *vp)
|
||||||
{
|
{
|
||||||
Value t, v;
|
if (argc == 1 && vp[1].isString() && vp[2].isInt32()) {
|
||||||
JSString *str;
|
|
||||||
|
|
||||||
t = vp[1];
|
|
||||||
v = vp[2];
|
|
||||||
if (argc == 1 && JSVAL_IS_STRING(t) && JSVAL_IS_INT(v)) {
|
|
||||||
size_t begin, end, length;
|
size_t begin, end, length;
|
||||||
|
|
||||||
str = JSVAL_TO_STRING(t);
|
JSString *str = vp[1].asString();
|
||||||
begin = JSVAL_TO_INT(v);
|
begin = vp[2].asInt32();
|
||||||
end = str->length();
|
end = str->length();
|
||||||
if (begin <= end) {
|
if (begin <= end) {
|
||||||
length = end - begin;
|
length = end - begin;
|
||||||
@ -2300,11 +2296,12 @@ str_slice(JSContext *cx, uintN argc, Value *vp)
|
|||||||
if (!str)
|
if (!str)
|
||||||
return JS_FALSE;
|
return JS_FALSE;
|
||||||
}
|
}
|
||||||
*vp = STRING_TO_JSVAL(str);
|
vp->setString(str);
|
||||||
return JS_TRUE;
|
return JS_TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
JSString *str;
|
||||||
NORMALIZE_THIS(cx, vp, str);
|
NORMALIZE_THIS(cx, vp, str);
|
||||||
|
|
||||||
if (argc != 0) {
|
if (argc != 0) {
|
||||||
@ -2345,7 +2342,7 @@ str_slice(JSContext *cx, uintN argc, Value *vp)
|
|||||||
if (!str)
|
if (!str)
|
||||||
return JS_FALSE;
|
return JS_FALSE;
|
||||||
}
|
}
|
||||||
*vp = STRING_TO_JSVAL(str);
|
vp->setString(str);
|
||||||
return JS_TRUE;
|
return JS_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2413,7 +2410,7 @@ tagify(JSContext *cx, const char *begin, JSString *param, const char *end,
|
|||||||
js_free((char *)tagbuf);
|
js_free((char *)tagbuf);
|
||||||
return JS_FALSE;
|
return JS_FALSE;
|
||||||
}
|
}
|
||||||
*vp = STRING_TO_JSVAL(str);
|
vp->setString(str);
|
||||||
return JS_TRUE;
|
return JS_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2913,15 +2910,15 @@ js_String(JSContext *cx, JSObject *obj, uintN argc, Value *argv, Value *rval)
|
|||||||
str = js_ValueToString(cx, argv[0]);
|
str = js_ValueToString(cx, argv[0]);
|
||||||
if (!str)
|
if (!str)
|
||||||
return JS_FALSE;
|
return JS_FALSE;
|
||||||
argv[0] = STRING_TO_JSVAL(str);
|
argv[0].setString(str);
|
||||||
} else {
|
} else {
|
||||||
str = cx->runtime->emptyString;
|
str = cx->runtime->emptyString;
|
||||||
}
|
}
|
||||||
if (!JS_IsConstructing(cx)) {
|
if (!JS_IsConstructing(cx)) {
|
||||||
*rval = STRING_TO_JSVAL(str);
|
rval->setString(str);
|
||||||
return JS_TRUE;
|
return JS_TRUE;
|
||||||
}
|
}
|
||||||
obj->setPrimitiveThis(STRING_TO_JSVAL(str));
|
obj->setPrimitiveThis(str);
|
||||||
return JS_TRUE;
|
return JS_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2956,10 +2953,10 @@ str_fromCharCode(JSContext *cx, uintN argc, Value *vp)
|
|||||||
str = JSString::unitString(code);
|
str = JSString::unitString(code);
|
||||||
if (!str)
|
if (!str)
|
||||||
return JS_FALSE;
|
return JS_FALSE;
|
||||||
*vp = STRING_TO_JSVAL(str);
|
vp->setString(str);
|
||||||
return JS_TRUE;
|
return JS_TRUE;
|
||||||
}
|
}
|
||||||
argv[0] = INT_TO_JSVAL(code);
|
argv[0].setInt32(code);
|
||||||
}
|
}
|
||||||
chars = (jschar *) cx->malloc((argc + 1) * sizeof(jschar));
|
chars = (jschar *) cx->malloc((argc + 1) * sizeof(jschar));
|
||||||
if (!chars)
|
if (!chars)
|
||||||
@ -2978,7 +2975,7 @@ str_fromCharCode(JSContext *cx, uintN argc, Value *vp)
|
|||||||
cx->free(chars);
|
cx->free(chars);
|
||||||
return JS_FALSE;
|
return JS_FALSE;
|
||||||
}
|
}
|
||||||
*vp = STRING_TO_JSVAL(str);
|
vp->setString(str);
|
||||||
return JS_TRUE;
|
return JS_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3011,14 +3008,14 @@ js_InitStringClass(JSContext *cx, JSObject *obj)
|
|||||||
if (!JS_DefineFunctions(cx, obj, string_functions))
|
if (!JS_DefineFunctions(cx, obj, string_functions))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
proto = JS_InitClass(cx, obj, NULL, &js_StringClass, js_String, 1,
|
proto = js_InitClass(cx, obj, NULL, &js_StringClass, js_String, 1,
|
||||||
NULL, string_methods,
|
NULL, string_methods,
|
||||||
NULL, string_static_methods);
|
NULL, string_static_methods);
|
||||||
if (!proto)
|
if (!proto)
|
||||||
return NULL;
|
return NULL;
|
||||||
proto->setPrimitiveThis(STRING_TO_JSVAL(cx->runtime->emptyString));
|
proto->setPrimitiveThis(cx->runtime->emptyString);
|
||||||
if (!js_DefineNativeProperty(cx, proto, ATOM_TO_JSID(cx->runtime->atomState.lengthAtom),
|
if (!js_DefineNativeProperty(cx, proto, ATOM_TO_JSID(cx->runtime->atomState.lengthAtom),
|
||||||
JSVAL_VOID, NULL, NULL,
|
sUndefinedValue, NULL, NULL,
|
||||||
JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_SHARED, 0, 0,
|
JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_SHARED, 0, 0,
|
||||||
NULL)) {
|
NULL)) {
|
||||||
return JS_FALSE;
|
return JS_FALSE;
|
||||||
@ -3192,7 +3189,7 @@ js_NewStringCopyZ(JSContext *cx, const jschar *s)
|
|||||||
}
|
}
|
||||||
|
|
||||||
JS_FRIEND_API(const char *)
|
JS_FRIEND_API(const char *)
|
||||||
js_ValueToPrintable(JSContext *cx, Value v, JSValueToStringFun v2sfun)
|
js_ValueToPrintable(JSContext *cx, const Value &v, JSValueToStringFun v2sfun)
|
||||||
{
|
{
|
||||||
JSString *str;
|
JSString *str;
|
||||||
|
|
||||||
@ -3206,22 +3203,23 @@ js_ValueToPrintable(JSContext *cx, Value v, JSValueToStringFun v2sfun)
|
|||||||
}
|
}
|
||||||
|
|
||||||
JSString *
|
JSString *
|
||||||
js_ValueToString(JSContext *cx, const Value &v)
|
js_ValueToString(JSContext *cx, const Value &arg)
|
||||||
{
|
{
|
||||||
JSString *str;
|
Value v;
|
||||||
|
v.copy(arg);
|
||||||
if (!JSVAL_IS_PRIMITIVE(v) && !JSVAL_TO_OBJECT(v)->defaultValue(cx, JSTYPE_STRING, &v))
|
if (v.isObject() && !v.asObject().defaultValue(cx, JSTYPE_STRING, &v))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (JSVAL_IS_STRING(v)) {
|
JSString *str;
|
||||||
str = JSVAL_TO_STRING(v);
|
if (v.isString()) {
|
||||||
} else if (JSVAL_IS_INT(v)) {
|
str = v.asString();
|
||||||
str = js_NumberToString(cx, JSVAL_TO_INT(v));
|
} else if (v.isInt32()) {
|
||||||
} else if (JSVAL_IS_DOUBLE(v)) {
|
str = js_NumberToString(cx, v.asInt32());
|
||||||
str = js_NumberToString(cx, *JSVAL_TO_DOUBLE(v));
|
} else if (v.isDouble()) {
|
||||||
} else if (JSVAL_IS_BOOLEAN(v)) {
|
str = js_NumberToString(cx, v.asDouble());
|
||||||
str = js_BooleanToString(cx, JSVAL_TO_BOOLEAN(v));
|
} else if (v.isBoolean()) {
|
||||||
} else if (JSVAL_IS_NULL(v)) {
|
str = js_BooleanToString(cx, v.asBoolean());
|
||||||
|
} else if (v.isNull()) {
|
||||||
str = ATOM_TO_STRING(cx->runtime->atomState.nullAtom);
|
str = ATOM_TO_STRING(cx->runtime->atomState.nullAtom);
|
||||||
} else {
|
} else {
|
||||||
str = ATOM_TO_STRING(cx->runtime->atomState.typeAtoms[JSTYPE_VOID]);
|
str = ATOM_TO_STRING(cx->runtime->atomState.typeAtoms[JSTYPE_VOID]);
|
||||||
@ -3241,38 +3239,39 @@ AppendAtom(JSAtom *atom, JSCharBuffer &cb)
|
|||||||
|
|
||||||
/* This function implements E-262-3 section 9.8, toString. */
|
/* This function implements E-262-3 section 9.8, toString. */
|
||||||
JSBool
|
JSBool
|
||||||
js_ValueToCharBuffer(JSContext *cx, Value v, JSCharBuffer &cb)
|
js_ValueToCharBuffer(JSContext *cx, const Value &arg, JSCharBuffer &cb)
|
||||||
{
|
{
|
||||||
if (!JSVAL_IS_PRIMITIVE(v) && !JSVAL_TO_OBJECT(v)->defaultValue(cx, JSTYPE_STRING, &v))
|
Value v;
|
||||||
|
v.copy(arg);
|
||||||
|
if (v.isObject() && !v.asObject().defaultValue(cx, JSTYPE_STRING, &v))
|
||||||
return JS_FALSE;
|
return JS_FALSE;
|
||||||
|
|
||||||
if (JSVAL_IS_STRING(v)) {
|
if (v.isString()) {
|
||||||
JSString *str = JSVAL_TO_STRING(v);
|
|
||||||
const jschar *chars;
|
const jschar *chars;
|
||||||
size_t length;
|
size_t length;
|
||||||
str->getCharsAndLength(chars, length);
|
v.asString()->getCharsAndLength(chars, length);
|
||||||
return cb.append(chars, length);
|
return cb.append(chars, length);
|
||||||
}
|
}
|
||||||
if (JSVAL_IS_NUMBER(v))
|
if (v.isNumber())
|
||||||
return js_NumberValueToCharBuffer(cx, v, cb);
|
return js_NumberValueToCharBuffer(cx, v, cb);
|
||||||
if (JSVAL_IS_BOOLEAN(v))
|
if (v.isBoolean())
|
||||||
return js_BooleanToCharBuffer(cx, JSVAL_TO_BOOLEAN(v), cb);
|
return js_BooleanToCharBuffer(cx, v.asBoolean(), cb);
|
||||||
if (JSVAL_IS_NULL(v))
|
if (v.isNull())
|
||||||
return AppendAtom(cx->runtime->atomState.nullAtom, cb);
|
return AppendAtom(cx->runtime->atomState.nullAtom, cb);
|
||||||
JS_ASSERT(JSVAL_IS_VOID(v));
|
JS_ASSERT(v.isUndefined());
|
||||||
return AppendAtom(cx->runtime->atomState.typeAtoms[JSTYPE_VOID], cb);
|
return AppendAtom(cx->runtime->atomState.typeAtoms[JSTYPE_VOID], cb);
|
||||||
}
|
}
|
||||||
|
|
||||||
JS_FRIEND_API(JSString *)
|
JS_FRIEND_API(JSString *)
|
||||||
js_ValueToSource(JSContext *cx, Value v)
|
js_ValueToSource(JSContext *cx, const Value &v)
|
||||||
{
|
{
|
||||||
if (JSVAL_IS_VOID(v))
|
if (v.isUndefined())
|
||||||
return ATOM_TO_STRING(cx->runtime->atomState.void0Atom);
|
return ATOM_TO_STRING(cx->runtime->atomState.void0Atom);
|
||||||
if (JSVAL_IS_STRING(v))
|
if (v.isString())
|
||||||
return js_QuoteString(cx, JSVAL_TO_STRING(v), '"');
|
return js_QuoteString(cx, v.asString(), '"');
|
||||||
if (JSVAL_IS_PRIMITIVE(v)) {
|
if (v.isPrimitive()) {
|
||||||
/* Special case to preserve negative zero, _contra_ toString. */
|
/* Special case to preserve negative zero, _contra_ toString. */
|
||||||
if (JSVAL_IS_DOUBLE(v) && JSDOUBLE_IS_NEGZERO(*JSVAL_TO_DOUBLE(v))) {
|
if (v.isDouble() && JSDOUBLE_IS_NEGZERO(v.asDouble())) {
|
||||||
/* NB: _ucNstr rather than _ucstr to indicate non-terminated. */
|
/* NB: _ucNstr rather than _ucstr to indicate non-terminated. */
|
||||||
static const jschar js_negzero_ucNstr[] = {'-', '0'};
|
static const jschar js_negzero_ucNstr[] = {'-', '0'};
|
||||||
|
|
||||||
@ -3282,8 +3281,8 @@ js_ValueToSource(JSContext *cx, Value v)
|
|||||||
}
|
}
|
||||||
|
|
||||||
JSAtom *atom = cx->runtime->atomState.toSourceAtom;
|
JSAtom *atom = cx->runtime->atomState.toSourceAtom;
|
||||||
AutoValueRooter tvr(cx, JSVAL_NULL);
|
AutoValueRooter tvr(cx);
|
||||||
if (!js_TryMethod(cx, JSVAL_TO_OBJECT(v), atom, 0, NULL, tvr.addr()))
|
if (!js_TryMethod(cx, &v.asObject(), atom, 0, NULL, tvr.addr()))
|
||||||
return NULL;
|
return NULL;
|
||||||
return js_ValueToString(cx, tvr.value());
|
return js_ValueToString(cx, tvr.value());
|
||||||
}
|
}
|
||||||
@ -5240,7 +5239,7 @@ TransferBufferToString(JSContext *cx, JSCharBuffer &cb, Value *rval)
|
|||||||
JSString *str = js_NewStringFromCharBuffer(cx, cb);
|
JSString *str = js_NewStringFromCharBuffer(cx, cb);
|
||||||
if (!str)
|
if (!str)
|
||||||
return false;
|
return false;
|
||||||
*rval = STRING_TO_JSVAL(str);
|
rval->setString(str);
|
||||||
return true;;
|
return true;;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5266,7 +5265,7 @@ Encode(JSContext *cx, JSString *str, const jschar *unescapedSet,
|
|||||||
|
|
||||||
str->getCharsAndLength(chars, length);
|
str->getCharsAndLength(chars, length);
|
||||||
if (length == 0) {
|
if (length == 0) {
|
||||||
*rval = STRING_TO_JSVAL(cx->runtime->emptyString);
|
rval->setString(cx->runtime->emptyString);
|
||||||
return JS_TRUE;
|
return JS_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5329,7 +5328,7 @@ Decode(JSContext *cx, JSString *str, const jschar *reservedSet, Value *rval)
|
|||||||
|
|
||||||
str->getCharsAndLength(chars, length);
|
str->getCharsAndLength(chars, length);
|
||||||
if (length == 0) {
|
if (length == 0) {
|
||||||
*rval = STRING_TO_JSVAL(cx->runtime->emptyString);
|
rval->setString(cx->runtime->emptyString);
|
||||||
return JS_TRUE;
|
return JS_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,11 +82,11 @@ ArrayBuffer::fromJSObject(JSObject *obj)
|
|||||||
}
|
}
|
||||||
|
|
||||||
JSBool
|
JSBool
|
||||||
ArrayBuffer::prop_getByteLength(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
ArrayBuffer::prop_getByteLength(JSContext *cx, JSObject *obj, jsid id, Value *vp)
|
||||||
{
|
{
|
||||||
ArrayBuffer *abuf = ArrayBuffer::fromJSObject(obj);
|
ArrayBuffer *abuf = ArrayBuffer::fromJSObject(obj);
|
||||||
if (abuf)
|
if (abuf)
|
||||||
*vp = INT_TO_JSVAL(jsint(abuf->byteLength));
|
vp->setInt32(jsint(abuf->byteLength));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -104,13 +104,13 @@ ArrayBuffer::class_finalize(JSContext *cx, JSObject *obj)
|
|||||||
*/
|
*/
|
||||||
JSBool
|
JSBool
|
||||||
ArrayBuffer::class_constructor(JSContext *cx, JSObject *obj,
|
ArrayBuffer::class_constructor(JSContext *cx, JSObject *obj,
|
||||||
uintN argc, jsval *argv, jsval *rval)
|
uintN argc, Value *argv, Value *rval)
|
||||||
{
|
{
|
||||||
if (!JS_IsConstructing(cx)) {
|
if (!JS_IsConstructing(cx)) {
|
||||||
obj = NewObject(cx, &ArrayBuffer::jsclass, NULL, NULL);
|
obj = NewObject(cx, &ArrayBuffer::jsclass, NULL, NULL);
|
||||||
if (!obj)
|
if (!obj)
|
||||||
return false;
|
return false;
|
||||||
*rval = OBJECT_TO_JSVAL(obj);
|
rval->setNonFunObj(*obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
return create(cx, obj, argc, argv, rval);
|
return create(cx, obj, argc, argv, rval);
|
||||||
@ -118,13 +118,13 @@ ArrayBuffer::class_constructor(JSContext *cx, JSObject *obj,
|
|||||||
|
|
||||||
bool
|
bool
|
||||||
ArrayBuffer::create(JSContext *cx, JSObject *obj,
|
ArrayBuffer::create(JSContext *cx, JSObject *obj,
|
||||||
uintN argc, jsval *argv, jsval *rval)
|
uintN argc, Value *argv, Value *rval)
|
||||||
{
|
{
|
||||||
if (!obj) {
|
if (!obj) {
|
||||||
obj = NewObject(cx, &ArrayBuffer::jsclass, NULL, NULL);
|
obj = NewObject(cx, &ArrayBuffer::jsclass, NULL, NULL);
|
||||||
if (!obj)
|
if (!obj)
|
||||||
return false;
|
return false;
|
||||||
*rval = OBJECT_TO_JSVAL(obj);
|
rval->setNonFunObj(*obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (argc == 0) {
|
if (argc == 0) {
|
||||||
@ -136,10 +136,10 @@ ArrayBuffer::create(JSContext *cx, JSObject *obj,
|
|||||||
int32_t nbytes;
|
int32_t nbytes;
|
||||||
if (!ValueToECMAInt32(cx, argv[0], &nbytes))
|
if (!ValueToECMAInt32(cx, argv[0], &nbytes))
|
||||||
return false;
|
return false;
|
||||||
if (nbytes < 0 || !INT_FITS_IN_JSVAL(nbytes)) {
|
if (nbytes < 0) {
|
||||||
/*
|
/*
|
||||||
* We're just not going to support arrays that are bigger than what will fit
|
* We're just not going to support arrays that are bigger than what will fit
|
||||||
* as an integer jsval; if someone actually ever complains (validly), then we
|
* as an integer value; if someone actually ever complains (validly), then we
|
||||||
* can fix.
|
* can fix.
|
||||||
*/
|
*/
|
||||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL,
|
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL,
|
||||||
@ -224,38 +224,38 @@ TypedArray::isArrayIndex(JSContext *cx, jsid id, jsuint *ip)
|
|||||||
}
|
}
|
||||||
|
|
||||||
JSBool
|
JSBool
|
||||||
TypedArray::prop_getBuffer(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
TypedArray::prop_getBuffer(JSContext *cx, JSObject *obj, jsid id, Value *vp)
|
||||||
{
|
{
|
||||||
TypedArray *tarray = fromJSObject(obj);
|
TypedArray *tarray = fromJSObject(obj);
|
||||||
if (tarray)
|
if (tarray)
|
||||||
*vp = OBJECT_TO_JSVAL(tarray->bufferJS);
|
vp->setNonFunObj(*tarray->bufferJS);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
JSBool
|
JSBool
|
||||||
TypedArray::prop_getByteOffset(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
TypedArray::prop_getByteOffset(JSContext *cx, JSObject *obj, jsid id, Value *vp)
|
||||||
{
|
{
|
||||||
TypedArray *tarray = fromJSObject(obj);
|
TypedArray *tarray = fromJSObject(obj);
|
||||||
if (tarray)
|
if (tarray)
|
||||||
*vp = INT_TO_JSVAL(tarray->byteOffset);
|
vp->setInt32(tarray->byteOffset);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
JSBool
|
JSBool
|
||||||
TypedArray::prop_getByteLength(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
TypedArray::prop_getByteLength(JSContext *cx, JSObject *obj, jsid id, Value *vp)
|
||||||
{
|
{
|
||||||
TypedArray *tarray = fromJSObject(obj);
|
TypedArray *tarray = fromJSObject(obj);
|
||||||
if (tarray)
|
if (tarray)
|
||||||
*vp = INT_TO_JSVAL(tarray->byteLength);
|
vp->setInt32(tarray->byteLength);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
JSBool
|
JSBool
|
||||||
TypedArray::prop_getLength(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
TypedArray::prop_getLength(JSContext *cx, JSObject *obj, jsid id, Value *vp)
|
||||||
{
|
{
|
||||||
TypedArray *tarray = fromJSObject(obj);
|
TypedArray *tarray = fromJSObject(obj);
|
||||||
if (tarray)
|
if (tarray)
|
||||||
*vp = INT_TO_JSVAL(tarray->length);
|
vp->setInt32(tarray->length);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -477,29 +477,29 @@ class TypedArrayTemplate
|
|||||||
|
|
||||||
static JSFunctionSpec jsfuncs[];
|
static JSFunctionSpec jsfuncs[];
|
||||||
|
|
||||||
static inline JSClass *slowClass()
|
static inline Class *slowClass()
|
||||||
{
|
{
|
||||||
return &TypedArray::slowClasses[ArrayTypeID()];
|
return &TypedArray::slowClasses[ArrayTypeID()];
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline JSClass *fastClass()
|
static inline Class *fastClass()
|
||||||
{
|
{
|
||||||
return &TypedArray::fastClasses[ArrayTypeID()];
|
return &TypedArray::fastClasses[ArrayTypeID()];
|
||||||
}
|
}
|
||||||
|
|
||||||
static JSObjectOps *getObjectOps(JSContext *cx, JSClass *clasp)
|
static JSObjectOps *getObjectOps(JSContext *cx, Class *clasp)
|
||||||
{
|
{
|
||||||
return &fastObjectOps;
|
return &fastObjectOps;
|
||||||
}
|
}
|
||||||
|
|
||||||
static JSBool
|
static JSBool
|
||||||
obj_getProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
|
obj_getProperty(JSContext *cx, JSObject *obj, jsid id, Value *vp)
|
||||||
{
|
{
|
||||||
ThisTypeArray *tarray = ThisTypeArray::fromJSObject(obj);
|
ThisTypeArray *tarray = ThisTypeArray::fromJSObject(obj);
|
||||||
JS_ASSERT(tarray);
|
JS_ASSERT(tarray);
|
||||||
|
|
||||||
if (id == ATOM_TO_JSID(cx->runtime->atomState.lengthAtom)) {
|
if (id == ATOM_TO_JSID(cx->runtime->atomState.lengthAtom)) {
|
||||||
*vp = INT_TO_JSVAL(tarray->length);
|
vp->setNumber(tarray->length);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -514,11 +514,11 @@ class TypedArrayTemplate
|
|||||||
|
|
||||||
JSObject *proto = obj->getProto();
|
JSObject *proto = obj->getProto();
|
||||||
if (!proto) {
|
if (!proto) {
|
||||||
*vp = JSVAL_VOID;
|
vp->setUndefined();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
*vp = JSVAL_VOID;
|
vp->setUndefined();
|
||||||
if (js_LookupPropertyWithFlags(cx, proto, id, cx->resolveFlags, &obj2, &prop) < 0)
|
if (js_LookupPropertyWithFlags(cx, proto, id, cx->resolveFlags, &obj2, &prop) < 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -536,13 +536,13 @@ class TypedArrayTemplate
|
|||||||
}
|
}
|
||||||
|
|
||||||
static JSBool
|
static JSBool
|
||||||
obj_setProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
|
obj_setProperty(JSContext *cx, JSObject *obj, jsid id, Value *vp)
|
||||||
{
|
{
|
||||||
ThisTypeArray *tarray = ThisTypeArray::fromJSObject(obj);
|
ThisTypeArray *tarray = ThisTypeArray::fromJSObject(obj);
|
||||||
JS_ASSERT(tarray);
|
JS_ASSERT(tarray);
|
||||||
|
|
||||||
if (id == ATOM_TO_JSID(cx->runtime->atomState.lengthAtom)) {
|
if (id == ATOM_TO_JSID(cx->runtime->atomState.lengthAtom)) {
|
||||||
*vp = INT_TO_JSVAL(tarray->length);
|
vp->setNumber(tarray->length);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -559,30 +559,30 @@ class TypedArrayTemplate
|
|||||||
// these objects. This is especially true when these arrays
|
// these objects. This is especially true when these arrays
|
||||||
// are used to implement HTML Canvas 2D's PixelArray objects,
|
// are used to implement HTML Canvas 2D's PixelArray objects,
|
||||||
// which used to be plain old arrays.
|
// which used to be plain old arrays.
|
||||||
*vp = JSVAL_VOID;
|
vp->setUndefined();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (JSVAL_IS_INT(*vp)) {
|
if (vp->isInt32()) {
|
||||||
tarray->setIndex(index, NativeType(JSVAL_TO_INT(*vp)));
|
tarray->setIndex(index, NativeType(vp->asInt32()));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
jsdouble d;
|
jsdouble d;
|
||||||
|
|
||||||
if (JSVAL_IS_DOUBLE(*vp)) {
|
if (vp->isDouble()) {
|
||||||
d = *JSVAL_TO_DOUBLE(*vp);
|
d = vp->asDouble();
|
||||||
} else if (JSVAL_IS_NULL(*vp)) {
|
} else if (vp->isNull()) {
|
||||||
d = 0.0f;
|
d = 0.0f;
|
||||||
} else if (JSVAL_IS_PRIMITIVE(*vp)) {
|
} else if (vp->isPrimitive()) {
|
||||||
JS_ASSERT(JSVAL_IS_STRING(*vp) || JSVAL_IS_SPECIAL(*vp));
|
JS_ASSERT(vp->isString() || vp->isUndefined() || vp->isBoolean());
|
||||||
if (JSVAL_IS_STRING(*vp)) {
|
if (vp->isString()) {
|
||||||
// note that ValueToNumber will always succeed with a string arg
|
// note that ValueToNumber will always succeed with a string arg
|
||||||
ValueToNumber(cx, *vp, &d);
|
ValueToNumber(cx, *vp, &d);
|
||||||
} else if (*vp == JSVAL_VOID) {
|
} else if (vp->isUndefined()) {
|
||||||
d = js_NaN;
|
d = js_NaN;
|
||||||
} else {
|
} else {
|
||||||
d = (double) JSVAL_TO_BOOLEAN(*vp);
|
d = (double) vp->asBoolean();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// non-primitive assignments become NaN or 0 (for float/int arrays)
|
// non-primitive assignments become NaN or 0 (for float/int arrays)
|
||||||
@ -614,20 +614,22 @@ class TypedArrayTemplate
|
|||||||
}
|
}
|
||||||
|
|
||||||
static JSBool
|
static JSBool
|
||||||
obj_defineProperty(JSContext *cx, JSObject *obj, jsid id, jsval value,
|
obj_defineProperty(JSContext *cx, JSObject *obj, jsid id, const Value *vp,
|
||||||
JSPropertyOp getter, JSPropertyOp setter, uintN attrs)
|
PropertyOp getter, PropertyOp setter, uintN attrs)
|
||||||
{
|
{
|
||||||
if (id == ATOM_TO_JSID(cx->runtime->atomState.lengthAtom))
|
if (id == ATOM_TO_JSID(cx->runtime->atomState.lengthAtom))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return obj_setProperty(cx, obj, id, &value);
|
Value v;
|
||||||
|
v.copy(*vp);
|
||||||
|
return obj_setProperty(cx, obj, id, &v);
|
||||||
}
|
}
|
||||||
|
|
||||||
static JSBool
|
static JSBool
|
||||||
obj_deleteProperty(JSContext *cx, JSObject *obj, jsval id, jsval *rval)
|
obj_deleteProperty(JSContext *cx, JSObject *obj, jsid id, Value *rval)
|
||||||
{
|
{
|
||||||
if (id == ATOM_TO_JSID(cx->runtime->atomState.lengthAtom)) {
|
if (id == ATOM_TO_JSID(cx->runtime->atomState.lengthAtom)) {
|
||||||
*rval = JSVAL_FALSE;
|
rval->setBoolean(false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -635,17 +637,17 @@ class TypedArrayTemplate
|
|||||||
JS_ASSERT(tarray);
|
JS_ASSERT(tarray);
|
||||||
|
|
||||||
if (tarray->isArrayIndex(cx, id)) {
|
if (tarray->isArrayIndex(cx, id)) {
|
||||||
*rval = JSVAL_FALSE;
|
rval->setBoolean(false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
*rval = JSVAL_TRUE;
|
rval->setBoolean(true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static JSBool
|
static JSBool
|
||||||
obj_enumerate(JSContext *cx, JSObject *obj, JSIterateOp enum_op,
|
obj_enumerate(JSContext *cx, JSObject *obj, JSIterateOp enum_op,
|
||||||
jsval *statep, jsid *idp)
|
Value *statep, jsid *idp)
|
||||||
{
|
{
|
||||||
ThisTypeArray *tarray = ThisTypeArray::fromJSObject(obj);
|
ThisTypeArray *tarray = ThisTypeArray::fromJSObject(obj);
|
||||||
JS_ASSERT(tarray);
|
JS_ASSERT(tarray);
|
||||||
@ -653,21 +655,22 @@ class TypedArrayTemplate
|
|||||||
jsint curVal;
|
jsint curVal;
|
||||||
switch (enum_op) {
|
switch (enum_op) {
|
||||||
case JSENUMERATE_INIT:
|
case JSENUMERATE_INIT:
|
||||||
*statep = JSVAL_ZERO;
|
statep->setInt32(0);
|
||||||
if (idp)
|
if (idp)
|
||||||
*idp = INT_TO_JSID(tarray->length);
|
*idp = INT_TO_JSID(tarray->length);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case JSENUMERATE_NEXT:
|
case JSENUMERATE_NEXT:
|
||||||
curVal = JSVAL_TO_INT(*statep);
|
curVal = statep->asInt32();
|
||||||
*idp = INT_TO_JSID(curVal);
|
*idp = INT_TO_JSID(curVal);
|
||||||
*statep = (curVal == int32(tarray->length))
|
if (curVal == int32(tarray->length))
|
||||||
? JSVAL_NULL
|
statep->setNull();
|
||||||
: INT_TO_JSVAL(curVal+1);
|
else
|
||||||
|
statep->setInt32(curVal + 1);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case JSENUMERATE_DESTROY:
|
case JSENUMERATE_DESTROY:
|
||||||
*statep = JSVAL_NULL;
|
statep->setNull();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -688,7 +691,7 @@ class TypedArrayTemplate
|
|||||||
*/
|
*/
|
||||||
static JSBool
|
static JSBool
|
||||||
class_constructor(JSContext *cx, JSObject *obj,
|
class_constructor(JSContext *cx, JSObject *obj,
|
||||||
uintN argc, jsval *argv, jsval *rval)
|
uintN argc, Value *argv, Value *rval)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
// Note: this is a constructor for slowClass, not fastClass!
|
// Note: this is a constructor for slowClass, not fastClass!
|
||||||
@ -698,20 +701,20 @@ class TypedArrayTemplate
|
|||||||
obj = NewObject(cx, slowClass(), NULL, NULL);
|
obj = NewObject(cx, slowClass(), NULL, NULL);
|
||||||
if (!obj)
|
if (!obj)
|
||||||
return false;
|
return false;
|
||||||
*rval = OBJECT_TO_JSVAL(obj);
|
rval->setNonFunObj(*obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
return create(cx, obj, argc, argv, rval);
|
return create(cx, obj, argc, argv, rval);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
create(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
create(JSContext *cx, JSObject *obj, uintN argc, Value *argv, Value *rval)
|
||||||
{
|
{
|
||||||
if (!obj) {
|
if (!obj) {
|
||||||
obj = NewObject(cx, slowClass(), NULL, NULL);
|
obj = NewObject(cx, slowClass(), NULL, NULL);
|
||||||
if (!obj)
|
if (!obj)
|
||||||
return false;
|
return false;
|
||||||
*rval = OBJECT_TO_JSVAL(obj);
|
rval->setNonFunObj(*obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
ThisTypeArray *tarray = 0;
|
ThisTypeArray *tarray = 0;
|
||||||
@ -724,8 +727,8 @@ class TypedArrayTemplate
|
|||||||
}
|
}
|
||||||
|
|
||||||
// figure out the type of the first argument
|
// figure out the type of the first argument
|
||||||
if (JSVAL_IS_INT(argv[0])) {
|
if (argv[0].isInt32()) {
|
||||||
int32 len = JSVAL_TO_INT(argv[0]);
|
int32 len = argv[0].asInt32();
|
||||||
if (len < 0) {
|
if (len < 0) {
|
||||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL,
|
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL,
|
||||||
JSMSG_BAD_ARRAY_LENGTH);
|
JSMSG_BAD_ARRAY_LENGTH);
|
||||||
@ -743,7 +746,7 @@ class TypedArrayTemplate
|
|||||||
delete tarray;
|
delete tarray;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else if (JSVAL_IS_OBJECT(argv[0])) {
|
} else if (argv[0].isObject()) {
|
||||||
int32_t byteOffset = -1;
|
int32_t byteOffset = -1;
|
||||||
int32_t length = -1;
|
int32_t length = -1;
|
||||||
|
|
||||||
@ -773,7 +776,7 @@ class TypedArrayTemplate
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!tarray->init(cx, JSVAL_TO_OBJECT(argv[0]), byteOffset, length)) {
|
if (!tarray->init(cx, &argv[0].asObject(), byteOffset, length)) {
|
||||||
delete tarray;
|
delete tarray;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -796,13 +799,13 @@ class TypedArrayTemplate
|
|||||||
|
|
||||||
/* slice(start[, end]) */
|
/* slice(start[, end]) */
|
||||||
static JSBool
|
static JSBool
|
||||||
fun_slice(JSContext *cx, uintN argc, jsval *vp)
|
fun_slice(JSContext *cx, uintN argc, Value *vp)
|
||||||
{
|
{
|
||||||
jsval *argv;
|
Value *argv;
|
||||||
JSObject *obj;
|
JSObject *obj;
|
||||||
|
|
||||||
argv = JS_ARGV(cx, vp);
|
argv = JS_ARGV(cx, vp);
|
||||||
obj = JS_THIS_OBJECT(cx, vp);
|
obj = ComputeThisObjectFromVp(cx, vp);
|
||||||
|
|
||||||
ThisTypeArray *tarray = ThisTypeArray::fromJSObject(obj);
|
ThisTypeArray *tarray = ThisTypeArray::fromJSObject(obj);
|
||||||
if (!tarray)
|
if (!tarray)
|
||||||
@ -849,7 +852,7 @@ class TypedArrayTemplate
|
|||||||
|
|
||||||
// note the usage of JS_NewObject here -- we don't want the
|
// note the usage of JS_NewObject here -- we don't want the
|
||||||
// constructor to be called!
|
// constructor to be called!
|
||||||
JSObject *nobj = JS_NewObject(cx, slowClass(), NULL, NULL);
|
JSObject *nobj = NewObject(cx, slowClass(), NULL, NULL);
|
||||||
if (!nobj) {
|
if (!nobj) {
|
||||||
delete ntarray;
|
delete ntarray;
|
||||||
return false;
|
return false;
|
||||||
@ -857,7 +860,7 @@ class TypedArrayTemplate
|
|||||||
|
|
||||||
makeFastWithPrivate(cx, nobj, ntarray);
|
makeFastWithPrivate(cx, nobj, ntarray);
|
||||||
|
|
||||||
*vp = OBJECT_TO_JSVAL(nobj);
|
vp->setNonFunObj(*nobj);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -878,8 +881,7 @@ class TypedArrayTemplate
|
|||||||
|
|
||||||
// now munge the classword and make this into a fast typed
|
// now munge the classword and make this into a fast typed
|
||||||
// array class, since it's an instance
|
// array class, since it's an instance
|
||||||
obj->classword ^= jsuword(slowClass());
|
obj->changeClassToFastArray();
|
||||||
obj->classword |= jsuword(fastClass());
|
|
||||||
|
|
||||||
obj->map = &fastObjectMap;
|
obj->map = &fastObjectMap;
|
||||||
}
|
}
|
||||||
@ -985,7 +987,7 @@ class TypedArrayTemplate
|
|||||||
*(static_cast<NativeType*>(data) + index) = val;
|
*(static_cast<NativeType*>(data) + index) = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void copyIndexToValue(JSContext *cx, uint32 index, jsval *vp);
|
inline void copyIndexToValue(JSContext *cx, uint32 index, Value *vp);
|
||||||
|
|
||||||
ThisTypeArray *
|
ThisTypeArray *
|
||||||
slice(uint32 begin, uint32 end)
|
slice(uint32 begin, uint32 end)
|
||||||
@ -1010,15 +1012,15 @@ class TypedArrayTemplate
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
static NativeType
|
static NativeType
|
||||||
nativeFromValue(JSContext *cx, jsval v)
|
nativeFromValue(JSContext *cx, const Value &v)
|
||||||
{
|
{
|
||||||
if (JSVAL_IS_INT(v))
|
if (v.isInt32())
|
||||||
return NativeType(JSVAL_TO_INT(v));
|
return NativeType(v.asInt32());
|
||||||
|
|
||||||
if (JSVAL_IS_DOUBLE(v))
|
if (v.isDouble())
|
||||||
return NativeType(*JSVAL_TO_DOUBLE(v));
|
return NativeType(v.asDouble());
|
||||||
|
|
||||||
if (JSVAL_IS_PRIMITIVE(v) && v != JSVAL_HOLE) {
|
if (v.isPrimitive()) {
|
||||||
jsdouble dval;
|
jsdouble dval;
|
||||||
ValueToNumber(cx, v, &dval);
|
ValueToNumber(cx, v, &dval);
|
||||||
return NativeType(dval);
|
return NativeType(dval);
|
||||||
@ -1038,15 +1040,13 @@ class TypedArrayTemplate
|
|||||||
if (ar->isDenseArray() && ar->getDenseArrayCapacity() >= len) {
|
if (ar->isDenseArray() && ar->getDenseArrayCapacity() >= len) {
|
||||||
JS_ASSERT(ar->getArrayLength() == len);
|
JS_ASSERT(ar->getArrayLength() == len);
|
||||||
|
|
||||||
jsval *src = ar->getDenseArrayElements();
|
Value *src = ar->getDenseArrayElements();
|
||||||
|
|
||||||
for (uintN i = 0; i < len; ++i) {
|
for (uintN i = 0; i < len; ++i)
|
||||||
jsval v = *src++;
|
*dest++ = nativeFromValue(cx, *src++);
|
||||||
*dest++ = nativeFromValue(cx, v);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
// slow path
|
// slow path
|
||||||
jsval v;
|
Value v;
|
||||||
|
|
||||||
for (uintN i = 0; i < len; ++i) {
|
for (uintN i = 0; i < len; ++i) {
|
||||||
if (!ar->getProperty(cx, INT_TO_JSID(i), &v))
|
if (!ar->getProperty(cx, INT_TO_JSID(i), &v))
|
||||||
@ -1148,14 +1148,9 @@ class TypedArrayTemplate
|
|||||||
bool
|
bool
|
||||||
createBufferWithByteLength(JSContext *cx, int32 bytes)
|
createBufferWithByteLength(JSContext *cx, int32 bytes)
|
||||||
{
|
{
|
||||||
if (!INT_FITS_IN_JSVAL(bytes)) {
|
Value argv;
|
||||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL,
|
argv.setInt32(bytes);
|
||||||
JSMSG_NEED_DIET, "byte length");
|
JSObject *obj = js_ConstructObject(cx, &ArrayBuffer::jsclass, NULL, NULL,
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
jsval argv = INT_TO_JSVAL(bytes);
|
|
||||||
JSObject *obj = JS_ConstructObjectWithArguments(cx, &ArrayBuffer::jsclass, NULL, NULL,
|
|
||||||
1, &argv);
|
1, &argv);
|
||||||
if (!obj)
|
if (!obj)
|
||||||
return false;
|
return false;
|
||||||
@ -1175,56 +1170,50 @@ class TypedArrayTemplate
|
|||||||
// less than 32-bits in size.
|
// less than 32-bits in size.
|
||||||
template<typename NativeType>
|
template<typename NativeType>
|
||||||
void
|
void
|
||||||
TypedArrayTemplate<NativeType>::copyIndexToValue(JSContext *cx, uint32 index, jsval *vp)
|
TypedArrayTemplate<NativeType>::copyIndexToValue(JSContext *cx, uint32 index, Value *vp)
|
||||||
{
|
{
|
||||||
JS_STATIC_ASSERT(sizeof(NativeType) < 4);
|
JS_STATIC_ASSERT(sizeof(NativeType) < 4);
|
||||||
|
|
||||||
*vp = INT_TO_JSVAL(getIndex(index));
|
vp->setInt32(getIndex(index));
|
||||||
}
|
}
|
||||||
|
|
||||||
// and we need to specialize for 32-bit integers and floats
|
// and we need to specialize for 32-bit integers and floats
|
||||||
template<>
|
template<>
|
||||||
void
|
void
|
||||||
TypedArrayTemplate<int32>::copyIndexToValue(JSContext *cx, uint32 index, jsval *vp)
|
TypedArrayTemplate<int32>::copyIndexToValue(JSContext *cx, uint32 index, Value *vp)
|
||||||
{
|
{
|
||||||
int32 val = getIndex(index);
|
int32 val = getIndex(index);
|
||||||
if (INT_FITS_IN_JSVAL(val)) {
|
if (val <= JSVAL_INT_MAX)
|
||||||
*vp = INT_TO_JSVAL(val);
|
vp->setInt32(val);
|
||||||
} else {
|
else
|
||||||
jsdouble *dp = js_NewWeaklyRootedDouble(cx, jsdouble(val));
|
vp->setDouble(val);
|
||||||
*vp = dp ? DOUBLE_TO_JSVAL(dp) : JSVAL_VOID;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
void
|
void
|
||||||
TypedArrayTemplate<uint32>::copyIndexToValue(JSContext *cx, uint32 index, jsval *vp)
|
TypedArrayTemplate<uint32>::copyIndexToValue(JSContext *cx, uint32 index, Value *vp)
|
||||||
{
|
{
|
||||||
uint32 val = getIndex(index);
|
uint32 val = getIndex(index);
|
||||||
if (val < uint32(JSVAL_INT_MAX)) {
|
if (val <= JSVAL_INT_MAX)
|
||||||
*vp = INT_TO_JSVAL(int32(val));
|
vp->setInt32(val);
|
||||||
} else {
|
else
|
||||||
jsdouble *dp = js_NewWeaklyRootedDouble(cx, jsdouble(val));
|
vp->setDouble(val);
|
||||||
*vp = dp ? DOUBLE_TO_JSVAL(dp) : JSVAL_VOID;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
void
|
void
|
||||||
TypedArrayTemplate<float>::copyIndexToValue(JSContext *cx, uint32 index, jsval *vp)
|
TypedArrayTemplate<float>::copyIndexToValue(JSContext *cx, uint32 index, Value *vp)
|
||||||
{
|
{
|
||||||
float val = getIndex(index);
|
float val = getIndex(index);
|
||||||
if (!js_NewWeaklyRootedNumber(cx, jsdouble(val), vp))
|
vp->setDouble(val);
|
||||||
*vp = JSVAL_VOID;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
void
|
void
|
||||||
TypedArrayTemplate<double>::copyIndexToValue(JSContext *cx, uint32 index, jsval *vp)
|
TypedArrayTemplate<double>::copyIndexToValue(JSContext *cx, uint32 index, Value *vp)
|
||||||
{
|
{
|
||||||
double val = getIndex(index);
|
double val = getIndex(index);
|
||||||
if (!js_NewWeaklyRootedNumber(cx, jsdouble(val), vp))
|
vp->setDouble(val);
|
||||||
*vp = JSVAL_VOID;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/***
|
/***
|
||||||
@ -1235,18 +1224,18 @@ TypedArrayTemplate<double>::copyIndexToValue(JSContext *cx, uint32 index, jsval
|
|||||||
* ArrayBuffer (base)
|
* ArrayBuffer (base)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
JSClass ArrayBuffer::jsclass = {
|
Class ArrayBuffer::jsclass = {
|
||||||
"ArrayBuffer",
|
"ArrayBuffer",
|
||||||
JSCLASS_HAS_PRIVATE | JSCLASS_HAS_CACHED_PROTO(JSProto_ArrayBuffer),
|
JSCLASS_HAS_PRIVATE | JSCLASS_HAS_CACHED_PROTO(JSProto_ArrayBuffer),
|
||||||
JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_PropertyStub,
|
PropertyStub, PropertyStub, PropertyStub, PropertyStub,
|
||||||
JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, ArrayBuffer::class_finalize,
|
EnumerateStub, ResolveStub, ConvertStub, ArrayBuffer::class_finalize,
|
||||||
JSCLASS_NO_OPTIONAL_MEMBERS
|
JSCLASS_NO_OPTIONAL_MEMBERS
|
||||||
};
|
};
|
||||||
|
|
||||||
JSPropertySpec ArrayBuffer::jsprops[] = {
|
JSPropertySpec ArrayBuffer::jsprops[] = {
|
||||||
{ "byteLength",
|
{ "byteLength",
|
||||||
-1, JSPROP_SHARED | JSPROP_PERMANENT | JSPROP_READONLY,
|
-1, JSPROP_SHARED | JSPROP_PERMANENT | JSPROP_READONLY,
|
||||||
ArrayBuffer::prop_getByteLength, ArrayBuffer::prop_getByteLength },
|
Jsvalify(ArrayBuffer::prop_getByteLength), Jsvalify(ArrayBuffer::prop_getByteLength) },
|
||||||
{0,0,0,0,0}
|
{0,0,0,0,0}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1257,20 +1246,19 @@ JSPropertySpec ArrayBuffer::jsprops[] = {
|
|||||||
JSPropertySpec TypedArray::jsprops[] = {
|
JSPropertySpec TypedArray::jsprops[] = {
|
||||||
{ js_length_str,
|
{ js_length_str,
|
||||||
-1, JSPROP_SHARED | JSPROP_PERMANENT | JSPROP_READONLY,
|
-1, JSPROP_SHARED | JSPROP_PERMANENT | JSPROP_READONLY,
|
||||||
TypedArray::prop_getLength, TypedArray::prop_getLength },
|
Jsvalify(TypedArray::prop_getLength), Jsvalify(TypedArray::prop_getLength) },
|
||||||
{ "byteLength",
|
{ "byteLength",
|
||||||
-1, JSPROP_SHARED | JSPROP_PERMANENT | JSPROP_READONLY,
|
-1, JSPROP_SHARED | JSPROP_PERMANENT | JSPROP_READONLY,
|
||||||
TypedArray::prop_getByteLength, TypedArray::prop_getByteLength },
|
Jsvalify(TypedArray::prop_getByteLength), Jsvalify(TypedArray::prop_getByteLength) },
|
||||||
{ "byteOffset",
|
{ "byteOffset",
|
||||||
-1, JSPROP_SHARED | JSPROP_PERMANENT | JSPROP_READONLY,
|
-1, JSPROP_SHARED | JSPROP_PERMANENT | JSPROP_READONLY,
|
||||||
TypedArray::prop_getByteOffset, TypedArray::prop_getByteOffset },
|
Jsvalify(TypedArray::prop_getByteOffset), Jsvalify(TypedArray::prop_getByteOffset) },
|
||||||
{ "buffer",
|
{ "buffer",
|
||||||
-1, JSPROP_SHARED | JSPROP_PERMANENT | JSPROP_READONLY,
|
-1, JSPROP_SHARED | JSPROP_PERMANENT | JSPROP_READONLY,
|
||||||
TypedArray::prop_getBuffer, TypedArray::prop_getBuffer },
|
Jsvalify(TypedArray::prop_getBuffer), Jsvalify(TypedArray::prop_getBuffer) },
|
||||||
{0,0,0,0,0}
|
{0,0,0,0,0}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* TypedArray boilerplate
|
* TypedArray boilerplate
|
||||||
*/
|
*/
|
||||||
@ -1306,8 +1294,8 @@ template<> JSFunctionSpec _typedArray::jsfuncs[] = { \
|
|||||||
{ \
|
{ \
|
||||||
#_typedArray, \
|
#_typedArray, \
|
||||||
JSCLASS_HAS_PRIVATE | JSCLASS_HAS_CACHED_PROTO(JSProto_##_typedArray), \
|
JSCLASS_HAS_PRIVATE | JSCLASS_HAS_CACHED_PROTO(JSProto_##_typedArray), \
|
||||||
JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, \
|
PropertyStub, PropertyStub, PropertyStub, PropertyStub, \
|
||||||
JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, JS_FinalizeStub, \
|
EnumerateStub, ResolveStub, ConvertStub, FinalizeStub, \
|
||||||
JSCLASS_NO_OPTIONAL_MEMBERS \
|
JSCLASS_NO_OPTIONAL_MEMBERS \
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1315,8 +1303,8 @@ template<> JSFunctionSpec _typedArray::jsfuncs[] = { \
|
|||||||
{ \
|
{ \
|
||||||
#_typedArray, \
|
#_typedArray, \
|
||||||
JSCLASS_HAS_PRIVATE, \
|
JSCLASS_HAS_PRIVATE, \
|
||||||
JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, \
|
PropertyStub, PropertyStub, PropertyStub, PropertyStub, \
|
||||||
JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, \
|
EnumerateStub, ResolveStub, ConvertStub, \
|
||||||
_typedArray::class_finalize, \
|
_typedArray::class_finalize, \
|
||||||
_typedArray::getObjectOps, NULL, NULL, NULL, \
|
_typedArray::getObjectOps, NULL, NULL, NULL, \
|
||||||
NULL, NULL, NULL, NULL \
|
NULL, NULL, NULL, NULL \
|
||||||
@ -1345,7 +1333,7 @@ IMPL_TYPED_ARRAY_STATICS(Float32Array);
|
|||||||
IMPL_TYPED_ARRAY_STATICS(Float64Array);
|
IMPL_TYPED_ARRAY_STATICS(Float64Array);
|
||||||
IMPL_TYPED_ARRAY_STATICS(Uint8ClampedArray);
|
IMPL_TYPED_ARRAY_STATICS(Uint8ClampedArray);
|
||||||
|
|
||||||
JSClass TypedArray::fastClasses[TYPE_MAX] = {
|
Class TypedArray::fastClasses[TYPE_MAX] = {
|
||||||
IMPL_TYPED_ARRAY_FAST_CLASS(Int8Array),
|
IMPL_TYPED_ARRAY_FAST_CLASS(Int8Array),
|
||||||
IMPL_TYPED_ARRAY_FAST_CLASS(Uint8Array),
|
IMPL_TYPED_ARRAY_FAST_CLASS(Uint8Array),
|
||||||
IMPL_TYPED_ARRAY_FAST_CLASS(Int16Array),
|
IMPL_TYPED_ARRAY_FAST_CLASS(Int16Array),
|
||||||
@ -1357,7 +1345,7 @@ JSClass TypedArray::fastClasses[TYPE_MAX] = {
|
|||||||
IMPL_TYPED_ARRAY_FAST_CLASS(Uint8ClampedArray)
|
IMPL_TYPED_ARRAY_FAST_CLASS(Uint8ClampedArray)
|
||||||
};
|
};
|
||||||
|
|
||||||
JSClass TypedArray::slowClasses[TYPE_MAX] = {
|
Class TypedArray::slowClasses[TYPE_MAX] = {
|
||||||
IMPL_TYPED_ARRAY_SLOW_CLASS(Int8Array),
|
IMPL_TYPED_ARRAY_SLOW_CLASS(Int8Array),
|
||||||
IMPL_TYPED_ARRAY_SLOW_CLASS(Uint8Array),
|
IMPL_TYPED_ARRAY_SLOW_CLASS(Uint8Array),
|
||||||
IMPL_TYPED_ARRAY_SLOW_CLASS(Int16Array),
|
IMPL_TYPED_ARRAY_SLOW_CLASS(Int16Array),
|
||||||
@ -1418,19 +1406,19 @@ js_IsTypedArray(JSObject *obj)
|
|||||||
JS_FRIEND_API(JSObject *)
|
JS_FRIEND_API(JSObject *)
|
||||||
js_CreateArrayBuffer(JSContext *cx, jsuint nbytes)
|
js_CreateArrayBuffer(JSContext *cx, jsuint nbytes)
|
||||||
{
|
{
|
||||||
AutoValueRooter tvr(cx);
|
Value vals[2];
|
||||||
if (!js_NewNumberInRootedValue(cx, jsdouble(nbytes), tvr.addr()))
|
vals[0].setNumber(nbytes);
|
||||||
|
vals[1].setUndefined();
|
||||||
|
|
||||||
|
AutoArrayRooter tvr(cx, JS_ARRAY_LENGTH(vals), vals);
|
||||||
|
if (!ArrayBuffer::create(cx, NULL, 1, &vals[0], &vals[1]))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
AutoValueRooter rval(cx);
|
return &vals[1].asObject();
|
||||||
if (!ArrayBuffer::create(cx, NULL, 1, tvr.addr(), rval.addr()))
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
return JSVAL_TO_OBJECT(rval.value());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline JSBool
|
static inline JSBool
|
||||||
TypedArrayConstruct(JSContext *cx, jsint atype, uintN argc, jsval *argv, jsval *rv)
|
TypedArrayConstruct(JSContext *cx, jsint atype, uintN argc, Value *argv, Value *rv)
|
||||||
{
|
{
|
||||||
switch (atype) {
|
switch (atype) {
|
||||||
case TypedArray::TYPE_INT8:
|
case TypedArray::TYPE_INT8:
|
||||||
@ -1471,16 +1459,15 @@ js_CreateTypedArray(JSContext *cx, jsint atype, jsuint nelements)
|
|||||||
{
|
{
|
||||||
JS_ASSERT(atype >= 0 && atype < TypedArray::TYPE_MAX);
|
JS_ASSERT(atype >= 0 && atype < TypedArray::TYPE_MAX);
|
||||||
|
|
||||||
jsval vals[2] = { JSVAL_NULL, JSVAL_NULL };
|
Value vals[2];
|
||||||
|
vals[0].setInt32(nelements);
|
||||||
|
vals[1].setUndefined();
|
||||||
|
|
||||||
AutoArrayRooter tvr(cx, JS_ARRAY_LENGTH(vals), vals);
|
AutoArrayRooter tvr(cx, JS_ARRAY_LENGTH(vals), vals);
|
||||||
|
|
||||||
if (!js_NewNumberInRootedValue(cx, jsdouble(nelements), &vals[0]))
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
if (!TypedArrayConstruct(cx, atype, 1, &vals[0], &vals[1]))
|
if (!TypedArrayConstruct(cx, atype, 1, &vals[0], &vals[1]))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return JSVAL_TO_OBJECT(vals[1]);
|
return &vals[1].asObject();
|
||||||
}
|
}
|
||||||
|
|
||||||
JS_FRIEND_API(JSObject *)
|
JS_FRIEND_API(JSObject *)
|
||||||
@ -1488,15 +1475,15 @@ js_CreateTypedArrayWithArray(JSContext *cx, jsint atype, JSObject *arrayArg)
|
|||||||
{
|
{
|
||||||
JS_ASSERT(atype >= 0 && atype < TypedArray::TYPE_MAX);
|
JS_ASSERT(atype >= 0 && atype < TypedArray::TYPE_MAX);
|
||||||
|
|
||||||
jsval vals[2] = { JSVAL_NULL, JSVAL_NULL };
|
Value vals[2];
|
||||||
|
vals[0].setObject(*arrayArg);
|
||||||
|
vals[1].setUndefined();
|
||||||
|
|
||||||
AutoArrayRooter tvr(cx, JS_ARRAY_LENGTH(vals), vals);
|
AutoArrayRooter tvr(cx, JS_ARRAY_LENGTH(vals), vals);
|
||||||
|
|
||||||
vals[0] = OBJECT_TO_JSVAL(arrayArg);
|
|
||||||
|
|
||||||
if (!TypedArrayConstruct(cx, atype, 1, &vals[0], &vals[1]))
|
if (!TypedArrayConstruct(cx, atype, 1, &vals[0], &vals[1]))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return JSVAL_TO_OBJECT(vals[1]);
|
return &vals[1].asObject();
|
||||||
}
|
}
|
||||||
|
|
||||||
JS_FRIEND_API(JSObject *)
|
JS_FRIEND_API(JSObject *)
|
||||||
@ -1507,30 +1494,27 @@ js_CreateTypedArrayWithBuffer(JSContext *cx, jsint atype, JSObject *bufArg,
|
|||||||
JS_ASSERT(bufArg && ArrayBuffer::fromJSObject(bufArg));
|
JS_ASSERT(bufArg && ArrayBuffer::fromJSObject(bufArg));
|
||||||
JS_ASSERT_IF(byteoffset < 0, length < 0);
|
JS_ASSERT_IF(byteoffset < 0, length < 0);
|
||||||
|
|
||||||
jsval vals[4] = { JSVAL_NULL, JSVAL_NULL, JSVAL_NULL, JSVAL_NULL };
|
Value vals[4];
|
||||||
AutoArrayRooter tvr(cx, JS_ARRAY_LENGTH(vals), vals);
|
|
||||||
|
|
||||||
int argc = 1;
|
int argc = 1;
|
||||||
vals[0] = OBJECT_TO_JSVAL(bufArg);
|
vals[0].setObject(*bufArg);
|
||||||
|
vals[3].setUndefined();
|
||||||
|
|
||||||
if (byteoffset >= 0) {
|
if (byteoffset >= 0) {
|
||||||
if (!js_NewNumberInRootedValue(cx, jsdouble(byteoffset), &vals[argc]))
|
vals[argc].setInt32(byteoffset);
|
||||||
return NULL;
|
|
||||||
|
|
||||||
argc++;
|
argc++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (length >= 0) {
|
if (length >= 0) {
|
||||||
if (!js_NewNumberInRootedValue(cx, jsdouble(length), &vals[argc]))
|
vals[argc].setInt32(length);
|
||||||
return NULL;
|
|
||||||
|
|
||||||
argc++;
|
argc++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AutoArrayRooter tvr(cx, JS_ARRAY_LENGTH(vals), vals);
|
||||||
if (!TypedArrayConstruct(cx, atype, argc, &vals[0], &vals[3]))
|
if (!TypedArrayConstruct(cx, atype, argc, &vals[0], &vals[3]))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return JSVAL_TO_OBJECT(vals[3]);
|
return &vals[3].asObject();
|
||||||
}
|
}
|
||||||
|
|
||||||
JS_FRIEND_API(JSBool)
|
JS_FRIEND_API(JSBool)
|
||||||
@ -1554,14 +1538,14 @@ js_ReparentTypedArrayToScope(JSContext *cx, JSObject *obj, JSObject *scope)
|
|||||||
if (!js_GetClassPrototype(cx, scope, key, &proto))
|
if (!js_GetClassPrototype(cx, scope, key, &proto))
|
||||||
return JS_FALSE;
|
return JS_FALSE;
|
||||||
|
|
||||||
obj->setProto(proto);
|
obj->setProto(NonFunObjTag(*proto));
|
||||||
obj->setParent(scope);
|
obj->setParent(scope);
|
||||||
|
|
||||||
key = JSCLASS_CACHED_PROTO_KEY(&ArrayBuffer::jsclass);
|
key = JSCLASS_CACHED_PROTO_KEY(&ArrayBuffer::jsclass);
|
||||||
if (!js_GetClassPrototype(cx, scope, key, &proto))
|
if (!js_GetClassPrototype(cx, scope, key, &proto))
|
||||||
return JS_FALSE;
|
return JS_FALSE;
|
||||||
|
|
||||||
buffer->setProto(proto);
|
buffer->setProto(NonFunObjTag(*proto));
|
||||||
buffer->setParent(scope);
|
buffer->setParent(scope);
|
||||||
|
|
||||||
return JS_TRUE;
|
return JS_TRUE;
|
||||||
|
@ -55,17 +55,17 @@ namespace js {
|
|||||||
* TypedArray with a size.
|
* TypedArray with a size.
|
||||||
*/
|
*/
|
||||||
struct JS_FRIEND_API(ArrayBuffer) {
|
struct JS_FRIEND_API(ArrayBuffer) {
|
||||||
static js::Class jsclass;
|
static Class jsclass;
|
||||||
static JSPropertySpec jsprops[];
|
static JSPropertySpec jsprops[];
|
||||||
|
|
||||||
static JSBool prop_getByteLength(JSContext *cx, JSObject *obj, jsval id, jsval *vp);
|
static JSBool prop_getByteLength(JSContext *cx, JSObject *obj, jsid id, Value *vp);
|
||||||
static void class_finalize(JSContext *cx, JSObject *obj);
|
static void class_finalize(JSContext *cx, JSObject *obj);
|
||||||
|
|
||||||
static JSBool class_constructor(JSContext *cx, JSObject *obj,
|
static JSBool class_constructor(JSContext *cx, JSObject *obj, uintN argc, Value *argv,
|
||||||
uintN argc, jsval *argv, jsval *rval);
|
Value *rval);
|
||||||
|
|
||||||
static bool create(JSContext *cx, JSObject *obj, uintN argc,
|
static bool create(JSContext *cx, JSObject *obj, uintN argc,
|
||||||
jsval *argv, jsval *rval);
|
Value *argv, Value *rval);
|
||||||
|
|
||||||
static ArrayBuffer *fromJSObject(JSObject *obj);
|
static ArrayBuffer *fromJSObject(JSObject *obj);
|
||||||
|
|
||||||
@ -116,20 +116,20 @@ struct JS_FRIEND_API(TypedArray) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// and MUST NOT be used to construct new objects.
|
// and MUST NOT be used to construct new objects.
|
||||||
static js::Class fastClasses[TYPE_MAX];
|
static Class fastClasses[TYPE_MAX];
|
||||||
|
|
||||||
// These are the slow/original classes, used
|
// These are the slow/original classes, used
|
||||||
// fo constructing new objects
|
// fo constructing new objects
|
||||||
static js::Class slowClasses[TYPE_MAX];
|
static Class slowClasses[TYPE_MAX];
|
||||||
|
|
||||||
static JSPropertySpec jsprops[];
|
static JSPropertySpec jsprops[];
|
||||||
|
|
||||||
static TypedArray *fromJSObject(JSObject *obj);
|
static TypedArray *fromJSObject(JSObject *obj);
|
||||||
|
|
||||||
static JSBool prop_getBuffer(JSContext *cx, JSObject *obj, jsval id, jsval *vp);
|
static JSBool prop_getBuffer(JSContext *cx, JSObject *obj, jsid id, Value *vp);
|
||||||
static JSBool prop_getByteOffset(JSContext *cx, JSObject *obj, jsval id, jsval *vp);
|
static JSBool prop_getByteOffset(JSContext *cx, JSObject *obj, jsid id, Value *vp);
|
||||||
static JSBool prop_getByteLength(JSContext *cx, JSObject *obj, jsval id, jsval *vp);
|
static JSBool prop_getByteLength(JSContext *cx, JSObject *obj, jsid id, Value *vp);
|
||||||
static JSBool prop_getLength(JSContext *cx, JSObject *obj, jsval id, jsval *vp);
|
static JSBool prop_getLength(JSContext *cx, JSObject *obj, jsid id, Value *vp);
|
||||||
|
|
||||||
static JSBool obj_lookupProperty(JSContext *cx, JSObject *obj, jsid id,
|
static JSBool obj_lookupProperty(JSContext *cx, JSObject *obj, jsid id,
|
||||||
JSObject **objp, JSProperty **propp);
|
JSObject **objp, JSProperty **propp);
|
||||||
|
@ -36,6 +36,9 @@
|
|||||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||||
*
|
*
|
||||||
* ***** END LICENSE BLOCK ***** */
|
* ***** END LICENSE BLOCK ***** */
|
||||||
|
|
||||||
|
#define __STDC_LIMIT_MACROS
|
||||||
|
|
||||||
#include "jsversion.h"
|
#include "jsversion.h"
|
||||||
|
|
||||||
#if JS_HAS_XDR
|
#if JS_HAS_XDR
|
||||||
@ -54,6 +57,8 @@
|
|||||||
#include "jsstr.h"
|
#include "jsstr.h"
|
||||||
#include "jsxdrapi.h"
|
#include "jsxdrapi.h"
|
||||||
|
|
||||||
|
using namespace js;
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
#define DBG(x) x
|
#define DBG(x) x
|
||||||
#else
|
#else
|
||||||
@ -502,22 +507,44 @@ XDRDoubleValue(JSXDRState *xdr, jsdouble *dp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
JS_PUBLIC_API(JSBool)
|
JS_PUBLIC_API(JSBool)
|
||||||
JS_XDRDouble(JSXDRState *xdr, jsdouble **dpp)
|
JS_XDRDouble(JSXDRState *xdr, jsdouble *dp)
|
||||||
{
|
{
|
||||||
jsdouble d = (xdr->mode == JSXDR_ENCODE) ? **dpp : 0.0;
|
jsdouble d = (xdr->mode == JSXDR_ENCODE) ? *dp : 0.0;
|
||||||
if (!XDRDoubleValue(xdr, &d))
|
if (!XDRDoubleValue(xdr, &d))
|
||||||
return JS_FALSE;
|
return JS_FALSE;
|
||||||
if (xdr->mode == JSXDR_DECODE) {
|
if (xdr->mode == JSXDR_DECODE)
|
||||||
*dpp = JS_NewDouble(xdr->cx, d);
|
*dp = d;
|
||||||
if (!*dpp)
|
|
||||||
return JS_FALSE;
|
|
||||||
}
|
|
||||||
return JS_TRUE;
|
return JS_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* These are magic pseudo-tags: see jsapi.h, near the top, for real tags. */
|
enum jsvaltag {
|
||||||
#define JSVAL_XDRNULL 0x8
|
JSVAL_OBJECT = 0x0,
|
||||||
#define JSVAL_XDRVOID 0xA
|
JSVAL_INT = 0x1,
|
||||||
|
JSVAL_DOUBLE = 0x2,
|
||||||
|
JSVAL_STRING = 0x4,
|
||||||
|
JSVAL_SPECIAL = 0x6,
|
||||||
|
JSVAL_XDRNULL = 0x8,
|
||||||
|
JSVAL_XDRVOID = 0xA
|
||||||
|
};
|
||||||
|
|
||||||
|
static jsvaltag
|
||||||
|
JSVAL_TAG(jsval v)
|
||||||
|
{
|
||||||
|
if (JSVAL_IS_NULL(v))
|
||||||
|
return JSVAL_XDRNULL;
|
||||||
|
if (JSVAL_IS_VOID(v))
|
||||||
|
return JSVAL_XDRVOID;
|
||||||
|
if (JSVAL_IS_OBJECT(v))
|
||||||
|
return JSVAL_OBJECT;
|
||||||
|
if (JSVAL_IS_INT(v))
|
||||||
|
return JSVAL_INT;
|
||||||
|
if (JSVAL_IS_DOUBLE(v))
|
||||||
|
return JSVAL_DOUBLE;
|
||||||
|
if (JSVAL_IS_STRING(v))
|
||||||
|
return JSVAL_STRING;
|
||||||
|
JS_ASSERT(JSVAL_IS_BOOLEAN(v));
|
||||||
|
return JSVAL_SPECIAL;
|
||||||
|
}
|
||||||
|
|
||||||
static JSBool
|
static JSBool
|
||||||
XDRValueBody(JSXDRState *xdr, uint32 type, jsval *vp)
|
XDRValueBody(JSXDRState *xdr, uint32 type, jsval *vp)
|
||||||
@ -540,11 +567,11 @@ XDRValueBody(JSXDRState *xdr, uint32 type, jsval *vp)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case JSVAL_DOUBLE: {
|
case JSVAL_DOUBLE: {
|
||||||
jsdouble *dp = (xdr->mode == JSXDR_ENCODE) ? JSVAL_TO_DOUBLE(*vp) : NULL;
|
double d = xdr->mode == JSXDR_ENCODE ? JSVAL_TO_DOUBLE(*vp) : 0;
|
||||||
if (!JS_XDRDouble(xdr, &dp))
|
if (!JS_XDRDouble(xdr, &d))
|
||||||
return JS_FALSE;
|
return JS_FALSE;
|
||||||
if (xdr->mode == JSXDR_DECODE)
|
if (xdr->mode == JSXDR_DECODE)
|
||||||
*vp = DOUBLE_TO_JSVAL(dp);
|
*vp = DOUBLE_TO_JSVAL(d);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case JSVAL_OBJECT: {
|
case JSVAL_OBJECT: {
|
||||||
@ -570,7 +597,7 @@ XDRValueBody(JSXDRState *xdr, uint32 type, jsval *vp)
|
|||||||
default: {
|
default: {
|
||||||
uint32 i;
|
uint32 i;
|
||||||
|
|
||||||
JS_ASSERT(type & JSVAL_INT);
|
JS_ASSERT(type == JSVAL_INT);
|
||||||
if (xdr->mode == JSXDR_ENCODE)
|
if (xdr->mode == JSXDR_ENCODE)
|
||||||
i = (uint32) JSVAL_TO_INT(*vp);
|
i = (uint32) JSVAL_TO_INT(*vp);
|
||||||
if (!JS_XDRUint32(xdr, &i))
|
if (!JS_XDRUint32(xdr, &i))
|
||||||
@ -588,14 +615,8 @@ JS_XDRValue(JSXDRState *xdr, jsval *vp)
|
|||||||
{
|
{
|
||||||
uint32 type;
|
uint32 type;
|
||||||
|
|
||||||
if (xdr->mode == JSXDR_ENCODE) {
|
if (xdr->mode == JSXDR_ENCODE)
|
||||||
if (JSVAL_IS_NULL(*vp))
|
|
||||||
type = JSVAL_XDRNULL;
|
|
||||||
else if (JSVAL_IS_VOID(*vp))
|
|
||||||
type = JSVAL_XDRVOID;
|
|
||||||
else
|
|
||||||
type = JSVAL_TAG(*vp);
|
type = JSVAL_TAG(*vp);
|
||||||
}
|
|
||||||
return JS_XDRUint32(xdr, &type) && XDRValueBody(xdr, type, vp);
|
return JS_XDRUint32(xdr, &type) && XDRValueBody(xdr, type, vp);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -606,7 +627,7 @@ js_XDRAtom(JSXDRState *xdr, JSAtom **atomp)
|
|||||||
uint32 type;
|
uint32 type;
|
||||||
|
|
||||||
if (xdr->mode == JSXDR_ENCODE) {
|
if (xdr->mode == JSXDR_ENCODE) {
|
||||||
v = ATOM_KEY(*atomp);
|
v = Jsvalify(BoxedWordToValue(ATOM_KEY(*atomp)));
|
||||||
return JS_XDRValue(xdr, &v);
|
return JS_XDRValue(xdr, &v);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -627,8 +648,10 @@ js_XDRAtom(JSXDRState *xdr, JSAtom **atomp)
|
|||||||
return *atomp != NULL;
|
return *atomp != NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
jsboxedword w;
|
||||||
return XDRValueBody(xdr, type, &v) &&
|
return XDRValueBody(xdr, type, &v) &&
|
||||||
js_AtomizePrimitiveValue(xdr->cx, v, atomp);
|
ValueToBoxedWord(xdr->cx, Valueify(v), &w) &&
|
||||||
|
js_AtomizePrimitiveValue(xdr->cx, w, atomp);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern JSBool
|
extern JSBool
|
||||||
@ -781,14 +804,14 @@ JS_XDRFindClassIdByName(JSXDRState *xdr, const char *name)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
JS_PUBLIC_API(JSClass *)
|
JS_PUBLIC_API(Class *)
|
||||||
JS_XDRFindClassById(JSXDRState *xdr, uint32 id)
|
JS_XDRFindClassById(JSXDRState *xdr, uint32 id)
|
||||||
{
|
{
|
||||||
uintN i = CLASS_ID_TO_INDEX(id);
|
uintN i = CLASS_ID_TO_INDEX(id);
|
||||||
|
|
||||||
if (i >= xdr->numclasses)
|
if (i >= xdr->numclasses)
|
||||||
return NULL;
|
return NULL;
|
||||||
return xdr->registry[i];
|
return Valueify(xdr->registry[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* JS_HAS_XDR */
|
#endif /* JS_HAS_XDR */
|
||||||
|
@ -110,7 +110,7 @@ struct JSXDRState {
|
|||||||
JSXDRMode mode;
|
JSXDRMode mode;
|
||||||
JSXDROps *ops;
|
JSXDROps *ops;
|
||||||
JSContext *cx;
|
JSContext *cx;
|
||||||
js::Class **registry;
|
JSClass **registry;
|
||||||
uintN numclasses;
|
uintN numclasses;
|
||||||
uintN maxclasses;
|
uintN maxclasses;
|
||||||
void *reghash;
|
void *reghash;
|
||||||
@ -164,7 +164,7 @@ extern JS_PUBLIC_API(JSBool)
|
|||||||
JS_XDRStringOrNull(JSXDRState *xdr, JSString **strp);
|
JS_XDRStringOrNull(JSXDRState *xdr, JSString **strp);
|
||||||
|
|
||||||
extern JS_PUBLIC_API(JSBool)
|
extern JS_PUBLIC_API(JSBool)
|
||||||
JS_XDRDouble(JSXDRState *xdr, jsdouble **dp);
|
JS_XDRDouble(JSXDRState *xdr, jsdouble *dp);
|
||||||
|
|
||||||
extern JS_PUBLIC_API(JSBool)
|
extern JS_PUBLIC_API(JSBool)
|
||||||
JS_XDRValue(JSXDRState *xdr, jsval *vp);
|
JS_XDRValue(JSXDRState *xdr, jsval *vp);
|
||||||
@ -205,7 +205,7 @@ JS_XDRFindClassById(JSXDRState *xdr, uint32 id);
|
|||||||
* before deserialization of bytecode. If the saved version does not match
|
* before deserialization of bytecode. If the saved version does not match
|
||||||
* the current version, abort deserialization and invalidate the file.
|
* the current version, abort deserialization and invalidate the file.
|
||||||
*/
|
*/
|
||||||
#define JSXDR_BYTECODE_VERSION (0xb973c0de - 62)
|
#define JSXDR_BYTECODE_VERSION (0xb973c0de - 63)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Library-private functions.
|
* Library-private functions.
|
||||||
|
Loading…
Reference in New Issue
Block a user