From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by yquem.inria.fr (Postfix) with ESMTP id CB39BBBAF for ; Sun, 29 Nov 2009 16:31:04 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AjgEAIIiEktV2gB4h2dsb2JhbACER5RpgmQBAQEKCwgHFacgjyGBL4IuVASBcoch X-IronPort-AV: E=Sophos;i="4.47,308,1257116400"; d="scan'208";a="41037245" Received: from emailfrontal1.citycable.ch ([85.218.0.120]) by mail1-smtp-roc.national.inria.fr with SMTP; 29 Nov 2009 16:31:04 +0100 Received: from [192.168.0.12] (unknown [85.218.92.99]) (Authenticated sender: guillaume.yziquel@citycable.ch) by emailfrontal1.citycable.ch (Postfix) with ESMTPA id 6DE5712C279; Sun, 29 Nov 2009 16:31:03 +0100 (CET) Message-ID: <4B1293BF.1000300@citycable.ch> Date: Sun, 29 Nov 2009 16:31:11 +0100 From: Guillaume Yziquel Reply-To: guillaume.yziquel@citycable.ch User-Agent: Mozilla-Thunderbird 2.0.0.22 (X11/20090707) MIME-Version: 1.0 To: OCaml List Subject: C stubs with many args. Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam: no; 0.00; guillaume:01 guillaume:01 stubs:01 maxence:01 stub:01 flags:01 sexp:01 sexp:01 camlprim:01 flags:01 camlparam:01 alloc:01 val:01 val:01 camlreturn:01 Hi. I've been recently reworking Maxence Guesdon's OCaml-R binding in order to provide a tighter integration with, and I'm currently trying to reverse-engineer the way closures are handled in R. So I've written up this small C stub code for a function with 6 parameters: > void Rf_begincontext (RCNTXT * cptr, int flags, SEXP syscall, SEXP env, SEXP sysp, SEXP promargs, SEXP callfun); > CAMLprim value r_reveng_begin_context_native (value flags, value syscall, value env, value sysp, value promargs, value callfun) { > CAMLparam5(flags, syscall, env, sysp, promargs); > CAMLxparam1(callfun); > CAMLlocal1(result); > result = caml_alloc(1, Abstract_tag); > Rf_begincontext ( (context) Field(result, 0), Int_val(flags), Sexp_val(syscall), Sexp_val(env), > Sexp_val(sysp), Sexp_val(promargs), Sexp_val(callfun)); > CAMLreturn(result); > } > CAMLprim value r_reveng_begin_context_bytecode (value * argv, int argn) { > > } I've been trying to follow section 18.1.2 of: http://caml.inria.fr/pub/docs/manual-ocaml/manual032.html Unfortunately, I'm a bit confused as to what should the CAMLparam and such be for the bytecode stub. Could someone provide me with an example somewhere? All the best, -- Guillaume Yziquel http://yziquel.homelinux.org/