Vala 和Genie 之间的关系很像js 和CoffeeScript 之间的关系。
js 和 cs 可以通过 $ coffee -bc
和 $ js2coffee
相互编译。 Genie 和 Vala 怎么样?
最佳答案
您可以使用 valac --dump-tree 将 Genie 转换为 Vala。从 Vala 到 Genie 的转换有点复杂,因为 libvala 中的 Vala.CodeWriter 类只输出 Vala,而不是 Genie。通过对 Vala.CodeVisitor 进行子类化(就像 Vala.CodeWriter 所做的那样),可能可以创建输出 Genie 的东西,但目前还没有人这样做。
也就是说,我完全不知道您为什么想要这样做。您可以在同一个 valac 调用中自由混合 Genie 和 Vala 文件。
修改来自 http://live.gnome.org/Genie 的示例, 将其放入 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
这在 mix-vala.vala 中:
private static int main (string[] args) {
var foobar = new Foo (10);
var foobar2 = new Foo.with_bar (10);
return 0;
}
然后用类似的东西编译
valac -o mix mix-genie.gs mix-vala.vala
关于compilation - 有什么办法可以在 Vala 和 Genie 之间进行编译吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8653620/