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

Method valueToWrappedObject

valdi/src/valdi/v8/V8JavaScriptContext.cpp:873–898  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

871 auto stringLength = stringValue.length();
872
873 return StringCache::getGlobal().makeString(stringData, stringLength);
874}
875
876Ref<StaticString> V8JavaScriptContext::valueToStaticString(const JSValue& value, JSExceptionTracker& exceptionTracker) {
877 v8::HandleScope handleScope(_isolate);
878 v8::Local<v8::Value> val = fromValdiJSValue(_isolate, value, exceptionTracker);
879 if (!exceptionTracker) {
880 return nullptr;
881 }
882 v8::Local<v8::Context> context = v8::Local<v8::Context>::New(_isolate, _context);
883 v8::Local<v8::String> string;
884 if (!val->ToString(context).ToLocal(&string)) {
885 exceptionTracker.onError("Failed to convert value to static string");
886 return nullptr;
887 }
888
889 const int length = string->Utf8Length(_isolate);
890 Ref<StaticString> str = StaticString::makeUTF8(length);
891 string->WriteUtf8(_isolate, str->utf8Data(), length);
892
893 return str;
894}
895
896bool V8JavaScriptContext::valueToBool(const JSValue& value, JSExceptionTracker& exceptionTracker) {
897 v8::HandleScope handleScope(_isolate);
898
899 auto val_ = fromValdiJSValue(_isolate, value, exceptionTracker);
900 if (!exceptionTracker) {
901 return false;

Callers 4

unwrapWrappedObjectFunction · 0.45
thisFromCallContextFunction · 0.45

Calls 7

getWithWrapperIDMethod · 0.80
onErrorMethod · 0.65
CastFunction · 0.50
isEmptyMethod · 0.45
GetInternalFieldMethod · 0.45
ValueMethod · 0.45

Tested by

no test coverage detected