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

Method hasObjectProperty

valdi/src/valdi/v8/V8JavaScriptContext.cpp:587–609  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

585 if (!local->IsObject()) {
586 exceptionTracker.onError("Cannot getObject property on non object value");
587 return JSValueRef();
588 }
589
590 v8::Local<v8::Context> context = v8::Local<v8::Context>::New(_isolate, _context);
591 auto val = v8::Local<v8::Object>::Cast(local);
592
593 v8::Local<v8::Value> retval;
594 if (!val->Get(context, static_cast<uint32_t>(index)).ToLocal(&retval)) {
595 exceptionTracker.onError("Failed to fetch object at requested index");
596 return JSValueRef();
597 }
598
599 return toRetainedJSValueRef(IndirectV8Persistent::make(_isolate, retval));
600}
601
602bool V8JavaScriptContext::hasObjectProperty(const JSValue& object, const JSPropertyName& propertyName) {
603 v8::HandleScope handleScope(_isolate);
604 JSExceptionTracker tracker(*this);
605
606 auto obj = v8::Local<v8::Object>::Cast(fromValdiJSValue(_isolate, object, tracker));
607 if (!tracker) {
608 tracker.clearError();
609 return false;
610 }
611
612 if (!obj->IsObject()) {

Callers 2

isJSPromiseCancelableMethod · 0.45
hasValueForObjectKeyMethod · 0.45

Calls 6

clearErrorMethod · 0.80
fromValdiJSValueFunction · 0.70
fromValdiJSPropertyNameFunction · 0.70
CastFunction · 0.50
NewFunction · 0.50
FromMaybeMethod · 0.45

Tested by

no test coverage detected