summaryrefslogtreecommitdiff
path: root/lib/Data/QRCode/XS.pm
blob: aa8597a8f9117d373939023a31653282d812dabb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package Data::QRCode::XS; 
use strict;
use warnings;
# ABSTRACT: qrcodes in C 
# VERSION 
use Data::QRCode::XS::Inline with => 'Alien::QREncode';
use Data::QRCode::XS::Inline => (
    'DATA',
    autowrap => 1,
    typemaps => 'typemap',
);
 
1;
 
__DATA__
__C__
 
int ECLEVEL_L() { return QR_ECLEVEL_L; }
int ECLEVEL_M() { return QR_ECLEVEL_M; }
int ECLEVEL_Q() { return QR_ECLEVEL_Q; }
int ECLEVEL_H() { return QR_ECLEVEL_H; }
 
#define CLASS "Data::QRCode" 
 
QRcode* _build(const char* class, SV* data, int level, int version ) {
    unsigned char * str;
    STRLEN len;
 
    str = SvPVutf8(data,len);
    return QRcode_encodeData(len,str,version,(QRecLevel)level);
}
 
int version(QRcode* self) {
    return self->version;
}
 
int width(QRcode* self) {
    return self->width;
}
 
void DESTROY(QRcode* self) {
    QRcode_free(self);
}
 
int _data_at(QRcode* self, int x, int y) {
    return self->data[x+y*self->width];
}