зеркало из https://github.com/mozilla/pjs.git
This commit is contained in:
Родитель
d9ff563fdb
Коммит
f7808560ee
|
@ -321,17 +321,13 @@ WrapFactory#wrap(Context cx, Scriptable scope, Object obj, Class)}
|
||||||
if (to == ScriptRuntime.StringClass) {
|
if (to == ScriptRuntime.StringClass) {
|
||||||
result = 1;
|
result = 1;
|
||||||
}
|
}
|
||||||
else if (to == ScriptRuntime.ObjectClass ||
|
else if (to.isInstance(fromObj)) {
|
||||||
to == ScriptRuntime.SerializableClass ||
|
|
||||||
to == ScriptRuntime.ComparableClass)
|
|
||||||
{
|
|
||||||
result = 2;
|
result = 2;
|
||||||
}
|
}
|
||||||
else if (to.isPrimitive() && to != Boolean.TYPE) {
|
else if (to.isPrimitive()) {
|
||||||
if (to == Character.TYPE) {
|
if (to == Character.TYPE) {
|
||||||
result = 3;
|
result = 3;
|
||||||
}
|
} else if (to != Boolean.TYPE) {
|
||||||
else {
|
|
||||||
result = 4;
|
result = 4;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -549,14 +545,12 @@ WrapFactory#wrap(Context cx, Scriptable scope, Object obj, Class)}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case JSTYPE_STRING:
|
case JSTYPE_STRING:
|
||||||
if (type == ScriptRuntime.StringClass ||
|
if (type == ScriptRuntime.StringClass || type.isInstance(value)) {
|
||||||
type == ScriptRuntime.ObjectClass ||
|
|
||||||
type == ScriptRuntime.SerializableClass ||
|
|
||||||
type == ScriptRuntime.ComparableClass) {
|
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
else if (type == Character.TYPE ||
|
else if (type == Character.TYPE
|
||||||
type == ScriptRuntime.CharacterClass) {
|
|| type == ScriptRuntime.CharacterClass)
|
||||||
|
{
|
||||||
// Special case for converting a single char string to a
|
// Special case for converting a single char string to a
|
||||||
// character
|
// character
|
||||||
// Placed here because it applies *only* to JS strings,
|
// Placed here because it applies *only* to JS strings,
|
||||||
|
@ -568,8 +562,9 @@ WrapFactory#wrap(Context cx, Scriptable scope, Object obj, Class)}
|
||||||
return coerceToNumber(type, value, useErrorHandler);
|
return coerceToNumber(type, value, useErrorHandler);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ((type.isPrimitive() && type != Boolean.TYPE) ||
|
else if ((type.isPrimitive() && type != Boolean.TYPE)
|
||||||
ScriptRuntime.NumberClass.isAssignableFrom(type)) {
|
|| ScriptRuntime.NumberClass.isAssignableFrom(type))
|
||||||
|
{
|
||||||
return coerceToNumber(type, value, useErrorHandler);
|
return coerceToNumber(type, value, useErrorHandler);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -84,10 +84,6 @@ public class ScriptRuntime {
|
||||||
|
|
||||||
DateClass = classOrNull("java.util.Date");
|
DateClass = classOrNull("java.util.Date");
|
||||||
|
|
||||||
// It will be null under JDK 1.1 as Comparable is only since JDK 1.2
|
|
||||||
public final static Class
|
|
||||||
ComparableClass = classOrNull("java.lang.Comparable");
|
|
||||||
|
|
||||||
public final static Class
|
public final static Class
|
||||||
ContextClass = classOrNull("org.mozilla.javascript.Context"),
|
ContextClass = classOrNull("org.mozilla.javascript.Context"),
|
||||||
FunctionClass = classOrNull("org.mozilla.javascript.Function"),
|
FunctionClass = classOrNull("org.mozilla.javascript.Function"),
|
||||||
|
|
Загрузка…
Ссылка в новой задаче