Horus

 view release on metacpan or  search on metacpan

Horus.xs  view on Meta::CPAN

    const char *ns_str = SvPV(ns_sv, ns_len);
    return horus_parse_uuid(ns_out, ns_str, ns_len);
}

/* ══════════════════════════════════════════════════════════════════
 * Custom ops - bypass XS subroutine dispatch overhead (5.14+)
 * ══════════════════════════════════════════════════════════════════ */

#if PERL_VERSION >= 14

/* ── Macro: ppaddr swap (for variable-arity functions) ───────────
 * Quick approach that leaves entersub intact - use for optional args */

#define HORUS_CK(name) \
static OP *horus_ck_##name(pTHX_ OP *o, GV *namegv, SV *protosv) { \
    PERL_UNUSED_ARG(namegv); PERL_UNUSED_ARG(protosv); \
    o->op_ppaddr = pp_horus_##name; return o; \
}

/* ── Macro: proper call checker for zero-arg functions ─────────── */

#define HORUS_CK_NOARG(name) \
static OP *horus_ck_##name(pTHX_ OP *entersubop, GV *namegv, SV *protosv) { \
    OP *pushop, *nextop, *newop; \
    PERL_UNUSED_ARG(namegv); PERL_UNUSED_ARG(protosv); \
    \
    pushop = cLISTOPx(entersubop)->op_first; \
    if (!pushop) return entersubop; \
    \
    if (pushop->op_type == OP_NULL && cLISTOPx(pushop)->op_first) { \

Horus.xs  view on Meta::CPAN

    nextop = OpSIBLING(pushop); \
    if (!nextop) return entersubop; \
    if (OpSIBLING(nextop)) return entersubop; \
    \
    newop = newOP(OP_CUSTOM, 0); \
    newop->op_ppaddr = pp_horus_##name; \
    op_free(entersubop); \
    return newop; \
}

/* ── Macro: proper call checker for unary functions ────────────── */

#define HORUS_CK_UNARY(name) \
static OP *horus_ck_##name(pTHX_ OP *entersubop, GV *namegv, SV *protosv) { \
    OP *pushop, *argop, *nextop, *newop; \
    PERL_UNUSED_ARG(namegv); PERL_UNUSED_ARG(protosv); \
    \
    pushop = cLISTOPx(entersubop)->op_first; \
    if (!pushop) return entersubop; \
    \
    if (pushop->op_type == OP_NULL && cLISTOPx(pushop)->op_first) { \

Horus.xs  view on Meta::CPAN

    OpMORESIB_set(pushop, nextop); \
    OpLASTSIB_set(argop, NULL); \
    \
    newop = newUNOP(OP_NULL, 0, argop); \
    newop->op_type = OP_CUSTOM; \
    newop->op_ppaddr = pp_horus_##name; \
    op_free(entersubop); \
    return newop; \
}

/* ── Macro: proper call checker for binary functions ──────────── */

#define HORUS_CK_BINARY(name) \
static OP *horus_ck_##name(pTHX_ OP *entersubop, GV *namegv, SV *protosv) { \
    OP *pushop, *arg1, *arg2, *nextop, *newop; \
    PERL_UNUSED_ARG(namegv); PERL_UNUSED_ARG(protosv); \
    \
    pushop = cLISTOPx(entersubop)->op_first; \
    if (!pushop) return entersubop; \
    \
    if (pushop->op_type == OP_NULL && cLISTOPx(pushop)->op_first) { \

Horus.xs  view on Meta::CPAN

} \
HORUS_CK_NOARG(name)

PP_CONST_PV(ns_dns,  "6ba7b810-9dad-11d1-80b4-00c04fd430c8", 36)
PP_CONST_PV(ns_url,  "6ba7b811-9dad-11d1-80b4-00c04fd430c8", 36)
PP_CONST_PV(ns_oid,  "6ba7b812-9dad-11d1-80b4-00c04fd430c8", 36)
PP_CONST_PV(ns_x500, "6ba7b814-9dad-11d1-80b4-00c04fd430c8", 36)

/* ── pp_* : Generator ops (proper restructuring) ─────────────── */

/* Macro for 0-or-1 arg generator call checker */
#define HORUS_CK_GEN01(name) \
static OP *horus_ck_##name(pTHX_ OP *entersubop, GV *namegv, SV *protosv) { \
    OP *pushop, *argop, *nextop, *newop; \
    int argc = 0; \
    PERL_UNUSED_ARG(namegv); PERL_UNUSED_ARG(protosv); \
    \
    pushop = cLISTOPx(entersubop)->op_first; \
    if (!pushop) return entersubop; \
    \
    if (pushop->op_type == OP_NULL && cLISTOPx(pushop)->op_first) { \

Horus.xs  view on Meta::CPAN


    SP = PL_stack_base + markix;
    XPUSHs(sv_2mortal(horus_uuid_to_sv(aTHX_ uuid, fmt)));
    PUTBACK;
    return NORMAL;
}
HORUS_CK(uuid_v5)

/* uuid_v8(custom_data, fmt?) - 1 or 2 args */

/* Macro for 1-or-2 arg call checker */
#define HORUS_CK_GEN12(name, pp1, pp2) \
static OP *horus_ck_##name(pTHX_ OP *entersubop, GV *namegv, SV *protosv) { \
    OP *pushop, *arg1, *arg2, *nextop, *newop; \
    int argc = 0; \
    PERL_UNUSED_ARG(namegv); PERL_UNUSED_ARG(protosv); \
    \
    pushop = cLISTOPx(entersubop)->op_first; \
    if (!pushop) return entersubop; \
    \
    if (pushop->op_type == OP_NULL && cLISTOPx(pushop)->op_first) { \

Horus.xs  view on Meta::CPAN

    int result = 0;

    if (horus_parse_uuid(uuid, in_str, in_len) == HORUS_PARSE_OK)
        result = horus_uuid_is_max_bin(uuid);

    SETs(sv_2mortal(newSViv(result)));
    RETURN;
}
HORUS_CK_UNARY(uuid_is_max)

/* ── Macro: XOP + call checker registration ──────────────────── */

#define HORUS_REG_XOP(c_name, desc) \
    XopENTRY_set(&horus_xop_##c_name, xop_name, "horus_" #c_name); \
    XopENTRY_set(&horus_xop_##c_name, xop_desc, desc); \
    Perl_custom_op_register(aTHX_ pp_horus_##c_name, &horus_xop_##c_name);

/* Register both variants of a 0-or-1 arg function under same XOP */
#define HORUS_REG_XOP_GEN01(c_name, desc) \
    XopENTRY_set(&horus_xop_##c_name, xop_name, "horus_" #c_name); \
    XopENTRY_set(&horus_xop_##c_name, xop_desc, desc); \



( run in 0.750 second using v1.01-cache-2.11-cpan-df04353d9ac )