Skip to content

Commit 8cd89e1

Browse files
committed
fix more implicit Dynamic variable types by explicitly declaring a type
These variables were being initialized with null, weren't initialized at all, or were initialized with an empty array, all of which introduce Dynamic
1 parent 3643bf0 commit 8cd89e1

38 files changed

+203
-143
lines changed

src/lime/_internal/backend/html5/HTML5HTTPRequest.hx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,8 @@ class HTML5HTTPRequest
308308
if (parent.enableResponseHeaders)
309309
{
310310
parent.responseHeaders = [];
311-
var name, value;
311+
var name:String;
312+
var value:String;
312313

313314
for (line in request.getAllResponseHeaders().split("\n"))
314315
{

src/lime/_internal/backend/html5/HTML5Window.hx

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,8 @@ class HTML5Window
482482
private function handleCutOrCopyEvent(event:ClipboardEvent):Void
483483
{
484484
var text = Clipboard.text;
485-
if (text == null) {
485+
if (text == null)
486+
{
486487
text = "";
487488
}
488489
event.clipboardData.setData("text/plain", text);
@@ -705,7 +706,6 @@ class HTML5Window
705706
}
706707

707708
case "mouseup":
708-
709709
// see comment below for mousemove for an explanation of
710710
// what the __stopMousePropagation flag is used for.
711711
if (__stopMousePropagation && event.currentTarget != parent.element)
@@ -729,7 +729,6 @@ class HTML5Window
729729
}
730730

731731
case "mousemove":
732-
733732
// this same listener is added to the parent element and to
734733
// the browser window for both the mousemove and the mouseup
735734
// event types, if mousedown happens first. this allows both
@@ -866,7 +865,11 @@ class HTML5Window
866865
}
867866
}
868867

869-
var touch, x, y, cacheX, cacheY;
868+
var touch:Touch;
869+
var x:Float;
870+
var y:Float;
871+
var cacheX:Float;
872+
var cacheY:Float;
870873

871874
for (data in event.changedTouches)
872875
{
@@ -1300,7 +1303,6 @@ class HTML5Window
13001303
textInput.removeEventListener('paste', handlePasteEvent, true);
13011304
textInput.removeEventListener('compositionstart', handleCompositionstartEvent, true);
13021305
textInput.removeEventListener('compositionend', handleCompositionendEvent, true);
1303-
13041306
}
13051307
}
13061308

@@ -1344,7 +1346,8 @@ class HTML5Window
13441346
{
13451347
if (!parent.__resizable) return;
13461348

1347-
var elementWidth, elementHeight;
1349+
var elementWidth:Float;
1350+
var elementHeight:Float;
13481351

13491352
if (parent.element != null)
13501353
{
@@ -1370,8 +1373,8 @@ class HTML5Window
13701373
{
13711374
if (parent.__width != elementWidth || parent.__height != elementHeight)
13721375
{
1373-
parent.__width = elementWidth;
1374-
parent.__height = elementHeight;
1376+
parent.__width = Std.int(elementWidth);
1377+
parent.__height = Std.int(elementHeight);
13751378

13761379
if (canvas != null)
13771380
{
@@ -1390,7 +1393,7 @@ class HTML5Window
13901393
div.style.height = elementHeight + "px";
13911394
}
13921395

1393-
parent.onResize.dispatch(elementWidth, elementHeight);
1396+
parent.onResize.dispatch(Std.int(elementWidth), Std.int(elementHeight));
13941397
}
13951398
}
13961399
else

src/lime/_internal/backend/native/NativeWindow.hx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,10 @@ class NativeWindow
350350
var windowWidth = Std.int(parent.__width * parent.__scale);
351351
var windowHeight = Std.int(parent.__height * parent.__scale);
352352

353-
var x, y, width, height;
353+
var x:Int;
354+
var y:Int;
355+
var width:Int;
356+
var height:Int;
354357

355358
if (rect != null)
356359
{

src/lime/_internal/format/BMP.hx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,10 @@ class BMP
109109

110110
var pixels = image.getPixels(new Rectangle(0, 0, image.width, image.height), ARGB32);
111111
var readPosition = 0;
112-
var a, r, g, b;
112+
var a:Int;
113+
var r:Int;
114+
var g:Int;
115+
var b:Int;
113116

114117
switch (type)
115118
{

src/lime/_internal/graphics/ImageCanvasUtil.hx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,10 @@ class ImageCanvasUtil
223223
{
224224
convertToCanvas(image);
225225

226-
var r, g, b, a;
226+
var r:Int;
227+
var g:Int;
228+
var b:Int;
229+
var a:Int;
227230

228231
if (format == ARGB32)
229232
{

src/lime/_internal/graphics/ImageDataUtil.hx

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -327,8 +327,12 @@ class ImageDataUtil
327327
var sourceFormat = sourceImage.buffer.format;
328328
var destFormat = image.buffer.format;
329329

330-
var sourcePosition, destPosition;
331-
var sourceAlpha, destAlpha, oneMinusSourceAlpha, blendAlpha;
330+
var sourcePosition:Int;
331+
var destPosition:Int;
332+
var sourceAlpha:Float;
333+
var destAlpha:Float;
334+
var oneMinusSourceAlpha:Float;
335+
var blendAlpha:Float;
332336
var sourcePixel:RGBA = 0;
333337
var destPixel:RGBA = 0;
334338

@@ -694,7 +698,8 @@ class ImageDataUtil
694698
_mask.a = 0xFF;
695699
}
696700

697-
var pixel, hit;
701+
var pixel:Int;
702+
var hit:Bool;
698703

699704
for (x in 0...image.width)
700705
{
@@ -921,7 +926,8 @@ class ImageDataUtil
921926
var sourcePremultiplied = sourceImage.buffer.premultiplied;
922927
var destPremultiplied = image.buffer.premultiplied;
923928

924-
var sourcePosition, destPosition;
929+
var sourcePosition:Int;
930+
var destPosition:Int;
925931
var sourcePixel:RGBA = 0;
926932
var destPixel:RGBA = 0;
927933

@@ -1113,10 +1119,20 @@ class ImageDataUtil
11131119
else
11141120
#end
11151121
{
1116-
var index, a16;
1122+
var index:Int;
11171123
var length = Std.int(data.length / 4);
1118-
var r1, g1, b1, a1, r2, g2, b2, a2;
1119-
var r, g, b, a;
1124+
var r1:Int;
1125+
var g1:Int;
1126+
var b1:Int;
1127+
var a1:Int;
1128+
var r2:Int;
1129+
var g2:Int;
1130+
var b2:Int;
1131+
var a2:Int;
1132+
var r:Int;
1133+
var g:Int;
1134+
var b:Int;
1135+
var a:Int;
11201136

11211137
switch (image.format)
11221138
{
@@ -1451,7 +1467,12 @@ class ImageDataUtil
14511467
private static #if cpp inline #end function __boxBlurH(imgA:UInt8Array, imgB:UInt8Array, w:Int, h:Int, r:Int, off:Int):Void
14521468
{
14531469
var iarr = 1 / (r + r + 1);
1454-
var ti, li, ri, fv, lv, val;
1470+
var ti:Int;
1471+
var li:Int;
1472+
var ri:Int;
1473+
var fv:Int;
1474+
var lv:Int;
1475+
var val:Int;
14551476

14561477
for (i in 0...h)
14571478
{
@@ -1499,7 +1520,12 @@ class ImageDataUtil
14991520
{
15001521
var iarr = 1 / (r + r + 1);
15011522
var ws = w * 4;
1502-
var ti, li, ri, fv, lv, val;
1523+
var ti:Int;
1524+
var li:Int;
1525+
var ri:Int;
1526+
var fv:Int;
1527+
var lv:Int;
1528+
var val:Int;
15031529

15041530
for (i in 0...w)
15051531
{

src/lime/graphics/Image.hx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1594,7 +1594,6 @@ class Image
15941594

15951595
var data = new UInt8Array(Bytes.ofData(data.getData()));
15961596
var length = header.width * header.height;
1597-
var b, g, r, a;
15981597

15991598
for (i in 0...length)
16001599
{

src/lime/text/Font.hx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,8 @@ class Font
437437
var offsetY = 0;
438438
var maxRows = 0;
439439

440-
var width, height;
440+
var width:Int;
441+
var height:Int;
441442
var i = 0;
442443

443444
while (i < count)
@@ -499,7 +500,10 @@ class Font
499500
offsetY = 0;
500501
maxRows = 0;
501502

502-
var index, x, y, image;
503+
var index:Int;
504+
var x:Int;
505+
var y:Int;
506+
var image:Image;
503507

504508
for (i in 0...count)
505509
{
@@ -665,7 +669,8 @@ class Font
665669
var timeout = 3000;
666670
var intervalLength = 50;
667671
var intervalCount = 0;
668-
var loaded, timeExpired;
672+
var loaded:Bool;
673+
var timeExpired:Bool;
669674

670675
var checkFont = function()
671676
{

src/lime/tools/AIRHelper.hx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ class AIRHelper
9292
default:
9393
}
9494

95-
var signingOptions = [];
95+
var signingOptions:Array<String> = [];
9696

9797
if (project.keystore != null)
9898
{
@@ -406,8 +406,8 @@ class AIRHelper
406406
if (targetPlatform == ANDROID && !project.targetFlags.exists("air-simulator"))
407407
{
408408
AndroidHelper.initialize(project);
409-
var deviceID = null;
410-
var adbFilter = null;
409+
var deviceID:String = null;
410+
var adbFilter:String = null;
411411

412412
// if (!Log.verbose) {
413413

@@ -431,7 +431,7 @@ class AIRHelper
431431
if (targetPlatform == ANDROID)
432432
{
433433
AndroidHelper.initialize(project);
434-
var deviceID = null;
434+
var deviceID:String = null;
435435
AndroidHelper.uninstall(project.meta.packageName, deviceID);
436436
}
437437
}

src/lime/tools/AssetHelper.hx

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ class AssetHelper
115115
libraries[lib.name] = lib;
116116
}
117117

118-
var assetData;
118+
var assetData:Dynamic;
119119

120120
for (asset in project.assets)
121121
{
@@ -155,8 +155,8 @@ class AssetHelper
155155
}
156156
}
157157

158-
var manifest = null;
159-
var manifests = [];
158+
var manifest:AssetManifest = null;
159+
var manifests:Array<AssetManifest> = [];
160160

161161
if (!hasManifest.exists(DEFAULT_LIBRARY_NAME))
162162
{
@@ -178,7 +178,7 @@ class AssetHelper
178178
if (targetDirectory != null)
179179
{
180180
System.mkdir(targetDirectory);
181-
var targetPath;
181+
var targetPath:String;
182182

183183
for (manifest in manifests)
184184
{
@@ -409,7 +409,7 @@ class AssetHelper
409409
libraryMap[library.name] = true;
410410
}
411411

412-
var library;
412+
var library:Library;
413413

414414
for (asset in project.assets)
415415
{
@@ -435,7 +435,7 @@ class AssetHelper
435435

436436
var handlers = new Array<String>();
437437
var hasPackedLibraries = false;
438-
var type;
438+
var type:String;
439439

440440
for (library in project.libraries)
441441
{
@@ -492,7 +492,7 @@ class AssetHelper
492492
}
493493
catch (e:Dynamic)
494494
{
495-
var types = [];
495+
var types:Array<String> = [];
496496

497497
for (library in project.libraries)
498498
{
@@ -545,7 +545,9 @@ class AssetHelper
545545
project.haxedefs.set("disable_preloader_assets", "1");
546546
}
547547

548-
var manifest, embed, asset;
548+
var manifest:AssetManifest;
549+
var embed:Bool;
550+
var asset:Asset;
549551

550552
for (library in project.libraries)
551553
{
@@ -609,7 +611,10 @@ class AssetHelper
609611

610612
public static function processPackedLibraries(project:HXProject, targetDirectory:String = null):Void
611613
{
612-
var type, asset, cacheAvailable, cacheDirectory, filename;
614+
var type:String;
615+
var cacheAvailable:Bool;
616+
var cacheDirectory:String;
617+
var filename:String;
613618
var output, manifest, position, assetData:Dynamic, input;
614619
var embeddedLibrary = false;
615620

@@ -656,7 +661,7 @@ class AssetHelper
656661

657662
try
658663
{
659-
var assetData;
664+
var assetData:Dynamic;
660665

661666
for (asset in project.assets)
662667
{

0 commit comments

Comments
 (0)