Router-R3
view release on metacpan or search on metacpan
++p; \
} \
printf("\n"); \
}
#else
#define DUMP_PAD(pad) ;
#endif
void
new(...)
PPCODE:
{
void *r3_pad;
int branch_n = 0;
int capture_n_total = 0;
int capture_key_len_total = 0;
if( items == 0 )
croak("Router::R3::new without classname?");
if( items == 2 && SvROK(ST(1)) ) {
SV *rv = SvRV(ST(1));
switch( SvTYPE(rv) ) {
STRLEN classname_len;
char * classname = SvPVbyte(ST(0), classname_len);
HV * stash = gv_stashpvn(classname, classname_len, 0);
sv_bless(obj, stash);
EXTEND(SP, 1);
PUSHs(sv_2mortal(obj));
}
void
match(SV* r3_sv, SV *str_sv)
PPCODE:
void* r3_pad = SvRV(SvRV(r3_sv));
node* r3 = *(node**)r3_pad;
char *str;
STRLEN str_len;
str = SvPVbyte(str_sv, str_len);
match_entry* entry = match_entry_createl(str, str_len);
node* matched_node = r3_tree_matchl(r3, str, str_len, entry);
0
);
capture_key_cursor += 2;
}
}
PUSHs(sv_2mortal(newRV_noinc((SV*)captures_hv)));
}
match_entry_free(entry);
void DESTROY(SV* r3_sv)
PPCODE:
void* pad = SvRV(SvRV(r3_sv));
int branch_n = *(int*)((char*)pad + sizeof(node*));
SV** target = (SV**)((char*)pad + sizeof(node*) + sizeof(int));
for(int i=0; i<branch_n; ++i)
SvREFCNT_dec(target[i]);
r3_tree_free(*(node**)pad);
Safefree(pad);
SvRV(SvRV(r3_sv)) = 0;
#ifdef PERL_R3_DEBUG
fallback/const-xs.inc view on Meta::CPAN
dTARGET;
#endif
STRLEN len;
int type;
/* IV iv; Uncomment this if you need to return IVs */
/* NV nv; Uncomment this if you need to return NVs */
/* const char *pv; Uncomment this if you need to return PVs */
INPUT:
SV * sv;
const char * s = SvPV(sv, len);
PPCODE:
type = constant(aTHX_ s, len);
/* Return 1 or 2 items. First is error message, or undef if no error.
Second, if present, is found value */
switch (type) {
case PERL_constant_NOTFOUND:
sv =
sv_2mortal(newSVpvf("%s is not a valid Router::R3 macro", s));
PUSHs(sv);
break;
case PERL_constant_NOTDEF:
( run in 0.417 second using v1.01-cache-2.11-cpan-5511b514fd6 )