updated comments
[language-befunge-vector-xs.git] / fallback / const-xs.inc
blob77cf10a5b10246d7665ae8a3f9da47ecc4d28095
1 void
2 constant(sv)
3     PREINIT:
4 #ifdef dXSTARG
5         dXSTARG; /* Faster if we have it.  */
6 #else
7         dTARGET;
8 #endif
9         STRLEN          len;
10         int             type;
11         /* IV           iv;     Uncomment this if you need to return IVs */
12         /* NV           nv;     Uncomment this if you need to return NVs */
13         /* const char   *pv;    Uncomment this if you need to return PVs */
14     INPUT:
15         SV *            sv;
16         const char *    s = SvPV(sv, len);
17     PPCODE:
18         type = constant(aTHX_ s, len);
19       /* Return 1 or 2 items. First is error message, or undef if no error.
20            Second, if present, is found value */
21         switch (type) {
22         case PERL_constant_NOTFOUND:
23           sv = sv_2mortal(newSVpvf("%s is not a valid Math::Vector::XS macro", s));
24           PUSHs(sv);
25           break;
26         case PERL_constant_NOTDEF:
27           sv = sv_2mortal(newSVpvf(
28             "Your vendor has not defined Math::Vector::XS macro %s, used", s));
29           PUSHs(sv);
30           break;
31         /* Uncomment this if you need to return IVs
32         case PERL_constant_ISIV:
33           EXTEND(SP, 1);
34           PUSHs(&PL_sv_undef);
35           PUSHi(iv);
36           break; */
37         /* Uncomment this if you need to return NOs
38         case PERL_constant_ISNO:
39           EXTEND(SP, 1);
40           PUSHs(&PL_sv_undef);
41           PUSHs(&PL_sv_no);
42           break; */
43         /* Uncomment this if you need to return NVs
44         case PERL_constant_ISNV:
45           EXTEND(SP, 1);
46           PUSHs(&PL_sv_undef);
47           PUSHn(nv);
48           break; */
49         /* Uncomment this if you need to return PVs
50         case PERL_constant_ISPV:
51           EXTEND(SP, 1);
52           PUSHs(&PL_sv_undef);
53           PUSHp(pv, strlen(pv));
54           break; */
55         /* Uncomment this if you need to return PVNs
56         case PERL_constant_ISPVN:
57           EXTEND(SP, 1);
58           PUSHs(&PL_sv_undef);
59           PUSHp(pv, iv);
60           break; */
61         /* Uncomment this if you need to return SVs
62         case PERL_constant_ISSV:
63           EXTEND(SP, 1);
64           PUSHs(&PL_sv_undef);
65           PUSHs(sv);
66           break; */
67         /* Uncomment this if you need to return UNDEFs
68         case PERL_constant_ISUNDEF:
69           break; */
70         /* Uncomment this if you need to return UVs
71         case PERL_constant_ISUV:
72           EXTEND(SP, 1);
73           PUSHs(&PL_sv_undef);
74           PUSHu((UV)iv);
75           break; */
76         /* Uncomment this if you need to return YESs
77         case PERL_constant_ISYES:
78           EXTEND(SP, 1);
79           PUSHs(&PL_sv_undef);
80           PUSHs(&PL_sv_yes);
81           break; */
82         default:
83           sv = sv_2mortal(newSVpvf(
84             "Unexpected return type %d while processing Math::Vector::XS macro %s, used",
85                type, s));
86           PUSHs(sv);
87         }