Medusa-XS
view release on metacpan or search on metacpan
lib/Medusa/XS.xs view on Meta::CPAN
SV *coderef
SV *method_name
PREINIT:
CV *cv;
CV *wrapper;
const char *method;
STRLEN method_len;
const char *pkg;
STRLEN pkg_len;
GV *gv;
PPCODE:
/* Get the CV from the coderef */
if (!SvROK(coderef) || SvTYPE(SvRV(coderef)) != SVt_PVCV) {
croak("wrap_sub: argument must be a code reference");
}
cv = (CV *)SvRV(coderef);
/* Get method name from CV or argument */
if (method_name && SvOK(method_name)) {
method = SvPV(method_name, method_len);
} else {
lib/Medusa/XS.xs view on Meta::CPAN
RETVAL = newSVpvf("AUDIT_CACHE@%s::%s", package, method);
OUTPUT:
RETVAL
# ------------------------------------------------------------------ #
# XSUB: _apply_deferred_wraps - Re-install wrappers queued on 5.10 #
# ------------------------------------------------------------------ #
void
_apply_deferred_wraps()
PPCODE:
medusa_check_apply_wraps(aTHX_ NULL);
XSRETURN(0);
# ------------------------------------------------------------------ #
# XSUB: log_message - Full XS logging implementation #
# ------------------------------------------------------------------ #
void
log_message(...)
PREINIT:
HV *params;
int i;
PPCODE:
/* Build params hash from @_ */
if (items % 2 != 0) {
croak("log_message: odd number of arguments");
}
params = newHV();
for (i = 0; i < items; i += 2) {
SV *key = ST(i);
SV *val = ST(i+1);
STRLEN len;
const char *k = SvPV(key, len);
lib/Medusa/XS.xs view on Meta::CPAN
# ------------------------------------------------------------------ #
# XSUB: init_logger - Initialize the logger from LOG_INIT #
# ------------------------------------------------------------------ #
void
init_logger()
PREINIT:
HV *log_config;
SV **svp;
PPCODE:
log_config = get_hv("Medusa::XS::LOG", 0);
if (!log_config) {
XSRETURN(0);
}
/* Check if LOG already initialized */
svp = hv_fetchs(log_config, "LOG", 0);
if (svp && SvROK(*svp)) {
XSRETURN(0);
}
lib/Medusa/XS.xs view on Meta::CPAN
void
import(...)
PREINIT:
HV *log_config;
const char *caller_pkg;
HV *caller_stash;
AV *isa;
GV *isa_gv;
int i;
PPCODE:
/* Check for odd number of args (after class name) */
if ((items - 1) % 2 != 0) {
croak("odd number of params passed in import");
}
/* Get caller package */
caller_pkg = CopSTASHPV(PL_curcop);
if (!caller_pkg) caller_pkg = "main";
/* Push Medusa::XS onto caller's @ISA */
lib/Medusa/XS.xs view on Meta::CPAN
PREINIT:
CV *cv;
GV *gv;
const char *method_name = "__ANON__";
STRLEN method_len = 8;
const char *pkg_name;
STRLEN pkg_len;
HV *audited;
int i;
bool found_audit = FALSE;
PPCODE:
/* Check if any attribute is "Audit" */
for (i = 2; i < items; i++) {
STRLEN len;
const char *attr = SvPV(ST(i), len);
if (len >= 5 && strncmp(attr, "Audit", 5) == 0) {
found_audit = TRUE;
break;
}
}
lib/Medusa/XS.xs view on Meta::CPAN
# ------------------------------------------------------------------ #
void
FETCH_CODE_ATTRIBUTES(pkg, coderef)
SV *pkg
SV *coderef
PREINIT:
CV *cv;
HV *audited;
bool is_audited_cv = FALSE;
PPCODE:
PERL_UNUSED_VAR(pkg);
if (!SvROK(coderef) || SvTYPE(SvRV(coderef)) != SVt_PVCV) {
XSRETURN(0);
}
cv = (CV *)SvRV(coderef);
/* Check %AUDITED hash */
audited = get_hv("Medusa::XS::AUDITED", 0);
if (audited) {
( run in 0.561 second using v1.01-cache-2.11-cpan-5511b514fd6 )