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

Method getObjectPropertyForIndex

valdi/src/valdi/v8/V8JavaScriptContext.cpp:561–585  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

559}
560
561JSValueRef V8JavaScriptContext::getObjectPropertyForIndex(const JSValue& object,
562 size_t index,
563 JSExceptionTracker& exceptionTracker) {
564 v8::HandleScope handleScope(_isolate);
565 auto local = fromValdiJSValue(_isolate, object, exceptionTracker);
566 if (!exceptionTracker) {
567 return JSValueRef();
568 }
569
570 if (!local->IsObject()) {
571 exceptionTracker.onError("Cannot getObject property on non object value");
572 return JSValueRef();
573 }
574
575 v8::Local<v8::Context> context = v8::Local<v8::Context>::New(_isolate, _context);
576 auto val = v8::Local<v8::Object>::Cast(local);
577
578 v8::Local<v8::Value> retval;
579 if (!val->Get(context, static_cast<uint32_t>(index)).ToLocal(&retval)) {
580 exceptionTracker.onError("Failed to fetch object at requested index");
581 return JSValueRef();
582 }
583
584 return toRetainedJSValueRef(IndirectV8Persistent::make(_isolate, retval));
585}
586
587bool V8JavaScriptContext::hasObjectProperty(const JSValue& object, const JSPropertyName& propertyName) {
588 v8::HandleScope handleScope(_isolate);

Callers 8

jsArrayToValueFunction · 0.45
visitES6CollectionMethod · 0.45
getArrayItemMethod · 0.45
setProtobufRepeatedFieldFunction · 0.45
getMessageIndexesFunction · 0.45
codepointsToStrMethod · 0.45
mainFunction · 0.45

Calls 6

ToLocalMethod · 0.80
fromValdiJSValueFunction · 0.70
onErrorMethod · 0.65
NewFunction · 0.50
CastFunction · 0.50
GetMethod · 0.45

Tested by

no test coverage detected