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

Method MarkAsFloatCallback

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

Source from the content-addressed store, hash-verified

303}
304
305void NumericCasts::MarkAsFloatCallback(const v8::FunctionCallbackInfo<Value>& args) {
306 try {
307 auto isolate = args.GetIsolate();
308
309 if (args.Length() != 1) {
310 throw NativeScriptException(string("float(x) should be called with single parameter"));
311 }
312 if (!args[0]->IsNumber()) {
313 throw NativeScriptException(string("float(x) should be called with single parameter containing a float number representation"));
314 }
315
316 auto context = isolate->GetCurrentContext();
317 auto value = args[0]->ToNumber(context).ToLocalChecked();
318 auto cast = Object::New(isolate);
319 MarkJsObject(isolate, cast, CastType::Float, value);
320 args.GetReturnValue().Set(cast);
321 } catch (NativeScriptException& e) {
322 e.ReThrowToV8();
323 } catch (std::exception e) {
324 stringstream ss;
325 ss << "Error: c++ exception: " << e.what() << endl;
326 NativeScriptException nsEx(ss.str());
327 nsEx.ReThrowToV8();
328 } catch (...) {
329 NativeScriptException nsEx(std::string("Error: c++ exception!"));
330 nsEx.ReThrowToV8();
331 }
332}
333
334void NumericCasts::MarkAsDoubleCallback(const v8::FunctionCallbackInfo<Value>& args) {
335 try {

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