3

The relationship between Vala and Genie are much like that between js and CoffeeScript. js and cs can compile from each other with $ coffee -bc and $ js2coffee. How about Genie and Vala here?

jiyinyiyong
  • 4,586
  • 7
  • 45
  • 88

1 Answers1

4

You could use valac --dump-tree to convert from Genie to Vala. Converting from Vala to Genie is a bit more complicated since the Vala.CodeWriter class in libvala only outputs Vala, not Genie. It would probably be possible to create something which outputs Genie by subclassing Vala.CodeVisitor (just like Vala.CodeWriter does), but nobody has done so yet.

That said, I have absolutely no idea why you would want to. You can freely mix Genie and Vala files within the same valac invocation.

Modifying an example from http://live.gnome.org/Genie, put this in mix-genie.gs:

[indent=4]

class Foo : Object
    prop a : int

    init     
        print "foo is intitialized"

    final
        print "foo is being destroyed"

    /* only class properties may be set in creation methods */    
    construct (b : int)
        a = b

    /* only class properties may be set in creation methods */        
    construct with_bar (bar : int)
        a = bar

And this in mix-vala.vala:

private static int main (string[] args) {
  var foobar = new Foo (10);
  var foobar2 = new Foo.with_bar (10);

  return 0;
}

And compile with something like

valac -o mix mix-genie.gs mix-vala.vala
nemequ
  • 16,623
  • 1
  • 43
  • 62
  • Compiling from Genie seems enough powerful to me. I tried to learn Genie(degusted about curly brackets and too many words), thinking about to read Vala's docs to learn more. So if there's a tool can translate between both, it will help. – jiyinyiyong Dec 29 '11 at 02:54
  • 1
    I'm currently working on a project that's about 90% python and 10% vala. It would be neat if I could convert the Vala into Genie just for the sake of looking more like the python code that makes up most of the project. – robru Feb 10 '13 at 19:14