In article <20030413004111.A80880 / beaver.net>,
Doug Beaver  <doug / beaver.net> wrote:
>hello,
>
>i'm curious if anyone out there is using ruby reflection to generate
>code for other languages.  i love using ruby to prototype classes and
>their interactions, especially if i can't decide on a design and need to
>try a few different implementations.  i'm writing lots of c++ and
>objective c these days, and it's much harder to turn around and quickly
>refactor class designs.
>
>has anyone tried using ruby's reflection to prototype classes in ruby
>and then render the class structure to other languages?  i've started
>working along these lines so that i can call #render_objc on any object
>and get back two big strings, one for the header and one for the source.
>i use reflection to pull out instance variables and check their type, so
>a ruby array turns into a NSMutableArray *, hash to NSMutableDictionary
>*, etc, etc.  i just look at variables, classes and methods with
>reflection, i don't parse the ruby code or try to do anything smart with
>it yet.  the methods in the target language are just stubs.
>
>eventually, i would like to take the ruby code inside my methods and
>stick that as a comment inside the generated methods in my target
>language.  then i can use ruby for RAD and generate stubs in my target
>language along with ruby code in comments so i can remember what each
>method was supposed to do.  then i can move through the methods, porting
>the ruby code to my target language and getting a finished product more
>quickly.
>
>anyone else going down this road?  perhaps you have some advice or
>pointers to examples you've found?  i'm not sure it's going to work
>100%, but i'm hoping it will allow me to save time.  if anyone's
>interested, i can post code once i fix some bugs and clean it up.  if i
>get something useful, i'm going to try this for c++ and perl as well.
>
>thanks,
>
>doug

I'm not currently doing this, but I do kind of want to be able to convert 
RHDL to VHDL and/or Verilog which would entail some similar effort 
(actually, it would probalby be harder).

At any rate, I really would be interested in seeing your code to generate 
objective C and/or C++, can you post this or submit it to the RAA?

Phil