diff --git a/deps/common.gyp b/deps/common.gyp index fd3c25c..284a50f 100644 --- a/deps/common.gyp +++ b/deps/common.gyp @@ -12,12 +12,13 @@ 'xcode_settings': { 'GCC_ENABLE_CPP_EXCEPTIONS': 'YES', 'OTHER_CFLAGS': [ '-O3', '-march=native', '-w' ], - 'OTHER_CPLUSPLUSFLAGS' : ['-Wno-c++11-narrowing'] + 'OTHER_CPLUSPLUSFLAGS' : ['-Wno-c++11-narrowing', '-std=c++11', '-stdlib=libc++', '-mmacosx-version-min=10.9'] } } ], ['OS=="win"', { + 'defines!': ['_HAS_EXCEPTIONS=0'], 'configurations': { 'Debug': { 'msvs_settings': { diff --git a/deps/zxing/zxing.gyp b/deps/zxing/zxing.gyp index d93e507..e423196 100644 --- a/deps/zxing/zxing.gyp +++ b/deps/zxing/zxing.gyp @@ -120,6 +120,15 @@ ], } ], + ['OS=="mac"', + { + "link_settings" : { + 'libraries': [ + '/usr/lib/libiconv.dylib', + ], + } + } + ] ], }, ] diff --git a/src/zxing.cc b/src/zxing.cc index 9631132..53f35f5 100644 --- a/src/zxing.cc +++ b/src/zxing.cc @@ -263,7 +263,7 @@ NAN_METHOD(ZXing::FindCode) object->Set(Nan::New("data").ToLocalChecked(), Nan::New(resultStr.c_str()).ToLocalChecked()); object->Set(Nan::New("buffer").ToLocalChecked(), - Nan::NewBuffer((char*)resultStr.data(), resultStr.length()).ToLocalChecked()); + Nan::CopyBuffer((char*)resultStr.data(), resultStr.length()).ToLocalChecked()); Local points = Nan::New(); auto strX = Nan::New("x").ToLocalChecked(); auto strY = Nan::New("y").ToLocalChecked(); diff --git a/test/fixtures/barcode4.png b/test/fixtures/barcode4.png new file mode 100644 index 0000000..38eb6e1 Binary files /dev/null and b/test/fixtures/barcode4.png differ diff --git a/test/zxing.test.js b/test/zxing.test.js index 2eb4b46..b31b169 100644 --- a/test/zxing.test.js +++ b/test/zxing.test.js @@ -11,6 +11,7 @@ describe('ZXing', function(){ this.barcode1 = new dv.Image("png", fs.readFileSync(__dirname + '/fixtures/barcode1.png')); this.barcode2 = new dv.Image("png", fs.readFileSync(__dirname + '/fixtures/barcode2.png')); this.barcode3 = new dv.Image("png", fs.readFileSync(__dirname + '/fixtures/barcode3.png')); + this.barcode4 = new dv.Image("png", fs.readFileSync(__dirname + '/fixtures/barcode4.png')); }) it('should have no #image set', function(){ should.not.exist(this.zxing.image); @@ -52,6 +53,11 @@ describe('ZXing', function(){ code.data.should.equal('This PDF417 barcode has error correction level 4'); should.exist(code.points); }) + it('should find QR Code', function(){ + this.zxing.image = this.barcode4; + var code = this.zxing.findCode(); + code.type.should.equal('QR'); + }) }) describe('#findCode() with tryHarder', function(){ before(function(){