Browse Source

added neko.NativeString

Nicolas Cannasse 17 years ago
parent
commit
f59aa88847
4 changed files with 46 additions and 1 deletions
  1. 3 0
      doc/CHANGES.txt
  2. 1 0
      std/haxe/ImportAll.hx
  3. 1 1
      std/haxe/io/BytesData.hx
  4. 41 0
      std/neko/NativeString.hx

+ 3 - 0
doc/CHANGES.txt

@@ -6,6 +6,9 @@ TODO optimizer : move multiple statics access into local variables
 TODO inlining : allow inlined getter/setter
 TODO inlining : allow inlined getter/setter
 TODO inlining : substitute class+function type parameters in order to have fully typed expressions
 TODO inlining : substitute class+function type parameters in order to have fully typed expressions
 
 
+2008-??-??: 2.01
+	added neko.NativeString
+
 2008-07-28: 2.0
 2008-07-28: 2.0
 	fixed current package bug in inherited constructor type
 	fixed current package bug in inherited constructor type
 	delayed type-parameter constraints check (allow mutual rec extends for SPOD)
 	delayed type-parameter constraints check (allow mutual rec extends for SPOD)

+ 1 - 0
std/haxe/ImportAll.hx

@@ -382,6 +382,7 @@ import neko.Random;
 import neko.Sys;
 import neko.Sys;
 import neko.Utf8;
 import neko.Utf8;
 import neko.Web;
 import neko.Web;
+import neko.NativeString;
 
 
 import neko.io.File;
 import neko.io.File;
 import neko.io.FileInput;
 import neko.io.FileInput;

+ 1 - 1
std/haxe/io/BytesData.hx

@@ -25,7 +25,7 @@
 package haxe.io;
 package haxe.io;
 
 
 #if neko
 #if neko
-	typedef BytesData =	Void; // neko-string
+	typedef BytesData =	neko.NativeString;
 #elseif flash9
 #elseif flash9
 	typedef BytesData =	flash.utils.ByteArray;
 	typedef BytesData =	flash.utils.ByteArray;
 #else
 #else

+ 41 - 0
std/neko/NativeString.hx

@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2005, The haXe Project Contributors
+ * All rights reserved.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ *   - Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *   - Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE HAXE PROJECT CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE HAXE PROJECT CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ */
+package neko;
+
+class NativeString {
+
+	public static inline function ofString( s : String ) : NativeString {
+		return untyped s.__s;
+	}
+
+	public static inline function toString( s : NativeString ) : String {
+		return new String(cast s);
+	}
+
+	public static inline function length( s : NativeString ) : Int {
+		return untyped __dollar__ssize(s);
+	}
+
+}