Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
Simn committed Mar 20, 2017
2 parents 5c44548 + e033003 commit 890f8c7
Show file tree
Hide file tree
Showing 12 changed files with 69 additions and 30 deletions.
9 changes: 9 additions & 0 deletions extra/CHANGES.txt
Original file line number Diff line number Diff line change
@@ -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

New features:
Expand Down
2 changes: 1 addition & 1 deletion extra/installer.nsi
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
; Installer details
VIAddVersionKey "CompanyName" "Haxe Foundation"
VIAddVersionKey "ProductName" "Haxe Installer"
VIAddVersionKey "LegalCopyright" "Haxe Foundation 2005-2016"
VIAddVersionKey "LegalCopyright" "Haxe Foundation 2005-2017"
VIAddVersionKey "FileDescription" "Haxe Installer"
VIAddVersionKey "ProductVersion" "${VERSION}.0"
VIAddVersionKey "FileVersion" "${VERSION}.0"
Expand Down
46 changes: 28 additions & 18 deletions src/generators/gencpp.ml
Original file line number Diff line number Diff line change
Expand Up @@ -745,7 +745,9 @@ let rec class_string klass suffix params remap =
(* Normal class *)
| 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
| _ ->
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 =
let type_string = type_string_remap remap in
Expand Down Expand Up @@ -1687,7 +1689,8 @@ and tcpp_to_string tcpp =
tcpp_to_string_suffix "" tcpp

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 "::")
;;


Expand Down Expand Up @@ -1973,7 +1976,8 @@ let cpp_enum_path_of enum =
rename
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 "::")
;;


Expand Down Expand Up @@ -2013,10 +2017,9 @@ let cpp_class_name klass =
rename ^ "_obj"
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"
;;


Expand Down Expand Up @@ -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 closureId = ref 0 in
let declarations = ref (Hashtbl.create 0) in
Expand Down Expand Up @@ -2972,7 +2975,7 @@ let retype_expression ctx request_type function_args expression_tree forInjectio
CppTry(cppBlock, cppCatches), TCppVoid

| 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 *)
let return_type = cpp_type_of expr.etype in
Expand Down Expand Up @@ -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
match return_type with
| 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 _
| TCppScalarArray _
| TCppNativePointer _
Expand Down Expand Up @@ -3057,6 +3065,11 @@ let retype_expression ctx request_type function_args expression_tree forInjectio
| TCppDynamic when cppExpr.cpptype=TCppVariant
-> 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
end else match cppExpr.cpptype, return_type with
| _, TCppUnchanged -> cppExpr
Expand Down Expand Up @@ -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 ptrCast = mk_cppexpr (CppCast(cppExpr,ptrType)) ptrType in
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), TCppStruct _ ->
Expand Down Expand Up @@ -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 out = ctx.ctx_output in
let lastLine = ref (-1) in
Expand All @@ -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 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 class_hash = gen_hash_small 0 class_name in

Expand All @@ -3244,7 +3254,7 @@ let gen_cpp_ast_expression_tree ctx class_name func_name function_args injection
List.iter gen_closure closures;
(match injection with Some inject -> inject.inj_prologue gc_stack | _ -> () );
let remaining = ref (List.length exprs) in
lastLine := -1;
lastLine := Lexer.get_error_line tree.epos;
List.iter (fun e ->
output_p e "";
if (!remaining=1) then
Expand Down Expand Up @@ -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 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 =
Expand All @@ -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;
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);
;;


Expand Down
12 changes: 11 additions & 1 deletion src/generators/genphp7.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1651,7 +1651,17 @@ class code_writer (ctx:Common.context) hx_type_path php_name =
*)
method write_expr_array_decl exprs =
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] ->
self#write ((self#use array_type_path) ^ "::wrap([");
self#write_expr expr;
Expand Down
3 changes: 1 addition & 2 deletions src/globals.ml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,10 @@ type platform =
| Python
| Hl

let version = 3401
let version = 3402
let version_major = version / 1000
let version_minor = (version mod 1000) / 100
let version_revision = (version mod 100)
let version_is_stable = version_minor land 1 = 0

let macro_platform = ref Neko

Expand Down
2 changes: 1 addition & 1 deletion src/typing/type.ml
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ and tclass = {
mutable cl_interface : bool;
mutable cl_super : (tclass * tparams) option;
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_ordered_statics : tclass_field list;
mutable cl_ordered_fields : tclass_field list;
Expand Down
2 changes: 1 addition & 1 deletion std/Date.hx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ extern class Date
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;

Expand Down
4 changes: 2 additions & 2 deletions std/Sys.hx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ extern class Sys {
static function putEnv( s : String, v : String ) : Void;

/**
Returns the whole environment variables.
Returns all environment variables.
**/
static function environment() : Map<String,String>;

Expand Down Expand Up @@ -145,4 +145,4 @@ extern class Sys {
**/
static function stderr() : haxe.io.Output;

}
}
2 changes: 1 addition & 1 deletion std/sys/FileSystem.hx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ extern class FileSystem {
/**
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.
If `path` is null, the result is unspecified.
Expand Down
6 changes: 5 additions & 1 deletion tests/unit/src/unit/issues/Issue2607.hx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@ class Issue2607 extends unit.Test {

inline static var CONST:Float = -1;

function test(v = CONST) {
function fun(v = CONST) {
eq(v, -1);
t((v is Float));
}

function test() {
fun();
}
}
4 changes: 2 additions & 2 deletions tests/unit/src/unit/issues/Issue3577.hx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ package unit.issues;

class Issue3577 extends 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;
function anon() {
y *= 2;
Expand Down
7 changes: 7 additions & 0 deletions tests/unit/src/unit/issues/Issue6090.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package unit.issues;

class Issue6090 extends Test {
public function test() {
eq(null, [][0]);
}
}

0 comments on commit 890f8c7

Please sign in to comment.