]> git.vpit.fr Git - perl/modules/re-engine-Plugin.git/blob - Plugin.h
Replace uses of "$^V" by "$]"
[perl/modules/re-engine-Plugin.git] / Plugin.h
1 #define GET_SELF_FROM_PPRIVATE(pprivate)        \
2     re__engine__Plugin self;                    \
3     SELF_FROM_PPRIVATE(self,pprivate);
4
5 /* re__engine__Plugin self; SELF_FROM_PPRIVATE(self,rx->pprivate) */
6 #define SELF_FROM_PPRIVATE(self, pprivate)                   \
7     if (sv_isobject(pprivate)) {                             \
8         SV * ref = SvRV((SV*)pprivate);                      \
9         IV tmp = SvIV((SV*)ref);                             \
10         self = INT2PTR(re__engine__Plugin,tmp);              \
11     } else {                                                 \
12         Perl_croak(aTHX_ "Not an object");                   \
13     }
14
15 START_EXTERN_C
16 EXTERN_C const regexp_engine engine_plugin;
17 #if PERL_VERSION <= 10
18 EXTERN_C REGEXP * Plugin_comp(pTHX_ const SV * const, const U32);
19 #else
20 EXTERN_C REGEXP * Plugin_comp(pTHX_ SV * const, U32);
21 #endif
22 EXTERN_C I32      Plugin_exec(pTHX_ REGEXP * const, char *, char *,
23                               char *, I32, SV *, void *, U32);
24 EXTERN_C char *   Plugin_intuit(pTHX_ REGEXP * const, SV *, char *,
25                                 char *, U32, re_scream_pos_data *);
26 EXTERN_C SV *     Plugin_checkstr(pTHX_ REGEXP * const);
27 EXTERN_C void     Plugin_free(pTHX_ REGEXP * const);
28 EXTERN_C void *   Plugin_dupe(pTHX_ REGEXP * const, CLONE_PARAMS *);
29 EXTERN_C void     Plugin_numbered_buff_FETCH(pTHX_ REGEXP * const,
30                                              const I32, SV * const);
31 EXTERN_C void     Plugin_numbered_buff_STORE(pTHX_ REGEXP * const,
32                                              const I32, SV const * const);
33 EXTERN_C I32      Plugin_numbered_buff_LENGTH(pTHX_ REGEXP * const,
34                                               const SV * const, const I32);
35 EXTERN_C SV *     Plugin_named_buff (pTHX_ REGEXP * const, SV * const,
36                                      SV * const, const U32);
37 EXTERN_C SV *     Plugin_named_buff_iter (pTHX_ REGEXP * const, const SV * const,
38                                           const U32);
39 EXTERN_C SV *     Plugin_package(pTHX_ REGEXP * const);
40 #ifdef USE_ITHREADS
41 EXTERN_C void *   Plugin_dupe(pTHX_ REGEXP * const, CLONE_PARAMS *);
42 #endif
43 END_EXTERN_C
44
45 START_EXTERN_C
46 EXTERN_C const regexp_engine engine_plugin;
47 END_EXTERN_C
48
49 #define RE_ENGINE_PLUGIN (&engine_plugin)
50 const regexp_engine engine_plugin = {
51     Plugin_comp,
52     Plugin_exec,
53     Plugin_intuit,
54     Plugin_checkstr,
55     Plugin_free,
56     Plugin_numbered_buff_FETCH,
57     Plugin_numbered_buff_STORE,
58     Plugin_numbered_buff_LENGTH,
59     Plugin_named_buff,
60     Plugin_named_buff_iter,
61     Plugin_package,
62 #if defined(USE_ITHREADS)
63     Plugin_dupe,
64 #endif
65 };
66
67 typedef struct replug {
68     /* Pointer back to the containing regexp struct so that accessors
69      * can modify nparens, gofs etc. */
70     struct regexp * rx;
71
72     /* A copy of the pattern given to comp, for ->pattern */
73     SV * pattern;
74
75     /* A copy of the string being matched against, for ->str */
76     SV * str;
77
78     /* The ->stash */
79     SV * stash;
80
81     /* Callbacks */
82     SV * cb_exec;
83     SV * cb_free;
84
85     /* ->num_captures */
86     SV * cb_num_capture_buff_FETCH;
87     SV * cb_num_capture_buff_STORE;
88     SV * cb_num_capture_buff_LENGTH;
89 } *re__engine__Plugin;
90
91 #if PERL_VERSION >= 11
92 # define rxREGEXP(RX)  (SvANY(RX))
93 # define newREGEXP(RX) ((RX) = ((REGEXP*) newSV_type(SVt_REGEXP)))
94 #else
95 # define rxREGEXP(RX)  (RX)
96 # define newREGEXP(RX) (Newxz((RX), 1, struct regexp))
97 #endif