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

Method valueToDouble

valdi/src/valdi/v8/V8JavaScriptContext.cpp:825–855  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

823 JSExceptionTracker& exceptionTracker,
824 IJavaScriptPropertyNamesVisitor& visitor) {
825 v8::HandleScope handleScope(_isolate);
826 auto obj = v8::Local<v8::Object>::Cast(fromValdiJSValue(_isolate, object, exceptionTracker));
827 if (!exceptionTracker) {
828 return;
829 }
830 if (!obj->IsObject()) {
831 exceptionTracker.onError("Cannot invoke visitObjectPropertyNames on a non object");
832 return;
833 }
834
835 v8::Local<v8::Context> context = v8::Local<v8::Context>::New(_isolate, _context);
836 v8::Local<v8::Array> properties;
837 if (!obj->GetPropertyNames(context).ToLocal(&properties)) {
838 exceptionTracker.onError("Cannot get property list from object");
839 return;
840 }
841
842 bool shouldContinue = true;
843 for (uint32_t i = 0; i < properties->Length() && shouldContinue && exceptionTracker; i++) {
844 v8::Local<v8::Value> ival;
845 if (!properties->Get(context, i).ToLocal(&ival)) {
846 // NOTE(rjaber): Should never happen
847 assert(false);
848 }
849 auto propertyName = toValdiJSPropertyName(IndirectV8Persistent::make(_isolate, ival));
850 shouldContinue = visitor.visitPropertyName(*this, object, propertyName, exceptionTracker);
851 }
852}
853
854StringBox V8JavaScriptContext::valueToString(const JSValue& value, JSExceptionTracker& exceptionTracker) {
855 v8::HandleScope handleScope(_isolate);
856 v8::Local<v8::Value> val = fromValdiJSValue(_isolate, value, exceptionTracker);
857 if (!exceptionTracker) {
858 return StringBox();

Callers 2

marshallMethod · 0.45
mainFunction · 0.45

Calls 5

ToLocalMethod · 0.80
ToMethod · 0.80
fromValdiJSValueFunction · 0.70
onErrorMethod · 0.65
NewFunction · 0.50

Tested by

no test coverage detected