Răsfoiți Sursa

Merge pull request #3193 from porfirioribeiro/patch-1

Custom js gen feature support
Simon Krajewski 11 ani în urmă
părinte
comite
e93dba969a
2 a modificat fișierele cu 11 adăugiri și 0 ștergeri
  1. 4 0
      std/haxe/macro/JSGenApi.hx
  2. 7 0
      typer.ml

+ 4 - 0
std/haxe/macro/JSGenApi.hx

@@ -40,6 +40,10 @@ typedef JSGenApi = {
 	function setTypeAccessor( callb : Type -> String ) : Void;
 	/** tells if the given identifier is a JS keyword **/
 	function isKeyword( ident : String ) : Bool;
+	/** add a feature **/
+	function addFeature( f : String ) : Bool;
+	/** check if a feature is used **/
+	function hasFeature( f : String ) : Bool;
 	/** quote and escape the given string constant **/
 	function quoteString( s : String ) : String;
 	/** create the metadata expression for the given type **/

+ 7 - 0
typer.ml

@@ -4157,6 +4157,13 @@ let make_macro_api ctx p =
 					"isKeyword", Interp.VFunction (Interp.Fun1 (fun v ->
 						Interp.VBool (Hashtbl.mem Genjs.kwds (Interp.dec_string v))
 					));
+					"hasFeature", Interp.VFunction (Interp.Fun1 (fun v ->
+						Interp.VBool (Common.has_feature ctx.com (Interp.dec_string v))
+					));
+					"addFeature", Interp.VFunction (Interp.Fun1 (fun v ->
+						Common.add_feature ctx.com (Interp.dec_string v);
+						Interp.VNull
+					));	
 					"quoteString", Interp.VFunction (Interp.Fun1 (fun v ->
 						Interp.enc_string ("\"" ^ Ast.s_escape (Interp.dec_string v) ^ "\"")
 					));