Issac wrote: > > Of all the ways to extend Python with C++, my favorite is Boost.Python > http://www.boost.org/libs/python/doc/ . > Does something like this exist for Ruby? I have written something almost but not quite entirely unlike it ;). To wit, the CGenerator module in RAA, and the forthcoming (this weekend if I'm not too lazy) CShadow module. Disclaimer: it works with C code, not C++. (I wrote C++ code for two years, and that's enough. Seriously, though, it would be a good idea for it to work with C++ as well.) CGenerator is a Ruby interface to the Ruby C API. It lets you define and load methods dynamically, and it does much of the housekeeping (rb_define_method, argument counts, argument parsing using rb_scan_args, initialization, declaration of symbols and classes, etc.). What's especially nice for my applications (and the reason I wrote it) is that you can generate C code programmatically, based on (in my case) numerical formulas provided in the executing script. You can also work with existing C libraries, but probably not well as Boost or SWIG. CGenerator doesn't currently include anything to parse prototypes, for example, though generating wrappers from the parser output would be easy. CShadow helps you integrate C and Ruby data in your objects. It's a mix-in that uses CGenerator to give your Ruby class a "shadow struct", which is a C struct attached to the object via the Data_Make_Struct macro and friends. This struct can have various members, called shadow attributes, which can be C data types or references to Ruby objects. These attributes are inherited in Ruby subclasses, which can add shadow attributes of their own. Some of the housekeeping is managed for you: accessor methods, the new method, type checking and conversion, mark and free functions, and (this one won't be done for a while) serialization. At the moment, these simple C structs, with their associated Ruby objects, are enough for my purposes, but it would be quite nice to allow a C++ object as the "shadow" of a Ruby object. It looks like Boost.Python would be a good source of ideas for this project. -- Joel VanderWerf California PATH, UC Berkeley mailto:vjoel / path.berkeley.edu Ph. (510) 231-9446 http://www.path.berkeley.edu FAX (510) 231-9512