Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] camlidl - finalizing cows without COM!
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Xavier Leroy <xavier.leroy@i...>
Subject: Re: [Caml-list] camlidl - finalizing cows without COM!
> Hi,
> I have just started hacking in camlidl and for now had a really pleasant
> experience.
> However I really can't find out how to create a finalized object without
> going into COM interfaces.
> Say my underlying C library for manipulating ..... hmmm.. cows  has a
> function that creates and references a new cow, and a function that is used
> to de-reference the cows when they no longer are live:
> typedef int cow;
> cow createAndReferenceCow(void);
> void freeCow(cow);
> Now, when the OCaml structures for some reason decide to garbage collect my
> cow the finalized object should call freeCow......  I have done this a bunch
> of times without the idl interface, but have no clue how to specify this in
> an idl file.  Help!!!

There's a new release of CamlIDL at
that supports a "finalize" attribute to do just this, e.g.

        typedef [abstract,finalize(freeCow)] int cow;

The release also fixes some minor bugs with error reporting in
presence of import files, and with "const" qualifiers.  (Thanks for
Dmitry Bely for his extensive testing and bug hunting!)

- Xavier Leroy
To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: