]> git.vpit.fr Git - perl/modules/Sub-Nary.git/blobdiff - Nary.xs
Rewrite list in XS
[perl/modules/Sub-Nary.git] / Nary.xs
diff --git a/Nary.xs b/Nary.xs
index 2415760185f879bcddfba0c20c1ade5d93ab449f..0165a66cb947b058a20f7e20bb1251d957433108 100644 (file)
--- a/Nary.xs
+++ b/Nary.xs
@@ -50,6 +50,23 @@ CODE:
  res = hv_exists(hv, "0", 1) && hv_iterinit(hv) == 1;
  XSRETURN_IV(res);
 
+void
+list(SV *sv)
+PROTOTYPE: $
+PREINIT:
+ HV *hv;
+ IV res;
+CODE:
+ if (!SvOK(sv))
+  XSRETURN_IV(0);
+ if (!SvROK(sv)) {
+  res = strEQ(SvPV_nolen(sv), "list");
+  XSRETURN_IV(res);
+ }
+ hv = (HV *) SvRV(sv);
+ res = hv_exists(hv, "list", 4) && hv_iterinit(hv) == 1;
+ XSRETURN_IV(res);
+
 void
 count(SV *sv)
 PROTOTYPE: $