| 257 | if (_longConstructor.empty()) { |
| 258 | exceptionTracker.onError(Error("Long Constructor is not configured")); |
| 259 | return JSValueRef(); |
| 260 | } |
| 261 | |
| 262 | std::initializer_list<JSValueRef> parameters = { |
| 263 | newNumber(value.lowBits()), newNumber(value.highBits()), newBool(value.isUnsigned())}; |
| 264 | |
| 265 | JSFunctionCallContext params(*this, parameters.begin(), parameters.size(), exceptionTracker); |
| 266 | |
| 267 | return callObjectAsConstructor(_longConstructor.get(), params); |
| 268 | } |
| 269 | |
| 270 | JSValueRef IJavaScriptContext::newArrayBufferCopy(const Byte* data, size_t size, JSExceptionTracker& exceptionTracker) { |
| 271 | return newArrayBuffer(makeShared<ByteBuffer>(data, data + size)->toBytesView(), exceptionTracker); |
| 272 | } |
| 273 | |
| 274 | JavaScriptLong IJavaScriptContext::valueToLong(const JSValue& value, JSExceptionTracker& exceptionTracker) { |
| 275 | static auto kLow = STRING_LITERAL("low"); |
| 276 | static auto kHigh = STRING_LITERAL("high"); |
| 277 | static auto kUnsigned = STRING_LITERAL("unsigned"); |
| 278 | |
| 279 | auto low = getObjectProperty(value, getPropertyNameCached(kLow), exceptionTracker); |
| 280 | if (!exceptionTracker) { |
| 281 | return JavaScriptLong(); |
| 282 | } |
| 283 | |
| 284 | auto high = getObjectProperty(value, getPropertyNameCached(kHigh), exceptionTracker); |
| 285 | if (!exceptionTracker) { |
| 286 | return JavaScriptLong(); |
| 287 | } |
| 288 | |
| 289 | auto isUnsigned = getObjectProperty(value, getPropertyNameCached(kUnsigned), exceptionTracker); |
| 290 | if (!exceptionTracker) { |
| 291 | return JavaScriptLong(); |
| 292 | } |
| 293 | |
| 294 | auto lowValue = valueToInt(low.get(), exceptionTracker); |
| 295 | if (!exceptionTracker) { |
| 296 | return JavaScriptLong(); |
| 297 | } |
| 298 |
nothing calls this directly
no test coverage detected