/* Interface to Perl from OCaml.
* Copyright (C) 2003 Merjis Ltd.
- * $Id: perl_c.c,v 1.8 2003-10-18 12:36:09 rich Exp $
+ * $Id: perl_c.c,v 1.11 2003-10-26 12:57:11 rich Exp $
*/
#include <stdio.h>
}
CAMLprim value
-perl4caml_sv_is_undef (value svv)
-{
- CAMLparam1 (svv);
- SV *sv = Sv_val (svv);
- CAMLreturn (SvLEN (sv) == 0 ? Val_true : Val_false);
-}
-
-CAMLprim value
perl4caml_sv_undef (value unit)
{
CAMLparam1 (unit);
}
CAMLprim value
+perl4caml_scalarref (value svv)
+{
+ CAMLparam1 (svv);
+ CAMLlocal1 (rsvv);
+ SV *sv = Sv_val (svv);
+ rsvv = Val_sv (newRV_inc (sv));
+ CAMLreturn (rsvv);
+}
+
+CAMLprim value
+perl4caml_arrayref (value avv)
+{
+ CAMLparam1 (avv);
+ CAMLlocal1 (rsvv);
+ AV *av = Av_val (avv);
+ rsvv = Val_sv (newRV_inc ((SV *) av));
+ CAMLreturn (rsvv);
+}
+
+CAMLprim value
+perl4caml_hashref (value hvv)
+{
+ CAMLparam1 (hvv);
+ CAMLlocal1 (rsvv);
+ HV *hv = Hv_val (hvv);
+ rsvv = Val_sv (newRV_inc ((SV *) hv));
+ CAMLreturn (rsvv);
+}
+
+CAMLprim value
perl4caml_deref (value svv)
{
CAMLparam1 (svv);
else if (optfnname != Val_int (0))
{
fnname = unoption (optfnname, Val_false);
- count = call_pv (String_val (fnname), G_EVAL|G_VOID);
+ count = call_pv (String_val (fnname), G_EVAL|G_VOID|G_DISCARD);
}
else
{
SPAGAIN;
- assert (count == 0); /* Pretty sure it should never be anything else. */
+ assert (count == 0);
/* Restore the stack. */
PUTBACK;
PUTBACK;
- count = call_method (String_val (name), G_EVAL|G_VOID);
+ count = call_method (String_val (name), G_EVAL|G_VOID|G_DISCARD);
SPAGAIN;
- assert (count == 0); /* Pretty sure it should never be anything else. */
+ assert (count == 0);
/* Restore the stack. */
PUTBACK;
PUTBACK;
- count = call_method (String_val (name), G_EVAL|G_VOID);
+ count = call_method (String_val (name), G_EVAL|G_VOID|G_DISCARD);
SPAGAIN;
- assert (count == 0); /* Pretty sure it should never be anything else. */
+ assert (count == 0);
/* Restore the stack. */
PUTBACK;