Cosmetics: use consistent naming and layout for internal methods providing JS library implementation

This commit is contained in:
igor%mir2.org 2002-11-12 09:29:57 +00:00
Родитель 710f9f5c64
Коммит ef5115e651
5 изменённых файлов: 70 добавлений и 88 удалений

Просмотреть файл

@ -170,7 +170,7 @@ public class BaseFunction extends IdScriptable implements Function {
return jsConstructor(cx, scope, args);
case Id_toString:
return jsFunction_toString(cx, thisObj, args);
return js_toString(cx, thisObj, args);
case Id_apply:
return applyOrCall(true, cx, scope, thisObj, args);
@ -376,8 +376,8 @@ public class BaseFunction extends IdScriptable implements Function {
return fn;
}
private static Object jsFunction_toString(Context cx, Scriptable thisObj,
Object[] args)
private static Object js_toString(Context cx, Scriptable thisObj,
Object[] args)
{
int indent = ScriptRuntime.toInt32(args, 0);
Object val = thisObj.getDefaultValue(ScriptRuntime.FunctionClass);

Просмотреть файл

@ -82,13 +82,17 @@ final class NativeBoolean extends IdScriptable {
{
if (prototypeFlag) {
if (methodId == Id_constructor) {
return jsConstructor(args, thisObj == null);
}
else if (methodId == Id_toString) {
return realThis(thisObj, f).jsFunction_toString();
}
else if (methodId == Id_valueOf) {
return wrap_boolean(realThis(thisObj, f).jsFunction_valueOf());
boolean b = ScriptRuntime.toBoolean(args, 0);
if (thisObj == null) {
// new Boolean(val) creates a new boolean object.
return new NativeBoolean(b);
}
// Boolean(val) converts val to a boolean.
return wrap_boolean(b);
} else if (methodId == Id_toString) {
return realThis(thisObj, f).booleanValue ? "true" : "false";
} else if (methodId == Id_valueOf) {
return wrap_boolean(realThis(thisObj, f).booleanValue);
}
}
@ -102,26 +106,6 @@ final class NativeBoolean extends IdScriptable {
return (NativeBoolean)thisObj;
}
private Object jsConstructor(Object[] args, boolean inNewExpr) {
boolean b = ScriptRuntime.toBoolean(args, 0);
if (inNewExpr) {
// new Boolean(val) creates a new boolean object.
return new NativeBoolean(b);
}
// Boolean(val) converts val to a boolean.
return wrap_boolean(b);
}
private String jsFunction_toString() {
return booleanValue ? "true" : "false";
}
private boolean jsFunction_valueOf() {
return booleanValue;
}
protected String getIdName(int id) {
if (prototypeFlag) {
if (id == Id_constructor) return "constructor";

Просмотреть файл

@ -175,23 +175,23 @@ final class NativeDate extends IdScriptable {
case Id_toLocaleString: {
double t = realThis(thisObj, f, true).date;
return jsFunction_toLocaleString(t);
return js_toLocaleString(t);
}
case Id_toLocaleTimeString: {
double t = realThis(thisObj, f, true).date;
return jsFunction_toLocaleTimeString(t);
return js_toLocaleTimeString(t);
}
case Id_toLocaleDateString: {
double t = realThis(thisObj, f, true).date;
return jsFunction_toLocaleDateString(t);
return js_toLocaleDateString(t);
}
case Id_toUTCString: {
double t = realThis(thisObj, f, true).date;
if (t == t) { return jsFunction_toUTCString(t); }
return jsFunction_NaN_date_str;
if (t == t) { return js_toUTCString(t); }
return js_NaN_date_str;
}
case Id_valueOf:
@ -202,7 +202,7 @@ final class NativeDate extends IdScriptable {
case Id_getYear: {
double t = realThis(thisObj, f, true).date;
if (t == t) { t = jsFunction_getYear(cx, t); }
if (t == t) { t = js_getYear(cx, t); }
return wrap_double(t);
}
@ -304,13 +304,13 @@ final class NativeDate extends IdScriptable {
case Id_getTimezoneOffset: {
double t = realThis(thisObj, f, true).date;
if (t == t) { t = jsFunction_getTimezoneOffset(t); }
if (t == t) { t = js_getTimezoneOffset(t); }
return wrap_double(t);
}
case Id_setTime:
return wrap_double(realThis(thisObj, f, true).
jsFunction_setTime(ScriptRuntime.toNumber(args, 0)));
js_setTime(ScriptRuntime.toNumber(args, 0)));
case Id_setMilliseconds:
return wrap_double(realThis(thisObj, f, false).
@ -370,7 +370,7 @@ final class NativeDate extends IdScriptable {
case Id_setYear:
return wrap_double(realThis(thisObj, f, false).
jsFunction_setYear(ScriptRuntime.toNumber(args, 0)));
js_setYear(ScriptRuntime.toNumber(args, 0)));
}
}
@ -906,7 +906,9 @@ final class NativeDate extends IdScriptable {
return ScriptRuntime.NaN;
tzoffset = n;
} else if (n >= 70 ||
(prevc == '/' && mon >= 0 && mday >= 0 && year < 0)) {
(prevc == '/' && mon >= 0 && mday >= 0
&& year < 0))
{
if (year >= 0)
return ScriptRuntime.NaN;
else if (c <= ' ' || c == ',' || c == '/' || i >= limit)
@ -1021,7 +1023,7 @@ final class NativeDate extends IdScriptable {
private static String date_format(double t, int format) {
if (t != t)
return jsFunction_NaN_date_str;
return js_NaN_date_str;
StringBuffer result = new StringBuffer(60);
double local = LocalTime(t);
@ -1171,7 +1173,7 @@ final class NativeDate extends IdScriptable {
}
/* constants for toString, toUTCString */
private static String jsFunction_NaN_date_str = "Invalid Date";
private static String js_NaN_date_str = "Invalid Date";
private static String[] days = {
"Sun","Mon","Tue","Wed","Thu","Fri","Sat"
@ -1186,35 +1188,36 @@ final class NativeDate extends IdScriptable {
java.text.DateFormat formatter)
{
if (t != t)
return jsFunction_NaN_date_str;
return js_NaN_date_str;
java.util.Date tempdate = new Date((long) t);
return formatter.format(tempdate);
}
private static String jsFunction_toLocaleString(double date) {
if (localeDateTimeFormatter == null)
private static String js_toLocaleString(double date) {
if (localeDateTimeFormatter == null) {
localeDateTimeFormatter =
DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG);
DateFormat.getDateTimeInstance(DateFormat.LONG,
DateFormat.LONG);
}
return toLocale_helper(date, localeDateTimeFormatter);
}
private static String jsFunction_toLocaleTimeString(double date) {
private static String js_toLocaleTimeString(double date) {
if (localeTimeFormatter == null)
localeTimeFormatter = DateFormat.getTimeInstance(DateFormat.LONG);
return toLocale_helper(date, localeTimeFormatter);
}
private static String jsFunction_toLocaleDateString(double date) {
private static String js_toLocaleDateString(double date) {
if (localeDateFormatter == null)
localeDateFormatter = DateFormat.getDateInstance(DateFormat.LONG);
return toLocale_helper(date, localeDateFormatter);
}
private static String jsFunction_toUTCString(double date) {
private static String js_toUTCString(double date) {
StringBuffer result = new StringBuffer(60);
String dateStr = Integer.toString(DateFromTime(date));
@ -1260,7 +1263,7 @@ final class NativeDate extends IdScriptable {
return result.toString();
}
private static double jsFunction_getYear(Context cx, double date) {
private static double js_getYear(Context cx, double date) {
int result = YearFromTime(LocalTime(date));
@ -1275,11 +1278,11 @@ final class NativeDate extends IdScriptable {
return result;
}
private static double jsFunction_getTimezoneOffset(double date) {
private static double js_getTimezoneOffset(double date) {
return (date - LocalTime(date)) / msPerMinute;
}
private double jsFunction_setTime(double time) {
private double js_setTime(double time) {
this.date = TimeClip(time);
return this.date;
}
@ -1360,11 +1363,11 @@ final class NativeDate extends IdScriptable {
return date;
}
private double jsFunction_setHours(Object[] args) {
private double js_setHours(Object[] args) {
return makeTime(args, 4, true);
}
private double jsFunction_setUTCHours(Object[] args) {
private double js_setUTCHours(Object[] args) {
return makeTime(args, 4, false);
}
@ -1437,7 +1440,7 @@ final class NativeDate extends IdScriptable {
return date;
}
private double jsFunction_setYear(double year) {
private double js_setYear(double year) {
double day, result;
if (year != year || Double.isInfinite(year)) {
this.date = ScriptRuntime.NaN;

Просмотреть файл

@ -112,23 +112,24 @@ final class NativeNumber extends IdScriptable {
case Id_constructor:
return jsConstructor(args, thisObj == null);
case Id_toString: return realThis(thisObj, f).
jsFunction_toString(toBase(args, 0));
case Id_toString:
return realThis(thisObj, f).js_toString(toBase(args, 0));
case Id_valueOf: return wrap_double(realThis(thisObj, f).
jsFunction_valueOf());
case Id_valueOf:
return wrap_double(realThis(thisObj, f).doubleValue);
case Id_toLocaleString: return realThis(thisObj, f).
jsFunction_toLocaleString(toBase(args, 0));
case Id_toLocaleString:
return realThis(thisObj, f).
js_toLocaleString(toBase(args, 0));
case Id_toFixed: return realThis(thisObj, f).
jsFunction_toFixed(cx, args);
case Id_toFixed:
return realThis(thisObj, f).js_toFixed(cx, args);
case Id_toExponential: return realThis(thisObj, f).
jsFunction_toExponential(cx, args);
case Id_toExponential:
return realThis(thisObj, f).js_toExponential(cx, args);
case Id_toPrecision:return realThis(thisObj, f).
jsFunction_toPrecision(cx, args);
case Id_toPrecision:
return realThis(thisObj, f).js_toPrecision(cx, args);
}
}
return super.execMethod(methodId, f, cx, scope, thisObj, args);
@ -158,29 +159,25 @@ final class NativeNumber extends IdScriptable {
}
public String toString() {
return jsFunction_toString(10);
return js_toString(10);
}
private String jsFunction_toString(int base) {
private String js_toString(int base) {
return ScriptRuntime.numberToString(doubleValue, base);
}
private double jsFunction_valueOf() {
return doubleValue;
private String js_toLocaleString(int base) {
return js_toString(base);
}
private String jsFunction_toLocaleString(int base) {
return jsFunction_toString(base);
}
private String jsFunction_toFixed(Context cx, Object[] args) {
private String js_toFixed(Context cx, Object[] args) {
/* We allow a larger range of precision than
ECMA requires; this is permitted by ECMA. */
return num_to(cx, args, DToA.DTOSTR_FIXED, DToA.DTOSTR_FIXED,
-20, MAX_PRECISION, 0);
}
private String jsFunction_toExponential(Context cx, Object[] args) {
private String js_toExponential(Context cx, Object[] args) {
/* We allow a larger range of precision than
ECMA requires; this is permitted by ECMA. */
return num_to(cx, args,
@ -189,7 +186,7 @@ final class NativeNumber extends IdScriptable {
0, MAX_PRECISION, 1);
}
private String jsFunction_toPrecision(Context cx, Object[] args) {
private String js_toPrecision(Context cx, Object[] args) {
/* We allow a larger range of precision than
ECMA requires; this is permitted by ECMA. */
return num_to(cx, args, DToA.DTOSTR_STANDARD, DToA.DTOSTR_PRECISION,

Просмотреть файл

@ -112,15 +112,14 @@ public class NativeScript extends NativeFunction implements Script {
return jsConstructor(cx, scope, args);
case Id_toString:
return realThis(thisObj, f, true).
jsFunction_toString(cx, args);
return realThis(thisObj, f, true).js_toString(cx, args);
case Id_exec:
return realThis(thisObj, f, true).jsFunction_exec();
return realThis(thisObj, f, true).js_exec();
case Id_compile:
return realThis(thisObj, f, false).
jsFunction_compile(cx, ScriptRuntime.toString(args, 0));
js_compile(cx, ScriptRuntime.toString(args, 0));
}
}
@ -143,7 +142,7 @@ public class NativeScript extends NativeFunction implements Script {
private static Object jsConstructor(Context cx, Scriptable scope,
Object[] args)
{
String source = args.length == 0
String source = (args.length == 0)
? ""
: ScriptRuntime.toString(args[0]);
return compile(cx, scope, source);
@ -166,18 +165,17 @@ public class NativeScript extends NativeFunction implements Script {
}
}
private Scriptable jsFunction_compile(Context cx, String source) {
private Scriptable js_compile(Context cx, String source) {
script = compile(cx, null, source);
return this;
}
private Object jsFunction_exec() throws JavaScriptException {
private Object js_exec() throws JavaScriptException {
throw Context.reportRuntimeError1
("msg.cant.call.indirect", "exec");
}
private Object jsFunction_toString(Context cx, Object[] args)
{
private Object js_toString(Context cx, Object[] args) {
Script thisScript = script;
if (thisScript == null) { thisScript = this; }
Scriptable scope = getTopLevelScope(this);