Skip to content

chore: Reformat AS3 code using asformat #18439

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 3 additions & 3 deletions core/src/avm2/globals/ArgumentError.as
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package {
public dynamic class ArgumentError extends Error {
ArgumentError.prototype.name = "ArgumentError"
ArgumentError.prototype.name = "ArgumentError";

public function ArgumentError(message:String = "", code:* = 0) {
super(message, code)
this.name = prototype.name
super(message, code);
this.name = prototype.name;
}

public static const length:int = 1;
Expand Down
28 changes: 14 additions & 14 deletions core/src/avm2/globals/Array.as
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ package {
// Array-like object (for example, `Array.prototype.sort.call(myVector)` works),
// but currently we only support calling them on real Arrays
{
prototype.concat = function(... rest):Array {
prototype.concat = function(...rest):Array {
var a:Array = this;
return a.AS3::concat.apply(a, rest);
};
Expand Down Expand Up @@ -61,7 +61,7 @@ package {
return a.AS3::pop();
};

prototype.push = function(... args):uint {
prototype.push = function(...args):uint {
var a:Array = this;
return a.AS3::push.apply(a, args);
};
Expand All @@ -86,17 +86,17 @@ package {
return a.AS3::some(callback, receiver);
};

prototype.sort = function(... rest):* {
prototype.sort = function(...rest):* {
var a:Array = this;
return a.AS3::sort.apply(a, rest);
};

prototype.sortOn = function(fieldNames:*, options:* = 0, ... rest):* {
prototype.sortOn = function(fieldNames:*, options:* = 0, ...rest):* {
var a:Array = this;
return a.AS3::sortOn(fieldNames, options);
};

prototype.splice = function(... rest):* {
prototype.splice = function(...rest):* {
var a:Array = this;
return a.AS3::splice.apply(a, rest);
};
Expand All @@ -106,7 +106,7 @@ package {
var result:String = "";
var arrayLength:uint = a.length;

for(var i:uint = 0; i < arrayLength; i ++) {
for (var i:uint = 0; i < arrayLength; i++) {
if (a[i] === void 0 || a[i] === null) {
result += a[i];
} else {
Expand All @@ -126,7 +126,7 @@ package {
return a.AS3::join(",");
};

prototype.unshift = function(... rest):uint {
prototype.unshift = function(...rest):uint {
var a:Array = this;
return a.AS3::unshift.apply(a, rest);
};
Expand Down Expand Up @@ -154,10 +154,10 @@ package {
}

// Constructor (defined in Rust)
public native function Array(... rest);
public native function Array(...rest);

// Instance methods
AS3 native function concat(... rest):Array;
AS3 native function concat(...rest):Array;

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

Expand All @@ -182,7 +182,7 @@ package {

AS3 native function pop():*;

AS3 native function push(... rest):uint;
AS3 native function push(...rest):uint;

[API("708")]
AS3 native function removeAt(index:int):*;
Expand All @@ -195,13 +195,13 @@ package {

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

AS3 native function sort(... rest):*;
AS3 native function sort(...rest):*;

AS3 native function sortOn(fieldNames:*, options:* = 0, ... rest):*;
AS3 native function sortOn(fieldNames:*, options:* = 0, ...rest):*;

AS3 native function splice(... rest):*;
AS3 native function splice(...rest):*;

AS3 native function unshift(... rest):uint;
AS3 native function unshift(...rest):uint;

public static const length:int = 1;
}
Expand Down
128 changes: 83 additions & 45 deletions core/src/avm2/globals/Date.as
Original file line number Diff line number Diff line change
Expand Up @@ -7,171 +7,211 @@ package {
prototype.valueOf = function():* {
var d:Date = this;
return d.AS3::valueOf();
}
};
prototype.toString = function():String {
var d:Date = this;
return d.AS3::toString();
}
};

prototype.toDateString = function():String {
var d:Date = this;
return d.AS3::toDateString();
}
};

prototype.toTimeString = function():String {
var d:Date = this;
return d.AS3::toTimeString();
}
};

prototype.toLocaleString = function():String {
var d:Date = this;
return d.AS3::toLocaleString();
}
};

prototype.toLocaleDateString = function():String {
var d:Date = this;
return d.AS3::toLocaleDateString();
}
};

prototype.toLocaleTimeString = function():String {
var d:Date = this;
return d.AS3::toLocaleTimeString();
}
};

prototype.toUTCString = function():String {
var d:Date = this;
return d.AS3::toUTCString();
}
};

prototype.toJSON = function(k:String):* {
var d:Date = this;
return d.AS3::toString();
}
};

prototype.getUTCFullYear = function():Number {
var d:Date = this;
return d.AS3::getUTCFullYear();
}
};

prototype.getUTCMonth = function():Number {
var d:Date = this;
return d.AS3::getUTCMonth();
}
};

prototype.getUTCDate = function():Number {
var d:Date = this;
return d.AS3::getUTCDate();
}
};

prototype.getUTCDay = function():Number {
var d:Date = this;
return d.AS3::getUTCDay();
}
};

prototype.getUTCHours = function():Number {
var d:Date = this;
return d.AS3::getUTCHours();
}
};

prototype.getUTCMinutes = function():Number {
var d:Date = this;
return d.AS3::getUTCMinutes();
}
};

prototype.getUTCSeconds = function():Number {
var d:Date = this;
return d.AS3::getUTCSeconds();
}
};

prototype.getUTCMilliseconds = function():Number {
var d:Date = this;
return d.AS3::getUTCMilliseconds();
}
};

prototype.getFullYear = function():Number {
var d:Date = this;
return d.AS3::getFullYear();
}
};

prototype.getMonth = function():Number {
var d:Date = this;
return d.AS3::getMonth();
}
};

prototype.getDate = function():Number {
var d:Date = this;
return d.AS3::getDate();
}
};

prototype.getDay = function():Number {
var d:Date = this;
return d.AS3::getDay();
}
};

prototype.getHours = function():Number {
var d:Date = this;
return d.AS3::getHours();
}
};

prototype.getMinutes = function():Number {
var d:Date = this;
return d.AS3::getMinutes();
}
};

prototype.getSeconds = function():Number {
var d:Date = this;
return d.AS3::getSeconds();
}
};

prototype.getMilliseconds = function():Number {
var d:Date = this;
return d.AS3::getMilliseconds();
}
};

prototype.getTimezoneOffset = function():Number {
var d:Date = this;
return d.AS3::getTimezoneOffset();
}
};

prototype.getTime = function():Number {
var d:Date = this;
return d.AS3::getTime();
}
};

prototype.setTime = function(t:* = undefined):Number {
var d:Date = this;
return d.AS3::setTime(t);
}
};

prototype.setFullYear = function(year:* = undefined, month:* = undefined, day:* = undefined):Number {
var d:Date = this;
return d._setFullYear(arguments);
}
};

prototype.setMonth = function(month:* = undefined, day:* = undefined):Number {
var d:Date = this;
return d._setMonth(arguments);
}
};

prototype.setDate = function(day:* = undefined):Number {
var d:Date = this;
return d._setDate(day);
}
};

prototype.setHours = function(hour:* = undefined, min:* = undefined, sec:* = undefined, ms:* = undefined):Number {
var d:Date = this;
return d._setHours(arguments);
}
};

prototype.setMinutes = function(min:* = undefined, sec:* = undefined, ms:* = undefined):Number {
var d:Date = this;
return d._setMinutes(arguments);
}
};

prototype.setSeconds = function(sec:* = undefined, ms:* = undefined):Number {
var d:Date = this;
return d._setSeconds(arguments);
}
};

prototype.setMilliseconds = function(ms:* = undefined):Number {
var d:Date = this;
return d._setMilliseconds(arguments);
}
};

prototype.setUTCFullYear = function(year:* = undefined, month:* = undefined, day:* = undefined):Number {
var d:Date = this;
return d._setUTCFullYear(arguments);
}
};

prototype.setUTCMonth = function(month:* = undefined, day:* = undefined):Number {
var d:Date = this;
return d._setUTCMonth(arguments);
}
};

prototype.setUTCDate = function(day:* = undefined):Number {
var d:Date = this;
return d._setUTCDate(arguments);
}
};

prototype.setUTCHours = function(hour:* = undefined, min:* = undefined, sec:* = undefined, ms:* = undefined):Number {
var d:Date = this;
return d._setUTCHours(arguments);
}
};

prototype.setUTCMinutes = function(min:* = undefined, sec:* = undefined, ms:* = undefined):Number {
var d:Date = this;
return d._setUTCMinutes(arguments);
}
};

prototype.setUTCSeconds = function(sec:* = undefined, ms:* = undefined):Number {
var d:Date = this;
return d._setUTCSeconds(arguments);
}
};

prototype.setUTCMilliseconds = function(ms:* = undefined):Number {
var d:Date = this;
return d._setUTCMilliseconds(arguments);
}
};

prototype.setPropertyIsEnumerable("valueOf", false);
prototype.setPropertyIsEnumerable("toString", false);
Expand Down Expand Up @@ -216,15 +256,14 @@ package {
prototype.setPropertyIsEnumerable("setUTCSeconds", false);
prototype.setPropertyIsEnumerable("setUTCMilliseconds", false);


public function Date(year:* = undefined, month:* = undefined, day:* = undefined, hours:* = undefined, minutes:* = undefined, seconds:* = undefined, ms:* = undefined) {
this.init(arguments);
}
private native function init(args:Array);

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

public static native function UTC(year:*, month:*, date:* = 1, hour:* = 0, minute:* = 0, second:* = 0, millisecond:* = 0, ... rest):Number;
public static native function UTC(year:*, month:*, date:* = 1, hour:* = 0, minute:* = 0, second:* = 0, millisecond:* = 0, ...rest):Number;

AS3 function valueOf():Number {
return this.AS3::getTime();
Expand Down Expand Up @@ -339,7 +378,6 @@ package {
return _setUTCMilliseconds(arguments);
}


public function get fullYear():Number {
return this.AS3::getFullYear();
}
Expand Down
Loading
Loading