Skip to content

Commit b2fb9d4

Browse files
Merge pull request #250 from justadudewhohacks/reduce-macroing
refactoring + fixes
2 parents 01aadd4 + c7e0ae4 commit b2fb9d4

File tree

102 files changed

+10273
-9515
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

102 files changed

+10273
-9515
lines changed

binding.gyp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
"cc/modules/io/io.cc",
3838
"cc/modules/io/VideoCapture.cc",
3939
"cc/modules/io/VideoWriter.cc",
40-
"cc/modules/photo.cc",
40+
"cc/modules/photo/photo.cc",
4141
"cc/modules/video/video.cc",
4242
"cc/modules/video/BackgroundSubtractor.cc",
4343
"cc/modules/video/BackgroundSubtractorMOG2.cc",

cc/CatchCvExceptionWorker.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
#include "Workers.h"
1+
#include "NativeNodeUtils.h"
22

33
#ifndef __FF_CATCHCVEXCEPTIONWORKER_H__
44
#define __FF_CATCHCVEXCEPTIONWORKER_H__
55

6-
struct CatchCvExceptionWorker : public SimpleWorker {
6+
struct CatchCvExceptionWorker : public FF::SimpleWorker {
77
public:
88
std::string execute() {
99
try {

cc/CustomMatAllocator.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,14 @@
44
#include <thread>
55
#include <stdint.h>
66

7-
#include "Converters.h"
7+
#include "NativeNodeUtils.h"
88
#include "Size.h"
99
#include "coreUtils.h"
1010
#include "matUtils.h"
1111
#include "Vec.h"
1212
#include "Point2.h"
1313
#include "Rect.h"
1414
#include "RotatedRect.h"
15-
#include "Workers.h"
1615

1716
// only valid for 3.1.0+
1817
#if CV_VERSION_MINOR > 0

cc/core/Mat.cc

Lines changed: 597 additions & 1217 deletions
Large diffs are not rendered by default.

cc/core/Mat.h

Lines changed: 78 additions & 127 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,35 @@
1-
#include "Size.h"
21
#include "coreUtils.h"
32
#include "matUtils.h"
43
#include "Vec.h"
54
#include "Point2.h"
65
#include "Rect.h"
76
#include "RotatedRect.h"
8-
#include "Converters.h"
97
#include "CatchCvExceptionWorker.h"
108
#include "macros.h"
9+
#include "NativeNodeUtils.h"
10+
#include "ExternalMemTracking.h"
1111

1212
#ifndef __FF_MAT_H__
1313
#define __FF_MAT_H__
1414

1515
class Mat : public Nan::ObjectWrap {
1616
public:
1717
cv::Mat mat;
18-
19-
static NAN_MODULE_INIT(Init);
20-
static NAN_METHOD(New);
2118

22-
static NAN_METHOD(Eye);
23-
static NAN_METHOD(FlattenFloat);
19+
static Nan::Persistent<v8::FunctionTemplate> constructor;
20+
21+
void setNativeProps(cv::Mat);
22+
23+
cv::Mat* getNativeObjectPtr() { return &mat; }
24+
cv::Mat getNativeObject() { return mat; }
25+
26+
typedef InstanceConverter<Mat, cv::Mat> Converter;
27+
28+
static const char* getClassName() {
29+
return "Mat";
30+
}
31+
32+
static NAN_MODULE_INIT(Init);
2433

2534
static FF_GETTER(Mat, GetRows, mat.rows);
2635
static FF_GETTER(Mat, GetCols, mat.cols);
@@ -44,134 +53,76 @@ class Mat : public Nan::ObjectWrap {
4453
info.GetReturnValue().Set(IntArrayConverter::wrap(sizes));
4554
};
4655

47-
static NAN_METHOD(At);
48-
static NAN_METHOD(AtRaw);
49-
static NAN_METHOD(Set);
50-
51-
struct PushBackWorker;
52-
static NAN_METHOD(PushBack);
53-
static NAN_METHOD(PushBackAsync);
54-
struct PopBackWorker;
55-
static NAN_METHOD(PopBack);
56-
static NAN_METHOD(PopBackAsync);
57-
58-
struct GetDataWorker;
59-
static NAN_METHOD(GetData);
60-
static NAN_METHOD(GetDataAsync);
61-
62-
static NAN_METHOD(GetDataAsArray);
63-
static NAN_METHOD(GetRegion);
64-
static NAN_METHOD(Row);
65-
66-
struct CopyWorker;
67-
static NAN_METHOD(Copy);
68-
static NAN_METHOD(CopyAsync);
69-
70-
struct CopyToWorker;
71-
static NAN_METHOD(CopyTo);
72-
static NAN_METHOD(CopyToAsync);
73-
74-
struct ConvertToWorker;
75-
static NAN_METHOD(ConvertTo);
76-
static NAN_METHOD(ConvertToAsync);
77-
78-
static NAN_METHOD(Norm);
79-
static NAN_METHOD(Normalize);
80-
81-
struct SplitChannelsWorker;
82-
static NAN_METHOD(SplitChannels);
83-
static NAN_METHOD(SplitChannelsAsync);
84-
85-
struct AddWeightedWorker;
86-
static NAN_METHOD(AddWeighted);
87-
static NAN_METHOD(AddWeightedAsync);
88-
89-
struct MinMaxLocWorker;
90-
static NAN_METHOD(MinMaxLoc);
91-
static NAN_METHOD(MinMaxLocAsync);
92-
93-
struct FindNonZeroWorker;
94-
static NAN_METHOD(FindNonZero);
95-
static NAN_METHOD(FindNonZeroAsync);
96-
97-
struct CountNonZeroWorker;
98-
static NAN_METHOD(CountNonZero);
99-
static NAN_METHOD(CountNonZeroAsync);
100-
101-
struct PadToSquareWorker;
102-
static NAN_METHOD(PadToSquare);
103-
static NAN_METHOD(PadToSquareAsync);
104-
105-
struct SumWorker;
106-
static NAN_METHOD(Sum);
107-
static NAN_METHOD(SumAsync);
108-
109-
struct ConvertScaleAbsWorker;
110-
static NAN_METHOD(ConvertScaleAbs);
111-
static NAN_METHOD(ConvertScaleAbsAsync);
112-
113-
struct GoodFeaturesToTrackWorker;
114-
static NAN_METHOD(GoodFeaturesToTrack);
115-
static NAN_METHOD(GoodFeaturesToTrackAsync);
116-
11756
FF_INIT_MAT_OPERATIONS();
11857
static NAN_METHOD(Dot) {
11958
FF_OPERATOR_RET_SCALAR(&cv::Mat::dot, FF_APPLY_CLASS_FUNC, FF_UNWRAP_MAT_AND_GET, Mat);
12059
}
12160

122-
struct DTWorker;
123-
struct DCTWorker;
124-
struct DFTWorker;
125-
static NAN_METHOD(Dct);
126-
static NAN_METHOD(DctAsync);
127-
static NAN_METHOD(Idct);
128-
static NAN_METHOD(IdctAsync);
129-
static NAN_METHOD(Dft);
130-
static NAN_METHOD(DftAsync);
131-
static NAN_METHOD(Idft);
132-
static NAN_METHOD(IdftAsync);
133-
134-
struct MulSpectrumsWorker;
135-
static NAN_METHOD(MulSpectrums);
136-
static NAN_METHOD(MulSpectrumsAsync);
137-
138-
struct TransformWorker;
139-
struct PerspectiveTransformWorker;
140-
static NAN_METHOD(Transform);
141-
static NAN_METHOD(TransformAsync);
142-
static NAN_METHOD(PerspectiveTransform);
143-
static NAN_METHOD(PerspectiveTransformAsync);
144-
145-
struct OpWithCodeWorker;
146-
struct FlipWorker;
147-
static NAN_METHOD(Flip);
148-
static NAN_METHOD(FlipAsync);
149-
150-
struct MeanStdDevWorker;
151-
static NAN_METHOD(MeanStdDev);
152-
static NAN_METHOD(MeanStdDevAsync);
153-
61+
static NAN_METHOD(New);
62+
static NAN_METHOD(Eye);
63+
static NAN_METHOD(FlattenFloat);
64+
static NAN_METHOD(At);
65+
static NAN_METHOD(AtRaw);
66+
static NAN_METHOD(Set);
67+
static NAN_METHOD(GetDataAsArray);
68+
static NAN_METHOD(GetRegion);
69+
static NAN_METHOD(Norm);
70+
static NAN_METHOD(Normalize);
71+
static NAN_METHOD(Row);
72+
static NAN_METHOD(Release);
73+
static NAN_METHOD(PushBack);
74+
static NAN_METHOD(PushBackAsync);
75+
static NAN_METHOD(PopBack);
76+
static NAN_METHOD(PopBackAsync);
77+
static NAN_METHOD(GetData);
78+
static NAN_METHOD(GetDataAsync);
79+
static NAN_METHOD(Copy);
80+
static NAN_METHOD(CopyAsync);
81+
static NAN_METHOD(CopyTo);
82+
static NAN_METHOD(CopyToAsync);
83+
static NAN_METHOD(ConvertTo);
84+
static NAN_METHOD(ConvertToAsync);
85+
static NAN_METHOD(SplitChannels);
86+
static NAN_METHOD(SplitChannelsAsync);
87+
static NAN_METHOD(AddWeighted);
88+
static NAN_METHOD(AddWeightedAsync);
89+
static NAN_METHOD(MinMaxLoc);
90+
static NAN_METHOD(MinMaxLocAsync);
91+
static NAN_METHOD(FindNonZero);
92+
static NAN_METHOD(FindNonZeroAsync);
93+
static NAN_METHOD(CountNonZero);
94+
static NAN_METHOD(CountNonZeroAsync);
95+
static NAN_METHOD(PadToSquare);
96+
static NAN_METHOD(PadToSquareAsync);
97+
static NAN_METHOD(Dct);
98+
static NAN_METHOD(DctAsync);
99+
static NAN_METHOD(Idct);
100+
static NAN_METHOD(IdctAsync);
101+
static NAN_METHOD(Dft);
102+
static NAN_METHOD(DftAsync);
103+
static NAN_METHOD(Idft);
104+
static NAN_METHOD(IdftAsync);
105+
static NAN_METHOD(MulSpectrums);
106+
static NAN_METHOD(MulSpectrumsAsync);
107+
static NAN_METHOD(Transform);
108+
static NAN_METHOD(TransformAsync);
109+
static NAN_METHOD(PerspectiveTransform);
110+
static NAN_METHOD(PerspectiveTransformAsync);
111+
static NAN_METHOD(Flip);
112+
static NAN_METHOD(FlipAsync);
113+
static NAN_METHOD(Sum);
114+
static NAN_METHOD(SumAsync);
115+
static NAN_METHOD(ConvertScaleAbs);
116+
static NAN_METHOD(ConvertScaleAbsAsync);
117+
static NAN_METHOD(GoodFeaturesToTrack);
118+
static NAN_METHOD(GoodFeaturesToTrackAsync);
119+
static NAN_METHOD(MeanStdDev);
120+
static NAN_METHOD(MeanStdDevAsync);
154121
#if CV_VERSION_MINOR > 1
155-
struct RotateWorker;
156-
static NAN_METHOD(Rotate);
157-
static NAN_METHOD(RotateAsync);
122+
static NAN_METHOD(Rotate);
123+
static NAN_METHOD(RotateAsync);
158124
#endif
159125

160-
static NAN_METHOD(Release);
161-
162-
163-
static Nan::Persistent<v8::FunctionTemplate> constructor;
164-
165-
void setNativeProps(cv::Mat);
166-
167-
cv::Mat* getNativeObjectPtr() { return &mat; }
168-
cv::Mat getNativeObject() { return mat; }
169-
170-
typedef InstanceConverter<Mat, cv::Mat> Converter;
171-
172-
static const char* getClassName() {
173-
return "Mat";
174-
}
175126
};
176127

177128
#endif

0 commit comments

Comments
 (0)