Skip to content

Commit

Permalink
[python] fix HaxeFoundation#3948 again and also check for ints and fl…
Browse files Browse the repository at this point in the history
…oats
  • Loading branch information
frabbit committed Mar 2, 2015
1 parent 3e7a8d4 commit 7eacabd
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions genpy.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1395,10 +1395,15 @@ module Printer = struct
let assign = if is_empty_expr then "" else Printf.sprintf "%s = _hx_e1\n%s" v.v_name indent in
let handle_base_type bt =
let t = print_base_type bt in
let res = if t = "String" then
Printf.sprintf "if python_lib_Builtin.isinstance(_hx_e1, str):\n%s\t%s\t%s" indent assign (print_expr {pctx with pc_indent = "\t" ^ pctx.pc_indent} e)
else
Printf.sprintf "if Std._hx_is(_hx_e1, %s):\n%s\t%s\t%s" t indent assign (print_expr {pctx with pc_indent = "\t" ^ pctx.pc_indent} e)
let print_type_check t_str =
Printf.sprintf "if python_lib_Builtin.isinstance(_hx_e1, %s):\n%s\t%s\t%s" t_str indent assign (print_expr {pctx with pc_indent = "\t" ^ pctx.pc_indent} e)
in
let res = match t with
| "String" -> print_type_check "python_lib_Builtin.str"
| "Bool" -> print_type_check "python_lib_Builtin.bool"
| "Int" -> print_type_check "python_lib_Builtin.int"
| "Float" -> print_type_check "python_lib_Builtin.float"
| t -> print_type_check t
in
if i > 0 then
indent ^ "el" ^ res
Expand Down

0 comments on commit 7eacabd

Please sign in to comment.