#include "sub_op.h"
+void sub_op_init(sub_op_config_t *c) {
+ c->name = NULL;
+ c->namelen = 0;
+ c->pp = 0;
+ c->check = 0;
+ c->ud = NULL;
+
+ return;
+}
+
void sub_op_register(pTHX_ const sub_op_config_t *c) {
SV *key = newSViv(PTR2IV(c->pp));
if (!PL_custom_op_names)
PL_custom_op_names = newHV();
- (void) hv_store_ent(PL_custom_op_names, key, newSVpv(c->name, c->len), 0);
+ (void) hv_store_ent(PL_custom_op_names, key, newSVpv(c->name, c->namelen), 0);
if (!PL_custom_op_descs)
PL_custom_op_descs = newHV();
- (void) hv_store_ent(PL_custom_op_descs, key, newSVpv(c->name, c->len), 0);
+ (void) hv_store_ent(PL_custom_op_descs, key, newSVpv(c->name, c->namelen), 0);
if (c->check) {
SV *check = newSViv(PTR2IV(c->check));
{
dMY_CXT;
- (void) hv_store(MY_CXT.map, c->name, c->len, key, 0);
+ (void) hv_store(MY_CXT.map, c->name, c->namelen, key, 0);
}
}
+sub_op_config_t *sub_op_dup(pTHX_ const sub_op_config_t *orig) {
+ sub_op_config_t *dupe = PerlMemShared_malloc(sizeof *dupe);
+
+ dupe->namelen = orig->namelen;
+ dupe->name = PerlMemShared_malloc(dupe->namelen);
+ Copy(orig->name, dupe->name, dupe->namelen, char);
+
+ dupe->pp = orig->pp;
+ dupe->check = orig->check;
+ dupe->ud = orig->ud;
+
+ return dupe;
+}
+
+void sub_op_free(pTHX_ sub_op_config_t *c) {
+ PerlMemShared_free((char *) c->name);
+ PerlMemShared_free(c);
+
+ return;
+}
+
/* --- Private helpers ----------------------------------------------------- */
STATIC IV so_hint(pTHX) {
XSRETURN_UNDEF;
ST(0) = sv_2mortal(newSVpvn(&on->buf, on->len));
XSRETURN(1);
+
+void
+_constant_sub(SV *sv)
+PROTOTYPE: $
+PPCODE:
+ if (!SvROK(sv))
+ XSRETURN_UNDEF;
+ sv = SvRV(sv);
+ if (SvTYPE(sv) < SVt_PVCV)
+ XSRETURN_UNDEF;
+ ST(0) = sv_2mortal(newSVuv(CvCONST(sv)));
+ XSRETURN(1);