/**
		15.2.4.5 Object.prototype.hasOwnProperty (V)
		When the hasOwnProperty method is called with argument V, the following steps are taken:
		1. Let O be this object.
		2. Call ToString(V).
		3. If O doesn’t have a property with the name given by Result(2), return false.
		4. Return true.
		NOTE Unlike [[HasProperty]] (section 8.6.2.4), this method does not consider objects in the prototype chain.
     */
	bool ObjectClass::_hasOwnProperty(Atom thisAtom, Stringp name)
	{
		AvmCore* core = this->core();
		name = name ? core->internString(name) : (Stringp)core->knull;

		Traitsp t = NULL;
		switch (atomKind(thisAtom))
		{
			case kObjectType:
			{
				// ISSUE should this look in traits and dynamic vars, or just dynamic vars.
				ScriptObject* obj = AvmCore::atomToScriptObject(thisAtom);
				if (obj->hasStringProperty(name))
					return true;
				t = obj->traits();
				break;
			}
			case kNamespaceType:
			case kStringType:
			case kBooleanType:
			case kDoubleType:
			case kIntegerType:
				t = toplevel()->toTraits(thisAtom);
				break;
			default:
				return false;
		}
		return t->getTraitsBindings()->findBinding(name, core->publicNamespace) != BIND_NONE;
	}
Example #2
0
    /**
        15.2.4.5 Object.prototype.hasOwnProperty (V)
        When the hasOwnProperty method is called with argument V, the following steps are taken:
        1. Let O be this object.
        2. Call ToString(V).
        3. If O doesn't have a property with the name given by Result(2), return false.
        4. Return true.
        NOTE Unlike [[HasProperty]] (section 8.6.2.4), this method does not consider objects in the prototype chain.
     */
    bool ObjectClass::_hasOwnProperty(Atom thisAtom, Stringp name)
    {
        AvmCore* core = this->core();
        name = name ? core->internString(name) : (Stringp)core->knull;

        Traitsp t = NULL;
        switch (atomKind(thisAtom))
        {
            case kObjectType:
            {
                // ISSUE should this look in traits and dynamic vars, or just dynamic vars.
                ScriptObject* obj = AvmCore::atomToScriptObject(thisAtom);
                // TODO
                // The change below is important as otherwise we will throw error in a call to hasAtomProperty for ByteArrayObject.
                // This gets us back to the behaviour which we had in Marlin.
                // A bugzilla bug [ 562224 ] has been created to address this issue more cleanly in near future
                return obj->traits()->getTraitsBindings()->findBinding(name, core->findPublicNamespace()) != BIND_NONE ||
                    obj->hasStringProperty(name);
            }
            case kNamespaceType:
            case kStringType:
            case kBooleanType:
            case kDoubleType:
            case kIntptrType:
                t = toplevel()->toTraits(thisAtom);
                break;
            default:
                return false;
        }
        // NOTE use caller's public namespace
        return t->getTraitsBindings()->findBinding(name, core->findPublicNamespace()) != BIND_NONE;
    }