Browse Source

[cpp] Add cpp.Lib.unloadAllLibraries. Allow Sys.exit to exit after dlls have been unloaded

Hugh 10 years ago
parent
commit
163052da9f
2 changed files with 10 additions and 3 deletions
  1. 8 0
      std/cpp/Lib.hx
  2. 2 3
      std/cpp/_std/Sys.hx

+ 8 - 0
std/cpp/Lib.hx

@@ -35,6 +35,14 @@ class Lib {
 		#end
 	}
 
+	/**
+		Unloaded all dynamic libraries in reverse order of loading.
+		Returns the number of libraries unloaded.
+	**/
+	public static function unloadAllLibraries() : Int {
+		return untyped __global__.__hxcpp_unload_all_libraries();
+	}
+
    @:analyzer(no_simplification)
 	public static function _loadPrime( lib : String, prim : String, signature : String, quietFail = false ) : Dynamic {
 		var factory:Callable< ConstCharStar -> Object > =

+ 2 - 3
std/cpp/_std/Sys.hx

@@ -106,7 +106,7 @@
 	}
 
 	public static function exit( code : Int ) : Void {
-		sys_exit(code);
+		untyped __global__.__hxcpp_exit(code);
 	}
 
 	public static function time() : Float {
@@ -140,7 +140,6 @@
 	private static var set_cwd = cpp.Lib.load("std","set_cwd",1);
 	private static var sys_string = cpp.Lib.load("std","sys_string",0);
 	private static var sys_command = cpp.Lib.load("std","sys_command",1);
-	private static var sys_exit = cpp.Lib.load("std","sys_exit",1);
 	private static var sys_time = cpp.Lib.load("std","sys_time",0);
 	private static var sys_cpu_time = cpp.Lib.load("std","sys_cpu_time",0);
 	private static var sys_exe_path = cpp.Lib.load("std","sys_exe_path",0);
@@ -151,4 +150,4 @@
 	private static var file_stderr = cpp.Lib.load("std","file_stderr",0);
 
 	private static var getch = cpp.Lib.load("std","sys_getch",1);
-}
+}