Skip to content

Commit

Permalink
Merge pull request #558 from justadudewhohacks/remove-macro-inferno
Browse files Browse the repository at this point in the history
remove macro inferno and fix node12 specific compiler warnings
  • Loading branch information
justadudewhohacks authored May 23, 2019
2 parents 0a86131 + e5e8199 commit 3b0f0c2
Show file tree
Hide file tree
Showing 154 changed files with 3,366 additions and 2,138 deletions.
1 change: 0 additions & 1 deletion binding.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"cc/core",
"cc/modules",
"<!(node -e \"require('nan')\")",
"<!(node -e \"require('macro-inferno')\")",
"<!(node -e \"require('native-node-utils')\")"
],
"libraries": [
Expand Down
10 changes: 5 additions & 5 deletions cc/ExternalMemTracking.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ NAN_METHOD(ExternalMemTracking::GetMemMetrics) {
}
#endif

FF_OBJ result = FF_NEW_OBJ();
Nan::Set(result, FF_NEW_STRING("TotalAlloc"), Nan::New((double)TotalAlloc));
Nan::Set(result, FF_NEW_STRING("TotalKnownByJS"), Nan::New((double)TotalKnownByJS));
Nan::Set(result, FF_NEW_STRING("NumAllocations"), Nan::New((double)NumAllocations));
Nan::Set(result, FF_NEW_STRING("NumDeAllocations"), Nan::New((double)NumDeAllocations));
v8::Local<v8::Object> result = Nan::New<v8::Object>();
Nan::Set(result, FF::newString("TotalAlloc"), Nan::New((double)TotalAlloc));
Nan::Set(result, FF::newString("TotalKnownByJS"), Nan::New((double)TotalKnownByJS));
Nan::Set(result, FF::newString("NumAllocations"), Nan::New((double)NumAllocations));
Nan::Set(result, FF::newString("NumDeAllocations"), Nan::New((double)NumDeAllocations));

info.GetReturnValue().Set(result);
return;
Expand Down
188 changes: 106 additions & 82 deletions cc/core/Mat.cc

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions cc/core/Mat.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ class Mat : public Nan::ObjectWrap {
static NAN_METHOD(GetRegion);
static NAN_METHOD(Norm);
static NAN_METHOD(Normalize);
static NAN_METHOD(NormalizeAsync);
static NAN_METHOD(Row);
static NAN_METHOD(Release);
static NAN_METHOD(PushBack);
Expand Down
92 changes: 71 additions & 21 deletions cc/core/MatBindings.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ namespace MatBindings {
return "";
}

FF_VAL getReturnValue() {
v8::Local<v8::Value> getReturnValue() {
return Mat::Converter::wrap(returnValue);
}

Expand Down Expand Up @@ -88,7 +88,7 @@ namespace MatBindings {
);
}

FF_VAL getReturnValue() {
v8::Local<v8::Value> getReturnValue() {
return Mat::Converter::wrap(self);
}
};
Expand All @@ -113,7 +113,7 @@ namespace MatBindings {
);
}

FF_VAL getReturnValue() {
v8::Local<v8::Value> getReturnValue() {
return Mat::Converter::wrap(self);
}
};
Expand Down Expand Up @@ -148,7 +148,7 @@ namespace MatBindings {
free(data);
}

FF_VAL getReturnValue() {
v8::Local<v8::Value> getReturnValue() {
return Nan::NewBuffer(data, size, freeBufferCallback, 0).ToLocalChecked();
}
};
Expand All @@ -168,7 +168,7 @@ namespace MatBindings {
return "";
}

FF_VAL getReturnValue() {
v8::Local<v8::Value> getReturnValue() {
return Mat::Converter::wrap(dst);
}

Expand Down Expand Up @@ -233,7 +233,7 @@ namespace MatBindings {
}

bool hasOptArgsObject(Nan::NAN_METHOD_ARGS_TYPE info) {
return FF_ARG_IS_OBJECT(1);
return FF::isArgObject(info, 1);
}

bool unwrapOptionalArgsFromOpts(Nan::NAN_METHOD_ARGS_TYPE info) {
Expand Down Expand Up @@ -326,11 +326,11 @@ namespace MatBindings {
}

v8::Local<v8::Value> getReturnValue() {
FF_OBJ ret = FF_NEW_OBJ();
Nan::Set(ret, FF_NEW_STRING("minVal"), Nan::New(minVal));
Nan::Set(ret, FF_NEW_STRING("maxVal"), Nan::New(maxVal));
Nan::Set(ret, FF_NEW_STRING("minLoc"), Point2::Converter::wrap(minLoc));
Nan::Set(ret, FF_NEW_STRING("maxLoc"), Point2::Converter::wrap(maxLoc));
v8::Local<v8::Object> ret = Nan::New<v8::Object>();
Nan::Set(ret, FF::newString("minVal"), Nan::New(minVal));
Nan::Set(ret, FF::newString("maxVal"), Nan::New(maxVal));
Nan::Set(ret, FF::newString("minLoc"), Point2::Converter::wrap(minLoc));
Nan::Set(ret, FF::newString("maxLoc"), Point2::Converter::wrap(maxLoc));
return ret;
}
};
Expand Down Expand Up @@ -422,7 +422,7 @@ namespace MatBindings {

cv::Mat dst;

FF_VAL getReturnValue() {
v8::Local<v8::Value> getReturnValue() {
return Mat::Converter::wrap(dst);
}

Expand Down Expand Up @@ -474,11 +474,11 @@ namespace MatBindings {
}

bool hasOptArgsObject(Nan::NAN_METHOD_ARGS_TYPE info) {
return FF_ARG_IS_OBJECT(0);
return FF::isArgObject(info, 0);
}

bool unwrapOptionalArgsFromOpts(Nan::NAN_METHOD_ARGS_TYPE info) {
FF_OBJ opts = info[0]->ToObject(Nan::GetCurrentContext()).ToLocalChecked();
v8::Local<v8::Object> opts = info[0]->ToObject(Nan::GetCurrentContext()).ToLocalChecked();
return (
IntConverter::optProp(&flags, "flags", opts) ||
IntConverter::optProp(&nonzeroRows, "nonzeroRows", opts)
Expand Down Expand Up @@ -507,7 +507,7 @@ namespace MatBindings {
return "";
}

FF_VAL getReturnValue() {
v8::Local<v8::Value> getReturnValue() {
return Mat::Converter::wrap(dst);
}

Expand All @@ -523,11 +523,11 @@ namespace MatBindings {
}

bool hasOptArgsObject(Nan::NAN_METHOD_ARGS_TYPE info) {
return FF_ARG_IS_OBJECT(1);
return FF::isArgObject(info, 1);
}

bool unwrapOptionalArgsFromOpts(Nan::NAN_METHOD_ARGS_TYPE info) {
FF_OBJ opts = info[1]->ToObject(Nan::GetCurrentContext()).ToLocalChecked();
v8::Local<v8::Object> opts = info[1]->ToObject(Nan::GetCurrentContext()).ToLocalChecked();
return (
BoolConverter::optProp(&dftRows, "dftRows", opts) ||
BoolConverter::optProp(&conjB, "conjB", opts)
Expand Down Expand Up @@ -670,7 +670,7 @@ namespace MatBindings {
}

bool hasOptArgsObject(Nan::NAN_METHOD_ARGS_TYPE info) {
return FF_ARG_IS_OBJECT(0);
return FF::isArgObject(info, 0);
}

bool unwrapOptionalArgsFromOpts(Nan::NAN_METHOD_ARGS_TYPE info) {
Expand Down Expand Up @@ -735,7 +735,7 @@ namespace MatBindings {
}

bool hasOptArgsObject(Nan::NAN_METHOD_ARGS_TYPE info) {
return FF_ARG_IS_OBJECT(3);
return FF::isArgObject(info, 3);
}

bool unwrapOptionalArgsFromOpts(Nan::NAN_METHOD_ARGS_TYPE info) {
Expand Down Expand Up @@ -767,7 +767,7 @@ namespace MatBindings {
return "";
}

FF_VAL getReturnValue() {
v8::Local<v8::Value> getReturnValue() {
return ObjectArrayConverter<Point2, cv::Point2f>::wrap(corners);
}
};
Expand Down Expand Up @@ -883,7 +883,7 @@ namespace MatBindings {
}

bool hasOptArgsObject(Nan::NAN_METHOD_ARGS_TYPE info) {
return FF_ARG_IS_OBJECT(4);
return FF::isArgObject(info, 4);
}

bool unwrapOptionalArgsFromOpts(Nan::NAN_METHOD_ARGS_TYPE info) {
Expand Down Expand Up @@ -986,6 +986,56 @@ namespace MatBindings {
);
}
};

struct NormalizeWorker : public CatchCvExceptionWorker {
public:
cv::Mat self;
NormalizeWorker(cv::Mat self) {
this->self = self;
}

double alpha = 1;
double beta = 0;
int norm_type = cv::NORM_L2;
int dtype = -1;
cv::Mat mask = cv::noArray().getMat();

cv::Mat returnValue;

std::string executeCatchCvExceptionWorker() {
cv::normalize(self, returnValue, alpha, beta, norm_type, dtype, mask);
return "";
}

v8::Local<v8::Value> getReturnValue() {
return Mat::Converter::wrap(returnValue);
}

bool unwrapOptionalArgs(Nan::NAN_METHOD_ARGS_TYPE info) {
return (
DoubleConverter::optArg(0, &alpha, info) ||
DoubleConverter::optArg(1, &beta, info) ||
IntConverter::optArg(2, &norm_type, info) ||
IntConverter::optArg(3, &dtype, info) ||
Mat::Converter::optArg(4, &mask, info)
);
}

bool hasOptArgsObject(Nan::NAN_METHOD_ARGS_TYPE info) {
return FF::isArgObject(info, 0);
}

bool unwrapOptionalArgsFromOpts(Nan::NAN_METHOD_ARGS_TYPE info) {
v8::Local<v8::Object> opts = info[0]->ToObject(Nan::GetCurrentContext()).ToLocalChecked();
return (
DoubleConverter::optProp(&alpha, "alpha", opts) ||
DoubleConverter::optProp(&beta, "beta", opts) ||
IntConverter::optProp(&norm_type, "normType", opts) ||
IntConverter::optProp(&dtype, "dtype", opts) ||
Mat::Converter::optProp(&mask, "mask", opts)
);
}
};

#if CV_VERSION_MINOR > 1
struct RotateWorker : public OpWithCodeWorker {
Expand Down
8 changes: 4 additions & 4 deletions cc/core/MatCalib3dBindings.h
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ namespace MatCalib3dBindings {
}

bool hasOptArgsObject(Nan::NAN_METHOD_ARGS_TYPE info) {
return FF_ARG_IS_OBJECT(6);
return FF::isArgObject(info, 6);
}

bool unwrapOptionalArgsFromOpts(Nan::NAN_METHOD_ARGS_TYPE info) {
Expand Down Expand Up @@ -451,7 +451,7 @@ namespace MatCalib3dBindings {
}

bool hasOptArgsObject(Nan::NAN_METHOD_ARGS_TYPE info) {
return FF_ARG_IS_OBJECT(3);
return FF::isArgObject(info, 3);
}

bool unwrapOptionalArgsFromOpts(Nan::NAN_METHOD_ARGS_TYPE info) {
Expand Down Expand Up @@ -656,7 +656,7 @@ namespace MatCalib3dBindings {
}

bool hasOptArgsObject(Nan::NAN_METHOD_ARGS_TYPE info) {
return FF_ARG_IS_OBJECT(1);
return FF::isArgObject(info, 1);
}

bool unwrapOptionalArgsFromOpts(Nan::NAN_METHOD_ARGS_TYPE info) {
Expand Down Expand Up @@ -748,7 +748,7 @@ namespace MatCalib3dBindings {
}

bool hasOptArgsObject(Nan::NAN_METHOD_ARGS_TYPE info) {
return FF_ARG_IS_OBJECT(2);
return FF::isArgObject(info, 2);
}

bool unwrapOptionalArgsFromOpts(Nan::NAN_METHOD_ARGS_TYPE info) {
Expand Down
55 changes: 14 additions & 41 deletions cc/core/MatImgproc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ void MatImgproc::Init(v8::Local<v8::FunctionTemplate> ctor) {
Nan::SetPrototypeMethod(ctor, "findContours", FindContours);
Nan::SetPrototypeMethod(ctor, "findContoursAsync", FindContoursAsync);
Nan::SetPrototypeMethod(ctor, "drawContours", DrawContours);
Nan::SetPrototypeMethod(ctor, "drawContoursAsync", DrawContoursAsync);
Nan::SetPrototypeMethod(ctor, "drawLine", DrawLine);
Nan::SetPrototypeMethod(ctor, "drawArrowedLine", DrawArrowedLine);
Nan::SetPrototypeMethod(ctor, "drawCircle", DrawCircle);
Expand Down Expand Up @@ -113,47 +114,19 @@ void MatImgproc::Init(v8::Local<v8::FunctionTemplate> ctor) {
};

NAN_METHOD(MatImgproc::DrawContours) {
FF_METHOD_CONTEXT("Mat::DrawContours");

FF_ARG_ARRAY(0, FF_ARR jsContours);
FF_ARG_INSTANCE(1, cv::Vec3d color, Vec3::constructor, FF_UNWRAP_VEC3_AND_GET);

// optional args
bool hasOptArgsObj = FF_HAS_ARG(2) && info[2]->IsObject();
FF_OBJ optArgs = hasOptArgsObj ? info[2]->ToObject(Nan::GetCurrentContext()).ToLocalChecked() : FF_NEW_OBJ();
FF_GET_INT_IFDEF(optArgs, int contourIdx, "contourIdx", 0);
FF_GET_INT_IFDEF(optArgs, int maxLevel, "maxLevel", INT_MAX);
FF_GET_INSTANCE_IFDEF(optArgs, cv::Point2d offset, "offset", Point2::constructor, FF_UNWRAP_PT2_AND_GET, Point2, cv::Point2d());
FF_GET_INT_IFDEF(optArgs, int lineType, "lineType", cv::LINE_8);
FF_GET_INT_IFDEF(optArgs, int thickness, "thickness", 1);
if (!hasOptArgsObj) {
FF_ARG_INT_IFDEF(2, contourIdx, contourIdx);
FF_ARG_UINT_IFDEF(3, maxLevel, maxLevel);
FF_ARG_INSTANCE_IFDEF(4, offset, Point2::constructor, FF_UNWRAP_PT2_AND_GET, offset);
FF_ARG_INT_IFDEF(5, lineType, lineType);
FF_ARG_INT_IFDEF(6, thickness, thickness);
}

std::vector<std::vector<cv::Point>> contours;
std::vector<cv::Vec4i> hierarchy;
for (uint i = 0; i < jsContours->Length(); i++) {
FF_OBJ jsContour = jsContours->Get(i)->ToObject(Nan::GetCurrentContext()).ToLocalChecked();
contours.push_back(FF_UNWRAP_CONTOUR_AND_GET(jsContour));
hierarchy.push_back(FF_UNWRAP_CONTOUR(jsContour)->hierarchy);
}

cv::drawContours(
FF_UNWRAP_MAT_AND_GET(info.This()),
contours,
contourIdx,
color,
thickness,
lineType,
hierarchy,
(int)maxLevel,
offset
);
FF_RETURN(info.This());
FF::SyncBinding(
std::make_shared<MatImgprocBindings::DrawContoursWorker>(Mat::Converter::unwrap(info.This())),
"Mat::DrawContours",
info
);
}

NAN_METHOD(MatImgproc::DrawContoursAsync) {
FF::AsyncBinding(
std::make_shared<MatImgprocBindings::DrawContoursWorker>(Mat::Converter::unwrap(info.This())),
"Mat::DrawContoursAsync",
info
);
}

NAN_METHOD(MatImgproc::Rescale) {
Expand Down
1 change: 1 addition & 0 deletions cc/core/MatImgproc.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class MatImgproc {
static void Init(v8::Local<v8::FunctionTemplate> ctor);

static NAN_METHOD(DrawContours);
static NAN_METHOD(DrawContoursAsync);
static NAN_METHOD(Rescale);
static NAN_METHOD(RescaleAsync);
static NAN_METHOD(Resize);
Expand Down
Loading

0 comments on commit 3b0f0c2

Please sign in to comment.