Much wider support for Catacomb in all its glory.
[catacomb-perl] / typemap
diff --git a/typemap b/typemap
index 0ffd393..a4f6297 100644 (file)
--- a/typemap
+++ b/typemap
@@ -1,5 +1,12 @@
 TYPEMAP
+const char *                   T_PV
+
 mp *                           T_MP
+gf *                           T_MP
+EC_Curve *                     T_CATSTRUCT
+EC_Info *                      T_CATSTRUCT
+Field *                                T_CATSTRUCT
+Group *                                T_CATSTRUCT
 gccipher *                     T_GCALG
 gchash *                       T_GCALG
 gcMAC *                                T_GCALG
@@ -9,13 +16,25 @@ gMAC *                               T_GALG
 grand *                                T_GALG
 keysize *                      T_KEYSZ
 
+fe *                           T_FIELDELT
+ec *                           T_ECPT
+ge *                           T_GROUPELT
+
 Rand_True *                    T_CATSTRUCT
 Rand_DSA *                     T_CATSTRUCT
 
+Share_GF *                     T_CATSTRUCT
+Share_Prime *                  T_CATSTRUCT
+
+PRP *                          T_CATSTRUCT
+PRPClass *                     T_CATSTRUCT
+
 MP_Mont        *                       T_CATSTRUCT
 MP_Barrett *                   T_CATSTRUCT
 MP_Mul *                       T_CATSTRUCT
 MP_CRT *                       T_CATSTRUCT
+MP_Reduce *                    T_CATSTRUCT
+GF_Reduce *                    T_CATSTRUCT
 MP_Prime_Filter *              T_CATSTRUCT
 MP_Prime_Rabin *               T_CATSTRUCT
 MP_Prime_Gen_Event *           T_CATSTRUCT
@@ -27,74 +46,68 @@ MP_Prime_Gen_JumpStepper *  T_CATSTRUCT
 MP_Prime_Gen_RabinTester *     T_CATSTRUCT
 
 Key_File *                     T_CATSTRUCT
-Key_Data *                     T_CATSTRUCT
+Key_DataImpl *                 T_CATSTRUCT
+Key_AttrIter *                 T_CATSTRUCT
+Key_StructIter *               T_CATSTRUCT
+Key_FileIter *                 T_CATSTRUCT
+Key_Filter *                   T_CATSTRUCTUNDEF
 Key *                          T_CATSTRUCT
-
 KeyErr                         T_KEYERR
 
+RSA_Public *                   T_CATSTRUCT
+RSA_Private *                  T_CATSTRUCT
+
 INPUT
 T_MP
        $var = mp_fromsv($arg, \"$var\", 0, 0)
 T_CATSTRUCT
-       if (sv_derived_from($arg, \"${my $ntt = $ntype; $ntt =~ s/^(.*)Ptr$/Catacomb::$1/; $ntt =~ s/_/::/g; \$ntt}\"))
-         $var = ($type)SvIV((SV *)SvRV($arg));
-       else
-         croak(\"$var is not of type ${my $ntt = $ntype; $ntt =~ s/^(.*)Ptr$/Catacomb::$1/; $ntt =~ s/_/::/g; \$ntt}\")
+       $var = ptrfromsv($arg, \"${my $ntt = $ntype; $ntt =~ s/^(.*)Ptr$/Catacomb::$1/; $ntt =~ s/_/::/g; \$ntt}\", \"$var\")
+T_CATSTRUCTUNDEF
+       $var = SvOK($arg) ? ptrfromsv($arg, \"${my $ntt = $ntype; $ntt =~ s/^(.*)Ptr$/Catacomb::$1/; $ntt =~ s/_/::/g; \$ntt}\", \"$var\") : 0
+T_FIELDELT
+       $var = fieldelt($arg, \"$var\")
+T_GROUPELT
+       $var = groupelt($arg, \"$var\")
+T_ECPT
+       $var = ecpt($arg, \"$var\")
 T_GALG
-       if (sv_derived_from($arg, \"${my $ntt = $ntype; $ntt =~ s/^g(.*)Ptr$/Catacomb::\u$1/; \$ntt}\"))
-         $var = ($type)SvIV((SV *)SvRV($arg));
-       else
-         croak(\"$var is not of type ${my $ntt = $ntype; $ntt =~ s/^g(.*)Ptr$/Catacomb::\u$1/; \$ntt}\")
+       $var = ptrfromsv($arg, \"${my $ntt = $ntype; $ntt =~ s/^g(.*)Ptr$/Catacomb::\u$1/; \$ntt}\", \"$var\")
 T_GCALG
-       if (sv_derived_from($arg, \"${my $ntt = $ntype; $ntt =~ s/^gc(.*)Ptr$/Catacomb::\u$1Class/; \$ntt}\"))
-         $var = ($type)SvIV((SV *)SvRV($arg));
-       else
-         croak(\"$var is not of type ${my $ntt = $ntype; $ntt =~ s/^gc(.*)Ptr$/Catacomb::\u$1Class/; \$ntt}\")
+       $var = ptrfromsv($arg, \"${my $ntt = $ntype; $ntt =~ s/^gc(.*)Ptr$/Catacomb::\u$1Class/; \$ntt}\", \"$var\")
 T_KEYSZ
-       if (sv_derived_from($arg, \"Catacomb::KeySize\"))
-         $var = (keysize *)SvIV((SV *)SvRV($arg));
-       else
-         croak(\"$var is not of type Catacomb::KeySize\")
+       $var = ptrfromsv($arg, \"Catacomb::KeySize\", \"$var\")
 T_PGENPROC
        if (sv_derived_from($arg, \"Catacomb::MP::Prime::Gen::Proc\"))
          $var = $arg;
        else
-         croak(\"$var is not of type Catacomb::MP::Prime::Gen::Proc\")
+         croak(\"$var is not of type Catacomb::MP::Prime::Gen::Proc\");
 T_NULLPGENPROC
        if (!SvOK($arg) || 
            sv_derived_from($arg, \"Catacomb::MP::Prime::Gen::Proc\"))
          $var = $arg;
        else
-         croak(\"$var is not of type Catacomb::MP::Prime::Gen::Proc\")
+         croak(\"$var is not of type Catacomb::MP::Prime::Gen::Proc\");
 
 OUTPUT
 T_MP
-       if ($var)
-         sv_setref_pv($arg, \"Catacomb::MP\", (void*)$var);
-       else
-         $arg = &PL_sv_undef;
+       ptrtosv(&$arg, $var, \"${my $ntt = $ntype; $ntt =~ s/^(.*)Ptr$/Catacomb::\U$1/; $ntt =~ s/_/::/g; \$ntt}\");
 T_CATSTRUCT
-       if ($var)
-         sv_setref_pv($arg, \"${my $ntt = $ntype; $ntt =~ s/^(.*)Ptr$/Catacomb::$1/; $ntt =~ s/_/::/g; \$ntt}\", (void *)$var);
-       else
-         $arg = &PL_sv_undef;
+       ptrtosv(&$arg, $var, \"${my $ntt = $ntype; $ntt =~ s/^(.*)Ptr$/Catacomb::$1/; $ntt =~ s/_/::/g; \$ntt}\");
+T_CATSTRUCTUNDEF
+       ptrtosv(&$arg, $var, \"${my $ntt = $ntype; $ntt =~ s/^(.*)Ptr$/Catacomb::$1/; $ntt =~ s/_/::/g; \$ntt}\");
+T_FIELDELT
+       ptrtosv(&$arg, $var, \"Catacomb::MP\");
+T_GROUPELT
+       ptrtosv(&$arg, $var, \"Catacomb::Group::Element\");
+T_ECPT
+       ptrtosv(&$arg, $var, \"Catacomb::EC::Point\");
 T_GALG
-       if ($var)
-         sv_setref_pv($arg, \"${my $ntt = $ntype; $ntt =~ s/^g(.*)Ptr$/Catacomb::\u$1/; \$ntt}\", (void *)$var);
-       else
-         $arg = &PL_sv_undef;
+       ptrtosv(&$arg, $var, \"${my $ntt = $ntype; $ntt =~ s/^g(.*)Ptr$/Catacomb::\u$1/; \$ntt}\");
 T_GCALG
-       if ($var)
-         sv_setref_pv($arg, \"${my $ntt = $ntype; $ntt =~ s/^gc(.*)Ptr$/Catacomb::\u$1Class/; \$ntt}\", (void *)$var);
-       else
-         $arg = &PL_sv_undef;
+       ptrtosv(&$arg, $var, \"${my $ntt = $ntype; $ntt =~ s/^gc(.*)Ptr$/Catacomb::\u$1Class/; \$ntt}\");
 T_KEYSZ
-       if ($var)
-         sv_setref_pv($arg, \"Catacomb::KeySize\", (void *)$var);
-       else
-         $arg = &PL_sv_undef;
+       ptrtosv(&$arg, (octet *)$var, \"Catacomb::KeySize\");
 T_PGENPROC
        $arg = $var;
-
 T_KEYERR
        $arg = keyerr($var);