Version française
Home     About     Download     Resources     Contact us    
Browse thread
C stubs with many args.
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Guillaume Yziquel <guillaume.yziquel@c...>
Subject: Re: [Caml-list] C stubs with many args.
Guillaume Yziquel a écrit :
> 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:

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 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) {
>   return r_reveng_begin_context_native(argv[0], argv[1], argv[2], argv[3], argv[4], argv[5]);
> }

All the best,

-- 
      Guillaume Yziquel
http://yziquel.homelinux.org/