From 7e4c9fd14a6ece5941cadec586daaf4ab8f02d39 Mon Sep 17 00:00:00 2001 From: rich Date: Wed, 3 Mar 2004 12:39:20 +0000 Subject: [PATCH] Attempts to fix the deref_* functions. --- perl.mli | 8 ++++---- perl_c.c | 12 ++++++------ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/perl.mli b/perl.mli index a9f0555..778de58 100644 --- a/perl.mli +++ b/perl.mli @@ -2,7 +2,7 @@ * * 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 @@ -88,17 +88,17 @@ val hashref : hv -> 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 diff --git a/perl_c.c b/perl_c.c index 3214e34..20d4299 100644 --- a/perl_c.c +++ b/perl_c.c @@ -1,6 +1,6 @@ /* 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 @@ -233,7 +233,7 @@ perl4caml_deref (value svv) 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: @@ -256,7 +256,7 @@ perl4caml_deref_array (value svv) 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: @@ -275,13 +275,13 @@ perl4caml_deref_hash (value svv) 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); -- 1.8.3.1