MCPcopy Create free account
hub / github.com/Snapchat/Valdi / put

Method put

third-party/jscore/include/JavaScriptCore/JSCallbackObjectFunctions.h:241–302  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

239
240template <class Parent>
241bool JSCallbackObject<Parent>::put(JSCell* cell, ExecState* exec, PropertyName propertyName, JSValue value, PutPropertySlot& slot)
242{
243 VM& vm = exec->vm();
244 auto scope = DECLARE_THROW_SCOPE(vm);
245
246 JSCallbackObject* thisObject = jsCast<JSCallbackObject*>(cell);
247 JSContextRef ctx = toRef(exec);
248 JSObjectRef thisRef = toRef(thisObject);
249 RefPtr<OpaqueJSString> propertyNameRef;
250 JSValueRef valueRef = toRef(exec, value);
251
252 if (StringImpl* name = propertyName.uid()) {
253 for (JSClassRef jsClass = thisObject->classRef(); jsClass; jsClass = jsClass->parentClass) {
254 if (JSObjectSetPropertyCallback setProperty = jsClass->setProperty) {
255 if (!propertyNameRef)
256 propertyNameRef = OpaqueJSString::create(name);
257 JSValueRef exception = 0;
258 bool result;
259 {
260 JSLock::DropAllLocks dropAllLocks(exec);
261 result = setProperty(ctx, thisRef, propertyNameRef.get(), valueRef, &exception);
262 }
263 if (exception)
264 throwException(exec, scope, toJS(exec, exception));
265 if (result || exception)
266 return result;
267 }
268
269 if (OpaqueJSClassStaticValuesTable* staticValues = jsClass->staticValues(exec)) {
270 if (StaticValueEntry* entry = staticValues->get(name)) {
271 if (entry->attributes & kJSPropertyAttributeReadOnly)
272 return false;
273 if (JSObjectSetPropertyCallback setProperty = entry->setProperty) {
274 JSValueRef exception = 0;
275 bool result;
276 {
277 JSLock::DropAllLocks dropAllLocks(exec);
278 result = setProperty(ctx, thisRef, entry->propertyNameRef.get(), valueRef, &exception);
279 }
280 if (exception)
281 throwException(exec, scope, toJS(exec, exception));
282 if (result || exception)
283 return result;
284 }
285 }
286 }
287
288 if (OpaqueJSClassStaticFunctionsTable* staticFunctions = jsClass->staticFunctions(exec)) {
289 if (StaticFunctionEntry* entry = staticFunctions->get(name)) {
290 PropertySlot getSlot(thisObject, PropertySlot::InternalMethodType::VMInquiry);
291 if (Parent::getOwnPropertySlot(thisObject, exec, propertyName, getSlot))
292 return Parent::put(thisObject, exec, propertyName, value, slot);
293 if (entry->attributes & kJSPropertyAttributeReadOnly)
294 return false;
295 return thisObject->JSCallbackObject<Parent>::putDirect(vm, propertyName, value); // put as override property
296 }
297 }
298 }

Callers

nothing calls this directly

Calls 5

toRefFunction · 0.85
toJSFunction · 0.85
getMethod · 0.65
createFunction · 0.50
classRefMethod · 0.45

Tested by

no test coverage detected