Commented out ref counting code for now. Updated Debian version.
[perl4caml.git] / perl_c.c
index 772bae2..3214e34 100644 (file)
--- 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.13 2003-12-11 17:41:52 rich Exp $
+ * $Id: perl_c.c,v 1.14 2004-02-03 12:38:57 rich Exp $
  */
 
 #include <stdio.h>
 /* Perl requires the interpreter to be called literally 'my_perl'! */
 static PerlInterpreter *my_perl;
 
+/* Get the concrete value from an optional field. */
+static value unoption (value option, value deflt);
+
 /* Wrap up an arbitrary void pointer in an opaque OCaml object. */
 static value Val_voidptr (void *ptr);
 
+/* Unwrap an arbitrary void pointer from an opaque OCaml object. */
+#define Voidptr_val(type,rv) ((type *) Field ((rv), 0))
+
+#if PERL4CAML_REFCOUNTING_EXPERIMENTAL
+
+/* Unwrap a custom block. */
+#define Xv_val(rv) (*((void **)Data_custom_val(rv)))
+
 /* Wrap up an SV, AV or HV in a custom OCaml object which will decrement
  * the reference count on finalization.
  */
 static value Val_xv (SV *sv);
 
-/* Get the concrete value from an optional field. */
-static value unoption (value option, value deflt);
+#else
 
-/* Unwrap an arbitrary void pointer from an opaque OCaml object. */
-#define Voidptr_val(type,rv) ((type *) Field ((rv), 0))
+#define Xv_val(rv) Voidptr_val (SV, (rv))
+#define Val_xv(sv) Val_voidptr ((sv))
 
-/* Unwrap a custom block. */
-#define Xv_val(rv) (*((void **)Data_custom_val(rv)))
+#endif
 
 /* Hide Perl types in opaque OCaml objects. */
 #define Val_perl(pl) (Val_voidptr ((pl)))
@@ -1044,6 +1053,8 @@ Val_voidptr (void *ptr)
   CAMLreturn (rv);
 }
 
+#if PERL4CAML_REFCOUNTING_EXPERIMENTAL
+
 static void
 xv_finalize (value v)
 {
@@ -1069,6 +1080,8 @@ Val_xv (SV *sv)
   CAMLreturn (rv);
 }
 
+#endif /* PERL4CAML_REFCOUNTING_EXPERIMENTAL */
+
 static value
 unoption (value option, value deflt)
 {