-
Notifications
You must be signed in to change notification settings - Fork 1
/
typemap
188 lines (152 loc) · 3.42 KB
/
typemap
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
TYPEMAP
SetOption T_SETOPT
IntOption T_INTOPT
StringOption T_STROPT
# This should really be called zero_is_success...
negative_is_error I_NEG_IS_ERROR
ALPM_Handle T_ALPM_HANDLE
ALPM_DB T_ALPM_DB
ALPM_LocalDB T_ALPM_LOCALDB
ALPM_SyncDB T_ALPM_SYNCDB
ALPM_Package T_ALPM_PACKAGE
ALPM_PackageFree T_ALPM_PACKAGEFREE
ALPM_FileList T_ALPM_FILELIST
ALPM_SigLevel T_SIGLEVEL
ALPM_Origin T_ORIGIN
ALPM_Validity T_VALIDITY
PackageList L_PACKAGE
DependList L_DEPEND
StringList L_STRING
StringListFree L_STRINGFREE
alpm_pkgreason_t T_PKGREASON
off_t T_INT
#--------------------
# INPUT # Perl ==> C
#--------------------
INPUT
T_ALPM_HANDLE
if(sv_derived_from($arg, \"ALPM\")){
$var = INT2PTR($type, SvIV((SV *)SvRV($arg)));
}else{
croak(\"error: expected an ALPM object\");
}
T_ALPM_DB
if(sv_derived_from($arg, \"ALPM::DB\")){
IV tmp = SvIV((SV*)SvRV($arg));
$var = INT2PTR($type, tmp);
}else{
croak(\"error: expected an ALPM::DB object\");
}
T_ALPM_LOCALDB
if(sv_derived_from($arg, \"ALPM::DB::Local\")){
IV tmp = SvIV((SV*)SvRV($arg));
$var = INT2PTR($type, tmp);
}else{
croak(\"error: expected an ALPM::DB::Local object\");
}
T_ALPM_SYNCDB
if(sv_derived_from($arg, \"ALPM::DB::Sync\")){
IV tmp = SvIV((SV*)SvRV($arg));
$var = INT2PTR($type, tmp);
}else{
croak(\"error: expected an ALPM::DB::Sync object\");
}
T_ALPM_PACKAGE
if(sv_derived_from($arg, \"ALPM::Package\")){
$var = INT2PTR($type, SvIV((SV *)SvRV($arg)));
}else{
croak(\"error: expected an ALPM::Package object\");
}
T_ALPM_PACKAGEFREE
if(sv_derived_from($arg, \"ALPM::PackageFree\")){
IV tmp = SvIV((SV*)SvRV($arg));
$var = INT2PTR($type,tmp);
}else{
croak(\"error: expected an ALPM::PackageFree object\");
}
T_SIGLEVEL
$var = p2c_siglevel($arg);
T_PKGREASON
$var = p2c_pkgreason($arg);
#---------------------
# OUTPUT # C ==> Perl
#---------------------
OUTPUT
# The handle should never be NULL. This is the only error condition
# but hopefully doesn't affect us. However, the string is sometimes NULL
# so we should convert it to undef.
T_STROPT
if($var == NULL){
$arg = &PL_sv_undef;
}else{
$arg = newSVpv($var, 0);
}
T_SETOPT
if($var == -1){
alpm_croak(self);
}else{
$arg = &PL_sv_yes;
}
T_INTOPT
if($var == -1){
alpm_croak(self);
}else{
$arg = newSViv($var);
}
I_NEG_IS_ERROR
$arg = ($var == 0 ? &PL_sv_yes : &PL_sv_no);
T_ALPM_HANDLE
if($var == NULL){
croak(\"error: ALPM handle is NULL\");
}else{
sv_setref_pv($arg, \"ALPM\", (void *)$var);
}
T_ALPM_DB
if($var == NULL){
$arg = &PL_sv_undef;
}else{
$arg = c2p_db($var);
}
T_ALPM_LOCALDB
if($var == NULL){
$arg = &PL_sv_undef;
}else{
$arg = c2p_localdb($var);
}
T_ALPM_SYNCDB
if($var == NULL){
$arg = &PL_sv_undef;
}else{
$arg = c2p_syncdb($var);
}
T_ALPM_PACKAGE
if($var == NULL){
$arg = &PL_sv_undef;
}else{
$arg = c2p_pkg($var);
}
T_ALPM_PACKAGEFREE
if($var == NULL){
$arg = &PL_sv_undef;
}else{
sv_setref_pv($arg, \"ALPM::PackageFree\", (void *)$var);
}
T_ALPM_FILELIST
$arg = c2p_filelist($var);
T_SIGLEVEL
$arg = c2p_siglevel($var);
T_ORIGIN
$arg = c2p_pkgfrom($var);
T_PKGREASON
$arg = c2p_pkgreason($var);
T_VALIDITY
$arg = c2p_pkgvalidation($var);
L_PACKAGE
$arg = newRV_noinc((SV*)list2av($var, c2p_pkg));
L_DEPEND
$arg = newRV_noinc((SV*)list2av($var, c2p_depend));
L_STRING
$arg = newRV_noinc((SV*)list2av($var, c2p_str));
L_STRINGFREE
$arg = newRV_noinc((SV*)list2av($var, c2p_str));
ZAPLIST($var, free);