Skip to content

Commit

Permalink
Merge pull request HaxeFoundation#4057 from HaxeFoundation/development
Browse files Browse the repository at this point in the history
3.2.0-rc2
  • Loading branch information
Simn committed Mar 20, 2015
2 parents a76d97b + 264a105 commit 27fa742
Show file tree
Hide file tree
Showing 119 changed files with 1,301 additions and 756 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ before_script:

install:
- if [ -z "${TRAVIS_OS_NAME}" ]; then export TRAVIS_OS_NAME=linux; fi; # for our forks that do not have mult-os enabled.
- if [ "${TRAVIS_OS_NAME}" = "linux" ]; then travis_retry sudo apt-get update -qq; travis_retry sudo apt-get install ocaml zlib1g-dev libgc-dev -qq; fi
- if [ "${TRAVIS_OS_NAME}" = "linux" ]; then travis_retry sudo apt-get update -qq; travis_retry sudo apt-get install ocaml-native-compilers zlib1g-dev libgc-dev -qq; fi
- if [ "${TRAVIS_OS_NAME}" = "osx" ]; then travis_retry brew update; travis_retry brew install caskroom/cask/brew-cask; travis_retry brew install ocaml camlp4; fi
- if [ "${TRAVIS_OS_NAME}" = "linux" ]; then travis_retry git clone https://github.com/HaxeFoundation/neko.git ~/neko && cd ~/neko && make os=${TRAVIS_OS_NAME} -s && sudo make install -s && cd $TRAVIS_BUILD_DIR; fi
- if [ "${TRAVIS_OS_NAME}" = "osx" ]; then travis_retry brew install neko --HEAD; fi

script:
- make -s
- make OCAMLOPT=ocamlopt.opt -s
- make tools -s
- sudo make install -s
- cd tests/
Expand Down
6 changes: 3 additions & 3 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ install:
- '%CYG_ROOT%/bin/bash -lc "godi_add godi-zip"'
- 'set PATH=%PATH%;%CYG_ROOT%/opt/wodi%WODI_ARCH%/bin'
# Install neko
- cinst make
- cinst make -y
- 'git clone --recursive https://github.com/HaxeFoundation/neko.git %NEKO_ROOT%'
- 'cd %NEKO_ROOT%'
- set PATH=%PATH%;%NEKO_ROOT%/bin
Expand All @@ -50,8 +50,8 @@ install:
build_script:
- 'cd %APPVEYOR_BUILD_FOLDER%'
- 'set PATH=%PATH%;%APPVEYOR_BUILD_FOLDER%'
- '%CYG_ROOT%/bin/bash -lc "cd \"$OLDPWD\" && make -f Makefile.win WODI=wodi%WODI_ARCH%"'
- '%CYG_ROOT%/bin/bash -lc "cd \"$OLDPWD\" && make -f Makefile.win WODI=wodi%WODI_ARCH% tools"'
- '%CYG_ROOT%/bin/bash -lc "cd \"$OLDPWD\" && make -f Makefile.win WODI=wodi%WODI_ARCH% OCAMLOPT=ocamlopt.opt"'
- '%CYG_ROOT%/bin/bash -lc "cd \"$OLDPWD\" && make -f Makefile.win WODI=wodi%WODI_ARCH% OCAMLOPT=ocamlopt.opt tools"'
- cd %APPVEYOR_BUILD_FOLDER%/tests/
- mkdir "%HAXELIB_ROOT%"
- haxelib setup "%HAXELIB_ROOT%"
Expand Down
4 changes: 2 additions & 2 deletions common.ml
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ let get_config com =
pf_overload = false;
pf_pattern_matching = false;
pf_can_skip_non_nullable_argument = true;
pf_reserved_type_paths = [([],"Object")];
pf_reserved_type_paths = [([],"Object");([],"Error")];
}
| Neko ->
{
Expand Down Expand Up @@ -610,7 +610,7 @@ let get_config com =
pf_overload = false;
pf_pattern_matching = false;
pf_can_skip_non_nullable_argument = false;
pf_reserved_type_paths = [([],"Object")];
pf_reserved_type_paths = [([],"Object");([],"Error")];
}
| Php ->
{
Expand Down
1 change: 1 addition & 0 deletions extra/CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
python : added python target
flash : flash player 12-14 support
js : added @:jsRequire and js.Lib.require
js : support haxe.CallStack.exceptionStack
cs : added @:bridgeProperties
cs : added -D erase_generics
cs : added -D dll_import to import haxe-generated dlls
Expand Down
2 changes: 1 addition & 1 deletion extra/haxelib_src
41 changes: 35 additions & 6 deletions filters.ml
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,28 @@ let rec add_final_return e =
{ e with eexpr = TFunction f }
| _ -> e

let rec wrap_js_exceptions com e =
let terr = List.find (fun mt -> match mt with TClassDecl {cl_path = ["js";"_Boot"],"HaxeError"} -> true | _ -> false) com.types in
let cerr = match terr with TClassDecl c -> c | _ -> assert false in

let rec is_error t =
match follow t with
| TInst ({cl_path = (["js"],"Error")},_) -> true
| TInst ({cl_super = Some (csup,tl)}, _) -> is_error (TInst (csup,tl))
| _ -> false
in

let rec loop e =
match e.eexpr with
| TThrow eerr when not (is_error eerr.etype) ->
let ewrap = { eerr with eexpr = TNew (cerr,[],[eerr]) } in
{ e with eexpr = TThrow ewrap }
| _ ->
Type.map_expr loop e
in

loop e

(* -------------------------------------------------------------------------- *)
(* CHECK LOCAL VARS INIT *)

Expand Down Expand Up @@ -705,13 +727,13 @@ let save_class_state ctx t = match t with
| TClassDecl c ->
let mk_field_restore f =
let rec mk_overload_restore f =
f.cf_kind,f.cf_expr,f.cf_type,f.cf_meta,f.cf_params
f.cf_name,f.cf_kind,f.cf_expr,f.cf_type,f.cf_meta,f.cf_params
in
( f,mk_overload_restore f, List.map (fun f -> f,mk_overload_restore f) f.cf_overloads )
in
let restore_field (f,res,overloads) =
let restore_field (f,(kind,expr,t,meta,params)) =
f.cf_kind <- kind; f.cf_expr <- expr; f.cf_type <- t; f.cf_meta <- meta; f.cf_params <- params;
let restore_field (f,(name,kind,expr,t,meta,params)) =
f.cf_name <- name; f.cf_kind <- kind; f.cf_expr <- expr; f.cf_type <- t; f.cf_meta <- meta; f.cf_params <- params;
f
in
let f = restore_field (f,res) in
Expand Down Expand Up @@ -998,9 +1020,14 @@ let commit_features ctx t =
) m.m_extra.m_features

let check_reserved_type_paths ctx t =
let m = t_infos t in
if List.mem m.mt_path ctx.com.config.pf_reserved_type_paths then
ctx.com.warning ("Type path " ^ (s_type_path m.mt_path) ^ " is reserved on this target") m.mt_pos
let check path pos =
if List.mem path ctx.com.config.pf_reserved_type_paths then
ctx.com.warning ("Type path " ^ (s_type_path path) ^ " is reserved on this target") pos
in
match t with
| TClassDecl c when not c.cl_extern -> check c.cl_path c.cl_pos
| TEnumDecl e when not e.e_extern -> check e.e_path e.e_pos
| _ -> ()

(* PASS 3 end *)

Expand Down Expand Up @@ -1088,6 +1115,7 @@ let run com tctx main =
let filters = [
Optimizer.sanitize com;
if com.config.pf_add_final_return then add_final_return else (fun e -> e);
if com.platform = Js then wrap_js_exceptions com else (fun e -> e);
rename_local_vars tctx;
] in
List.iter (run_expression_filters tctx filters) new_types;
Expand All @@ -1113,6 +1141,7 @@ let run com tctx main =
captured_vars com;
promote_complex_rhs com;
if com.config.pf_add_final_return then add_final_return else (fun e -> e);
if com.platform = Js then wrap_js_exceptions com else (fun e -> e);
rename_local_vars tctx;
] in
List.iter (run_expression_filters tctx filters) new_types;
Expand Down
57 changes: 34 additions & 23 deletions gencpp.ml
Original file line number Diff line number Diff line change
Expand Up @@ -367,11 +367,6 @@ let get_meta_string_path ctx meta key =
loop meta
;;

let has_meta_key meta key =
List.exists (fun m -> match m with | (k,_,_) when k=key-> true | _ -> false ) meta
;;


let get_field_access_meta field_access key =
match field_access with
| FInstance(_,_,class_field)
Expand All @@ -384,6 +379,19 @@ let get_code meta key =
if (code<>"") then code ^ "\n" else code
;;

let has_meta_key meta key =
List.exists (fun m -> match m with | (k,_,_) when k=key-> true | _ -> false ) meta
;;

let type_has_meta_key haxe_type key =
match follow haxe_type with
| TInst (klass,_) -> has_meta_key klass.cl_meta key
| TType (type_def,_) -> has_meta_key type_def.t_meta key
| TEnum (enum_def,_) -> has_meta_key enum_def.e_meta key
| _ -> false
;;


(*
let dump_meta meta =
List.iter (fun m -> match m with | (k,_,_) -> print_endline ((fst (MetaInfo.to_string k)) ^ "=" ^ (get_meta_string meta k) ) | _ -> () ) meta;;
Expand Down Expand Up @@ -489,15 +497,6 @@ let rec remove_parens_cast expression =
| _ -> expression
;;
*)

let cant_be_null type_string =
is_numeric type_string
;;

let is_object type_string =
not (is_numeric type_string || type_string="::String");
;;

let is_interface_type t =
match follow t with
| TInst (klass,params) -> klass.cl_interface
Expand Down Expand Up @@ -609,6 +608,7 @@ let rec class_string klass suffix params remap =
| TInst ({ cl_path = [],"Int" },_)
| TInst ({ cl_path = [],"Float" },_)
| TEnum ({ e_path = [],"Bool" },_) -> "Dynamic"
| t when type_has_meta_key t Meta.NotNull -> "Dynamic"
| _ -> "/*NULL*/" ^ (type_string t) )
| _ -> assert false);
(* Normal class *)
Expand Down Expand Up @@ -640,6 +640,7 @@ and type_string_suff suffix haxe_type remap =
| TInst ({ cl_path = [],"Int" },_)
| TInst ({ cl_path = [],"Float" },_)
| TEnum ({ e_path = [],"Bool" },_) -> "Dynamic" ^ suffix
| t when type_has_meta_key t Meta.NotNull -> "Dynamic" ^ suffix
| _ -> type_string_suff suffix t remap)
| _ -> assert false);
| [] , "Array" ->
Expand Down Expand Up @@ -692,7 +693,7 @@ and type_string haxe_type =

and array_element_type haxe_type =
match type_string haxe_type with
| x when cant_be_null x -> x
| x when cant_be_null haxe_type -> x
| x when is_interface_type (follow haxe_type) -> x
| "::String" -> "::String"
| _ -> "::Dynamic"
Expand Down Expand Up @@ -725,15 +726,20 @@ and cpp_function_signature_params params = match params with

and gen_interface_arg_type_name name opt typ =
let type_str = (type_string typ) in
(if (opt && (cant_be_null type_str) ) then
(if (opt && (cant_be_null typ) ) then
"hx::Null< " ^ type_str ^ " > "
else
type_str )
^ " " ^ (keyword_remap name)
and gen_tfun_interface_arg_list args =
String.concat "," (List.map (fun (name,opt,typ) -> gen_interface_arg_type_name name opt typ) args)
and cant_be_null haxe_type =
is_numeric (type_string haxe_type) || (type_has_meta_key haxe_type Meta.NotNull )
;;

let is_object type_string =
not (is_numeric type_string || type_string="::String");
;;



Expand Down Expand Up @@ -867,7 +873,7 @@ let gen_arg_type_name name default_val arg_type prefix =
let type_str = (type_string arg_type) in
match default_val with
| Some TNull -> (type_str,remap_name)
| Some constant when (cant_be_null type_str) -> ("hx::Null< " ^ type_str ^ " > ",prefix ^ remap_name)
| Some constant when (cant_be_null arg_type) -> ("hx::Null< " ^ type_str ^ " > ",prefix ^ remap_name)
| Some constant -> (type_str,prefix ^ remap_name)
| _ -> (type_str,remap_name);;

Expand Down Expand Up @@ -1830,7 +1836,7 @@ and gen_expression ctx retval expression =
| TInst (klass,[element]) ->
( match type_string element with
| _ when is_struct_access element -> ()
| x when cant_be_null x -> ()
| x when cant_be_null element -> ()
| _ when is_interface_type element -> ()
| "::String" | "Dynamic" -> ()
| real_type -> gen_array_cast cast_name real_type call
Expand Down Expand Up @@ -2411,9 +2417,14 @@ and gen_expression ctx retval expression =
gen_expression ctx retval cast;
| TCast (cast,None) ->
let ret_type = type_string expression.etype in
output ("((" ^ ret_type ^ ")(");
gen_expression ctx true cast;
output "))";
let from_type = if is_dynamic_in_cpp ctx cast then "Dynamic" else type_string cast.etype in
if (from_type = ret_type) then begin
gen_expression ctx true cast
end else begin
output ("((" ^ ret_type ^ ")(");
gen_expression ctx true cast;
output "))";
end;
| TCast (e1,Some t) ->
let class_name = (join_class_path_remap (t_path t) "::" ) in
if (class_name="Array") then
Expand Down Expand Up @@ -5559,13 +5570,13 @@ let generate_source common_ctx =
| ([],"Array"), [t] -> "Array<" ^ (stype t) ^ ">"
| (["haxe";"io"],"Unsigned_char__"),_ -> "uint8"
| ([],"EnumValue"),_ -> "Dynamic"
| ([],"Null"),[t] when cant_be_null (type_string t) -> "Null<" ^ (stype t) ^ ">"
| ([],"Null"),[t] when cant_be_null t -> "Null<" ^ (stype t) ^ ">"
| ([],"Null"),[t] -> (stype t)
| _ -> spath klass.cl_path
)
| TType (type_def,params) ->
(match type_def.t_path, params with
| ([],"Null"),[t] when cant_be_null (type_string t) -> "Null<" ^ (stype t) ^ ">"
| ([],"Null"),[t] when cant_be_null t -> "Null<" ^ (stype t) ^ ">"
| ([],"Array"), [t] -> "Array< " ^ (stype (follow t) ) ^ " >"
| _,_ -> stype (apply_params type_def.t_params params type_def.t_type)
)
Expand Down
11 changes: 11 additions & 0 deletions genjs.ml
Original file line number Diff line number Diff line change
Expand Up @@ -663,6 +663,17 @@ and gen_expr ctx e =
let bend = open_block ctx in
let last = ref false in
let else_block = ref false in

if (has_feature ctx "haxe.CallStack.exceptionStack") then begin
newline ctx;
print ctx "%s.lastException = %s" (ctx.type_accessor (TClassDecl { null_class with cl_path = ["haxe"],"CallStack" })) vname
end;

if (has_feature ctx "js.Boot.HaxeError") then begin
newline ctx;
print ctx "if (%s instanceof %s) %s = %s.val" vname (ctx.type_accessor (TClassDecl { null_class with cl_path = ["js";"_Boot"],"HaxeError" })) vname vname;
end;

List.iter (fun (v,e) ->
if !last then () else
let t = (match follow v.v_type with
Expand Down
2 changes: 1 addition & 1 deletion libs
Submodule libs updated 1 files
+43 −9 extc/extc_stubs.c
5 changes: 0 additions & 5 deletions main.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1396,16 +1396,11 @@ try
process_ref := process;
process ctx.com.args;
process_libs();
(try ignore(Common.find_file com "mt/Include.hx"); Common.raw_define com "mt"; with Not_found -> ());
if com.display <> DMNone then begin
com.warning <- message ctx;
com.error <- error ctx;
com.main_class <- None;
let real = get_real_path (!Parser.resume_display).Ast.pfile in
(* try to fix issue on windows when get_real_path fails (8.3 DOS names disabled) *)
let real = (match List.rev (ExtString.String.nsplit real path_sep) with
| file :: path when String.length file > 0 && file.[0] >= 'a' && file.[1] <= 'z' -> file.[0] <- char_of_int (int_of_char file.[0] - int_of_char 'a' + int_of_char 'A'); String.concat path_sep (List.rev (file :: path))
| _ -> real) in
classes := lookup_classes com real;
if !classes = [] then begin
if not (Sys.file_exists real) then failwith "Display file does not exist";
Expand Down
Loading

0 comments on commit 27fa742

Please sign in to comment.