Permalink
Browse files

Haxe3 fixes for smoke.jeash.com, a few browser.* and samples.

  • Loading branch information...
andyli committed Mar 16, 2013
1 parent decd4b3 commit 803704b13f9d985e1ea3b8136e74516efc08e083
Showing with 122 additions and 94 deletions.
  1. +4 −0 browser/media/Video.hx
  2. +1 −1 browser/net/NetStream.hx
  3. +1 −1 samples/01-Simple/compile-swf.hxml
  4. +1 −1 samples/03-Bitmaps/flash.hxml
  5. +1 −1 samples/04-Text/compile_swf.hxml
  6. +1 −1 samples/05-CacheAsBitmap/flash.hxml
  7. +0 −2 samples/PiratePig/project.nmml
  8. +1 −1 tools/command-line-simple/flash/hxml/debug.hxml
  9. +1 −1 tools/command-line-simple/flash/hxml/release.hxml
  10. +3 −1 tools/smoke.jeash.com/display/DisplayAddChildTransform.hx
  11. +3 −2 tools/smoke.jeash.com/display/DisplayObjectContainerZIndex.hx
  12. +3 −1 tools/smoke.jeash.com/display/SimpleButtonTest.hx
  13. +3 −1 tools/smoke.jeash.com/display/VisibilityTest.hx
  14. +1 −1 tools/smoke.jeash.com/display/makefile
  15. +4 −1 tools/smoke.jeash.com/events/KeyCodeTest.hx
  16. +3 −1 tools/smoke.jeash.com/events/MouseEnabled.hx
  17. +3 −1 tools/smoke.jeash.com/events/MouseRollOver.hx
  18. +2 −2 tools/smoke.jeash.com/events/makefile
  19. +3 −1 tools/smoke.jeash.com/interop/OneWayBinding.hx
  20. +1 −1 tools/smoke.jeash.com/media/makefile
  21. +3 −1 tools/smoke.jeash.com/net/GetUrl.hx
  22. +3 −1 tools/smoke.jeash.com/net/GetUrlBinary.hx
  23. +3 −1 tools/smoke.jeash.com/net/LoadFromBytesJpg.hx
  24. +3 −1 tools/smoke.jeash.com/net/PostUrl.hx
  25. +1 −1 tools/smoke.jeash.com/net/makefile
  26. +1 −1 tools/smoke.jeash.com/phantomjs/PhantomJs.hx
  27. +25 −27 tools/smoke.jeash.com/phantomjs/PhantomSuiteRunner.hx
  28. +1 −2 tools/smoke.jeash.com/phantomjs/PhantomSuiteRunner.hxml
  29. +3 −1 tools/smoke.jeash.com/text/BasicTextField.hx
  30. +3 −1 tools/smoke.jeash.com/text/DoubleCenteredTextField.hx
  31. +3 −1 tools/smoke.jeash.com/text/TextFieldBorderAndBackground.hx
  32. +1 −1 tools/smoke.jeash.com/text/makefile
  33. +1 −1 tools/smoke.jeash.com/utils/makefile
  34. +24 −24 tools/smoke.jeash.com/zjnue/scrolltest/src/pack/cross/components/scroller/model/ScrollModel.hx
  35. +1 −1 tools/smoke.jeash.com/zjnue/scrolltest/src/pack/flash/components/scroller/view/RangeScroller.hx
  36. +5 −5 tools/smoke.jeash.com/zjnue/scrolltest/src/pack/flash/components/scroller/view/Scroller.hx
  37. +1 −2 tools/welcome/Welcome.hxml
View
@@ -15,7 +15,11 @@ import browser.media.VideoElement;
import browser.net.NetStream;
import browser.Html5Dom;
import browser.Lib;
+#if !haxe3
import js.Dom;
+#else
+import js.html.*;
+#end
class Video extends DisplayObject {
View
@@ -57,7 +57,7 @@ class NetStream extends EventDispatcher {
super();
- nmeVideoElement = cast js.Lib.document.createElement("video");
+ nmeVideoElement = cast #if !haxe3 js.Lib.document #else js.Browser.document #end .createElement("video");
nmeConnection = connection;
play = Reflect.makeVarArgs(nmePlay);
@@ -1,3 +1,3 @@
-main Sample
--swf9 Sample.swf
+-swf Sample.swf
-swf-header 320:480:60:ccccff
@@ -1,4 +1,4 @@
-main Sample
--swf9 Sample.swf
+-swf Sample.swf
-swf-header 480:320:30:ffffff
-cp ../..
@@ -1,4 +1,4 @@
--swf9 Sample.swf
+-swf Sample.swf
-main Sample
-swf-header 640:640:24:ffffff
-cp ..
@@ -1,3 +1,3 @@
-main Sample
--swf9 Sample.swf
+-swf Sample.swf
-swf-header 320:480:60:ccccff
@@ -38,6 +38,4 @@
<certificate path="path/to/author.p12" if="blackberry" />
</section>
- <haxeflag name="--dead-code-elimination" if="html5" />
-
</project>
@@ -1,6 +1,6 @@
-main ApplicationMain ::HAXE_FLAGS::
-swf-version ::SWF_VERSION::
--swf9 ::BUILD_DIR::/flash/bin/::APP_FILE::.swf
+-swf ::BUILD_DIR::/flash/bin/::APP_FILE::.swf
-swf-header ::WIN_WIDTH:::::WIN_HEIGHT:::::WIN_FPS:::::WIN_FLASHBACKGROUND::
-cp ::BUILD_DIR::/flash/haxe
-D fdb
@@ -1,5 +1,5 @@
-main ApplicationMain ::HAXE_FLAGS::
-swf-version ::SWF_VERSION::
--swf9 ::BUILD_DIR::/flash/bin/::APP_FILE::.swf
+-swf ::BUILD_DIR::/flash/bin/::APP_FILE::.swf
-swf-header ::WIN_WIDTH:::::WIN_HEIGHT:::::WIN_FPS:::::WIN_FLASHBACKGROUND::
-cp ::BUILD_DIR::/flash/haxe
@@ -11,7 +11,9 @@ class DisplayAddChildTransform extends Sprite {
private var _mcMess:Sprite;
- static function main () flash.Lib.current.addChild(new DisplayAddChildTransform())
+ static function main () {
+ flash.Lib.current.addChild(new DisplayAddChildTransform());
+ }
public function new () {
@@ -18,6 +18,7 @@ class DisplayObjectContainerZIndex extends Sprite {
s1.addChild(s1a);
}
- static function main ()
- Lib.current.addChild(new DisplayObjectContainerZIndex())
+ static function main () {
+ Lib.current.addChild(new DisplayObjectContainerZIndex());
+ }
}
@@ -11,7 +11,9 @@ class SimpleButtonTest extends Sprite {
var button:CustomSimpleButton = new CustomSimpleButton();
addChild(button);
}
- static function main () Lib.current.addChild(new SimpleButtonTest())
+ static function main () {
+ Lib.current.addChild(new SimpleButtonTest());
+ }
}
class CustomSimpleButton extends SimpleButton {
@@ -39,6 +39,8 @@ class VisibilityTest extends Sprite {
}
- static function main () Lib.current.stage.addChild(new VisibilityTest())
+ static function main () {
+ Lib.current.stage.addChild(new VisibilityTest());
+ }
}
@@ -10,7 +10,7 @@ all: $(JS) $(SWF) $(HTML)
haxe -debug -js $*.js -cp ../../../ --remap flash:browser -main $*
%.swf: %.hx
- haxe -cp ~/projects/stax/src/main/haxe -swf-header 400:400:8:ffffff -swf9 $*.swf -main $*
+ haxe -cp ~/projects/stax/src/main/haxe -swf-header 400:400:8:ffffff -swf $*.swf -main $*
%.html: %.hx
xsltproc --stringparam jsfile "$*.js" -o $*.html template.xsl main.xml
@@ -2,7 +2,10 @@ import flash.events.KeyboardEvent;
import flash.Lib;
class KeyCodeTest {
- static function main () new KeyCodeTest()
+ static function main () {
+ new KeyCodeTest();
+ }
+
public function new () {
Lib.current.stage.addEventListener(KeyboardEvent.KEY_DOWN, keyPress);
}
@@ -26,5 +26,7 @@ class MouseEnabled extends Sprite
#if js untyped window.phantomTestResult = true; #end
}
- static function main () Lib.current.stage.addChild(new MouseEnabled())
+ static function main () {
+ Lib.current.stage.addChild(new MouseEnabled());
+ }
}
@@ -3,7 +3,9 @@ import flash.events.MouseEvent;
import flash.Lib;
class MouseRollOver {
- static function main () new MouseRollOver()
+ static function main () {
+ new MouseRollOver();
+ }
public function new () {
var s = new Sprite();
@@ -5,10 +5,10 @@ HTML := $(patsubst %.hx,%.html,$(wildcard *.hx))
all: $(JS) $(SWF) $(HTML)
%.js: %.hx
- haxe -js $*.js -cp ../../../ --dead-code-elimination --remap flash:browser -main $*
+ haxe -js $*.js -cp ../../../ --remap flash:browser -main $*
%.swf: %.hx
- haxe -swf-header 400:400:8:ffffff -swf9 $*.swf -main $*
+ haxe -swf-header 400:400:8:ffffff -swf $*.swf -main $*
%.html: %.hx
xsltproc --stringparam jsfile "$*.js" -o $*.html template.xsl main.xml
@@ -4,7 +4,9 @@ import flash.Lib;
class OneWayBinding {
- static function main () new OneWayBinding()
+ static function main () {
+ new OneWayBinding();
+ }
public function new () {
var s = new Sprite();
@@ -10,7 +10,7 @@ all: $(JS) $(SWF) $(HTML)
haxe -debug -js $*.js -cp ../../../ --remap flash:browser -main $*
%.swf: %.hx
- haxe -cp ~/projects/stax/src/main/haxe -swf-header 400:400:8:ffffff -swf9 $*.swf -main $*
+ haxe -cp ~/projects/stax/src/main/haxe -swf-header 400:400:8:ffffff -swf $*.swf -main $*
%.html: %.hx
xsltproc --stringparam jsfile "$*.js" -o $*.html template.xsl main.xml
@@ -34,6 +34,8 @@ class GetUrl {
#if js untyped window.phantomTestResult = tgt.data; #end
}
- static function main () new GetUrl()
+ static function main () {
+ new GetUrl();
+ }
}
@@ -38,5 +38,7 @@ class GetUrlBinary {
#end
}
- static function main () new GetUrlBinary()
+ static function main () {
+ new GetUrlBinary();
+ }
}
@@ -38,6 +38,8 @@ class LoadFromBytesJpg {
#end
}
- static function main () new LoadFromBytesJpg()
+ static function main () {
+ new LoadFromBytesJpg();
+ }
}
@@ -68,5 +68,7 @@ class PostUrl extends Sprite {
Lib.trace(event);
}
- static function main () Lib.current.addChild(new PostUrl())
+ static function main () {
+ Lib.current.addChild(new PostUrl());
+ }
}
@@ -10,7 +10,7 @@ all: $(JS) $(SWF) $(HTML)
haxe -debug -js $*.js -cp ../../../ --remap flash:browser -main $*
%.swf: %.hx
- haxe -swf-header 400:400:8:ffffff -swf9 $*.swf -main $*
+ haxe -swf-header 400:400:8:ffffff -swf $*.swf -main $*
%.html: %.hx
xsltproc --stringparam jsfile "$*.js" -o $*.html template.xsl main.xml
@@ -12,7 +12,7 @@ extern class WebPage {
function release():Void;
function render(fileName:String):Void;
function renderBase64(format:String):String;
- @:overload (function (type:String, key:Int):Void {})
+ @:overload(function (type:String, key:Int):Void {})
function sendEvent(type:String, x:Int, y:Int):Void;
function uploadFile(selector:String, fileName:String):Void;
dynamic function onAlert(msg:String):Void;
@@ -12,9 +12,6 @@ import utest.ui.text.PrintReport;
using haxe.io.Path;
-using tink.macro.tools.MacroTools;
-using tink.core.types.Outcome;
-
using Lambda;
using Std;
using StringTools;
@@ -76,7 +73,7 @@ class PhantomSuiteRunner {
trace("-- done -- " + address);
}, ASYNC_WAIT );
- trace("Loading ${address}".format());
+ trace('Loading ${address}');
page.open(address, executeAfterPageLoad(async));
}
@@ -88,25 +85,25 @@ class PhantomSuiteRunner {
cb();
}
- public static function stringTest(expected: String) return function (page) stringTestPage(page, expected)
+ public static function stringTest(expected: String) {return function (page) stringTestPage(page, expected);}
public static function stringTestPage(page: WebPage, expected: String) {
Assert.equals(expected, page.evaluate(function () return untyped window.phantomTestResult));
}
- public static function boolTest() return function (page) boolTestPage(page)
+ public static function boolTest() {return function (page) boolTestPage(page);}
public static function boolTestPage(page: WebPage) {
#if js
Assert.isTrue(page.evaluate(function () return untyped window.phantomTestResult));
#end
}
- public static function intTest(expected: Int) return function (page) intTestPage(page, expected)
+ public static function intTest(expected: Int) {return function (page) intTestPage(page, expected);}
public static function intTestPage(page: WebPage, expected: Int) {
Assert.equals(expected, page.evaluate(function () return untyped window.phantomTestResult));
}
- public static function arrayTest(expected: Array<Dynamic>) return function (page) arrayTestPage(page, expected)
+ public static function arrayTest(expected: Array<Dynamic>) {return function (page) arrayTestPage(page, expected);}
public static function arrayTestPage(page: WebPage, expected: Array<Dynamic>) {
Assert.same(expected, page.evaluate(function () return untyped window.phantomTestResult));
}
- public static function imageTest(imageFileName: String) return function (page) imageTestPage(page, imageFileName)
+ public static function imageTest(imageFileName: String) {return function (page) imageTestPage(page, imageFileName);}
public static function imageTestPage(page: WebPage, imageFileName: String) {
#if js
var compareFileName = "/" + imageFileName.withoutDirectory().withoutExtension() + "_compare.png";
@@ -116,37 +113,37 @@ class PhantomSuiteRunner {
#end
}
- public static function imageDump(imageFileName: String) return function (page) imageDumpPage(page, imageFileName)
+ public static function imageDump(imageFileName: String) {return function (page) imageDumpPage(page, imageFileName);}
public static function imageDumpPage(page: WebPage, imageFileName: String) {
#if js
page.render(ROOT_PATH + imageFileName);
#end
}
- public static function sendMouseEvent(eventType: String, coords: Array<Int>) return function (page) sendMouseEventPage(page, eventType, coords)
+ public static function sendMouseEvent(eventType: String, coords: Array<Int>) {return function (page) sendMouseEventPage(page, eventType, coords);}
public static function sendMouseEventPage(page: WebPage, eventType: String, coords: Array<Int>) {
trace("sending event " + eventType + " to page at x,y = " + coords);
#if js
page.sendEvent(eventType, coords[0], coords[1]);
#end
}
- public static function sendKeyboardEvent(eventType: String, keys: Array<Int>) return function (page) sendKeyboardEventPage(page, eventType, keys)
+ public static function sendKeyboardEvent(eventType: String, keys: Array<Int>) {return function (page) sendKeyboardEventPage(page, eventType, keys);}
public static function sendKeyboardEventPage(page: WebPage, eventType: String, keys: Array<Int>) {
trace("sending event " + eventType + " to page with keys = " + keys);
#if js
keys.map(function (key) page.sendEvent(eventType, key));
#end
}
- @:macro public static function rootPath() {
+ macro public static function rootPath() {
#if neko
- return sys.FileSystem.fullPath(Sys.getCwd() + "/../").toExpr();
+ return macro $v{sys.FileSystem.fullPath(Sys.getCwd() + "/../")};
#end
}
#if macro
- @:macro public static function build () : Array<Field> {
+ macro public static function build () : Array<Field> {
var fields = [];
for (spec in findSpecs(ROOT_PATH, []))
for (test in PhantomSuiteRunner.loadSpec(spec))
@@ -169,52 +166,53 @@ class PhantomSuiteRunner {
var p = Context.makePosition({min: 0, max: 0, file: fileName });
var spec : TestSpec = try Json.parse(content) catch ( e : Dynamic ) Context.error(Std.string(e), p);
- var url = BASE_URL + if (spec.target != null) basename.directory() + '/' + spec.target; else basename + ".html";
+ var url = BASE_URL + if (spec.target != null) basename.directory() + '/' + spec.target; else basename + ".html";
var fields = Context.getBuildFields();
var block = [];
if (spec.events != null) {
spec.events.map(function (s)
if (s.eventType != null && Std.is(s.coords, Array)) {
if (s.eventType.startsWith("key")) {
- block.push("PhantomSuiteRunner.sendKeyboardEvent".resolve().call([s.eventType.toExpr(), s.coords.toExpr()]));
+ block.push(macro PhantomSuiteRunner.sendKeyboardEvent($v{s.eventType}, $v{s.coords}));
} else {
- block.push("PhantomSuiteRunner.sendMouseEvent".resolve().call([s.eventType.toExpr(), s.coords.toExpr()]));
+ block.push(macro PhantomSuiteRunner.sendMouseEvent($v{s.eventType}, $v{s.coords}));
}
} else {
Context.error(s + " should have attribute 'eventType' and array 'coords'", p);
}
);
}
+
block.push(switch (spec.testType) {
case "STRING":
var expected = spec.assrt;
- "PhantomSuiteRunner.stringTest".resolve().call([expected.toExpr()]);
+ macro PhantomSuiteRunner.stringTest($v{expected});
case "BOOL":
- "PhantomSuiteRunner.boolTest".resolve().call([]);
+ macro PhantomSuiteRunner.boolTest();
case "INT":
var expected = spec.assrt;
- "PhantomSuiteRunner.intTest".resolve().call([expected.toExpr()]);
+ macro PhantomSuiteRunner.intTest($v{expected});
case "ARRAY":
var expected = spec.assrt;
- "PhantomSuiteRunner.arrayTest".resolve().call([expected.toExpr()]);
+ macro PhantomSuiteRunner.arrayTest($v{expected});
case "IMAGE":
var img = (basename + ".png");
if (sys.FileSystem.exists(ROOT_PATH + img)) {
- "PhantomSuiteRunner.imageTest".resolve().call([img.toExpr()]);
+ macro PhantomSuiteRunner.imageTest($v{img});
} else {
- "PhantomSuiteRunner.imageDump".resolve().call([img.toExpr()]);
-
+ macro PhantomSuiteRunner.imageDump($v{img});
}
default: Context.error(fileName + " should have a valid testType attribute", p);
});
- var test = "PhantomSuiteRunner.loadPage".resolve().call([url.toExpr(), block.toArray()]);
- fields.push({ name : "test" + basename.withoutDirectory(), doc: null, meta: [], access : [APublic], kind: FFun(test.func()), pos : p });
+ var test = macro function() PhantomSuiteRunner.loadPage($v{url}, $a{block});
+ var testFunc = switch(test.expr){ case EFunction(_, f): f; case _: throw "test is not a function"; }
+ fields.push({ name : "test" + basename.withoutDirectory(), doc: null, meta: [], access : [APublic], kind: FFun(testFunc), pos : Context.currentPos() });
return fields;
}
Oops, something went wrong.

0 comments on commit 803704b

Please sign in to comment.