compilation - 有什么办法可以在 Vala 和 Genie 之间进行编译吗?

标签 compilation vala genie

Vala 和Genie 之间的关系很像js 和CoffeeScript 之间的关系。 js 和 cs 可以通过 $ coffee -bc$ js2coffee 相互编译。 Genie 和 Vala 怎么样?

最佳答案

您可以使用 valac --dump-tree 将 Genie 转换为 Vala。从 Vala 到 Genie 的转换有点复杂,因为 libval​​a 中的 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/

相关文章:

vala - Genie 中泛型方法的语法是什么?

Gtk.在 Sprite 中的应用

macos - 如何编译 Fortran 代码以在未安装 gfortran 的情况下运行

machine-learning - 幕府将军安装窗口

gtk - forward_display_line 不起作用

localization - Vala、资源和本地化

c++ - 编译单元和静态链接问题

linux - glWindowPos2i 未在此范围内声明

gcc - 如何修复警告: missing braces around initializer?

vala - 我如何将该程序从 Vala 翻译为 Genie?