| 24 | } |
| 25 | |
| 26 | Box* toBox(Nan::NAN_METHOD_ARGS_TYPE args, int start, int* end) |
| 27 | { |
| 28 | if (args[start]->IsNumber() && args[start + 1]->IsNumber() |
| 29 | && args[start + 2]->IsNumber() && args[start + 3]->IsNumber()) { |
| 30 | int x = floor(args[start + 0]->NumberValue()); |
| 31 | int y = floor(args[start + 1]->NumberValue()); |
| 32 | int width = ceil(args[start + 2]->NumberValue()); |
| 33 | int height = ceil(args[start + 3]->NumberValue()); |
| 34 | if (end) { |
| 35 | *end = start + 3; |
| 36 | } |
| 37 | return boxCreate(x, y, width, height); |
| 38 | } else if (args[start]->IsObject()) { |
| 39 | Handle<Object> object = args[start]->ToObject(); |
| 40 | int x = floor(Nan::Get(object, Nan::New("x").ToLocalChecked()).ToLocalChecked()->NumberValue()); |
| 41 | int y = floor(Nan::Get(object, Nan::New("y").ToLocalChecked()).ToLocalChecked()->NumberValue()); |
| 42 | int width = ceil(Nan::Get(object, Nan::New("width").ToLocalChecked()).ToLocalChecked()->NumberValue()); |
| 43 | int height = ceil(Nan::Get(object, Nan::New("height").ToLocalChecked()).ToLocalChecked()->NumberValue()); |
| 44 | if (end) { |
| 45 | *end = start; |
| 46 | } |
| 47 | return boxCreate(x, y, width, height); |
| 48 | } else { |
| 49 | if (end) { |
| 50 | *end = start - 1; |
| 51 | } |
| 52 | return 0; |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | int toOp(v8::Local<v8::Value> value) |
| 57 | { |
no test coverage detected