Commit | Line | Data |
38bf2a25 |
1 | #ifndef __MOP_H__ |
2 | #define __MOP_H__ |
3 | |
4 | #include "EXTERN.h" |
5 | #include "perl.h" |
6 | #include "XSUB.h" |
7 | |
8 | #define NEED_newRV_noinc |
9 | #define NEED_sv_2pv_flags |
10 | #define NEED_sv_2pv_nolen |
11 | #include "ppport.h" |
12 | |
cdcadcbe |
13 | /* In theory, ExtUtils::ParseXS provide backcompat for this. However, the only |
14 | * available version doing that right now is 3.03_02, which is a dev release. We |
15 | * don't want to depend on dev releases, so we copy the code here. It should be |
16 | * removed once there's a stable ExtUtils::ParseXS version newer than 3.03_02. */ |
17 | #ifndef XS_EXTERNAL |
18 | # define XS_EXTERNAL XS |
19 | #endif |
20 | |
38bf2a25 |
21 | #define MOP_CALL_BOOT(name) mop_call_xs(aTHX_ name, cv, mark); |
22 | |
23 | #ifndef XSPROTO |
cdcadcbe |
24 | #define XSPROTO(name) XS_EXTERNAL(name) |
38bf2a25 |
25 | #endif |
26 | |
27 | void mop_call_xs (pTHX_ XSPROTO(subaddr), CV *cv, SV **mark); |
28 | |
29 | typedef enum { |
30 | KEY__expected_method_class, |
31 | KEY_ISA, |
32 | KEY_VERSION, |
33 | KEY_accessor, |
34 | KEY_associated_class, |
35 | KEY_associated_metaclass, |
36 | KEY_associated_methods, |
37 | KEY_attribute_metaclass, |
38 | KEY_attributes, |
39 | KEY_body, |
40 | KEY_builder, |
41 | KEY_clearer, |
42 | KEY_constructor_class, |
43 | KEY_constructor_name, |
44 | KEY_definition_context, |
45 | KEY_destructor_class, |
46 | KEY_immutable_trait, |
47 | KEY_init_arg, |
48 | KEY_initializer, |
49 | KEY_insertion_order, |
50 | KEY_instance_metaclass, |
51 | KEY_is_inline, |
52 | KEY_method_metaclass, |
53 | KEY_methods, |
54 | KEY_name, |
55 | KEY_package, |
56 | KEY_package_name, |
57 | KEY_predicate, |
58 | KEY_reader, |
59 | KEY_wrapped_method_metaclass, |
60 | KEY_writer, |
61 | KEY_package_cache_flag, |
62 | KEY__version, |
63 | key_last, |
64 | } mop_prehashed_key_t; |
65 | |
66 | #define KEY_FOR(name) mop_prehashed_key_for(KEY_ ##name) |
67 | #define HASH_FOR(name) mop_prehashed_hash_for(KEY_ ##name) |
68 | |
69 | void mop_prehash_keys (void); |
70 | SV *mop_prehashed_key_for (mop_prehashed_key_t key); |
71 | U32 mop_prehashed_hash_for (mop_prehashed_key_t key); |
72 | |
73 | #define INSTALL_SIMPLE_READER(klass, name) INSTALL_SIMPLE_READER_WITH_KEY(klass, name, name) |
74 | #define INSTALL_SIMPLE_READER_WITH_KEY(klass, name, key) \ |
75 | { \ |
76 | CV *cv = newXS("Class::MOP::" #klass "::" #name, mop_xs_simple_reader, __FILE__); \ |
77 | CvXSUBANY(cv).any_i32 = KEY_ ##key; \ |
78 | } |
79 | |
cdcadcbe |
80 | XS_EXTERNAL(mop_xs_simple_reader); |
38bf2a25 |
81 | |
82 | extern SV *mop_method_metaclass; |
83 | extern SV *mop_associated_metaclass; |
84 | extern SV *mop_wrap; |
85 | |
86 | UV mop_check_package_cache_flag(pTHX_ HV *stash); |
87 | int mop_get_code_info (SV *coderef, char **pkg, char **name); |
88 | SV *mop_call0(pTHX_ SV *const self, SV *const method); |
89 | |
90 | typedef enum { |
91 | TYPE_FILTER_NONE, |
92 | TYPE_FILTER_CODE, |
93 | TYPE_FILTER_ARRAY, |
94 | TYPE_FILTER_IO, |
95 | TYPE_FILTER_HASH, |
96 | TYPE_FILTER_SCALAR, |
97 | } type_filter_t; |
98 | |
99 | typedef bool (*get_package_symbols_cb_t) (const char *, STRLEN, SV *, void *); |
100 | |
101 | void mop_get_package_symbols(HV *stash, type_filter_t filter, get_package_symbols_cb_t cb, void *ud); |
102 | HV *mop_get_all_package_symbols (HV *stash, type_filter_t filter); |
103 | |
104 | #endif |