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

Method valueToLong

valdi/src/valdi/runtime/Interfaces/IJavaScriptContext.cpp:259–295  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

257}
258
259JavaScriptLong IJavaScriptContext::valueToLong(const JSValue& value, JSExceptionTracker& exceptionTracker) {
260 static auto kLow = STRING_LITERAL("low");
261 static auto kHigh = STRING_LITERAL("high");
262 static auto kUnsigned = STRING_LITERAL("unsigned");
263
264 auto low = getObjectProperty(value, getPropertyNameCached(kLow), exceptionTracker);
265 if (!exceptionTracker) {
266 return JavaScriptLong();
267 }
268
269 auto high = getObjectProperty(value, getPropertyNameCached(kHigh), exceptionTracker);
270 if (!exceptionTracker) {
271 return JavaScriptLong();
272 }
273
274 auto isUnsigned = getObjectProperty(value, getPropertyNameCached(kUnsigned), exceptionTracker);
275 if (!exceptionTracker) {
276 return JavaScriptLong();
277 }
278
279 auto lowValue = valueToInt(low.get(), exceptionTracker);
280 if (!exceptionTracker) {
281 return JavaScriptLong();
282 }
283
284 auto highValue = valueToInt(high.get(), exceptionTracker);
285 if (!exceptionTracker) {
286 return JavaScriptLong();
287 }
288
289 auto isUnsignedValue = valueToBool(isUnsigned.get(), exceptionTracker);
290 if (!exceptionTracker) {
291 return JavaScriptLong();
292 }
293
294 return JavaScriptLong(static_cast<int32_t>(lowValue), static_cast<int32_t>(highValue), isUnsignedValue);
295}
296
297JSValueRef IJavaScriptContext::evaluateNative(const std::string_view& /*sourceFilename*/,
298 JSExceptionTracker& exceptionTracker) {

Callers

nothing calls this directly

Calls 2

JavaScriptLongClass · 0.70
getMethod · 0.65

Tested by

no test coverage detected