]> git.vpit.fr Git - perl/modules/re-engine-Plugin.git/blobdiff - Plugin.xs
Revamp helpers variable declarations
[perl/modules/re-engine-Plugin.git] / Plugin.xs
index 7655326eb4eb6ad6dbfbd73c7ce9663f4447dc53..90e63fc8349d8fde716b40d0059459396564cfb8 100644 (file)
--- a/Plugin.xs
+++ b/Plugin.xs
@@ -75,10 +75,6 @@ static void xsh_hints_user_deinit(pTHX_ xsh_hints_user_t *hv) {
 
 /* --- Custom regexp engine ------------------------------------------------ */
 
-#define GET_SELF_FROM_PPRIVATE(pprivate) \
- re__engine__Plugin self;                \
- SELF_FROM_PPRIVATE(self,pprivate);
-
 /* re__engine__Plugin self; SELF_FROM_PPRIVATE(self,rx->pprivate) */
 #define SELF_FROM_PPRIVATE(self, pprivate) \
  if (sv_isobject(pprivate)) {              \
@@ -215,7 +211,7 @@ Plugin_comp(pTHX_ const SV * const pattern, const U32 flags)
  obj = newSV(0);
  SvREFCNT_inc_simple_void_NN(obj);
  Newxz(re, 1, struct replug);
- sv_setref_pv(obj, "re::engine::Plugin", (void *) re);
+ sv_setref_pv(obj, XSH_PACKAGE, (void *) re);
 
  newREGEXP(RX);
  rx = rxREGEXP(RX);
@@ -285,14 +281,16 @@ Plugin_exec(pTHX_ REGEXP * const RX, char *stringarg, char *strend,
             char *strbeg, REP_ENG_EXEC_MINEND_TYPE minend,
             SV *sv, void *data, U32 flags)
 {
- dSP;
+ struct regexp *rx;
+ re__engine__Plugin self;
  I32 matched;
- struct regexp *rx = rxREGEXP(RX);
 
- GET_SELF_FROM_PPRIVATE(rx->pprivate);
+ rx = rxREGEXP(RX);
+ SELF_FROM_PPRIVATE(self, rx->pprivate);
 
  if (self->cb_exec) {
   SV *ret;
+  dSP;
 
   /* Store the current str for ->str */
   SvREFCNT_dec(self->str);
@@ -420,16 +418,19 @@ void
 Plugin_numbered_buff_FETCH(pTHX_ REGEXP * const RX, const I32 paren,
                            SV * const sv)
 {
dSP;
I32 items;
struct regexp *rx;
re__engine__Plugin self;
  SV *callback;
- struct regexp *rx = rxREGEXP(RX);
 
- GET_SELF_FROM_PPRIVATE(rx->pprivate);
+ rx = rxREGEXP(RX);
+ SELF_FROM_PPRIVATE(self, rx->pprivate);
 
  callback = self->cb_num_capture_buff_FETCH;
 
  if (callback) {
+  I32 items;
+  dSP;
+
   ENTER;
   SAVETMPS;
 
@@ -461,15 +462,18 @@ void
 Plugin_numbered_buff_STORE(pTHX_ REGEXP * const RX, const I32 paren,
                            SV const * const value)
 {
- dSP;
+ struct regexp *rx;
+ re__engine__Plugin self;
  SV *callback;
- struct regexp *rx = rxREGEXP(RX);
 
- GET_SELF_FROM_PPRIVATE(rx->pprivate);
+ rx = rxREGEXP(RX);
+ SELF_FROM_PPRIVATE(self, rx->pprivate);
 
  callback = self->cb_num_capture_buff_STORE;
 
  if (callback) {
+  dSP;
+
   ENTER;
   SAVETMPS;
 
@@ -491,16 +495,18 @@ I32
 Plugin_numbered_buff_LENGTH(pTHX_ REGEXP * const RX, const SV * const sv,
                             const I32 paren)
 {
- dSP;
+ struct regexp *rx;
+ re__engine__Plugin self;
  SV *callback;
- struct regexp *rx = rxREGEXP(RX);
 
- GET_SELF_FROM_PPRIVATE(rx->pprivate);
+ rx = rxREGEXP(RX);
+ SELF_FROM_PPRIVATE(self, rx->pprivate);
 
  callback = self->cb_num_capture_buff_LENGTH;
 
  if (callback) {
   IV ret;
+  dSP;
 
   ENTER;
   SAVETMPS;
@@ -546,7 +552,7 @@ Plugin_package(pTHX_ REGEXP * const RX)
 {
  PERL_UNUSED_ARG(RX);
 
- return newSVpvs("re::engine::Plugin");
+ return newSVpvs(XSH_PACKAGE);
 }
 
 static void xsh_user_global_setup(pTHX) {