Debian Codegraph @

typemap

raw
1 # Typemap file for FreeType types. The ones which are used for classes are
2 # mapped to blessed references.
3
4 TYPEMAP
5 FT_UShort T_INT_FTUINT
6 FT_UInt T_INT_FTUINT
7 FT_Int32 T_INT_FTINT32
8 FT_ULong T_INT_FTULONG
9 FT_Pos T_INT_FTINT32
10 FT_Encoding T_INT_FTULONG
11 FT_F26Dot6 T_DOUBLE_FT26Dot6
12
13 Font_FreeType T_PTROBJ_SPECIAL
14 Font_FreeType_Face T_PTROBJ_SPECIAL
15 Font_FreeType_Glyph T_PTROBJ_SPECIAL
16 Font_FreeType_CharMap T_PTROBJ_SPECIAL
17 Font_FreeType_NamedInfo T_PTROBJ_SPECIAL
18 Font_FreeType_BoundingBox T_PTROBJ_SPECIAL
19
20 const char * T_PV
21 HV * T_HVREF
22
23
24 # Converts between Perl numbers and the FT_UInt type, which is a simple
25 # unsigned integer.
26
27 INPUT
28 T_INT_FTUINT
29 $var = (FT_UInt) SvUV($arg);
30
31 OUTPUT
32 T_INT_FTUINT
33 sv_setuv($arg, (UV) $var);
34
35
36 # Converts between Perl numbers and the FT_Int32 type, which is a simple
37 # signed integer.
38
39 INPUT
40 T_INT_FTINT32
41 $var = (FT_Int32) SvIV($arg);
42
43 OUTPUT
44 T_INT_FTINT32
45 sv_setiv($arg, (IV) $var);
46
47
48 # Same as above but for the FT_ULong type.
49
50 INPUT
51 T_INT_FTULONG
52 $var = (FT_ULong) SvUV($arg);
53
54 OUTPUT
55 T_INT_FTULONG
56 sv_setuv($arg, (UV) $var);
57
58
59 # This type converts between Perl integer or float numbers and the fixed-point
60 # 26.6 numbers sometimes used by FreeType. It rounds to the closest value
61 # which can be stored.
62
63 INPUT
64 T_DOUBLE_FT26Dot6
65 $var = (FT_F26Dot6) floor(SvNV($arg) * 64.0 + 0.5);
66
67 OUTPUT
68 T_DOUBLE_FT26Dot6
69 sv_setnv($arg, (double) $var / 64.0);
70
71
72 # There follows the definition of T_PTROBJ_SPECIAL, which is stolen from
73 # the 'perlxs' documentation. It handles the type being blessed into the
74 # appropriate class, changing underscores in the C name to '::' in the
75 # Perl name.
76 #
77 # I've added a check on sv_isobject() to prevent a segfault if a method
78 # is called on the package name.
79
80 INPUT
81 T_PTROBJ_SPECIAL
82 if (sv_isobject($arg) &&
83 sv_derived_from($arg, \"${(my $ntt=$ntype)=~s/_/::/g;\$ntt}\"))
84 {
85 IV tmp = SvIV((SV*)SvRV($arg));
86 $var = ($type) tmp;
87 }
88 else
89 croak(\"$var is not of type ${(my $ntt=$ntype)=~s/_/::/g;\$ntt}\");
90
91 OUTPUT
92 T_PTROBJ_SPECIAL
93 sv_setref_pv($arg, \"${(my $ntt=$ntype)=~s/_/::/g;\$ntt}\", (void*)$var);
94
95
96 # Needed for compatability with Perl 5.6.1. This is the version out
97 # of the 5.8.4 typemap, because the standard 5.6 one doesn't work.
98 INPUT
99 T_HVREF
100 if (SvROK($arg) && SvTYPE(SvRV($arg))==SVt_PVHV)
101 $var = (HV*)SvRV($arg);
102 else
103 Perl_croak(aTHX_ \"$var is not a hash reference\")
104
105 # vi:ts=4 sw=4 expandtab