diff --git a/.gitignore b/.gitignore index 00bd9b4..e3553a2 100755 --- a/.gitignore +++ b/.gitignore @@ -14,4 +14,7 @@ npm-debug.log # Tests /tests/simple/js-generated -/tests/compound/js-generated \ No newline at end of file +/tests/simple/ts-generated +/tests/compound/js-generated +/tests/compound/ts-generated +/tests/compound/as3-tmp diff --git a/README.md b/README.md index c02432d..2545b6f 100755 --- a/README.md +++ b/README.md @@ -33,6 +33,8 @@ Make sure you have [Node v6+](https://nodejs.org/) installed. You should have `as3-to-ts` now globaly available in your commandline. +If you want to run the test suite using `npm test`, run `npm link @as3web/as3-to-ts` in the as3-to-ts folder. + ## Usage ``` diff --git a/npm-debug.log.1304647979 b/npm-debug.log.1304647979 deleted file mode 100644 index 511d04e..0000000 --- a/npm-debug.log.1304647979 +++ /dev/null @@ -1,53 +0,0 @@ -0 info it worked if it ends with ok -1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe', -1 verbose cli 'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js', -1 verbose cli 'run', -1 verbose cli 'test:simple:win', -1 verbose cli '--scripts-prepend-node-path=auto', -1 verbose cli 'focused=DebugClass' ] -2 info using npm@3.10.10 -3 info using node@v6.10.3 -4 verbose run-script [ 'pretest:simple:win', -4 verbose run-script 'test:simple:win', -4 verbose run-script 'posttest:simple:win' ] -5 info lifecycle as3-to-ts@0.3.3~pretest:simple:win: as3-to-ts@0.3.3 -6 silly lifecycle as3-to-ts@0.3.3~pretest:simple:win: no script for pretest:simple:win, continuing -7 info lifecycle as3-to-ts@0.3.3~test:simple:win: as3-to-ts@0.3.3 -8 verbose lifecycle as3-to-ts@0.3.3~test:simple:win: unsafe-perm in lifecycle true -9 verbose lifecycle as3-to-ts@0.3.3~test:simple:win: PATH: C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin;D:\work\sunflower\as3-to-ts\as3-to-ts\node_modules\.bin;C:\Program Files (x86)\PHP\v5.6;C:\ProgramData\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Program Files (x86)\Common Files\Acronis\SnapAPI\;C:\Program Files (x86)\Git\cmd;C:\Users\Ushan\.dnx\bin;C:\Program Files\Microsoft DNX\Dnvm\;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;C:\Program Files\Microsoft SQL Server\120\Tools\Binn\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Users\Ushan\AppData\Roaming\npm;C:\Program Files\Java\jre1.8.0_45\bin\;C:\Program Files\MySQL\MySQL Server 5.5\bin;C:\Windows\system32\config\systemprofile\.dnx\bin;C:\Program Files\Microsoft DNX\Dnvm\;C:\Program Files\TortoiseSVN\bin;F:\ProgramsNonForSSD\Autodesk32\Backburner\;C:\Program Files (x86)\Common Files\Autodesk Shared\;C:\Program Files\Common Files\Autodesk Shared\;C:\Program Files (x86)\GtkSharp\2.12\bin;C:\Program Files (x86)\Skype\Phone\;C:\Program Files\nodejs\;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Program Files\Java\jre1.8.0_45\bin\;C:\Program Files (x86)\PHP\v5.6\;D:\AIRSDK_19_Compiler\bin\;D:\gradle-3.1\\bin;D:\ant1.10\\bin;C:\Users\Ushan\AppData\Roaming\npm -10 verbose lifecycle as3-to-ts@0.3.3~test:simple:win: CWD: D:\work\sunflower\as3-to-ts\as3-to-ts -11 silly lifecycle as3-to-ts@0.3.3~test:simple:win: Args: [ '/d /s /c', -11 silly lifecycle 'node %NODE_DEBUG_OPTION% tests/simple/SimpleTests.js "focused=DebugClass"' ] -12 silly lifecycle as3-to-ts@0.3.3~test:simple:win: Returned: code: 1 signal: null -13 info lifecycle as3-to-ts@0.3.3~test:simple:win: Failed to exec test:simple:win script -14 verbose stack Error: as3-to-ts@0.3.3 test:simple:win: `node %NODE_DEBUG_OPTION% tests/simple/SimpleTests.js "focused=DebugClass"` -14 verbose stack Exit status 1 -14 verbose stack at EventEmitter. (C:\Program Files\nodejs\node_modules\npm\lib\utils\lifecycle.js:255:16) -14 verbose stack at emitTwo (events.js:106:13) -14 verbose stack at EventEmitter.emit (events.js:191:7) -14 verbose stack at ChildProcess. (C:\Program Files\nodejs\node_modules\npm\lib\utils\spawn.js:40:14) -14 verbose stack at emitTwo (events.js:106:13) -14 verbose stack at ChildProcess.emit (events.js:191:7) -14 verbose stack at maybeClose (internal/child_process.js:886:16) -14 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5) -15 verbose pkgid as3-to-ts@0.3.3 -16 verbose cwd D:\work\sunflower\as3-to-ts\as3-to-ts -17 error Windows_NT 6.1.7601 -18 error argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "test:simple:win" "--scripts-prepend-node-path=auto" "focused=DebugClass" -19 error node v6.10.3 -20 error npm v3.10.10 -21 error code ELIFECYCLE -22 error as3-to-ts@0.3.3 test:simple:win: `node %NODE_DEBUG_OPTION% tests/simple/SimpleTests.js "focused=DebugClass"` -22 error Exit status 1 -23 error Failed at the as3-to-ts@0.3.3 test:simple:win script 'node %NODE_DEBUG_OPTION% tests/simple/SimpleTests.js "focused=DebugClass"'. -23 error Make sure you have the latest version of node.js and npm installed. -23 error If you do, this is most likely a problem with the as3-to-ts package, -23 error not with npm itself. -23 error Tell the author that this fails on your system: -23 error node %NODE_DEBUG_OPTION% tests/simple/SimpleTests.js "focused=DebugClass" -23 error You can get information on how to open an issue for this project with: -23 error npm bugs as3-to-ts -23 error Or if that isn't available, you can get their info via: -23 error npm owner ls as3-to-ts -23 error There is likely additional logging output above. -24 verbose exit [ 1, true ] diff --git a/npm-debug.log.1955635711 b/npm-debug.log.1955635711 deleted file mode 100644 index e69de29..0000000 diff --git a/src/emit/classlist.ts b/src/emit/classlist.ts index 2bf4d40..b265e85 100644 --- a/src/emit/classlist.ts +++ b/src/emit/classlist.ts @@ -50,9 +50,10 @@ export default class ClassList { } public static getLastPathToRoot():string{ - if (ClassList.isScanning) return; - //let classRecord: ClassRecord = ClassList.classList[ClassList.classList.length - 1]; let classRecord: ClassRecord = ClassList.currentClassRecord; + if(!classRecord) { + classRecord = ClassList.classList[ClassList.classList.length - 1]; + } let packageLevel: number = 0; if (classRecord && classRecord.packageName && classRecord.packageName != "") { diff --git a/src/emit/emitter.ts b/src/emit/emitter.ts index 7212d59..5336523 100755 --- a/src/emit/emitter.ts +++ b/src/emit/emitter.ts @@ -977,7 +977,7 @@ function emitForEach(emitter:Emitter, node:Node):void { emitter.catchup(blockNode.start + 1); let def = emitter.findDefInScope(nameNode.text); - if (def.type && castStr == "" ){ + if (def && def.type && castStr == "" ){ castStr = `<${def.type.toString()}>`; } let declarationWord:string = ""; @@ -1191,7 +1191,10 @@ function emitClass(emitter:Emitter, node:Node):void { let mods = node.findChild(NodeKind.MOD_LIST); if (mods && mods.children.length) { emitter.catchup(mods.start); - emitter.insert("\n@classBound\n"); + + // insert @classBound with equal indentation for the next line + emitter.output = emitter.output.replace(/([^\S\n]*)$/, "$1@classBound\n$1"); + let insertExport = false; mods.children.forEach(node => { if (node.text !== 'private') { @@ -1441,16 +1444,20 @@ function emitMethod(emitter:Emitter, node:Node):void { if (node.kind !== NodeKind.FUNCTION || name.text !== emitter.currentClassName) { let pathToRoot = ClassList.getLastPathToRoot(); emitter.ensureImportIdentifier("bound", `${pathToRoot}bound`); + let mods = node.findChild(NodeKind.MOD_LIST); - if (mods) + if (mods) { emitter.catchup(mods.start); - else + } else { emitter.catchup(name.start); - emitter.insert("@bound\n"); + } + + // insert @bound with equal indentation for the next line + emitter.output = emitter.output.replace(/([^\S\n]*)$/, "$1@bound\n$1"); + emitClassField(emitter, node); - emitter.consume('function', name.start); + emitter.catchup(name.end); - //emitter.insert(" = "); } else { let mods = node.findChild(NodeKind.MOD_LIST); diff --git a/tests/compound/CompoundTests.js b/tests/compound/CompoundTests.js index 4403011..4bf2687 100755 --- a/tests/compound/CompoundTests.js +++ b/tests/compound/CompoundTests.js @@ -96,7 +96,7 @@ filesAS.forEach(file => { } } else { - console.log(colors.red(' ✗ ERROR: unable to find reference file to compare to.')); + //console.log(colors.red(' ✗ ERROR: unable to find reference file to compare to.')); } }); diff --git a/tests/compound/as3-tmp/Main.as b/tests/compound/as3-tmp/Main.as deleted file mode 100644 index c12d0ed..0000000 --- a/tests/compound/as3-tmp/Main.as +++ /dev/null @@ -1,82 +0,0 @@ -package { - - -import flash.display.Sprite; -import flash.display.StageAlign; -import flash.display.StageScaleMode; -import flash.text.TextField; -import flash.net.navigateToURL; -import flash.net.URLRequest; - -import vehicles.Vehicle; - -public class Main extends Sprite { - - public function doYourThing(spr:Sprite):void { - trace("snippets are cool"); -} - - - private var thing1:String = "heya"; - private var thing2:String = "oops, forgot the semi :O" - public var noAccessDeclDefaultsToInternal:String; - - public function Main() { - super(); - - earlyDrop(); - - // method doens't exist - doSomething(); - - stage.scaleMode = StageScaleMode.NO_SCALE; - stage.align = StageAlign.TOP_LEFT; - - var msg:String = "Hello, World"; - - navigateToURL(new URLRequest("https://www.away3d.com"), "_self"); - var textField:TextField = new TextField(); - textField.x = 100; - textField.y = 100; - textField.text = msg; - addChild(textField); - - var vehicle:Vehicle= new Vehicle; - vehicle.doSomething(); - - // Comment. - - /* - This - is - a - multiline - comment. - */ - - var a:String = "a"; - switch(a) { - case "b": - break; - case "a": - break; - } - - for(var i:uint = 0; i < 10; i++) { - continue; - } - - var date:Date = new Date(); - } - - public function earlyDrop(something:Boolean):void { - if(something == false) { - return; - } - if(something == true) { - return; - } - var a:String = "a"; - } -} -} diff --git a/tests/compound/as3-tmp/Snippet.snp b/tests/compound/as3-tmp/Snippet.snp deleted file mode 100644 index de6d52d..0000000 --- a/tests/compound/as3-tmp/Snippet.snp +++ /dev/null @@ -1,6 +0,0 @@ -import flash.display.Sprite; - -public function doYourThing(spr:Sprite):void { - trace("snippets are cool"); -} - diff --git a/tests/compound/as3-tmp/vehicles/Boat.as b/tests/compound/as3-tmp/vehicles/Boat.as deleted file mode 100644 index ac1b547..0000000 --- a/tests/compound/as3-tmp/vehicles/Boat.as +++ /dev/null @@ -1,10 +0,0 @@ -/** - * Created by palebluedot on 3/24/17. - */ -package vehicles { -public class Boat extends Vehicle { - public function Boat() { - super(); - } -} -} diff --git a/tests/compound/as3-tmp/vehicles/Car.as b/tests/compound/as3-tmp/vehicles/Car.as deleted file mode 100644 index b891771..0000000 --- a/tests/compound/as3-tmp/vehicles/Car.as +++ /dev/null @@ -1,21 +0,0 @@ -/** - * Created by palebluedot on 3/24/17. - */ -package vehicles { -import vehicles.components.Wheel; - -public class Car extends Vehicle { - - public var wheels:Vector.; - - public function Car() { - super(); - - wheels = new Vector.(); - wheels.push( new Wheel() ); - wheels.push( new Wheel() ); - wheels.push( new Wheel() ); - wheels.push( new Wheel() ); - } -} -} diff --git a/tests/compound/as3-tmp/vehicles/Vehicle.as b/tests/compound/as3-tmp/vehicles/Vehicle.as deleted file mode 100644 index 6e16048..0000000 --- a/tests/compound/as3-tmp/vehicles/Vehicle.as +++ /dev/null @@ -1,18 +0,0 @@ -/** - * Created by palebluedot on 3/24/17. - */ -package vehicles { -import vehicles.components.Base.Thing; -import vehicles.components.Engine; - -public class Vehicle extends Thing { - - public var engine:Engine; - - public function Vehicle() { - super(); - doSomething(); - doSomethingElse(); // method doesn't exist - } -} -} diff --git a/tests/compound/as3-tmp/vehicles/components/Base/IDoer.as b/tests/compound/as3-tmp/vehicles/components/Base/IDoer.as deleted file mode 100644 index 685d316..0000000 --- a/tests/compound/as3-tmp/vehicles/components/Base/IDoer.as +++ /dev/null @@ -1,8 +0,0 @@ -/** - * Created by palebluedot on 3/27/17. - */ -package vehicles.components.Base { -public interface IDoer { - function doSomething():void; -} -} diff --git a/tests/compound/as3-tmp/vehicles/components/Base/Orphan.as b/tests/compound/as3-tmp/vehicles/components/Base/Orphan.as deleted file mode 100644 index c79489c..0000000 --- a/tests/compound/as3-tmp/vehicles/components/Base/Orphan.as +++ /dev/null @@ -1,8 +0,0 @@ -package vehicles.components.Base { - public class Orphan { - private var _aVar:String = ""; - public function Orphan() { - // heya - } - } -} \ No newline at end of file diff --git a/tests/compound/as3-tmp/vehicles/components/Base/Thing.as b/tests/compound/as3-tmp/vehicles/components/Base/Thing.as deleted file mode 100644 index 37ba9cc..0000000 --- a/tests/compound/as3-tmp/vehicles/components/Base/Thing.as +++ /dev/null @@ -1,28 +0,0 @@ -/** - * Created by palebluedot on 3/24/17. - */ -package vehicles.components.Base { -public class Thing implements IDoer { - - private var aFunction:Function = function(param1:uint, param2:String):Boolean { - return false; - }; - - public function Thing() { - - - } - - public function doSomething():void { - // this looks like a comment, but it isn't. - } - - private function thisIsASuperSecretMethod(name:String, defaultVal:* = null):void { - - } - - private function addSubDoer(doer:IDoer):void { - - } -} -} diff --git a/tests/compound/as3-tmp/vehicles/components/Engine.as b/tests/compound/as3-tmp/vehicles/components/Engine.as deleted file mode 100644 index 6ed11e3..0000000 --- a/tests/compound/as3-tmp/vehicles/components/Engine.as +++ /dev/null @@ -1,34 +0,0 @@ -/** - * Created by palebluedot on 3/24/17. - */ -package vehicles.components { -import flash.utils.getTimer; - -import vehicles.components.Base.Thing; - -public class Engine extends Thing { - - private var _timeStarted:Number = -1; - - public function Engine() { - super(); - } - - public function start():void { - _timeStarted = getTimer(); - } - - public function stop():void { - _timeStarted = -1; - } - - public function getRunningTime():Number { - if(_timeStarted == -1) { - return 0; - } - else { - return getTimer() - _timeStarted; - } - } -} -} diff --git a/tests/compound/as3-tmp/vehicles/components/Wheel.as b/tests/compound/as3-tmp/vehicles/components/Wheel.as deleted file mode 100644 index 5b2aa4c..0000000 --- a/tests/compound/as3-tmp/vehicles/components/Wheel.as +++ /dev/null @@ -1,12 +0,0 @@ -/** - * Created by palebluedot on 3/24/17. - */ -package vehicles.components { -import vehicles.components.Base.Thing; - -public class Wheel extends Thing { - public function Wheel() { - super(); - } -} -} diff --git a/tests/compound/ts-expected/Main.ts b/tests/compound/ts-expected/Main.ts index 89156c6..bfda0ec 100644 --- a/tests/compound/ts-expected/Main.ts +++ b/tests/compound/ts-expected/Main.ts @@ -1,4 +1,6 @@ +import { bound } from "./bound"; import { AwayDate } from "@as3web/flash"; +import { classBound } from "./classBound"; import { Sprite } from "@as3web/flash" import { StageAlign } from "@as3web/flash" @@ -9,19 +11,19 @@ import { URLRequest } from "@as3web/flash" import {Vehicle} from "./vehicles/Vehicle"; +@classBound export class Main extends Sprite { - public doYourThing = (spr:Sprite):void => { + @bound + public doYourThing(spr:Sprite):void { console.log("snippets are cool"); } - private thing1:string = "heya"; private thing2:string = "oops, forgot the semi :O" public noAccessDeclDefaultsToInternal:string; constructor(){ - super(); super(); this.earlyDrop(); @@ -69,7 +71,8 @@ export class Main extends Sprite { var date:AwayDate = new AwayDate(); } - public earlyDrop = (something:boolean):void => { + @bound + public earlyDrop(something:boolean):void { if(something == false) { return; } diff --git a/tests/compound/ts-expected/vehicles/Boat.ts b/tests/compound/ts-expected/vehicles/Boat.ts index d803f81..59e6f38 100644 --- a/tests/compound/ts-expected/vehicles/Boat.ts +++ b/tests/compound/ts-expected/vehicles/Boat.ts @@ -1,10 +1,11 @@ import { Vehicle } from "./Vehicle"; +import { classBound } from "../classBound"; /** * Created by palebluedot on 3/24/17. */ +@classBound export class Boat extends Vehicle { constructor(){ - super(); super(); } } diff --git a/tests/compound/ts-expected/vehicles/Car.ts b/tests/compound/ts-expected/vehicles/Car.ts index a3ea0ae..9a22b8c 100644 --- a/tests/compound/ts-expected/vehicles/Car.ts +++ b/tests/compound/ts-expected/vehicles/Car.ts @@ -1,15 +1,16 @@ import { Vehicle } from "./Vehicle"; +import { classBound } from "../classBound"; /** * Created by palebluedot on 3/24/17. */ import { Wheel } from "./components/Wheel"; +@classBound export class Car extends Vehicle { public wheels:Wheel[]; constructor(){ - super(); super(); this.wheels = []; diff --git a/tests/compound/ts-expected/vehicles/Vehicle.ts b/tests/compound/ts-expected/vehicles/Vehicle.ts index 53e0bb4..e0dcc5f 100644 --- a/tests/compound/ts-expected/vehicles/Vehicle.ts +++ b/tests/compound/ts-expected/vehicles/Vehicle.ts @@ -1,15 +1,16 @@ +import { classBound } from "../classBound"; /** * Created by palebluedot on 3/24/17. */ import { Thing } from "./components/Base/Thing"; import { Engine } from "./components/Engine"; +@classBound export class Vehicle extends Thing { public engine:Engine; constructor(){ - super(); super(); this.doSomething(); this.doSomethingElse(); // method doesn't exist diff --git a/tests/compound/ts-expected/vehicles/components/Base/Orphan.ts b/tests/compound/ts-expected/vehicles/components/Base/Orphan.ts index 5f03623..44ddc62 100644 --- a/tests/compound/ts-expected/vehicles/components/Base/Orphan.ts +++ b/tests/compound/ts-expected/vehicles/components/Base/Orphan.ts @@ -1,3 +1,5 @@ +import { classBound } from "../../../classBound"; + @classBound export class Orphan { private _aVar:string = ""; constructor(){ diff --git a/tests/compound/ts-expected/vehicles/components/Base/Thing.ts b/tests/compound/ts-expected/vehicles/components/Base/Thing.ts index 90a1a83..b6fd571 100644 --- a/tests/compound/ts-expected/vehicles/components/Base/Thing.ts +++ b/tests/compound/ts-expected/vehicles/components/Base/Thing.ts @@ -1,10 +1,13 @@ import { IDoer } from "./IDoer"; +import { bound } from "../../../bound"; +import { classBound } from "../../../classBound"; /** * Created by palebluedot on 3/24/17. */ +@classBound export class Thing implements IDoer { - static __interfaces__; + static __interfaces__ = ["IDoer"]; private aFunction:Function = (param1:number, param2:string):boolean => { return false; }; @@ -14,17 +17,19 @@ private aFunction:Function = (param1:number, param2:string):boolean => { } - public doSomething = ():void => { + @bound + public doSomething():void { // this looks like a comment, but it isn't. } - private thisIsASuperSecretMethod = (name:string, defaultVal:any = null):void => { + @bound + private thisIsASuperSecretMethod(name:string, defaultVal:any = null):void { } - private addSubDoer = (doer:IDoer):void => { + @bound + private addSubDoer(doer:IDoer):void { } } -Thing.__interfaces__ = ["IDoer"]; diff --git a/tests/compound/ts-expected/vehicles/components/Engine.ts b/tests/compound/ts-expected/vehicles/components/Engine.ts index d1dd64a..2699158 100644 --- a/tests/compound/ts-expected/vehicles/components/Engine.ts +++ b/tests/compound/ts-expected/vehicles/components/Engine.ts @@ -1,3 +1,5 @@ +import { bound } from "../../bound"; +import { classBound } from "../../classBound"; /** * Created by palebluedot on 3/24/17. */ @@ -5,24 +7,27 @@ import { Thing } from "./Base/Thing"; +@classBound export class Engine extends Thing { private _timeStarted:number = -1; constructor(){ - super(); super(); } - public start = ():void => { + @bound + public start():void { this._timeStarted = Date.now(); } - public stop = ():void => { + @bound + public stop():void { this._timeStarted = -1; } - public getRunningTime = ():number => { + @bound + public getRunningTime():number { if(this._timeStarted == -1) { return 0; } diff --git a/tests/compound/ts-expected/vehicles/components/Wheel.ts b/tests/compound/ts-expected/vehicles/components/Wheel.ts index a5ced16..088710e 100644 --- a/tests/compound/ts-expected/vehicles/components/Wheel.ts +++ b/tests/compound/ts-expected/vehicles/components/Wheel.ts @@ -1,11 +1,12 @@ +import { classBound } from "../../classBound"; /** * Created by palebluedot on 3/24/17. */ import { Thing } from "./Base/Thing"; +@classBound export class Wheel extends Thing { constructor(){ - super(); super(); } } diff --git a/tests/compound/ts-generated/Main.ts b/tests/compound/ts-generated/Main.ts index 89156c6..bfda0ec 100644 --- a/tests/compound/ts-generated/Main.ts +++ b/tests/compound/ts-generated/Main.ts @@ -1,4 +1,6 @@ +import { bound } from "./bound"; import { AwayDate } from "@as3web/flash"; +import { classBound } from "./classBound"; import { Sprite } from "@as3web/flash" import { StageAlign } from "@as3web/flash" @@ -9,19 +11,19 @@ import { URLRequest } from "@as3web/flash" import {Vehicle} from "./vehicles/Vehicle"; +@classBound export class Main extends Sprite { - public doYourThing = (spr:Sprite):void => { + @bound + public doYourThing(spr:Sprite):void { console.log("snippets are cool"); } - private thing1:string = "heya"; private thing2:string = "oops, forgot the semi :O" public noAccessDeclDefaultsToInternal:string; constructor(){ - super(); super(); this.earlyDrop(); @@ -69,7 +71,8 @@ export class Main extends Sprite { var date:AwayDate = new AwayDate(); } - public earlyDrop = (something:boolean):void => { + @bound + public earlyDrop(something:boolean):void { if(something == false) { return; } diff --git a/tests/compound/ts-generated/vehicles/Boat.ts b/tests/compound/ts-generated/vehicles/Boat.ts index d803f81..59e6f38 100644 --- a/tests/compound/ts-generated/vehicles/Boat.ts +++ b/tests/compound/ts-generated/vehicles/Boat.ts @@ -1,10 +1,11 @@ import { Vehicle } from "./Vehicle"; +import { classBound } from "../classBound"; /** * Created by palebluedot on 3/24/17. */ +@classBound export class Boat extends Vehicle { constructor(){ - super(); super(); } } diff --git a/tests/compound/ts-generated/vehicles/Car.ts b/tests/compound/ts-generated/vehicles/Car.ts index a3ea0ae..9a22b8c 100644 --- a/tests/compound/ts-generated/vehicles/Car.ts +++ b/tests/compound/ts-generated/vehicles/Car.ts @@ -1,15 +1,16 @@ import { Vehicle } from "./Vehicle"; +import { classBound } from "../classBound"; /** * Created by palebluedot on 3/24/17. */ import { Wheel } from "./components/Wheel"; +@classBound export class Car extends Vehicle { public wheels:Wheel[]; constructor(){ - super(); super(); this.wheels = []; diff --git a/tests/compound/ts-generated/vehicles/Vehicle.ts b/tests/compound/ts-generated/vehicles/Vehicle.ts index 53e0bb4..e0dcc5f 100644 --- a/tests/compound/ts-generated/vehicles/Vehicle.ts +++ b/tests/compound/ts-generated/vehicles/Vehicle.ts @@ -1,15 +1,16 @@ +import { classBound } from "../classBound"; /** * Created by palebluedot on 3/24/17. */ import { Thing } from "./components/Base/Thing"; import { Engine } from "./components/Engine"; +@classBound export class Vehicle extends Thing { public engine:Engine; constructor(){ - super(); super(); this.doSomething(); this.doSomethingElse(); // method doesn't exist diff --git a/tests/compound/ts-generated/vehicles/components/Base/Orphan.ts b/tests/compound/ts-generated/vehicles/components/Base/Orphan.ts index 5f03623..44ddc62 100644 --- a/tests/compound/ts-generated/vehicles/components/Base/Orphan.ts +++ b/tests/compound/ts-generated/vehicles/components/Base/Orphan.ts @@ -1,3 +1,5 @@ +import { classBound } from "../../../classBound"; + @classBound export class Orphan { private _aVar:string = ""; constructor(){ diff --git a/tests/compound/ts-generated/vehicles/components/Base/Thing.ts b/tests/compound/ts-generated/vehicles/components/Base/Thing.ts index 90a1a83..b6fd571 100644 --- a/tests/compound/ts-generated/vehicles/components/Base/Thing.ts +++ b/tests/compound/ts-generated/vehicles/components/Base/Thing.ts @@ -1,10 +1,13 @@ import { IDoer } from "./IDoer"; +import { bound } from "../../../bound"; +import { classBound } from "../../../classBound"; /** * Created by palebluedot on 3/24/17. */ +@classBound export class Thing implements IDoer { - static __interfaces__; + static __interfaces__ = ["IDoer"]; private aFunction:Function = (param1:number, param2:string):boolean => { return false; }; @@ -14,17 +17,19 @@ private aFunction:Function = (param1:number, param2:string):boolean => { } - public doSomething = ():void => { + @bound + public doSomething():void { // this looks like a comment, but it isn't. } - private thisIsASuperSecretMethod = (name:string, defaultVal:any = null):void => { + @bound + private thisIsASuperSecretMethod(name:string, defaultVal:any = null):void { } - private addSubDoer = (doer:IDoer):void => { + @bound + private addSubDoer(doer:IDoer):void { } } -Thing.__interfaces__ = ["IDoer"]; diff --git a/tests/compound/ts-generated/vehicles/components/Engine.ts b/tests/compound/ts-generated/vehicles/components/Engine.ts index d1dd64a..2699158 100644 --- a/tests/compound/ts-generated/vehicles/components/Engine.ts +++ b/tests/compound/ts-generated/vehicles/components/Engine.ts @@ -1,3 +1,5 @@ +import { bound } from "../../bound"; +import { classBound } from "../../classBound"; /** * Created by palebluedot on 3/24/17. */ @@ -5,24 +7,27 @@ import { Thing } from "./Base/Thing"; +@classBound export class Engine extends Thing { private _timeStarted:number = -1; constructor(){ - super(); super(); } - public start = ():void => { + @bound + public start():void { this._timeStarted = Date.now(); } - public stop = ():void => { + @bound + public stop():void { this._timeStarted = -1; } - public getRunningTime = ():number => { + @bound + public getRunningTime():number { if(this._timeStarted == -1) { return 0; } diff --git a/tests/compound/ts-generated/vehicles/components/Wheel.ts b/tests/compound/ts-generated/vehicles/components/Wheel.ts index a5ced16..088710e 100644 --- a/tests/compound/ts-generated/vehicles/components/Wheel.ts +++ b/tests/compound/ts-generated/vehicles/components/Wheel.ts @@ -1,11 +1,12 @@ +import { classBound } from "../../classBound"; /** * Created by palebluedot on 3/24/17. */ import { Thing } from "./Base/Thing"; +@classBound export class Wheel extends Thing { constructor(){ - super(); super(); } } diff --git a/tests/simple/ts-expected/AClassNameWithNumer3InIt.ts b/tests/simple/ts-expected/AClassNameWithNumer3InIt.ts index 3637838..4dc2c55 100755 --- a/tests/simple/ts-expected/AClassNameWithNumer3InIt.ts +++ b/tests/simple/ts-expected/AClassNameWithNumer3InIt.ts @@ -1,6 +1,8 @@ +import { classBound } from "./classBound"; /** * Created by palebluedot on 4/25/17. */ +@classBound export class AClassNameWithNumer3InIt { constructor(){ } diff --git a/tests/simple/ts-expected/Callbacks.ts b/tests/simple/ts-expected/Callbacks.ts index 002764d..bd347bc 100755 --- a/tests/simple/ts-expected/Callbacks.ts +++ b/tests/simple/ts-expected/Callbacks.ts @@ -1,3 +1,6 @@ +import { bound } from "./bound"; +import { classBound } from "./classBound"; +@classBound export class Callbacks { public a:string = "a" @@ -13,15 +16,17 @@ export class Callbacks { }); } - private callback = ():void => { + @bound + private callback():void { console.log("(class callback) this is: " + this); if(this) { console.log("a is: " + this.a) } else { console.log("a is: unknown") } } - private executeCallback = (callback:Function):void => { + @bound + private executeCallback(callback:Function):void { callback(); } } -new Callbacks() \ No newline at end of file +new Callbacks(); \ No newline at end of file diff --git a/tests/simple/ts-expected/Casting.ts b/tests/simple/ts-expected/Casting.ts index 8c33803..f9eae46 100755 --- a/tests/simple/ts-expected/Casting.ts +++ b/tests/simple/ts-expected/Casting.ts @@ -1,3 +1,6 @@ +import { bound } from "./bound"; +import { classBound } from "./classBound"; +@classBound export class Casting { constructor(){ @@ -34,9 +37,10 @@ export class Casting { } - private thisMethodIsInTheClassScope = (str:string) => { + @bound + private thisMethodIsInTheClassScope(str:string) { console.log(str); } } -new Casting() \ No newline at end of file +new Casting(); \ No newline at end of file diff --git a/tests/simple/ts-expected/ClassMember.ts b/tests/simple/ts-expected/ClassMember.ts index d9c94ab..8f6ce9e 100755 --- a/tests/simple/ts-expected/ClassMember.ts +++ b/tests/simple/ts-expected/ClassMember.ts @@ -1,4 +1,6 @@ +import { classBound } from "./classBound"; +@classBound export class ClassMember { public myVar:number = 100; diff --git a/tests/simple/ts-expected/DebugClass.ts b/tests/simple/ts-expected/DebugClass.ts index ab94e58..d662f37 100755 --- a/tests/simple/ts-expected/DebugClass.ts +++ b/tests/simple/ts-expected/DebugClass.ts @@ -1,12 +1,15 @@ +import { classBound } from "./classBound"; -export class DebugClass -{ - public key; +@classBound +export class DebugClass { + private prop1:number; + private prop2:number; + private prop3:number; constructor(){ - } + console.log(this.prop2); + } } - diff --git a/tests/simple/ts-expected/DynamicCasting.ts b/tests/simple/ts-expected/DynamicCasting.ts index 803fa77..5a38f59 100644 --- a/tests/simple/ts-expected/DynamicCasting.ts +++ b/tests/simple/ts-expected/DynamicCasting.ts @@ -1,5 +1,7 @@ import { DebugClass } from "./DebugClass"; +import { classBound } from "./classBound"; +@classBound export class DynamicCasting { constructor(){ diff --git a/tests/simple/ts-expected/DynamicClass.ts b/tests/simple/ts-expected/DynamicClass.ts index 24647d0..44b82d0 100755 --- a/tests/simple/ts-expected/DynamicClass.ts +++ b/tests/simple/ts-expected/DynamicClass.ts @@ -1,5 +1,7 @@ import { SubDynamicClass } from "./SubDynamicClass"; +import { classBound } from "./classBound"; + @classBound export class DynamicClass { constructor(){ @@ -9,6 +11,7 @@ import { SubDynamicClass } from "./SubDynamicClass"; } } + @classBound export class SubDynamicClass{ } diff --git a/tests/simple/ts-expected/ForEach.ts b/tests/simple/ts-expected/ForEach.ts index d5eff62..89383f9 100755 --- a/tests/simple/ts-expected/ForEach.ts +++ b/tests/simple/ts-expected/ForEach.ts @@ -1,6 +1,9 @@ +import { classBound } from "./classBound"; /** * Created by palebluedot on 4/24/17. */ + +@classBound export class ForEach { constructor(){ @@ -10,7 +13,7 @@ export class ForEach { strings.push('cats'); strings.push('nature'); for (var __$nflvKey in strings) { - var str:string = strings[__$nflvKey]; + var str:string = strings[__$nflvKey]; console.log("a string: " + str); } @@ -44,4 +47,4 @@ export class ForEach { // } // } -new ForEach() \ No newline at end of file +new ForEach(); \ No newline at end of file diff --git a/tests/simple/ts-expected/ForEachClassMapping.ts b/tests/simple/ts-expected/ForEachClassMapping.ts index fb98179..f464f5b 100755 --- a/tests/simple/ts-expected/ForEachClassMapping.ts +++ b/tests/simple/ts-expected/ForEachClassMapping.ts @@ -1,5 +1,8 @@ import { MappedClass } from "./MappedClass"; +import { classBound } from "./classBound"; +import { bound } from "./bound"; +@classBound export class ForEachClassMapping { constructor(){ @@ -12,7 +15,7 @@ export class ForEachClassMapping myObj.c = c; for (var __$nflvKey in myObj) { - var value:MappedClass = myObj[__$nflvKey]; + var value:MappedClass = myObj[__$nflvKey]; console.log(value); } @@ -29,7 +32,8 @@ class MappedClass this.value = value; } - public toString = ():string => + @bound + public toString():string { return this.value; } diff --git a/tests/simple/ts-expected/GetSet.ts b/tests/simple/ts-expected/GetSet.ts index 4cfcd6a..42769fb 100644 --- a/tests/simple/ts-expected/GetSet.ts +++ b/tests/simple/ts-expected/GetSet.ts @@ -1,4 +1,6 @@ - export class GetSet { +import { classBound } from "./classBound"; + @classBound + export class GetSet { constructor(){ diff --git a/tests/simple/ts-expected/InterfaceTest.ts b/tests/simple/ts-expected/InterfaceTest.ts index b302a64..7fa32a2 100755 --- a/tests/simple/ts-expected/InterfaceTest.ts +++ b/tests/simple/ts-expected/InterfaceTest.ts @@ -1,4 +1,7 @@ +import { classBound } from "./classBound"; +import { bound } from "./bound"; +@classBound export class InterfaceTest { constructor(){ @@ -9,14 +12,14 @@ export class InterfaceTest interface myInterface{ - myFunc(value:number):number + myFunc(value:Number):number } class MyClass implements myInterface{ - static __interfaces__; -public myFunc = (value:number):number => + static __interfaces__ = ["myInterface"]; +@bound +public myFunc(value:number):number { return 10 } -} -MyClass.__interfaces__ = ["myInterface"]; \ No newline at end of file +} \ No newline at end of file diff --git a/tests/simple/ts-expected/LoopImport.ts b/tests/simple/ts-expected/LoopImport.ts index bf59b10..8780c8f 100755 --- a/tests/simple/ts-expected/LoopImport.ts +++ b/tests/simple/ts-expected/LoopImport.ts @@ -1,5 +1,7 @@ import { SubClass } from "./SubClass"; +import { classBound } from "./classBound"; +@classBound export class LoopImport { constructor(){ diff --git a/tests/simple/ts-expected/MemberAccessors.ts b/tests/simple/ts-expected/MemberAccessors.ts index 1a95ead..2f6a6d3 100755 --- a/tests/simple/ts-expected/MemberAccessors.ts +++ b/tests/simple/ts-expected/MemberAccessors.ts @@ -1,3 +1,6 @@ +import { bound } from "./bound"; +import { classBound } from "./classBound"; +@classBound export class Accessors { public memberVar:string = "hello"; @@ -6,7 +9,8 @@ export class Accessors { this.memberMethod(); } - public memberMethod = ():void => { + @bound + public memberMethod():void { console.log(this.memberVar); var a:string = "a"; diff --git a/tests/simple/ts-expected/PrimitiveCheck.ts b/tests/simple/ts-expected/PrimitiveCheck.ts index 71d8845..6408f0f 100755 --- a/tests/simple/ts-expected/PrimitiveCheck.ts +++ b/tests/simple/ts-expected/PrimitiveCheck.ts @@ -1,4 +1,6 @@ -import { AS3Utils } from "as3-to-ts/src/AS3Utils"; +import { AS3Utils } from "./AS3Utils"; +import { classBound } from "./classBound"; +@classBound export class PrimitiveCheck { constructor(){ @@ -7,7 +9,7 @@ export class PrimitiveCheck { if(typeof myVar === 'number') { console.log("it's a number"); } if(typeof myVar === 'string') { console.log("it's a string"); } if(typeof myVar === 'boolean') { console.log("it's a boolean"); } - if(AS3Utils.isInstanceOfInterface(myVar, "Object")) { console.log("it's an object"); } + if(myVar instanceof Object) { console.log("it's an object"); } /* Expected TS: diff --git a/tests/simple/ts-expected/SimpleInterface.ts b/tests/simple/ts-expected/SimpleInterface.ts index f0db869..6c7ab08 100755 --- a/tests/simple/ts-expected/SimpleInterface.ts +++ b/tests/simple/ts-expected/SimpleInterface.ts @@ -1,6 +1,6 @@ export interface SimpleInterface { - myFunction(var1:number = 7, var2:string = "13", var3:number = 17):number + myFunction(var1?:number, var2?:string, var3?:number):number } diff --git a/tests/simple/ts-expected/Super.ts b/tests/simple/ts-expected/Super.ts index 1612f51..d31cf1e 100644 --- a/tests/simple/ts-expected/Super.ts +++ b/tests/simple/ts-expected/Super.ts @@ -1,40 +1,48 @@ +import { bound } from "./bound"; +import { classBound } from "./classBound"; + +@classBound export class Being { public name:string; private _happiness:string; public set happiness(value:string) { this.doSetHappiness(value); } - public doSetHappiness = (value:string):void => { + @bound + public doSetHappiness(value:string):void { this._happiness = value; } constructor(){ this.name = "abstract being"; this.happiness = "low"; } - public be = ():void => { + @bound + public be():void { console.log(this.name + " is - hapiness: " + this._happiness); } } +@classBound export class Animal extends Being { constructor(){ - super(); super(); this.name = "animal"; } - public move = ():void => { + @bound + public move():void { console.log(this.name + ", an animal, moved"); this.breathe(); } - protected breathe = ():void => { + @bound + protected breathe():void { console.log(this.name + ", an animal, breathed"); this.be(); } } +@classBound export class Snake extends Animal { constructor(){ - super(); super(); this.name = "snake"; } @@ -42,7 +50,8 @@ export class Snake extends Animal { this.doSetHappiness("very " + value); this.breathe(); } - /*override*/ public move = ():void => { + @bound + /*override*/ public move():void { this.happiness = "high"; super.move(); } diff --git a/tests/simple/ts-expected/SuperArray.ts b/tests/simple/ts-expected/SuperArray.ts index af44953..71650d1 100755 --- a/tests/simple/ts-expected/SuperArray.ts +++ b/tests/simple/ts-expected/SuperArray.ts @@ -1,3 +1,5 @@ +import { classBound } from "./classBound"; +@classBound export class SuperArray extends Array { constructor(...args){ diff --git a/tests/simple/ts-expected/SuperHoistingTest.ts b/tests/simple/ts-expected/SuperHoistingTest.ts index adf40ae..e2ec42b 100755 --- a/tests/simple/ts-expected/SuperHoistingTest.ts +++ b/tests/simple/ts-expected/SuperHoistingTest.ts @@ -1,5 +1,8 @@ import { MyClass } from "./MyClass"; +import { bound } from "./bound"; +import { classBound } from "./classBound"; +@classBound export class SuperHoistingTest extends MyClass { constructor(){ @@ -7,7 +10,8 @@ export class SuperHoistingTest extends MyClass } - /*override*/ protected myFunc = (value:number):number => + @bound + /*override*/ protected myFunc(value:number):number { return super.myFunc(value) * 3; } @@ -30,7 +34,8 @@ class MyClass{ { this.myVar2 = 13; } - protected myFunc = (value:number):number => + @bound + protected myFunc(value:number):number { return value * 10; } diff --git a/tests/simple/ts-expected/Trace.ts b/tests/simple/ts-expected/Trace.ts index 7a44289..83537c5 100755 --- a/tests/simple/ts-expected/Trace.ts +++ b/tests/simple/ts-expected/Trace.ts @@ -1,4 +1,6 @@ - export class Trace { +import { classBound } from "./classBound"; + @classBound + export class Trace { constructor(){ console.log("hello!"); console.log("tracing 1, 2, 3..."); @@ -7,4 +9,4 @@ } } -new Trace() \ No newline at end of file +new Trace(); \ No newline at end of file diff --git a/tests/simple/ts-expected/Unreachable.ts b/tests/simple/ts-expected/Unreachable.ts index 20dd731..b2213a8 100755 --- a/tests/simple/ts-expected/Unreachable.ts +++ b/tests/simple/ts-expected/Unreachable.ts @@ -1,11 +1,15 @@ +import { bound } from "./bound"; +import { classBound } from "./classBound"; /** * Created by palebluedot on 5/3/17. */ +@classBound export class Unreachable { constructor(){ this.demonstrate(); } - public demonstrate = ():number => { + @bound + public demonstrate():number { var tPow:number = 1; var tExp:number = 1; diff --git a/tests/simple/ts-generated/AClassNameWithNumer3InIt.ts b/tests/simple/ts-generated/AClassNameWithNumer3InIt.ts index 3637838..4dc2c55 100755 --- a/tests/simple/ts-generated/AClassNameWithNumer3InIt.ts +++ b/tests/simple/ts-generated/AClassNameWithNumer3InIt.ts @@ -1,6 +1,8 @@ +import { classBound } from "./classBound"; /** * Created by palebluedot on 4/25/17. */ +@classBound export class AClassNameWithNumer3InIt { constructor(){ } diff --git a/tests/simple/ts-generated/Callbacks.ts b/tests/simple/ts-generated/Callbacks.ts index 376e51d..bd347bc 100755 --- a/tests/simple/ts-generated/Callbacks.ts +++ b/tests/simple/ts-generated/Callbacks.ts @@ -1,4 +1,6 @@ -import { bound } from "as3-to-ts/src/bound"; +import { bound } from "./bound"; +import { classBound } from "./classBound"; +@classBound export class Callbacks { public a:string = "a" @@ -15,16 +17,16 @@ export class Callbacks { } @bound -private callback():void { + private callback():void { console.log("(class callback) this is: " + this); if(this) { console.log("a is: " + this.a) } else { console.log("a is: unknown") } } @bound -private executeCallback(callback:Function):void { + private executeCallback(callback:Function):void { callback(); } } -new Callbacks() \ No newline at end of file +new Callbacks(); \ No newline at end of file diff --git a/tests/simple/ts-generated/Casting.ts b/tests/simple/ts-generated/Casting.ts index 459bdb3..f9eae46 100755 --- a/tests/simple/ts-generated/Casting.ts +++ b/tests/simple/ts-generated/Casting.ts @@ -1,4 +1,6 @@ -import { bound } from "as3-to-ts/src/bound"; +import { bound } from "./bound"; +import { classBound } from "./classBound"; +@classBound export class Casting { constructor(){ @@ -36,9 +38,9 @@ export class Casting { } @bound -private thisMethodIsInTheClassScope(str:string) { + private thisMethodIsInTheClassScope(str:string) { console.log(str); } } -new Casting() \ No newline at end of file +new Casting(); \ No newline at end of file diff --git a/tests/simple/ts-generated/ClassMember.ts b/tests/simple/ts-generated/ClassMember.ts index d9c94ab..8f6ce9e 100755 --- a/tests/simple/ts-generated/ClassMember.ts +++ b/tests/simple/ts-generated/ClassMember.ts @@ -1,4 +1,6 @@ +import { classBound } from "./classBound"; +@classBound export class ClassMember { public myVar:number = 100; diff --git a/tests/simple/ts-generated/DebugClass.ts b/tests/simple/ts-generated/DebugClass.ts index fd8f7ae..d662f37 100755 --- a/tests/simple/ts-generated/DebugClass.ts +++ b/tests/simple/ts-generated/DebugClass.ts @@ -1,5 +1,4 @@ -import { classBound } from "undefinedclassBound"; - +import { classBound } from "./classBound"; @classBound export class DebugClass { diff --git a/tests/simple/ts-generated/DynamicCasting.ts b/tests/simple/ts-generated/DynamicCasting.ts index 803fa77..5a38f59 100644 --- a/tests/simple/ts-generated/DynamicCasting.ts +++ b/tests/simple/ts-generated/DynamicCasting.ts @@ -1,5 +1,7 @@ import { DebugClass } from "./DebugClass"; +import { classBound } from "./classBound"; +@classBound export class DynamicCasting { constructor(){ diff --git a/tests/simple/ts-generated/DynamicClass.ts b/tests/simple/ts-generated/DynamicClass.ts index 24647d0..44b82d0 100755 --- a/tests/simple/ts-generated/DynamicClass.ts +++ b/tests/simple/ts-generated/DynamicClass.ts @@ -1,5 +1,7 @@ import { SubDynamicClass } from "./SubDynamicClass"; +import { classBound } from "./classBound"; + @classBound export class DynamicClass { constructor(){ @@ -9,6 +11,7 @@ import { SubDynamicClass } from "./SubDynamicClass"; } } + @classBound export class SubDynamicClass{ } diff --git a/tests/simple/ts-generated/ForEach.ts b/tests/simple/ts-generated/ForEach.ts index be9963f..89383f9 100755 --- a/tests/simple/ts-generated/ForEach.ts +++ b/tests/simple/ts-generated/ForEach.ts @@ -1,6 +1,9 @@ +import { classBound } from "./classBound"; /** * Created by palebluedot on 4/24/17. */ + +@classBound export class ForEach { constructor(){ @@ -44,4 +47,4 @@ export class ForEach { // } // } -new ForEach() \ No newline at end of file +new ForEach(); \ No newline at end of file diff --git a/tests/simple/ts-generated/ForEachClassMapping.ts b/tests/simple/ts-generated/ForEachClassMapping.ts index 0fd3c47..f464f5b 100755 --- a/tests/simple/ts-generated/ForEachClassMapping.ts +++ b/tests/simple/ts-generated/ForEachClassMapping.ts @@ -1,6 +1,8 @@ import { MappedClass } from "./MappedClass"; -import { bound } from "as3-to-ts/src/bound"; +import { classBound } from "./classBound"; +import { bound } from "./bound"; +@classBound export class ForEachClassMapping { constructor(){ @@ -31,7 +33,7 @@ class MappedClass } @bound -public toString():string + public toString():string { return this.value; } diff --git a/tests/simple/ts-generated/ForEachSimple.ts b/tests/simple/ts-generated/ForEachSimple.ts index a65bccd..6ab8a98 100755 --- a/tests/simple/ts-generated/ForEachSimple.ts +++ b/tests/simple/ts-generated/ForEachSimple.ts @@ -1,4 +1,6 @@ +import { classBound } from "./classBound";  +@classBound export class ForEachSimple { constructor(){ diff --git a/tests/simple/ts-generated/GetSet.ts b/tests/simple/ts-generated/GetSet.ts index 4cfcd6a..42769fb 100644 --- a/tests/simple/ts-generated/GetSet.ts +++ b/tests/simple/ts-generated/GetSet.ts @@ -1,4 +1,6 @@ - export class GetSet { +import { classBound } from "./classBound"; + @classBound + export class GetSet { constructor(){ diff --git a/tests/simple/ts-generated/InterfaceTest.ts b/tests/simple/ts-generated/InterfaceTest.ts index 24238e8..7fa32a2 100755 --- a/tests/simple/ts-generated/InterfaceTest.ts +++ b/tests/simple/ts-generated/InterfaceTest.ts @@ -1,5 +1,7 @@ -import { bound } from "as3-to-ts/src/bound"; +import { classBound } from "./classBound"; +import { bound } from "./bound"; +@classBound export class InterfaceTest { constructor(){ @@ -14,11 +16,10 @@ interface myInterface{ } class MyClass implements myInterface{ - static __interfaces__; + static __interfaces__ = ["myInterface"]; @bound public myFunc(value:number):number { return 10 } -} -MyClass.__interfaces__ = ["myInterface"]; \ No newline at end of file +} \ No newline at end of file diff --git a/tests/simple/ts-generated/LoopImport.ts b/tests/simple/ts-generated/LoopImport.ts index bf59b10..8780c8f 100755 --- a/tests/simple/ts-generated/LoopImport.ts +++ b/tests/simple/ts-generated/LoopImport.ts @@ -1,5 +1,7 @@ import { SubClass } from "./SubClass"; +import { classBound } from "./classBound"; +@classBound export class LoopImport { constructor(){ diff --git a/tests/simple/ts-generated/MemberAccessors.ts b/tests/simple/ts-generated/MemberAccessors.ts index 845958b..2f6a6d3 100755 --- a/tests/simple/ts-generated/MemberAccessors.ts +++ b/tests/simple/ts-generated/MemberAccessors.ts @@ -1,4 +1,6 @@ -import { bound } from "as3-to-ts/src/bound"; +import { bound } from "./bound"; +import { classBound } from "./classBound"; +@classBound export class Accessors { public memberVar:string = "hello"; @@ -8,7 +10,7 @@ export class Accessors { } @bound -public memberMethod():void { + public memberMethod():void { console.log(this.memberVar); var a:string = "a"; diff --git a/tests/simple/ts-generated/PrimitiveCheck.ts b/tests/simple/ts-generated/PrimitiveCheck.ts index 71d8845..6408f0f 100755 --- a/tests/simple/ts-generated/PrimitiveCheck.ts +++ b/tests/simple/ts-generated/PrimitiveCheck.ts @@ -1,4 +1,6 @@ -import { AS3Utils } from "as3-to-ts/src/AS3Utils"; +import { AS3Utils } from "./AS3Utils"; +import { classBound } from "./classBound"; +@classBound export class PrimitiveCheck { constructor(){ @@ -7,7 +9,7 @@ export class PrimitiveCheck { if(typeof myVar === 'number') { console.log("it's a number"); } if(typeof myVar === 'string') { console.log("it's a string"); } if(typeof myVar === 'boolean') { console.log("it's a boolean"); } - if(AS3Utils.isInstanceOfInterface(myVar, "Object")) { console.log("it's an object"); } + if(myVar instanceof Object) { console.log("it's an object"); } /* Expected TS: diff --git a/tests/simple/ts-generated/Super.ts b/tests/simple/ts-generated/Super.ts index 9244c0b..d31cf1e 100644 --- a/tests/simple/ts-generated/Super.ts +++ b/tests/simple/ts-generated/Super.ts @@ -1,4 +1,7 @@ -import { bound } from "as3-to-ts/src/bound"; +import { bound } from "./bound"; +import { classBound } from "./classBound"; + +@classBound export class Being { public name:string; private _happiness:string; @@ -6,7 +9,7 @@ export class Being { this.doSetHappiness(value); } @bound -public doSetHappiness(value:string):void { + public doSetHappiness(value:string):void { this._happiness = value; } constructor(){ @@ -14,28 +17,30 @@ public doSetHappiness(value:string):void { this.happiness = "low"; } @bound -public be():void { + public be():void { console.log(this.name + " is - hapiness: " + this._happiness); } } +@classBound export class Animal extends Being { constructor(){ super(); this.name = "animal"; } @bound -public move():void { + public move():void { console.log(this.name + ", an animal, moved"); this.breathe(); } @bound -protected breathe():void { + protected breathe():void { console.log(this.name + ", an animal, breathed"); this.be(); } } +@classBound export class Snake extends Animal { constructor(){ super(); @@ -46,7 +51,7 @@ export class Snake extends Animal { this.breathe(); } @bound -/*override*/ public move():void { + /*override*/ public move():void { this.happiness = "high"; super.move(); } diff --git a/tests/simple/ts-generated/SuperArray.ts b/tests/simple/ts-generated/SuperArray.ts index af44953..71650d1 100755 --- a/tests/simple/ts-generated/SuperArray.ts +++ b/tests/simple/ts-generated/SuperArray.ts @@ -1,3 +1,5 @@ +import { classBound } from "./classBound"; +@classBound export class SuperArray extends Array { constructor(...args){ diff --git a/tests/simple/ts-generated/SuperHoistingTest.ts b/tests/simple/ts-generated/SuperHoistingTest.ts index ac3b7e4..e2ec42b 100755 --- a/tests/simple/ts-generated/SuperHoistingTest.ts +++ b/tests/simple/ts-generated/SuperHoistingTest.ts @@ -1,6 +1,8 @@ import { MyClass } from "./MyClass"; -import { bound } from "as3-to-ts/src/bound"; +import { bound } from "./bound"; +import { classBound } from "./classBound"; +@classBound export class SuperHoistingTest extends MyClass { constructor(){ @@ -9,7 +11,7 @@ export class SuperHoistingTest extends MyClass } @bound -/*override*/ protected myFunc(value:number):number + /*override*/ protected myFunc(value:number):number { return super.myFunc(value) * 3; } @@ -33,7 +35,7 @@ class MyClass{ this.myVar2 = 13; } @bound -protected myFunc(value:number):number + protected myFunc(value:number):number { return value * 10; } diff --git a/tests/simple/ts-generated/Trace.ts b/tests/simple/ts-generated/Trace.ts index 7a44289..83537c5 100755 --- a/tests/simple/ts-generated/Trace.ts +++ b/tests/simple/ts-generated/Trace.ts @@ -1,4 +1,6 @@ - export class Trace { +import { classBound } from "./classBound"; + @classBound + export class Trace { constructor(){ console.log("hello!"); console.log("tracing 1, 2, 3..."); @@ -7,4 +9,4 @@ } } -new Trace() \ No newline at end of file +new Trace(); \ No newline at end of file diff --git a/tests/simple/ts-generated/Unreachable.ts b/tests/simple/ts-generated/Unreachable.ts index 261f0f0..b2213a8 100755 --- a/tests/simple/ts-generated/Unreachable.ts +++ b/tests/simple/ts-generated/Unreachable.ts @@ -1,13 +1,15 @@ -import { bound } from "as3-to-ts/src/bound"; +import { bound } from "./bound"; +import { classBound } from "./classBound"; /** * Created by palebluedot on 5/3/17. */ +@classBound export class Unreachable { constructor(){ this.demonstrate(); } @bound -public demonstrate():number { + public demonstrate():number { var tPow:number = 1; var tExp:number = 1; diff --git a/tests/simple/ts-generated/XML.ts b/tests/simple/ts-generated/XML.ts index a67a5c8..c4d5554 100755 --- a/tests/simple/ts-generated/XML.ts +++ b/tests/simple/ts-generated/XML.ts @@ -1,10 +1,12 @@ import { XML, XMLList } from "@as3web/flash"; +import { classBound } from "./classBound"; +@classBound export class XML { constructor(){ var sport:XML = - "\n Basketball\n men\n women\n NBC\n ESPN\n "; + "\r\n Basketball\r\n men\r\n women\r\n NBC\r\n ESPN\r\n "; sport.name["isCool"] = '→'; diff --git a/tests/simple/ts-generated/XMLListTest.ts b/tests/simple/ts-generated/XMLListTest.ts index 21fc8dd..7e80355 100644 --- a/tests/simple/ts-generated/XMLListTest.ts +++ b/tests/simple/ts-generated/XMLListTest.ts @@ -1,4 +1,6 @@ +import { classBound } from "./classBound"; +@classBound export class XMLListTest { constructor(){ diff --git a/utils/classBound.ts b/utils/classBound.ts index 69132db..9241082 100755 --- a/utils/classBound.ts +++ b/utils/classBound.ts @@ -27,7 +27,11 @@ export function classBound(target: any) { f.prototype = original.prototype; - for (var p in original) if (original.hasOwnProperty(p)) f[p] = original[p]; + for (var p in original) { + if (original.hasOwnProperty(p)) { + f[p] = original[p]; + } + } return f; }