|
@@ -23,18 +23,24 @@
|
|
@:coreApi
|
|
@:coreApi
|
|
class String {
|
|
class String {
|
|
public var length(default,null) : Int;
|
|
public var length(default,null) : Int;
|
|
- public function new(string:String) untyped {}
|
|
|
|
|
|
|
|
- static function __init__() : Void{
|
|
|
|
- untyped __lua__("setmetatable(_G.string, String.prototype)");
|
|
|
|
|
|
+
|
|
|
|
+ public function new(string:String) untyped {
|
|
|
|
+ if (string != null) __lua__("self = string");
|
|
|
|
+ else __lua__("self = ''");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ static function __init__() : Void untyped{
|
|
|
|
+ __lua__("getmetatable('').__index = String.__index");
|
|
}
|
|
}
|
|
|
|
|
|
@:keep
|
|
@:keep
|
|
- function __index(k:String) : Dynamic {
|
|
|
|
- if (k == "length") return untyped __lua__("#self");
|
|
|
|
|
|
+ static function __index(s:Dynamic, k:Dynamic) : Dynamic {
|
|
|
|
+ if (k == "length") return untyped __lua__("#s");
|
|
else return null;
|
|
else return null;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
public function toUpperCase() : String return untyped this.upper();
|
|
public function toUpperCase() : String return untyped this.upper();
|
|
public function toLowerCase() : String return untyped this.lower();
|
|
public function toLowerCase() : String return untyped this.lower();
|
|
public function indexOf( str : String, ?startIndex : Int ) : Int {
|
|
public function indexOf( str : String, ?startIndex : Int ) : Int {
|