From: Kakadu <kakadu.hafanana@gmail.com>
To: Caml List <caml-list@inria.fr>
Subject: [Caml-list] [C] call Caml method
Date: Sat, 15 Oct 2011 13:30:22 +0400 [thread overview]
Message-ID: <CAGmVoG3JbmLcPnwM33HVxosWEB0eM2mQqxrv6reRMnuooaEf0A@mail.gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 874 bytes --]
Hi!
I've found in OCaml manual how to call object's method without arguments.
But I have no idea how to call method with some arguments.
For example I have this OCaml code:
external call_meth: < .. > -> unit = "call_a_meth"
class a = object
method foo x = print_endline x
end;;
and C code:
CAMLprim
value call_a_meth(value obj) {
CAMLparam1(obj);
CAMLlocal3(meth, meth2, arg1);
meth = caml_get_public_method(obj, caml_hash_variant("foo") ) ;
if (meth == 0)
printf ("Fuck\n");
arg1 = Val_int(1);
// caml_callback2(meth, obj, arg1); // segfault in this line
meth2 = caml_callback(meth, obj); // no crash, but method's body is not
being executed
caml_callback(meth2, arg1); // segfault.
CAMLreturn(Val_unit);
}
I've tested three variants of calling above, But I still can't call a method
with parameters. Any ideas?
Best wishes,
Kakadu
[-- Attachment #2: Type: text/html, Size: 2813 bytes --]
next reply other threads:[~2011-10-15 9:30 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-15 9:30 Kakadu [this message]
2011-10-15 9:44 ` Jérémie Dimino
2011-10-15 11:22 ` Kakadu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAGmVoG3JbmLcPnwM33HVxosWEB0eM2mQqxrv6reRMnuooaEf0A@mail.gmail.com \
--to=kakadu.hafanana@gmail.com \
--cc=caml-list@inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox