Sort and format.
git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@92 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/dev/core/super/com/google/gwt/dev/jjs/intrinsic/com/google/gwt/lang/Array.java b/dev/core/super/com/google/gwt/dev/jjs/intrinsic/com/google/gwt/lang/Array.java
index 478272a..85c9052 100644
--- a/dev/core/super/com/google/gwt/dev/jjs/intrinsic/com/google/gwt/lang/Array.java
+++ b/dev/core/super/com/google/gwt/dev/jjs/intrinsic/com/google/gwt/lang/Array.java
@@ -1,112 +1,138 @@
-// Copyright 2006 Google Inc. All Rights Reserved.
+/*
+ * Copyright 2006 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
package com.google.gwt.lang;
+// CHECKSTYLE_NAMING_OFF: Follows legacy naming pattern. Fix me.
+
/**
* This is a magic class the compiler uses as a base class for injected array
* classes.
*/
public final class Array {
- public final int length;
- protected final int queryId;
-
- public Array(int length, int typeId, int queryId, String typeName) {
- this.length = length;
- this.typeName = typeName;
- this.typeId = typeId;
- this.queryId = queryId;
- }
-
/**
* Creates an array like "new T[a][b][c][][]" by passing in javascript objects
- * as follows: [a, b, c]
+ * as follows: [a, b, c].
*/
public static Array initDims(String typeName, Object typeIdExprs,
Object queryIdExprs, Object dimExprs, Object defaultValue) {
// ASSERT: dimExprs.length > 0 or else code gen is broken
//
return initDims(typeName, typeIdExprs, queryIdExprs, dimExprs, 0,
- getValueCount(dimExprs), defaultValue);
- }
-
- /**
- * Creates an array like "new T[a][b][c][][]" by passing in javascript objects
- * as follows: [a,b,c]
- */
- private static Array initDims(String typeName, Object typeIdExprs,
- Object queryIdExprs, Object dimExprs, int index, int count,
- Object defaultValue) {
- int length;
- if ((length = getIntValue(dimExprs, index)) < 0)
- throw new NegativeArraySizeException();
-
- Array result = new Array(length, getIntValue(typeIdExprs, index),
- getIntValue(queryIdExprs, index), typeName);
-
- ++index;
- if (index < count) {
- typeName = typeName.substring(1);
- for (int i = 0; i < length; ++i)
- _set(result, i, initDims(typeName, typeIdExprs, queryIdExprs, dimExprs,
- index, count, defaultValue));
- } else {
- for (int i = 0; i < length; ++i)
- _set(result, i, defaultValue);
- }
-
- return result;
+ getValueCount(dimExprs), defaultValue);
}
/**
* Creates an array like "new T[][]{a,b,c,d}" by passing in javascript objects
- * as follows: [a,b,c,d]
+ * as follows: [a,b,c,d].
*/
public static final Array initValues(String typeName, int typeId,
int queryId, Object values) {
int length = getValueCount(values);
Array result = new Array(length, typeId, queryId, typeName);
- for (int i = 0; i < length; ++i)
+ for (int i = 0; i < length; ++i) {
_set(result, i, getValue(values, i));
+ }
return result;
}
/**
- * Performs an array assignment, checking for valid index and type
+ * Performs an array assignment, checking for valid index and type.
*/
public static Object setCheck(Array array, int index, Object value) {
if (value != null && array.queryId != 0
- && !Cast.instanceOf(value, array.queryId))
+ && !Cast.instanceOf(value, array.queryId)) {
throw new ArrayStoreException();
+ }
return _set(array, index, value);
}
-
/**
- * Sets a value in the array
+ * Sets a value in the array.
*/
private static native Object _set(Array array, int index, Object value) /*-{
return array[index] = value;
}-*/;
/**
- * Gets the length of a JSON array
+ * Gets an the first value from a JSON int array.
+ */
+ private static native int getIntValue(Object values, int index) /*-{
+ return values[index];
+ }-*/;
+
+ /**
+ * Gets a value from a JSON array.
+ */
+ private static native Object getValue(Object values, int index) /*-{
+ return values[index];
+ }-*/;
+
+ /**
+ * Gets the length of a JSON array.
*/
private static native int getValueCount(Object values) /*-{
return values.length;
}-*/;
/**
- * Gets a value from a JSON array
+ * Creates an array like "new T[a][b][c][][]" by passing in javascript objects
+ * as follows: [a,b,c].
*/
- private native static Object getValue(Object values, int index) /*-{
- return values[index];
- }-*/;
+ private static Array initDims(String typeName, Object typeIdExprs,
+ Object queryIdExprs, Object dimExprs, int index, int count,
+ Object defaultValue) {
+ int length;
+ if ((length = getIntValue(dimExprs, index)) < 0) {
+ throw new NegativeArraySizeException();
+ }
- /**
- * Gets an the first value from a JSON int array
- */
- private native static int getIntValue(Object values, int index) /*-{
- return values[index];
- }-*/;
+ Array result = new Array(length, getIntValue(typeIdExprs, index),
+ getIntValue(queryIdExprs, index), typeName);
+ ++index;
+ if (index < count) {
+ typeName = typeName.substring(1);
+ for (int i = 0; i < length; ++i) {
+ _set(result, i, initDims(typeName, typeIdExprs, queryIdExprs, dimExprs,
+ index, count, defaultValue));
+ }
+ } else {
+ for (int i = 0; i < length; ++i) {
+ _set(result, i, defaultValue);
+ }
+ }
+
+ return result;
+ }
+
+ public final int length;
+
+ protected final int queryId;
+
+ public Array(int length, int typeId, int queryId, String typeName) {
+ this.length = length;
+ this.queryId = queryId;
+
+ /*
+ * These are inherited protected fields from GWT's Object emulation class.
+ */
+ this.typeName = typeName;
+ this.typeId = typeId;
+ }
}
+
+// CHECKSTYLE_NAMING_ON
diff --git a/dev/core/super/com/google/gwt/dev/jjs/intrinsic/com/google/gwt/lang/Cast.java b/dev/core/super/com/google/gwt/dev/jjs/intrinsic/com/google/gwt/lang/Cast.java
index 06f1384..fc9bcdb 100644
--- a/dev/core/super/com/google/gwt/dev/jjs/intrinsic/com/google/gwt/lang/Cast.java
+++ b/dev/core/super/com/google/gwt/dev/jjs/intrinsic/com/google/gwt/lang/Cast.java
@@ -1,16 +1,45 @@
-// Copyright 2006 Google Inc. All Rights Reserved.
+/*
+ * Copyright 2006 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
package com.google.gwt.lang;
import com.google.gwt.core.client.JavaScriptObject;
+// CHECKSTYLE_NAMING_OFF: Uses legacy conventions of underscore prefixes.
+
/**
* This is a magic class the compiler uses to perform any cast operations that
* require code.
*/
final class Cast {
-
+
// magic magic magic
- protected static Object typeIdArray;
+ protected static Object typeIdArray;
+
+ protected static native boolean canCast(int srcId, int dstId) /*-{
+ // either a null or 0 both will be false, short circuit
+ if (!srcId)
+ return false;
+
+ // force to boolean
+ return !!@com.google.gwt.lang.Cast::typeIdArray[srcId][dstId];
+ }-*/;
+
+ static native String charToString(char x) /*-{
+ return String.fromCharCode(x);
+ }-*/;
static native Object dynamicCast(Object src, int dstId) /*-{
if (src != null)
@@ -28,24 +57,86 @@
}-*/;
/**
+ * See JLS 5.1.3.
+ */
+ static native byte narrow_byte(Object x) /*-{
+ return x << 24 >> 24;
+ }-*/;
+
+ /**
+ * See JLS 5.1.3.
+ */
+ static native char narrow_char(Object x) /*-{
+ return x & 0xFFFF;
+ }-*/;
+
+ /**
+ * See JLS 5.1.3.
+ */
+ static native int narrow_int(Object x) /*-{
+ return ~~x;
+ }-*/;
+
+ /**
+ * See JLS 5.1.3.
+ */
+ static native short narrow_short(Object x) /*-{
+ return x << 16 >> 16;
+ }-*/;
+
+ /**
+ * See JLS 5.1.3 for why we do a two-step cast. First we rount to int, then
+ * narrow to byte.
+ */
+ static byte round_byte(Object x) {
+ return narrow_byte(floatToInt(x));
+ }
+
+ /**
+ * See JLS 5.1.3 for why we do a two-step cast. First we rount to int, then
+ * narrow to char.
+ */
+ static char round_char(Object x) {
+ return narrow_char(floatToInt(x));
+ }
+
+ /**
+ * See JLS 5.1.3.
+ */
+ static native int round_int(Object x) /*-{
+ if (x > @java.lang.Integer::MAX_VALUE) return @java.lang.Integer::MAX_VALUE;
+ if (x < @java.lang.Integer::MIN_VALUE) return @java.lang.Integer::MIN_VALUE;
+ return x >= 0 ? Math.floor(x) : Math.ceil(x);
+ }-*/;
+
+ /**
+ * See JLS 5.1.3.
+ */
+ static native long round_long(Object x) /*-{
+ if (x > @java.lang.Long::MAX_VALUE) return @java.lang.Long::MAX_VALUE;
+ if (x < @java.lang.Long::MIN_VALUE) return @java.lang.Long::MIN_VALUE;
+ return x >= 0 ? Math.floor(x) : Math.ceil(x);
+ }-*/;
+
+ /**
+ * See JLS 5.1.3 for why we do a two-step cast. First we rount to int, then
+ * narrow to short.
+ */
+ static short round_short(Object x) {
+ return narrow_short(floatToInt(x));
+ }
+
+ /**
* Check a statically false cast, which can succeed if the argument is null.
*/
static Object throwClassCastExceptionUnlessNull(Object o)
throws ClassCastException {
- if (o != null)
+ if (o != null) {
throw new ClassCastException();
+ }
return null;
}
- protected static native boolean canCast(int srcId, int dstId) /*-{
- // either a null or 0 both will be false, short circuit
- if (!srcId)
- return false;
-
- // force to boolean
- return !!@com.google.gwt.lang.Cast::typeIdArray[srcId][dstId];
- }-*/;
-
static native JavaScriptObject wrapJSO(JavaScriptObject jso, Object seed) /*-{
_ = seed.prototype;
@@ -65,82 +156,8 @@
return jso;
}-*/;
- static native String charToString(char x) /*-{
- return String.fromCharCode(x);
- }-*/;
-
/**
- * See JLS 5.1.3
- */
- static native byte narrow_byte(Object x) /*-{
- return x << 24 >> 24;
- }-*/;
-
- /**
- * See JLS 5.1.3
- */
- static native short narrow_short(Object x) /*-{
- return x << 16 >> 16;
- }-*/;
-
- /**
- * See JLS 5.1.3
- */
- static native char narrow_char(Object x) /*-{
- return x & 0xFFFF;
- }-*/;
-
- /**
- * See JLS 5.1.3
- */
- static native int narrow_int(Object x) /*-{
- return ~~x;
- }-*/;
-
- /**
- * See JLS 5.1.3 for why we do a two-step cast.
- * First we rount to int, then narrow to byte
- */
- static byte round_byte(Object x) {
- return narrow_byte(floatToInt(x));
- }
-
- /**
- * See JLS 5.1.3 for why we do a two-step cast.
- * First we rount to int, then narrow to short
- */
- static short round_short(Object x) {
- return narrow_short(floatToInt(x));
- }
-
- /**
- * See JLS 5.1.3 for why we do a two-step cast.
- * First we rount to int, then narrow to char
- */
- static char round_char(Object x) {
- return narrow_char(floatToInt(x));
- }
-
- /**
- * See JLS 5.1.3
- */
- static native int round_int(Object x) /*-{
- if (x > @java.lang.Integer::MAX_VALUE) return @java.lang.Integer::MAX_VALUE;
- if (x < @java.lang.Integer::MIN_VALUE) return @java.lang.Integer::MIN_VALUE;
- return x >= 0 ? Math.floor(x) : Math.ceil(x);
- }-*/;
-
- /**
- * See JLS 5.1.3
- */
- static native long round_long(Object x) /*-{
- if (x > @java.lang.Long::MAX_VALUE) return @java.lang.Long::MAX_VALUE;
- if (x < @java.lang.Long::MIN_VALUE) return @java.lang.Long::MIN_VALUE;
- return x >= 0 ? Math.floor(x) : Math.ceil(x);
- }-*/;
-
- /**
- * See JLS 5.1.3
+ * See JLS 5.1.3.
*/
private static native Object floatToInt(Object x) /*-{
if (x > @java.lang.Integer::MAX_VALUE) return @java.lang.Integer::MAX_VALUE;
@@ -149,3 +166,5 @@
}-*/;
}
+
+// CHECKSTYLE_NAMING_ON
diff --git a/dev/core/super/com/google/gwt/dev/jjs/intrinsic/com/google/gwt/lang/Exceptions.java b/dev/core/super/com/google/gwt/dev/jjs/intrinsic/com/google/gwt/lang/Exceptions.java
index a7d531b..ad08eaf 100644
--- a/dev/core/super/com/google/gwt/dev/jjs/intrinsic/com/google/gwt/lang/Exceptions.java
+++ b/dev/core/super/com/google/gwt/dev/jjs/intrinsic/com/google/gwt/lang/Exceptions.java
@@ -1,4 +1,18 @@
-// Copyright 2006 Google Inc. All Rights Reserved.
+/*
+ * Copyright 2006 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
package com.google.gwt.lang;
import com.google.gwt.core.client.JavaScriptException;
@@ -7,31 +21,16 @@
* This is a magic class the compiler uses to throw and check exceptions.
*/
final class Exceptions {
-
+
static Object caught(Object e) {
- if (e instanceof Throwable)
+ if (e instanceof Throwable) {
return e;
+ }
return new JavaScriptException(javaScriptExceptionName(e),
- javaScriptExceptionDescription(e));
+ javaScriptExceptionDescription(e));
}
/**
- * Returns the name of an unexpected JavaScript exception (not a normal Java
- * one).
- */
- private static native String javaScriptExceptionName(Object e) /*-{
- return e.name;
- }-*/;
-
- /**
- * Returns the description of an unexpected JavaScript exception (not a normal
- * Java one).
- */
- private static native String javaScriptExceptionDescription(Object e) /*-{
- return e.message;
- }-*/;
-
- /**
* Easily throw a ClassCastException from native or generated code.
*/
static void throwClassCastException() throws ClassCastException {
@@ -45,4 +44,20 @@
throw new NullPointerException();
}
+ /**
+ * Returns the description of an unexpected JavaScript exception (not a normal
+ * Java one).
+ */
+ private static native String javaScriptExceptionDescription(Object e) /*-{
+ return e.message;
+ }-*/;
+
+ /**
+ * Returns the name of an unexpected JavaScript exception (not a normal Java
+ * one).
+ */
+ private static native String javaScriptExceptionName(Object e) /*-{
+ return e.name;
+ }-*/;
+
}