[Cython] [cython-users] ANN: XDress v0.1 -- Automatic Code Generator and C/C++ Wrapper

Anthony Scopatz scopatz at gmail.com
Tue Apr 2 21:52:39 CEST 2013


On Tue, Apr 2, 2013 at 2:17 PM, Dag Sverre Seljebotn <
d.s.seljebotn at astro.uio.no> wrote:

> [Crossing over to cython-devel to discuss further development]
>
> Wow, my first impression is this looks great!
>

Thanks Dag!


> It's a shame that clang wasn't able to give a good enough parse tree for
> templates


Yeah, this was pretty infuriating since it is the last part of a visitor
pattern that you write.  To be clear though, this wouldn't be super hard
for them to expose it would just take some work and then some effort to get
the Clang people to merge these changes back into their mainline.  They are
open to this kind of activity and Eli has a great blog post describing the
process in brutal detail [1].   I just personally don't have time to go
down this road.


> Is gcc-xml still a fork of a really old gcc?


Hmm, now that you mention it, I am not sure.  The website gives conflicting
information on how much of an extension / plugin it is.  However, gccxml
does support gcc 4.7 so it can't be that old.


> Did you look into the code using the gcc plugin architecture that Phillip
> Heron worked on in the GSoC last year for this?
>

No, I didn't even know about it! Though pxd generation is only part of what
xdress does, it will be good to look at.

Be Well
Anthony

1. http://eli.thegreenplace.net/2011/07/03/parsing-c-in-python-with-clang/


>
> Also, Cython devs, where's the wiki page listing all the wrapper
> generators in existence? I tried to find it but couldn't..
>
> Dag Sverre
>
>
> On 04/02/2013 08:26 PM, Anthony Scopatz wrote:
>
>> Hello All,
>>
>> I am spamming the lists which may be interested in a C/C++ automatic
>> API wrapper / code generator / type system / thing I wrote.  I'll keep
>> future updates more discrete.  I'd love to help folks get started with
>> this
>> and more participation is always welcome!  Release notes are below.
>>
>> Please visit the docs: http://bit.ly/xdress-code
>>
>> Or just grab the repo: http://github.com/scopatz/**xdress<http://github.com/scopatz/xdress>
>>
>> Be Well
>> Anthony
>>
>> ========================
>> XDress 0.1 Release Notes
>> ========================
>> XDress is an automatic wrapper generator for C/C++ written in pure
>> Python. Currently,
>> xdress may generate Python bindings (via Cython) for C++ classes &
>> functions
>> and in-memory wrappers for C++ standard library containers (sets,
>> vectors, maps).
>> In the future, other tools and bindings will be supported.
>>
>> The main enabling feature of xdress is a dynamic type system that was
>> designed with
>> the purpose of API generation in mind.
>>
>> Release highlights:
>>
>>    - Dynamic system for specifying types
>>    - Automatically describes C/C++ APIs from source code with no
>> modifications.
>>    - Python extension module generation (via Cython) from C++ API
>> descriptions
>>    - Python views into C++ STL containers.  Vectors are NumPy arrays
>> while maps
>>      and sets have custom collections.MutableMapping and
>> collections.MutableSet
>>      subclasses.
>>    - Command line interface to the above tools.
>>
>> Please visit the website for more information: http://bit.ly/xdress-code
>>
>> Or grab the code from GitHub: http://github.com/scopatz/**xdress<http://github.com/scopatz/xdress>
>>
>> XDress is free & open source (BSD 2-clause license) and requires Python
>> 2.7,
>> NumPy 1.5+, PyTables 2.1+, Cython 0.18+, GCC-XML, and lxml.
>>
>> New Features
>> ============
>>
>> Type System
>> -----------
>> This module provides a suite of tools for denoting, describing, and
>> converting
>> between various data types and the types coming from various systems.
>>   This is
>> achieved by providing canonical abstractions of various kinds of types:
>>
>> * Base types (int, str, float, non-templated classes)
>> * Refined types (even or odd ints, strings containing the letter 'a')
>> * Dependent types (templates such arrays, maps, sets, vectors)
>>
>> All types are known by their name (a string identifier) and may be
>> aliased with
>> other names.  However, the string id of a type is not sufficient to
>> fully describe
>> most types.  The system here implements a canonical form for all kinds
>> of types.
>> This canonical form is itself hashable, being comprised only of strings,
>> ints,
>> and tuples.
>>
>> Descriptions
>> ------------
>> A key component of API wrapper generation is having a a top-level,
>> abstract
>> representation of the software that is being wrapped.  In C++ there are
>> three
>> basic constructs which may be wrapped: variables, functions, and classes.
>> Here we restrict ourselves to wrapping classes and functions, though
>> variables
>> may be added in the future.
>>
>> The abstract representation of a C++ class is known as a description
>> (abbr. desc).
>> This description is simply a Python dictionary with a specific structure.
>> This structure makes heavy use of the type system to declare the types
>> of all needed
>> parameters.
>>
>> Mini-FAQ
>> ========
>> * Why not use an existing solution (eg, SWIG)?
>>
>>      Their type systems don't support run-time, user provided refinement
>> types,
>>      and thus are unsuited for verification & validation use cases that
>> often
>>      arise in computational science.
>>
>>      Furthermore, they tend to not handle C++ dependent types well (i.e.
>> vector<T>
>>      does not come back as a np.view(..., dtype=T)).
>>
>> * Why GCC-XML and not Clang's AST?
>>
>>      I tried using Clang's AST (and the remnants of a broken visitor
>> class remain
>>      in the code base).  However, the official Clang AST Python bindings
>> lack
>>      support for template argument types.  This is a really big deal.
>> Other C++ ASTs
>>      may be supported in the future -- including Clang's.
>>
>> * I run xdress and it creates these files, now what?!
>>
>>      It is your job to integrate the files created by xdress into your
>> build system.
>>
>> Join in the Fun!
>> ================
>> If you are interested in using xdress on your project (and need help),
>> contributing
>> back to xdress, starting up a development team, or writing your own code
>> generation
>> front end tool on top of the type system and autodescriber, please let
>> me know.
>> Participation is very welcome!
>>
>> Authors
>> =======
>> XDress was written by `Anthony Scopatz <http://scopatz.com/>`_, who had
>> many
>> type system discussions with John Bachan over coffee at the Div school,
>> and was
>> polished up and released under the encouragement of Christopher
>> Jordan-Squire at
>> `PyCon 2013 <https://us.pycon.org/2013/>`_**.
>>
>> --
>>
>> ---
>> You received this message because you are subscribed to the Google
>> Groups "cython-users" group.
>> To unsubscribe from this group and stop receiving emails from it, send
>> an email to cython-users+unsubscribe@**googlegroups.com<cython-users%2Bunsubscribe at googlegroups.com>
>> .
>> For more options, visit https://groups.google.com/**groups/opt_out<https://groups.google.com/groups/opt_out>
>> .
>>
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/cython-devel/attachments/20130402/b3e8354c/attachment-0001.html>


More information about the cython-devel mailing list