I started on a libusb wrapper for a project I'm working on, and I thought I would try to make it into a working Babel package soon. First I have some questions though.
You can see what I currently have right here: https://github.com/skyfex/kiosk/blob/master/libusb.nim
Any other comments to the code is welcome.
The separate c2nim which is available through babel should provide a version which sorts enums. Hmm... the nimrod tree still has c2nim.
It seems finalizers are deprecated and the future is the destructor pragma.
I did the low level C vs high level nimrod split for midnight_dynamite and it works very well. But that's an implementation detail I decided to help me update the underlaying C library in the future with less pain. Since you are planning on offering the module through babel I think it would be enough to mark only the higher level as exported procs and then through nimdoc you document those bits. Most users won't look at the c2nim generated versions so it won't matter much if they are all mixed up in the same source file.
The alias issue you mention is weird, you mean that type type DeviceDescriptor* = libusb_device_descriptor somehow prevents you from accessing the fields? Aliasing is used in various places of the standard library and seems to work fine
and a "usb" package, which will have a more Nimrodic interface (exceptions, iterators, garbage collection, all the goodies)
Fine -- would be a nice example for a high level wrapper. (I used the old libusb some years ago from C.)
The separate c2nim which is available through babel should provide a version which sorts enums.
Interesting -- it took me some hours to do the manually sorting for GTK3 :-(
Gradha:
I just meant that if I have a struct
type:
libusb_bar = object
...
libusb_foo = object
name: libusb_bar
And i do
type Bar = libusb_bar
type Foo = libusb_foo
Then the type of Foo.name is libusb_bar, not Bar as I wanted. It shouldnt cause any restrictions I suppose, but Im thinking it could cause confusion to users (in error messages and so on). Also might be problem when generating documentation for the nimrodic wrapper.
That's essentially the same problems you get with C's typedef aliasing. You could also write the aliases in the original block to use them if you consider them so important.
type:
libusb_bar = object
...
libusb_foo = object
name: Bar
Bar = libusb_bar