* C stubs with many args.
@ 2009-11-29 15:31 Guillaume Yziquel
2009-11-29 16:28 ` [Caml-list] " Guillaume Yziquel
2009-11-29 18:31 ` Richard Jones
0 siblings, 2 replies; 3+ messages in thread
From: Guillaume Yziquel @ 2009-11-29 15:31 UTC (permalink / raw)
To: OCaml List
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/
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Caml-list] C stubs with many args.
2009-11-29 15:31 C stubs with many args Guillaume Yziquel
@ 2009-11-29 16:28 ` Guillaume Yziquel
2009-11-29 18:31 ` Richard Jones
1 sibling, 0 replies; 3+ messages in thread
From: Guillaume Yziquel @ 2009-11-29 16:28 UTC (permalink / raw)
To: OCaml List
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/
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Caml-list] C stubs with many args.
2009-11-29 15:31 C stubs with many args Guillaume Yziquel
2009-11-29 16:28 ` [Caml-list] " Guillaume Yziquel
@ 2009-11-29 18:31 ` Richard Jones
1 sibling, 0 replies; 3+ messages in thread
From: Richard Jones @ 2009-11-29 18:31 UTC (permalink / raw)
To: Guillaume Yziquel; +Cc: OCaml List
On Sun, Nov 29, 2009 at 04:31:11PM +0100, Guillaume Yziquel wrote:
> 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?
In case you still have problems, you could look at the code we
autogenerate in libguestfs, eg: ocaml/guestfs_c_actions.c. We
generate bindings for functions that have various numbers of arguments
(up to 9).
Rich.
--
Richard Jones
Red Hat
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2009-11-29 18:31 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-11-29 15:31 C stubs with many args Guillaume Yziquel
2009-11-29 16:28 ` [Caml-list] " Guillaume Yziquel
2009-11-29 18:31 ` Richard Jones
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox