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

Method MarkAsShortCallback

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

Source from the content-addressed store, hash-verified

234}
235
236void NumericCasts::MarkAsShortCallback(const v8::FunctionCallbackInfo<Value>& args) {
237 try {
238 auto isolate = args.GetIsolate();
239
240 if (args.Length() != 1) {
241 throw NativeScriptException(string("short(x) should be called with single parameter"));
242 return;
243 }
244 if (!args[0]->IsString() && !args[0]->IsStringObject() && !args[0]->IsNumber() && !args[0]->IsNumberObject()) {
245 throw NativeScriptException(string("short(x) should be called with single parameter containing a short number representation"));
246 }
247
248 Local<Value> value;
249 auto context = isolate->GetCurrentContext();
250 if (args[0]->IsInt32()) {
251 value = args[0]->ToInt32(context).ToLocalChecked();
252 } else {
253 value = args[0]->ToString(context).ToLocalChecked();
254 }
255
256 auto cast = Object::New(isolate);
257 MarkJsObject(isolate, cast, CastType::Short, value);
258 args.GetReturnValue().Set(cast);
259 } catch (NativeScriptException& e) {
260 e.ReThrowToV8();
261 } catch (std::exception e) {
262 stringstream ss;
263 ss << "Error: c++ exception: " << e.what() << endl;
264 NativeScriptException nsEx(ss.str());
265 nsEx.ReThrowToV8();
266 } catch (...) {
267 NativeScriptException nsEx(std::string("Error: c++ exception!"));
268 nsEx.ReThrowToV8();
269 }
270}
271
272void NumericCasts::MarkAsCharCallback(const v8::FunctionCallbackInfo<Value>& args) {
273 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