Bläddra i källkod

fixes in macro api wrapping (close #5944, close #5872)

Nicolas Cannasse 8 år sedan
förälder
incheckning
709c1b7769
2 ändrade filer med 7 tillägg och 4 borttagningar
  1. 2 2
      src/macro/interp.ml
  2. 5 2
      src/macro/macroApi.ml

+ 2 - 2
src/macro/interp.ml

@@ -2835,6 +2835,7 @@ let decode_tdecl = function
 
 
 let dec_int = function
 let dec_int = function
 	| VInt i -> i
 	| VInt i -> i
+	| VInt32 i -> Int32.to_int i
 	| _ -> raise Invalid_expr
 	| _ -> raise Invalid_expr
 
 
 let dec_i32 = function
 let dec_i32 = function
@@ -3091,8 +3092,7 @@ let value_signature v =
 
 
 let prepare_callback v n =
 let prepare_callback v n =
 	match v with
 	match v with
-	| VFunction f ->
-		if nargs f <> n then raise Invalid_expr;
+	| VFunction _ | VClosure _ ->
 		let ctx = get_ctx() in
 		let ctx = get_ctx() in
 		(fun args ->
 		(fun args ->
 			match catch_errors ctx (fun() -> ctx.do_call VNull v args null_pos) with
 			match catch_errors ctx (fun() -> ctx.do_call VNull v args null_pos) with

+ 5 - 2
src/macro/macroApi.ml

@@ -1082,6 +1082,9 @@ and decode_type t =
 	| 8, [a; pl] -> TAbstract (decode_ref a, List.map decode_type (dec_array pl))
 	| 8, [a; pl] -> TAbstract (decode_ref a, List.map decode_type (dec_array pl))
 	| _ -> raise Invalid_expr
 	| _ -> raise Invalid_expr
 
 
+and decode_type_decl t =
+	decode_tdecl (field t "__t")
+
 (* ---------------------------------------------------------------------- *)
 (* ---------------------------------------------------------------------- *)
 (* TEXPR Encoding *)
 (* TEXPR Encoding *)
 
 
@@ -1616,7 +1619,7 @@ let macro_api ccom get_api =
 						enc_string ("\"" ^ Ast.s_escape (dec_string v) ^ "\"")
 						enc_string ("\"" ^ Ast.s_escape (dec_string v) ^ "\"")
 					);
 					);
 					"buildMetaData", vfun1 (fun t ->
 					"buildMetaData", vfun1 (fun t ->
-						match Codegen.build_metadata com (decode_tdecl t) with
+						match Codegen.build_metadata com (decode_type_decl t) with
 						| None -> vnull
 						| None -> vnull
 						| Some e -> encode_texpr e
 						| Some e -> encode_texpr e
 					);
 					);
@@ -1633,7 +1636,7 @@ let macro_api ccom get_api =
 						vnull
 						vnull
 					);
 					);
 					"setCurrentClass", vfun1 (fun c ->
 					"setCurrentClass", vfun1 (fun c ->
-						Genjs.set_current_class js_ctx (match decode_tdecl c with TClassDecl c -> c | _ -> assert false);
+						Genjs.set_current_class js_ctx (match decode_type_decl c with TClassDecl c -> c | _ -> assert false);
 						vnull
 						vnull
 					);
 					);
 				] in
 				] in