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 mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id 6117FBBAF for ; Sun, 29 Nov 2009 17:28:36 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AkoKABowEktV2gB5aWdsb2JhbACER5RpgmQNCgkHFadVjxmBL4IuVASJEw X-IronPort-AV: E=Sophos;i="4.47,308,1257116400"; d="scan'208";a="51202712" Received: from emailfrontal2.citycable.ch ([85.218.0.121]) by mail4-smtp-sop.national.inria.fr with SMTP; 29 Nov 2009 17:28:36 +0100 Received: from [192.168.0.12] (unknown [85.218.92.99]) (Authenticated sender: guillaume.yziquel@citycable.ch) by emailfrontal2.citycable.ch (Postfix) with ESMTPA id 64638B10599; Sun, 29 Nov 2009 17:28:30 +0100 (CET) Message-ID: <4B12A134.3090703@citycable.ch> Date: Sun, 29 Nov 2009 17:28:36 +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: Re: [Caml-list] C stubs with many args. References: <4B1293BF.1000300@citycable.ch> In-Reply-To: <4B1293BF.1000300@citycable.ch> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable 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 Guillaume Yziquel a =C3=A9crit : > Hi. >=20 > I've been recently reworking Maxence Guesdon's OCaml-R binding in order= =20 > to provide a tighter integration with, and I'm currently trying to=20 > reverse-engineer the way closures are handled in R. So I've written up=20 > this small C stub code for a function with 6 parameters: OK. Figured it out. Stupid me: > 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 syscal= l, value env, value sysp, value promargs, value callfun) { > CAMLparam5(flags, syscall, env, sysp, promargs); > CAMLxparam1(callfun); > CAMLlocal1(result); > result =3D caml_alloc(1, Abstract_tag); > Rf_begincontext ( (context) Field(result, 0), Int_val(flags), Sexp_va= l(syscall), Sexp_val(env), > Sexp_val(sysp), Sexp_val(promargs), Sexp_val(callfu= n)); > CAMLreturn(result); > } > CAMLprim value r_reveng_begin_context_bytecode (value * argv, int argn)= { > return r_reveng_begin_context_native(argv[0], argv[1], argv[2], argv[= 3], argv[4], argv[5]); > } All the best, --=20 Guillaume Yziquel http://yziquel.homelinux.org/