Changeset 87588 in webkit for trunk/Source/JavaScriptCore/API
- Timestamp:
- May 27, 2011, 5:28:56 PM (14 years ago)
- Location:
- trunk/Source/JavaScriptCore/API
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/API/JSCallbackObject.h
r87586 r87588 189 189 static EncodedJSValue JSC_HOST_CALL construct(ExecState*); 190 190 191 static JSValue staticValueGetter(ExecState*, JSValue, const Identifier&);191 JSValue getStaticValue(ExecState*, const Identifier&); 192 192 static JSValue staticFunctionGetter(ExecState*, JSValue, const Identifier&); 193 193 static JSValue callbackGetter(ExecState*, JSValue, const Identifier&); -
trunk/Source/JavaScriptCore/API/JSCallbackObjectFunctions.h
r84660 r87588 150 150 if (OpaqueJSClassStaticValuesTable* staticValues = jsClass->staticValues(exec)) { 151 151 if (staticValues->contains(propertyName.impl())) { 152 slot.setCustom(this, staticValueGetter); 153 return true; 152 JSValue value = getStaticValue(exec, propertyName); 153 if (value) { 154 slot.setValue(value); 155 return true; 156 } 154 157 } 155 158 } … … 226 229 if (result || exception) 227 230 return; 228 } else 229 throwError(exec, createReferenceError(exec, "Attempt to set a property that is not settable.")); 231 } 230 232 } 231 233 } … … 516 518 517 519 template <class Base> 518 JSValue JSCallbackObject<Base>::staticValueGetter(ExecState* exec, JSValue slotBase, const Identifier& propertyName) 519 { 520 JSCallbackObject* thisObj = asCallbackObject(slotBase); 521 522 JSObjectRef thisRef = toRef(thisObj); 520 JSValue JSCallbackObject<Base>::getStaticValue(ExecState* exec, const Identifier& propertyName) 521 { 522 JSObjectRef thisRef = toRef(this); 523 523 RefPtr<OpaqueJSString> propertyNameRef; 524 524 525 for (JSClassRef jsClass = thisObj->classRef(); jsClass; jsClass = jsClass->parentClass)525 for (JSClassRef jsClass = classRef(); jsClass; jsClass = jsClass->parentClass) 526 526 if (OpaqueJSClassStaticValuesTable* staticValues = jsClass->staticValues(exec)) 527 527 if (StaticValueEntry* entry = staticValues->get(propertyName.impl())) … … 543 543 } 544 544 545 return throwError(exec, createReferenceError(exec, "Static value property defined with NULL getProperty callback."));545 return JSValue(); 546 546 } 547 547 -
trunk/Source/JavaScriptCore/API/tests/testapi.c
r87586 r87588 312 312 } 313 313 314 static bool MyObject_set_nullGetForwardSet(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef value, JSValueRef* exception) 315 { 316 UNUSED_PARAM(ctx); 317 UNUSED_PARAM(object); 318 UNUSED_PARAM(propertyName); 319 UNUSED_PARAM(value); 320 UNUSED_PARAM(exception); 321 return false; // Forward to parent class. 322 } 323 314 324 static JSStaticValue evilStaticValues[] = { 315 325 { "nullGetSet", 0, 0, kJSPropertyAttributeNone }, 326 { "nullGetForwardSet", 0, MyObject_set_nullGetForwardSet, kJSPropertyAttributeNone }, 316 327 { 0, 0, 0, 0 } 317 328 }; -
trunk/Source/JavaScriptCore/API/tests/testapi.js
r87586 r87588 95 95 shouldBe("'throwOnHasInstance' instanceof MyObject", "an exception"); 96 96 97 MyObject.nullGetForwardSet = 1; 98 shouldBe("MyObject.nullGetForwardSet", 1); 99 97 100 var foundMyPropertyName = false; 98 101 var foundRegularType = false; … … 163 166 shouldBe("(new Object()) instanceof MyObject", false); 164 167 165 shouldThrow("MyObject.nullGetSet = 1");166 should Throw("MyObject.nullGetSet");168 MyObject.nullGetSet = 1; 169 shouldBe("MyObject.nullGetSet", 1); 167 170 shouldThrow("MyObject.nullCall()"); 168 171 shouldThrow("MyObject.hasPropertyLie");
Note:
See TracChangeset
for help on using the changeset viewer.