Browse Source

Lua: Fix the constructor behavior for String

Justin Donaldson 9 years ago
parent
commit
0e85818bff
2 changed files with 5 additions and 4 deletions
  1. 4 0
      genlua.ml
  2. 1 4
      std/lua/_std/String.hx

+ 4 - 0
genlua.ml

@@ -1409,6 +1409,10 @@ let generate_class ctx c =
 					);
 					);
 					print ctx "%s.super(%s)" p (String.concat "," ("self" :: (List.map ident (List.map arg_name f.tf_args))));
 					print ctx "%s.super(%s)" p (String.concat "," ("self" :: (List.map ident (List.map arg_name f.tf_args))));
 					newline ctx;
 					newline ctx;
+					if p = "String" then begin
+					    spr ctx "self = string";
+					    newline ctx;
+					end;
 					spr ctx "return self";
 					spr ctx "return self";
 					bend(); newline ctx;
 					bend(); newline ctx;
 					spr ctx "end"; newline ctx; newline ctx;
 					spr ctx "end"; newline ctx; newline ctx;

+ 1 - 4
std/lua/_std/String.hx

@@ -29,10 +29,7 @@ class String {
 	public var length(default,null) : Int;
 	public var length(default,null) : Int;
 
 
 
 
-	public function new(string:String) untyped {
-		if (string != null) __lua__("self = string");
-		else __lua__("self = ''");
-	}
+	public function new(string:String) untyped {}
 
 
 	static function __init__() : Void untyped{
 	static function __init__() : Void untyped{
 		__lua__("getmetatable('').__index = String.__index;");
 		__lua__("getmetatable('').__index = String.__index;");