When I previously wrote that Rust is to the same level as my previous Ruby extensions generator. It was and is, yes, ready to build Ruby-Hunspell, to the point that the current GIT head of this one is currently only based on Rust and thus depends n it, but I did forget one thing. When I converted ruby-hunspell from a hand-crafted C source file to a generated extension, I indeed extended the generator to add a few more cases that were needed for hat particular task, but RubyTag++ was already covering a lot more tasks, that I still haven’t covered in Rust.
But this is not a bad news anyway, the work is starting being less messy and more comfortable, now that a pattern starts to appear. While the original generator was a mostly top-down approach, slightly object oriented, but with a lot of if and case conditions to abstract the various differences between a method and a constructor and between parameters, this time I’ve started to use a more object oriented approach, as it should happen with Ruby.
Just tonight I found a pretty good abstraction: everything that is described in the interface description file (beside the bindings object itself) is an Element, that can contain more children Elements; every Element provides to the bindings a declaration (that also contains the declarations of its children), a definition (that also contains the definitions of its children) and an initialization (that also contains the initializations of its children), these are the three main components for Ruby bindings, the first two are simply instances of the respective C/C++ concepts, while the latter is simply the content of the initialisation function for the extension itself, where modules, classes and so on are registered with Ruby.
So while I’m developing Rust, and adding more complex features, I start actually reducing the code and making it more easily readable. By moving the C/C++ code on separate files, also, I’ve made that also more readable, even if that means wasting some space to contain them.
What is missing right now to convert RubyTag++ to Rust? Well, quite a lot of code, constants I just added tonight, but then attributes have to be added too, with their set/get structure, and inheritance has to be tweaked, as right now is likely not working, and I have to get a better support for sub-modules, and classes within classes.
But I also implemented a few things that were missing or pretty much unusable in the previous generator of course, for instance you can now describe custom methods inline in the description without having YAML for describing a template, and you can just make some differences between the methods if they are slight: the description file is in Ruby, so you can use variables and treat them how you prefer. And I started adding support for classes wrapping around C interfaces, together with the start of ruby-xine bindings (that will be my real-world scenario to keep in a working state).
When I started, I decided I wanted to write as many test cases as I could to make sure that I didn’t introduce regressions between the versions; unfortunately I haven’t been able to write more than a couple of testcases up to now, but I’ve being using ruby-hunspell and ruby-xine as my test suite… this is not going to work well on the long run, so tomorrow I’ll see to add some more test cases describing the features I added tonight, hopefully this way I can just run Rust’s test directory (that uses a pretty old-style Makefile to run the tests, but I haven’t being able to understand Rakefile correctly.. unless it is just a way to invoke system from ruby, and thus has no advantage over make other than not requiring make installed) rather than building two extensions and run their testsuites (actually ruby-xine still hasn’t had a testsuite, but it will have tomorrow, it will also be quite easy, as I just need, as a “testsuite”, a single unit with a few tests, at least for now).
I’ll remember again for who’s interested, the rust site is at RubyForge, there’s a rust-devel mailing list, you can subscribe to ask questions or propose patches, enhancements and similar, there’s also a CIA project page that I just set up (thanks Micah for your site that is improving a lot lately!) where you can follow the updates; as soon as I ge something working with ruby-xine, you’ll find that also as a GIT repository under Rust.
And now the questions are: will I be able to write an user (as in person using it, not the kind of final user one expects) documentation for Rust? And, how can I focus some attention on Rust so that there will be someone else but me interested in it? 🙂
I know that by starting ruby-xine I’m likely to get the attention of Luis (metalgod), but that’s hardly enough, logically.
Update (2017-04-22): as you may know, Rubyforge was shut down in 2014. Unfortunately that means that most of the Rust documentation and repository are probably gone (I may have backups but I have not uploaded them anywhere).