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

Method MarkAsLongCallback

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

Source from the content-addressed store, hash-verified

164}
165
166void NumericCasts::MarkAsLongCallback(const v8::FunctionCallbackInfo<Value>& args) {
167 try {
168 auto isolate = args.GetIsolate();
169
170 if (args.Length() != 1) {
171 throw NativeScriptException(string("long(x) should be called with single parameter"));
172 }
173 if (!args[0]->IsString() && !args[0]->IsStringObject() && !args[0]->IsNumber() && !args[0]->IsNumberObject()) {
174 throw NativeScriptException(string("long(x) should be called with single parameter containing a long number representation"));
175 }
176
177 Local<Value> value;
178 auto context = isolate->GetCurrentContext();
179 if (args[0]->IsInt32()) {
180 value = args[0]->ToInt32(context).ToLocalChecked();
181 } else {
182 value = args[0]->ToString(context).ToLocalChecked();
183 }
184
185 auto cast = Object::New(isolate);
186 MarkJsObject(isolate, cast, CastType::Long, value);
187 args.GetReturnValue().Set(cast);
188 } catch (NativeScriptException& e) {
189 e.ReThrowToV8();
190 } catch (std::exception e) {
191 stringstream ss;
192 ss << "Error: c++ exception: " << e.what() << endl;
193 NativeScriptException nsEx(ss.str());
194 nsEx.ReThrowToV8();
195 } catch (...) {
196 NativeScriptException nsEx(std::string("Error: c++ exception!"));
197 nsEx.ReThrowToV8();
198 }
199}
200
201void NumericCasts::MarkAsByteCallback(const v8::FunctionCallbackInfo<Value>& args) {
202 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