Browse Source

changed StringBuf.add implementation.

Nicolas Cannasse 18 years ago
parent
commit
1d9fca55ef
8 changed files with 14 additions and 16 deletions
  1. 3 3
      std/DateTools.hx
  2. 1 1
      std/Hash.hx
  3. 1 1
      std/IntHash.hx
  4. 3 5
      std/StringBuf.hx
  5. 1 1
      std/flash9/FlashXml__.hx
  6. 3 3
      std/haxe/Template.hx
  7. 1 1
      std/haxe/unit/TestResult.hx
  8. 1 1
      std/js/JsXml__.hx

+ 3 - 3
std/DateTools.hx

@@ -97,12 +97,12 @@ class DateTools {
 			if( np < 0 )
 				break;
 
-			r.add( f.substr(p,np-p) );
+			r.addSub(f,p,np-p);
 			r.add( __jsflash_format_get(d, f.substr(np+1,1) ) );
 
 			p = np+2;
 		}
-		r.add(f.substr(p,f.length-p));
+		r.addSub(f,p,f.length-p);
 		return r.toString();
 	}
 	#end
@@ -135,7 +135,7 @@ class DateTools {
 	public static function delta( d : Date, t : Float ) : Date {
 		return Date.fromTime( d.getTime() + t );
 	}
-	
+
 	static var DAYS_OF_MONTH = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
 
 	/**

+ 1 - 1
std/Hash.hx

@@ -197,7 +197,7 @@ class Hash<T> {
 		for( i in it ) {
 			s.add(i);
 			s.add(" => ");
-			s.add(get(i));
+			s.add2(Std.string(get(i)));
 			if( it.hasNext() )
 				s.add(", ");
 		}

+ 1 - 1
std/IntHash.hx

@@ -188,7 +188,7 @@ class IntHash<T> {
 		for( i in it ) {
 			s.add(i);
 			s.add(" => ");
-			s.add(get(i));
+			s.add2(Std.string(get(i)));
 			if( it.hasNext() )
 				s.add(", ");
 		}

+ 3 - 5
std/StringBuf.hx

@@ -46,13 +46,11 @@ class StringBuf {
 	/**
 		Adds the representation of any value to the string buffer.
 	**/
-	public function add( x : Dynamic ) {
+	public function add( ?x : Dynamic ) {
 		#if neko
 		__add(b,x);
-		#else flash
-		b += untyped flash.Boot.__string_rec(x,"");
-		#else js
-		b += untyped js.Boot.__string_rec(x,"");
+		#else true
+		b += x;
 		#else error
 		#end
 	}

+ 1 - 1
std/flash9/FlashXml__.hx

@@ -408,7 +408,7 @@ class FlashXml__ {
 		}
 
 		for( x in iterator() )
-			s.add(x);
+			s.add(x.toString());
 
 		if( nodeType == Xml.Element ) {
 			s.add("</");

+ 3 - 3
std/haxe/Template.hx

@@ -301,9 +301,9 @@ class Template {
 	function run( e : TemplateExpr ) {
 		switch( e ) {
 		case OpVar(v):
-			buf.add(resolve(v));
+			buf.add(Std.string(resolve(v)));
 		case OpExpr(e):
-			buf.add(e());
+			buf.add(Std.string(e()));
 		case OpIf(e,eif,eelse):
 			var v = e();
 			if( v == null || v == false ) {
@@ -348,7 +348,7 @@ class Template {
 			}
 			buf = old;
 			try {
-				buf.add(Reflect.callMethod(macros,v,pl));
+				buf.add(Std.string(Reflect.callMethod(macros,v,pl)));
 			} catch( e : Dynamic ) {
 				var plstr = try pl.toString() catch( e : Dynamic ) "???";
 				var msg = "Macro call "+m+"("+plstr+") failed ("+Std.string(e)+")";

+ 1 - 1
std/haxe/unit/TestResult.hx

@@ -68,7 +68,7 @@ class TestResult {
 
 				if (test.backtrace != null){
 					#if flash9
-					buf.add(test.backtrace);
+					buf.add(Std.string(test.backtrace));
 					#else true
 					buf.add(haxe.Stack.toString(test.backtrace));
 					#end

+ 1 - 1
std/js/JsXml__.hx

@@ -408,7 +408,7 @@ class JsXml__ {
 		}
 
 		for( x in iterator() )
-			s.add(x);
+			s.add(x.toString());
 
 		if( nodeType == Xml.Element ) {
 			s.add("</");