Fix 56883.

git-svn-id: svn://10.0.0.236/trunk@81602 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
nboyd%atg.com 2000-10-23 14:31:05 +00:00
parent e92e7d150f
commit 151d31ddc9
2 changed files with 46 additions and 4 deletions

View File

@ -342,13 +342,25 @@ public class NativeArray extends ScriptableObject {
public static String jsFunction_toString(Context cx, Scriptable thisObj,
Object[] args, Function funObj)
throws JavaScriptException
{
return toStringHelper(cx, thisObj,
cx.getLanguageVersion() == cx.VERSION_1_2);
cx.getLanguageVersion() == cx.VERSION_1_2,
false);
}
public static String jsFunction_toLocaleString(Context cx,
Scriptable thisObj,
Object[] args,
Function funObj)
throws JavaScriptException
{
return toStringHelper(cx, thisObj, false, true);
}
private static String toStringHelper(Context cx, Scriptable thisObj,
boolean toSource)
boolean toSource, boolean toLocale)
throws JavaScriptException
{
/* It's probably redundant to handle long lengths in this
* function; StringBuffers are limited to 2^31 in java.
@ -403,6 +415,15 @@ public class NativeArray extends ScriptableObject {
try {
// stop recursion.
cx.iterating.put(thisObj, Boolean.TRUE);
if (toLocale && elem != Undefined.instance &&
elem != null)
{
Scriptable obj = cx.toObject(elem, thisObj);
Object tls = ScriptRuntime.getProp(obj,
"toLocaleString", thisObj);
elem = ScriptRuntime.call(cx, tls, elem,
ScriptRuntime.emptyArgs);
}
result.append(ScriptRuntime.toString(elem));
} finally {
cx.iterating.remove(thisObj);

View File

@ -342,13 +342,25 @@ public class NativeArray extends ScriptableObject {
public static String jsFunction_toString(Context cx, Scriptable thisObj,
Object[] args, Function funObj)
throws JavaScriptException
{
return toStringHelper(cx, thisObj,
cx.getLanguageVersion() == cx.VERSION_1_2);
cx.getLanguageVersion() == cx.VERSION_1_2,
false);
}
public static String jsFunction_toLocaleString(Context cx,
Scriptable thisObj,
Object[] args,
Function funObj)
throws JavaScriptException
{
return toStringHelper(cx, thisObj, false, true);
}
private static String toStringHelper(Context cx, Scriptable thisObj,
boolean toSource)
boolean toSource, boolean toLocale)
throws JavaScriptException
{
/* It's probably redundant to handle long lengths in this
* function; StringBuffers are limited to 2^31 in java.
@ -403,6 +415,15 @@ public class NativeArray extends ScriptableObject {
try {
// stop recursion.
cx.iterating.put(thisObj, Boolean.TRUE);
if (toLocale && elem != Undefined.instance &&
elem != null)
{
Scriptable obj = cx.toObject(elem, thisObj);
Object tls = ScriptRuntime.getProp(obj,
"toLocaleString", thisObj);
elem = ScriptRuntime.call(cx, tls, elem,
ScriptRuntime.emptyArgs);
}
result.append(ScriptRuntime.toString(elem));
} finally {
cx.iterating.remove(thisObj);