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

Function onObjectBegin

valdi/src/valdi/quickjs/QuickJSJavaScriptContext.cpp:1071–1116  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1069 double number = 0;
1070
1071 if (!checkCall(exceptionTracker, JS_ToFloat64(_context, &number, fromValdiJSValue(value)))) {
1072 return 0;
1073 }
1074
1075 return number;
1076}
1077
1078int32_t QuickJSJavaScriptContext::valueToInt(const Valdi::JSValue& value, Valdi::JSExceptionTracker& exceptionTracker) {
1079 auto guard = _threadAccessChecker.guard();
1080 int32_t number = 0;
1081
1082 if (!checkCall(exceptionTracker, JS_ToInt32(_context, &number, fromValdiJSValue(value)))) {
1083 return 0;
1084 }
1085
1086 return number;
1087}
1088
1089Valdi::Ref<Valdi::RefCountable> QuickJSJavaScriptContext::valueToWrappedObject(
1090 const Valdi::JSValue& value, Valdi::JSExceptionTracker& /*exceptionTracker*/) {
1091 auto guard = _threadAccessChecker.guard();
1092 return Valdi::unwrapNativeClassInstanceData(getObjectWrappedObject(fromValdiJSValue(value)));
1093}
1094
1095Valdi::Ref<Valdi::JSFunction> QuickJSJavaScriptContext::valueToFunction(
1096 const Valdi::JSValue& value, Valdi::JSExceptionTracker& /*exceptionTracker*/) {
1097 auto guard = _threadAccessChecker.guard();
1098 return Valdi::Ref(getObjectCallable(fromValdiJSValue(value)));
1099}
1100
1101Valdi::JSTypedArray QuickJSJavaScriptContext::valueToTypedArray(const Valdi::JSValue& value,
1102 Valdi::JSExceptionTracker& exceptionTracker) {
1103 auto guard = _threadAccessChecker.guard();
1104 auto jsValue = fromValdiJSValue(value);
1105
1106 if (JS_IsArrayBuffer(_context, jsValue) != 0) {
1107 size_t size = 0;
1108 auto* buffer = JS_GetArrayBuffer(_context, &size, jsValue);
1109
1110 if (!checkCall(exceptionTracker, buffer == nullptr ? -1 : 0)) {
1111 return Valdi::JSTypedArray();
1112 }
1113
1114 return Valdi::JSTypedArray(Valdi::ArrayBuffer, buffer, size, toUnretainedJSValueRef(jsValue));
1115 } else {
1116 auto arrayType = JS_GetTypedArrayType(_context, jsValue);
1117 if (arrayType == JS_TYPED_ARRAY_NONE) {
1118 checkCallAndGetValue(exceptionTracker, JS_ThrowTypeError(_context, "value is not a typed array"));
1119 return Valdi::JSTypedArray();

Callers

nothing calls this directly

Calls 4

getHeapDumpBuilderFunction · 0.85
getGlobalFunction · 0.85
makeStringMethod · 0.80
beginNodeMethod · 0.80

Tested by

no test coverage detected