From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id HAA02773; Fri, 27 Jun 2003 07:24:55 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id HAA02559 for ; Fri, 27 Jun 2003 07:24:53 +0200 (MET DST) Received: from post.kis.ru (post.kis.ru [195.98.32.206]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id h5R5Oqf05720 for ; Fri, 27 Jun 2003 07:24:53 +0200 (MET DST) Received: from [195.98.54.162] (HELO heaven.merann.ru) by post.kis.ru (CommuniGate Pro SMTP 4.0.6) with ESMTP id 2990549; Fri, 27 Jun 2003 09:24:51 +0400 Date: Fri, 27 Jun 2003 09:24:59 +0400 From: Mikhail Fedotov X-Mailer: The Bat! (v1.62r) Reply-To: Mikhail Fedotov X-Priority: 3 (Normal) Message-ID: <54997465.20030627092459@kittown.com> To: "Jean-Baptiste Rouquier" CC: caml-list@inria.fr Subject: Re[2]: [Caml-list] interfacing C and OCaml In-Reply-To: <003001c33c17$343a0d80$355afac1@zofo> References: <003001c33c17$343a0d80$355afac1@zofo> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Spam: no; 0.00; caml-list:01 interfacing:01 camlprim:01 buffer:01 foo:01 camlparam:01 camlreturn:01 camllocal:01 alloc:01 val:01 sizeof:01 ocaml:01 int:01 ops:01 data:03 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Hi! JBR> 1. Should I use JBR> CAMLprim value input(value channel, value buffer, value offset, value JBR> length) JBR> { JBR> return ... JBR> } Yes. This function can be called from other C function or from OCaml. JBR> as in 18.1.2 in the manual, or JBR> void foo (value v1, value v2, value v3) JBR> { JBR> CAMLparam3 (v1, v2, v3); JBR> ... JBR> CAMLreturn0; JBR> } This if for functions called from C only. Not suitable for use from OCaml directly. Should be specified in the manual, I believe, but I've got no response in the list to my comment on this. I hope it will be in the manual for the OCaml 3.07. JBR> ------------------------------------------------ JBR> 3. Is it correct to store p in the custom block v by JBR> CAMLlocal(v); JBR> v = alloc_custom(ops, 4, 0, 1); JBR> (my_type *) Data_custom_val(v) = p; JBR> ? JBR> When does the parameter "size" (here "4") vary ? CAMLlocal(v); my_type *t; my_type r; v = alloc_custom(ops, 1 + sizeof(my_type), 1, 10); t = (my_type *) Data_custom_val(v); t->some_int_member = 7; Mikhail ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners