Changeset 35775 in webkit for trunk/JavaScriptCore/API/JSCallbackObjectFunctions.h
- Timestamp:
- Aug 15, 2008, 12:43:48 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/API/JSCallbackObjectFunctions.h
r35478 r35775 34 34 #include "JSString.h" 35 35 #include "JSStringRef.h" 36 #include "OpaqueJSString.h" 36 37 #include "PropertyNameArray.h" 37 38 #include <wtf/Vector.h> … … 106 107 JSContextRef ctx = toRef(exec); 107 108 JSObjectRef thisRef = toRef(this); 108 JSStringRef propertyNameRef = toRef(propertyName.ustring().rep());109 RefPtr<OpaqueJSString> propertyNameRef; 109 110 110 111 for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parentClass) { 111 112 // optional optimization to bypass getProperty in cases when we only need to know if the property exists 112 113 if (JSObjectHasPropertyCallback hasProperty = jsClass->hasProperty) { 113 if (hasProperty(ctx, thisRef, propertyNameRef)) { 114 if (!propertyNameRef) 115 propertyNameRef = OpaqueJSString::create(propertyName.ustring()); 116 if (hasProperty(ctx, thisRef, propertyNameRef.get())) { 114 117 slot.setCustom(this, callbackGetter); 115 118 return true; 116 119 } 117 120 } else if (JSObjectGetPropertyCallback getProperty = jsClass->getProperty) { 118 if (JSValueRef value = getProperty(ctx, thisRef, propertyNameRef, toRef(exec->exceptionSlot()))) { 121 if (!propertyNameRef) 122 propertyNameRef = OpaqueJSString::create(propertyName.ustring()); 123 if (JSValueRef value = getProperty(ctx, thisRef, propertyNameRef.get(), toRef(exec->exceptionSlot()))) { 119 124 // cache the value so we don't have to compute it again 120 125 // FIXME: This violates the PropertySlot design a little bit. … … 154 159 JSContextRef ctx = toRef(exec); 155 160 JSObjectRef thisRef = toRef(this); 156 JSStringRef propertyNameRef = toRef(propertyName.ustring().rep());161 RefPtr<OpaqueJSString> propertyNameRef; 157 162 JSValueRef valueRef = toRef(value); 158 163 159 164 for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parentClass) { 160 165 if (JSObjectSetPropertyCallback setProperty = jsClass->setProperty) { 161 if (setProperty(ctx, thisRef, propertyNameRef, valueRef, toRef(exec->exceptionSlot()))) 166 if (!propertyNameRef) 167 propertyNameRef = OpaqueJSString::create(propertyName.ustring()); 168 if (setProperty(ctx, thisRef, propertyNameRef.get(), valueRef, toRef(exec->exceptionSlot()))) 162 169 return; 163 170 } … … 168 175 return; 169 176 if (JSObjectSetPropertyCallback setProperty = entry->setProperty) { 170 if (setProperty(ctx, thisRef, propertyNameRef, valueRef, toRef(exec->exceptionSlot()))) 177 if (!propertyNameRef) 178 propertyNameRef = OpaqueJSString::create(propertyName.ustring()); 179 if (setProperty(ctx, thisRef, propertyNameRef.get(), valueRef, toRef(exec->exceptionSlot()))) 171 180 return; 172 181 } else … … 199 208 JSContextRef ctx = toRef(exec); 200 209 JSObjectRef thisRef = toRef(this); 201 JSStringRef propertyNameRef = toRef(propertyName.ustring().rep());210 RefPtr<OpaqueJSString> propertyNameRef; 202 211 203 212 for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parentClass) { 204 213 if (JSObjectDeletePropertyCallback deleteProperty = jsClass->deleteProperty) { 205 if (deleteProperty(ctx, thisRef, propertyNameRef, toRef(exec->exceptionSlot()))) 214 if (!propertyNameRef) 215 propertyNameRef = OpaqueJSString::create(propertyName.ustring()); 216 if (deleteProperty(ctx, thisRef, propertyNameRef.get(), toRef(exec->exceptionSlot()))) 206 217 return true; 207 218 } … … 431 442 432 443 JSObjectRef thisRef = toRef(thisObj); 433 JSStringRef propertyNameRef = toRef(propertyName.ustring().rep());444 RefPtr<OpaqueJSString> propertyNameRef; 434 445 435 446 for (JSClassRef jsClass = thisObj->m_class; jsClass; jsClass = jsClass->parentClass) … … 437 448 if (StaticValueEntry* entry = staticValues->get(propertyName.ustring().rep())) 438 449 if (JSObjectGetPropertyCallback getProperty = entry->getProperty) { 439 if (JSValueRef value = getProperty(toRef(exec), thisRef, propertyNameRef, toRef(exec->exceptionSlot()))) 450 if (!propertyNameRef) 451 propertyNameRef = OpaqueJSString::create(propertyName.ustring()); 452 if (JSValueRef value = getProperty(toRef(exec), thisRef, propertyNameRef.get(), toRef(exec->exceptionSlot()))) 440 453 return toJS(value); 441 454 } … … 477 490 478 491 JSObjectRef thisRef = toRef(thisObj); 479 JSStringRef propertyNameRef = toRef(propertyName.ustring().rep());492 RefPtr<OpaqueJSString> propertyNameRef; 480 493 481 494 for (JSClassRef jsClass = thisObj->m_class; jsClass; jsClass = jsClass->parentClass) 482 495 if (JSObjectGetPropertyCallback getProperty = jsClass->getProperty) { 483 if (JSValueRef value = getProperty(toRef(exec), thisRef, propertyNameRef, toRef(exec->exceptionSlot()))) 496 if (!propertyNameRef) 497 propertyNameRef = OpaqueJSString::create(propertyName.ustring()); 498 if (JSValueRef value = getProperty(toRef(exec), thisRef, propertyNameRef.get(), toRef(exec->exceptionSlot()))) 484 499 return toJS(value); 485 500 }
Note:
See TracChangeset
for help on using the changeset viewer.