From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id p9F9UViL007558 for ; Sat, 15 Oct 2011 11:30:31 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AkMBAAVSmU7RVdi2imdsb2JhbABDqF0IIgEBAQoJDQcSBiGCBwITGQEbHgMSCQddAREBBQEiGxqeYIJYCotRgmCEcj2IbgIFCod6BId8hHCHDo0qPYN0 X-IronPort-AV: E=Sophos;i="4.69,350,1315173600"; d="scan'208";a="113010339" Received: from mail-qy0-f182.google.com ([209.85.216.182]) by mail4-smtp-sop.national.inria.fr with ESMTP/TLS/RC4-SHA; 15 Oct 2011 11:30:24 +0200 Received: by qyg14 with SMTP id 14so1118469qyg.6 for ; Sat, 15 Oct 2011 02:30:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; bh=cq0bkJYyiS3fu89E8KwKh420cIk71c41vDGRQ5ELa5c=; b=WnqO2DkMN07bcNr5XDOC/JaUV8oALrlWXaQkeR/9d6935WaQdCrqnuTtZDGVFwGfs7 pfITHQrLCXn/SB35zSG8tMbnffqMX+/gGUbTlCxbF+bHJuZlKJpnCJ7nmZAfY0SBstgW tOGFxMZtPTtUNiDJqGLoOH2uieMpepzpASHXk= MIME-Version: 1.0 Received: by 10.229.196.144 with SMTP id eg16mr2654922qcb.59.1318671022909; Sat, 15 Oct 2011 02:30:22 -0700 (PDT) Received: by 10.229.95.198 with HTTP; Sat, 15 Oct 2011 02:30:22 -0700 (PDT) Date: Sat, 15 Oct 2011 13:30:22 +0400 Message-ID: From: Kakadu To: Caml List Content-Type: multipart/alternative; boundary=0050450155fbe569e504af530551 Subject: [Caml-list] [C] call Caml method --0050450155fbe569e504af530551 Content-Type: text/plain; charset=ISO-8859-1 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 --0050450155fbe569e504af530551 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
Hi!

I've found in OCaml manual = how to call object's method without arguments. But I have no idea how t= o call method with some arguments.
For example I have this OCaml code:
external call_meth:= < .. > -> unit =3D "call_a_meth"

class a =3D object
=A0 method foo x =3D print_endline x end;;

and= C code:

CAMLpri= m
value call_a_meth(value obj) { =A0 CAMLparam1(obj);
=A0 CAMLlocal3(meth, meth2, arg1); =A0 meth =3D caml_get_p= ublic_method(obj, caml_hash_variant("foo") ) ;
=A0 if (meth =3D=3D 0)
=A0=A0=A0=A0=A0=A0 prin= tf ("Fuck\n");
=A0 arg1 =3D Val_= int(1);
//=A0 caml_callback2(me= th, obj, arg1); // segfault in this line
= =A0 meth2 =3D caml_callback(meth, obj);=A0 // no crash, but method's bo= dy is not being executed
=A0 caml_callback(meth2, arg1); =A0 =A0= =A0=A0 // segfault.
=A0 CAMLreturn(Val_un= it);

}

I'v= e tested three variants of calling above, But I still can't call a meth= od with parameters. Any ideas?

Best wishes,
Kakadu
--0050450155fbe569e504af530551--