caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] replacing swig
@ 2011-01-06 12:20 Joel Reymont
  2011-01-06 12:31 ` [Caml-list] " Joel Reymont
  2011-01-06 13:15 ` [Caml-list] " Adrien
  0 siblings, 2 replies; 3+ messages in thread
From: Joel Reymont @ 2011-01-06 12:20 UTC (permalink / raw)
  To: caml-list

Suppose you are writing a SWIG replacement based on gccxml, gcc plugins, etc. 

How would you figure out if the user meant char** as a pointer to a string vs an array of characters?

SWIG handles this with typemaps. Does this mean that whatever replaces SWIG would also require a typemap DSL?

---
http://wagerlabs.com | @wagerlabs | http://www.linkedin.com/in/joelreymont







^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Caml-list] Re: replacing swig
  2011-01-06 12:20 [Caml-list] replacing swig Joel Reymont
@ 2011-01-06 12:31 ` Joel Reymont
  2011-01-06 13:15 ` [Caml-list] " Adrien
  1 sibling, 0 replies; 3+ messages in thread
From: Joel Reymont @ 2011-01-06 12:31 UTC (permalink / raw)
  To: caml-list

An even better question...

How would you create C/C++ function signature annotations in OCaml + Camlp4, without requiring a DSL?

Can this be done and is this desirable?

On Jan 6, 2011, at 12:20 PM, Joel Reymont wrote:

> Suppose you are writing a SWIG replacement based on gccxml, gcc plugins, etc. 
> 
> How would you figure out if the user meant char** as a pointer to a string vs an array of characters?
> 
> SWIG handles this with typemaps. Does this mean that whatever replaces SWIG would also require a typemap DSL?

---
http://wagerlabs.com | @wagerlabs | http://www.linkedin.com/in/joelreymont







^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Caml-list] replacing swig
  2011-01-06 12:20 [Caml-list] replacing swig Joel Reymont
  2011-01-06 12:31 ` [Caml-list] " Joel Reymont
@ 2011-01-06 13:15 ` Adrien
  1 sibling, 0 replies; 3+ messages in thread
From: Adrien @ 2011-01-06 13:15 UTC (permalink / raw)
  To: Joel Reymont; +Cc: caml-list

Hi,

You need annotations in the code. There's just no way to guess this.
And you'd have to guess for out-parameters too, and maybe also
"ownership" (who will have to free the object), and length of arrays
(end delimiters)...


For an overview of which kind of info you want, see:
  http://live.gnome.org/GObjectIntrospection/Annotations


As you'll see, there is a project named gobject-introspection: the
annotations in comments around functions are parsed and an XML file is
created.
I started a project named "ocaml-gir" to take advantage of that and,
really didn't enjoy working with it. I've actually stopped developping
it completely: I've even emptied git HEAD so people are less likely to
use it.
Working with a bad tool outputting bad data wasn't a lot of fun.

I then started "cowboy"[1] which uses yacfe to parse source files,
simplifies its output a bit and then parses the gobject annotations to
create bindings. It's possible to do do that for non-gobject projects
too.
There should be more info in the announcement from a few months
ago[2]. I've had no time to spend on the documentation unfortunately
but if you need help/details, I'll help (although, not before
saturday).


You might also want to look at qtcaml[3]. It interfaces with gccxml
and it should also be possible to use this interface and only write an
"adapter" like you'd do with cowboy.


Whatever you do, unless you have a magic wand, you will need
annotations and a "regular" interface: it should follow a set of
standards/rules. If you have troubles remembering the interface, how
could you make a computer understand it?
Changing the interface of the project won't be possible usually but
adding annotations upstream shouldn't be a problem. It might take time
but you'll probably get help from the project members.


[1] http://git.ocamlcore.org/cgi-bin/gitweb.cgi?p=cowboy/cowboy.git;a=summary
[2] http://caml.inria.fr/pub/ml-archives/caml-list/2010/08/9b3412eabe356c5740441fb017d84911.en.html
[3] http://qt-caml.crapulion.org/trac


Regards,

Adrien Nader

On 06/01/2011, Joel Reymont <joelr1@gmail.com> wrote:
> Suppose you are writing a SWIG replacement based on gccxml, gcc plugins,
> etc.
>
> How would you figure out if the user meant char** as a pointer to a string
> vs an array of characters?
>
> SWIG handles this with typemaps. Does this mean that whatever replaces SWIG
> would also require a typemap DSL?
>
> ---
> http://wagerlabs.com | @wagerlabs | http://www.linkedin.com/in/joelreymont
>
>
>
>
>
>
>
> --
> Caml-list mailing list.  Subscription management and archives:
> https://sympa-roc.inria.fr/wws/info/caml-list
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
>
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-01-06 13:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-06 12:20 [Caml-list] replacing swig Joel Reymont
2011-01-06 12:31 ` [Caml-list] " Joel Reymont
2011-01-06 13:15 ` [Caml-list] " Adrien

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).