GObjectIntrospectionを使用すると、Cオブジェクトを任意の高級言語で使用できます。https://live.gnome.org/GObjectIntrospection
IBusは、Linux用の入力方式フレームワークです。code.google.com/p/ibus
GObjectIntrospection/javascriptの使用に少し問題があります。ibusエンジンを作ってみました。同じコードがvala、pythonで機能します。しかし、javascriptのセグメンテーション違反で。私はopenSUSE12.1gnome3を使用しています。「ibus-devel」パッケージは、GObjectIntrospectionに必要な/usr/share/gir-1.0/IBus-1.0.girを提供します。
次のコードを実行しようとしています。
#!/usr/bin/env gjs
const IBus = imports.gi.IBus;
//get the ibus bus
var bus = new IBus.Bus();
if(bus.is_connected()){
var factory = new IBus.Factory({
connection: bus.get_connection()
});
factory.add_engine({
engine_name:"ibus-sarim",
engine_type:typeof(this)
});
}
「newIBus.Factory」の6行目でクラッシュします。
ターミナル出力、
(gjs:13353): GLib-GIO-CRITICAL **: g_dbus_connection_register_object:
assertion `object_path != NULL && g_variant_is_object_path
(object_path)' failed
Segmentation fault
どこに問題があるのかわかりません。https://github.com/ibus/ibus/blob/master/bindings/vala/test/enchant.valaでibusに付属のvalaテストコードを試しました 。コンパイルして正常に実行されます。enchant.vala行148で、
var factory = new Factory(bus.get_connection());
Factoryを作成するためのコードは、javascriptで試したものと同じです。Pythonでも、
from gi.repository import IBus
from gi.repository import GLib
from gi.repository import GObject
IBus.init()
bus = IBus.Bus()
if bus.is_connected():
factory = IBus.Factory.new(bus.get_connection())
これも正常に機能しているようで、セグメンテーション違反はありません。しかし、javascriptでは毎回失敗します。何か案が ?私は何の役にも立たずに数日間これを叩いています:(