forked from maxmind/geoip-api-perl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtypemap
35 lines (30 loc) · 909 Bytes
/
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
TYPEMAP
char * O_CHAR
const char * T_PV
GeoIP * O_OBJECT
GeoIPRecord * O_OBJECT
float T_FLOAT
INPUT
O_OBJECT
if( sv_isobject($arg) && (SvTYPE(SvRV($arg)) == SVt_PVMG) )
$var = ($type)SvIV((SV*)SvRV( $arg ));
else{
warn( \"${Package}::$func_name() -- $var is not a blessed SV reference\" );
XSRETURN_UNDEF;
}
# this is just here because a O_CHAR input is required to compile,
# should be same as if O_CHAR wasn't defined
O_CHAR
$var = ($type)SvPVbyte_nolen ($arg)
OUTPUT
# The Perl object is blessed into 'CLASS', which should be a
# char* having the name of the package for the blessing.
O_OBJECT
sv_setref_pv( $arg, (char *)CLASS, (void*)$var );
# prevent memory leaks with malloc'ed returned char * strings
O_CHAR
if($var != NULL) {
$arg = newSVpv($var, strlen($var));
free($var);
sv_2mortal($arg);
}