-
Notifications
You must be signed in to change notification settings - Fork 0
/
mro_compat.h
executable file
·65 lines (47 loc) · 1.97 KB
/
mro_compat.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/*
----------------------------------------------------------------------------
Devel::MRO/mro_compat.h - Provides mro functions for XS modules
Copyright (c) 2008-2009, Goro Fuji (gfx) <gfuji(at)cpan.org>.
This program is free software; you can redistribute it and/or
modify it under the same terms as Perl itself.
----------------------------------------------------------------------------
Usage:
#include "mro_compat.h"
Functions:
AV* mro_get_linear_isa(HV* stash)
U32 mro_get_pkg_gen(HV* stash)
U32 mro_get_cache_gen(HV* stash)
U32 mro_get_gen(HV* stash)
void mro_method_changed_in(HV* stash)
See "perldoc Devel::MRO" for details.
*/
#ifndef MRO_COMPAT
#ifdef mro_get_linear_isa /* >= 5.10.0 */
#define MRO_COMPAT 0
/* NOTE:
Because ActivePerl 5.10.0 does not provide Perl_mro_meta_init(),
which is used in HvMROMETA() macro, this mro_get_pkg_gen() refers
to xhv_mro_meta directly.
*/
/* compatible with &mro::get_pkg_gen() */
#ifndef mro_get_pkg_gen
#define mro_get_pkg_gen(stash) (HvAUX(stash) ? HvAUX(stash)->xhv_mro_meta->pkg_gen : (U32)0)
#endif
#ifndef mro_get_cache_gen
#define mro_get_cache_gen(stash) (HvAUX(stash) ? HvAUX(stash)->xhv_mro_meta->cache_gen : (U32)0)
#endif
/* pkg_gen + cache_gen */
#ifndef mro_get_gen
#define mro_get_gen(stash) (HvAUX(stash) ? (HvAUX(stash)->xhv_mro_meta->pkg_gen + HvAUX(stash)->xhv_mro_meta->cache_gen) : (U32)0)
#endif
#else /* < 5.10.0 */
#define MRO_COMPAT 1
#define mro_get_linear_isa(stash) mro_compat_mro_get_linear_isa(aTHX_ stash)
#define mro_method_changed_in(stash) mor_compat_mro_method_changed_in(aTHX_ stash)
#define mro_get_pkg_gen(stash) ((void)stash, PL_sub_generation)
#define mro_get_cache_gen(stash) ((void)stash, (U32)0) /* ??? */
#define mro_get_gen(stash) ((void)stash, PL_sub_generation)
EXTERN_C AV* mro_compat_mro_get_linear_isa(pTHX_ HV* const stash);
EXTERN_C void mro_compat_mro_method_changed_in(pTHX_ HV* const stash);
#endif /* !get_linear_isa */
#endif /* !MRO_COMPAT */