X-Git-Url: https://git.saurik.com/apple/javascriptcore.git/blobdiff_plain/6fe7ccc865dc7d7541b93c5bcaf6368d2c98a174..8b637bb680022adfddad653280734877951535a9:/API/JSCallbackObjectFunctions.h diff --git a/API/JSCallbackObjectFunctions.h b/API/JSCallbackObjectFunctions.h index b909dde..b92e316 100644 --- a/API/JSCallbackObjectFunctions.h +++ b/API/JSCallbackObjectFunctions.h @@ -51,7 +51,7 @@ inline JSCallbackObject* JSCallbackObject::asCallbackObject(JSVa template JSCallbackObject::JSCallbackObject(ExecState* exec, Structure* structure, JSClassRef jsClass, void* data) - : Parent(exec->globalData(), structure) + : Parent(exec->vm(), structure) , m_callbackObjectData(adoptPtr(new JSCallbackObjectData(data, jsClass))) { } @@ -59,8 +59,8 @@ JSCallbackObject::JSCallbackObject(ExecState* exec, Structure* structure // Global object constructor. // FIXME: Move this into a separate JSGlobalCallbackObject class derived from this one. template -JSCallbackObject::JSCallbackObject(JSGlobalData& globalData, JSClassRef jsClass, Structure* structure) - : Parent(globalData, structure) +JSCallbackObject::JSCallbackObject(VM& vm, JSClassRef jsClass, Structure* structure) + : Parent(vm, structure) , m_callbackObjectData(adoptPtr(new JSCallbackObjectData(0, jsClass))) { } @@ -68,18 +68,18 @@ JSCallbackObject::JSCallbackObject(JSGlobalData& globalData, JSClassRef template void JSCallbackObject::finishCreation(ExecState* exec) { - Base::finishCreation(exec->globalData()); + Base::finishCreation(exec->vm()); ASSERT(Parent::inherits(&s_info)); init(exec); } // This is just for Global object, so we can assume that Base::finishCreation is JSGlobalObject::finishCreation. template -void JSCallbackObject::finishCreation(JSGlobalData& globalData) +void JSCallbackObject::finishCreation(VM& vm) { ASSERT(Parent::inherits(&s_info)); ASSERT(Parent::isGlobalObject()); - Base::finishCreation(globalData); + Base::finishCreation(vm); init(jsCast(this)->globalExec()); } @@ -111,10 +111,10 @@ void JSCallbackObject::init(ExecState* exec) } template -UString JSCallbackObject::className(const JSObject* object) +String JSCallbackObject::className(const JSObject* object) { const JSCallbackObject* thisObject = jsCast(object); - UString thisClassName = thisObject->classRef()->className(); + String thisClassName = thisObject->classRef()->className(); if (!thisClassName.isEmpty()) return thisClassName; @@ -122,64 +122,72 @@ UString JSCallbackObject::className(const JSObject* object) } template -bool JSCallbackObject::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot) +bool JSCallbackObject::getOwnPropertySlot(JSCell* cell, ExecState* exec, PropertyName propertyName, PropertySlot& slot) { JSCallbackObject* thisObject = jsCast(cell); JSContextRef ctx = toRef(exec); JSObjectRef thisRef = toRef(thisObject); RefPtr propertyNameRef; - for (JSClassRef jsClass = thisObject->classRef(); jsClass; jsClass = jsClass->parentClass) { - // optional optimization to bypass getProperty in cases when we only need to know if the property exists - if (JSObjectHasPropertyCallback hasProperty = jsClass->hasProperty) { - if (!propertyNameRef) - propertyNameRef = OpaqueJSString::create(propertyName.ustring()); - APICallbackShim callbackShim(exec); - if (hasProperty(ctx, thisRef, propertyNameRef.get())) { - slot.setCustom(thisObject, callbackGetter); - return true; - } - } else if (JSObjectGetPropertyCallback getProperty = jsClass->getProperty) { - if (!propertyNameRef) - propertyNameRef = OpaqueJSString::create(propertyName.ustring()); - JSValueRef exception = 0; - JSValueRef value; - { + if (StringImpl* name = propertyName.publicName()) { + for (JSClassRef jsClass = thisObject->classRef(); jsClass; jsClass = jsClass->parentClass) { + // optional optimization to bypass getProperty in cases when we only need to know if the property exists + if (JSObjectHasPropertyCallback hasProperty = jsClass->hasProperty) { + if (!propertyNameRef) + propertyNameRef = OpaqueJSString::create(name); APICallbackShim callbackShim(exec); - value = getProperty(ctx, thisRef, propertyNameRef.get(), &exception); - } - if (exception) { - throwError(exec, toJS(exec, exception)); - slot.setValue(jsUndefined()); - return true; - } - if (value) { - slot.setValue(toJS(exec, value)); - return true; - } - } - - if (OpaqueJSClassStaticValuesTable* staticValues = jsClass->staticValues(exec)) { - if (staticValues->contains(propertyName.impl())) { - JSValue value = thisObject->getStaticValue(exec, propertyName); + if (hasProperty(ctx, thisRef, propertyNameRef.get())) { + slot.setCustom(thisObject, callbackGetter); + return true; + } + } else if (JSObjectGetPropertyCallback getProperty = jsClass->getProperty) { + if (!propertyNameRef) + propertyNameRef = OpaqueJSString::create(name); + JSValueRef exception = 0; + JSValueRef value; + { + APICallbackShim callbackShim(exec); + value = getProperty(ctx, thisRef, propertyNameRef.get(), &exception); + } + if (exception) { + throwError(exec, toJS(exec, exception)); + slot.setValue(jsUndefined()); + return true; + } if (value) { - slot.setValue(value); + slot.setValue(toJS(exec, value)); return true; } } - } - - if (OpaqueJSClassStaticFunctionsTable* staticFunctions = jsClass->staticFunctions(exec)) { - if (staticFunctions->contains(propertyName.impl())) { - slot.setCustom(thisObject, staticFunctionGetter); - return true; + + if (OpaqueJSClassStaticValuesTable* staticValues = jsClass->staticValues(exec)) { + if (staticValues->contains(name)) { + JSValue value = thisObject->getStaticValue(exec, propertyName); + if (value) { + slot.setValue(value); + return true; + } + } + } + + if (OpaqueJSClassStaticFunctionsTable* staticFunctions = jsClass->staticFunctions(exec)) { + if (staticFunctions->contains(name)) { + slot.setCustom(thisObject, staticFunctionGetter); + return true; + } } } } - + return Parent::getOwnPropertySlot(thisObject, exec, propertyName, slot); } +template +bool JSCallbackObject::getOwnPropertySlotByIndex(JSCell* cell, ExecState* exec, unsigned propertyName, PropertySlot& slot) +{ + return cell->methodTable()->getOwnPropertySlot(cell, exec, Identifier::from(exec, propertyName), slot); +} + template JSValue JSCallbackObject::defaultValue(const JSObject* object, ExecState* exec, PreferredPrimitiveType hint) { @@ -205,10 +213,10 @@ JSValue JSCallbackObject::defaultValue(const JSObject* object, ExecState } template -bool JSCallbackObject::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) +bool JSCallbackObject::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor) { JSCallbackObject* thisObject = jsCast(object); - PropertySlot slot; + PropertySlot slot(thisObject); if (thisObject->methodTable()->getOwnPropertySlot(thisObject, exec, propertyName, slot)) { // Ideally we should return an access descriptor, but returning a value descriptor is better than nothing. JSValue value = slot.getValue(exec, propertyName); @@ -225,7 +233,7 @@ bool JSCallbackObject::getOwnPropertyDescriptor(JSObject* object, ExecSt } template -void JSCallbackObject::put(JSCell* cell, ExecState* exec, const Identifier& propertyName, JSValue value, PutPropertySlot& slot) +void JSCallbackObject::put(JSCell* cell, ExecState* exec, PropertyName propertyName, JSValue value, PutPropertySlot& slot) { JSCallbackObject* thisObject = jsCast(cell); JSContextRef ctx = toRef(exec); @@ -233,10 +241,72 @@ void JSCallbackObject::put(JSCell* cell, ExecState* exec, const Identifi RefPtr propertyNameRef; JSValueRef valueRef = toRef(exec, value); + if (StringImpl* name = propertyName.publicName()) { + for (JSClassRef jsClass = thisObject->classRef(); jsClass; jsClass = jsClass->parentClass) { + if (JSObjectSetPropertyCallback setProperty = jsClass->setProperty) { + if (!propertyNameRef) + propertyNameRef = OpaqueJSString::create(name); + JSValueRef exception = 0; + bool result; + { + APICallbackShim callbackShim(exec); + result = setProperty(ctx, thisRef, propertyNameRef.get(), valueRef, &exception); + } + if (exception) + throwError(exec, toJS(exec, exception)); + if (result || exception) + return; + } + + if (OpaqueJSClassStaticValuesTable* staticValues = jsClass->staticValues(exec)) { + if (StaticValueEntry* entry = staticValues->get(name)) { + if (entry->attributes & kJSPropertyAttributeReadOnly) + return; + if (JSObjectSetPropertyCallback setProperty = entry->setProperty) { + if (!propertyNameRef) + propertyNameRef = OpaqueJSString::create(name); + JSValueRef exception = 0; + bool result; + { + APICallbackShim callbackShim(exec); + result = setProperty(ctx, thisRef, propertyNameRef.get(), valueRef, &exception); + } + if (exception) + throwError(exec, toJS(exec, exception)); + if (result || exception) + return; + } + } + } + + if (OpaqueJSClassStaticFunctionsTable* staticFunctions = jsClass->staticFunctions(exec)) { + if (StaticFunctionEntry* entry = staticFunctions->get(name)) { + if (entry->attributes & kJSPropertyAttributeReadOnly) + return; + thisObject->JSCallbackObject::putDirect(exec->vm(), propertyName, value); // put as override property + return; + } + } + } + } + + return Parent::put(thisObject, exec, propertyName, value, slot); +} + +template +void JSCallbackObject::putByIndex(JSCell* cell, ExecState* exec, unsigned propertyIndex, JSValue value, bool shouldThrow) +{ + JSCallbackObject* thisObject = jsCast(cell); + JSContextRef ctx = toRef(exec); + JSObjectRef thisRef = toRef(thisObject); + RefPtr propertyNameRef; + JSValueRef valueRef = toRef(exec, value); + Identifier propertyName = Identifier(exec, String::number(propertyIndex)); + for (JSClassRef jsClass = thisObject->classRef(); jsClass; jsClass = jsClass->parentClass) { if (JSObjectSetPropertyCallback setProperty = jsClass->setProperty) { if (!propertyNameRef) - propertyNameRef = OpaqueJSString::create(propertyName.ustring()); + propertyNameRef = OpaqueJSString::create(propertyName.impl()); JSValueRef exception = 0; bool result; { @@ -248,14 +318,14 @@ void JSCallbackObject::put(JSCell* cell, ExecState* exec, const Identifi if (result || exception) return; } - + if (OpaqueJSClassStaticValuesTable* staticValues = jsClass->staticValues(exec)) { if (StaticValueEntry* entry = staticValues->get(propertyName.impl())) { if (entry->attributes & kJSPropertyAttributeReadOnly) return; if (JSObjectSetPropertyCallback setProperty = entry->setProperty) { if (!propertyNameRef) - propertyNameRef = OpaqueJSString::create(propertyName.ustring()); + propertyNameRef = OpaqueJSString::create(propertyName.impl()); JSValueRef exception = 0; bool result; { @@ -269,61 +339,62 @@ void JSCallbackObject::put(JSCell* cell, ExecState* exec, const Identifi } } } - + if (OpaqueJSClassStaticFunctionsTable* staticFunctions = jsClass->staticFunctions(exec)) { if (StaticFunctionEntry* entry = staticFunctions->get(propertyName.impl())) { if (entry->attributes & kJSPropertyAttributeReadOnly) return; - thisObject->JSCallbackObject::putDirect(exec->globalData(), propertyName, value); // put as override property - return; + break; } } } - - return Parent::put(thisObject, exec, propertyName, value, slot); + + return Parent::putByIndex(thisObject, exec, propertyIndex, value, shouldThrow); } template -bool JSCallbackObject::deleteProperty(JSCell* cell, ExecState* exec, const Identifier& propertyName) +bool JSCallbackObject::deleteProperty(JSCell* cell, ExecState* exec, PropertyName propertyName) { JSCallbackObject* thisObject = jsCast(cell); JSContextRef ctx = toRef(exec); JSObjectRef thisRef = toRef(thisObject); RefPtr propertyNameRef; - for (JSClassRef jsClass = thisObject->classRef(); jsClass; jsClass = jsClass->parentClass) { - if (JSObjectDeletePropertyCallback deleteProperty = jsClass->deleteProperty) { - if (!propertyNameRef) - propertyNameRef = OpaqueJSString::create(propertyName.ustring()); - JSValueRef exception = 0; - bool result; - { - APICallbackShim callbackShim(exec); - result = deleteProperty(ctx, thisRef, propertyNameRef.get(), &exception); + if (StringImpl* name = propertyName.publicName()) { + for (JSClassRef jsClass = thisObject->classRef(); jsClass; jsClass = jsClass->parentClass) { + if (JSObjectDeletePropertyCallback deleteProperty = jsClass->deleteProperty) { + if (!propertyNameRef) + propertyNameRef = OpaqueJSString::create(name); + JSValueRef exception = 0; + bool result; + { + APICallbackShim callbackShim(exec); + result = deleteProperty(ctx, thisRef, propertyNameRef.get(), &exception); + } + if (exception) + throwError(exec, toJS(exec, exception)); + if (result || exception) + return true; } - if (exception) - throwError(exec, toJS(exec, exception)); - if (result || exception) - return true; - } - - if (OpaqueJSClassStaticValuesTable* staticValues = jsClass->staticValues(exec)) { - if (StaticValueEntry* entry = staticValues->get(propertyName.impl())) { - if (entry->attributes & kJSPropertyAttributeDontDelete) - return false; - return true; + + if (OpaqueJSClassStaticValuesTable* staticValues = jsClass->staticValues(exec)) { + if (StaticValueEntry* entry = staticValues->get(name)) { + if (entry->attributes & kJSPropertyAttributeDontDelete) + return false; + return true; + } } - } - - if (OpaqueJSClassStaticFunctionsTable* staticFunctions = jsClass->staticFunctions(exec)) { - if (StaticFunctionEntry* entry = staticFunctions->get(propertyName.impl())) { - if (entry->attributes & kJSPropertyAttributeDontDelete) - return false; - return true; + + if (OpaqueJSClassStaticFunctionsTable* staticFunctions = jsClass->staticFunctions(exec)) { + if (StaticFunctionEntry* entry = staticFunctions->get(name)) { + if (entry->attributes & kJSPropertyAttributeDontDelete) + return false; + return true; + } } } } - + return Parent::deleteProperty(thisObject, exec, propertyName); } @@ -356,10 +427,11 @@ EncodedJSValue JSCallbackObject::construct(ExecState* exec) for (JSClassRef jsClass = jsCast*>(constructor)->classRef(); jsClass; jsClass = jsClass->parentClass) { if (JSObjectCallAsConstructorCallback callAsConstructor = jsClass->callAsConstructor) { - int argumentCount = static_cast(exec->argumentCount()); - Vector arguments(argumentCount); - for (int i = 0; i < argumentCount; i++) - arguments[i] = toRef(exec, exec->argument(i)); + size_t argumentCount = exec->argumentCount(); + Vector arguments; + arguments.reserveInitialCapacity(argumentCount); + for (size_t i = 0; i < argumentCount; ++i) + arguments.uncheckedAppend(toRef(exec, exec->argument(i))); JSValueRef exception = 0; JSObject* result; { @@ -372,12 +444,12 @@ EncodedJSValue JSCallbackObject::construct(ExecState* exec) } } - ASSERT_NOT_REACHED(); // getConstructData should prevent us from reaching here + RELEASE_ASSERT_NOT_REACHED(); // getConstructData should prevent us from reaching here return JSValue::encode(JSValue()); } template -bool JSCallbackObject::hasInstance(JSObject* object, ExecState* exec, JSValue value, JSValue) +bool JSCallbackObject::customHasInstance(JSObject* object, ExecState* exec, JSValue value) { JSCallbackObject* thisObject = jsCast(object); JSContextRef execRef = toRef(exec); @@ -422,10 +494,11 @@ EncodedJSValue JSCallbackObject::call(ExecState* exec) for (JSClassRef jsClass = jsCast*>(toJS(functionRef))->classRef(); jsClass; jsClass = jsClass->parentClass) { if (JSObjectCallAsFunctionCallback callAsFunction = jsClass->callAsFunction) { - int argumentCount = static_cast(exec->argumentCount()); - Vector arguments(argumentCount); - for (int i = 0; i < argumentCount; i++) - arguments[i] = toRef(exec, exec->argument(i)); + size_t argumentCount = exec->argumentCount(); + Vector arguments; + arguments.reserveInitialCapacity(argumentCount); + for (size_t i = 0; i < argumentCount; ++i) + arguments.uncheckedAppend(toRef(exec, exec->argument(i))); JSValueRef exception = 0; JSValue result; { @@ -438,12 +511,12 @@ EncodedJSValue JSCallbackObject::call(ExecState* exec) } } - ASSERT_NOT_REACHED(); // getCallData should prevent us from reaching here + RELEASE_ASSERT_NOT_REACHED(); // getCallData should prevent us from reaching here return JSValue::encode(JSValue()); } template -void JSCallbackObject::getOwnPropertyNames(JSObject* object, ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode) +void JSCallbackObject::getOwnNonIndexPropertyNames(JSObject* object, ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode) { JSCallbackObject* thisObject = jsCast(object); JSContextRef execRef = toRef(exec); @@ -459,8 +532,8 @@ void JSCallbackObject::getOwnPropertyNames(JSObject* object, ExecState* typedef OpaqueJSClassStaticValuesTable::const_iterator iterator; iterator end = staticValues->end(); for (iterator it = staticValues->begin(); it != end; ++it) { - StringImpl* name = it->first.get(); - StaticValueEntry* entry = it->second.get(); + StringImpl* name = it->key.get(); + StaticValueEntry* entry = it->value.get(); if (entry->getProperty && (!(entry->attributes & kJSPropertyAttributeDontEnum) || (mode == IncludeDontEnumProperties))) propertyNames.add(Identifier(exec, name)); } @@ -470,15 +543,15 @@ void JSCallbackObject::getOwnPropertyNames(JSObject* object, ExecState* typedef OpaqueJSClassStaticFunctionsTable::const_iterator iterator; iterator end = staticFunctions->end(); for (iterator it = staticFunctions->begin(); it != end; ++it) { - StringImpl* name = it->first.get(); - StaticFunctionEntry* entry = it->second.get(); + StringImpl* name = it->key.get(); + StaticFunctionEntry* entry = it->value.get(); if (!(entry->attributes & kJSPropertyAttributeDontEnum) || (mode == IncludeDontEnumProperties)) propertyNames.add(Identifier(exec, name)); } } } - Parent::getOwnPropertyNames(thisObject, exec, propertyNames, mode); + Parent::getOwnNonIndexPropertyNames(thisObject, exec, propertyNames, mode); } template @@ -496,44 +569,49 @@ void* JSCallbackObject::getPrivate() template bool JSCallbackObject::inherits(JSClassRef c) const { - for (JSClassRef jsClass = classRef(); jsClass; jsClass = jsClass->parentClass) + for (JSClassRef jsClass = classRef(); jsClass; jsClass = jsClass->parentClass) { if (jsClass == c) return true; - + } return false; } template -JSValue JSCallbackObject::getStaticValue(ExecState* exec, const Identifier& propertyName) +JSValue JSCallbackObject::getStaticValue(ExecState* exec, PropertyName propertyName) { JSObjectRef thisRef = toRef(this); RefPtr propertyNameRef; - for (JSClassRef jsClass = classRef(); jsClass; jsClass = jsClass->parentClass) - if (OpaqueJSClassStaticValuesTable* staticValues = jsClass->staticValues(exec)) - if (StaticValueEntry* entry = staticValues->get(propertyName.impl())) - if (JSObjectGetPropertyCallback getProperty = entry->getProperty) { - if (!propertyNameRef) - propertyNameRef = OpaqueJSString::create(propertyName.ustring()); - JSValueRef exception = 0; - JSValueRef value; - { - APICallbackShim callbackShim(exec); - value = getProperty(toRef(exec), thisRef, propertyNameRef.get(), &exception); + if (StringImpl* name = propertyName.publicName()) { + for (JSClassRef jsClass = classRef(); jsClass; jsClass = jsClass->parentClass) { + if (OpaqueJSClassStaticValuesTable* staticValues = jsClass->staticValues(exec)) { + if (StaticValueEntry* entry = staticValues->get(name)) { + if (JSObjectGetPropertyCallback getProperty = entry->getProperty) { + if (!propertyNameRef) + propertyNameRef = OpaqueJSString::create(name); + JSValueRef exception = 0; + JSValueRef value; + { + APICallbackShim callbackShim(exec); + value = getProperty(toRef(exec), thisRef, propertyNameRef.get(), &exception); + } + if (exception) { + throwError(exec, toJS(exec, exception)); + return jsUndefined(); + } + if (value) + return toJS(exec, value); } - if (exception) { - throwError(exec, toJS(exec, exception)); - return jsUndefined(); - } - if (value) - return toJS(exec, value); } + } + } + } return JSValue(); } template -JSValue JSCallbackObject::staticFunctionGetter(ExecState* exec, JSValue slotParent, const Identifier& propertyName) +JSValue JSCallbackObject::staticFunctionGetter(ExecState* exec, JSValue slotParent, PropertyName propertyName) { JSCallbackObject* thisObj = asCallbackObject(slotParent); @@ -542,49 +620,54 @@ JSValue JSCallbackObject::staticFunctionGetter(ExecState* exec, JSValue if (Parent::getOwnPropertySlot(thisObj, exec, propertyName, slot2)) return slot2.getValue(exec, propertyName); - for (JSClassRef jsClass = thisObj->classRef(); jsClass; jsClass = jsClass->parentClass) { - if (OpaqueJSClassStaticFunctionsTable* staticFunctions = jsClass->staticFunctions(exec)) { - if (StaticFunctionEntry* entry = staticFunctions->get(propertyName.impl())) { - if (JSObjectCallAsFunctionCallback callAsFunction = entry->callAsFunction) { - - JSObject* o = JSCallbackFunction::create(exec, thisObj->globalObject(), callAsFunction, propertyName); - thisObj->putDirect(exec->globalData(), propertyName, o, entry->attributes); - return o; + if (StringImpl* name = propertyName.publicName()) { + for (JSClassRef jsClass = thisObj->classRef(); jsClass; jsClass = jsClass->parentClass) { + if (OpaqueJSClassStaticFunctionsTable* staticFunctions = jsClass->staticFunctions(exec)) { + if (StaticFunctionEntry* entry = staticFunctions->get(name)) { + if (JSObjectCallAsFunctionCallback callAsFunction = entry->callAsFunction) { + + JSObject* o = JSCallbackFunction::create(exec, thisObj->globalObject(), callAsFunction, name); + thisObj->putDirect(exec->vm(), propertyName, o, entry->attributes); + return o; + } } } } } - - return throwError(exec, createReferenceError(exec, "Static function property defined with NULL callAsFunction callback.")); + + return throwError(exec, createReferenceError(exec, ASCIILiteral("Static function property defined with NULL callAsFunction callback."))); } template -JSValue JSCallbackObject::callbackGetter(ExecState* exec, JSValue slotParent, const Identifier& propertyName) +JSValue JSCallbackObject::callbackGetter(ExecState* exec, JSValue slotParent, PropertyName propertyName) { JSCallbackObject* thisObj = asCallbackObject(slotParent); JSObjectRef thisRef = toRef(thisObj); RefPtr propertyNameRef; - for (JSClassRef jsClass = thisObj->classRef(); jsClass; jsClass = jsClass->parentClass) - if (JSObjectGetPropertyCallback getProperty = jsClass->getProperty) { - if (!propertyNameRef) - propertyNameRef = OpaqueJSString::create(propertyName.ustring()); - JSValueRef exception = 0; - JSValueRef value; - { - APICallbackShim callbackShim(exec); - value = getProperty(toRef(exec), thisRef, propertyNameRef.get(), &exception); - } - if (exception) { - throwError(exec, toJS(exec, exception)); - return jsUndefined(); + if (StringImpl* name = propertyName.publicName()) { + for (JSClassRef jsClass = thisObj->classRef(); jsClass; jsClass = jsClass->parentClass) { + if (JSObjectGetPropertyCallback getProperty = jsClass->getProperty) { + if (!propertyNameRef) + propertyNameRef = OpaqueJSString::create(name); + JSValueRef exception = 0; + JSValueRef value; + { + APICallbackShim callbackShim(exec); + value = getProperty(toRef(exec), thisRef, propertyNameRef.get(), &exception); + } + if (exception) { + throwError(exec, toJS(exec, exception)); + return jsUndefined(); + } + if (value) + return toJS(exec, value); } - if (value) - return toJS(exec, value); } - - return throwError(exec, createReferenceError(exec, "hasProperty callback returned true for a property that doesn't exist.")); + } + + return throwError(exec, createReferenceError(exec, ASCIILiteral("hasProperty callback returned true for a property that doesn't exist."))); } } // namespace JSC