Browse Source

Merge branch 'development'

Simon Krajewski 8 years ago
parent
commit
890f8c70cf

+ 9 - 0
extra/CHANGES.txt

@@ -1,3 +1,12 @@
+2017-03-20: 3.4.2
+
+	Bugfixes:
+
+	cpp : fixed issue with @:native names being prefixed with :: (#6086)
+	cpp : fixed issue with return type handling (#6103)
+	cpp : fixed inaccurate line numbers that threw off debugging
+	php7 : fixed generation of `[][0]` constructs (#6090)
+
 2017-03-17: 3.4.1
 2017-03-17: 3.4.1
 
 
 	New features:
 	New features:

+ 1 - 1
extra/installer.nsi

@@ -25,7 +25,7 @@
 ; Installer details
 ; Installer details
 VIAddVersionKey "CompanyName" "Haxe Foundation"
 VIAddVersionKey "CompanyName" "Haxe Foundation"
 VIAddVersionKey "ProductName" "Haxe Installer"
 VIAddVersionKey "ProductName" "Haxe Installer"
-VIAddVersionKey "LegalCopyright" "Haxe Foundation 2005-2016"
+VIAddVersionKey "LegalCopyright" "Haxe Foundation 2005-2017"
 VIAddVersionKey "FileDescription" "Haxe Installer"
 VIAddVersionKey "FileDescription" "Haxe Installer"
 VIAddVersionKey "ProductVersion" "${VERSION}.0"
 VIAddVersionKey "ProductVersion" "${VERSION}.0"
 VIAddVersionKey "FileVersion" "${VERSION}.0"
 VIAddVersionKey "FileVersion" "${VERSION}.0"

+ 28 - 18
src/generators/gencpp.ml

@@ -745,7 +745,9 @@ let rec class_string klass suffix params remap =
    (* Normal class *)
    (* Normal class *)
    | path when klass.cl_extern && (not (is_internal_class path) )->
    | path when klass.cl_extern && (not (is_internal_class path) )->
             (join_class_path_remap klass.cl_path "::") ^ suffix
             (join_class_path_remap klass.cl_path "::") ^ suffix
-   | _ -> "::" ^ (join_class_path_remap klass.cl_path "::") ^ suffix
+   | _ ->
+      let globalNamespace = if (get_meta_string klass.cl_meta Meta.Native)<>"" then "" else "::" in
+      globalNamespace ^ (join_class_path_remap klass.cl_path "::") ^ suffix
    )
    )
 and type_string_suff suffix haxe_type remap =
 and type_string_suff suffix haxe_type remap =
    let type_string = type_string_remap remap in
    let type_string = type_string_remap remap in
@@ -1687,7 +1689,8 @@ and tcpp_to_string tcpp =
     tcpp_to_string_suffix "" tcpp
     tcpp_to_string_suffix "" tcpp
 
 
 and cpp_class_path_of klass =
 and cpp_class_path_of klass =
-      " ::" ^ (join_class_path_remap klass.cl_path "::")
+      let globalNamespace = if (get_meta_string klass.cl_meta Meta.Native)<>"" then " " else " ::" in
+      globalNamespace ^ (join_class_path_remap klass.cl_path "::")
 ;;
 ;;
 
 
 
 
@@ -1973,7 +1976,8 @@ let cpp_enum_path_of enum =
       rename
       rename
    else
    else
    *)
    *)
-      "::" ^ (join_class_path_remap enum.e_path "::")
+   let globalNamespace = if (get_meta_string enum.e_meta Meta.Native)<>"" then "" else "::" in
+   globalNamespace ^ (join_class_path_remap enum.e_path "::")
 ;;
 ;;
 
 
 
 
@@ -2013,10 +2017,9 @@ let cpp_class_name klass =
       rename ^ "_obj"
       rename ^ "_obj"
    else
    else
    *)
    *)
-   begin
-      let path = "::" ^ (join_class_path_remap klass.cl_path "::") in
-      if path="::String" then path else path ^ "_obj"
-   end
+   let globalNamespace = if (get_meta_string klass.cl_meta Meta.Native)<>"" then "" else "::" in
+   let path = globalNamespace ^ (join_class_path_remap klass.cl_path "::") in
+   if path="::String" then path else path ^ "_obj"
 ;;
 ;;
 
 
 
 
@@ -2314,7 +2317,7 @@ let is_gc_element ctx member_type =
 
 
 
 
 
 
-let retype_expression ctx request_type function_args expression_tree forInjection =
+let retype_expression ctx request_type function_args function_type expression_tree forInjection =
    let rev_closures = ref [] in
    let rev_closures = ref [] in
    let closureId = ref 0 in
    let closureId = ref 0 in
    let declarations = ref (Hashtbl.create 0) in
    let declarations = ref (Hashtbl.create 0) in
@@ -2972,7 +2975,7 @@ let retype_expression ctx request_type function_args expression_tree forInjectio
             CppTry(cppBlock, cppCatches), TCppVoid
             CppTry(cppBlock, cppCatches), TCppVoid
 
 
          | TReturn eo ->
          | TReturn eo ->
-            CppReturn(match eo with None -> None | Some e -> Some (retype (cpp_type_of e.etype) e)), TCppVoid
+            CppReturn(match eo with None -> None | Some e -> Some (retype (cpp_type_of function_type) e)), TCppVoid
 
 
          | TCast (base,None) -> (* Use auto-cast rules *)
          | TCast (base,None) -> (* Use auto-cast rules *)
             let return_type = cpp_type_of expr.etype in
             let return_type = cpp_type_of expr.etype in
@@ -3030,6 +3033,11 @@ let retype_expression ctx request_type function_args expression_tree forInjectio
       end else if (cppExpr.cpptype=TCppVariant || cppExpr.cpptype=TCppDynamic) then begin
       end else if (cppExpr.cpptype=TCppVariant || cppExpr.cpptype=TCppDynamic) then begin
          match return_type with
          match return_type with
          | TCppUnchanged -> cppExpr
          | TCppUnchanged -> cppExpr
+         | TCppInst(t) when (has_meta_key t.cl_meta Meta.StructAccess) ->
+             let structType = TCppStruct( TCppInst(t) ) in
+             let structCast =  mk_cppexpr (CppCast(cppExpr,structType)) structType in
+             mk_cppexpr (CppCast(structCast,(TCppInst t))) (TCppInst t)
+
          | TCppObjectArray _
          | TCppObjectArray _
          | TCppScalarArray _
          | TCppScalarArray _
          | TCppNativePointer _
          | TCppNativePointer _
@@ -3057,6 +3065,11 @@ let retype_expression ctx request_type function_args expression_tree forInjectio
          | TCppDynamic when cppExpr.cpptype=TCppVariant
          | TCppDynamic when cppExpr.cpptype=TCppVariant
               -> mk_cppexpr (CppCastVariant(cppExpr)) return_type
               -> mk_cppexpr (CppCastVariant(cppExpr)) return_type
 
 
+         | TCppStar(t,const) ->
+             let ptrType = TCppPointer((if const then "ConstPointer" else "Pointer"),t) in
+             let ptrCast =  mk_cppexpr (CppCast(cppExpr,ptrType)) ptrType in
+             mk_cppexpr (CppCast(ptrCast,TCppStar(t,const))) (TCppStar(t,const))
+
          | _ -> cppExpr
          | _ -> cppExpr
       end else match cppExpr.cpptype, return_type with
       end else match cppExpr.cpptype, return_type with
          | _, TCppUnchanged -> cppExpr
          | _, TCppUnchanged -> cppExpr
@@ -3105,10 +3118,7 @@ let retype_expression ctx request_type function_args expression_tree forInjectio
              let ptrType = TCppPointer((if const then "ConstPointer" else "Pointer"),t) in
              let ptrType = TCppPointer((if const then "ConstPointer" else "Pointer"),t) in
              let ptrCast =  mk_cppexpr (CppCast(cppExpr,ptrType)) ptrType in
              let ptrCast =  mk_cppexpr (CppCast(cppExpr,ptrType)) ptrType in
              mk_cppexpr (CppCast(ptrCast,TCppDynamic)) TCppDynamic
              mk_cppexpr (CppCast(ptrCast,TCppDynamic)) TCppDynamic
-         | TCppDynamic, TCppStar(t,const) ->
-             let ptrType = TCppPointer((if const then "ConstPointer" else "Pointer"),t) in
-             let ptrCast =  mk_cppexpr (CppCast(cppExpr,ptrType)) ptrType in
-             mk_cppexpr (CppCast(ptrCast,TCppStar(t,const))) (TCppStar(t,const))
+
 
 
          | TCppStar(t,const), TCppInst _
          | TCppStar(t,const), TCppInst _
          | TCppStar(t,const), TCppStruct _ ->
          | TCppStar(t,const), TCppStruct _ ->
@@ -3211,7 +3221,7 @@ let gen_type ctx haxe_type =
 ;;
 ;;
 
 
 
 
-let gen_cpp_ast_expression_tree ctx class_name func_name function_args injection tree =
+let gen_cpp_ast_expression_tree ctx class_name func_name function_args function_type injection tree =
    let writer = ctx.ctx_writer in
    let writer = ctx.ctx_writer in
    let out = ctx.ctx_output in
    let out = ctx.ctx_output in
    let lastLine = ref (-1) in
    let lastLine = ref (-1) in
@@ -3233,7 +3243,7 @@ let gen_cpp_ast_expression_tree ctx class_name func_name function_args injection
 
 
    let forInjection = match injection with Some inject -> inject.inj_setvar<>"" | _ -> false in
    let forInjection = match injection with Some inject -> inject.inj_setvar<>"" | _ -> false in
 
 
-   let cppTree =  retype_expression ctx TCppVoid function_args tree forInjection in
+   let cppTree =  retype_expression ctx TCppVoid function_args function_type tree forInjection in
    let label_name i = Printf.sprintf "_hx_goto_%i" i in
    let label_name i = Printf.sprintf "_hx_goto_%i" i in
    let class_hash = gen_hash_small 0 class_name in
    let class_hash = gen_hash_small 0 class_name in
 
 
@@ -3244,7 +3254,7 @@ let gen_cpp_ast_expression_tree ctx class_name func_name function_args injection
          List.iter gen_closure closures;
          List.iter gen_closure closures;
          (match injection with Some inject -> inject.inj_prologue gc_stack | _ -> () );
          (match injection with Some inject -> inject.inj_prologue gc_stack | _ -> () );
          let remaining = ref (List.length exprs) in
          let remaining = ref (List.length exprs) in
-         lastLine := -1;
+         lastLine := Lexer.get_error_line tree.epos;
          List.iter (fun e ->
          List.iter (fun e ->
             output_p e "";
             output_p e "";
             if (!remaining=1) then
             if (!remaining=1) then
@@ -4048,7 +4058,7 @@ let gen_cpp_function_body ctx clazz is_static func_name function_def head_code t
    let args = List.map fst function_def.tf_args in
    let args = List.map fst function_def.tf_args in
 
 
    let injection = mk_injection prologue "" tail_code in
    let injection = mk_injection prologue "" tail_code in
-   gen_cpp_ast_expression_tree ctx dot_name func_name args injection (mk_block function_def.tf_expr);
+   gen_cpp_ast_expression_tree ctx dot_name func_name args function_def.tf_type injection (mk_block function_def.tf_expr);
 ;;
 ;;
 
 
 let gen_cpp_init ctx dot_name func_name var_name expr =
 let gen_cpp_init ctx dot_name func_name var_name expr =
@@ -4059,7 +4069,7 @@ let gen_cpp_init ctx dot_name func_name var_name expr =
          hx_stack_push ctx output_i dot_name func_name expr.epos gc_stack;
          hx_stack_push ctx output_i dot_name func_name expr.epos gc_stack;
    in
    in
    let injection = mk_injection prologue var_name "" in
    let injection = mk_injection prologue var_name "" in
-   gen_cpp_ast_expression_tree ctx dot_name func_name [] injection (mk_block expr);
+   gen_cpp_ast_expression_tree ctx dot_name func_name [] t_dynamic injection (mk_block expr);
 ;;
 ;;
 
 
 
 

+ 11 - 1
src/generators/genphp7.ml

@@ -1651,7 +1651,17 @@ class code_writer (ctx:Common.context) hx_type_path php_name =
 		*)
 		*)
 		method write_expr_array_decl exprs =
 		method write_expr_array_decl exprs =
 			match exprs with
 			match exprs with
-				| [] -> self#write ("new " ^ (self#use array_type_path) ^ "()")
+				| [] ->
+					let decl () = self#write ("new " ^ (self#use array_type_path) ^ "()") in
+					(* Wrap into parentheses if trying to access items of empty array declaration *)
+					(match self#parent_expr with
+						| Some { eexpr = TArray _ } ->
+							self#write "(";
+							decl();
+							self#write ")"
+						| _ ->
+							decl()
+					)
 				| [expr] ->
 				| [expr] ->
 					self#write ((self#use array_type_path) ^ "::wrap([");
 					self#write ((self#use array_type_path) ^ "::wrap([");
 					self#write_expr expr;
 					self#write_expr expr;

+ 1 - 2
src/globals.ml

@@ -20,11 +20,10 @@ type platform =
 	| Python
 	| Python
 	| Hl
 	| Hl
 
 
-let version = 3401
+let version = 3402
 let version_major = version / 1000
 let version_major = version / 1000
 let version_minor = (version mod 1000) / 100
 let version_minor = (version mod 1000) / 100
 let version_revision = (version mod 100)
 let version_revision = (version mod 100)
-let version_is_stable = version_minor land 1 = 0
 
 
 let macro_platform = ref Neko
 let macro_platform = ref Neko
 
 

+ 1 - 1
src/typing/type.ml

@@ -206,7 +206,7 @@ and tclass = {
 	mutable cl_interface : bool;
 	mutable cl_interface : bool;
 	mutable cl_super : (tclass * tparams) option;
 	mutable cl_super : (tclass * tparams) option;
 	mutable cl_implements : (tclass * tparams) list;
 	mutable cl_implements : (tclass * tparams) list;
-	mutable cl_fields : (string , tclass_field) PMap.t;
+	mutable cl_fields : (string, tclass_field) PMap.t;
 	mutable cl_statics : (string, tclass_field) PMap.t;
 	mutable cl_statics : (string, tclass_field) PMap.t;
 	mutable cl_ordered_statics : tclass_field list;
 	mutable cl_ordered_statics : tclass_field list;
 	mutable cl_ordered_fields : tclass_field list;
 	mutable cl_ordered_fields : tclass_field list;

+ 1 - 1
std/Date.hx

@@ -67,7 +67,7 @@ extern class Date
 	function getMinutes() : Int;
 	function getMinutes() : Int;
 
 
 	/**
 	/**
-		Returns the seconds of the `this` Date (0-59 range).
+		Returns the seconds of `this` Date (0-59 range).
 	**/
 	**/
 	function getSeconds() : Int;
 	function getSeconds() : Int;
 
 

+ 2 - 2
std/Sys.hx

@@ -51,7 +51,7 @@ extern class Sys {
 	static function putEnv( s : String, v : String ) : Void;
 	static function putEnv( s : String, v : String ) : Void;
 
 
 	/**
 	/**
-		Returns the whole environment variables.
+		Returns all environment variables.
 	**/
 	**/
 	static function environment() : Map<String,String>;
 	static function environment() : Map<String,String>;
 
 
@@ -145,4 +145,4 @@ extern class Sys {
 	**/
 	**/
 	static function stderr() : haxe.io.Output;
 	static function stderr() : haxe.io.Output;
 
 
-}
+}

+ 1 - 1
std/sys/FileSystem.hx

@@ -75,7 +75,7 @@ extern class FileSystem {
 	/**
 	/**
 		Tells if the file or directory specified by `path` is a directory.
 		Tells if the file or directory specified by `path` is a directory.
 
 
-		If `path` is not a valid file system entry or if its destination is no
+		If `path` is not a valid file system entry or if its destination is not
 		accessible, an exception is thrown.
 		accessible, an exception is thrown.
 
 
 		If `path` is null, the result is unspecified.
 		If `path` is null, the result is unspecified.

+ 5 - 1
tests/unit/src/unit/issues/Issue2607.hx

@@ -4,8 +4,12 @@ class Issue2607 extends unit.Test {
 
 
 	inline static var CONST:Float = -1;
 	inline static var CONST:Float = -1;
 
 
-	function test(v = CONST) {
+	function fun(v = CONST) {
 		eq(v, -1);
 		eq(v, -1);
 		t((v is Float));
 		t((v is Float));
 	}
 	}
+
+	function test() {
+		fun();
+	}
 }
 }

+ 2 - 2
tests/unit/src/unit/issues/Issue3577.hx

@@ -2,10 +2,10 @@ package unit.issues;
 
 
 class Issue3577 extends Test {
 class Issue3577 extends Test {
 	function test() {
 	function test() {
-		eq(testNull(2), 4);
+		eq(tNull(2), 4);
 	}
 	}
 
 
-	function testNull(?x:Int=0) : Int {
+	function tNull(?x:Int=0) : Int {
 		var y:Int = x;
 		var y:Int = x;
 		function anon() {
 		function anon() {
 			y *= 2;
 			y *= 2;

+ 7 - 0
tests/unit/src/unit/issues/Issue6090.hx

@@ -0,0 +1,7 @@
+package unit.issues;
+
+class Issue6090 extends Test {
+	public function test() {
+		eq(null, [][0]);
+	}
+}