Sha256: a1df3bbc7cb8241714c7523933081e40555926e3d0b4b3ac727431e728a9db44

Contents?: true

Size: 1.47 KB

Versions: 28

Compression:

Stored size: 1.47 KB

Contents

import com.asunit.framework.*;

class com.asunit.framework.Reflection {
	private var visitedObjects:Array;
	private var qualifiedName:String;

	public static function getQualifiedName(ref:Object)
	{
		return new Reflection(ref).toString();
	}

	// Use static Constructor / getQualifiedName
	private function Reflection(ref:Object)
	{
		visitedObjects = new Array();
		qualifiedName = getNameSpace("", _global, ref);
	}

	public function toString()
	{
		return qualifiedName;
	}

	public function beenVisited(obj:Object):Boolean
	{
		for(var i in visitedObjects) {
			if(visitedObjects[i] == obj) {
				return true;
			}
		}
		return false;
	}

	public function openMember(ref:Object)
	{
		_global.ASSetPropFlags(ref, null, 6, true);
	}

	public function closeMember(ref:Object)
	{
		_global.ASSetPropFlags(ref, null, 0, true);
	}

	public function getNameSpace(name:String, ref:Object, obj:Object)
	{
		if(!beenVisited(ref)) {
			var str = name;
			openMember(ref);
			visitedObjects.push(ref);
			for(var i in ref) {
   				if(i == "prototype" || i == "__proto__" || i == "toLocaleString" || i == "constructor") {
   					continue;
   				}
				str += ((str == "") ? "" :".") + i;
				if(ref[i] == obj) {
					closeMember(ref);
					return str;
				}
				closeMember(ref);
				// check here so that looping continues if result is invalid...
				return getNameSpace(str, ref[i], obj);
			}
			closeMember(ref);
			return str;
		}
	}
}

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
asproject-0.1.27 templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/Reflection.as
asproject-0.1.21 templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/Reflection.as
asproject-0.1.29 templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/Reflection.as
asproject-0.1.31 templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/Reflection.as
asproject-0.1.30 templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/Reflection.as
asproject-0.1.28 templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/Reflection.as
asproject-0.1.32 templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/Reflection.as
asproject-0.1.33 templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/Reflection.as
asproject-0.1.34 templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/Reflection.as
asproject-0.1.35 templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/Reflection.as
asproject-0.1.36 templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/Reflection.as
asproject-0.1.37 templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/Reflection.as
asproject-0.1.42 templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/Reflection.as
asproject-0.1.41 templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/Reflection.as
asproject-0.1.40 templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/Reflection.as
asproject-0.1.38 templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/Reflection.as
asproject-0.1.43 templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/Reflection.as
asproject-0.1.44 templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/Reflection.as
asproject-0.1.60 templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/Reflection.as
asproject-0.1.68 templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/Reflection.as