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 TAA27382; Tue, 4 Jun 2002 19:25:19 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id TAA27378 for ; Tue, 4 Jun 2002 19:25:18 +0200 (MET DST) Received: from relay.rinet.ru (relay.rinet.ru [195.54.192.35]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id g54HPHH05906 for ; Tue, 4 Jun 2002 19:25:17 +0200 (MET DST) Received: (from uucp@localhost) by relay.rinet.ru (8.11.6/8.11.6) with UUCP id g54HPBJ14672 for caml-list@inria.fr; Tue, 4 Jun 2002 21:25:11 +0400 (MSD) X-Envelope-To: caml-list@inria.fr Received: from bely.stormoff (BELY) [192.168.0.10] by stormoff with esmtp (Exim 3.12 #1 (Debian)) id 17FI1P-00039m-00; Tue, 04 Jun 2002 21:23:03 +0400 X-Comment-To: Florian Hars To: caml-list@inria.fr Subject: Re: [Caml-list] CamlIDL documentation and COM issues References: <3CFCEAB6.5040204@hars.de> From: Dmitry Bely Date: Tue, 04 Jun 2002 21:23:04 +0400 In-Reply-To: <3CFCEAB6.5040204@hars.de> (Florian Hars's message of "Tue, 04 Jun 2002 18:28:38 +0200") Message-ID: <8z5vq7pj.fsf@mail.ru> User-Agent: Gnus/5.090007 (Oort Gnus v0.07) XEmacs/21.4 (Economic Science (Windows [1]), i586-pc-win32) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Florian Hars writes: > I am trying to write an interface to an existing C library and I > intend to use CamlIDL for this task, but I am missing some more > HOWTO-like documentation. > > The library uses a pattern that should be common enough to supported > in CamlIDL (and explained in the hints on writing IDL files): there is > a struct that is only of internal relavance, and there is an open and > a close function that returns or frees a pointer to such a struct, and > several functions that operate on such a handle: > > typedef struct { /* things */ } Foo; > typedef Foo * FooHandle; > FooHandle FooOpen(args...); > int FooOperate(FooHandle fhdl, args...); > void FooClose(FooHandle fhdl); > > Now all I need is a way to put this handle into a Caml variable (and, > optionally, to call FooClose automatically whenever the handle runs > out of scope). It looks like the [abstract] and [ptr] attributes, > either alone or in combination, might be relevant for this task. But > [ptr] requires the Com module, which I do not want to use. (OK, it is > tiny under unix, but still... It's easy: [interface.idl] quote(c,"#include "); typedef [abstract,finalize(FooClose)] void* FooHandle; FooHandle FooOpen(args...); int FooOperate(FooHandle fhdl, args...); void FooClose(FooHandle fhdl); $camlidl -no-include interface.idl FooClose() will be called automatically when Foo instance is garbage-collected. > what happens if I ever recompile the > program under windoze? Shouldn't the generally useful features for > interfacing to C/C++ and the COM-specific stuff be somehow separated, > like in a module Idl and another module Com? This would certainly help > to reduce the prevailing confusion over the possible uses of > CamlIDL. Or is it irrelevant for my problem?) Com module works under unix and windows (under Unix some COM stuff is emulated), so there is no such problem. > An example for the use of errorcheck(fn) and a remark on the type of > fn in errorcheck might be helpful, too. If you write IDL definition typedef [errorcheck(checkFoo)] something Foo; then checkFoo() should have C prototype void check(Foo); > Oh, and shouldn't the example on page 24 of the Manual (1.0.4) read > > double time() quote(call, "_res=....; "); > ^^^^^^ > Or is "call" implicit if no ident is given in a quote in a function > definition? Yes, "call" can be ommited: [camlidl/compiler/parser_midl.mly] ... opt_quotes: opt_quotes QUOTE LPAREN STRING RPAREN { ("call", $4) :: $1 } | opt_quotes QUOTE LPAREN ident COMMA STRING RPAREN { ($4, $6) :: $1 } | /* empty */ { [] } ; But you are right, this doesn't seem to be documented in the manual. Ask Xavier Leroy for the correction. Hope to hear from you soon, Dmitry ------------------- 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