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

Method MarkAsCharCallback

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

Source from the content-addressed store, hash-verified

270}
271
272void NumericCasts::MarkAsCharCallback(const v8::FunctionCallbackInfo<Value>& args) {
273 try {
274 auto isolate = args.GetIsolate();
275
276 if (args.Length() != 1) {
277 throw NativeScriptException(string("char(x) should be called with single parameter"));
278 }
279 if (!args[0]->IsString()) {
280 throw NativeScriptException(string("char(x) should be called with single parameter containing a char representation"));
281 }
282
283 auto context = isolate->GetCurrentContext();
284 auto value = args[0]->ToString(context).ToLocalChecked();
285 if (value->Length() != 1) {
286 throw NativeScriptException(string("char(x) should be called with single parameter containing a single char"));
287 }
288
289 auto cast = Object::New(isolate);
290 MarkJsObject(isolate, cast, CastType::Char, value);
291 args.GetReturnValue().Set(cast);
292 } catch (NativeScriptException& e) {
293 e.ReThrowToV8();
294 } catch (std::exception e) {
295 stringstream ss;
296 ss << "Error: c++ exception: " << e.what() << endl;
297 NativeScriptException nsEx(ss.str());
298 nsEx.ReThrowToV8();
299 } catch (...) {
300 NativeScriptException nsEx(std::string("Error: c++ exception!"));
301 nsEx.ReThrowToV8();
302 }
303}
304
305void NumericCasts::MarkAsFloatCallback(const v8::FunctionCallbackInfo<Value>& args) {
306 try {

Callers 1

Calls 11

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

Tested by

no test coverage detected