ValaとGenieの関係は、jsとCoffeeScriptの関係によく似ています。$ coffee -bc
jsとcsは、とを使用して相互にコンパイルできます$ js2coffee
。ここの魔神とヴァラはどうですか?
1 に答える
4
valac --dump-treeを使用して、GenieからValaに変換できます。libvalaのVala.CodeWriterクラスはValaのみを出力し、Genieは出力しないため、ValaからGenieへの変換は少し複雑です。Vala.CodeVisitorをサブクラス化することでGenieを出力するものを作成することはおそらく可能ですが(Vala.CodeWriterと同じように)、まだ誰もそうしていません。
そうは言っても、なぜあなたがそうしたいのか、私にはまったくわかりません。同じ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
于 2011-12-28T17:49:33.643 に答える