Browse Source

added getter/setter for module name

Nicolas Cannasse 17 years ago
parent
commit
29bc870cd2
1 changed files with 10 additions and 6 deletions
  1. 10 6
      std/neko/vm/Module.hx

+ 10 - 6
std/neko/vm/Module.hx

@@ -40,6 +40,7 @@ class Module {
 		The abstract handle.
 	**/
 	public var m : ModuleHandle;
+	public var name(getName,setName) : String;
 
 	public function new( m ) {
 		this.m = m;
@@ -54,13 +55,16 @@ class Module {
 		return _module_exec(m);
 	}
 
-	/**
-		Returns the Module name. This is the name that the Module was loaded with by the Loader.
-	**/
-	public function name() {
+	function getName() {
 		return new String(_module_name(m));
 	}
 
+	function setName( n : String ) {
+		_module_set_name(m,untyped n.__s);
+		return n;
+	}
+
+
 	/**
 		Returns the Loader that this Module was loaded with.s
 	**/
@@ -97,7 +101,7 @@ class Module {
 	}
 
 	public function toString() {
-		return "[Module:"+name()+"]";
+		return "[Module:"+name+"]";
 	}
 
 	/**
@@ -112,7 +116,6 @@ class Module {
 		return h;
 	}
 
-
 	/**
 		The raw export table.
 	**/
@@ -183,5 +186,6 @@ class Module {
 	static var _module_global_get = neko.Lib.load("std","module_global_get",2);
 	static var _module_global_set = neko.Lib.load("std","module_global_set",3);
 	static var _module_read_string = neko.Lib.loadLazy("std","module_read_string",2);
+	static var _module_set_name = neko.Lib.loadLazy("std","module_set_name",2);
 
 }