<commit_before>package openfl.utils;
#if cpp
import haxe.ds.WeakMap;
#elseif js
typedef JSWeakRef = js.lib.WeakRef;
#end
/**
 * ...
 * @author <NAME>
 */
class WeakRef
{
	#if cpp
	private var weakMap: WeakMap<Dynamic, Int>; 
	#elseif js
	private var weakRef: JSWeakRef;
	#end
	public var object(get, set):Dynamic;
	
	private function set_object(value:Dynamic):Dynamic{
		#if cpp
		weakMap.set(value, 0);
		#elseif js
		weakRef = new JSWeakRef(value);
		#end
		return value;
	}
	
	private function get_object():Dynamic{
		#if cpp
		var iterator = weakMap.keys();
		if (iterator.hasNext()) return iterator.next();		
		return null;
		#elseif js
		return weakRef.deref();
		#end
	}

	public function new(?object:Dynamic)
	{
		#if cpp
		weakMap = new WeakMap();
		if (object != null) weakMap.set(object, 0);	
		#elseif js
		if (object != null) weakRef = new JSWeakRef(object);
		#end
	}

}<commit_msg>Change WeakRef draft from class to abstract<commit_after>package openfl.utils;
#if cpp
	import haxe.ds.WeakMap;
#elseif js
	typedef JSWeakRef = js.lib.WeakRef<Dynamic>;
#end

abstract WeakRef(#if cpp WeakMap #elseif js JSWeakRef #end)
{

	public var object(get, set):Dynamic;

	inline function set_object(value:Dynamic):Dynamic
	{
		#if cpp
		this.set(value, 0);
		#elseif js
		this = new JSWeakRef(value);
		#end
		return value;
	}

	inline function get_object():Dynamic
	{
		#if cpp
		var iterator = this.keys();
		if (iterator.hasNext()) return iterator.next();
		return null;
		#elseif js
		return this.deref();
		#end
	}

	inline public function new(?object:Dynamic)
	{
		#if cpp
		this = new WeakMap();
		if (object != null) this.set(object, 0);
		#elseif js
		this = new JSWeakRef(object);
		#end
	}

}
{'fraction_non_alphanumeric': 0.13020527859237538, 'fraction_numerical': 0.002346041055718475, 'mean_word_length': 3.846590909090909, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3004705', 'n_tokens_mistral': 701, 'n_tokens_neox': 626, 'n_words': 174}