浏览代码

run on C++, mostly

Simon Krajewski 1 年之前
父节点
当前提交
e09e259e00

+ 3 - 0
std/haxe/coro/Coroutine.hx

@@ -11,6 +11,9 @@ abstract Coroutine<T:haxe.Constraints.Function> {
 		for resuming coroutine execution.
 	**/
 	@:coroutine
+	#if cpp
+	@:native("::hx::Coroutine::suspend")
+	#end
 	public static extern function suspend<T>(f:(cont:Continuation<T, Null<Dynamic>>)->Void):T;
 
 	#if (jvm || eval)

+ 2 - 0
tests/misc/coroutines/build-cpp.hxml

@@ -0,0 +1,2 @@
+build-base.hxml
+--cpp bin/cpp

+ 2 - 0
tests/misc/coroutines/src/TestControlFlow.hx

@@ -89,6 +89,7 @@ class TestControlFlow extends utest.Test {
 		});
 	}
 
+	#if !cpp
 	function testTryCatch(async:Async) {
 		mapCalls.start([new E1(), new E2()], tryCatch, (result,error) -> {
 			Assert.same(["e1", "e2"], result);
@@ -113,6 +114,7 @@ class TestControlFlow extends utest.Test {
 		}
 		return "none";
 	}
+	#end
 }
 
 @:coroutine

+ 4 - 0
tests/runci/targets/Cpp.hx

@@ -73,6 +73,10 @@ class Cpp {
 				runCpp("bin/cppia/Host-debug", ["bin/unit.cppia", "-jit"]);
 		}
 
+		changeDirectory(getMiscSubDir("coroutines"));
+		runCommand("haxe", ["build-cpp.hxml"]);
+		runCpp("bin/cpp/Main-debug.exe");
+
 		changeDirectory(sysDir);
 		runCommand("haxe", ["-D", archFlag, "--each", "compile-cpp.hxml"].concat(args));
 		runSysTest(FileSystem.fullPath("bin/cpp/Main-debug"));