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

Method getObjectPropertyForIndex

valdi/src/valdi/jscore/JavaScriptCoreContext.cpp:829–841  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

827 Valdi::JSExceptionTracker& exceptionTracker) {
828 if (_weakRefConstructor == nullptr) {
829 // No support for weak refs
830 auto jsValue = fromValdiJSValue(weakRef);
831 return returnJSValueRef(jsValue.valueRef, jsValue.type);
832 } else {
833 auto derefFn = toUnretainedJSValueRef(_weakRefDerefFunction, kJSTypeObject);
834
835 Valdi::JSFunctionCallContext callContext(*this, nullptr, 0, exceptionTracker);
836 callContext.setThisValue(weakRef);
837
838 auto target = callObjectAsFunction(derefFn.get(), callContext);
839 // iOS links the system JavaScriptCore, and the one shipped with iOS 15 returns null from
840 // WeakRef.prototype.deref() for a collected target. iOS 16+, the spec, and the other
841 // engines return undefined.
842 if (isValueNull(target.get())) {
843 return newUndefined();
844 }

Callers

nothing calls this directly

Calls 2

asObjectRefOrThrowMethod · 0.80
fromValdiJSValueFunction · 0.70

Tested by

no test coverage detected