caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Xavier Leroy <Xavier.Leroy@inria.fr>
To: Patrick Goldbronn - SYSCO <patrick.goldbronn@cea.fr>,
	"Inria, caml" <caml-list@inria.fr>
Subject: Re: use of camlidl
Date: Thu, 16 Dec 1999 11:35:49 +0100	[thread overview]
Message-ID: <19991216113549.20150@pauillac.inria.fr> (raw)
In-Reply-To: <38564CD2.E5C1A7E4@cea.fr>; from Patrick Goldbronn - SYSCO on Tue, Dec 14, 1999 at 01:57:38PM +0000

> I'd like to give the caml name of the interfacing C function :
> for example, I have the function :
> void NP_do (int n , double val) ;
> With camlidl, I get the caml function nP_do: int -> float -> unit ;
> I'd like to have the name 'do' (in module np.ml :) )

"do" is problematic because it's a Caml reserved keyword.  But more to
the point, CamlIDL doesn't (yet) allow the Caml name of a function to
be specified, it derives it automatically from the name given in the
IDL file.  I admit an mlname(...) attribute on function declarations
could be useful, though.

> 2)
> I see in documentation (in section 3.7 page 10) 
>   value c2ml (ty * input) ;
>   void ml2c (value input, ty * output) ;
> 
> But in generated C file, I see another argument : 'camlidl_ctx _ctx'
> 
> So (after error during compilation) I added camlidl_ctx in function c2ml
> and ml2c but I don't use it (of course I don't know what is it :( )
> 
>   value c2ml (ty * input, camlidl_ctx _ctx) ;
>   void ml2c (value input, ty * output, camlidl_ctx _ctx) ;
> 
> That's right nevertheless ?

Yes.  The "camlidl_ctx" argument is useful if your c2ml and ml2c
functions need to perform dynamic allocation of C memory (a la
malloc()) and want the allocated memory to be automatically freed when
the stub code terminates.  If you don't need dynamic allocation in
your conversion functions, you can safely ignore the extra parameter.

> I have another trouble : I can't define a string array.
> I have the C function :
> void NP_initialize( int argc, char ** argv, int *err );
> Where argc is the length of the string array argv (of course) and err is
> an error code.
> I can't retrieve the 'string array' in ml file. I've got 'char option
> array'  ??
> void NP_initialize( [in] int argc, [in,length_is(argc)] char ** argv,
> [out] int *err );

You need to tell CamlIDL that those "char *" are really strings:

void NP_initialize( [in] int argc,
                    [in,length_is(argc),string*] char ** argv,
                    [out] int *err );

Hope this helps,

- Xavier Leroy




      parent reply	other threads:[~1999-12-16 11:54 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-12-14 13:57 Patrick Goldbronn - SYSCO
1999-12-15  9:03 ` Patrick Goldbronn - SYSCO
1999-12-16 10:35 ` Xavier Leroy [this message]

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=19991216113549.20150@pauillac.inria.fr \
    --to=xavier.leroy@inria.fr \
    --cc=caml-list@inria.fr \
    --cc=patrick.goldbronn@cea.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;
as well as URLs for NNTP newsgroup(s).