| 1 |
|
| ################################################################################ |
| 2 |
|
| # |
| 3 |
|
| # Copyright (c) 2002-2020 Marcus Holland-Moritz. All rights reserved. |
| 4 |
|
| # This program is free software; you can redistribute it and/or modify |
| 5 |
|
| # it under the same terms as Perl itself. |
| 6 |
|
| # |
| 7 |
|
| ################################################################################ |
| 8 |
|
| |
| 9 |
|
| |
| 10 |
|
| ################################################################################ |
| 11 |
|
| # |
| 12 |
|
| # METHOD: arg |
| 13 |
|
| # |
| 14 |
|
| # WRITTEN BY: Marcus Holland-Moritz ON: Jun 2004 |
| 15 |
|
| # CHANGED BY: ON: |
| 16 |
|
| # |
| 17 |
|
| ################################################################################ |
| 18 |
|
| # |
| 19 |
|
| # DESCRIPTION: Turn string arguments into blessed object, so we can recognize |
| 20 |
|
| # them later on. |
| 21 |
|
| # |
| 22 |
|
| ################################################################################ |
| 23 |
|
| |
| 24 |
|
| void |
| 25 |
|
| CBC::arg(...) |
| 26 |
|
| PREINIT: |
| 27 |
81 |
| CBC_METHOD(arg); |
| 28 |
|
| int i; |
| 29 |
|
| |
| 30 |
|
| PPCODE: |
| 31 |
|
| CT_DEBUG_METHOD; |
| 32 |
|
| |
| 33 |
81 |
▶ | CHECK_VOID_CONTEXT; |
Branch: 2 branches
| Branch | True | False | Total |
| CHECK_VOID_CONTEXT; |
6 |
75 |
81 |
| CHECK_VOID_CONTEXT; |
4 |
2 |
6 |
|
| 34 |
|
| |
| 35 |
163 |
▶ | for (i = 1; i < items; i++) |
Branch: 1 branch
| Branch | True | False | Total |
| for (i = 1; i < items; i++) |
94 |
69 |
163 |
|
| 36 |
|
| { |
| 37 |
|
| const char *argstr; |
| 38 |
|
| STRLEN len; |
| 39 |
|
| HookArgType type; |
| 40 |
|
| SV *sv; |
| 41 |
|
| |
| 42 |
94 |
| argstr = SvPV(ST(i), len); |
| 43 |
|
| |
| 44 |
94 |
▶ | if (strEQ(argstr, "SELF")) |
Branch: 1 branch
| Branch | True | False | Total |
| if (strEQ(argstr, "SELF")) |
20 |
74 |
94 |
|
| 45 |
20 |
| type = HOOK_ARG_SELF; |
| 46 |
74 |
▶ | else if (strEQ(argstr, "TYPE")) |
Branch: 1 branch
| Branch | True | False | Total |
| else if (strEQ(argstr, "TYPE")) |
23 |
51 |
74 |
|
| 47 |
23 |
| type = HOOK_ARG_TYPE; |
| 48 |
51 |
▶ | else if (strEQ(argstr, "DATA")) |
Branch: 1 branch
| Branch | True | False | Total |
| else if (strEQ(argstr, "DATA")) |
31 |
20 |
51 |
|
| 49 |
31 |
| type = HOOK_ARG_DATA; |
| 50 |
20 |
▶ | else if (strEQ(argstr, "HOOK")) |
Branch: 1 branch
| Branch | True | False | Total |
| else if (strEQ(argstr, "HOOK")) |
14 |
6 |
20 |
|
| 51 |
14 |
| type = HOOK_ARG_HOOK; |
| 52 |
|
| else |
| 53 |
6 |
| Perl_croak(aTHX_ "Unknown argument type '%s' in %s", argstr, method); |
| 54 |
|
| |
| 55 |
88 |
| sv = newRV_noinc(newSViv(type)); |
| 56 |
88 |
| sv_bless(sv, gv_stashpv(ARGTYPE_PACKAGE, 1)); |
| 57 |
88 |
| ST(i-1) = sv_2mortal(sv); |
| 58 |
|
| } |
| 59 |
|
| |
| 60 |
69 |
| XSRETURN(items-1); |
| 61 |
|
| |