فهرست منبع

[lua] make @:native constructors possible

Justin Donaldson 9 سال پیش
والد
کامیت
01f6d985f7
1فایلهای تغییر یافته به همراه7 افزوده شده و 0 حذف شده
  1. 7 0
      src/generators/genlua.ml

+ 7 - 0
src/generators/genlua.ml

@@ -664,6 +664,13 @@ and gen_expr ?(local=true) ctx e = begin
 		(match c.cl_constructor with
 		| Some cf when Meta.has Meta.SelfCall cf.cf_meta ->
 			print ctx "%s" (ctx.type_accessor (TClassDecl c));
+		| Some cf when Meta.has Meta.Native cf.cf_meta ->
+			let _, args, mp = Meta.get Meta.Native cf.cf_meta in
+			(match args with
+			| [( EConst(String s),_)] ->
+				print ctx "%s.%s" (ctx.type_accessor (TClassDecl c)) s;
+			| _ ->
+				print ctx "%s.new" (ctx.type_accessor (TClassDecl c)));
 		| _ -> print ctx "%s.new" (ctx.type_accessor (TClassDecl c)));
 		spr ctx "(";
 		concat ctx "," (gen_value ctx) el;