Changeset 15376 in webkit for trunk/JavaScriptCore/API/JSCallbackObject.cpp
- Timestamp:
- Jul 12, 2006, 1:12:08 AM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/API/JSCallbackObject.cpp
r15317 r15376 60 60 61 61 do { 62 if (JS InitializeCallback initialize = jsClass->callbacks.initialize)62 if (JSObjectInitializeCallback initialize = jsClass->callbacks.initialize) 63 63 initialize(context, thisRef, toRef(exec->exceptionSlot())); 64 64 } while ((jsClass = jsClass->parent)); … … 70 70 71 71 for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parent) 72 if (JS FinalizeCallback finalize = jsClass->callbacks.finalize)72 if (JSObjectFinalizeCallback finalize = jsClass->callbacks.finalize) 73 73 finalize(thisRef); 74 74 … … 85 85 JSContextRef context = toRef(exec); 86 86 JSObjectRef thisRef = toRef(this); 87 JS InternalStringRef propertyNameRef = toRef(propertyName.ustring().rep());87 JSStringRef propertyNameRef = toRef(propertyName.ustring().rep()); 88 88 89 89 for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parent) { 90 90 // optional optimization to bypass getProperty in cases when we only need to know if the property exists 91 if (JS HasPropertyCallback hasPropertyCallback= jsClass->callbacks.hasProperty) {92 if (hasProperty Callback(context, thisRef, propertyNameRef, toRef(exec->exceptionSlot()))) {91 if (JSObjectHasPropertyCallback hasProperty = jsClass->callbacks.hasProperty) { 92 if (hasProperty(context, thisRef, propertyNameRef, toRef(exec->exceptionSlot()))) { 93 93 slot.setCustom(this, callbackGetter); 94 94 return true; 95 95 } 96 } else if (JSGetPropertyCallback getPropertyCallback = jsClass->callbacks.getProperty) { 97 JSValueRef returnValue; 98 if (getPropertyCallback(context, thisRef, propertyNameRef, &returnValue, toRef(exec->exceptionSlot()))) { 96 } else if (JSObjectGetPropertyCallback getProperty = jsClass->callbacks.getProperty) { 97 if (JSValueRef value = getProperty(context, thisRef, propertyNameRef, toRef(exec->exceptionSlot()))) { 99 98 // cache the value so we don't have to compute it again 100 99 // FIXME: This violates the PropertySlot design a little bit. 101 100 // We should either use this optimization everywhere, or nowhere. 102 slot.setCustom(reinterpret_cast<JSObject*>(toJS( returnValue)), cachedValueGetter);101 slot.setCustom(reinterpret_cast<JSObject*>(toJS(value)), cachedValueGetter); 103 102 return true; 104 103 } … … 134 133 JSContextRef context = toRef(exec); 135 134 JSObjectRef thisRef = toRef(this); 136 JS InternalStringRef propertyNameRef = toRef(propertyName.ustring().rep());135 JSStringRef propertyNameRef = toRef(propertyName.ustring().rep()); 137 136 JSValueRef valueRef = toRef(value); 138 137 139 138 for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parent) { 140 if (JS SetPropertyCallback setPropertyCallback= jsClass->callbacks.setProperty) {141 if (setProperty Callback(context, thisRef, propertyNameRef, valueRef, toRef(exec->exceptionSlot())))139 if (JSObjectSetPropertyCallback setProperty = jsClass->callbacks.setProperty) { 140 if (setProperty(context, thisRef, propertyNameRef, valueRef, toRef(exec->exceptionSlot()))) 142 141 return; 143 142 } … … 147 146 if (entry->attributes & kJSPropertyAttributeReadOnly) 148 147 return; 149 if (JS SetPropertyCallback setPropertyCallback= entry->setProperty) {150 if (setProperty Callback(context, thisRef, propertyNameRef, valueRef, toRef(exec->exceptionSlot())))148 if (JSObjectSetPropertyCallback setProperty = entry->setProperty) { 149 if (setProperty(context, thisRef, propertyNameRef, valueRef, toRef(exec->exceptionSlot()))) 151 150 return; 152 151 } … … 163 162 } 164 163 } 164 165 165 return JSObject::put(exec, propertyName, value, attr); 166 166 } … … 175 175 JSContextRef context = toRef(exec); 176 176 JSObjectRef thisRef = toRef(this); 177 JS InternalStringRef propertyNameRef = toRef(propertyName.ustring().rep());178 179 for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parent) { 180 if (JS DeletePropertyCallback deletePropertyCallback= jsClass->callbacks.deleteProperty) {181 if (deleteProperty Callback(context, thisRef, propertyNameRef, toRef(exec->exceptionSlot())))177 JSStringRef propertyNameRef = toRef(propertyName.ustring().rep()); 178 179 for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parent) { 180 if (JSObjectDeletePropertyCallback deleteProperty = jsClass->callbacks.deleteProperty) { 181 if (deleteProperty(context, thisRef, propertyNameRef, toRef(exec->exceptionSlot()))) 182 182 return true; 183 183 } … … 199 199 } 200 200 } 201 201 202 return JSObject::deleteProperty(exec, propertyName); 202 203 } … … 222 223 223 224 for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parent) { 224 if (JS CallAsConstructorCallback callAsConstructorCallback= jsClass->callbacks.callAsConstructor) {225 if (JSObjectCallAsConstructorCallback callAsConstructor = jsClass->callbacks.callAsConstructor) { 225 226 size_t argc = args.size(); 226 227 JSValueRef argv[argc]; 227 228 for (size_t i = 0; i < argc; i++) 228 229 argv[i] = toRef(args[i]); 229 return toJS(callAsConstructor Callback(execRef, thisRef, argc, argv, toRef(exec->exceptionSlot())));230 return toJS(callAsConstructor(execRef, thisRef, argc, argv, toRef(exec->exceptionSlot()))); 230 231 } 231 232 } … … 251 252 252 253 for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parent) { 253 if (JS CallAsFunctionCallback callAsFunctionCallback= jsClass->callbacks.callAsFunction) {254 if (JSObjectCallAsFunctionCallback callAsFunction = jsClass->callbacks.callAsFunction) { 254 255 size_t argc = args.size(); 255 256 JSValueRef argv[argc]; 256 257 for (size_t i = 0; i < argc; i++) 257 258 argv[i] = toRef(args[i]); 258 return toJS(callAsFunction Callback(execRef, thisRef, thisObjRef, argc, argv, toRef(exec->exceptionSlot())));259 return toJS(callAsFunction(execRef, thisRef, thisObjRef, argc, argv, toRef(exec->exceptionSlot()))); 259 260 } 260 261 } … … 270 271 271 272 for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parent) { 272 if (JS GetPropertyListCallback getPropertyListCallback = jsClass->callbacks.getPropertyList)273 getPropertyListCallback(context, thisRef, toRef(&propertyList), toRef(exec->exceptionSlot()));273 if (JSObjectAddPropertiesToListCallback addPropertiesToList = jsClass->callbacks.addPropertiesToList) 274 addPropertiesToList(context, thisRef, toRef(&propertyList), toRef(exec->exceptionSlot())); 274 275 275 276 if (__JSClass::StaticValuesTable* staticValues = jsClass->staticValues) { … … 304 305 JSObjectRef thisRef = toRef(this); 305 306 306 for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parent) { 307 if (JSConvertToTypeCallback convertToTypeCallback = jsClass->callbacks.convertToType) { 308 JSValueRef returnValue; 309 if (convertToTypeCallback(context, thisRef, kJSTypeBoolean, &returnValue, toRef(exec->exceptionSlot()))) 310 return toJS(returnValue)->getBoolean(); 311 } 312 } 307 for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parent) 308 if (JSObjectConvertToTypeCallback convertToType = jsClass->callbacks.convertToType) 309 if (JSValueRef value = convertToType(context, thisRef, kJSTypeBoolean, toRef(exec->exceptionSlot()))) 310 return toJS(value)->getBoolean(); 311 313 312 return JSObject::toBoolean(exec); 314 313 } … … 319 318 JSObjectRef thisRef = toRef(this); 320 319 321 for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parent) { 322 if (JSConvertToTypeCallback convertToTypeCallback = jsClass->callbacks.convertToType) { 323 JSValueRef returnValue; 324 if (convertToTypeCallback(context, thisRef, kJSTypeNumber, &returnValue, toRef(exec->exceptionSlot()))) 325 return toJS(returnValue)->getNumber(); 326 } 327 } 320 for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parent) 321 if (JSObjectConvertToTypeCallback convertToType = jsClass->callbacks.convertToType) 322 if (JSValueRef value = convertToType(context, thisRef, kJSTypeNumber, toRef(exec->exceptionSlot()))) 323 return toJS(value)->getNumber(); 324 328 325 return JSObject::toNumber(exec); 329 326 } … … 334 331 JSObjectRef thisRef = toRef(this); 335 332 336 for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parent) { 337 if (JSConvertToTypeCallback convertToTypeCallback = jsClass->callbacks.convertToType) { 338 JSValueRef returnValue; 339 if (convertToTypeCallback(context, thisRef, kJSTypeString, &returnValue, toRef(exec->exceptionSlot()))) 340 return toJS(returnValue)->getString(); 341 } 342 } 333 for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parent) 334 if (JSObjectConvertToTypeCallback convertToType = jsClass->callbacks.convertToType) 335 if (JSValueRef value = convertToType(context, thisRef, kJSTypeString, toRef(exec->exceptionSlot()))) 336 return toJS(value)->getString(); 337 343 338 return JSObject::toString(exec); 344 339 } … … 359 354 if (jsClass == c) 360 355 return true; 356 361 357 return false; 362 358 } … … 375 371 376 372 JSObjectRef thisRef = toRef(thisObj); 377 JSInternalStringRef propertyNameRef = toRef(propertyName.ustring().rep()); 378 379 for (JSClassRef jsClass = thisObj->m_class; jsClass; jsClass = jsClass->parent) { 380 JSValueRef returnValue; 381 373 JSStringRef propertyNameRef = toRef(propertyName.ustring().rep()); 374 375 for (JSClassRef jsClass = thisObj->m_class; jsClass; jsClass = jsClass->parent) 382 376 if (__JSClass::StaticValuesTable* staticValues = jsClass->staticValues) 383 377 if (StaticValueEntry* entry = staticValues->get(propertyName.ustring().rep())) 384 if (JSGetPropertyCallback getPropertyCallback = entry->getProperty) 385 if (getPropertyCallback(toRef(exec), thisRef, propertyNameRef, &returnValue, toRef(exec->exceptionSlot()))) 386 return toJS(returnValue); 387 } 378 if (JSObjectGetPropertyCallback getProperty = entry->getProperty) 379 if (JSValueRef value = getProperty(toRef(exec), thisRef, propertyNameRef, toRef(exec->exceptionSlot()))) 380 return toJS(value); 388 381 389 382 return jsUndefined(); … … 401 394 if (__JSClass::StaticFunctionsTable* staticFunctions = jsClass->staticFunctions) { 402 395 if (StaticFunctionEntry* entry = staticFunctions->get(propertyName.ustring().rep())) { 403 JSValue* v = toJS(JS FunctionMake(toRef(exec), entry->callAsFunction));396 JSValue* v = toJS(JSObjectMakeFunction(toRef(exec), entry->callAsFunction)); 404 397 thisObj->putDirect(propertyName, v, entry->attributes); 405 398 return v; … … 417 410 418 411 JSObjectRef thisRef = toRef(thisObj); 419 JSInternalStringRef propertyNameRef = toRef(propertyName.ustring().rep()); 420 421 for (JSClassRef jsClass = thisObj->m_class; jsClass; jsClass = jsClass->parent) { 422 JSValueRef returnValue; 423 424 if (JSGetPropertyCallback getPropertyCallback = jsClass->callbacks.getProperty) 425 if (getPropertyCallback(toRef(exec), thisRef, propertyNameRef, &returnValue, toRef(exec->exceptionSlot()))) 426 return toJS(returnValue); 427 } 412 JSStringRef propertyNameRef = toRef(propertyName.ustring().rep()); 413 414 for (JSClassRef jsClass = thisObj->m_class; jsClass; jsClass = jsClass->parent) 415 if (JSObjectGetPropertyCallback getProperty = jsClass->callbacks.getProperty) 416 if (JSValueRef value = getProperty(toRef(exec), thisRef, propertyNameRef, toRef(exec->exceptionSlot()))) 417 return toJS(value); 428 418 429 419 return jsUndefined();
Note:
See TracChangeset
for help on using the changeset viewer.