Skip to content

Commit 5bb7fd9

Browse files
committed
avm2: Reformat top-level AS3 sources
This makes AS3 code more consistent.
1 parent 8bae58f commit 5bb7fd9

File tree

19 files changed

+134
-117
lines changed

19 files changed

+134
-117
lines changed

core/src/avm2/globals/ArgumentError.as

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package {
22
[Ruffle(ConstructOnCall)]
33
public dynamic class ArgumentError extends Error {
4-
ArgumentError.prototype.name = "ArgumentError"
4+
ArgumentError.prototype.name = "ArgumentError";
55

66
public function ArgumentError(message:String = "", code:* = 0) {
77
super(message, code)

core/src/avm2/globals/Array.as

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,16 @@ package {
33
[Ruffle(InstanceAllocator)]
44
public dynamic class Array {
55
public static const CASEINSENSITIVE:uint = 1;
6-
76
public static const DESCENDING:uint = 2;
8-
97
public static const UNIQUESORT:uint = 4;
10-
118
public static const RETURNINDEXEDARRAY:uint = 8;
12-
139
public static const NUMERIC:uint = 16;
1410

1511
// FIXME avmplus allows for calling some of these prototype functions on any
1612
// Array-like object (for example, `Array.prototype.sort.call(myVector)` works),
1713
// but currently we only support calling them on real Arrays
1814
{
19-
prototype.concat = function(... rest):Array {
15+
prototype.concat = function(...rest):Array {
2016
var a:Array = this;
2117
return a.AS3::concat.apply(a, rest);
2218
};
@@ -61,7 +57,7 @@ package {
6157
return a.AS3::pop();
6258
};
6359

64-
prototype.push = function(... args):uint {
60+
prototype.push = function(...args):uint {
6561
var a:Array = this;
6662
return a.AS3::push.apply(a, args);
6763
};
@@ -86,17 +82,17 @@ package {
8682
return a.AS3::some(callback, receiver);
8783
};
8884

89-
prototype.sort = function(... rest):* {
85+
prototype.sort = function(...rest):* {
9086
var a:Array = this;
9187
return a.AS3::sort.apply(a, rest);
9288
};
9389

94-
prototype.sortOn = function(fieldNames:*, options:* = 0, ... rest):* {
90+
prototype.sortOn = function(fieldNames:*, options:* = 0, ...rest):* {
9591
var a:Array = this;
9692
return a.AS3::sortOn(fieldNames, options);
9793
};
9894

99-
prototype.splice = function(... rest):* {
95+
prototype.splice = function(...rest):* {
10096
var a:Array = this;
10197
return a.AS3::splice.apply(a, rest);
10298
};
@@ -106,7 +102,7 @@ package {
106102
var result:String = "";
107103
var arrayLength:uint = a.length;
108104

109-
for(var i:uint = 0; i < arrayLength; i ++) {
105+
for (var i:uint = 0; i < arrayLength; i ++) {
110106
if (a[i] === void 0 || a[i] === null) {
111107
result += a[i];
112108
} else {
@@ -126,7 +122,7 @@ package {
126122
return a.AS3::join(",");
127123
};
128124

129-
prototype.unshift = function(... rest):uint {
125+
prototype.unshift = function(...rest):uint {
130126
var a:Array = this;
131127
return a.AS3::unshift.apply(a, rest);
132128
};
@@ -154,10 +150,10 @@ package {
154150
}
155151

156152
// Constructor (defined in Rust)
157-
public native function Array(... rest);
153+
public native function Array(...rest);
158154

159155
// Instance methods
160-
AS3 native function concat(... rest):Array;
156+
AS3 native function concat(...rest):Array;
161157

162158
AS3 native function every(callback:Function, receiver:* = null):Boolean;
163159

@@ -188,7 +184,7 @@ package {
188184

189185
AS3 native function pop():*;
190186

191-
AS3 native function push(... rest):uint;
187+
AS3 native function push(...rest):uint;
192188

193189
[API("708")]
194190
AS3 native function removeAt(index:int):*;
@@ -201,13 +197,13 @@ package {
201197

202198
AS3 native function some(callback:Function, receiver:* = null):Boolean;
203199

204-
AS3 native function sort(... rest):*;
200+
AS3 native function sort(...rest):*;
205201

206-
AS3 native function sortOn(fieldNames:*, options:* = 0, ... rest):*;
202+
AS3 native function sortOn(fieldNames:*, options:* = 0, ...rest):*;
207203

208-
AS3 native function splice(... rest):*;
204+
AS3 native function splice(...rest):*;
209205

210-
AS3 native function unshift(... rest):uint;
206+
AS3 native function unshift(...rest):uint;
211207

212208
public static const length:int = 1;
213209
}

core/src/avm2/globals/Date.as

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,14 +221,31 @@ package {
221221
prototype.setPropertyIsEnumerable("setUTCMilliseconds", false);
222222

223223

224-
public function Date(year:* = undefined, month:* = undefined, day:* = undefined, hours:* = undefined, minutes:* = undefined, seconds:* = undefined, ms:* = undefined) {
224+
public function Date(
225+
year:* = undefined,
226+
month:* = undefined,
227+
day:* = undefined,
228+
hours:* = undefined,
229+
minutes:* = undefined,
230+
seconds:* = undefined,
231+
ms:* = undefined
232+
) {
225233
this.init(arguments);
226234
}
227235
private native function init(args:Array);
228236

229237
public static native function parse(date:*):Number;
230238

231-
public static native function UTC(year:*, month:*, date:* = 1, hour:* = 0, minute:* = 0, second:* = 0, millisecond:* = 0, ... rest):Number;
239+
public static native function UTC(
240+
year:*,
241+
month:*,
242+
date:* = 1,
243+
hour:* = 0,
244+
minute:* = 0,
245+
second:* = 0,
246+
millisecond:* = 0,
247+
...rest
248+
):Number;
232249

233250
AS3 function valueOf():Number {
234251
return this.AS3::getTime();

core/src/avm2/globals/Function.as

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ package {
3939
// this AS-defined method does nothing
4040
}
4141

42-
public native function get length() : int;
42+
public native function get length():int;
4343

4444
[Ruffle(FastCall)]
4545
public native function get prototype():*;
@@ -51,7 +51,7 @@ package {
5151

5252
[Ruffle(NativeCallable)]
5353
private static function createDummyFunction():Function {
54-
return function() { };
54+
return function() {};
5555
}
5656

5757
public static const length:int = 1;

core/src/avm2/globals/JSON.as

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package {
22
[API("674")]
33
[Ruffle(Abstract)]
44
public final class JSON {
5-
public static native function parse(text:String, reviver:Function = null): Object;
6-
public static native function stringify(value:Object, replacer:* = null, space:* = null): String;
5+
public static native function parse(text:String, reviver:Function = null):Object;
6+
public static native function stringify(value:Object, replacer:* = null, space:* = null):String;
77
}
88
}

core/src/avm2/globals/Math.as

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,49 +2,49 @@ package {
22
[Ruffle(InstanceAllocator)]
33
[Ruffle(CallHandler)]
44
public final class Math {
5-
public static const E: Number = 2.718281828459045;
6-
public static const LN10: Number = 2.302585092994046;
7-
public static const LN2: Number = 0.6931471805599453;
8-
public static const LOG10E: Number = 0.4342944819032518;
9-
public static const LOG2E: Number = 1.442695040888963387;
10-
public static const PI: Number = 3.141592653589793;
11-
public static const SQRT1_2: Number = 0.7071067811865476;
12-
public static const SQRT2: Number = 1.4142135623730951;
5+
public static const E:Number = 2.718281828459045;
6+
public static const LN10:Number = 2.302585092994046;
7+
public static const LN2:Number = 0.6931471805599453;
8+
public static const LOG10E:Number = 0.4342944819032518;
9+
public static const LOG2E:Number = 1.442695040888963387;
10+
public static const PI:Number = 3.141592653589793;
11+
public static const SQRT1_2:Number = 0.7071067811865476;
12+
public static const SQRT2:Number = 1.4142135623730951;
1313

1414
[Ruffle(FastCall)]
15-
public static native function abs(x: Number): Number;
15+
public static native function abs(x:Number):Number;
1616
[Ruffle(FastCall)]
17-
public static native function acos(x: Number): Number;
17+
public static native function acos(x:Number):Number;
1818
[Ruffle(FastCall)]
19-
public static native function asin(x: Number): Number;
19+
public static native function asin(x:Number):Number;
2020
[Ruffle(FastCall)]
21-
public static native function atan(x: Number): Number;
21+
public static native function atan(x:Number):Number;
2222
[Ruffle(FastCall)]
23-
public static native function ceil(x: Number): Number;
23+
public static native function ceil(x:Number):Number;
2424
[Ruffle(FastCall)]
25-
public static native function cos(x: Number): Number;
25+
public static native function cos(x:Number):Number;
2626
[Ruffle(FastCall)]
27-
public static native function exp(x: Number): Number;
27+
public static native function exp(x:Number):Number;
2828
[Ruffle(FastCall)]
29-
public static native function floor(x: Number): Number;
29+
public static native function floor(x:Number):Number;
3030
[Ruffle(FastCall)]
31-
public static native function log(x: Number): Number;
31+
public static native function log(x:Number):Number;
3232
[Ruffle(FastCall)]
33-
public static native function round(x: Number): Number;
33+
public static native function round(x:Number):Number;
3434
[Ruffle(FastCall)]
35-
public static native function sin(x: Number): Number;
35+
public static native function sin(x:Number):Number;
3636
[Ruffle(FastCall)]
37-
public static native function sqrt(x: Number): Number;
37+
public static native function sqrt(x:Number):Number;
3838
[Ruffle(FastCall)]
39-
public static native function tan(x: Number): Number;
39+
public static native function tan(x:Number):Number;
4040

4141
[Ruffle(FastCall)]
42-
public static native function atan2(y: Number, x: Number): Number;
42+
public static native function atan2(y:Number, x:Number):Number;
4343
[Ruffle(FastCall)]
44-
public static native function pow(x: Number, y: Number): Number;
44+
public static native function pow(x:Number, y:Number):Number;
4545

4646
// This is a hacky way to specify `-Infinity` as a default value.
47-
private static const NegInfinity: Number = -1 / 0;
47+
private static const NegInfinity:Number = -1 / 0;
4848

4949
// NOTE: These methods are marked as FastCall despite their ability to
5050
// throw an error (when Objects are passed in the restargs). This is fine
@@ -53,11 +53,11 @@ package {
5353
// parameters; the methods cannot error if called with only two parameters.
5454

5555
[Ruffle(FastCall)]
56-
public static native function max(x: Number = NegInfinity, y: Number = NegInfinity, ...rest): Number;
56+
public static native function max(x:Number = NegInfinity, y:Number = NegInfinity, ...rest):Number;
5757
[Ruffle(FastCall)]
58-
public static native function min(x: Number = Infinity, y: Number = Infinity, ...rest): Number;
58+
public static native function min(x:Number = Infinity, y:Number = Infinity, ...rest):Number;
5959

6060
[Ruffle(FastCall)]
61-
public static native function random(): Number;
61+
public static native function random():Number;
6262
}
6363
}

core/src/avm2/globals/RangeError.as

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package {
22
[Ruffle(ConstructOnCall)]
33
public dynamic class RangeError extends Error {
4-
RangeError.prototype.name = "RangeError"
4+
RangeError.prototype.name = "RangeError";
55

66
public function RangeError(message:String = "", code:* = 0) {
77
super(message, code);

core/src/avm2/globals/RegExp.as

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ package {
3838

3939
prototype.toString = function():String {
4040
// Note: This function is not generic and will throw for non-regexps.
41-
var regexp: RegExp = this;
41+
var regexp:RegExp = this;
4242

4343
// ECMA-262 Edition 5.1 - RegExp.prototype.toString():
4444
// Return the String value formed by concatenating the Strings "/",

core/src/avm2/globals/String.as

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ package {
1313
return s.AS3::charCodeAt(index);
1414
};
1515

16-
prototype.concat = function(... args):String {
16+
prototype.concat = function(...args):String {
1717
var s:String = this;
1818
return s.AS3::concat.apply(s, args);
1919
};
@@ -60,7 +60,7 @@ package {
6060

6161
prototype.substr = function(start:Number = 0, len:Number = 2147483647.0):String {
6262
var s:String = this;
63-
return s.AS3::substr(start,len);
63+
return s.AS3::substr(start, len);
6464
};
6565

6666
prototype.substring = function(start:Number = 0, end:Number = 2147483647.0):String {
@@ -89,23 +89,23 @@ package {
8989
};
9090

9191
prototype.toString = function():String {
92-
if(this === String.prototype) {
92+
if (this === String.prototype) {
9393
return "";
9494
}
9595

96-
if(!(this is String)) {
96+
if (!(this is String)) {
9797
throw new TypeError("Error #1004: Method String.prototype.toString was invoked on an incompatible object.", 1004);
9898
}
9999

100100
return this;
101101
};
102102

103103
prototype.valueOf = function():* {
104-
if(this === String.prototype) {
104+
if (this === String.prototype) {
105105
return "";
106106
}
107107

108-
if(!(this is String)) {
108+
if (!(this is String)) {
109109
throw new TypeError("Error #1004: Method String.prototype.valueOf was invoked on an incompatible object.", 1004);
110110
}
111111

@@ -138,9 +138,9 @@ package {
138138
// this AS-defined method does nothing
139139
}
140140

141-
AS3 static native function fromCharCode(... rest):String;
141+
AS3 static native function fromCharCode(...rest):String;
142142

143-
public static native function fromCharCode(... rest):String;
143+
public static native function fromCharCode(...rest):String;
144144

145145
// Instance methods
146146
[Ruffle(FastCall)]
@@ -152,7 +152,7 @@ package {
152152
[Ruffle(FastCall)]
153153
AS3 native function charCodeAt(index:Number = 0):Number;
154154

155-
AS3 native function concat(... rest):String;
155+
AS3 native function concat(...rest):String;
156156

157157
AS3 native function indexOf(str:String = "undefined", index:Number = 0):int;
158158

core/src/avm2/globals/Toplevel.as

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package {
22
public namespace AS3 = "http://adobe.com/AS3/2006/builtin";
33

4-
public const NaN: Number = 0 / 0;
4+
public const NaN:Number = 0 / 0;
55

6-
public const Infinity: Number = 1 / 0;
6+
public const Infinity:Number = 1 / 0;
77

88
public const undefined = void 0;
99

@@ -28,7 +28,7 @@ package {
2828
[Ruffle(FastCall)]
2929
public native function parseInt(string:String = "NaN", base:int = 0):Number;
3030

31-
public native function trace(... rest):void;
31+
public native function trace(...rest):void;
3232
}
3333

3434
// These classes are required by other core code, so we put them here. Toplevel.as

0 commit comments

Comments
 (0)