chiark / gitweb /
0ffd393f0897864571478de81906c50066f6c0db
[catacomb-perl] / typemap
1 TYPEMAP
2 mp *                            T_MP
3 gccipher *                      T_GCALG
4 gchash *                        T_GCALG
5 gcMAC *                         T_GCALG
6 gcipher *                       T_GALG
7 ghash *                         T_GALG
8 gMAC *                          T_GALG
9 grand *                         T_GALG
10 keysize *                       T_KEYSZ
11
12 Rand_True *                     T_CATSTRUCT
13 Rand_DSA *                      T_CATSTRUCT
14
15 MP_Mont *                       T_CATSTRUCT
16 MP_Barrett *                    T_CATSTRUCT
17 MP_Mul *                        T_CATSTRUCT
18 MP_CRT *                        T_CATSTRUCT
19 MP_Prime_Filter *               T_CATSTRUCT
20 MP_Prime_Rabin *                T_CATSTRUCT
21 MP_Prime_Gen_Event *            T_CATSTRUCT
22 MP_Prime_Gen_Proc *             T_PGENPROC
23 MP_Prime_Gen_NullProc *         T_NULLPGENPROC
24 MP_Prime_Gen_MagicProc *        T_CATSTRUCT
25 MP_Prime_Gen_FilterStepper *    T_CATSTRUCT
26 MP_Prime_Gen_JumpStepper *      T_CATSTRUCT
27 MP_Prime_Gen_RabinTester *      T_CATSTRUCT
28
29 Key_File *                      T_CATSTRUCT
30 Key_Data *                      T_CATSTRUCT
31 Key *                           T_CATSTRUCT
32
33 KeyErr                          T_KEYERR
34
35 INPUT
36 T_MP
37         $var = mp_fromsv($arg, \"$var\", 0, 0)
38 T_CATSTRUCT
39         if (sv_derived_from($arg, \"${my $ntt = $ntype; $ntt =~ s/^(.*)Ptr$/Catacomb::$1/; $ntt =~ s/_/::/g; \$ntt}\"))
40           $var = ($type)SvIV((SV *)SvRV($arg));
41         else
42           croak(\"$var is not of type ${my $ntt = $ntype; $ntt =~ s/^(.*)Ptr$/Catacomb::$1/; $ntt =~ s/_/::/g; \$ntt}\")
43 T_GALG
44         if (sv_derived_from($arg, \"${my $ntt = $ntype; $ntt =~ s/^g(.*)Ptr$/Catacomb::\u$1/; \$ntt}\"))
45           $var = ($type)SvIV((SV *)SvRV($arg));
46         else
47           croak(\"$var is not of type ${my $ntt = $ntype; $ntt =~ s/^g(.*)Ptr$/Catacomb::\u$1/; \$ntt}\")
48 T_GCALG
49         if (sv_derived_from($arg, \"${my $ntt = $ntype; $ntt =~ s/^gc(.*)Ptr$/Catacomb::\u$1Class/; \$ntt}\"))
50           $var = ($type)SvIV((SV *)SvRV($arg));
51         else
52           croak(\"$var is not of type ${my $ntt = $ntype; $ntt =~ s/^gc(.*)Ptr$/Catacomb::\u$1Class/; \$ntt}\")
53 T_KEYSZ
54         if (sv_derived_from($arg, \"Catacomb::KeySize\"))
55           $var = (keysize *)SvIV((SV *)SvRV($arg));
56         else
57           croak(\"$var is not of type Catacomb::KeySize\")
58 T_PGENPROC
59         if (sv_derived_from($arg, \"Catacomb::MP::Prime::Gen::Proc\"))
60           $var = $arg;
61         else
62           croak(\"$var is not of type Catacomb::MP::Prime::Gen::Proc\")
63 T_NULLPGENPROC
64         if (!SvOK($arg) || 
65             sv_derived_from($arg, \"Catacomb::MP::Prime::Gen::Proc\"))
66           $var = $arg;
67         else
68           croak(\"$var is not of type Catacomb::MP::Prime::Gen::Proc\")
69
70 OUTPUT
71 T_MP
72         if ($var)
73           sv_setref_pv($arg, \"Catacomb::MP\", (void*)$var);
74         else
75           $arg = &PL_sv_undef;
76 T_CATSTRUCT
77         if ($var)
78           sv_setref_pv($arg, \"${my $ntt = $ntype; $ntt =~ s/^(.*)Ptr$/Catacomb::$1/; $ntt =~ s/_/::/g; \$ntt}\", (void *)$var);
79         else
80           $arg = &PL_sv_undef;
81 T_GALG
82         if ($var)
83           sv_setref_pv($arg, \"${my $ntt = $ntype; $ntt =~ s/^g(.*)Ptr$/Catacomb::\u$1/; \$ntt}\", (void *)$var);
84         else
85           $arg = &PL_sv_undef;
86 T_GCALG
87         if ($var)
88           sv_setref_pv($arg, \"${my $ntt = $ntype; $ntt =~ s/^gc(.*)Ptr$/Catacomb::\u$1Class/; \$ntt}\", (void *)$var);
89         else
90           $arg = &PL_sv_undef;
91 T_KEYSZ
92         if ($var)
93           sv_setref_pv($arg, \"Catacomb::KeySize\", (void *)$var);
94         else
95           $arg = &PL_sv_undef;
96 T_PGENPROC
97         $arg = $var;
98
99 T_KEYERR
100         $arg = keyerr($var);