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

Method MarkAsByteCallback

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

Source from the content-addressed store, hash-verified

199}
200
201void NumericCasts::MarkAsByteCallback(const v8::FunctionCallbackInfo<Value>& args) {
202 try {
203 auto isolate = args.GetIsolate();
204
205 if (args.Length() != 1) {
206 throw NativeScriptException(string("byte(x) should be called with single parameter"));
207 }
208 if (!args[0]->IsString() && !args[0]->IsStringObject() && !args[0]->IsNumber() && !args[0]->IsNumberObject()) {
209 throw NativeScriptException(string("byte(x) should be called with single parameter containing a byte number representation"));
210 }
211
212 Local<Value> value;
213 auto context = isolate->GetCurrentContext();
214 if (args[0]->IsInt32()) {
215 value = args[0]->ToInt32(context).ToLocalChecked();
216 } else {
217 value = args[0]->ToString(context).ToLocalChecked();
218 }
219
220 auto cast = Object::New(isolate);
221 MarkJsObject(isolate, cast, CastType::Byte, value);
222 args.GetReturnValue().Set(cast);
223 } catch (NativeScriptException& e) {
224 e.ReThrowToV8();
225 } catch (std::exception e) {
226 stringstream ss;
227 ss << "Error: c++ exception: " << e.what() << endl;
228 NativeScriptException nsEx(ss.str());
229 nsEx.ReThrowToV8();
230 } catch (...) {
231 NativeScriptException nsEx(std::string("Error: c++ exception!"));
232 nsEx.ReThrowToV8();
233 }
234}
235
236void NumericCasts::MarkAsShortCallback(const v8::FunctionCallbackInfo<Value>& args) {
237 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