MCPcopy Create free account
hub / github.com/NativeScript/android / MarkAsDoubleCallback

Method MarkAsDoubleCallback

test-app/runtime/src/main/cpp/NumericCasts.cpp:334–361  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

332}
333
334void NumericCasts::MarkAsDoubleCallback(const v8::FunctionCallbackInfo<Value>& args) {
335 try {
336 auto isolate = args.GetIsolate();
337
338 if (args.Length() != 1) {
339 throw NativeScriptException(string("double(x) should be called with single parameter"));
340 }
341 if (!args[0]->IsNumber()) {
342 throw NativeScriptException(string("double(x) should be called with single parameter containing a double number representation"));
343 }
344
345 auto context = isolate->GetCurrentContext();
346 auto value = args[0]->ToNumber(context).ToLocalChecked();
347 auto cast = Object::New(isolate);
348 MarkJsObject(isolate, cast, CastType::Double, value);
349 args.GetReturnValue().Set(cast);
350 } catch (NativeScriptException& e) {
351 e.ReThrowToV8();
352 } catch (std::exception e) {
353 stringstream ss;
354 ss << "Error: c++ exception: " << e.what() << endl;
355 NativeScriptException nsEx(ss.str());
356 nsEx.ReThrowToV8();
357 } catch (...) {
358 NativeScriptException nsEx(std::string("Error: c++ exception!"));
359 nsEx.ReThrowToV8();
360 }
361}
362
363void NumericCasts::MarkJsObject(Isolate* isolate, const Local<Object>& object, CastType castType, const Local<Value>& value) {
364 auto key = ArgConverter::ConvertToV8String(isolate, s_castMarker);

Callers 1

Calls 9

NewFunction · 0.85
ToLocalCheckedMethod · 0.80
GetReturnValueMethod · 0.80
ReThrowToV8Method · 0.80
GetIsolateMethod · 0.45
LengthMethod · 0.45
SetMethod · 0.45
whatMethod · 0.45

Tested by

no test coverage detected