| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
/* You may distribute under the terms of either the GNU General Public License |
|
2
|
|
|
|
|
|
|
* or the Artistic License (the same terms as Perl itself) |
|
3
|
|
|
|
|
|
|
* |
|
4
|
|
|
|
|
|
|
* (C) Paul Evans, 2020-2023 -- leonerd@leonerd.org.uk |
|
5
|
|
|
|
|
|
|
*/ |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
#include "EXTERN.h" |
|
8
|
|
|
|
|
|
|
#include "perl.h" |
|
9
|
|
|
|
|
|
|
#include "XSUB.h" |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
#include "XSParseSublike.h" |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
#if PERL_REVISION > 5 || (PERL_REVISION == 5 && PERL_VERSION >= 26) |
|
14
|
|
|
|
|
|
|
# define HAVE_SUB_PARAM_ATTRIBUTES |
|
15
|
|
|
|
|
|
|
#endif |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
static const struct XSParseSublikeHooks parse_func_hooks = { |
|
18
|
|
|
|
|
|
|
.permit_hintkey = "t::func/func", |
|
19
|
|
|
|
|
|
|
}; |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
static const struct XSParseSublikeHooks parse_nfunc_hooks = { |
|
22
|
|
|
|
|
|
|
.permit_hintkey = "t::func/nfunc", |
|
23
|
|
|
|
|
|
|
.flags = XS_PARSE_SUBLIKE_FLAG_SIGNATURE_NAMED_PARAMS, |
|
24
|
|
|
|
|
|
|
}; |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
static const struct XSParseSublikeHooks parse_afunc_hooks = { |
|
27
|
|
|
|
|
|
|
.permit_hintkey = "t::func/afunc", |
|
28
|
|
|
|
|
|
|
.flags = XS_PARSE_SUBLIKE_FLAG_SIGNATURE_PARAM_ATTRIBUTES, |
|
29
|
|
|
|
|
|
|
}; |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
#ifdef HAVE_SUB_PARAM_ATTRIBUTES |
|
32
|
4
|
|
|
|
|
|
static void apply_Attribute(pTHX_ struct XPSSignatureParamContext *ctx, SV *attrvalue, void **attrdata_ptr, void *funcdata) |
|
33
|
|
|
|
|
|
|
{ |
|
34
|
|
|
|
|
|
|
/* TODO: maybe the context should store a lexname string? */ |
|
35
|
4
|
|
|
|
|
|
PADNAME *pn = PadnamelistARRAY(PL_comppad_name)[ctx->padix]; |
|
36
|
|
|
|
|
|
|
|
|
37
|
4
|
|
|
|
|
|
AV *av = get_av("main::ATTRIBUTE_APPLIED", GV_ADD); |
|
38
|
|
|
|
|
|
|
|
|
39
|
4
|
|
|
|
|
|
av_push(av, newSVsv(PadnameSV(pn))); |
|
40
|
4
|
|
|
|
|
|
av_push(av, newSVsv(attrvalue)); |
|
41
|
4
|
|
|
|
|
|
} |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
static const struct XPSSignatureAttributeFuncs attr_funcs = { |
|
44
|
|
|
|
|
|
|
.ver = XSPARSESUBLIKE_ABI_VERSION, |
|
45
|
|
|
|
|
|
|
.permit_hintkey = "t::func/Attribute", |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
.apply = apply_Attribute, |
|
48
|
|
|
|
|
|
|
}; |
|
49
|
|
|
|
|
|
|
#endif |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
MODULE = t::func PACKAGE = t::func |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
BOOT: |
|
54
|
6
|
|
|
|
|
|
boot_xs_parse_sublike(0); |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
register_xs_parse_sublike("func", &parse_func_hooks, NULL); |
|
57
|
|
|
|
|
|
|
register_xs_parse_sublike("nfunc", &parse_nfunc_hooks, NULL); |
|
58
|
|
|
|
|
|
|
register_xs_parse_sublike("afunc", &parse_afunc_hooks, NULL); |
|
59
|
|
|
|
|
|
|
#ifdef HAVE_SUB_PARAM_ATTRIBUTES |
|
60
|
|
|
|
|
|
|
register_xps_signature_attribute("Attribute", &attr_funcs, NULL); |
|
61
|
|
|
|
|
|
|
#endif |