0

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では毎回失敗します。何か案が ?私は何の役にも立たずに数日間これを叩いています:(

4

1 に答える 1

0

IBusFactoryの場合:

"connection"               IBusConnection*       : Read / Write / Construct Only

ドキュメントには"Construct Only"。それは今のところ解釈の対象ですが、それはおそらく私的または保護されたクラスのメンバーであることを意味します。とはいえ、コンストラクターは次のように定義されています。

IBusFactory *       ibus_factory_new                    (IBusConnection *connection);

コンストラクターには、その接続変数があります。正確にそのように提供すると、アプリは正常に機能することに注意してください。

const IBus = imports.gi.IBus;
//get the ibus bus
var bus = new IBus.Bus();
if(bus.is_connected()){
    var factory = new IBus.Factory(bus.get_connection());
}

さてfactory.add_engine()、定義はここにあります:

void                ibus_factory_add_engine             (IBusFactory *factory,
                                                         const gchar *engine_name,
                                                         GType engine_type);

つまり、engine_nameおよびengine_typeを関数パラメーターとして指定する必要があります。これは機能します:

factory.add_engine('ibus-engine-name', some-engine-type);

エンジンのアイデアについては、 http://ibus.googlecode.com/svn/docs/ibus/ch03.htmlを参照してください。このコードはセグメンテーション違反ではありませんが、どちらも機能しません。add_engine()の2番目のパラメータまでの正しい構文を示します。

#!/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(bus.get_connection());
    factory.add_engine("ibus-sarim", typeof(this));
}
于 2012-01-15T04:49:45.670 に答える