After thinking about it some more, I realised that bindgen works perfectly for generating the low-level C layer, and that the custom codegen can then just handle the OOP layer on top of it.
I did a quick hack here, and after a few signature changes it all just worked: https://github.com/martindemello/wxRust/commits/bindgen martin On Sat, Oct 5, 2013 at 9:54 PM, Martin DeMello <[email protected]> wrote: > I took a closer look, and now think bindgen may not be the way to go > for this. The wxc layer uses a bunch of custom C macros to provide > extra information to binding generators, and generating bindings from > the preprocessed C source throws all that information away. Might be > worth taking a closer look at what the Haskell bindings are doing with > the wxc headers and trying to reproduce that in wxRust. > > martin > > On Fri, Sep 27, 2013 at 8:51 PM, KENZ gelsoft <[email protected]> wrote: >> I tried rust-bindgen finally, and it worked excellently. Great work!! >> >> Since it requires Clang 3.3 which doesn't exist on OS X 10.8 setup, >> I tried commit 3d49dbbbb7bcc0cf63b43a16a6cf52480fa9b752 and some tweak. >> >> And some arguments are needed, for my project: >> >> $ ./bindgen -x c++ ../wxRust/wxHaskell/wxc/src/include/wxc.h >> `wx-config --cflags` --include stdint.h --include time.h > >> ../wxRust/generated.rs >> >> bindgen is C mode as default like clang or gcc are, so I understand it >> requires `-x c++` option, >> but I don't know why I have to explicitly include stdint.h and time.h >> for size_t and uint8_t. >> Do you have another recommended options? >> >> My codegen.py just handles functions, so handling for other >> definitions benefits. >> So I want adopt rust-bindgen to generate extern fn part of my binding >> for long-term plan. >> >> Despite I know its Clang requirement changed for bitwidth support, but >> as a Mac developer, I don't want to install the Clang 3.3 only for >> rust-bindgen, >> especially I don't want add a new prerequisite to my library. >> Are there a posibility of optional Clang 3.1 support (without bitwidth >> support)? >> >> >> >> 2013/9/26 Martin DeMello <[email protected]>: >>> no, but it might be feasible to add. not sure if it'd fall within the >>> scope of bindgen or not, but at least bindgen could emit some sort of >>> serialised data structure that would make generating the next level >>> binding easier. >>> >>> martin >>> >>> On Wed, Sep 25, 2013 at 4:49 PM, KENZ gelsoft <[email protected]> >>> wrote: >>>> Oh, I didn't know that project, thank you for information. I'll try it. >>>> BTW, I chose to make own parser and generator to generate not only extern >>>> fn >>>> decls but also next-level wrapper such as: >>>> >>>> trait Frame { >>>> pub fn show(&self) { >>>> unsafe { >>>> wxFrame_Show(self.handle()); >>>> } >>>> } >>>> } >>>> >>>> or so, would bindgen helps this use case? (c.f. parsed data accessible or >>>> so.) >>>> >>>> Did you try using bindgen on the wxc header file? If there were bits >>>> it couldn't handle, I'd be interested in helping fix that. >>>> >>>> martin >>>> >>>> On Wed, Sep 25, 2013 at 10:49 AM, KENZ gelsoft <[email protected]> >>>> wrote: >>>>> Hello, everyone. >>>>> >>>>> I would like to introduce my experimental project, wxRust. >>>>> Which is a wxWidgets binding for Rust. >>>>> >>>>> https://github.com/kenz-gelsoft/wxRust >>>>> >>>>> This binding is based on the wxHaskell especially its "wxc"*1 >>>>> C-Language wxWidgets binding part. >>>>> >>>>> Currently, it just converts wxc's header file to `extern fn`s and >>>>> export them as a rust library. >>>>> >>>>> Test program has just started working which opens a wxFrame >>>>> by calling wxc's C interface from extern fn. >>>>> >>>>> Current state is pre-alpha experimental state, there's no stable API, >>>>> hard to use, but announced here for someone planning similar project. >>>>> >>>>> I'm planning for next generating simple OOP style wrapper as rust >>>>> traits for each classes from wxc's header. >>>>> >>>>> There is many problems to tackle, for example how it can work >>>>> with multitask or, library users can write wx GUI programs easier. >>>>> Any helps or feedbacks are welcome. >>>>> >>>>> *1: [http://www.haskell.org/haskellwiki/WxHaskell#Status] >>>>> >>>>> >>>>> Thanks, >>>>> -- >>>>> KENZ <[email protected]> >>>>> >>>>> >>>>> _______________________________________________ >>>>> Rust-dev mailing list >>>>> [email protected] >>>>> https://mail.mozilla.org/listinfo/rust-dev >>>>> _______________________________________________ Rust-dev mailing list [email protected] https://mail.mozilla.org/listinfo/rust-dev
