зеркало из https://github.com/mozilla/pjs.git
Bug 358594: sharp variables should deserialize using old getter/setter syntax.
This commit is contained in:
Родитель
704e55daa9
Коммит
bdcf02c83c
|
@ -719,6 +719,7 @@ js_obj_toSource(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
||||||
uintN attrs;
|
uintN attrs;
|
||||||
#endif
|
#endif
|
||||||
jsval *val;
|
jsval *val;
|
||||||
|
JSString *gsopold[2];
|
||||||
JSString *gsop[2];
|
JSString *gsop[2];
|
||||||
JSAtom *atom;
|
JSAtom *atom;
|
||||||
JSString *idstr, *valstr, *str;
|
JSString *idstr, *valstr, *str;
|
||||||
|
@ -877,31 +878,23 @@ js_obj_toSource(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
||||||
(attrs & (JSPROP_GETTER | JSPROP_SETTER))) {
|
(attrs & (JSPROP_GETTER | JSPROP_SETTER))) {
|
||||||
if (attrs & JSPROP_GETTER) {
|
if (attrs & JSPROP_GETTER) {
|
||||||
val[valcnt] = (jsval) ((JSScopeProperty *)prop)->getter;
|
val[valcnt] = (jsval) ((JSScopeProperty *)prop)->getter;
|
||||||
#ifdef OLD_GETTER_SETTER
|
gsopold[valcnt] =
|
||||||
gsop[valcnt] =
|
|
||||||
ATOM_TO_STRING(cx->runtime->atomState.getterAtom);
|
ATOM_TO_STRING(cx->runtime->atomState.getterAtom);
|
||||||
#else
|
gsop[valcnt] =
|
||||||
gsop[valcnt] = needOldStyleGetterSetter
|
ATOM_TO_STRING(cx->runtime->atomState.getAtom);
|
||||||
? ATOM_TO_STRING(cx->runtime->atomState.getterAtom)
|
|
||||||
: ATOM_TO_STRING(cx->runtime->atomState.getAtom);
|
|
||||||
#endif
|
|
||||||
valcnt++;
|
|
||||||
}
|
}
|
||||||
if (attrs & JSPROP_SETTER) {
|
if (attrs & JSPROP_SETTER) {
|
||||||
val[valcnt] = (jsval) ((JSScopeProperty *)prop)->setter;
|
val[valcnt] = (jsval) ((JSScopeProperty *)prop)->setter;
|
||||||
#ifdef OLD_GETTER_SETTER
|
gsopold[valcnt] =
|
||||||
gsop[valcnt] =
|
|
||||||
ATOM_TO_STRING(cx->runtime->atomState.setterAtom);
|
ATOM_TO_STRING(cx->runtime->atomState.setterAtom);
|
||||||
#else
|
gsop[valcnt] =
|
||||||
gsop[valcnt] = needOldStyleGetterSetter
|
ATOM_TO_STRING(cx->runtime->atomState.setAtom);
|
||||||
? ATOM_TO_STRING(cx->runtime->atomState.setterAtom)
|
|
||||||
: ATOM_TO_STRING(cx->runtime->atomState.setAtom);
|
|
||||||
#endif
|
|
||||||
valcnt++;
|
|
||||||
}
|
}
|
||||||
|
valcnt++;
|
||||||
} else {
|
} else {
|
||||||
valcnt = 1;
|
valcnt = 1;
|
||||||
gsop[0] = NULL;
|
gsop[0] = NULL;
|
||||||
|
gsopold[0] = NULL;
|
||||||
ok = OBJ_GET_PROPERTY(cx, obj, id, &val[0]);
|
ok = OBJ_GET_PROPERTY(cx, obj, id, &val[0]);
|
||||||
}
|
}
|
||||||
OBJ_DROP_PROPERTY(cx, obj2, prop);
|
OBJ_DROP_PROPERTY(cx, obj2, prop);
|
||||||
|
@ -917,6 +910,7 @@ js_obj_toSource(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
||||||
*/
|
*/
|
||||||
valcnt = 1;
|
valcnt = 1;
|
||||||
gsop[0] = NULL;
|
gsop[0] = NULL;
|
||||||
|
gsopold[0] = NULL;
|
||||||
ok = OBJ_GET_PROPERTY(cx, obj, id, &val[0]);
|
ok = OBJ_GET_PROPERTY(cx, obj, id, &val[0]);
|
||||||
|
|
||||||
#endif /* !JS_HAS_GETTER_SETTER */
|
#endif /* !JS_HAS_GETTER_SETTER */
|
||||||
|
@ -952,6 +946,12 @@ js_obj_toSource(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
||||||
vchars = JSSTRING_CHARS(valstr);
|
vchars = JSSTRING_CHARS(valstr);
|
||||||
vlength = JSSTRING_LENGTH(valstr);
|
vlength = JSSTRING_LENGTH(valstr);
|
||||||
|
|
||||||
|
if (vchars[0] == '#')
|
||||||
|
needOldStyleGetterSetter = JS_TRUE;
|
||||||
|
|
||||||
|
if (needOldStyleGetterSetter)
|
||||||
|
gsop[j] = gsopold[j];
|
||||||
|
|
||||||
#ifndef OLD_GETTER_SETTER
|
#ifndef OLD_GETTER_SETTER
|
||||||
/*
|
/*
|
||||||
* Remove '(function ' from the beginning of valstr and ')' from the
|
* Remove '(function ' from the beginning of valstr and ')' from the
|
||||||
|
@ -964,6 +964,9 @@ js_obj_toSource(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
||||||
vchars += n;
|
vchars += n;
|
||||||
vlength -= n + 1;
|
vlength -= n + 1;
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
needOldStyleGetterSetter = JS_TRUE;
|
||||||
|
gsop[j] = gsopold[j];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* If val[j] is a non-sharp object, consider sharpening it. */
|
/* If val[j] is a non-sharp object, consider sharpening it. */
|
||||||
|
@ -980,10 +983,14 @@ js_obj_toSource(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
||||||
if (IS_SHARP(he)) {
|
if (IS_SHARP(he)) {
|
||||||
vchars = vsharp;
|
vchars = vsharp;
|
||||||
vlength = js_strlen(vchars);
|
vlength = js_strlen(vchars);
|
||||||
|
needOldStyleGetterSetter = JS_TRUE;
|
||||||
|
gsop[j] = gsopold[j];
|
||||||
} else {
|
} else {
|
||||||
if (vsharp) {
|
if (vsharp) {
|
||||||
vsharplength = js_strlen(vsharp);
|
vsharplength = js_strlen(vsharp);
|
||||||
MAKE_SHARP(he);
|
MAKE_SHARP(he);
|
||||||
|
needOldStyleGetterSetter = JS_TRUE;
|
||||||
|
gsop[j] = gsopold[j];
|
||||||
}
|
}
|
||||||
js_LeaveSharpObject(cx, NULL);
|
js_LeaveSharpObject(cx, NULL);
|
||||||
}
|
}
|
||||||
|
@ -1029,17 +1036,6 @@ js_obj_toSource(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
||||||
}
|
}
|
||||||
comma = ", ";
|
comma = ", ";
|
||||||
|
|
||||||
#ifdef OLD_GETTER_SETTER
|
|
||||||
js_strncpy(&chars[nchars], idstrchars, idstrlength);
|
|
||||||
nchars += idstrlength;
|
|
||||||
if (gsop[j]) {
|
|
||||||
chars[nchars++] = ' ';
|
|
||||||
gsoplength = JSSTRING_LENGTH(gsop[j]);
|
|
||||||
js_strncpy(&chars[nchars], JSSTRING_CHARS(gsop[j]), gsoplength);
|
|
||||||
nchars += gsoplength;
|
|
||||||
}
|
|
||||||
chars[nchars++] = ':';
|
|
||||||
#else
|
|
||||||
if (needOldStyleGetterSetter) {
|
if (needOldStyleGetterSetter) {
|
||||||
js_strncpy(&chars[nchars], idstrchars, idstrlength);
|
js_strncpy(&chars[nchars], idstrchars, idstrlength);
|
||||||
nchars += idstrlength;
|
nchars += idstrlength;
|
||||||
|
@ -1064,7 +1060,7 @@ js_obj_toSource(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
||||||
/* Extraneous space after id here will be extracted later */
|
/* Extraneous space after id here will be extracted later */
|
||||||
chars[nchars++] = gsop[j] ? ' ' : ':';
|
chars[nchars++] = gsop[j] ? ' ' : ':';
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
if (vsharplength) {
|
if (vsharplength) {
|
||||||
js_strncpy(&chars[nchars], vsharp, vsharplength);
|
js_strncpy(&chars[nchars], vsharp, vsharplength);
|
||||||
nchars += vsharplength;
|
nchars += vsharplength;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче