Skip to content

Commit 41c52ac

Browse files
committed
Remove preprocessor directives for node <4
1 parent 1ecc702 commit 41c52ac

File tree

4 files changed

+0
-68
lines changed

4 files changed

+0
-68
lines changed

src/Canvas.cc

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -180,47 +180,25 @@ NAN_SETTER(Canvas::SetHeight) {
180180
* EIO toBuffer callback.
181181
*/
182182

183-
#if NODE_VERSION_AT_LEAST(0, 6, 0)
184183
void
185184
Canvas::ToBufferAsync(uv_work_t *req) {
186-
#elif NODE_VERSION_AT_LEAST(0, 5, 4)
187-
void
188-
Canvas::EIO_ToBuffer(eio_req *req) {
189-
#else
190-
int
191-
Canvas::EIO_ToBuffer(eio_req *req) {
192-
#endif
193185
closure_t *closure = (closure_t *) req->data;
194186

195187
closure->status = canvas_write_to_png_stream(
196188
closure->canvas->surface()
197189
, toBuffer
198190
, closure);
199-
200-
#if !NODE_VERSION_AT_LEAST(0, 5, 4)
201-
return 0;
202-
#endif
203191
}
204192

205193
/*
206194
* EIO after toBuffer callback.
207195
*/
208196

209-
#if NODE_VERSION_AT_LEAST(0, 6, 0)
210197
void
211198
Canvas::ToBufferAsyncAfter(uv_work_t *req) {
212-
#else
213-
int
214-
Canvas::EIO_AfterToBuffer(eio_req *req) {
215-
#endif
216-
217199
Nan::HandleScope scope;
218200
closure_t *closure = (closure_t *) req->data;
219-
#if NODE_VERSION_AT_LEAST(0, 6, 0)
220201
delete req;
221-
#else
222-
ev_unref(EV_DEFAULT_UC);
223-
#endif
224202

225203
if (closure->status) {
226204
Local<Value> argv[1] = { Canvas::Error(closure->status) };
@@ -236,10 +214,6 @@ Canvas::EIO_AfterToBuffer(eio_req *req) {
236214
delete closure->pfn;
237215
closure_destroy(closure);
238216
free(closure);
239-
240-
#if !NODE_VERSION_AT_LEAST(0, 6, 0)
241-
return 0;
242-
#endif
243217
}
244218

245219
/*
@@ -328,14 +302,9 @@ NAN_METHOD(Canvas::ToBuffer) {
328302
canvas->Ref();
329303
closure->pfn = new Nan::Callback(info[0].As<Function>());
330304

331-
#if NODE_VERSION_AT_LEAST(0, 6, 0)
332305
uv_work_t* req = new uv_work_t;
333306
req->data = closure;
334307
uv_queue_work(uv_default_loop(), req, ToBufferAsync, (uv_after_work_cb)ToBufferAsyncAfter);
335-
#else
336-
eio_custom(EIO_ToBuffer, EIO_PRI_DEFAULT, EIO_AfterToBuffer, closure);
337-
ev_ref(EV_DEFAULT_UC);
338-
#endif
339308

340309
return;
341310
// Sync

src/Canvas.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -63,19 +63,8 @@ class Canvas: public Nan::ObjectWrap {
6363
static NAN_METHOD(StreamJPEGSync);
6464
static NAN_METHOD(RegisterFont);
6565
static Local<Value> Error(cairo_status_t status);
66-
#if NODE_VERSION_AT_LEAST(0, 6, 0)
6766
static void ToBufferAsync(uv_work_t *req);
6867
static void ToBufferAsyncAfter(uv_work_t *req);
69-
#else
70-
static
71-
#if NODE_VERSION_AT_LEAST(0, 5, 4)
72-
void
73-
#else
74-
int
75-
#endif
76-
EIO_ToBuffer(eio_req *req);
77-
static int EIO_AfterToBuffer(eio_req *req);
78-
#endif
7968
static PangoWeight GetWeightFromCSSString(const char *weight);
8069
static PangoStyle GetStyleFromCSSString(const char *style);
8170
static PangoFontDescription *ResolveFontDescription(const PangoFontDescription *desc);

src/CanvasRenderingContext2d.cc

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -697,16 +697,8 @@ NAN_METHOD(Context2d::GetImageData) {
697697

698698
uint8_t *src = canvas->data();
699699

700-
#if NODE_MAJOR_VERSION == 0 && NODE_MINOR_VERSION <= 10
701-
Local<Object> global = Context::GetCurrent()->Global();
702-
703-
Local<Int32> sizeHandle = Nan::New(size);
704-
Local<Value> caargv[] = { sizeHandle };
705-
Local<Object> clampedArray = global->Get(Nan::New("Uint8ClampedArray").ToLocalChecked()).As<Function>()->NewInstance(1, caargv);
706-
#else
707700
Local<ArrayBuffer> buffer = ArrayBuffer::New(Isolate::GetCurrent(), size);
708701
Local<Uint8ClampedArray> clampedArray = Uint8ClampedArray::New(buffer, 0, size);
709-
#endif
710702

711703
Nan::TypedArrayContents<uint8_t> typedArrayContents(clampedArray);
712704
uint8_t* dst = *typedArrayContents;

src/ImageData.cc

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,7 @@ NAN_METHOD(ImageData::New) {
3939
return Nan::ThrowTypeError("Class constructors cannot be invoked without 'new'");
4040
}
4141

42-
#if NODE_MAJOR_VERSION == 0 && NODE_MINOR_VERSION <= 10
43-
Local<v8::Object> clampedArray;
44-
Local<Object> global = Context::GetCurrent()->Global();
45-
#else
4642
Local<Uint8ClampedArray> clampedArray;
47-
#endif
48-
4943
uint32_t width;
5044
uint32_t height;
5145
int length;
@@ -63,23 +57,11 @@ NAN_METHOD(ImageData::New) {
6357
}
6458
length = width * height * 4;
6559

66-
#if NODE_MAJOR_VERSION == 0 && NODE_MINOR_VERSION <= 10
67-
Local<Int32> sizeHandle = Nan::New(length);
68-
Local<Value> caargv[] = { sizeHandle };
69-
clampedArray = global->Get(Nan::New("Uint8ClampedArray").ToLocalChecked()).As<Function>()->NewInstance(1, caargv);
70-
#else
7160
clampedArray = Uint8ClampedArray::New(ArrayBuffer::New(Isolate::GetCurrent(), length), 0, length);
72-
#endif
7361

74-
#if NODE_MAJOR_VERSION == 0 && NODE_MINOR_VERSION <= 10
75-
} else if (info[0]->ToObject()->GetIndexedPropertiesExternalArrayDataType() == kExternalPixelArray && info[1]->IsUint32()) {
76-
clampedArray = info[0]->ToObject();
77-
length = clampedArray->GetIndexedPropertiesExternalArrayDataLength();
78-
#else
7962
} else if (info[0]->IsUint8ClampedArray() && info[1]->IsUint32()) {
8063
clampedArray = info[0].As<Uint8ClampedArray>();
8164
length = clampedArray->Length();
82-
#endif
8365
if (length == 0) {
8466
Nan::ThrowRangeError("The input data has a zero byte length.");
8567
return;

0 commit comments

Comments
 (0)