Browse Source

Add 'set'. Fix toString

Hugh Sanderson 12 years ago
parent
commit
0b92bfeabd
1 changed files with 9 additions and 4 deletions
  1. 9 4
      std/cpp/vm/WeakRef.hx

+ 9 - 4
std/cpp/vm/WeakRef.hx

@@ -46,13 +46,18 @@ class WeakRef<T>
 		return  untyped __global__.__hxcpp_weak_ref_get(ref);
 		return  untyped __global__.__hxcpp_weak_ref_get(ref);
 	}
 	}
 	
 	
+	public function set(inObject:T):T
+	{
+		if (hardRef)
+			ref = inObject;
+		else
+			ref = untyped __global__.__hxcpp_weak_ref_create(inObject);
+		return inObject;
+	}
 	
 	
 	public function toString():String
 	public function toString():String
 	{
 	{
-		if (hardRef)
-			return "" + hardRef;
-		
-		return "WeakRef(" + ref + ")";
+		return "WeakRef(" + get() + ")";
 	}
 	}
 }
 }