line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# SPDX-License-Identifier: GPL-1.0-or-later OR Artistic-1.0-Perl |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package GS1::SyntaxEngine::FFI::GS1Encoder; |
4
|
|
|
|
|
|
|
$GS1::SyntaxEngine::FFI::GS1Encoder::VERSION = '0.2'; |
5
|
5
|
|
|
5
|
|
1201430
|
use utf8; |
|
5
|
|
|
|
|
44
|
|
|
5
|
|
|
|
|
27
|
|
6
|
|
|
|
|
|
|
|
7
|
5
|
|
|
5
|
|
2688
|
use strictures 2; |
|
5
|
|
|
|
|
8867
|
|
|
5
|
|
|
|
|
228
|
|
8
|
5
|
|
|
5
|
|
3432
|
use namespace::clean; |
|
5
|
|
|
|
|
82884
|
|
|
5
|
|
|
|
|
43
|
|
9
|
|
|
|
|
|
|
|
10
|
5
|
|
|
5
|
|
5461
|
use FFI::Platypus 2.08; |
|
5
|
|
|
|
|
40513
|
|
|
5
|
|
|
|
|
182
|
|
11
|
5
|
|
|
5
|
|
2476
|
use FFI::Platypus::Memory (); |
|
5
|
|
|
|
|
68489
|
|
|
5
|
|
|
|
|
207
|
|
12
|
|
|
|
|
|
|
|
13
|
5
|
|
|
5
|
|
2271
|
use Alien::libgs1encoders 0.03; |
|
5
|
|
|
|
|
237857
|
|
|
5
|
|
|
|
|
46
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
my $ffi = FFI::Platypus->new( |
16
|
|
|
|
|
|
|
api => 2, |
17
|
|
|
|
|
|
|
lib => [ Alien::libgs1encoders->dynamic_libs ] |
18
|
|
|
|
|
|
|
); |
19
|
|
|
|
|
|
|
$ffi->mangler( |
20
|
|
|
|
|
|
|
sub { |
21
|
|
|
|
|
|
|
my ($name) = @_; |
22
|
|
|
|
|
|
|
"gs1_encoder$name"; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
$ffi->attach( _instanceSize => ['void'] => 'size_t' ); |
27
|
|
|
|
|
|
|
$ffi->attach( _init => ['opaque'] => 'int' ); |
28
|
|
|
|
|
|
|
$ffi->attach( _getVersion => ['opaque'] => 'string' ); |
29
|
|
|
|
|
|
|
$ffi->attach( _getErrMsg => ['opaque'] => 'string' ); |
30
|
|
|
|
|
|
|
$ffi->attach( _getSym => ['opaque'] => 'int' ); |
31
|
|
|
|
|
|
|
$ffi->attach( _setSym => [ 'opaque', 'int' ] => 'bool' ); |
32
|
|
|
|
|
|
|
$ffi->attach( _getAddCheckDigit => ['opaque'] => 'bool' ); |
33
|
|
|
|
|
|
|
$ffi->attach( _setAddCheckDigit => [ 'opaque', 'bool' ] => 'bool' ); |
34
|
|
|
|
|
|
|
$ffi->attach( _getPermitUnknownAIs => ['opaque'] => 'bool' ); |
35
|
|
|
|
|
|
|
$ffi->attach( _setPermitUnknownAIs => [ 'opaque', 'bool' ] => 'bool' ); |
36
|
|
|
|
|
|
|
$ffi->attach( _getPermitZeroSuppressedGTINinDLuris => ['opaque'] => 'bool' ); |
37
|
|
|
|
|
|
|
$ffi->attach( |
38
|
|
|
|
|
|
|
_setPermitZeroSuppressedGTINinDLuris => [ 'opaque', 'bool' ] => 'bool' ); |
39
|
|
|
|
|
|
|
$ffi->attach( _getIncludeDataTitlesInHRI => ['opaque'] => 'bool' ); |
40
|
|
|
|
|
|
|
$ffi->attach( _setIncludeDataTitlesInHRI => [ 'opaque', 'bool' ] => 'bool' ); |
41
|
|
|
|
|
|
|
$ffi->attach( _getValidateAIassociations => ['opaque'] => 'bool' ); |
42
|
|
|
|
|
|
|
$ffi->attach( _setValidateAIassociations => [ 'opaque', 'bool' ] => 'bool' ); |
43
|
|
|
|
|
|
|
$ffi->attach( _getDLuri => [ 'opaque', 'string' ] => 'string' ); |
44
|
|
|
|
|
|
|
$ffi->attach( _getScanData => ['opaque'] => 'string' ); |
45
|
|
|
|
|
|
|
$ffi->attach( _setScanData => [ 'opaque', 'string' ] => 'bool' ); |
46
|
|
|
|
|
|
|
$ffi->attach( _getDataStr => ['opaque'] => 'string' ); |
47
|
|
|
|
|
|
|
$ffi->attach( _setDataStr => [ 'opaque', 'string' ] => 'bool' ); |
48
|
|
|
|
|
|
|
$ffi->attach( _getAIdataStr => ['opaque'] => 'string' ); |
49
|
|
|
|
|
|
|
$ffi->attach( _setAIdataStr => [ 'opaque', 'string' ] => 'bool' ); |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub new { |
52
|
5
|
|
|
5
|
0
|
560
|
my ($class) = @_; |
53
|
5
|
|
|
|
|
156
|
my $size = _instanceSize(); |
54
|
5
|
|
|
|
|
125
|
my $self = bless \FFI::Platypus::Memory::malloc($size), $class; |
55
|
5
|
|
|
|
|
22
|
my $r = _init( ${$self} ); |
|
5
|
|
|
|
|
983
|
|
56
|
5
|
|
|
|
|
35
|
return $self; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub _throw_error_exception { |
60
|
0
|
|
|
0
|
|
0
|
my ($self) = @_; |
61
|
0
|
|
|
|
|
0
|
GS1::SyntaxEngine::FFI::EncoderParameterException->throw( |
62
|
|
|
|
|
|
|
{ message => $self->error_msg } ); |
63
|
0
|
|
|
|
|
0
|
return; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub ai_data_str { |
67
|
3
|
|
|
3
|
0
|
7243
|
my ( $self, $value ) = @_; |
68
|
3
|
50
|
|
|
|
12
|
if ( @_ == 2 ) { |
69
|
0
|
0
|
|
|
|
0
|
_setAIdataStr( ${$self}, $value ) or $self->_throw_error_exception(); |
|
0
|
|
|
|
|
0
|
|
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
3
|
|
|
|
|
7
|
return _getAIdataStr( ${$self} ); |
|
3
|
|
|
|
|
57
|
|
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub data_str { |
76
|
8
|
|
|
8
|
0
|
465
|
my ( $self, $value ) = @_; |
77
|
8
|
100
|
|
|
|
31
|
if ( @_ == 2 ) { |
78
|
5
|
50
|
|
|
|
12
|
_setDataStr( ${$self}, $value ) or $self->_throw_error_exception(); |
|
5
|
|
|
|
|
93
|
|
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
8
|
|
|
|
|
17
|
return _getDataStr( ${$self} ); |
|
8
|
|
|
|
|
47
|
|
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub scan_data { |
85
|
0
|
|
|
0
|
0
|
0
|
my ( $self, $value ) = @_; |
86
|
0
|
0
|
|
|
|
0
|
if ( @_ == 2 ) { |
87
|
0
|
0
|
|
|
|
0
|
_setScanData( ${$self}, $value ) or $self->_throw_error_exception(); |
|
0
|
|
|
|
|
0
|
|
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
0
|
|
|
|
|
0
|
return _getScanData( ${$self} ); |
|
0
|
|
|
|
|
0
|
|
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
sub error_msg { |
94
|
0
|
|
|
0
|
0
|
0
|
my ($self) = @_; |
95
|
0
|
|
|
|
|
0
|
return _getErrMsg( ${$self} ); |
|
0
|
|
|
|
|
0
|
|
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
sub add_check_digit { |
99
|
0
|
|
|
0
|
0
|
0
|
my ( $self, $value ) = @_; |
100
|
0
|
0
|
|
|
|
0
|
if ( @_ == 2 ) { |
101
|
0
|
0
|
|
|
|
0
|
_setAddCheckDigit( ${$self}, $value ) |
|
0
|
|
|
|
|
0
|
|
102
|
|
|
|
|
|
|
or $self->_throw_error_exception(); |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
|
105
|
0
|
|
|
|
|
0
|
return _getAddCheckDigit( ${$self} ); |
|
0
|
|
|
|
|
0
|
|
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
sub permit_unknown_ais { |
109
|
0
|
|
|
0
|
0
|
0
|
my ( $self, $value ) = @_; |
110
|
0
|
0
|
|
|
|
0
|
if ( @_ == 2 ) { |
111
|
0
|
0
|
|
|
|
0
|
_setPermitUnknownAIs( ${$self}, $value ) |
|
0
|
|
|
|
|
0
|
|
112
|
|
|
|
|
|
|
or $self->_throw_error_exception(); |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
|
115
|
0
|
|
|
|
|
0
|
return _getPermitUnknownAIs( ${$self} ); |
|
0
|
|
|
|
|
0
|
|
116
|
|
|
|
|
|
|
} |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
sub permit_zero_suppressed_gtin_in_dl_uris { |
119
|
0
|
|
|
0
|
0
|
0
|
my ( $self, $value ) = @_; |
120
|
0
|
0
|
|
|
|
0
|
if ( @_ == 2 ) { |
121
|
0
|
0
|
|
|
|
0
|
_setPermitZeroSuppressedGTINinDLuris( ${$self}, $value ) |
|
0
|
|
|
|
|
0
|
|
122
|
|
|
|
|
|
|
or $self->_throw_error_exception(); |
123
|
|
|
|
|
|
|
} |
124
|
|
|
|
|
|
|
|
125
|
0
|
|
|
|
|
0
|
return _getPermitZeroSuppressedGTINinDLuris( ${$self} ); |
|
0
|
|
|
|
|
0
|
|
126
|
|
|
|
|
|
|
} |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
sub include_data_titles_in_hri { |
129
|
0
|
|
|
0
|
0
|
0
|
my ( $self, $value ) = @_; |
130
|
0
|
0
|
|
|
|
0
|
if ( @_ == 2 ) { |
131
|
0
|
0
|
|
|
|
0
|
_setIncludeDataTitlesInHRI( ${$self}, $value ) |
|
0
|
|
|
|
|
0
|
|
132
|
|
|
|
|
|
|
or $self->_throw_error_exception(); |
133
|
|
|
|
|
|
|
} |
134
|
|
|
|
|
|
|
|
135
|
0
|
|
|
|
|
0
|
return _getIncludeDataTitlesInHRI( ${$self} ); |
|
0
|
|
|
|
|
0
|
|
136
|
|
|
|
|
|
|
} |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
sub validate_ai_associations { |
139
|
0
|
|
|
0
|
0
|
0
|
my ( $self, $value ) = @_; |
140
|
0
|
0
|
|
|
|
0
|
if ( @_ == 2 ) { |
141
|
0
|
0
|
|
|
|
0
|
_setValidateAIassociations( ${$self}, $value ) |
|
0
|
|
|
|
|
0
|
|
142
|
|
|
|
|
|
|
or $self->_throw_error_exception(); |
143
|
|
|
|
|
|
|
} |
144
|
|
|
|
|
|
|
|
145
|
0
|
|
|
|
|
0
|
return _getValidateAIassociations( ${$self} ); |
|
0
|
|
|
|
|
0
|
|
146
|
|
|
|
|
|
|
} |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
sub version { |
149
|
1
|
|
|
1
|
0
|
9
|
my ($self) = @_; |
150
|
1
|
|
|
|
|
3
|
return _getVersion( ${$self} ); |
|
1
|
|
|
|
|
7
|
|
151
|
|
|
|
|
|
|
} |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
sub dl_uri { |
154
|
1
|
|
|
1
|
0
|
7
|
my ( $self, $domain ) = @_; |
155
|
1
|
|
|
|
|
2
|
return _getDLuri( ${$self}, $domain ); |
|
1
|
|
|
|
|
38
|
|
156
|
|
|
|
|
|
|
} |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
sub DESTROY { |
159
|
5
|
|
|
5
|
|
26429
|
my ($self) = @_; |
160
|
5
|
|
|
|
|
16
|
FFI::Platypus::Memory::free( ${$self} ); |
|
5
|
|
|
|
|
41
|
|
161
|
5
|
|
|
|
|
17
|
return $self; |
162
|
|
|
|
|
|
|
} |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
1; |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
__END__ |