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 | |
a4e46ae7 |
27 | #ifndef CvISXSUB |
28 | #define CvISXSUB(cv) (CvXSUB(cv) ? TRUE : FALSE) |
29 | #endif |
30 | |
38bf2a25 |
31 | void mop_call_xs (pTHX_ XSPROTO(subaddr), CV *cv, SV **mark); |
32 | |
33 | typedef enum { |
34 | KEY__expected_method_class, |
35 | KEY_ISA, |
36 | KEY_VERSION, |
37 | KEY_accessor, |
38 | KEY_associated_class, |
39 | KEY_associated_metaclass, |
40 | KEY_associated_methods, |
41 | KEY_attribute_metaclass, |
42 | KEY_attributes, |
43 | KEY_body, |
44 | KEY_builder, |
45 | KEY_clearer, |
46 | KEY_constructor_class, |
47 | KEY_constructor_name, |
48 | KEY_definition_context, |
49 | KEY_destructor_class, |
50 | KEY_immutable_trait, |
51 | KEY_init_arg, |
52 | KEY_initializer, |
53 | KEY_insertion_order, |
54 | KEY_instance_metaclass, |
55 | KEY_is_inline, |
56 | KEY_method_metaclass, |
57 | KEY_methods, |
58 | KEY_name, |
59 | KEY_package, |
60 | KEY_package_name, |
61 | KEY_predicate, |
62 | KEY_reader, |
63 | KEY_wrapped_method_metaclass, |
64 | KEY_writer, |
65 | KEY_package_cache_flag, |
66 | KEY__version, |
67 | key_last, |
68 | } mop_prehashed_key_t; |
69 | |
70 | #define KEY_FOR(name) mop_prehashed_key_for(KEY_ ##name) |
71 | #define HASH_FOR(name) mop_prehashed_hash_for(KEY_ ##name) |
72 | |
73 | void mop_prehash_keys (void); |
74 | SV *mop_prehashed_key_for (mop_prehashed_key_t key); |
75 | U32 mop_prehashed_hash_for (mop_prehashed_key_t key); |
76 | |
77 | #define INSTALL_SIMPLE_READER(klass, name) INSTALL_SIMPLE_READER_WITH_KEY(klass, name, name) |
78 | #define INSTALL_SIMPLE_READER_WITH_KEY(klass, name, key) \ |
79 | { \ |
80 | CV *cv = newXS("Class::MOP::" #klass "::" #name, mop_xs_simple_reader, __FILE__); \ |
81 | CvXSUBANY(cv).any_i32 = KEY_ ##key; \ |
82 | } |
83 | |
cdcadcbe |
84 | XS_EXTERNAL(mop_xs_simple_reader); |
38bf2a25 |
85 | |
86 | extern SV *mop_method_metaclass; |
87 | extern SV *mop_associated_metaclass; |
88 | extern SV *mop_wrap; |
89 | |
90 | UV mop_check_package_cache_flag(pTHX_ HV *stash); |
91 | int mop_get_code_info (SV *coderef, char **pkg, char **name); |
92 | SV *mop_call0(pTHX_ SV *const self, SV *const method); |
93 | |
94 | typedef enum { |
95 | TYPE_FILTER_NONE, |
96 | TYPE_FILTER_CODE, |
97 | TYPE_FILTER_ARRAY, |
98 | TYPE_FILTER_IO, |
99 | TYPE_FILTER_HASH, |
100 | TYPE_FILTER_SCALAR, |
101 | } type_filter_t; |
102 | |
103 | typedef bool (*get_package_symbols_cb_t) (const char *, STRLEN, SV *, void *); |
104 | |
105 | void mop_get_package_symbols(HV *stash, type_filter_t filter, get_package_symbols_cb_t cb, void *ud); |
106 | HV *mop_get_all_package_symbols (HV *stash, type_filter_t filter); |
107 | |
108 | #endif |