diff --git a/src/generators/cpp/gen/cppCppia.ml b/src/generators/cpp/gen/cppCppia.ml index 2ef8a64d948..d4967163c88 100644 --- a/src/generators/cpp/gen/cppCppia.ml +++ b/src/generators/cpp/gen/cppCppia.ml @@ -7,7 +7,7 @@ open CppAst open CppAstTools open CppContext -type script_type = +type script_type = | ScriptBool | ScriptInt | ScriptFloat @@ -413,7 +413,7 @@ let is_extern_class_instance obj = let rec is_dynamic_in_cpp ctx expr = let expr_type = type_string - (match follow expr.etype with TFun (args, ret) -> ret | _ -> expr.etype) + (match follow_with_coro expr.etype with Coro (args, ret) | NotCoro TFun (args, ret) -> ret | _ -> expr.etype) in if expr_type = "Dynamic" || expr_type = "cpp::ArrayBase" then true else @@ -454,8 +454,8 @@ let rec is_dynamic_in_cpp ctx expr = in if is_IaCall then true else - match follow func.etype with - | TFun (args, ret) -> is_dynamic_in_cpp ctx func + match follow_with_coro func.etype with + | Coro _ | NotCoro TFun _ -> is_dynamic_in_cpp ctx func | _ -> true) | TParenthesis expr | TMeta (_, expr) -> is_dynamic_in_cpp ctx expr | TCast (e, None) -> type_string expr.etype = "Dynamic" @@ -1087,8 +1087,8 @@ class script_writer ctx filename asciiOut = this#write (this#op IaCall ^ argN ^ "\n"); this#gen_expression func); let matched_args = - match func.etype with - | TFun (args, _) -> ( + match follow_with_coro func.etype with + | Coro (args, _) | NotCoro TFun (args, _) -> ( try List.iter2 (fun (_, _, protoT) arg -> @@ -1814,10 +1814,21 @@ let generate_script_class common_ctx script class_def = ^ "\n"); let generate_field isStatic field = - match (field.cf_kind, follow field.cf_type) with - | Var { v_read = AccInline; v_write = AccNever }, _ -> + let unknown() = + print_endline + ("Unknown method type " + ^ join_class_path class_def.cl_path "." + ^ "." ^ field.cf_name) + in + let map_args_ret f = match follow_with_coro field.cf_type with + | Coro(args,ret) -> f args ret + | NotCoro (TFun(args,ret)) -> f args ret + | _ -> unknown () + in + match field.cf_kind with + | Var { v_read = AccInline; v_write = AccNever } -> script#writeOpLine IaInline - | Var v, _ -> + | Var v-> let mode_code mode = match mode with | AccNormal | AccCtor -> IaAccessNormal @@ -1836,23 +1847,24 @@ let generate_script_class common_ctx script class_def = let isExtern = not (is_physical_field field) in script#var (mode_code v.v_read) (mode_code v.v_write) isExtern isStatic field.cf_name field.cf_type field.cf_expr - | Method MethDynamic, TFun (args, ret) -> - script#func isStatic true field.cf_name ret args - (has_class_flag class_def CInterface) - field.cf_expr field.cf_pos - | Method _, TFun (args, ret) when field.cf_name = "new" -> - script#func true false "new" - (TInst (class_def, [])) - args false field.cf_expr field.cf_pos - | Method _, TFun (args, ret) -> - script#func isStatic false field.cf_name ret args - (has_class_flag class_def CInterface) - field.cf_expr field.cf_pos - | Method _, _ -> - print_endline - ("Unknown method type " - ^ join_class_path class_def.cl_path "." - ^ "." ^ field.cf_name) + | Method MethDynamic -> + map_args_ret (fun args ret -> + script#func isStatic true field.cf_name ret args + (has_class_flag class_def CInterface) + field.cf_expr field.cf_pos + ) + | Method _ when field.cf_name = "new" -> + map_args_ret (fun args ret -> + script#func true false "new" + (TInst (class_def, [])) + args false field.cf_expr field.cf_pos + ) + | Method _ -> + map_args_ret (fun args ret -> + script#func isStatic false field.cf_name ret args + (has_class_flag class_def CInterface) + field.cf_expr field.cf_pos + ) in (match class_def.cl_constructor with | Some field -> generate_field true field diff --git a/std/cpp/cppia/HostClasses.hx b/std/cpp/cppia/HostClasses.hx index 3a71f0ee563..45df76e3d7c 100644 --- a/std/cpp/cppia/HostClasses.hx +++ b/std/cpp/cppia/HostClasses.hx @@ -123,6 +123,7 @@ class HostClasses { "haxe.Int64", "haxe.Int32", "haxe.Serializer", + "haxe.Timer", "haxe.Unserializer", "haxe.ds.ArraySort", "haxe.ds.GenericStack", @@ -183,7 +184,7 @@ class HostClasses { externs.set("sys.net._Socket.SocketOutput", true); externs.set("sys.ssl._Socket.SocketInput", true); externs.set("sys.ssl._Socket.SocketOutput", true); - externs.set("sys.thread._Thread.HaxeThread",true); + externs.set("sys.thread._Thread.HaxeThread", true); externs.set("haxe.ds.TreeNode", true); externs.set("haxe.xml.XmlParserException", true); for (e in classes) diff --git a/std/haxe/Timer.hx b/std/haxe/Timer.hx index ccf04173aa7..a4c84cee488 100644 --- a/std/haxe/Timer.hx +++ b/std/haxe/Timer.hx @@ -185,7 +185,7 @@ class Timer { * * The precision and epoch of the timer is platform defined. */ - public static inline function milliseconds():Int64 { + public static #if !cppia inline #end function milliseconds():Int64 { #if flash return flash.Lib.getTimer(); #elseif js diff --git a/tests/runci/targets/Cpp.hx b/tests/runci/targets/Cpp.hx index 29884f0e687..c474e720b32 100644 --- a/tests/runci/targets/Cpp.hx +++ b/tests/runci/targets/Cpp.hx @@ -25,7 +25,7 @@ class Cpp { final path = getHaxelibPath("hxcpp"); infoMsg('hxcpp has already been installed in $path.'); } catch(e:Dynamic) { - haxelibInstallGit("HaxeFoundation", "hxcpp", true); + haxelibInstallGit("tobil4sk", "hxcpp", "fix/missing-jit-exception-checks", true); final oldDir = Sys.getCwd(); changeDirectory(getHaxelibPath("hxcpp") + "tools/hxcpp/"); runCommand("haxe", ["-D", "source-header=''", "compile.hxml"]); diff --git a/tests/unit/src/unit/TestMain.hx b/tests/unit/src/unit/TestMain.hx index 8cc773e8283..0242ebc6224 100644 --- a/tests/unit/src/unit/TestMain.hx +++ b/tests/unit/src/unit/TestMain.hx @@ -103,7 +103,7 @@ function main() { new TestFieldVariance(), new TestConstrainedMonomorphs(), new TestDefaultTypeParameters(), - #if (!flash && !hl && !cppia) + #if (!flash && !hl) new TestCoroutines(), #end // new TestUnspecified(),