Simon Krajewski 3 lat temu
rodzic
commit
1f7de73ed3
1 zmienionych plików z 9 dodań i 0 usunięć
  1. 9 0
      std/haxe/macro/Context.hx

+ 9 - 0
std/haxe/macro/Context.hx

@@ -626,6 +626,15 @@ class Context {
 		return load("timer", 1)(id);
 	}
 
+	/**
+		Executes `code` in a context that has `imports` and `usings` added.
+
+		This is equivalent to temporarily having `import` and `using` statements in a file. These
+		are only active during the execution of `code` and do not affect anything afterwards. This
+		is true even if `code` throws an exception.
+
+		If any argument is `null`, the result is unspecified.
+	**/
 	public static function withImports<X>(imports:Array<String>, usings:Array<String>, code:() -> X):X {
 		return load("with_imports", 3)(imports, usings, code);
 	}