diff options
author | dakkar <dakkar@thenautilus.net> | 2016-11-10 13:27:18 +0000 |
---|---|---|
committer | dakkar <dakkar@thenautilus.net> | 2016-11-10 13:39:29 +0000 |
commit | 61f964216b16b25200e2a2ac961f7444c0570daf (patch) | |
tree | a39731665727a5f0a5aaa20c1c8c92a8f1a1ffcc /lib/Data/QRCode.pm | |
parent | try using more magic (diff) | |
download | Data-QRCode-61f964216b16b25200e2a2ac961f7444c0570daf.tar.gz Data-QRCode-61f964216b16b25200e2a2ac961f7444c0570daf.tar.bz2 Data-QRCode-61f964216b16b25200e2a2ac961f7444c0570daf.zip |
split into input / qrcode
Diffstat (limited to 'lib/Data/QRCode.pm')
-rw-r--r-- | lib/Data/QRCode.pm | 45 |
1 files changed, 29 insertions, 16 deletions
diff --git a/lib/Data/QRCode.pm b/lib/Data/QRCode.pm index 680e251..b7f8c4e 100644 --- a/lib/Data/QRCode.pm +++ b/lib/Data/QRCode.pm @@ -3,33 +3,27 @@ use strict; use warnings; # ABSTRACT: qrcodes in C # VERSION -use Data::QRCode::XS; - -my %levels = ( - L => Data::QRCode::XS::ECLEVEL_L(), - M => Data::QRCode::XS::ECLEVEL_M(), - Q => Data::QRCode::XS::ECLEVEL_Q(), - H => Data::QRCode::XS::ECLEVEL_H(), +use Data::QRCode::Inline with => 'Alien::QREncode'; +use Data::QRCode::Inline C => ( + 'DATA', + autowrap => 1, + typemaps => 'typemap', ); sub new { - my ($class, $data, $level, $version) = @_; - $version ||= 0; - $level = $levels{uc $level} || Data::QRCode::XS::ECLEVEL_M(); - return Data::QRCode::XS::_build($class,$data,$level,$version); + my ($class, $input) = @_; + my $self = QRcode_encodeInput($input); + bless $self, $class; + return $self; } -sub width { Data::QRCode::XS::width(@_) } - -sub version { Data::QRCode::XS::version(@_) } - sub data_at { my ($self,$x,$y) = @_; my $width = $self->width; if ($x < 0 or $x >= $width or $y < 0 or $y >= $width) { return; } - my $value = Data::QRCode::XS::_data_at($self,$x,$y); + my $value = _data_at($self,$x,$y); return { color => $value & 0x01, @@ -44,3 +38,22 @@ sub data_at { } 1; + +__DATA__ +__C__ + +QRcode *QRcode_encodeInput(QRinput *input); + +void DESTROY(QRcode *qrcode) { QRcode_free(qrcode); } + +int version(QRcode* self) { + return self->version; +} + +int width(QRcode* self) { + return self->width; +} + +int _data_at(QRcode* self, int x, int y) { + return self->data[x+y*self->width]; +} |