| 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; |
|
| 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 /* Change this to constant(aTHX_ s, len, &iv, &nv); |
|
| 19 if you need to return both NVs and IVs */ |
|
| 20 type = constant(aTHX_ s, len, &iv); |
|
| 21 /* Return 1 or 2 items. First is error message, or undef if no error. |
|
| 22 Second, if present, is found value */ |
|
| 23 switch (type) { |
|
| 24 case PERL_constant_NOTFOUND: |
|
| 25 sv = sv_2mortal(newSVpvf("%s is not a valid Gaim::DebugLevel macro", s)); |
|
| 26 PUSHs(sv); |
|
| 27 break; |
|
| 28 case PERL_constant_NOTDEF: |
|
| 29 sv = sv_2mortal(newSVpvf( |
|
| 30 "Your vendor has not defined Gaim::DebugLevel macro %s, used", s)); |
|
| 31 PUSHs(sv); |
|
| 32 break; |
|
| 33 case PERL_constant_ISIV: |
|
| 34 EXTEND(SP, 1); |
|
| 35 PUSHs(&PL_sv_undef); |
|
| 36 PUSHi(iv); |
|
| 37 break; |
|
| 38 /* Uncomment this if you need to return NOs |
|
| 39 case PERL_constant_ISNO: |
|
| 40 EXTEND(SP, 1); |
|
| 41 PUSHs(&PL_sv_undef); |
|
| 42 PUSHs(&PL_sv_no); |
|
| 43 break; */ |
|
| 44 /* Uncomment this if you need to return NVs |
|
| 45 case PERL_constant_ISNV: |
|
| 46 EXTEND(SP, 1); |
|
| 47 PUSHs(&PL_sv_undef); |
|
| 48 PUSHn(nv); |
|
| 49 break; */ |
|
| 50 /* Uncomment this if you need to return PVs |
|
| 51 case PERL_constant_ISPV: |
|
| 52 EXTEND(SP, 1); |
|
| 53 PUSHs(&PL_sv_undef); |
|
| 54 PUSHp(pv, strlen(pv)); |
|
| 55 break; */ |
|
| 56 /* Uncomment this if you need to return PVNs |
|
| 57 case PERL_constant_ISPVN: |
|
| 58 EXTEND(SP, 1); |
|
| 59 PUSHs(&PL_sv_undef); |
|
| 60 PUSHp(pv, iv); |
|
| 61 break; */ |
|
| 62 /* Uncomment this if you need to return SVs |
|
| 63 case PERL_constant_ISSV: |
|
| 64 EXTEND(SP, 1); |
|
| 65 PUSHs(&PL_sv_undef); |
|
| 66 PUSHs(sv); |
|
| 67 break; */ |
|
| 68 /* Uncomment this if you need to return UNDEFs |
|
| 69 case PERL_constant_ISUNDEF: |
|
| 70 break; */ |
|
| 71 /* Uncomment this if you need to return UVs |
|
| 72 case PERL_constant_ISUV: |
|
| 73 EXTEND(SP, 1); |
|
| 74 PUSHs(&PL_sv_undef); |
|
| 75 PUSHu((UV)iv); |
|
| 76 break; */ |
|
| 77 /* Uncomment this if you need to return YESs |
|
| 78 case PERL_constant_ISYES: |
|
| 79 EXTEND(SP, 1); |
|
| 80 PUSHs(&PL_sv_undef); |
|
| 81 PUSHs(&PL_sv_yes); |
|
| 82 break; */ |
|
| 83 default: |
|
| 84 sv = sv_2mortal(newSVpvf( |
|
| 85 "Unexpected return type %d while processing Gaim::DebugLevel macro %s, used", |
|
| 86 type, s)); |
|
| 87 PUSHs(sv); |
|
| 88 } |
|