From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.2 required=5.0 tests=AWL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by yquem.inria.fr (Postfix) with ESMTP id 15C08BC37 for ; Fri, 7 Aug 2009 06:24:08 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgECAD9Je0rLOwFrkWdsb2JhbACaQAEBAQEJCwoHEwS1W4QWBQ X-IronPort-AV: E=Sophos;i="4.43,338,1246831200"; d="scan'208";a="32170604" Received: from outbound.icp-qv1-irony-out2.iinet.net.au ([203.59.1.107]) by mail3-smtp-sop.national.inria.fr with ESMTP; 07 Aug 2009 06:24:06 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApoEALdJe0rLzuai/2dsb2JhbADQXYQWBQ X-IronPort-AV: E=Sophos;i="4.43,338,1246809600"; d="scan'208";a="548082245" Received: from unknown (HELO hendrix.mega-nerd.net) ([203.206.230.162]) by outbound.icp-qv1-irony-out2.iinet.net.au with ESMTP; 07 Aug 2009 12:23:42 +0800 Received: from hendrix.mnn (hendrix.mnn [192.168.200.99]) by hendrix.mega-nerd.net (Postfix) with SMTP id 6DFE21070CD for ; Fri, 7 Aug 2009 14:23:42 +1000 (EST) Date: Fri, 7 Aug 2009 14:23:42 +1000 From: Erik de Castro Lopo To: caml-list@inria.fr Subject: Re: [Caml-list] C wrappers and callbacks from Ocaml to C and back to Ocaml Message-Id: <20090807142342.5ed13aac.mle+ocaml@mega-nerd.com> In-Reply-To: <87r5voa4y1.fsf@frosties.localdomain> References: <20090807071731.bfd0d34b.mle+ocaml@mega-nerd.com> <87r5voa4y1.fsf@frosties.localdomain> Reply-To: caml-list@inria.fr Organization: Erik Conspiracy Secret Labs X-Mailer: Sylpheed 2.6.0 (GTK+ 2.16.1; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam: no; 0.00; ocaml:01 wrappers:01 callbacks:01 ocaml:01 struct:01 cheers:01 wrote:01 caml-list:01 functions:01 caml:02 caml:02 debugging:03 root:04 root:04 erik:04 Goswin von Brederlow wrote: > Well, you just do. A structure is a value like anything else. Yes, with a bit of careful debugging I managed to get a bit further and even managed to extract (in the C code) the Ocaml function from the Ocaml struct and I think I can call it, but I haven't test that yet. > What you have to watch out for is the GC. This is what I was worried about :-). > If you store the value > somewhere then you have to tell the GC about it by registering it as a > new root. And when you are done with it you need to unregister it. Ah yes, the following two functions in : CAMLextern void caml_register_global_root (value *); CAMLextern void caml_remove_global_root (value *); Cheers, Erik -- ---------------------------------------------------------------------- Erik de Castro Lopo http://www.mega-nerd.com/