| 1 |
|
| void |
| 2 |
|
| constant(sv) |
| 3 |
|
| PREINIT: |
| 4 |
|
| #ifdef dXSTARG |
| 5 |
0 |
▶ | dXSTARG; /* Faster if we have it. */ |
Branch: 1 branch
| Branch | True | False | Total |
| dXSTARG; /* Faster if we have it. */ |
0 |
0 |
0 |
|
| 6 |
|
| #else |
| 7 |
|
| dTARGET; |
| 8 |
|
| #endif |
| 9 |
|
| STRLEN len; |
| 10 |
|
| int type; |
| 11 |
0 |
| IV iv = 0; /* avoid uninit var warning */ |
| 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 value_constant(aTHX_ s, len, &iv, &nv); |
| 19 |
|
| if you need to return both NVs and IVs */ |
| 20 |
0 |
| type = value_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 |
0 |
| switch (type) { |
| 24 |
0 |
| case PERL_constant_NOTFOUND: |
| 25 |
|
| sv = |
| 26 |
0 |
| sv_2mortal(newSVpvf("%s is not a valid MarpaX::ESLIF::Value::Type macro", s)); |
| 27 |
0 |
| PUSHs(sv); |
| 28 |
0 |
| break; |
| 29 |
0 |
| case PERL_constant_NOTDEF: |
| 30 |
0 |
| sv = sv_2mortal(newSVpvf( |
| 31 |
|
| "Your vendor has not defined MarpaX::ESLIF::Value::Type macro %s, used", |
| 32 |
|
| s)); |
| 33 |
0 |
| PUSHs(sv); |
| 34 |
0 |
| break; |
| 35 |
0 |
| case PERL_constant_ISIV: |
| 36 |
0 |
▶ | EXTEND(SP, 2); |
Branch: 1 branch
| Branch | True | False | Total |
| EXTEND(SP, 2); |
0 |
0 |
0 |
|
| 37 |
0 |
| PUSHs(&PL_sv_undef); |
| 38 |
0 |
▶ | PUSHi(iv); |
Branch: 1 branch
| Branch | True | False | Total |
| PUSHi(iv); |
0 |
0 |
0 |
|
| 39 |
0 |
| break; |
| 40 |
|
| /* Uncomment this if you need to return NOs |
| 41 |
|
| case PERL_constant_ISNO: |
| 42 |
|
| EXTEND(SP, 2); |
| 43 |
|
| PUSHs(&PL_sv_undef); |
| 44 |
|
| PUSHs(&PL_sv_no); |
| 45 |
|
| break; */ |
| 46 |
|
| /* Uncomment this if you need to return NVs |
| 47 |
|
| case PERL_constant_ISNV: |
| 48 |
|
| EXTEND(SP, 2); |
| 49 |
|
| PUSHs(&PL_sv_undef); |
| 50 |
|
| PUSHn(nv); |
| 51 |
|
| break; */ |
| 52 |
|
| /* Uncomment this if you need to return PVs |
| 53 |
|
| case PERL_constant_ISPV: |
| 54 |
|
| EXTEND(SP, 2); |
| 55 |
|
| PUSHs(&PL_sv_undef); |
| 56 |
|
| PUSHp(pv, strlen(pv)); |
| 57 |
|
| break; */ |
| 58 |
|
| /* Uncomment this if you need to return PVNs |
| 59 |
|
| case PERL_constant_ISPVN: |
| 60 |
|
| EXTEND(SP, 2); |
| 61 |
|
| PUSHs(&PL_sv_undef); |
| 62 |
|
| PUSHp(pv, iv); |
| 63 |
|
| break; */ |
| 64 |
|
| /* Uncomment this if you need to return SVs |
| 65 |
|
| case PERL_constant_ISSV: |
| 66 |
|
| EXTEND(SP, 2); |
| 67 |
|
| PUSHs(&PL_sv_undef); |
| 68 |
|
| PUSHs(sv); |
| 69 |
|
| break; */ |
| 70 |
|
| /* Uncomment this if you need to return UNDEFs |
| 71 |
|
| case PERL_constant_ISUNDEF: |
| 72 |
|
| break; */ |
| 73 |
|
| /* Uncomment this if you need to return UVs |
| 74 |
|
| case PERL_constant_ISUV: |
| 75 |
|
| EXTEND(SP, 2); |
| 76 |
|
| PUSHs(&PL_sv_undef); |
| 77 |
|
| PUSHu((UV)iv); |
| 78 |
|
| break; */ |
| 79 |
|
| /* Uncomment this if you need to return YESs |
| 80 |
|
| case PERL_constant_ISYES: |
| 81 |
|
| EXTEND(SP, 2); |
| 82 |
|
| PUSHs(&PL_sv_undef); |
| 83 |
|
| PUSHs(&PL_sv_yes); |
| 84 |
|
| break; */ |
| 85 |
0 |
| default: |
| 86 |
0 |
| sv = sv_2mortal(newSVpvf( |
| 87 |
|
| "Unexpected return type %d while processing MarpaX::ESLIF::Value::Type macro %s, used", |
| 88 |
|
| type, s)); |
| 89 |
0 |
| PUSHs(sv); |
| 90 |
|
| } |