X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=perl_c.c;h=3214e34bf8653eff826c664f7f71949ee9db1427;hb=da563c98dbb391c4343bb3749ccd3b47a3cc425f;hp=772bae2c37eba525482b6f9ca90325dcd9d22ab6;hpb=b10da63ac424daf0c005a666510afeafe1bcbfd3;p=perl4caml.git diff --git a/perl_c.c b/perl_c.c index 772bae2..3214e34 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.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 @@ -31,22 +31,31 @@ /* 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) {