*
* Copyright (C) 2003 Merjis Ltd.
*
- * $Id: perl.mli,v 1.11 2003-12-11 17:41:52 rich Exp $
+ * $Id: perl.mli,v 1.12 2004-03-03 12:39:20 rich Exp $
*)
type sv
val deref : sv -> sv
(** The input is a reference to a scalar. This returns the underlying
* scalar [SV]. If the input is not a reference to a scalar, throws
- * [Invalid_arg].
+ * [Invalid_argument].
*)
val deref_array : sv -> av
(** The input is a reference to an array. This returns the underlying
* array [AV]. If the input is not a reference to an array, throws
- * [Invalid_arg].
+ * [Invalid_argument].
*)
val deref_hash : sv -> hv
(** The input is a reference to a hash. This returns the underlying
* hash [HV]. If the input is not a reference to a hash, throws
- * [Invalid_arg].
+ * [Invalid_argument].
*)
val av_empty : unit -> av
/* Interface to Perl from OCaml.
* Copyright (C) 2003 Merjis Ltd.
- * $Id: perl_c.c,v 1.14 2004-02-03 12:38:57 rich Exp $
+ * $Id: perl_c.c,v 1.15 2004-03-03 12:39:20 rich Exp $
*/
#include <stdio.h>
CAMLlocal1 (rsvv);
SV *sv = Sv_val (svv);
- if (SvTYPE (sv) != SVt_RV)
+ if (SvROK (sv))
invalid_argument ("deref: SV is not a reference");
switch (SvTYPE (SvRV (sv))) {
case SVt_IV:
CAMLlocal1 (ravv);
SV *sv = Sv_val (svv);
- if (SvTYPE (sv) != SVt_RV)
+ if (SvROK (sv))
invalid_argument ("deref_array: SV is not a reference");
switch (SvTYPE (SvRV (sv))) {
case SVt_PVAV:
CAMLlocal1 (rhvv);
SV *sv = Sv_val (svv);
- if (SvTYPE (sv) != SVt_RV)
- invalid_argument ("deref_array: SV is not a reference");
+ if (SvROK (sv))
+ invalid_argument ("deref_hash: SV is not a reference");
switch (SvTYPE (SvRV (sv))) {
case SVt_PVHV:
break;
default:
- invalid_argument ("deref_array: SV is not a reference to a hash");
+ invalid_argument ("deref_hash: SV is not a reference to a hash");
}
rhvv = Val_hv ((HV *) SvRV (sv));
CAMLreturn (rhvv);