| 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(); |
| 1120 | } |
| 1121 | |
| 1122 | auto arrayBuffer = checkCallAndGetValue(exceptionTracker, |
| 1123 | JS_GetTypedArrayBuffer(_context, jsValue, nullptr, nullptr, nullptr)); |
| 1124 | if (!exceptionTracker) { |
| 1125 | return Valdi::JSTypedArray(); |
| 1126 | } |
| 1127 | |
| 1128 | size_t length = 0; |
| 1129 | size_t bytesLength = 0; |
| 1130 | auto* ptr = JS_GetTypedArrayData(_context, jsValue, &length, &bytesLength); |
| 1131 | if (!checkCall(exceptionTracker, ptr == nullptr ? -1 : 0)) { |
| 1132 | return Valdi::JSTypedArray(); |
| 1133 | } |
| 1134 | |
| 1135 | auto type = toValdiTypedArrayType(arrayType); |
| 1136 | |
| 1137 | return Valdi::JSTypedArray(type, ptr, static_cast<size_t>(bytesLength), std::move(arrayBuffer)); |
| 1138 | } |
| 1139 | } |
| 1140 | |
| 1141 | Valdi::ValueType QuickJSJavaScriptContext::getValueType(const Valdi::JSValue& value) { |
| 1142 | auto guard = _threadAccessChecker.guard(); |
| 1143 | auto jsValue = fromValdiJSValue(value); |
| 1144 | |
| 1145 | if (JS_IsUndefined(jsValue) != 0) { |
| 1146 | return Valdi::ValueType::Undefined; |
| 1147 | } |
| 1148 | if (JS_IsNull(jsValue) != 0) { |
| 1149 | return Valdi::ValueType::Null; |
| 1150 | } |
| 1151 | if (JS_IsString(jsValue) != 0) { |
| 1152 | return Valdi::ValueType::StaticString; |
| 1153 | } |
| 1154 | if (JS_IsNumber(jsValue) != 0) { |
| 1155 | return Valdi::ValueType::Double; |
| 1156 | } |
| 1157 | if (JS_IsBool(jsValue) != 0) { |
| 1158 | return Valdi::ValueType::Bool; |
| 1159 | } |
| 1160 | if (JS_IsArray(_context, jsValue) != 0) { |
| 1161 | return Valdi::ValueType::Array; |
| 1162 | } |
| 1163 | if (JS_IsObjectOfClass(_context, jsValue, getWrappedObjectClassDef()->classID) != 0) { |
| 1164 | return Valdi::ValueType::ValdiObject; |
| 1165 | } |
| 1166 | if (JS_IsFunction(_context, jsValue) != 0) { |
| 1167 | return Valdi::ValueType::Function; |
| 1168 | } |
| 1169 | if (JS_GetTypedArrayType(_context, jsValue) != JS_TYPED_ARRAY_NONE || JS_IsArrayBuffer(_context, jsValue) != 0) { |
| 1170 | return Valdi::ValueType::TypedArray; |
| 1171 | } |
| 1172 | if (JS_IsError(_context, jsValue) != 0) { |
| 1173 | return Valdi::ValueType::Error; |
| 1174 | } |
| 1175 | if (JS_IsSymbol(jsValue) != 0) { |
nothing calls this directly
no test coverage detected