ある映画で見たシーン:インドを夜行列車で旅する主人公、失踪した友人を探して欧州(多分英国)からインドへはるばるやって来た。窓の外は夜の帳。主人公の顔が窓に映える。そこに流れる映画音楽:ベートーベンの弦楽四重奏7番の第3楽章。瞑想的な音楽が主人公の内面の旅に趣を添える。
映画の名前も監督の名前も忘れてしまったが、音楽とそれが使われたシーンは鮮明に憶えている。この曲は冬の夜に仕事部屋で聴くのにふさわしい。哲学的で暖かい。
音楽は容易に記憶に結びつく。ヨハン・シュトラウスの”美しき青きドナウ”を聴くと多くの人が宇宙飛行士の遊泳のシーンを思い浮かべるかもしれない。音のない宇宙遊泳のシーンに、華やかなワルツが流れるその意外な効果。ウィーンフィルのニューイヤーコンサートでこの曲を聴いていつも思い浮かぶのは、宇宙遊泳のシーンなのだ。
----------------------------------------------------------------------------
原文: 青色表示
訳文: 黒色表示
注記/訂正: 赤色表示
The syntax of XPIDL is straightforward:
#include "domstubs.idl";
[scriptable, uuid(xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)]
interface nsIDOMFabian : nsISupports
{
void fabian();
readonly attribute boolean neat;
};
XPIDL の構文は簡単です:
#include "domstubs.idl";
[scriptable, uuid(xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)]
interface nsIDOMFabian : nsISupports
{
void fabian();
readonly attribute boolean neat;
};
This is the definition of the nsIDOMFabian interface. The uuid of the interface is a unique identifier. Every interface needs one. You can generate *1them using guidgen on windows, or by issuing the command "mozbot uuid" in #mozilla on irc.mozilla.org.
これが nsIDOMFabian インターフェイスの定義です。インターフェイスの uuid は一意の識別子であり、すべてのインターフェイスに 1 つ必要です。ウインドウで guidgen を使うか、また irc.mozilla.org の #mozilla で "mozbot uuid" コマンドを発行して uuid を生成できます。
*1→正しくは"it = an unique identifier"と単数の代名詞となるべき?
At compile-time, the XPIDL compiler will turn this interface definition into real C++ code, a header file that will contain the pure abstract class. This class will look like this:
#define NS_IDOMFABIAN_IID
{0xxxxxxxxx, 0xxxxx, 0xxxxx,
{ 0xxx, 0xxx, 0xxx, 0xxx, 0xxx, 0xxx, 0xxx, 0xxx }}
class nsIDOMFabian : public nsISupports {
public:
NS_IMETHOD Fabian(void) = 0;
NS_IMETHOD GetNeat(PRBool *aNeat) = 0;
};
#define NS_DECL_NSIDOMFABIAN
#define NS_FORWARD_NSIDOMFABIAN(_to)
#define NS_FORWARD_SAFE_NSIDOMFABIAN(_to)
コンパイル時に、XPIDL コンパイラはこのインターフェイスの定義を実際の C++ コードに変換しますが、これは純粋な抽象クラスを備えたヘッダファイルです。このクラスは以下のようになっています:
#define NS_IDOMFABIAN_IID
{0xxxxxxxxx, 0xxxxx, 0xxxxx,
{ 0xxx, 0xxx, 0xxx, 0xxx, 0xxx, 0xxx, 0xxx, 0xxx }}
class nsIDOMFabian : public nsISupports {
public:
NS_IMETHOD Fabian(void) = 0;
NS_IMETHOD GetNeat(PRBool *aNeat) = 0;
};
#define NS_DECL_NSIDOMFABIAN
#define NS_FORWARD_NSIDOMFABIAN(_to)
#define NS_FORWARD_SAFE_NSIDOMFABIAN(_to)
As we can see, the auto-generated header file contains the IID of our interface, and a "pure abstract class" is correctly defined. The XPIDL compiler turns the IDL methods and attributes into C++ functions according to the following rules:
見て分かるとおり、自動生成のヘッダは私たちのインターフェイスの IID を備えており、”純粋な抽象クラス”は正しく定義されます。XPIDL コンパイラは IDL メソッドと属性を以下のルールに従って C++ の関数へ変換します:
The methods of the interface keep the same name in C++. However in IDL we have to use the so-called "interCaps" model. That means that the first letter is lower-cased, and the other letters that begin a new word are upper-cased. For example, in IDL we'd write getElementById, which in C++ would be translated to GetElementById.
インターフェイスのメソッドは C++ でも同じ名前を保持します。しかし IDL ではいわゆる "interCaps" モデルを使用しなければなりません。つまり最初の文字は小文字になり、そのあとの新しい単語の最初の文字は大文字になります。たとえば、IDL では getElementById と書くので、C++ では GetElementById に翻訳されることになります。
NS_IMETHOD is a macro that basically means "virtual nsresult". The argument list and return type are turned into correct C++ types according to rules not described here.
NS_IMETHOD は基本的に "virtual nsresult" を意味するマクロです。ここでは解説していませんがルールに従って、引数のリストと戻り値の型は正しい C++ の型へ変換されます。
The attributes of the interface become two functions: a getter, and a setter. In our example, since the attribute is declared as read-only, only a getter is defined: GetNeat. The argument is a pointer to an object of type PRBool, automatically generated by XPIDL. Clever uh. Note that the same interCaps model applies to IDL attributes as well.
インターフェイスの属性は 2 つの関数になります: getter と setter です。私たちの例では、属性は read-only で宣言されるので、getter だけが定義されます: GetNeat です。引数は自動的に XPIDL によって生成される PRBool 型のオブジェクトへのポインタです。賢いですね。同じ interCaps のモデルが同様に IDL の属性へ適用されることに注意してください。
The three macros are explained in detail in Section 1.E.d. The next step is to build our new interface.
1.E.d で 3 つのマクロが詳細に解説されます。次のステップは新しいインターフェイスをビルドすることです。
これで、XPIDL がどのようにインターフェイス定義を支援するかについて解説を終わります。
See you tomorrow! (^-^)/~~~~
映画の名前も監督の名前も忘れてしまったが、音楽とそれが使われたシーンは鮮明に憶えている。この曲は冬の夜に仕事部屋で聴くのにふさわしい。哲学的で暖かい。
音楽は容易に記憶に結びつく。ヨハン・シュトラウスの”美しき青きドナウ”を聴くと多くの人が宇宙飛行士の遊泳のシーンを思い浮かべるかもしれない。音のない宇宙遊泳のシーンに、華やかなワルツが流れるその意外な効果。ウィーンフィルのニューイヤーコンサートでこの曲を聴いていつも思い浮かぶのは、宇宙遊泳のシーンなのだ。
----------------------------------------------------------------------------
原文: 青色表示
訳文: 黒色表示
注記/訂正: 赤色表示
The syntax of XPIDL is straightforward:
#include "domstubs.idl";
[scriptable, uuid(xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)]
interface nsIDOMFabian : nsISupports
{
void fabian();
readonly attribute boolean neat;
};
XPIDL の構文は簡単です:
#include "domstubs.idl";
[scriptable, uuid(xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)]
interface nsIDOMFabian : nsISupports
{
void fabian();
readonly attribute boolean neat;
};
This is the definition of the nsIDOMFabian interface. The uuid of the interface is a unique identifier. Every interface needs one. You can generate *1them using guidgen on windows, or by issuing the command "mozbot uuid" in #mozilla on irc.mozilla.org.
これが nsIDOMFabian インターフェイスの定義です。インターフェイスの uuid は一意の識別子であり、すべてのインターフェイスに 1 つ必要です。ウインドウで guidgen を使うか、また irc.mozilla.org の #mozilla で "mozbot uuid" コマンドを発行して uuid を生成できます。
*1→正しくは"it = an unique identifier"と単数の代名詞となるべき?
At compile-time, the XPIDL compiler will turn this interface definition into real C++ code, a header file that will contain the pure abstract class. This class will look like this:
#define NS_IDOMFABIAN_IID
{0xxxxxxxxx, 0xxxxx, 0xxxxx,
{ 0xxx, 0xxx, 0xxx, 0xxx, 0xxx, 0xxx, 0xxx, 0xxx }}
class nsIDOMFabian : public nsISupports {
public:
NS_IMETHOD Fabian(void) = 0;
NS_IMETHOD GetNeat(PRBool *aNeat) = 0;
};
#define NS_DECL_NSIDOMFABIAN
#define NS_FORWARD_NSIDOMFABIAN(_to)
#define NS_FORWARD_SAFE_NSIDOMFABIAN(_to)
コンパイル時に、XPIDL コンパイラはこのインターフェイスの定義を実際の C++ コードに変換しますが、これは純粋な抽象クラスを備えたヘッダファイルです。このクラスは以下のようになっています:
#define NS_IDOMFABIAN_IID
{0xxxxxxxxx, 0xxxxx, 0xxxxx,
{ 0xxx, 0xxx, 0xxx, 0xxx, 0xxx, 0xxx, 0xxx, 0xxx }}
class nsIDOMFabian : public nsISupports {
public:
NS_IMETHOD Fabian(void) = 0;
NS_IMETHOD GetNeat(PRBool *aNeat) = 0;
};
#define NS_DECL_NSIDOMFABIAN
#define NS_FORWARD_NSIDOMFABIAN(_to)
#define NS_FORWARD_SAFE_NSIDOMFABIAN(_to)
As we can see, the auto-generated header file contains the IID of our interface, and a "pure abstract class" is correctly defined. The XPIDL compiler turns the IDL methods and attributes into C++ functions according to the following rules:
見て分かるとおり、自動生成のヘッダは私たちのインターフェイスの IID を備えており、”純粋な抽象クラス”は正しく定義されます。XPIDL コンパイラは IDL メソッドと属性を以下のルールに従って C++ の関数へ変換します:
The methods of the interface keep the same name in C++. However in IDL we have to use the so-called "interCaps" model. That means that the first letter is lower-cased, and the other letters that begin a new word are upper-cased. For example, in IDL we'd write getElementById, which in C++ would be translated to GetElementById.
インターフェイスのメソッドは C++ でも同じ名前を保持します。しかし IDL ではいわゆる "interCaps" モデルを使用しなければなりません。つまり最初の文字は小文字になり、そのあとの新しい単語の最初の文字は大文字になります。たとえば、IDL では getElementById と書くので、C++ では GetElementById に翻訳されることになります。
NS_IMETHOD is a macro that basically means "virtual nsresult". The argument list and return type are turned into correct C++ types according to rules not described here.
NS_IMETHOD は基本的に "virtual nsresult" を意味するマクロです。ここでは解説していませんがルールに従って、引数のリストと戻り値の型は正しい C++ の型へ変換されます。
The attributes of the interface become two functions: a getter, and a setter. In our example, since the attribute is declared as read-only, only a getter is defined: GetNeat. The argument is a pointer to an object of type PRBool, automatically generated by XPIDL. Clever uh. Note that the same interCaps model applies to IDL attributes as well.
インターフェイスの属性は 2 つの関数になります: getter と setter です。私たちの例では、属性は read-only で宣言されるので、getter だけが定義されます: GetNeat です。引数は自動的に XPIDL によって生成される PRBool 型のオブジェクトへのポインタです。賢いですね。同じ interCaps のモデルが同様に IDL の属性へ適用されることに注意してください。
The three macros are explained in detail in Section 1.E.d. The next step is to build our new interface.
1.E.d で 3 つのマクロが詳細に解説されます。次のステップは新しいインターフェイスをビルドすることです。
これで、XPIDL がどのようにインターフェイス定義を支援するかについて解説を終わります。
See you tomorrow! (^-^)/~~~~