Skip to content

Commit 665f779

Browse files
committed
avm2: Reformat remaining AS3 sources
This makes AS3 code more consistent.
1 parent 5bb7fd9 commit 665f779

File tree

24 files changed

+173
-145
lines changed

24 files changed

+173
-145
lines changed
Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
package __ruffle__ {
2-
public native function stub_method(... rest):void;
2+
// Mark the method where this function is invoked as stubbed.
3+
public native function stub_method(...rest):void;
34

4-
public native function stub_getter(... rest):void;
5+
// Mark the getter where this function is invoked as stubbed.
6+
public native function stub_getter(...rest):void;
57

6-
public native function stub_setter(... rest):void;
8+
// Mark the setter where this function is invoked as stubbed.
9+
public native function stub_setter(...rest):void;
710

8-
public native function stub_constructor(... rest):void;
11+
// Mark the constructor where this function is invoked as stubbed.
12+
public native function stub_constructor(...rest):void;
913

14+
// Note: the following function is not related to stubbing.
1015

11-
public native function log_warn(... rest):void;
16+
// Produce a regular warning in Ruffle logs.
17+
public native function log_warn(...rest):void;
1218
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package flash.concurrent {
22
[API("684")]
33
public final class Condition {
4-
public static const isSupported: Boolean = false;
4+
public static const isSupported:Boolean = false;
55

6-
public function Condition(mutex: Mutex) {}
6+
public function Condition(mutex:Mutex) {}
77
}
88
}

core/src/avm2/globals/flash/desktop/Clipboard.as

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,47 @@
11
package flash.desktop {
22
import __ruffle__.stub_getter;
33
import __ruffle__.stub_method;
4+
45
import flash.system.System;
56

67
public class Clipboard {
78
private static var _generalClipboard = new Clipboard();
89

9-
public static function get generalClipboard(): Clipboard {
10+
public static function get generalClipboard():Clipboard {
1011
return Clipboard._generalClipboard;
1112
}
1213

1314
function Clipboard() {
1415
// TODO: This should only be callable in AIR
1516
}
1617

17-
public function get formats(): Array {
18+
public function get formats():Array {
1819
stub_getter("flash.desktop.Clipboard", "formats");
1920
return new Array();
2021
}
2122

22-
public function clear(): void {
23+
public function clear():void {
2324
stub_method("flash.desktop.Clipboard", "clear");
2425
}
2526

26-
public function clearData(format: String): void {
27+
public function clearData(format:String):void {
2728
stub_method("flash.desktop.Clipboard", "clearData");
2829
}
2930

30-
public function getData(format: String, transferMode: String = ClipboardTransferMode.ORIGINAL_PREFERRED): Object {
31+
public function getData(
32+
format:String,
33+
transferMode:String = ClipboardTransferMode.ORIGINAL_PREFERRED
34+
):Object {
3135
stub_method("flash.desktop.Clipboard", "getData");
3236
return null;
3337
}
3438

35-
public function hasFormat(format: String): Boolean {
39+
public function hasFormat(format:String):Boolean {
3640
stub_method("flash.desktop.Clipboard", "hasFormat");
3741
return false;
3842
}
3943

40-
public function setData(format: String, data: Object, serializable: Boolean = true): Boolean {
44+
public function setData(format:String, data:Object, serializable:Boolean = true):Boolean {
4145
stub_method("flash.desktop.Clipboard", "setData");
4246
if (format == ClipboardFormats.TEXT_FORMAT) {
4347
System.setClipboard(data);
@@ -46,7 +50,7 @@ package flash.desktop {
4650
return false;
4751
}
4852

49-
public function setDataHandler(format: String, handler: Function, serializable: Boolean = true): Boolean {
53+
public function setDataHandler(format:String, handler:Function, serializable:Boolean = true):Boolean {
5054
stub_method("flash.desktop.Clipboard", "setDataHandler");
5155
return false;
5256
}

core/src/avm2/globals/flash/display/Stage.as

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,13 @@ package flash.display {
3636
return super.addChildAt(child, index);
3737
}
3838

39-
override public function addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void {
39+
override public function addEventListener(
40+
type:String,
41+
listener:Function,
42+
useCapture:Boolean = false,
43+
priority:int = 0,
44+
useWeakReference:Boolean = false
45+
):void {
4046
super.addEventListener(type, listener, useCapture, priority, useWeakReference);
4147
}
4248

@@ -180,7 +186,7 @@ package flash.display {
180186
throw new IllegalOperationError("Error #2071: The Stage class does not implement this property or method.", 2071);
181187
}
182188

183-
override public function set transform(value: Transform):void {
189+
override public function set transform(value:Transform):void {
184190
throw new IllegalOperationError("Error #2071: The Stage class does not implement this property or method.", 2071);
185191
}
186192

@@ -279,7 +285,7 @@ package flash.display {
279285
}
280286

281287
[API("670")]
282-
public function get softKeyboardRect() : Rectangle {
288+
public function get softKeyboardRect():Rectangle {
283289
stub_getter("flash.display.Stage", "softKeyboardRect");
284290
// This is technically a valid implementation most of the time,
285291
// as 0x0 Rect is the expected value with no soft keyboard.

core/src/avm2/globals/flash/display/Stage3D.as

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,15 @@ package flash.display {
4141
}
4242

4343
private function checkProfile(profile:String):Boolean {
44-
if ([Context3DProfile.BASELINE, Context3DProfile.BASELINE_CONSTRAINED, Context3DProfile.BASELINE_EXTENDED, Context3DProfile.STANDARD, Context3DProfile.STANDARD_CONSTRAINED, Context3DProfile.STANDARD_EXTENDED].indexOf(profile) == -1) {
44+
var acceptedValues:Array = [
45+
Context3DProfile.BASELINE,
46+
Context3DProfile.BASELINE_CONSTRAINED,
47+
Context3DProfile.BASELINE_EXTENDED,
48+
Context3DProfile.STANDARD,
49+
Context3DProfile.STANDARD_CONSTRAINED,
50+
Context3DProfile.STANDARD_EXTENDED
51+
];
52+
if (acceptedValues.indexOf(profile) == -1) {
4553
throw new ArgumentError("Error #2008: Parameter profile must be one of the accepted values.", 2008);
4654
}
4755
}

core/src/avm2/globals/flash/display3D/Context3D.as

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,13 @@ package flash.display3D {
191191
[API("686")]
192192
public native function setSamplerStateAt(sampler:int, wrap:String, filter:String, mipfilter:String):void;
193193

194-
public native function setRenderToTexture(texture:TextureBase, enableDepthAndStencil:Boolean = false, antiAlias:int = 0, surfaceSelector:int = 0, colorOutputIndex:int = 0):void;
194+
public native function setRenderToTexture(
195+
texture:TextureBase,
196+
enableDepthAndStencil:Boolean = false,
197+
antiAlias:int = 0,
198+
surfaceSelector:int = 0,
199+
colorOutputIndex:int = 0
200+
):void;
195201

196202
public function setStencilActions(
197203
triangleFace:String = "frontAndBack",

core/src/avm2/globals/flash/events/Event.as

Lines changed: 6 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -2,101 +2,57 @@ package flash.events {
22
[Ruffle(InstanceAllocator)]
33
public class Event {
44
public static const ACTIVATE:String = "activate";
5-
65
public static const ADDED:String = "added";
7-
86
public static const ADDED_TO_STAGE:String = "addedToStage";
9-
107
public static const BROWSER_ZOOM_CHANGE:String = "browserZoomChange";
11-
128
public static const CANCEL:String = "cancel";
13-
149
public static const CHANGE:String = "change";
15-
1610
public static const CLEAR:String = "clear";
17-
1811
public static const CLOSE:String = "close";
19-
2012
[API("661")]
2113
public static const CLOSING:String = "closing";
22-
2314
public static const COMPLETE:String = "complete";
24-
2515
public static const CONNECT:String = "connect";
26-
2716
public static const COPY:String = "copy";
28-
2917
public static const CUT:String = "cut";
30-
3118
public static const DEACTIVATE:String = "deactivate";
32-
3319
public static const ENTER_FRAME:String = "enterFrame";
34-
3520
public static const FRAME_CONSTRUCTED:String = "frameConstructed";
36-
3721
[API("661")]
3822
public static const EXITING:String = "exiting";
39-
4023
public static const EXIT_FRAME:String = "exitFrame";
41-
4224
public static const FRAME_LABEL:String = "frameLabel";
43-
4425
public static const ID3:String = "id3";
45-
4626
public static const INIT:String = "init";
47-
4827
public static const MOUSE_LEAVE:String = "mouseLeave";
49-
5028
public static const OPEN:String = "open";
51-
5229
public static const PASTE:String = "paste";
53-
5430
public static const REMOVED:String = "removed";
55-
5631
public static const REMOVED_FROM_STAGE:String = "removedFromStage";
57-
5832
public static const RENDER:String = "render";
59-
6033
public static const RESIZE:String = "resize";
61-
6234
public static const SCROLL:String = "scroll";
63-
6435
public static const TEXT_INTERACTION_MODE_CHANGE:String = "textInteractionModeChange";
65-
6636
public static const SELECT:String = "select";
67-
6837
public static const SELECT_ALL:String = "selectAll";
69-
7038
public static const SOUND_COMPLETE:String = "soundComplete";
71-
7239
public static const TAB_CHILDREN_CHANGE:String = "tabChildrenChange";
73-
7440
public static const TAB_ENABLED_CHANGE:String = "tabEnabledChange";
75-
7641
public static const TAB_INDEX_CHANGE:String = "tabIndexChange";
77-
7842
public static const UNLOAD:String = "unload";
79-
8043
public static const FULLSCREEN:String = "fullScreen";
81-
8244
[API("667")]
8345
public static const CONTEXT3D_CREATE:String = "context3DCreate";
84-
8546
[API("667")]
8647
public static const TEXTURE_READY:String = "textureReady";
87-
8848
[API("682")]
8949
public static const VIDEO_FRAME:String = "videoFrame";
90-
9150
[API("681")]
9251
public static const SUSPEND:String = "suspend";
93-
9452
[API("682")]
9553
public static const CHANNEL_MESSAGE:String = "channelMessage";
96-
9754
[API("682")]
9855
public static const CHANNEL_STATE:String = "channelState";
99-
10056
[API("682")]
10157
public static const WORKER_STATE:String = "workerState";
10258

@@ -117,15 +73,15 @@ package flash.events {
11773
return new Event(this.type, this.bubbles, this.cancelable);
11874
}
11975

120-
public function toString(): String {
121-
return this.formatToString("Event","type","bubbles","cancelable","eventPhase");
76+
public function toString():String {
77+
return this.formatToString("Event", "type", "bubbles", "cancelable", "eventPhase");
12278
}
12379

124-
public function formatToString(className:String, ... arguments):String {
80+
public function formatToString(className:String, ...arguments):String {
12581
var fmt = "[" + className;
126-
for each (var key: String in arguments) {
82+
for each (var key:String in arguments) {
12783
var val = this[key];
128-
if(val is String) {
84+
if (val is String) {
12985
fmt += " " + key + "=\"" + val + "\"";
13086
} else {
13187
fmt += " " + key + "=" + val;
@@ -134,7 +90,7 @@ package flash.events {
13490
return fmt += "]";
13591
}
13692

137-
public native function isDefaultPrevented(): Boolean;
93+
public native function isDefaultPrevented():Boolean;
13894
public native function preventDefault():void;
13995
public native function stopPropagation():void;
14096
public native function stopImmediatePropagation():void;
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package flash.events {
22
public class UncaughtErrorEvents extends EventDispatcher {
3-
public function UncaughtErrorEvents() {
4-
}
3+
public function UncaughtErrorEvents() {}
54
}
65
}

core/src/avm2/globals/flash/external/ExternalInterface.as

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ package flash.external {
55

66
public static native function addCallback(functionName:String, closure:Function):void;
77

8-
public static native function call(functionName: String, ...arguments):*;
8+
public static native function call(functionName:String, ...arguments):*;
99

1010
public static native function get objectID():String;
1111
}

core/src/avm2/globals/flash/filters/ConvolutionFilter.as

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ package flash.filters {
4949
this.preserveAlpha = preserveAlpha;
5050
}
5151

52-
override public function clone(): BitmapFilter {
52+
override public function clone():BitmapFilter {
5353
return new ConvolutionFilter(
5454
this.matrixX,
5555
this.matrixY,

0 commit comments

Comments
 (0)